Obi Official Forum
Masking out fluids - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html)
+--- Thread: Masking out fluids (/thread-1407.html)



Masking out fluids - billmccrary - 04-10-2019

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!


RE: Masking out fluids - josemendez - 05-10-2019

(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


RE: Masking out fluids - billmccrary - 07-10-2019

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/questions/152824/how-can-i-create-a-see-behind-walls-effect