材质动态加载贴图实现灰色效果 shader

来源:互联网 发布:flash编程视频教程 编辑:程序博客网 时间:2024/06/05 06:55

头像使用了为材质动态加载贴图。为了实现灰色效果,网上找了段着色器。

[csharp] view plaincopy
  1. Shader "GrayscaleLol" {  
  2.     Properties {  
  3.         _MainTex ("Base (RGB)", 2D) = "white" {}  
  4.     }  
  5.     SubShader {  
  6.         Tags { "RenderType"="Opaque" }  
  7.         LOD 200  
  8.    
  9.         CGPROGRAM  
  10.         #pragma surface surf Lambert  
  11.    
  12.         sampler2D _MainTex;  
  13.    
  14.         struct Input {  
  15.             float2 uv_MainTex;  
  16.         };  
  17.    
  18.         void surf (Input IN, inout SurfaceOutput o) {  
  19.             half4 c = tex2D (_MainTex, IN.uv_MainTex);  
  20.             o.Albedo = (c.r + c.g + c.b)/3;  
  21.             o.Alpha = c.a;  
  22.         }  
  23.         ENDCG  
  24.     }   
  25.     FallBack "Diffuse"  
  26. }  
0 0