Unity3D/Shader

Shader: Photoshop Overlay Effect

blueasa 2015. 4. 27. 17:09
  1. //Somehow achieves an effect similar to this:
  2. //#define BlendOverlayf(base, blend) (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))
  3. Shader "Photoshop/Overlay"
  4. {
  5. Properties
  6. {
  7. _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
  8. }
  9. SubShader
  10. {
  11. Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
  12. ZWrite Off Lighting Off Cull Off Fog { Mode Off } Blend DstColor SrcColor
  13. LOD 110
  14. Pass
  15. {
  16. CGPROGRAM
  17. #pragma vertex vert_vct
  18. #pragma fragment frag_mult
  19. #pragma fragmentoption ARB_precision_hint_fastest
  20. #include "UnityCG.cginc"
  21. sampler2D _MainTex;
  22. float4 _MainTex_ST;
  23. struct vin_vct
  24. {
  25. float4 vertex : POSITION;
  26. float4 color : COLOR;
  27. float2 texcoord : TEXCOORD0;
  28. };
  29. struct v2f_vct
  30. {
  31. float4 vertex : POSITION;
  32. fixed4 color : COLOR;
  33. half2 texcoord : TEXCOORD0;
  34. };
  35. v2f_vct vert_vct(vin_vct v)
  36. {
  37. v2f_vct o;
  38. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  39. o.color = v.color;
  40. o.texcoord = v.texcoord;
  41. return o;
  42. }
  43. float4 frag_mult(v2f_vct i) : COLOR
  44. {
  45. float4 tex = tex2D(_MainTex, i.texcoord);
  46. float4 final;
  47. final.rgb = i.color.rgb * tex.rgb * 2;
  48. final.a = i.color.a * tex.a;
  49. return lerp(float4(0.5f,0.5f,0.5f,0.5f), final, final.a);
  50. }
  51. ENDCG
  52. }
  53. }
  54. }




출처 : http://answers.unity3d.com/questions/384550/shader-photoshop-overlay-effect.html

반응형