Changed ray tracing closest hit shader hit attributes to vec2
Fixes #878
This commit is contained in:
parent
711743ad69
commit
1993f3af5d
9 changed files with 11 additions and 14 deletions
|
|
@ -3,7 +3,7 @@
|
|||
#extension GL_EXT_nonuniform_qualifier : enable
|
||||
|
||||
layout(location = 0) rayPayloadInEXT vec3 hitValue;
|
||||
hitAttributeEXT vec3 attribs;
|
||||
hitAttributeEXT vec2 attribs;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
layout(location = 0) rayPayloadInEXT vec3 hitValue;
|
||||
layout(location = 0) callableDataEXT vec3 outColor;
|
||||
hitAttributeEXT vec3 attribs;
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ struct RayPayload {
|
|||
|
||||
layout(location = 0) rayPayloadInEXT RayPayload rayPayload;
|
||||
|
||||
hitAttributeEXT vec3 attribs;
|
||||
hitAttributeEXT vec2 attribs;
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;
|
||||
layout(binding = 2, set = 0) uniform UBO
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
layout(location = 0) rayPayloadInEXT vec3 hitValue;
|
||||
layout(location = 2) rayPayloadEXT bool shadowed;
|
||||
hitAttributeEXT vec3 attribs;
|
||||
hitAttributeEXT vec2 attribs;
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;
|
||||
layout(binding = 2, set = 0) uniform UBO
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ for root, dirs, files in os.walk(dir_path):
|
|||
hlsl_file = os.path.join(root, file)
|
||||
spv_out = hlsl_file + ".spv"
|
||||
|
||||
target = ''
|
||||
profile = ''
|
||||
if(hlsl_file.find('.vert') != -1):
|
||||
profile = 'vs_6_1'
|
||||
|
|
@ -53,6 +54,7 @@ for root, dirs, files in os.walk(dir_path):
|
|||
elif(hlsl_file.find('.rgen') != -1 or
|
||||
hlsl_file.find('.rchit') != -1 or
|
||||
hlsl_file.find('.rmiss') != -1):
|
||||
target='-fspv-target-env=vulkan1.2'
|
||||
profile = 'lib_6_3'
|
||||
|
||||
print('Compiling %s' % (hlsl_file))
|
||||
|
|
@ -61,9 +63,10 @@ for root, dirs, files in os.walk(dir_path):
|
|||
'-spirv',
|
||||
'-T', profile,
|
||||
'-E', 'main',
|
||||
'-fspv-extension=SPV_NV_ray_tracing',
|
||||
'-fspv-extension=SPV_KHR_ray_tracing',
|
||||
'-fspv-extension=SPV_KHR_multiview',
|
||||
'-fspv-extension=SPV_KHR_shader_draw_parameters',
|
||||
'-fspv-extension=SPV_EXT_descriptor_indexing',
|
||||
target,
|
||||
hlsl_file,
|
||||
'-Fo', spv_out])
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ struct Payload
|
|||
};
|
||||
|
||||
[shader("closesthit")]
|
||||
void main(inout Payload p, in float3 attribs)
|
||||
void main(inout Payload p, in float2 attribs)
|
||||
{
|
||||
const float3 barycentricCoords = float3(1.0f - attribs.x - attribs.y, attribs.x, attribs.y);
|
||||
p.hitValue = barycentricCoords;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
// Copyright 2021 Sascha Willems
|
||||
|
||||
struct Attribute
|
||||
{
|
||||
float2 attribs;
|
||||
};
|
||||
|
||||
struct Payload
|
||||
{
|
||||
[[vk::location(0)]] float3 hitValue;
|
||||
|
|
@ -16,7 +11,7 @@ struct CallData
|
|||
};
|
||||
|
||||
[shader("closesthit")]
|
||||
void main(inout Payload p, in float3 attribs)
|
||||
void main(inout Payload p, in float2 attribs)
|
||||
{
|
||||
// Execute the callable shader indexed by the current geometry being hit
|
||||
// For our sample this means that the first callable shader in the SBT is invoked for the first triangle, the second callable shader for the second triangle, etc.
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ Vertex unpack(uint index)
|
|||
}
|
||||
|
||||
[shader("closesthit")]
|
||||
void main(inout RayPayload rayPayload, in float3 attribs)
|
||||
void main(inout RayPayload rayPayload, in float2 attribs)
|
||||
{
|
||||
uint PrimitiveID = PrimitiveIndex();
|
||||
int3 index = int3(indices[3 * PrimitiveID], indices[3 * PrimitiveID + 1], indices[3 * PrimitiveID + 2]);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ Vertex unpack(uint index)
|
|||
}
|
||||
|
||||
[shader("closesthit")]
|
||||
void main(in InPayload inPayload, inout InOutPayload inOutPayload, in float3 attribs)
|
||||
void main(in InPayload inPayload, inout InOutPayload inOutPayload, in float2 attribs)
|
||||
{
|
||||
uint PrimitiveID = PrimitiveIndex();
|
||||
int3 index = int3(indices[3 * PrimitiveID], indices[3 * PrimitiveID + 1], indices[3 * PrimitiveID + 2]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue