Geometry Shader Question

I’m trying out geometry shaders using glsl #150. Got a basic pass through shader done, but I have a question:

I have a paired vertex and fragment shader, where vryNormal is an output from vertex shader to the fragment.

If is possible for me to use a geometry shader between these two without having to change the inputs fragment shader?(the geometry shader will be generating new geometry and new vryNormal values)

Original:
(vert)out vryNormal -> (frag)in vryNormal
New:
(vert)out vryNormal -> (geometry)inout vryNormal -> (frag)in vryNormal

I think i read in the spec that you can’t have “inout” at a global level. Is there a way of doing this or do i have to design all my shaders that might have a geometry stage as having 3 stages, and just use a pass through shader in the case where i don’t want want to do anything in the geometry shader.

I7m sorry if this isn’t clear or it’s a dumb question, but any help is appreciated :slight_smile:

I think i read in the spec that you can’t have “inout” at a global level. Is there a way of doing this or do i have to design all my shaders that might have a geometry stage as having 3 stages, and just use a pass through shader in the case where i don’t want want to do anything in the geometry shader.

The correct way to do this is to use interface blocks for your shaders. Just give them all the same name, if they are intended to match. In GLSL, this is legal, because each kind of block (input, output, uniform) has its own namespace.

Thank you Alfonse, you have helped me a lot.

A further question:

in my shaders I have:


//vert
out VaryingNormal
{
	vec3 vryNormal;
};

//geom
in vec3 vryNormal[3];
out VaryingNormal
{
	vec3 vryNormal;
}outVN;

//frag
in VaryingNormal
{
	vec3 vryNormal;
};

which works fine, but this:


//vert
out VaryingNormal
{
	vec3 vryNormal;
};

//geom
in VaryingNormalA
{
	vec3 vryNormal[3];
}inVN;
out VaryingNormal
{
	vec3 vryNormal;
}outVN;

//frag
in VaryingNormal
{
	vec3 vryNormal;
};

does not work, or at least the normal value isn’t passed through properly as it is creating my depth buffer properly. There are also no warnings when compiling and linking the shader.

if I remove the inVN instance name the second example works fine. Could someone please explain the reason for this? is it because the interface blocks names don’t match? If so why does it work when I remove the instance name?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.