I have a fog image effect that uses the depth map, so it draws over transparent materials. I had an idea for a solid material that could become 'transparent' by cutting out pixels instead. It still has to write to the depth map, otherwise near objects would remove all the fog from behind them. I'm going to use the effect as little as I can, just for fading out enemies and items, maybe for a few small windows, etc. It's almost complete, the only problem is that flat areas now have striped shadowing when they should be fully lit. Also, I'm not sure if I've set up the passes the correct way. Does anyone have any ideas? Thank you! Code (CSharp): Shader "Dithered Solid" { Properties { _Color("Color", Color) = (1,1,1,1) _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 _Transparency ("Transparency", Range(0,1)) = 0.5 _Metallic("Metallic", Range(0.0, 1.0)) = 0 _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5 [Enum(UnityEngine.Rendering.CullMode)] _Culling ("Cull Mode", Int) = 2 } CGINCLUDE half4 _Color; half _Glossiness; half _Metallic; float _Transparency; struct Input { float4 color : COLOR; float4 screenPos; }; void surf(Input IN, inout SurfaceOutputStandard o) { const float4x4 thresholdMatrix = { 1,9,3,11, 13,5,15,7, 4,12,2,10, 16,8,14,6 }; float2 pixelPos = IN.screenPos.xy / IN.screenPos.w * _ScreenParams.xy; float threshold = thresholdMatrix[pixelPos.x % 4][pixelPos.y % 4] / 17; float ditheredAlpha = 1; if (threshold > _Transparency) ditheredAlpha = 0; o.Albedo = _Color.rgb; o.Alpha = _Color.a * ditheredAlpha; o.Metallic = _Metallic; o.Smoothness = _Glossiness; } ENDCG SubShader { Tags { "LightMode" = "ShadowCaster" } Cull [_Culling] CGPROGRAM #pragma surface surf Standard alphatest:_Cutoff fullforwardshadows addshadow keepalpha #pragma target 3.0 ENDCG } SubShader { Tags { "RenderType" = "TransparentCutout" "Queue" = "AlphaTest" } Cull [_Culling] CGPROGRAM #pragma surface surf Standard alphatest:_Cutoff fullforwardshadows addshadow #pragma target 3.0 ENDCG } FallBack "Diffuse" }
You don’t have any passes in your shader, and shouldn’t, since the surface shader will generate them for you. You also shouldn’t have a light mode defined for a sub shader, those should only be used on a Pass, which again the Surface Shader should be generating for you and setting proper light mode tags on. You also shouldn’t have two sub shaders at all unless they’re being used to define different shaders for different platforms. Try deleting the entire first SubShader.