2025-05-07 19:21:51 +02:00
|
|
|
/*
|
|
|
|
|
Crafter®.Graphics
|
|
|
|
|
Copyright (C) 2025 Catcrafts®
|
|
|
|
|
Catcrafts.net
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 3.0 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
|
|
|
|
|
2025-05-03 06:51:33 +02:00
|
|
|
#version 450
|
|
|
|
|
#extension GL_EXT_mesh_shader : require
|
|
|
|
|
|
|
|
|
|
layout (binding = 0) uniform UBO
|
|
|
|
|
{
|
|
|
|
|
mat4 modelProjectionView;
|
|
|
|
|
} ubo;
|
|
|
|
|
|
|
|
|
|
struct VertexType
|
|
|
|
|
{
|
|
|
|
|
vec4 position;
|
|
|
|
|
vec2 uv;
|
|
|
|
|
vec2 pad;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
layout (std140, binding = 1) buffer VERTEX
|
|
|
|
|
{
|
|
|
|
|
VertexType pos[];
|
|
|
|
|
} vertex;
|
|
|
|
|
|
|
|
|
|
layout (binding = 2) buffer INDEX {
|
|
|
|
|
uint index[];
|
|
|
|
|
} index;
|
|
|
|
|
|
|
|
|
|
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
|
layout(triangles, max_vertices = 192, max_primitives = 64) out;
|
|
|
|
|
|
|
|
|
|
layout (location = 0) out PerVertexData
|
|
|
|
|
{
|
|
|
|
|
vec2 uv;
|
|
|
|
|
} outVert[];
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
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]].position;
|
|
|
|
|
gl_MeshVerticesEXT[localID+1].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+1]].position;
|
|
|
|
|
gl_MeshVerticesEXT[localID+2].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+2]].position;
|
|
|
|
|
|
|
|
|
|
outVert[localID].uv = vertex.pos[index.index[triangleID]].uv;
|
|
|
|
|
outVert[localID + 1].uv = vertex.pos[index.index[triangleID+1]].uv;
|
|
|
|
|
outVert[localID + 2].uv = vertex.pos[index.index[triangleID+2]].uv;
|
|
|
|
|
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex.x] = uvec3(localID, localID+1, localID+2);
|
|
|
|
|
}
|