Unity3d Shader动态表面效果着色器 .

动态表面效果着色器,做一做特效倒是比较合适,截图如下:

  1. Shader "Effects/Plasma" {   
  2. Properties {   
  3.    _MainTex ("Base (RGB)", RECT) = "white" {}   
  4.    _ColorBand ("Base (RGB)", 2D) = "white" {}   
  5. }  
  6. SubShader {   
  7. ZTest Always Cull Off ZWrite Off   
  8.       Fog { Mode off }   
  9.    Pass {   
  10.          
  11.                
  12. CGPROGRAM   
  13. #pragma vertex vert_img   
  14. #pragma fragment fragSh   
  15. #pragma fragmentoption ARB_precision_hint_fastest   
  16. #include "UnityCG.cginc"   
  17. uniform samplerRECT _MainTex;   
  18. uniform sampler2D _ColorBand;  
  19. float4 fragSh (v2f_img i) : COLOR   
  20. {   
  21.       
  22.    float2 ca = float2(0.2, 0.2);   
  23.    float2 cb = float2(0.7, 0.9);   
  24.    float da = distance(i.uv, ca);   
  25.    float db = distance(i.uv, cb);   
  26.       
  27.    float c1 = sin(da * _CosTime.y * 16 + _Time.x);   
  28.    float c2 = cos(i.uv.x * 8 + _Time.z);   
  29.    float c3 = cos(db * 14) + _CosTime.x;  
  30.    float p = (c1 + c2 + c3) / 3;   
  31.       
  32.    return tex2D(_ColorBand, float2(p, 0.5));   
  33. }   
  34. ENDCG   
  35.    }   
  36. }   
  37. Fallback off   
  38. }  
posted @ 2012-05-16 01:26  渡蓝  阅读(1797)  评论(1)    收藏  举报