Copying all data from interface blocks

Hey, is there an easy way to copy all the data in an interface block from the input to the output? For example lets say in the geometry shader I have

in Vertex {
    vec4 color;
    vec3 camSpaceVert;
    vec3 camVector;
    vec3 norm;
    vec2 texCoord0;
} vVertIn[];

out Vertex {
    vec4 color;
    vec3 camSpaceVert;
    vec3 camVector;
    vec3 norm;
    vec2 texCoord0;
} vVertOut;

The geometry shader is only changing the gl_Position values (and doing layered rendering) so all of the input data just needs to be copied for every vertex. Is there a way to do the full copy implicitly or do I need to copy each member individually? This becomes cumbersome as members are added/removed from the inputs/outputs.

This doesn’t work:


vVertOut = vVertIn[i];

Thoughts? Thanks.

Have you tried putting the list of varyings into a struct and simply declare a struct variable in the in/out blocks? I don’t recall whether there is struct assignment support in GLSL, but sure what you tried shouldn’t work, even though they look like to be identical as the two interface blocks have different type, thus definitely not assignable.

Thanks for the suggestion, you’re correct. If I put it in a struct within the interface block is does how. However this extra layer of having to do interface.struct.value makes it pretty ugly also. And I think I’d need to split up the members that have different qualifiers (like noperspective) into different structs, which means it’s still a multi-line copy. Guess it’s not possible, thank’s for the suggestion though.

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