BlockGame/blocks/geometry.shader
2022-02-06 18:28:12 +01:00

28 lines
594 B
GLSL

R"(#version 330
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
out vec3 normal;
out vec4 pos;
in vec2 v_texcoords[];
out vec2 texcoords;
void main( void )
{
vec3 a = ( gl_in[1].gl_Position - gl_in[0].gl_Position ).xyz;
vec3 b = ( gl_in[2].gl_Position - gl_in[0].gl_Position ).xyz;
vec3 N = normalize( cross( b, a ) );
for( int i=0; i<gl_in.length( ); ++i )
{
gl_Position = gl_in[i].gl_Position;
normal = N;
pos = gl_in[i].gl_Position;
texcoords = v_texcoords[i];
EmitVertex( );
}
EndPrimitive( );
})";