Guest User

StencilLightURP.shader

a guest
Sep 21st, 2025
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/StencilLight Color"
  2. {
  3.     Properties
  4.     {
  5.         [HDR]_Color("Color",Color) = (1,1,1,1)
  6.     }
  7.     HLSLINCLUDE
  8.    
  9.     #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"        
  10.     struct appdata
  11.     {
  12.         float4 vertex : POSITION;
  13.     };
  14.    
  15.     struct v2f
  16.     {
  17.         float4 vertex : SV_POSITION;
  18.     };
  19.    
  20.    
  21.    
  22.     v2f vert(appdata v)
  23.     {
  24.         v2f o;
  25.         o.vertex = TransformObjectToHClip(v.vertex.xyz);
  26.         return o;
  27.     }
  28.  
  29.     CBUFFER_START(UnityPerMaterial)
  30.         float4 _Color;    
  31.     CBUFFER_END
  32.    
  33.     float4 frag(v2f i) : SV_Target
  34.     {
  35.         return _Color * _Color.a;
  36.     }
  37.     ENDHLSL
  38.  
  39.     SubShader
  40.     {
  41.         Tags{"Queue" = "Transparent" "RenderType" = "Transparent"}  
  42.         Pass
  43.         {
  44.             Tags
  45.             {
  46.                 "RenderType" = "Transparent"          
  47.                 "RenderPipeline" = "UniversalPipeline"            
  48.             }        
  49.             Zwrite off
  50.             Ztest Lequal
  51.             Cull Back
  52.             Blend DstColor One
  53.            
  54.             Stencil
  55.             {
  56.                 comp equal
  57.                 ref 1
  58.                 pass zero
  59.                 fail zero
  60.                 zfail zero
  61.             }        
  62.             HLSLPROGRAM
  63.             #pragma vertex vert
  64.             #pragma fragment frag        
  65.             ENDHLSL
  66.         }      
  67.         Pass
  68.         {
  69.             Tags
  70.             {
  71.                 "RenderPipeline" = "UniversalPipeline"
  72.                 "LightMode" = "UniversalForward"
  73.             }
  74.             ZTest always
  75.             ZWrite off
  76.             Cull Front
  77.             Blend DstColor One
  78.  
  79.             Stencil
  80.             {
  81.                 Ref 1
  82.                 Comp equal
  83.                 Pass Zero
  84.                 fail zero
  85.                 Zfail zero
  86.             }        
  87.             HLSLPROGRAM
  88.             #pragma vertex vert
  89.             #pragma fragment frag
  90.             ENDHLSL
  91.         }    
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment