🔳 CosterGraphics/Systems/OutlineSystem/RenderPasses/OutlineColorMaskDepthTestedPass
🏒 Render Passes
🧱 Outline Color Mask Depth Tested Pass
OutlineColorMaskDepthTestedPass render pass.
(for taking the Screen Shot the Outline3D components on the turret in the center and the bunny on the right were disabled)
📖 Description
Renders silhouettes of 🔳Outline3D objects with L EQUAL(Less than or equal to) depth testing enabled in the mask shader causing outlines only to appear where objects are visible (not occluded by other non-Outline3D geometry).
This mask answers the binary question of where 🔳Outline3D geometry exists not hidden behind other geometry.
Can be used in combination with the non-depth tested Texture2D_OutlineColorTextureMask to toggle between always-visible/see-trough or depth-tested/hidden-behind other geometry outlines, or to generate outlines with a different color for the hidden and visible parts.
🔧 How It Works
- Inputs:
🔳Outline3Dobjects and camera depth buffer. - Process: Draws objects with L Equal depth testing and small depth bias.
- Outputs:
Texture2D_OutlineColorTextureMaskDepthTested(R8_UNorm format). - Code Example:
// From OutlineColorMaskDepthTestedPass.RecordRenderGraph
UniversalResourceData resourceData = frameContext.Get<UniversalResourceData>();
TextureDesc colorTextureDesc = resourceData.activeColorTexture.GetDescriptor(renderGraph);
colorTextureDesc.name = "Texture2D_OutlineColorTextureMaskDepthTested";
colorTextureDesc.colorFormat = GraphicsFormat.R8_UNorm;
TextureHandle outlineColorTextureMaskDepthTested = renderGraph.CreateTexture(colorTextureDesc);
builder.SetRenderAttachment(outlineColorTextureMaskDepthTested, 0, AccessFlags.Write);
🔗 Requirements
- Material:
outlineColorMaskDepthTestedMaterial. - Shader:
Simple-Msk-ColorTextureMaskDepthTested-Default.shadergraph - URP Settings: Depth buffer enabled.
- Dependencies: Requires Color Mask Pass.
⭐ Tier Usage
- Available in: ⭐Simple, ⭐⭐Basic, ⭐⭐⭐Advanced, ⭐⭐⭐⭐Pro.
- Conditional: Runs if Composite Shader has
_OutlineColorTextureMaskDepthTestedTexture2D property.
🔫 Troubleshooting
- Issue: Mask has gaps/z-fighting issues with
🔳Outline3Dgeometry.- Fix: Increase depth bias in shader (
cmd.SetGlobalDepthBias(-0.2f, -0.2f)).
- Fix: Increase depth bias in shader (
🏎️ Performance
- Slightly more expensive than the non-depth tested color mask.