• 正反面都正确接受光源的双面材质


    Shader "Transparent/Diffuse DoubleSided" {
    
    
    Properties {
    
    	 _Color ("Main Color", Color) = (1,1,1,1)
    
    	 _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
    
    }
    
    
    
    
    SubShader {
    
    		 Tags { "RenderType"="Opaque" }
    
     		 LOD 300
    
     		
    
    	 	Pass {
    
    			 Tags { "LightMode" = "Vertex" }
    
    				
    
    			 Cull Back
    
    			 ZWrite On
    
    			 Lighting On
    
    			
    
    			 CGPROGRAM
    
    			
    
    			 #pragma vertex vert
    
    			 #pragma fragment frag
    
    			
    
    			 #include "UnityCG.cginc"
    
    			
    
    			 sampler _MainTex;
    
    			 float4 _MainTex_ST;
    
    			 float4 _Color;
    
    			
    
    			 struct a2v {
    
    				 float4 vertex : POSITION;
    
    				 float3 normal : NORMAL;
    
    				 float4 texcoord : TEXCOORD0;
    
    			 };
    
    			
    
    			 struct v2f {
    
    				 float4 pos : POSITION;
    
    				 float2 uv : TEXCOORD0;
    
    				 float3 color : TEXCOORD1;
    
    			 };
    
    			
    
    			 v2f vert(a2v v) {
    
    				 v2f o;o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    
    				 o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
    
    				 o.color = ShadeVertexLights(v.vertex, v.normal);
    
    				 return o;
    
    			 }
    
    			
    
    			 float4 frag(v2f i) : COLOR {
    
    				 float4 c = tex2D(_MainTex, i.uv)*_Color;
    
    				 clip(c.a-0.9);
    
    				 c.rgb = c.rgb * i.color * 2;
    
    				 return c;
    
    			 }
    
    			
    
    			 ENDCG
    
    		 }
    
    		
    
    		
    
    		 Pass {
    
    			 Tags { "LightMode" = "Vertex" }
    
    				
    
    			 Cull Front
    
    			 ZWrite On
    
    			 Lighting On
    
    			
    
    			 CGPROGRAM
    
    			
    
    			 #pragma vertex vert
    
    			 #pragma fragment frag
    
    			
    
    			 #include "UnityCG.cginc"
    
    			
    
    			 sampler _MainTex;
    
    			 float4 _MainTex_ST;
    
    			 float4 _Color;
    
    			
    
    			 struct a2v {
    
    				 float4 vertex : POSITION;
    
    				 float3 normal : NORMAL;
    
    				 float4 texcoord : TEXCOORD0;
    
    			 };
    
    			
    
    			 struct v2f {
    
    				 float4 pos : POSITION;
    
    				 float2 uv : TEXCOORD0;
    
    				 float3 color : TEXCOORD1;
    
    			 };
    
    			
    
    			 v2f vert(a2v v) {
    
    				 v2f o;o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    
    				 o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
    
    				 o.color = ShadeVertexLights(v.vertex, -v.normal);
    
    				 return o;
    
    			 }
    
    			
    
    			 float4 frag(v2f i) : COLOR {
    
    				 float4 c = tex2D(_MainTex, i.uv)*_Color;
    
    				 clip(c.a-0.9);
    
    				 c.rgb = c.rgb * i.color * 2;
    
    				 return c;
    
    			 }
    
    			
    
    			 ENDCG
    
    		 }
    
    	 } 
    
    	 FallBack "Diffuse"
    
    }
    

      

  • 相关阅读:
    SqlServer查询所有表名 查询表的所有列名
    IIS控制txt文件的访问
    CHM文件打不开
    [转]VS 2010项目中添加lib库
    SqlServer游标
    [转]_beginthread(), _beginthreadex()与CreateThread()的区别
    jquery radio快速度取值
    linx niginx下php无法创建文件夹及文件
    [转载]无效的 CurrentPageIndex 值.它必须大于等于 0 且小于 PageCount
    使用DateGrid的ItemCommand的一点心得
  • 原文地址:https://www.cnblogs.com/softimagewht/p/4750850.html
Copyright © 2020-2023  润新知