Bilinear interpolation for quad vertex data via geometry shader #12
@@ -1,9 +1,8 @@
|
||||
#version 330 core
|
||||
|
||||
layout (lines_adjacency) in;
|
||||
layout (triangle_strip, max_vertices = 6) out;
|
||||
layout (triangle_strip, max_vertices = 4) out;
|
||||
|
||||
// TODO: [VEN][GEO-NEO-AO] Cleaner layout definitions?
|
||||
in VS_OUT
|
||||
{
|
||||
vec4 v_Color;// The interpolated vertex color
|
||||
@@ -35,13 +34,10 @@ out GS_OUT
|
||||
#endif
|
||||
} gs_out;
|
||||
|
||||
void setVertex(int i) {
|
||||
// TODO: [VEN][GEO-NEO-AO] These numbers were found by 'guessing'
|
||||
const vec2 edges[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
|
||||
|
||||
void setVertex(in int i, in vec2 edge) {
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
|
||||
gs_out.edge = edges[i];
|
||||
gs_out.edge = edge;
|
||||
|
||||
gs_out.v_TexCoord = gs_in[i].v_TexCoord;
|
||||
|
||||
@@ -57,33 +53,20 @@ void setVertex(int i) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
setVertex(0);
|
||||
EmitVertex();
|
||||
|
||||
setVertex(1);
|
||||
EmitVertex();
|
||||
|
||||
setVertex(2);
|
||||
// Set the colors once for the entire primitive
|
||||
gs_out.v_Color[0] = gs_in[0].v_Color;
|
||||
gs_out.v_Color[1] = gs_in[3].v_Color;
|
||||
gs_out.v_Color[2] = gs_in[1].v_Color;
|
||||
gs_out.v_Color[3] = gs_in[2].v_Color;
|
||||
|
||||
// Define the triangle strip as: ABDC
|
||||
setVertex(0, vec2(0.0, 0.0));
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
setVertex(0);
|
||||
setVertex(1, vec2(0.0, 1.0));
|
||||
EmitVertex();
|
||||
|
||||
setVertex(2);
|
||||
setVertex(3, vec2(1.0, 0.0));
|
||||
EmitVertex();
|
||||
|
||||
setVertex(3);
|
||||
|
||||
gs_out.v_Color[0] = gs_in[0].v_Color;
|
||||
gs_out.v_Color[1] = gs_in[3].v_Color;
|
||||
gs_out.v_Color[2] = gs_in[1].v_Color;
|
||||
gs_out.v_Color[3] = gs_in[2].v_Color;
|
||||
setVertex(2, vec2(1.0, 1.0));
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
Reference in new issue
Block a user