Bilinear interpolation for quad vertex data via geometry shader #12
@@ -1,9 +1,8 @@
|
|||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
layout (lines_adjacency) in;
|
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
|
in VS_OUT
|
||||||
{
|
{
|
||||||
vec4 v_Color;// The interpolated vertex color
|
vec4 v_Color;// The interpolated vertex color
|
||||||
@@ -35,13 +34,10 @@ out GS_OUT
|
|||||||
#endif
|
#endif
|
||||||
} gs_out;
|
} gs_out;
|
||||||
|
|
||||||
void setVertex(int i) {
|
void setVertex(in int i, in vec2 edge) {
|
||||||
// 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));
|
|
||||||
|
|
||||||
gl_Position = gl_in[i].gl_Position;
|
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;
|
gs_out.v_TexCoord = gs_in[i].v_TexCoord;
|
||||||
|
|
||||||
@@ -57,33 +53,20 @@ void setVertex(int i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
setVertex(0);
|
// Set the colors once for the entire primitive
|
||||||
EmitVertex();
|
|
||||||
|
|
||||||
setVertex(1);
|
|
||||||
EmitVertex();
|
|
||||||
|
|
||||||
setVertex(2);
|
|
||||||
gs_out.v_Color[0] = gs_in[0].v_Color;
|
gs_out.v_Color[0] = gs_in[0].v_Color;
|
||||||
gs_out.v_Color[1] = gs_in[3].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[2] = gs_in[1].v_Color;
|
||||||
gs_out.v_Color[3] = gs_in[2].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();
|
EmitVertex();
|
||||||
|
setVertex(1, vec2(0.0, 1.0));
|
||||||
EndPrimitive();
|
|
||||||
|
|
||||||
setVertex(0);
|
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
setVertex(3, vec2(1.0, 0.0));
|
||||||
setVertex(2);
|
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
setVertex(2, vec2(1.0, 1.0));
|
||||||
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;
|
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
|
|||||||
Reference in new issue
Block a user