Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Masking out fluids
#1
Maybe an odd question / request - we have some fluid clipping through some geometry due to a large-ish render scale (5), and we'd like to be able to put some 'masking' geometry over the top of it that will allow the camera to see everything BUT the fluid.  We don't have any shader specialists so wondering if that is something possible to do with obi fluids today or if that would be something someone knew how to do?  I have simple sandbox examples of basic geometry working by reusing someone's stencil buffer shaders, but I don't know how to implement that against the fluids.  Attached images of that simple sandbox stuff if it helps explain what I'm asking.  Thanks!
Reply
#2
(04-10-2019, 08:35 PM)billmccrary Wrote: Maybe an odd question / request - we have some fluid clipping through some geometry due to a large-ish render scale (5), and we'd like to be able to put some 'masking' geometry over the top of it that will allow the camera to see everything BUT the fluid.  We don't have any shader specialists so wondering if that is something possible to do with obi fluids today or if that would be something someone knew how to do?  I have simple sandbox examples of basic geometry working by reusing someone's stencil buffer shaders, but I don't know how to implement that against the fluids.  Attached images of that simple sandbox stuff if it helps explain what I'm asking.  Thanks!

Hi there,

This is more of a general shader question that anything specific to Obi. Modifying "DielectricFluidShader.shader" (or whatever shader your fluid material is using) to read from the stencil buffer should be enough. See:
https://docs.unity3d.com/Manual/SL-Stencil.html
Reply
#3
OK thanks - ended up being very easy, need to stop being afraid of shaders =)

Also here is the source for the shader for the blocking geometry (Custom/SimpleMask in the post marked as the answer).

https://gamedev.stackexchange.com/questi...lls-effect


Attached Files Thumbnail(s)
   
Reply