shader_flowlight3d.shader 905 B

123456789101112131415161718192021222324252627282930313233343536
  1. Shader "Custom/shader_flowlight3d" {
  2. Properties {
  3. _MainTex ("Base (RGB)", 2D) = "white" {}
  4. _LightTex ("_LightTex Base (RGB) Trans (A)", 2D) = "black" {}
  5. _speed ("LightSpeed", Vector) = (1,1,0,0)
  6. }
  7. SubShader {
  8. Tags { "RenderType"="Opaque" }
  9. LOD 200
  10. CGPROGRAM
  11. #pragma surface surf Lambert
  12. sampler2D _MainTex;
  13. sampler2D _LightTex;//流光图
  14. float2 _speed;//速度
  15. struct Input {
  16. float2 uv_MainTex;
  17. float3 worldNormal;//增加最终的法线参数
  18. };
  19. void surf (Input IN, inout SurfaceOutput o) {
  20. float2 ruv = IN.worldNormal.xy;//使用normal来做uv,可以取得如环境反射版的效果
  21. ruv = ruv *0.5;//收敛到-0.5到0.5之间的一个球形单位
  22. ruv+=_Time.xx*_speed;//运动他们
  23. half4 c = tex2D (_MainTex, IN.uv_MainTex)+ tex2D(_LightTex, ruv.xy);
  24. o.Albedo = c.rgb;
  25. o.Alpha = c.a;
  26. }
  27. ENDCG
  28. }
  29. FallBack "Diffuse"
  30. }