PDA

View Full Version : Unexpected shader behaviour



_x57_
08-18-2011, 10:28 AM
Hi everyone,

after migrating my application development to a new pc my shaders seem not to work anymore and the problem has been driving me crazy for two days now. I started outcommenting line by line backwards and ended up with this simple vertex shader showing unexpected behaviour (at least i don't understand whats going on):



#version 330 compatibility

uniform int renderPass;
flat out vec4 clipCoord;

void main( void )
{
clipCoord = ftransform();

if (renderPass == 0) {
gl_Position = clipCoord;
} else {
gl_Position = vec4((clipCoord.xyz/clipCoord.w) + vec3(0.5,0.5,0), 1);
}
return;

// ... things i do not do at the moment, hence the return above
}



I basically render an object from vbo (into an fbo with two color attachment textures if that is important) - in the first pass (renderPass==0) i render its faces/triangles and in the second pass i render its vertices as GL_POINTS.

I expected that the points rendered in the second pass are translated to the right by 0.25*viewport_width compared to the faces rendered in the first pass. However, this is only true on my 'old system' - on the 'new system' they coincide perfectly with the faces as if the +vec3(0.5, 0.5,0) was not there.

Also, exchanging the two 'gl_Position = ...' lines causes both (points and faces) to be drawn WITH the offset.

'old' system: WinVista 64, nv GeForce 9800GT, driver version 266.58

'new' system: Win 7 64, GeForce 560 GTX, driver: 280.26(current)
(also tested GF 480GTX, and several other older display driver versions with both cards (not simultaneously installed))

The problem persists when i directly copy the executables and all libs used in my app to the other system and run it (no recompile).

I don't know if this might have s.th. to do with my problem:
I also noted that using "gl_PointSize=1.0" later in the shader produced "scrambled" fbo contents, so i removed it (1.0 seems to be the default anyway).

Bruce Merry
08-23-2011, 03:08 AM
The most likely explanation for your symptoms would seem to be that the renderPass uniform isn't being set correctly for some reason. Perhaps call glGetUniform after setting the uniform to check that it is really getting set?



I also noted that using "gl_PointSize=1.0" later in the shader produced "scrambled" fbo contents, so i removed it (1.0 seems to be the default anyway).

Are you using vertex program point size mode? If not then it will use the API state, which does default to 1.0 (although assigning 1.0 to it really shouldn't break anything - that smells like a driver problem).