- Home /
 
               Question by 
               unity_HP0zR3u3FL7JBQ · Sep 17, 2018 at 10:39 PM · 
                shadershadowstransparentlodcrossfade  
              
 
              How to force transparent shader for smooth lod transition to receive shadows?
I'm trying to create shader for smooth LOD crossfade transition without dithering. But for textures with alpha channel(or with additional map) and with falling/received shadows. I cannot find proper combination of methods for now, and start to think it's impossible.
I will appreciate for any help. 
 Shader "CrossFadingLod2"
 {
     Properties
     {
         _Color ("Color", Color) = (1,1,1,1)
         _MainTex ("Albedo (RGB)", 2D) = "white" {}
     _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
         _Glossiness ("Smoothness", Range(0,1)) = 0.5
         _Metallic ("Metallic", Range(0,1)) = 0.0
     }
     SubShader
     {
         Tags { 
         "RenderType"="TransparentCutout" 
         "Queue"="Transparent" 
         //"Queue"="AlphaTest" 
         }
         LOD 200
            
         CGPROGRAM
         #pragma multi_compile _ LOD_FADE_CROSSFADE
         #pragma surface surf Standard  alpha:blend 
         // #pragma surface surf Standard  alphatest:_Cutoff 
         
         sampler2D _MainTex;
 
         struct Input {
             float2 uv_MainTex;
         };
 
         half _Glossiness;
         half _Metallic;
         fixed4 _Color;
 
         void surf(Input IN, inout SurfaceOutputStandard o) {
             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
             o.Albedo = c.rgb;
             o.Metallic = _Metallic;
             o.Smoothness = _Glossiness;
         #ifdef LOD_FADE_CROSSFADE
                     o.Alpha = c.a * unity_LODFade.x;
         #else
                     o.Alpha = c.a;
         #endif
         }
         ENDCG
     }
 
 
      SubShader
      {
         Tags {  "LightMode" = "ShadowCaster" }
         CGPROGRAM
         #pragma multi_compile _ LOD_FADE_CROSSFADE
         #pragma surface surf Standard alphatest:_Cutoff 
         sampler2D _MainTex;
  
         struct Input {
             float2 uv_MainTex;
         };
  
         void surf (Input IN, inout SurfaceOutputStandard o) {
             fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
 
         #ifdef LOD_FADE_CROSSFADE 
                     o.Alpha = c.a * unity_LODFade.x;
         #else
                     o.Alpha = c.a;
         #endif
         }
         ENDCG
     }
    FallBack "Transparent/Diffuse/VertexLit"   
 }
 
 
                 
                shader2.png 
                (124.0 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                