Hello all,
I am working on a project that defines PN triangles in a tessellation control shader from gridded elevation data. The associated tess eval shader evaluates the surface correctly and the fragment shader produces a good rendering. However, I would like to provide the fragment shader with information both about the 3D triangle from which a given fragment was rendered and information about adjacent rendered triangles, kind of replicating what a geometry shader could get if it was using triangles_adjacency primitives. Since that’s not compatible with the patch primitive necessary for the tessellation shaders, I would like to write ‘triangle’ data from a geometry shader to a shader storage buffer object. But right now I get a GLSL compilation error when I add a line of code that writes to any SSO in the geometry shader. The specific error is:
ErrorLog = 0x0050c1f0 "Geometry info
(0) : error C5133: multiple outputs associated with semantic "SBO_BUFFER[0]"
I have been able to write to SSOs in fragment shaders just fine so I’m guessing I’ve got the syntax wrong or something here is illegal. Here is a pass-through geometry shader that highlights the problem. If I include the line that assigns v to vertex[], I get the compilation error above. Please let me know if there is something else I need to do to get SSOs to work with geometry shaders. Thanks!
Jim
// Geometry shader that tries to write to a SSO
#version 430 core
struct Vertex { // vertex generated by tess eval shader and stored by geometry shaderint m_vertexID;
float easting;
float elevation;
float northing;
};
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
layout (std430, binding = 2) buffer gVertexBuffer { // backing store in application bufferVertex vertex[];
};
void main()
{for (int i = 0; i < gl_in.length(); i++) {
[INDENT=2]Vertex v;[/INDENT]
[INDENT=2]// Assign various things to v…[/INDENT]
[INDENT=2]vertex[gl_PrimitiveIDIn] = v; // CAUSES GLSL COMPILATION ERROR[/INDENT]
[INDENT=2]gl_Position = gl_in[i].gl_Position;[/INDENT]
[INDENT=2]EmitVertex();[/INDENT]
}
EndPrimitive();
}