Skip to content

Instantly share code, notes, and snippets.

@troughton
Created September 24, 2022 22:54
Show Gist options
  • Save troughton/7111a56ffe084bb8c1b796180656d3ce to your computer and use it in GitHub Desktop.
Save troughton/7111a56ffe084bb8c1b796180656d3ce to your computer and use it in GitHub Desktop.
DebugDraw.hlsl
struct DebugVertex {
float3 position : POSITION;
float4 colour : COLOR;
};
struct DebugVertexUniforms {
float4x4 worldToProjection;
};
[[vk::push_constant]] DebugVertexUniforms uniforms;
struct DebugVertexInOut {
float4 position : SV_Position;
float4 colour : COLOR0;
};
[shader("vertex")]
DebugVertexInOut DebugDrawPass_Vertex(DebugVertex debugVertex) {
DebugVertexInOut output;
output.position = mul(uniforms.worldToProjection, float4(debugVertex.position, 1));
output.colour = debugVertex.colour; // inverseToneMap(debugVertex.colour);
return output;
}
[shader("pixel")]
float4 DebugDrawPass_Fragment(DebugVertexInOut input) : SV_Target {
return input.colour;
}
struct DebugPointVertex {
float3 position : POSITION;
float4 colour : COLOR;
float size : PSIZE;
};
struct DebugPointVertexInOut {
float4 position : SV_Position;
float4 colour : COLOR0;
[[vk::builtin("PointSize")]] float size : PSIZE;
};
[shader("vertex")]
DebugPointVertexInOut DebugDrawPass_VertexPoint(DebugPointVertex debugVertex) {
DebugPointVertexInOut output;
output.position = mul(uniforms.worldToProjection, float4(debugVertex.position, 1));
output.colour = debugVertex.colour; // inverseToneMap(debugVertex.colour);
output.size = debugVertex.size;
return output;
}
[shader("pixel")]
float4 DebugDrawPass_FragmentPoint(DebugPointVertexInOut input) : SV_Target {
return input.colour;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment