AimplainLeo / osgocean

Automatically exported from code.google.com/p/osgocean
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Wave-top reflection artifacts #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When the wave-top hits an object it's possible that the reflection is
dissected by the clipping plane (see screenshot, that's my oil-rig in the
ocean) which is really irritating (from a distance it appears that the
object is hovering over the water).

As a quick hack I shifted the clipping plane:

reflClipPlane->setClipPlane(0.0, 0.0, 1.0, -getOceanSurfaceHeight() + 1.5);

... but I suppose it would be a lot nicer if the maximum wave-top would be
used instead of that magic 1.5. I just couldn't figure out where to get it. :)

I realize that this increases the risk of below-surface geometry ending up
in the reflection map so it _might_ be prudent to make this configurable -
OTOH I've seen no such artifacts in my application after the change...

Original issue reported on code.google.com by felix.nawothnig on 12 May 2010 at 9:37

Attachments:

GoogleCodeExporter commented 9 years ago
Yes a similar issue has been flagged before. It's difficult to solve this 
properly 
with a static clip plane and a non planar surface. As you rightly point out 
this 
would only work for certain situations.

However, if you want to send in a clip plane tweak I'd be happy to include it. 
Otherwise it'll have to wait until I get a moment. 

If you need the maximum wave height you could add a variable to OceanTile to 
store 
the highest wave height and access the current tile. OceanTile computes the 
average 
height for each tile when it generates the vertices so it wouldn't be much work 
to 
store the highest/lowest waves at the point - they should be equally displaced 
anyway 
the average height of a tile of FFT ocean is approximately zero.

Original comment by kcb...@googlemail.com on 12 May 2010 at 10:08

GoogleCodeExporter commented 9 years ago
> It's difficult to solve this properly with a static clip plane and a non 
> planar surface.

Given this some thought - I suppose one could do a (depth-only) pass of the 
surface
before doing the reflection map?

Original comment by felix.nawothnig on 13 May 2010 at 7:43

GoogleCodeExporter commented 9 years ago
Can you expand on that?

Original comment by kcb...@googlemail.com on 13 May 2010 at 7:51

GoogleCodeExporter commented 9 years ago
Just thinking... the point of the reflection clipping is avoid rendering any
below-surface geometry - with a non-planar surface the obvious way to do that 
is to
exclude below-water geometry using depth-testing.

Instead of using a clipping plane one could simply render the (mirrored) ocean
surface before doing the reflection map with color buffer output disabled (as 
we are
only interested in the depth values).

Doing another pass of the surface geometry would obviously have some performance
impact but it shouldn't be that bad - we don't need the water fragment shader 
for
this one and it's independent from the scene complexity (and that's my real 
reason
for suggesting this - the osgOcean surface itself has virtually no cost in my 
(real
world) application, the only thing that hurts me is the extra scene geometry 
pass for
reflection...).

Original comment by felix.nawothnig on 13 May 2010 at 2:39

GoogleCodeExporter commented 9 years ago
After lots of trying - okay, I'm pretty sure it's not possible to do this with 
just
GL depth testing (because the geometry I want to cull is on the wrong damn 
side).

I'll now try rendering the reflected surface into a depth-map and perform an
(additional) manual depth test in the fragment shader... as I only need to do 
this in
case the vertex happens to be between wave-bottom and wave-top the penalty still
shouldn't be that bad.

Original comment by felix.nawothnig on 21 May 2010 at 4:55

GoogleCodeExporter commented 9 years ago
It may cost a lot to confirm whether the point is between wave-bottom and 
wave-top, 
any good ideas?

Original comment by tianxiao...@foxmail.com on 24 May 2010 at 2:51