zoukankan      html  css  js  c++  java
  • 正反面都正确接受光源的双面材质

    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"
    
    }
    

      

  • 相关阅读:
    矩阵树定理 / 生成树计数
    NC20811 蓝魔法师 (树形DP/树上01背包)
    Xor-MST学习/ 2020牛客暑假多校(五)B.Graph
    HDU-6820 Tree (2020杭电多校(五) 1007)
    Flipping Coins (概率DP)
    宝石装箱 容斥+dp
    Rabbit的工作(1) (dP)
    Codeforces-1350 E.Orac and Game of Life
    HDU-6563 Strength (贪心)
    HDU-6558 The Moon (期望DP)
  • 原文地址:https://www.cnblogs.com/softimagewht/p/4750850.html
Copyright © 2011-2022 走看看