-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Ray tracing fixes (#2625)
* Fix shader files' inconsistent file extensions * Fix shader files' inconsistent formatting * Fix examples' code inconsistencies * Fix library code inconsistencies * Fix `get_ray_tracing_pipeline_shader_group_handles` scoping
Showing
22 changed files
with
641 additions
and
633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#version 460 | ||
#extension GL_EXT_ray_tracing : require | ||
|
||
layout(location = 0) rayPayloadInEXT vec3 hit_value; | ||
hitAttributeEXT vec2 attribs; | ||
|
||
void main() { | ||
vec3 barycentrics = vec3(1.0 - attribs.x - attribs.y, attribs.x, attribs.y); | ||
hit_value = barycentrics; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#version 460 | ||
#extension GL_EXT_ray_tracing : require | ||
|
||
layout(location = 0) rayPayloadEXT vec3 hit_value; | ||
|
||
layout(set = 0, binding = 0) uniform accelerationStructureEXT top_level_as; | ||
layout(set = 0, binding = 1) uniform Camera { | ||
mat4 view_proj; // Camera view * projection | ||
mat4 view_inverse; // Camera inverse view matrix | ||
mat4 proj_inverse; // Camera inverse projection matrix | ||
} camera; | ||
layout(set = 1, binding = 0, rgba32f) uniform image2D image; | ||
|
||
void main() { | ||
const vec2 pixel_center = vec2(gl_LaunchIDEXT.xy) + vec2(0.5); | ||
const vec2 in_uv = pixel_center / vec2(gl_LaunchSizeEXT.xy); | ||
vec2 d = in_uv * 2.0 - 1.0; | ||
|
||
vec4 origin = camera.view_inverse * vec4(0, 0, 0, 1); | ||
vec4 target = camera.proj_inverse * vec4(d.x, d.y, 1, 1); | ||
vec4 direction = camera.view_inverse * vec4(normalize(target.xyz), 0); | ||
|
||
uint ray_flags = gl_RayFlagsOpaqueEXT; | ||
float t_min = 0.001; | ||
float t_max = 10000.0; | ||
|
||
traceRayEXT( | ||
top_level_as, // acceleration structure | ||
ray_flags, // rayFlags | ||
0xFF, // cullMask | ||
0, // sbtRecordOffset | ||
0, // sbtRecordStride | ||
0, // missIndex | ||
origin.xyz, // ray origin | ||
t_min, // ray min range | ||
direction.xyz, // ray direction | ||
t_max, // ray max range | ||
0); // payload (location = 0) | ||
|
||
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(hit_value, 1.0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#version 460 | ||
#extension GL_EXT_ray_tracing : require | ||
|
||
layout(location = 0) rayPayloadInEXT vec3 hit_value; | ||
|
||
void main() { | ||
hit_value = vec3(0.0, 0.0, 0.2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#version 460 | ||
#extension GL_EXT_ray_tracing : require | ||
|
||
layout(location = 0) rayPayloadInEXT vec3 hit_value; | ||
hitAttributeEXT vec2 attribs; | ||
|
||
void main() { | ||
vec3 barycentrics = vec3(1.0 - attribs.x - attribs.y, attribs.x, attribs.y); | ||
hit_value = barycentrics; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#version 460 | ||
#extension GL_EXT_ray_tracing : require | ||
|
||
layout(location = 0) rayPayloadEXT vec3 hit_value; | ||
|
||
layout(set = 0, binding = 0) uniform accelerationStructureEXT top_level_as; | ||
layout(set = 0, binding = 1) uniform Camera { | ||
mat4 view_proj; // Camera view * projection | ||
mat4 view_inverse; // Camera inverse view matrix | ||
mat4 proj_inverse; // Camera inverse projection matrix | ||
} camera; | ||
layout(set = 1, binding = 0, rgba32f) uniform image2D image; | ||
|
||
void main() { | ||
const vec2 pixel_center = vec2(gl_LaunchIDEXT.xy) + vec2(0.5); | ||
const vec2 in_uv = pixel_center / vec2(gl_LaunchSizeEXT.xy); | ||
vec2 d = in_uv * 2.0 - 1.0; | ||
|
||
vec4 origin = camera.view_inverse * vec4(0, 0, 0, 1); | ||
vec4 target = camera.proj_inverse * vec4(d.x, d.y, 1, 1); | ||
vec4 direction = camera.view_inverse * vec4(normalize(target.xyz), 0); | ||
|
||
uint ray_flags = gl_RayFlagsOpaqueEXT; | ||
float t_min = 0.001; | ||
float t_max = 10000.0; | ||
|
||
traceRayEXT( | ||
top_level_as, // acceleration structure | ||
ray_flags, // rayFlags | ||
0xFF, // cullMask | ||
0, // sbtRecordOffset | ||
0, // sbtRecordStride | ||
0, // missIndex | ||
origin.xyz, // ray origin | ||
t_min, // ray min range | ||
direction.xyz, // ray direction | ||
t_max, // ray max range | ||
0); // payload (location = 0) | ||
|
||
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(hit_value, 1.0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#version 460 | ||
#extension GL_EXT_ray_tracing : require | ||
|
||
layout(location = 0) rayPayloadInEXT vec3 hit_value; | ||
|
||
void main() { | ||
hit_value = vec3(0.0, 0.0, 0.2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.