【发布时间】:2018-04-22 11:58:13
【问题描述】:
我的 Timer.shader 文件有 2 个错误,但不明白为什么,我是 Unity3D 的新手
这是错误:
Shader error in 'Timer': 'dot': no matching 0 parameter intrinsic function; Possible intrinsic functions are: dot(floatM|halfM|doubleM|min10floatM|min16floatM|intM|uintM|min12intM|min16intM|min16uintM, floatM|halfM|doubleM|min10floatM|min16floatM|intM|uintM|min12intM|min16intM|min16uintM) at line 51 (on gles3)
Shader error in 'Timer': syntax error: unexpected token 'h' at line 51 (on gles3)
还有错误的文件:Timer.shader
Shader "Timer"
{
Properties
{
_MainTex ("Texture Image", 2D) = "white" {}
_SecondTex ("Second Image", 2D) = "white" {}
_MaskTime ("Time", Range (0, 1)) = 0
_MPow ("Pow", Range (5, 50)) = 5
}
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _MainTex;
sampler2D _SecondTex;
fixed _MaskTime;
fixed _MPow;
struct vertexInput
{
float4 vertex : POSITION;
fixed4 texcoord : TEXCOORD0;
};
struct vertexOutput
{
fixed4 pos : SV_POSITION;
fixed2 tex : TEXCOORD0;
};
vertexOutput vert (vertexInput input)
{
vertexOutput output;
output.tex = input.texcoord;
output.pos = UnityObjectToClipPos (input.vertex);
return output;
};
float4 frag (vertexOutput input) : COLOR
{
fixed3 c0 = tex2D (_MainTex, fixed2 (input.tex));
fixed3 c1 = tex2D (_SecondTex, fixed2 (input.tex));
fixed dot1 = dot (normalize (input.tex.xy-fixed2 (0.5h, 0.5h)), fixed2 (0h, 1h));
half ang = acos (dot1);
ang = degrees (ang);
ang = (input.tex.x<0.5h)?360h-ang:ang;
fixed pos = min ((ang/360h), 360h);
pos = pos+0.9h-_MaskTime+(0.2h*(1h-_MaskTime));
pos = saturate (pow (pos, _MPow*_MPow));
fixed3 c = lerp (c1.rgb, c0, pos);
return fixed4 (c, 1h);
//return pos;
}
ENDCG
}
}
}
如果需要更多信息,请告诉我,因为就像我说我是新人一样,我不太了解这个错误。
我正在尝试构建到 Android,但一切都崩溃了,因为如果我只按播放,一切都会在没有警告的情况下运行。
当然是其他平台的错误触发,但我假装构建到Android
【问题讨论】:
-
你为什么在你的着色器中使用
h?只需删除任何h在您的着色器中,例如0.5h到0.5
标签: unity3d