Guest User

Untitled

a guest
Oct 24th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. Shader "CookbookShaders/Ch08/Blend Mode/AddImageEffect.shader"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Base (RGB)", 2D) = "white" {}
  6. _BlendTex ("Blend Texture", 2D) = "white" {}
  7. _BlendOpacity ("Blend Opacity", Range(0, 1)) = 1
  8. }
  9.  
  10. SubShader
  11. {
  12. Pass
  13. {
  14. CGPROGRAM
  15. #pragma vertex vert_img
  16. #pragma fragment frag
  17. #pragma fragmentoption ARB_precision_hint_fastest
  18. #include "UnityCG.cginc"
  19.  
  20. // declare corresponding CGPROGRAM variables
  21. uniform sampler2D _MainTex;
  22. uniform sampler2D _BlendTex;
  23. fixed _BlendOpacity;
  24.  
  25. fixed4 frag(v2f_img i) : COLOR
  26. {
  27. // Get the colors from the RenderTexture and the UVs from the v2f_img struct
  28. fixed4 renderTex = tex2D(_MainTex, i.uv);
  29. fixed4 blendTex = tex2D(_BlendTex, i.uv);
  30.  
  31. // perform Add blend mode
  32. fixed4 blendedTex = renderTex + blendTex;
  33.  
  34. // lerp between no blending and full blending
  35. renderTex = lerp(renderTex, blendedTex, _BlendOpacity);
  36.  
  37. return renderTex;
  38. }
  39.  
  40. ENDCG
  41. }
  42. }
  43. }
Add Comment
Please, Sign In to add comment