Suppose I have a geometry shader that computes its output gl_Position
from some inputs other than gl_in[].gl_Position
. If the previous pipelines stages (vertex and tessellation) do not write to their out gl_Position
, does the action of the entire pipeline still remain well-defined?
Or put it other way, does the value of gl_Position
has any effect on the functioning of the GL before the completion of the Geometry shader? If not, it would mean I can simply use it as an extra slot for passing data without any special spatial interpretation between stages, right?
(The question assumes OpenGL 4.5 forward profile.)
gl_Position
only needs to be written by the final Vertex Processing stage (VS, tessellation, and GS) in the rendering pipeline. So if you have an active GS, the VS that connects to it need not write to gl_Position
at all. Or it can put any arbitrary vec4
data in it.
Do note that gl_Position
does still need to be written by whatever the final vertex processing stage is. Assuming you want rasterization, of course. And no, that's not being flippant; you could be doing transform feedback.
If not, it would mean I can simply use it as an extra slot for passing data without any special spatial interpretation between stages, right?
If there's a GS, then none of the outputs from the previous shader stages will have "any special spatial interpretation". gl_Position
isn't special in this regard.
Interpolation is a function of the Rasterizer, which happens after vertex processing. Indeed, in GLSL 4.30+, the interpolation qualifiers on the fragment shader inputs are the only ones that matter. They're not even used for interface matching anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With