- Home /
[Unity3] How can I fix this shader 'texture' syntax error under 3.0?
Hi,
Test driving the 3.0 Beta here, hope it's okay to ask a bleeding edge question. I'm encountering the following error when trying to use the ForceField shader from the Wiki:
Shader error in 'Shield': GLSL vertex shader: ERROR: 0:289: 'texture' : syntax error syntax error at line 16 Shader error in 'Shield': Shader program had errors at line 17
The referenced code is:
15 Pass {
16 CGPROGRAM
17 #pragma vertex vert
18 #pragma fragment frag
19 #pragma fragmentoption ARB_fog_exp2
20 #include "UnityCG.cginc"
Any pointers how I could get this working under 3.0? I checked the included docs, but the syntax still looks the same in there. I realize the syntax may be tentative and I might have to change it again, just want to get it working for the time being.
Thanks
$$anonymous$$, as a recommendation, unity3 is a better tag than beta, as it has long-term relevance.
Answer by aayars · Jul 08, 2010 at 02:31 AM
Ack, I just needed to stare at the error longer.
Seems that "texture" is a keyword now. It is used as a variable name later in the shader. I changed the variable name, and it now compiles fine.
I withdraw this question :-)
Actually let it remain, as it will be useful for others. Have an upvote for researching your own problem ins$$anonymous$$d of sitting around waiting for a reply. :-)
Be sure to checkmark your answer in 48 hours, so people know you solved your problem. :)
"texture" is not a keyword per se, but becomes a keyword when shader is compiled into OpenGL ES 2.0 for iPhone/Android (which is on by default). You could add "#pragma exclude_renderers gles" to your shader to make it not compile into that target if you're sure you won't need it.
But yeah, probably best to avoid na$$anonymous$$g variables "texture".