【发布时间】:2017-03-27 04:51:01
【问题描述】:
我正在开发 Unity 2D 平台游戏。 我正在使用我找到here 的着色器,但是当我翻转我的精灵(比例 -1)时, 精灵消失了,我对着色器编码知之甚少, 而且我在谷歌上没有找到任何帮助,任何人都可以帮助修复着色器吗? 这是着色器:
Properties {
[PerRendererData] _MainTex ("Main texture", 2D) = "white" {}
_DissolveTex ("Dissolution texture", 2D) = "gray" {}
_Threshold ("Threshold", Range(0., 1.01)) = 0.
}
SubShader {
Tags { "Queue"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
v2f vert(appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord;
return o;
}
sampler2D _DissolveTex;
float _Threshold;
fixed4 frag(v2f i) : SV_Target {
float4 c = tex2D(_MainTex, i.uv);
float val = tex2D(_DissolveTex, i.uv).r;
c.a *= step(_Threshold, val);
return c;
}
ENDCG
}
}
【问题讨论】: