From cf794643a6f90b73e53c3e620e3c64c1be3bab7c Mon Sep 17 00:00:00 2001 From: MelekTaus Moribundus Date: Fri, 10 Jul 2026 19:28:22 +0200 Subject: [PATCH] Fix camo forward pass on Deferred+ (ComplexLit forward-only path, HalfLambert/X-ray restored) Co-Authored-By: Claude Fable 5 --- Assets/Shaders/PlayerCamoLit.shader | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Assets/Shaders/PlayerCamoLit.shader b/Assets/Shaders/PlayerCamoLit.shader index 58c1e87..be6f8ca 100644 --- a/Assets/Shaders/PlayerCamoLit.shader +++ b/Assets/Shaders/PlayerCamoLit.shader @@ -7,8 +7,10 @@ // _BaseColor / PBR keywords on the material instance) is unaffected. TWO passes deviate from stock: // - ForwardLit: fragment is CamoForwardFragment, which reimplements URP's forward shading while // delegating GI / shadows / clustered lights to URP and applying the camo knobs. -// - GBuffer: fragment is CamoGBufferFragment. The project renders forward, so this pass only feeds -// HTrace WSGI's thin GBuffer - it mirrors the camo body grade (brightness/saturation) onto the +// - GBuffer: fragment is CamoGBufferFragment. The avatar itself is ALWAYS shaded forward (the +// subshader is tagged "ComplexLit" + "UniversalForwardOnly", so on Deferred/Deferred+ the deferred +// lighting is stenciled out for it) - this pass only fills GBuffer data for consumers such as +// HTrace WSGI's thin GBuffer: it mirrors the camo body grade (brightness/saturation) onto the // albedo and the painted-height AO remap onto the occlusion, so HTrace's injected indirect light // matches the graded forward look (see PlayerCamoGBuffer.hlsl). // All other passes (ShadowCaster, DepthOnly, DepthNormals, Meta, ...) are stock URP/Lit. @@ -123,7 +125,12 @@ Shader "Custom/PlayerCamoLit" { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" - "UniversalMaterialType" = "Lit" + // "ComplexLit" (not "Lit"): on the Deferred/Deferred+ path URP stencils these pixels out of + // the deferred lighting and shades the object in the forward-only pass instead - required + // because the whole camo look (HalfLambert, specular dampen, visible X-ray half) lives in + // CamoForwardFragment, which deferred lighting would otherwise bypass. The GBuffer pass + // below still runs and fills correct (graded) data for HTrace WSGI. + "UniversalMaterialType" = "ComplexLit" "IgnoreProjector" = "True" } LOD 300 @@ -135,7 +142,9 @@ Shader "Custom/PlayerCamoLit" Name "ForwardLit" Tags { - "LightMode" = "UniversalForward" + // "UniversalForwardOnly" (not "UniversalForward"): drawn by the forward path AND by the + // deferred path's forward-only fallback, so the camo fragment runs on every rendering mode. + "LightMode" = "UniversalForwardOnly" } // ------------------------------------- @@ -492,10 +501,12 @@ Shader "Custom/PlayerCamoLit" // This pass is used when drawing to a _CameraNormalsTexture texture Pass { - Name "DepthNormals" + // "DepthNormalsOnly" (not "DepthNormals"): the deferred path's normal prepass draws ONLY this + // tag (deferred objects get their normals from the GBuffer); the forward path draws both. + Name "DepthNormalsOnly" Tags { - "LightMode" = "DepthNormals" + "LightMode" = "DepthNormalsOnly" } // -------------------------------------