Been a while... (Using mesh deformation as water effect)

Soooo…



I had to take an extended break from working on my game. After multiple bug fixes (mostly to do with UI implementation), I finally got around to making use of that mesh deformation shader to produce a simple and decent looking water effect.



Here are the initial results… using Ripple and Warble together along the Y axis.



http://youtu.be/sgwzqA5-NJs



The settings are as follows:

[java]
Texture tex_Water = assetManager.loadTexture("Textures/Core/Water/Water.png");
tex_Water.setMinFilter(MinFilter.BilinearNoMipMaps);
tex_Water.setMagFilter(MagFilter.Bilinear);
tex_Water.setWrap(WrapMode.Repeat);

mat_ZoneWater = new Material(assetManager, "MatDefs/Displace.j3md");
mat_ZoneWater.setFloat("Shininess", 1f);
mat_ZoneWater.setTexture("DiffuseMap", tex_Water);
mat_ZoneWater.setColor("Ambient", ColorRGBA.White);
mat_ZoneWater.setColor("Diffuse", ColorRGBA.White);
mat_ZoneWater.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
mat_ZoneWater.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
mat_ZoneWater.setBoolean("DeformY_Ripple", true);
mat_ZoneWater.setBoolean("DeformY_Warble", true);
mat_ZoneWater.setInt("DirY", 0);
mat_ZoneWater.setFloat("SpeedY", 3f);
mat_ZoneWater.setFloat("SizeY", 12f);
mat_ZoneWater.setFloat("DepthY", .05f);
[/java]

You'll have to adjust the Speed, Size & Depth depending on the scale of your models... but overall, since the entire effect is pushed off to GPU, the end results are nice.
8 Likes

Nice, now all we need is refraction/reflection off the edges :wink:

Glad to see you’re on it still :slight_smile:

Hey man, welcome back!



So what are the differences/benefits of this versus SimpleWater or AdvancedWater?

@erlend_sh said:
Hey man, welcome back!

So what are the differences/benefits of this versus SimpleWater or AdvancedWater?

I guess it's a lot cheaper than the Water Filter

Also t0neg0d is a she.
@nehon said:
I guess it's a lot cheaper than the Water Filter

Also t0neg0d is a she.


Heheh... nice. You called him out publicly. I at least berated him in private. :)
@erlend_sh said:
Hey man, welcome back!

So what are the differences/benefits of this versus SimpleWater or AdvancedWater?


Well...

I haven't really played around with either. This shader wasn't really written as a water filter. It was written for two reasons... 1. I wanted something I could use to animate objects using the GPU only... and 2. I wanted to understand how to recalculate normals.

It ended up producing a decent looking water effect for my purposes and the overhead is nil since everything is happening in the vertex shader.

I've seen the other two... and they look awesome! But both tax the crappy machine I am developing on atm.