Tech Breakdown: Hiding Water in Boat Interiors

The Problem. Someone get a bucket!
  • Making a ‘mask’ mesh for each boat
  • Writing a shader for the ‘mask’ mesh
  • Modifying the water shader to use the mask

The Mask Mesh

The water mask mesh

The Mask Shader

The shader for the water mask mesh
Toggling the water mask mesh on and off
Gross

The Stencil Buffer

Stencil - This is just signifying that we’ll be doing a stencil operation in this shader pass Ref 1 - The stencil value we'll be referencing is 1Comp always - When we look at the current stencil value, our shader should always draw its pixel regardless of the stencil value.Pass replace - When we draw a pixel, we should replace the current stencil value with our value, aka '1'. 

Masking in the Water Shader

Adding the stencil block to the water shader.
Water water everywhere but not a drop in our boat!
Oops…
Artifact is ‘fixed’

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store