GLSL Sampler Problem

Started by
3 comments, last by Kazade 18 years, 1 month ago
Hey, I'm just learning about vertex and fragment shaders using glsl, and i've come across an error when compiling a shader and I cant figure out what it means. This is what my log is printing... Link successful. The GLSL vertex shader will run in hardware. The GLSL fragment shader will run in hardware. Validation failed - samplers of different types are bound to the same texture image unit. Yet i am setting different texture units like this...


	GLuint loc = gBufferFill->GetUniformLocation("diffuseTex");
	gBufferFill->SendUniform(loc, 0);

	loc = gBufferFill->GetUniformLocation("normalMap");
	gBufferFill->SendUniform(loc, 1);

	loc = gBufferFill->GetUniformLocation("normalisationCubeMap");
	gBufferFill->SendUniform(loc, 2);
This is probably a really simple question, but i cant find any information on the error im getting. Cheers. Luke.
Member of the NeHe team.
Advertisement
no idea, though try it without the normalisation cubemap.
youll get better quality on all cards + on quite a few cards itll be faster (and the % of cards itll be faster on will only go up )
Post the part of the code where you bind the textures to the texture slots, please.
Quote:Original post by Kazade
Hey,

I'm just learning about vertex and fragment shaders using glsl, and i've come across an error when compiling a shader and I cant figure out what it means. This is what my log is printing...

Link successful. The GLSL vertex shader will run in hardware. The GLSL fragment shader will run in hardware. Validation failed - samplers of different types are bound to the same texture image unit.

Yet i am setting different texture units like this...

	GLuint loc = gBufferFill->GetUniformLocation("diffuseTex");	gBufferFill->SendUniform(loc, 0);	loc = gBufferFill->GetUniformLocation("normalMap");	gBufferFill->SendUniform(loc, 1);	loc = gBufferFill->GetUniformLocation("normalisationCubeMap");	gBufferFill->SendUniform(loc, 2);


This is probably a really simple question, but i cant find any information on the error im getting.


When do you validate the shader program, before or after that code?

The validate message depends on the current over all state of the shader program and the OpenGL pipeline.

When you link a shader all uniform data defaults to zero, this includes samplers, as such when you validate the driver looks at your shader and see all the uniforms pointing at the same shader unit BUT being different types, thus it throws that error back at you.

If you setup the uniforms and THEN validate it should validate just fine.

OK I removed the normalisation cube map from the shader and it compiled and validated fine. Isnt it slower to normalise the vectors everytime? On a slightly related question i'm now having trouble using texture rectangles in my shader. My Radeon 9550 says it supports GL_EXT_texture_rectangle, yet when I use samplerRect in my shader it says its a syntax error.

I cant find any information anywhere on any of this stuff, the only information I have is from "More OpenGL Game Programming" but that doesnt help as most of the examples are for nVidia.

Luke.
Member of the NeHe team.

This topic is closed to new replies.

Advertisement