38 lines
1.0 KiB
GLSL
38 lines
1.0 KiB
GLSL
#version 430
|
|
|
|
layout(quads, equal_spacing, ccw) in; // Define the type of patch (e.g., quads)
|
|
|
|
layout(location = 0) uniform mat4 M;
|
|
|
|
layout(std140, binding = 0) uniform SceneUniforms
|
|
{
|
|
mat4 PV; //camera projection * view matrix
|
|
vec4 eye_w; //world-space eye position
|
|
};
|
|
|
|
in VertexData {
|
|
vec2 tex_coord;
|
|
} inData[];
|
|
|
|
out vec3 frag_position; // Ensure this matches the input in fragment.glsl
|
|
|
|
out VertexData {
|
|
vec2 tex_coord;
|
|
} outData;
|
|
|
|
void main()
|
|
{
|
|
// Interpolate the position using the barycentric coordinates from tessellation
|
|
vec3 pos = mix(mix(gl_in[0].gl_Position.xyz, gl_in[1].gl_Position.xyz, gl_TessCoord.x),
|
|
mix(gl_in[3].gl_Position.xyz, gl_in[2].gl_Position.xyz, gl_TessCoord.x),
|
|
gl_TessCoord.y);
|
|
|
|
frag_position = pos;
|
|
|
|
outData.tex_coord = mix(mix(inData[0].tex_coord, inData[1].tex_coord, gl_TessCoord.x),
|
|
mix(inData[3].tex_coord, inData[2].tex_coord, gl_TessCoord.x),
|
|
gl_TessCoord.y);
|
|
|
|
gl_Position = PV*M*vec4(pos, 1.0);
|
|
}
|