Jump to content
  • Advertisement
Sign in to follow this  
Nairb

GLSL Geom Shader Problem

This topic is 4087 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!