BlockGame/blocks/geometry.shader

28 lines
594 B
Plaintext
Raw Permalink Normal View History

2022-02-05 20:44:31 +00:00
R"(#version 330
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
out vec3 normal;
out vec4 pos;
2022-02-06 17:28:12 +00:00
in vec2 v_texcoords[];
out vec2 texcoords;
2022-02-05 20:44:31 +00:00
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;
2022-02-06 17:28:12 +00:00
texcoords = v_texcoords[i];
2022-02-05 20:44:31 +00:00
EmitVertex( );
}
EndPrimitive( );
})";