Hi Quintijn, Cheers for looking at this.
> This solution is to render sloped geometry underneath the water surface > around the object in the refraction pass. This geometry should have the same > color as the ocean refraction color. This will create a smooth depth > transition around the object. Using this technique it should be possible to > add foam anywhere in the ocean you like. Adding foam around ships etc was always going to require special cases, in the past I did this with projective textures but it's only suitable for a small set of scenarios. This geometry approach could work but I suspect it would require the underwater and over water refraction passes to be separated into two different passes, swapped over automatically based on eye position relative to the surface height. Or alternatively some sort of nodemask switching which would hide the geometry when underwater. Otherwise the geometry would be seen when you look up to above water objects from below. That isn't such a big deal but would require some tinkering. > An alternative solution to the problem is to remove the object from the > refraction prerender pass. This causes the object and the ocean around it to > be rendered the same as before the changes. However this will remove the > foam and translucency effects for that particular object. yes again with this one since the refraction pass is used above and below water the object would mysteriously vanish from the surface if you were underwater. J-S since you're osgocean in the wild, how workable is the geometry approach in application such as yours? > 2. When sampling from the depth buffer the distorted vertex coordinates are > used. This caused problems near the edges even in parts not immersed in the > water. This problem is fixed in the attached shader file by using the > undistorted vertex coordinates for sampling the depth values. Thanks for the fix I'll merge it in when I get a sec. Regards, Kim. 2009/11/17 Quintijn Hendrickx <[email protected]>: > > Dear Jean-Sébastien Guay, > > > There seem to be two problems when rendering objects in the water that do > not have a smooth transition into deeper water. > > 1. Sharp foam transitions caused by sharp depth transitions at the edges of > an object. > > There is no easy fix for this problem but there is an unelegant solution > that should work in most cases. > > This solution is to render sloped geometry underneath the water surface > around the object in the refraction pass. This geometry should have the same > color as the ocean refraction color. This will create a smooth depth > transition around the object. Using this technique it should be possible to > add foam anywhere in the ocean you like. > > 2. When sampling from the depth buffer the distorted vertex coordinates are > used. This caused problems near the edges even in parts not immersed in the > water. This problem is fixed in the attached shader file by using the > undistorted vertex coordinates for sampling the depth values. > > > An alternative solution to the problem is to remove the object from the > refraction prerender pass. This causes the object and the ocean around it to > be rendered the same as before the changes. However this will remove the > foam and translucency effects for that particular object. > > > Kind regards, > > Quintijn Hendrickx > > > > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > > _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
