Shader: Photoshop Overlay Effect
Unity3D/Shader / 2015. 4. 27. 17:09
- //Somehow achieves an effect similar to this:
- //#define BlendOverlayf(base, blend) (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))
- Shader "Photoshop/Overlay"
- {
- Properties
- {
- _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
- }
- SubShader
- {
- Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
- ZWrite Off Lighting Off Cull Off Fog { Mode Off } Blend DstColor SrcColor
- LOD 110
- Pass
- {
- CGPROGRAM
- #pragma vertex vert_vct
- #pragma fragment frag_mult
- #pragma fragmentoption ARB_precision_hint_fastest
- #include "UnityCG.cginc"
- sampler2D _MainTex;
- float4 _MainTex_ST;
- struct vin_vct
- {
- float4 vertex : POSITION;
- float4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- };
- struct v2f_vct
- {
- float4 vertex : POSITION;
- fixed4 color : COLOR;
- half2 texcoord : TEXCOORD0;
- };
- v2f_vct vert_vct(vin_vct v)
- {
- v2f_vct o;
- o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
- o.color = v.color;
- o.texcoord = v.texcoord;
- return o;
- }
- float4 frag_mult(v2f_vct i) : COLOR
- {
- float4 tex = tex2D(_MainTex, i.texcoord);
- float4 final;
- final.rgb = i.color.rgb * tex.rgb * 2;
- final.a = i.color.a * tex.a;
- return lerp(float4(0.5f,0.5f,0.5f,0.5f), final, final.a);
- }
- ENDCG
- }
- }
- }
출처 : http://answers.unity3d.com/questions/384550/shader-photoshop-overlay-effect.html
반응형
'Unity3D > Shader' 카테고리의 다른 글
[펌] 휘어지는 효과 렌더링 (0) | 2016.05.16 |
---|---|
[NGUI] Overlay Shader with Panel Clipping (0) | 2015.06.09 |
Unity3d Shader Syntax Highlighting(Visual Studio 2010/2012/2013) (0) | 2015.03.24 |
[NGUI] Unlit - Transparent Colored Additive (4) | 2015.01.27 |
Unity3d Shader Syntax Highlighting(Visual Studio 2010 또는 2012) (0) | 2014.07.21 |