VoxelEngine2/shaders/shader.geom

152 lines
5 KiB
Text
Raw Normal View History

#version 450
layout(points) in;
layout(triangle_strip, max_vertices=24) out;
layout(binding = 0) uniform UniformBufferObject {
mat4 model;
mat4 geom_rot;
mat4 view;
mat4 proj;
} ubo;
layout(location = 0) in vec3 geoColor[];
layout(location = 1) in vec2 geoTexCoord[];
layout(location = 0) out vec3 fragColor;
layout(location = 1) out vec2 fragTexCoord;
void main () {
mat4 geom_rotation = ubo.geom_rot;
//back
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, -0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, -0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, 0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, 0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
EndPrimitive();
//front
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, 0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, -0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, 0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, -0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
EndPrimitive();
//up
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, 0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, 0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, 0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, 0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
EndPrimitive();
//down
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, -0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, -0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, -0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, -0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
EndPrimitive();
//left
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, 0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, -0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, 0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(-0.5, -0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
EndPrimitive();
//right
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, -0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, -0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, 0.5, 0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
gl_Position = ubo.proj * ubo.view * (gl_in[0].gl_Position + geom_rotation * vec4(0.5, 0.5, -0.5, 0));
fragColor = geoColor[0];
fragTexCoord = geoTexCoord[0];
EmitVertex();
EndPrimitive();
}