Sign in to follow this  
slicer4ever

OpenGL GLSL Geometry problem.

Recommended Posts

Hello all, i'm having a very weird problem with openGL glsl.

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

[code]

#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[i].gl_Position+vec4(60.0,0.0,0.0,0.0));
gl_FrontColor = gl_in[i].gl_FrontColor;
EmitVertex();
}
EndPrimitive();
for(int i=0;i<gl_VerticesIn;i++){
gl_Position = Proj*View*gl_in[i].gl_Position;
gl_FrontColor = gl_in[i].gl_FrontColor;
EmitVertex();
}
EndPrimitive();
return;
}
[/code]

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.

Share this post


Link to post
Share on other sites
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):
[CODE]layout(triangle_strip , max_vertices=3) out;
[/CODE]
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:
[CODE]layout(triangle_strip , max_vertices=6) out;
[/CODE]

That should do the trick. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
Cheers!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this