Added a basic mesh shader example
This commit is contained in:
parent
c79333e085
commit
89fc84bf14
7 changed files with 298 additions and 0 deletions
19
data/shaders/glsl/meshshader/meshshader.frag
Normal file
19
data/shaders/glsl/meshshader/meshshader.frag
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* Copyright (c) 2021, Sascha Willems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#version 450
|
||||
|
||||
layout (location = 0) in VertexInput {
|
||||
vec4 color;
|
||||
} vertexInput;
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vertexInput.color;
|
||||
}
|
||||
BIN
data/shaders/glsl/meshshader/meshshader.frag.spv
Normal file
BIN
data/shaders/glsl/meshshader/meshshader.frag.spv
Normal file
Binary file not shown.
36
data/shaders/glsl/meshshader/meshshader.mesh
Normal file
36
data/shaders/glsl/meshshader/meshshader.mesh
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* Copyright (c) 2021, Sascha Willems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#version 450
|
||||
#extension GL_EXT_mesh_shader : require
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
} ubo;
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
layout(triangles, max_vertices = 3, max_primitives = 1) out;
|
||||
|
||||
layout(location = 0) out VertexOutput
|
||||
{
|
||||
vec4 color;
|
||||
} vertexOutput[];
|
||||
|
||||
void main()
|
||||
{
|
||||
SetMeshOutputsEXT(3, 1);
|
||||
mat4 mvp = ubo.projection * ubo.view * ubo.model;
|
||||
gl_MeshVerticesEXT[0].gl_Position = mvp * vec4( 0.0, -1.0, 0.0, 1.0);
|
||||
gl_MeshVerticesEXT[1].gl_Position = mvp * vec4(-1.0, 1.0, 0.0, 1.0);
|
||||
gl_MeshVerticesEXT[2].gl_Position = mvp * vec4( 1.0, 1.0, 0.0, 1.0);
|
||||
vertexOutput[0].color = vec4(0.0, 1.0, 0.0, 1.0);
|
||||
vertexOutput[1].color = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
vertexOutput[2].color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(0, 1, 2);
|
||||
}
|
||||
BIN
data/shaders/glsl/meshshader/meshshader.mesh.spv
Normal file
BIN
data/shaders/glsl/meshshader/meshshader.mesh.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue