Sign in to follow this  

why can't i access normls during the geometry shader

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
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

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