VoxelEngine/Objects/Cuboid/cuboid_geometry.glsl

204 lines
6.4 KiB
Text
Raw Normal View History

2017-08-27 12:51:26 +02:00
#version 410
layout(points) in;
layout(triangle_strip,max_vertices=24) out;
uniform mat4 projModelViewMatrix;
uniform mat3 normalMatrix;
uniform mat3 rotMatrix;
layout(location = 0) in vec3 colorgeo[1];
layout(location = 1) in vec3 size[1];
layout(location = 0) out vec3 colorout;
layout(location = 1) out vec3 normal;
layout(location = 2) out vec3 pos;
void main(){
//hinten
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,0,-1));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,0,-1));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,0,-1));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,0,-1));
pos = gl_Position.xyz;
EmitVertex();
EndPrimitive();
//vorne
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,0,1));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,0,1));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,0,1));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,0,1));
pos = gl_Position.xyz;
EmitVertex();
EndPrimitive();
//oben
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,1,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,1,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,1,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,1,0));
pos = gl_Position.xyz;
EmitVertex();
EndPrimitive();
//unten
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,-1,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,-1,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,-1,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(0,-1,0));
pos = gl_Position.xyz;
EmitVertex();
EndPrimitive();
//links
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(-1,0,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(-1,0,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(-1,0,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(-size[0].x,-size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(-1,0,0));
pos = gl_Position.xyz;
EmitVertex();
EndPrimitive();
//rechts
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(1,0,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,-size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(1,0,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(1,0,0));
pos = gl_Position.xyz;
EmitVertex();
gl_Position = projModelViewMatrix *(gl_in[0].gl_Position + vec4(rotMatrix * vec3(size[0].x,size[0].y,-size[0].z),0));
colorout = colorgeo[0];
normal = normalize(rotMatrix * vec3(1,0,0));
pos = gl_Position.xyz;
EmitVertex();
EndPrimitive();
}