WaterFilter enhancement : under water

Hey All, i implemented an underwater shader for the Water post process filter.

see the video here

http://www.youtube.com/watch?v=i62pTYFEUMw



It's in the last revision.
usage is simple, create a FilterPostPorcessor, add a WaterFilter and just get the cam under water.

In the video there is a WaterFilter, a LightScatteringFiltern, a BloomFilter,and a DepthOfFieldFilter.
You can see the code in TestPostWater.
I encourage you to test it, because it's a bit too dark in the video.

I made this on my Ati Card, so i'd like you fellow monkeys to test it on your hardware....especially mac users :D

Thanks monkeys, looking forward for feedback.
11 Likes

Wicked :smiley:

I get this for the PostWaterLakeTest:


SCHWERWIEGEND: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/MatDefs/Water/Water.frag, defines, type=Fragment] error:ERROR: 0:146: 'texture' : no matching overloaded function found
ERROR: 0:146: 'r' : field selection requires structure or vector on left hand side
ERROR: 0:153: 'textureOffset' : no matching overloaded function found
ERROR: 0:153: 'r' : field selection requires structure or vector on left hand side
ERROR: 0:154: 'textureOffset' : no matching overloaded function found
ERROR: 0:154: 'r' : field selection requires structure or vector on left hand side
ERROR: 0:155: 'textureOffset' : no matching overloaded function found
ERROR: 0:155: 'r' : field selection requires structure or vector on left hand side
ERROR: 0:156: 'textureOffset' : no matching overloaded function found
ERROR: 0:156: 'r' : field selection requires structure or vector on left hand side


And this for the PostWater test:

SCHWERWIEGEND: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.UnsatisfiedLinkError: org.lwjgl.openal.EFX10.nalGenFilters(ILjava/nio/IntBuffer;I)V
at org.lwjgl.openal.EFX10.nalGenFilters(Native Method)
Java Result: 143

the first is fixed, hope that’s the same issue in the second :stuck_out_tongue:

One left:

SCHWERWIEGEND: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/MatDefs/Water/Water.frag, defines, type=Fragment] error:ERROR: 0:146: 'texture' : no matching overloaded function found
ERROR: 0:146: 'r' : field selection requires structure or vector on left hand side

You seriously astonish me ! x.x



No need for Hydrax anymore, hehe. So cool, thank you ! You’re a life saver.



It’s working fine on my Nvidia 275.

It works totally fine for me:

Ubuntu 10.10 Linux

NVidia 260 GTX with driver version 260.19.29



Awesome effects!!! Continue with this work

Wow man, love the depth-depend blue color of the water. And the sound effect is good too … You like the god of the sea or some??? Definitely use this in my game !

Looked nice from the video so I tried…

Well. It killed my Graphics Device totally. My IDE hung up so sadly i cant tell you the Exceptions if there were.



I updated my graphics drivers and tried again.

Same result… Are there special requirements for this shader?



Graphics Capabilities
FrameBuffer
FrameBufferMRT
FrameBufferMultisample
OpenGL20
OpenGL21
ARBprogram
GLSL100
GLSL110
GLSL120
GLSL130
VertexTextureFetch
TextureArray
TextureBuffer
FloatTexture
FloatColorBuffer
FloatDepthBuffer
PackedFloatTexture
SharedExponentTexture
PackedFloatColorBuffer
TextureCompressionLATC
NonPowerOfTwoTextures
MeshInstancing
VertexBufferArray

Thats what i have... Its a laptop onboard graphics chip. ATI Radeon 3100

This is totally great, thanks for this!



I had to comment out the second DirectionalLight in TestPostWater.java (local variable ‘l’), or I get nothing but black screen.



In my own app, I had to remove a particle emitter and flickering point light (my prototype campfire) or I got similar problems (not totally black, but mostly black). The PointLight seemed to cause most of the problem, but I still got artifacts with the particle emitter in the scene.



I’m running an NVidia 8800GT, 275.33 (latest) drivers.



