Hello Quintijn,
Some time ago I posted a submission to improve the quality of shore line
rendering in osgOcean. I have tried to improve on this some more and
would like to share the changes I made.
Thanks for sharing!
Because the shore line foam effect now depends on the actual waterHeight
and only the terrain is used in the projective heightmap prerender pass
only the terrain will cause shoreline foam and no foam artifacts will
occur around objects in the water such as boats.
Good modifications, the color changes for shallow to deep water look
good. Also the fix for the foam artifacts is welcome. But there is no
foam at all around boats from what I can see... It would be cool to have
foam around these objects (basically anything that intersects the ocean
surface)...
A second addition I made is the option to fade the movement of the water
waves near the shore into a sinus curve. The Fourier transformed waves
did not always look realistic near the shores, for example it was
possible for water to popup through the terrain out of nowhere. This
option can also be used to fade out the ocean-like waves if the ocean is
connected to inland water such as rivers and lakes. This technique does
require a vertex shader texture lookup so I added define statements to
disable it for older hardware.
I added code to disable the heightmap prerender pass for better
performance but note that it is required for the shoreline foam and
sinus curve shore waves.
I also added a key to be able to disable it at runtime in the
oceanExample, and removed the #defines from the shaders themselves so
they can be set by the ShaderManager when the ocean surface is dirtied.
This allowed me to find a small mistake in the shaders that you had put
in FFTOceanSurface.cpp which caused the foam texture to be all over the
place when the HeightMap was disabled. I used the shader file
(water.vert/.frag) which were correct to fix it.
I hope these are useful additions to osgOcean, the changes are applied
to the svn head.
They are definitely useful additions. Committed to SVN.
But I think now would be a good time to do an optimization pass on the
shaders and the traversals. Just taking the oceanExample, which doesn't
have a complex scene with many objects (just the terrain and the ocean
in view actually), I'm getting about 3.5ms Draw, and 9ms GPU on a
GeForce 9800GTX+. Imagine if we add a more complex scene too... In
real-world applications the ocean rendering can't take most of the frame
time, that's not going to work.
I notice the glare pass is a lot more GPU-intensive than the heightmap
pass, or the reflection pass. But even then, I imagine it's a
combination of things - half a millisecond here and a quarter of a
millisecond there will quickly add up, so some general optimization
would be useful. Bear in mind that some things can be disabled
altogether in some modes to avoid ifs in the shader, using ShaderManager
to set #defines based on application state as I've done for the height
map pass.
If you have any ideas that could help, or have some time to try to
reduce those times (mostly the GPU time, so optimizing the shaders
probably) it would be really appreciated. I'm not on an ocean-related
project right now, so I can't put time into this, but I'll have to
eventually.
Thanks a lot for contributing.
J-S
--
______________________________________________________
Jean-Sebastien Guay [email protected]
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org