Jump to content
  • Advertisement
Sign in to follow this  
billconan

why can't i access normls during the geometry shader

This topic is 3227 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

hello guys, i tried in my glsl geometry shader to access the vertex normals, something like gl_NormalIn, but i then realized that glsl doesn't have this variable defined during the geometry shader. what i'm trying to do is generating a surfel on the fly. the input of my geometry shader is a point with a normal, and the output is a small disk centered at the point with the same normal. but if i don't know the normal, how i'm suppose to do that? i didn't find many geometry shader documents online, but people say it is easy to generate point sprites with geometry shader. thanks

Share this post


Link to post
Share on other sites
Advertisement
The normal is not an input of the geometry shader. The normal is meant to be an input of the vertex shader to compute vertex lighting then the normal should be discarded.

However, you can pass the normal through shaders using a varying.

The above page linked by V-man shows how to use varyings to pass the normal from a vertex shader to a geometry shader.

Make sure to declare it as a single vector in the vertex shader and a tuple in the geometry shader (most likely a triplet, for triangles). For instance in the vertex shader, the varying will be declared like this :
varying vec3 VNormal;

And in the geometry shader it would be like this :
varying in vec3 VNormal[3];

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!