ImageBlendEffect.shader 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Custom/ImageBlendEffect"
  3. {
  4. Properties
  5. {
  6. _MainTex ("Base", 2D) = "" {}
  7. _BlendTex ("Image", 2D) = "" {}
  8. _BumpMap ("Normalmap", 2D) = "bump" {}
  9. }
  10. CGINCLUDE
  11. #include "UnityCG.cginc"
  12. struct v2f
  13. {
  14. float4 pos : POSITION;
  15. float2 uv : TEXCOORD0;
  16. };
  17. sampler2D _MainTex;
  18. sampler2D _BlendTex;
  19. sampler2D _BumpMap;
  20. float _BlendAmount;
  21. float _EdgeSharpness;
  22. float _SeeThroughness;
  23. float _Distortion;
  24. v2f vert(appdata_img v)
  25. {
  26. v2f o;
  27. o.pos = UnityObjectToClipPos(v.vertex);
  28. o.uv = v.texcoord.xy;
  29. return o;
  30. }
  31. half4 frag(v2f i) : COLOR
  32. {
  33. float4 blendColor = tex2D(_BlendTex, i.uv);
  34. blendColor.a = blendColor.a + (_BlendAmount * 2 - 1);
  35. blendColor.a = saturate(blendColor.a * _EdgeSharpness - (_EdgeSharpness - 1) * 0.5);
  36. //Distortion:
  37. half2 bump = UnpackNormal(tex2D(_BumpMap, i.uv)).rg;
  38. float4 mainColor = tex2D(_MainTex, i.uv+bump*blendColor.a*_Distortion);
  39. //return float4(i.uv.x+bump.x,i.uv.y+bump.y,0.5,0)*blendColor.a*_Distortion; //Test
  40. float4 overlayColor = blendColor;
  41. overlayColor.rgb = mainColor.rgb*(blendColor.rgb+0.5)*(blendColor.rgb+0.5); //double overlay
  42. blendColor = lerp(blendColor,overlayColor,_SeeThroughness);
  43. return lerp(mainColor, blendColor, blendColor.a);
  44. }
  45. ENDCG
  46. Subshader
  47. {
  48. Pass
  49. {
  50. ZTest Always Cull Off ZWrite Off
  51. Fog
  52. {
  53. Mode off
  54. }
  55. CGPROGRAM
  56. #pragma fragmentoption ARB_precision_hint_fastest
  57. #pragma vertex vert
  58. #pragma fragment frag
  59. ENDCG
  60. }
  61. }
  62. Fallback off
  63. }