GLSL Geometry problem.

Started by
1 comment, last by slicer4ever 12 years ago
Hello all, i'm having a very weird problem with openGL glsl.

i'm just starting out with geometry shaders, so i have this:



#version 150
#extension GL_EXT_geometry_shader4: enable
layout(triangles) in;
layout(triangle_strip , max_vertices=3) out;
uniform mat4 View;
uniform mat4 Proj;
void main(){
for(int i=0;i<gl_VerticesIn;i++){
gl_Position = Proj*View*(gl_in.gl_Position+vec4(60.0,0.0,0.0,0.0));
gl_FrontColor = gl_in.gl_FrontColor;
EmitVertex();
}
EndPrimitive();
for(int i=0;i<gl_VerticesIn;i++){
gl_Position = Proj*View*gl_in.gl_Position;
gl_FrontColor = gl_in.gl_FrontColor;
EmitVertex();
}
EndPrimitive();
return;
}


but it's behaving..weirdly...

essentially, it seem to behave like it end's the geometry shader after the first EndPrimitive() call.

i can swap the two around loops around, and it'll draw the other primitive correctly. it just won't draw them both.

my gpu is an nvidia gtx560m, with the latest 296.10 drivers.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Advertisement
Hi!

A geometry shader must know how many vertices are written at most.
That's what you define in this line (aside from the output topology):
layout(triangle_strip , max_vertices=3) out;

Currently you output only at most 3 vertices, which would be exactly one triangle. No more.
If you want to output a second triangle, you'd have to tell GL that at most 6 vertices are written:
layout(triangle_strip , max_vertices=6) out;


That should do the trick. smile.png
Cheers!
ah, ok. i thought max_vertices was per-primitve, not max for the shader. thanks for the information.=-)
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

This topic is closed to new replies.

Advertisement