www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AW999 on April 11, 2010, 10:59:51 pm

Title: Photorealistic flowing water
Post by: AW999 on April 11, 2010, 10:59:51 pm

I'm wondering if anyone has any idea how to produce an effect similar to the flowing water you can see in the following video of "Big Game Hunter 2010" at c. 4:26 onward and again c. 5:07 onward - http://www.youtube.com/watch?v=H458jdZov48&feature=related

It looks like they've got a refraction effect as well as the obvious surface foam flowing along (which is easy enough). I guess my question is: how do you produce the refraction effect?
Title: Re: Photorealistic flowing water
Post by: EgonOlsen on April 11, 2010, 11:23:42 pm
It's a shader effect, i.e. you have to write yourself some pixel/vertex shaders for this.
Title: Re: Photorealistic flowing water
Post by: AW999 on April 15, 2010, 09:05:48 pm
It's a shader effect, i.e. you have to write yourself some pixel/vertex shaders for this.

  I've been reading a bit on the subject of shaders, and apparently they have to be coded in assembly language?  I know assembly, but how is that done via jPCT ?  Is there a tutorial somewhere?
Title: Re: Photorealistic flowing water
Post by: EgonOlsen on April 15, 2010, 09:10:31 pm
No, you don't have to do it this way. You can use GLSL, which is more like a high level language...like a variant of C. You can find a simple example here: http://www.jpct.net/wiki/index.php/Shaders (http://www.jpct.net/wiki/index.php/Shaders)

However, creating a realistic water shader is an art form and once you enable shaders on an object, you'll have to do a lot on your own that the fixed function pipeline will do for you otherwise (like lighting and stuff).
Title: Re: Photorealistic flowing water
Post by: AW999 on April 16, 2010, 12:43:18 am
No, you don't have to do it this way. You can use GLSL, which is more like a high level language...like a variant of C. You can find a simple example here: http://www.jpct.net/wiki/index.php/Shaders (http://www.jpct.net/wiki/index.php/Shaders)
However, creating a realistic water shader is an art form and once you enable shaders on an object, you'll have to do a lot on your own that the fixed function pipeline will do for you otherwise (like lighting and stuff).

  You know, I'll bet they produced that flowing water effect just by making an animated texture for the underwater rocks etc, with a moving refraction pattern; then placed another object above that for the surface foam patterns etc.  Or wouldn't that work very well?
Title: Re: Photorealistic flowing water
Post by: AW999 on April 22, 2010, 01:58:59 am
Since shader code runs on the 3D graphics card (correct?), what happens if another program is also running shader code at the same time?  I would think multitasking would really foul things up here...
Title: Re: Photorealistic flowing water
Post by: EgonOlsen on April 22, 2010, 07:03:15 am
No problem. The different contexts will separate this. In fact, even non-shader graphics are using some pre-defined shaders on current hardware, so from the hardware's point of view, this makes no difference.