Jump to content

[SOLVED] water in ship


photo

Recommended Posts

How to not render water inside of ship (see linked pictures)? Create some mask surface inside of ship slightly above sea level and use special material/shader on it to not render sea? Is it possible by using default shaders? Thanks.

 

Edit: Btw, why is picture quality spoiled so much by upload here? It is much darker and lower res, but size in kb is same.

post-714-0-71563700-1353197040_thumb.jpg

post-714-0-89448600-1353197312_thumb.jpg

Link to comment

We had a similar requirement for putting arbitrary "holes" into terrain surface geometry without re-tesselation, see post on Depth Clear Material. Finally I got this basically working, but this approach required patching UNIGINE engine render and material source code for explicit per-material depth test mode selection.

 

For your special water use-case case a different approach might be possible by just modifying the base UNIGINE water material.

 

Key idea would be to specify one or multiple simple clipping rectangle or ellipse definitions representing your water clipping regions by center coordinate x/y/witdh/length and simple 2D Z-rotation matrix (so clipping geometry can be rotated according to your ship heading) as two vec4 material shader parameters per clipping geometry.

 

Then, within a customized water material fragment shader you could test each fragment coordinate against these clipping areas and discard all water surface pixels within these clipping regions.

 

Added support of latest SDK for array material parameters (it is now possible to pass a lot of vectors into the shader from a material) Material::set|getParameterArray() might be helpful to provide multiple clippping regions.

 

Material clipping region parameters then have to be updated on each frame according to the world position/orientation of your ships, so water pixels inside the hull will be clipped away.

Link to comment

It will be a special WorldVolume node which will be able to deform water surface and grass object on vertex shader level.

Box and ellipse shapes will be supported. The solution is almost ready.

Link to comment

Very good solution for ObjectGrass, were simply pushing vertices below groud surface is no problem. In case of water this will also be an effective solution for modern container ships with rectangular storage rooms.

 

For some other ships with more rounded hulls like above example it might not be so easy to find a good spacer approximation which will completely clip inside space without producing visible outside artifacts (at least when seen from underwater, were backfacing and pushed down polygons might become visible outside of the hull). Nevertheless great implementation work !

Link to comment
For some other ships with more rounded hulls like above example it might not be so easy to find a good spacer approximation which will completely clip inside space without producing visible outside artifacts (at least when seen from underwater, were backfacing and pushed down polygons might become visible outside of the hull). Nevertheless great implementation work !

 

Lets see, I will try it on our ship.

Link to comment
  • 2 weeks later...
In case of water this will also be an effective solution for modern container ships with rectangular storage rooms. For some other ships with more rounded hulls like above example it might not be so easy to find a good spacer approximation which will completely clip inside space without producing visible outside artifacts (at least when seen from underwater, were backfacing and pushed down polygons might become visible outside of the hull).

Yep, it's a rough approximation. But of course you can check and turn WorldSpacer on only when the camera's inside the ship. Just in case, I know you know that :)

 

Lets see, I will try it on our ship.

Sure, try it out.

Link to comment

Yep, it's a rough approximation. But of course you can check and turn WorldSpacer on only when the camera's inside the ship. Just in case, I know you know that :)

No, actually I missed this simple, but exellent idea !

Link to comment
  • 2 months later...

I can't seem to get this to work with ObjectWater or ObjectWaterMesh and I can't find an example to try in the SDK?...

Is  there anything I need to do except make sure the masks are compatible?

Link to comment
×
×
  • Create New...