How hard would it be to make it so you could define multiple water volumes using this technology (imagine a mountain scene with several lakes at different altitudes)?

KuroSei said:
Looked nice from the video so I tried...
Well. It killed my Graphics Device totally. My IDE hung up so sadly i cant tell you the Exceptions if there were.

I updated my graphics drivers and tried again.
Same result... Are there special requirements for this shader?

Thats what i have... Its a laptop onboard graphics chip. ATI Radeon 3100

Yeah the test case is quite intensive, you can try to disable Bloom, LightScattering and DepthOfField, then you'll have only the water filter

@mattias
Yeah this is a known issue the filter does not work anymore with multiple light source, it should be fixed soon.
For the different altitudes lakes, it's kinda hard. One solution could be to have multiple areas defined by 8 points, or a center and a radius (woud be faster...but would be spherical). Since the shader sample the position of the pixel in world space, could be doable to render water only in those area.
The problem would be that the water would look the same in this different areas. you wouldn't be able to have the sea and a lake with muddy water in the same scene. All sea or all muddy.
That would be possible to pass all the parameter for each area, but there is already a lot of them for one area, that would require a lot of bandwidth to the GPU.
It's doable...but, it could bring a lot of hardwares to their knees I guess.

I tried with disabling everything else… It still kills my graphics device.



I will try some debugging to see where exactly it kills the device.

I tried to run testpostwater but always get this error

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

com.jme3.renderer.RendererException: Image format ‘DXT1’ is unsupported by the video hardware.

at com.jme3.renderer.lwjgl.TextureUtil.checkFormatSupported(TextureUtil.java:99)

at com.jme3.renderer.lwjgl.TextureUtil.uploadTexture(TextureUtil.java:183)

at com.jme3.renderer.lwjgl.LwjglRenderer.updateTexImageData(LwjglRenderer.java:1763)

at com.jme3.renderer.lwjgl.LwjglRenderer.setTexture(LwjglRenderer.java:1794)

at com.jme3.material.MatParamTexture.apply(MatParamTexture.java:46)

at com.jme3.material.Material.render(Material.java:968)

at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:658)

at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:187)

at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:246)

at com.jme3.water.ReflectionProcessor.postQueue(ReflectionProcessor.java:56)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1123)

at com.jme3.water.WaterFilter.preFrame(WaterFilter.java:189)

at com.jme3.post.FilterPostProcessor.preFrame(FilterPostProcessor.java:328)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1101)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1164)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:257)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:144)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:173)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:218)

at java.lang.Thread.run(Thread.java:662)

what is dxt1 and dxt1a ?

I also tried other testwaters but none worked for me

I am using intel gma 4500

It’s an image compression format…I guess the sky image uses it. try to comment out the sky in the test case. (will look weird though :p)



Maybe try some other skies of the testpackage, I don’t know if they are all compressed in this format.

xieu90 said:
what is dxt1 and dxt1a ?
I also tried other testwaters but none worked for me
I am using intel gma 4500

@xieu90: Are you on Linux? Have you installed drivers from Intel or Mesa3D?

@nehon

I comment the sky in tests and now all of them work

I also had skyfactory work but with png file

the frame rate is quite low at me

TestPostWater : under water 10 , above water 1-2

I think I will stay underwater, it is pretty and fps is also higher

very nice work ^^



@Momoko_Fan

yeah I’m in linux (Linux Mint Debian)

I think I have mesa3d

http://i.imgur.com/nnfw0.png

and I installed it like this

http://omnsproject.org/?p=680

Quite a wonder that this works on intel onboard cards, not bad, must mean something for the shader compability :wink:

Yeah … Mesa3D does not support DXT formats. There’s nothing we can do about that except not use DXT.

This only effects a small group of people who are using Linux with Mesa drivers (there has been one more person with this issue)

@Momoko_Fan

what kind of driver do you have then ? Intel or also Mesa like me ?

Noice one dude! :slight_smile: