Passing varying variables through geometry shader

Go To StackoverFlow.com

3

I introduced a geometry shader to my OpenGL application. My shaders have quite a few of "varying" variables that I pass from the vertex shader to the fragment shader. Now, having introduced the geometry shader I have to manually pass every varying value in the geometry shader for each vertex. Is there a way to avoid that and do things "automatically"?

2012-04-05 15:29
by SimpleMan


2

No.

As soon as you introduce a geometry shader in your pipeline, if you want to pass variables from the vertex shader to the fragment shader you have to pass them manually, creating an input variable from the vertex shader and an output variable to the fragment shader. I don't know which GLSL version you're using, but you might want to check section 4.3.4 of the GLSL 3.30 spec.

2012-04-05 18:25
by fcoelho


2

No, because there's no sensible way to do that for anything except a noop geometry shader, and if your geometry shader isn't doing anything to the geometry, why is it enabled in the first place?

In general, a geometry shader takes a number of vertexes as input and produces a (different) number of vertexes as output. So which input vertex(es) should be mapped to which output vertex(es) 'automatically'?

2012-04-06 00:36
by Chris Dodd
Yeah, you are right. In my case geometry shader actually doesn't do anything to geometry apart from discarding vertices, so it makes sense there. But I understand that application of geometry shaders is much wider, thus what I want is not feasible. Thanks for explanation - SimpleMan 2012-04-06 18:34
There are very useful geometry shaders which do not alter geometry. geometry shaders are the only place all vertices of a primitive are available for computation. The "Single-Pass Wireframe" technique uses this information to add additional information without altering geometry. When using this technique, it's a bit annoying to have to pass-through all other values. However, we must, so cest'la'vie - David Jeske 2013-09-20 07:12
Ads