Skip to content
Snippets Groups Projects
Commit 55937807 authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#87] Add task index visualisation

parent 60ab534c
No related branches found
No related tags found
1 merge request!74Resolve "Mesh Shader Implementation"
Pipeline #26373 passed
......@@ -2,8 +2,31 @@
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 passNormal;
layout(location = 1) in flat uint passTaskIndex;
layout(location = 0) out vec3 outColor;
uint lowbias32(uint x)
{
x ^= x >> 16;
x *= 0x7feb352dU;
x ^= x >> 15;
x *= 0x846ca68bU;
x ^= x >> 16;
return x;
}
float hashToFloat(uint hash){
return (hash % 255) / 255.f;
}
vec3 colorFromIndex(uint i){
return vec3(
hashToFloat(lowbias32(i+0)),
hashToFloat(lowbias32(i+1)),
hashToFloat(lowbias32(i+2)));
}
void main() {
outColor = normalize(passNormal) * 0.5 +0.5;
outColor = normalize(passNormal) * 0.5 + 0.5;
outColor = colorFromIndex(passTaskIndex);
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ layout( push_constant ) uniform constants{
};
layout(location = 0) out vec3 passNormal[];
layout(location = 1) out uint passTaskIndex[];
struct Vertex
{
......@@ -45,8 +46,10 @@ void main() {
vec3 inPos = vertices[index].position;
vec3 inNormal = vertices[index].normal;
gl_MeshVerticesNV[workIndex].gl_Position = mvp * vec4(inPos, 1);
passNormal[workIndex] = inNormal;
passTaskIndex[workIndex] = previousMeshGroupCount;
if(gl_LocalInvocationID.x == 0){
gl_PrimitiveCountNV = 10;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment