I'm learning OpenGL from http://www.arcsynthesis.org/gltut/index.html tutorial, and I had really hard time getting Tutorial 13: Geometry Impostors working (6+ hours), and it is now working after a really minor change in the code that should actually be no-op, and I need your help to find out why does it change anything.
The problem was that with the unchanged code the fragment shader didn't get correct input from the geometry shader, but with either replacing geometry shader's out interface block to separate variables or giving the block an instance name makes the program work fine. But these changes should be no-op.
The problem is probably a name collision.
Like this it doesn't work:
in VertexData
{
vec3 cameraSpherePos;
float sphereRadius;
} vert[];
out FragData
{
flat vec3 cameraSpherePos;
flat float sphereRadius;
smooth vec2 mapping;
};
void main()
{
mapping =
cameraSpherePos =
sphereRadius =
EmitVertex();
/* mapping's value doesn't get to the fragment shader correctly */
}
But either giving FragData an instance name like frag, and using frag.mappaing instad of mapping, or using 3 separate variables solves the problem.
Why doesn't it work without an instance name?
Edit: It seems to be a driver issue.
Create instance names for all interface blocks like:
FragData { /* ... */ } gs2fs;
And then:
gs2fs.cameraCornerPos = vec4(vert[0].cameraSpherePos, 1.0);
Working with GLSL samples often gets tedious due to nasty version problems.
Some general debugging advice:
glGetString(GL_SHADING_LANGUAGE_VERSION)
glGetShaderInfoLog()
and glGetProgramInfoLog()
!The problem actually was with not using the latest driver.
I was running this on linux, and got the latest driver from Ubuntu's package manager: the Nvidia 310-experimental. But even though its experimental, it's rather old. With manually installing the 319 from nvidia's site the code worked fine without any change.
Moral of the story:
Always use the latest drivers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With