赞
踩
测试场景:
一个Standard Shader的cube 放置在后面加上一个测试shader的球放置在前面
1、Blend SrcAlpha OneMinusSrcAlpha 正常模式(透明度混合)
2、Blend OneMinusDstColor One 柔和相加(soft Additive)
3、Blend DstColor Zero 正片叠底 (Multiply)相乘
4、Blend DstColor SrcColor 两倍相乘 (2X Multiply)
5、 变暗
6、变亮
7、Blend OneMinusDstColor One 滤色
8、Blend One One 线性变淡
测试代码
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 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 //1 //Blend SrcAlpha OneMinusSrcAlpha //2 //Blend OneMinusDstColor One //3 //Blend DstColor Zero //4 //Blend DstColor SrcColor //5 /*BlendOp Min Blend One One*/ //6 /*BlendOp Max Blend One One*/ //7 //Blend OneMinusDstColor One //8 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 = UnityObjectToClipPos(v.pos); return o; } fixed4 frag(v2f i) : SV_Target{ return fixed4(_Color.rgb, _Color.a * _AlphaScale); } ENDCG } } Fallback "Diffuse" }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。