PDA

View Full Version : Attribute not active.



VansFannel
12-01-2010, 11:59 AM
Hello.

In reading the book: OpenGL ES 2.0 Programming Guide (Addison-Wesley). And I have read the following:

"Attribute names that do not exist or are not active in a vertex shader attached to the program object are ignored."

When an attribute is not active?

Thanks.

SteveBaker
12-04-2010, 12:46 PM
When the code that uses it is optimized away by the compiler...

attribute float x ;
float y, z ;
y = 6 - (1+2+3) ;
z = x * y ;

...the compiler might manage to optimize that to:

float y, z ;
y = z = 0 ;

...and now 'x' isn't needed - so it "does not exist" in the compiled binary of the shader.

Hence a variable that you might have declared and even used throughout the shader may simply not exist at run time. That's why "inactive" variables are treated as if they don't exist...because at the level of the binary shader, they literally don't exist. But you don't want it to be an error to pass a value for that attribute into the shader because very often you run the same mesh data through multiple shaders - some of which may use the attribute and others may not.