fix: applied a workaround to fix a Microsoft HLSL compiler issue
close #131 https://fogbugz.unity3d.com/default.asp?934464_sjh4cs4ok77ne0cj&_ga=2.124069071.432066521.1640792064-45545210.1640792064develop
parent
f59d147fe0
commit
50c41f29cc
|
@ -7,6 +7,11 @@ float4x4 _GameVP;
|
||||||
float4x4 _GameTVP;
|
float4x4 _GameTVP;
|
||||||
half4 _MaskInteraction;
|
half4 _MaskInteraction;
|
||||||
|
|
||||||
|
float CustomStep(float a, float x)
|
||||||
|
{
|
||||||
|
return x >= a;
|
||||||
|
}
|
||||||
|
|
||||||
fixed Approximately(float4x4 a, float4x4 b)
|
fixed Approximately(float4x4 a, float4x4 b)
|
||||||
{
|
{
|
||||||
float4x4 d = abs(a - b);
|
float4x4 d = abs(a - b);
|
||||||
|
@ -30,16 +35,16 @@ float SoftMaskInternal(float4 clipPos)
|
||||||
float4 cpos = mul(_GameTVP, mul(UNITY_MATRIX_M, wpos));
|
float4 cpos = mul(_GameTVP, mul(UNITY_MATRIX_M, wpos));
|
||||||
view = lerp(view, cpos.xy / cpos.w * 0.5 + 0.5, isSceneView);
|
view = lerp(view, cpos.xy / cpos.w * 0.5 + 0.5, isSceneView);
|
||||||
#if UNITY_UV_STARTS_AT_TOP
|
#if UNITY_UV_STARTS_AT_TOP
|
||||||
view.y = lerp(view.y, 1 - view.y, step(0, _ProjectionParams.x));
|
view.y = lerp(view.y, 1 - view.y, CustomStep(0, _ProjectionParams.x));
|
||||||
#endif
|
#endif
|
||||||
#elif UNITY_UV_STARTS_AT_TOP
|
#elif UNITY_UV_STARTS_AT_TOP
|
||||||
view.y = lerp(view.y, 1 - view.y, step(0, _ProjectionParams.x));
|
view.y = lerp(view.y, 1 - view.y, CustomStep(0, _ProjectionParams.x));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fixed4 mask = tex2D(_SoftMaskTex, view);
|
fixed4 mask = tex2D(_SoftMaskTex, view);
|
||||||
half4 alpha = saturate(lerp(fixed4(1, 1, 1, 1), lerp(mask, 1 - mask, _MaskInteraction - 1), _MaskInteraction));
|
half4 alpha = saturate(lerp(fixed4(1, 1, 1, 1), lerp(mask, 1 - mask, _MaskInteraction - 1), _MaskInteraction));
|
||||||
#if SOFTMASK_EDITOR
|
#if SOFTMASK_EDITOR
|
||||||
alpha *= step(0, view.x) * step(view.x, 1) * step(0, view.y) * step(view.y, 1);
|
alpha *= CustomStep(0, view.x) * CustomStep(view.x, 1) * CustomStep(0, view.y) * CustomStep(view.y, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return alpha.x * alpha.y * alpha.z * alpha.w;
|
return alpha.x * alpha.y * alpha.z * alpha.w;
|
||||||
|
@ -53,4 +58,4 @@ float SoftMaskInternal(float4 clipPos)
|
||||||
#define SoftMask(clipPos, worldPosition) SoftMaskInternal(clipPos)
|
#define SoftMask(clipPos, worldPosition) SoftMaskInternal(clipPos)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // UI_SOFTMASK_INCLUDED
|
#endif // UI_SOFTMASK_INCLUDED
|
Loading…
Reference in New Issue