- Home /
Shader error "Parser is hopelessly lost" when declaring uv2 variable.
I'm having an error where it says "Parser is hopelessly lost" on CGPROGRAM line. This only happens when I declare the "float2 uv2_OverlayTex" variable. I don't understand why this is, because in the Surface Shaders documentation, it says 'Texture coordinates must be named “uv” followed by texture name (or start it with “uv2” to use second texture coordinate set).' Why would it give me an error when doing exactly that? Is there something wrong with my approach? The texture name is "_OverlayTex", so the second uvs must be "uv2_OverlayTex", right?
So you know, the code is set up to have a second texture set to be an overlay (to use Photoshop terminology) on the main texture. I'm attempting to use different tiling for the second texture as I want it to be higher resolution, like a detail map. Thanks for any help you can offer!
Shader "Custom/Overlay Texture" {
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
_OverlayTex ("Overlaid Texture (RGBA)",2D) = "white" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _OverlayTex;
fixed4 _Color;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
float2 uv2_OverlayTex
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 basecol = tex2D (_MainTex, IN.uv_MainTex);
fixed4 overlaycol = tex2D (_OverlayTex, IN.uv_MainTex);
o.Albedo = basecol * _Color * overlaycol;
o.Alpha = basecol.a;
}
ENDCG
}
//Fallback "Diffuse"
}
Answer by CHPedersen · Nov 10, 2014 at 02:49 PM
It's because you have a missing semi-colon in the Input struct where you defined that float2. :)
It should be:
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
float2 uv2_OverlayTex; <----- Semi colin there
};
Oh my goodness gracious. I hate myself and thank you so much.
It's one of the classics, fret not, and know that everyone does that sometimes.
Please do mark the answer accepted. :)
Ah yes. I forgot I had to do more than thumbs up it. Also this makes me wish yet again $$anonymous$$onodevelop helped me find problems in shaderlab code like it does with C#. I feel like I'm coding blind. Thanks again.
Your answer
Follow this Question
Related Questions
Can anyone help me with reflective shader with fall off property? 0 Answers
Problem with lighting in CG Shader 1 Answer
ShaderLab on Unity3d Indie 2 Answers
Two shaders for one model 3 Answers