Jump to content

[SOLVED] water in ship


photo

Recommended Posts

Posted

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

Posted

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.

Posted

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.

Posted

Wow, this sounds cool, so it will support grass clipping too ?! Great !

Posted

WorldSpacer node will be available in the next SDK update.

This object can trample grass and dry the water.

spacer_00.jpg

spacer_01.jpg

  • Like 1
Posted

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 !

Posted
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.

Posted

Yep this seems to be a very good test case.

  • 2 weeks later...
Posted

Would this object work for partical systems like the ones used for rain in the valley demo

Posted
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.

Posted
Would this object work for partical systems like the ones used for rain in the valley demo

Danny, what's your use case that's not covered by clippers in particle systems?

Posted

this is cool with the ability to cut out grass on the object. For example if a player places a house in our case.. cut the grass under it :)

Posted

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 !

  • 2 months later...
Posted

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?

×
×
  • Create New...