Syntax Error with "Hello World" Shader

From part 1 of the shader tutorial…

Shader "simple" {
    Properties {
        _Color ("Main Color", Color) = (1,.5,.5,1)
    }
	Pass {
        Material {
            Diffuse [_Color]
        }
        Lighting On
    }
}

Syntax error on line 5. Line five is a closing brace.

It works like this:

Shader "simple" { 
	Properties { 
		_Color ("Main Color", Color) = (1,.5,.5,1) 
	} 
	SubShader {
		Pass { 
			Material { 
				Diffuse [_Color] 
			} 
			Lighting On 
		}
	} 
}

Whooops. And I thought I was the one learning ShaderLab here. :wink:

Waits to find out he’s dead wrong anyways

-Jon

The second one has the correct number of braces (don’t forget that the shader itself has to be closed). Depending on where in the parsing/lexing process for the shader errors of that type are generated, it could give a bad line number (or a confusing one, anyways), or I could have counted the lines wrong… :wink:

You counted the lines/braces wrong. Open up the ShaderLab tutorial and try it for yourself. The first one is missing the SubShader part.

I think you read me incorrectly. I’m not saying I was having trouble, I was saying the tutorial was incorrect! :wink:

-Jon

Thanks, I fixed it in the manual -