GLSL, interface unit

Problem:

I am learning OpenGL from the http://www.arcsynthesis.org/gltut/index.html tutorial and it was very difficult for me to get study guide 13: Geometry workers working (6+ hours)) and now it works after a really minor change code that won't actually work, and I need your help to find out why this is changing something.

Explanation - Edited:

The problem was that with the invariable code, the fragment shader did not get the correct input from the geometry shader, but either replacing the shader interface block with the geometry with separate variables, or giving the block an instance name, makes the program work fine. But these changes must be non-op.

The problem is probably a name clash.

How 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 value doesn't get to the fragment shader correctly */ } 

But either providing FragData with an instance name such as frag, using the frag.mappaing layout function, or using 3 separate variables solves the problem.

Why doesn't it work without an instance name?

Edit: It looks like a driver issue.

+7
source share
3 answers

Create instance names for all interface blocks, for example:

 FragData { // .. } gs2fs; 

And then:

 gs2fs.cameraCornerPos = vec4(vert[0].cameraSpherePos, 1.0); 
+2
source

Working with GLSL samples is often tedious due to unpleasant version issues.

Some general debugging tips:

  • make sure you include the correct version tags in your shader source.
  • make sure your OpenGL driver really supports this version by calling glGetString(GL_SHADING_LANGUAGE_VERSION)
  • create tools for transcoding shaders at runtime (for example, by assigning this key event)
  • and FOREMOST: use glGetShaderInfoLog() and glGetProgramInfoLog() !
+2
source

The problem actually was that you did not use the latest driver.

I ran this on linux and got the latest driver from the Ubuntu package manager: Nvidia 310-experimental. But although its experimental, it is rather old. When manually installing 319 from the nvidia website, the code worked fine without any changes.

The moral of the story:

Always use the latest drivers.

+1
source

All Articles