Sign in to follow this  

GLSL Geom Shader Problem

This topic is 3725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a really weird error with geometry shaders. Just something simple. Takes a point (x,y,z) and creates a triangle with height x. The code below works:
gl_Position = vec4(0, 0, 0, 1);
gl_Position = gl_ModelViewProjectionMatrix * gl_Position;
gl_FrontColor = gl_FrontColorIn[0];
EmitVertex();
  
gl_Position = vec4(5, 10, 0, 1);
gl_Position = gl_ModelViewProjectionMatrix * gl_Position;
gl_FrontColor = gl_FrontColorIn[0];
EmitVertex();
  
gl_Position = vec4(10, 0, 0, 1);
gl_Position = gl_ModelViewProjectionMatrix * gl_Position;
gl_FrontColor = gl_FrontColorIn[0];
EmitVertex();

So I know it's not a problem generating my triangle. However, when I try to change the height based on a variable (float p = gl_PositionIn[0].x, where I'm careful not to transform my point in the vertex shader) it gets all wonky. I tested that p was equal to 10 with a quick if statement (which gave true only on 10, so it wouldn't be a floating point issue). When I set p manually (float p = 10) it works fine. So I have no clue what's going on. Anyone seen behaviour like this and know what I'm doing wrong? Cheers, --Brian

Share this post


Link to post
Share on other sites
Solved that pretty quickly.

Apparently a line like gl_Position = gl_ModelViewProjectionMatrix * gl_Position produces the invalid result. Setting a temporary variable to my new value of gl_Position and using it on the right hand side fixed the problem.

I dunno, maybe there's something hidden in the GLSL documentation about this, but it looks like a bug to me...

Cheers,
--Brian

Share this post


Link to post
Share on other sites

This topic is 3725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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