Shader Blend混合效果
1、Blend SrcAlpha OneMinusSrcAlpha 正常模式(透明度混合)
BlendOp MinBlend One One
1
2
1
2
6、变亮
BlendOp MaxBlend One One
1
2
1
2
测试代码
Shader "Wp/Blend"{ Properties{ _Color("Color", Color) = (1, 1, 1, 1) _MainTex("MainTex", 2D) = "White" {} _AlphaScale("AlphaScale", Range(0, 1)) = 1 } SubShader{ Tags{ "Queue" = "Transparent" "Ignoreprojector" = "True" "RenderType" = "Transparent" } Pass{ ZWrite off// Blend SrcAlpha OneMinusSrcAlpha// Blend OneMinusDstColor One// Blend DstColor Zero// Blend DstColor SrcColor// BlendOp Max// Blend One One// Blend OneMinusDstColor One Blend One One CGPROGRAM #pragma vertex vert #pragma fragment frag fixed4 _Color; sampler2D _MainTex; float4 _MainTex_ST; float _AlphaScale; struct a2v{ float4 pos : POSITION; float4 normal : NORMAL; float texcoord : TEXCOORD0; }; struct v2f{ float4 pos : SV_POSITION; float3 worldNormal : TEXCOORD0; float3 worldPos : TEXCOORD1; float4 uv : TEXCOORD2; }; v2f vert(a2v v){ v2f o; o.pos = mul(UNITY_MATRIX_MVP, v.pos); return o; } fixed4 frag(v2f i) : SV_Target{ return fixed4(_Color.rgb, _Color.a * _AlphaScale); } ENDCG } } Fallback "Diffuse"}
网友评论