图片加印花

作者:追风剑情 发布于:2018-12-28 11:48 分类:Shader

示例

  1. Shader "Custom/DecalTest"
  2. {
  3. Properties
  4. {
  5. _Color ("Main Color", Color) = (1,1,1,1)
  6. _MainTex ("Base (RGB)", 2D) = "white" {}
  7. _DecalTex ("Decal (RGBA)", 2D) = "black" {}
  8. }
  9. SubShader {
  10. Tags { "RenderType"="Opaque" }
  11. LOD 250
  12.  
  13. CGPROGRAM
  14. #pragma surface surf Lambert
  15.  
  16. sampler2D _MainTex;
  17. sampler2D _DecalTex;
  18. fixed4 _Color;
  19.  
  20. struct Input {
  21. float2 uv_MainTex;
  22. float2 uv_DecalTex;
  23. };
  24.  
  25. void surf (Input IN, inout SurfaceOutput o) {
  26. fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
  27. half4 decal = tex2D(_DecalTex, IN.uv_DecalTex);
  28. c.rgb = lerp (c.rgb, decal.rgb, decal.a);
  29. c *= _Color;
  30. o.Albedo = c.rgb;
  31. o.Alpha = c.a;
  32. }
  33. ENDCG
  34. }
  35.  
  36. Fallback "Legacy Shaders/Diffuse"
  37. }

效果

1111.png22222.png

标签: Shader

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号