Jump to content

  • Log In with Google      Sign In   
  • Create Account


GLSL Geometry problem.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 slicer4ever   Crossbones+   -  Reputation: 3684

Like
0Likes
Like

Posted 02 April 2012 - 08:40 AM

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[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;
}

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.

Sponsor:

#2 Tsus   Members   -  Reputation: 1028

Like
2Likes
Like

Posted 03 April 2012 - 01:29 PM

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. Posted Image
Cheers!

Acagamics e.V. – IGDA Student Game Development Club (University of Magdeburg, Germany)


#3 slicer4ever   Crossbones+   -  Reputation: 3684

Like
0Likes
Like

Posted 04 April 2012 - 03:33 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS