Skip to content

Commit

Permalink
Fixed closesthit shader
Browse files Browse the repository at this point in the history
  • Loading branch information
SaschaWillems committed Apr 19, 2024
1 parent dc3ed00 commit eedfcc6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions shaders/hlsl/raytracingpositionfetch/closesthit.rchit
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ struct UBO
float4x4 projInverse;
float4 lightPos;
};
cbuffer ubo : register(b2)
{
UBO ubo;
};
ConstantBuffer<UBO> ubo : register(b2);

// We need to use special syntax for SPIR-V inlines
#define HitTriangleVertexPositionsKHR 5335
#define RayTracingPositionFetchKHR 5336

[[vk::ext_extension("SPV_KHR_ray_tracing_position_fetch")]]
[[vk::ext_capability(RayTracingPositionFetchKHR)]]
[[vk::ext_builtin_input(HitTriangleVertexPositionsKHR)]]
const static float3 gl_HitTriangleVertexPositions[3];

[shader("closesthit")]
void main(inout Payload p, in Attributes attribs)
Expand All @@ -35,11 +39,6 @@ void main(inout Payload p, in Attributes attribs)

// With VK_KHR_ray_tracing_position_fetch we can access the vertices for the hit triangle in the shader

// We need to use special syntax for SPIR-V inlines
#define HitTriangleVertexPositionsKHR 5391
[[vk::ext_builtin_output(HitTriangleVertexPositionsKHR)]]
static float3 gl_HitTriangleVertexPositions[3];

float3 vertexPos0 = gl_HitTriangleVertexPositions[0];
float3 vertexPos1 = gl_HitTriangleVertexPositions[1];
float3 vertexPos2 = gl_HitTriangleVertexPositions[2];
Expand Down
Binary file not shown.
Binary file added shaders/hlsl/raytracingpositionfetch/miss.rmiss.spv
Binary file not shown.
Binary file not shown.

0 comments on commit eedfcc6

Please sign in to comment.