Crafter.Graphics/MeshShaderXYZ.mesh

30 lines
985 B
Text
Raw Normal View History

2025-04-19 15:46:26 +02:00
#version 450
#extension GL_EXT_mesh_shader : require
2025-04-19 23:59:27 +02:00
layout (binding = 0) uniform UBO
{
2025-04-27 22:16:56 +02:00
mat4 modelProjectionView;
2025-04-19 23:59:27 +02:00
} ubo;
2025-04-27 01:57:25 +02:00
layout (binding = 1) buffer VERTEX
{
vec4 pos[];
} vertex;
2025-04-27 22:16:56 +02:00
2025-04-27 01:57:25 +02:00
layout (binding = 2) buffer INDEX {
uint index[];
} index;
2025-04-27 22:16:56 +02:00
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
layout(triangles, max_vertices = 192, max_primitives = 64) out;
2025-04-19 15:46:26 +02:00
void main()
{
2025-04-27 22:16:56 +02:00
SetMeshOutputsEXT(192, 64);
uint triangleID = ((gl_WorkGroupID.x * gl_WorkGroupSize.x) + gl_LocalInvocationIndex.x)*3;
uint localID = gl_LocalInvocationIndex.x*3;
gl_MeshVerticesEXT[localID].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID]];
gl_MeshVerticesEXT[localID+1].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+1]];
gl_MeshVerticesEXT[localID+2].gl_Position =ubo.modelProjectionView * vertex.pos[index.index[triangleID+2]];
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex.x] = uvec3(localID, localID+1, localID+2);
2025-04-19 23:59:27 +02:00
}