-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,305 additions
and
0 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 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,7 @@ | ||
# Ray Tracing | ||
|
||
TODO | ||
|
||
- Screenshot | ||
- Explain which backends this supports | ||
- Explain what hardware this supports |
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,11 @@ | ||
$shaders = @( | ||
"$PSScriptRoot\data\simple.rchit" | ||
"$PSScriptRoot\data\simple.rgen" | ||
"$PSScriptRoot\data\simple.rmiss" | ||
) | ||
|
||
Remove-Item $PSScriptRoot\data\*.spv | ||
|
||
foreach ($shader in $shaders) { | ||
& glslangValidator --target-env vulkan1.2 --entry-point main $shader -o "$shader.spv" | ||
} |
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,9 @@ | ||
#version 460 | ||
#extension GL_EXT_ray_tracing : enable | ||
|
||
layout(location = 0) rayPayloadInEXT vec3 out_color; | ||
hitAttributeEXT vec3 attribs; | ||
|
||
void main() { | ||
out_color = vec3(1.0, 0.0, 0.0); | ||
} |
Binary file not shown.
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,34 @@ | ||
#version 460 | ||
#extension GL_EXT_ray_tracing : enable | ||
|
||
layout(binding = 0, set = 0) uniform accelerationStructureEXT accel_struct; | ||
layout(binding = 1, set = 0, rgba8) uniform image2D storage_image; | ||
layout(binding = 2, set = 0) uniform CameraProperties { | ||
mat4 view_inverse; | ||
mat4 proj_inverse; | ||
} | ||
cam; | ||
|
||
layout(location = 0) rayPayloadEXT vec3 out_color; | ||
|
||
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 = cam.view_inverse * vec4(0, 0, 0, 1); | ||
vec4 target = cam.proj_inverse * vec4(d.x, d.y, 1, 1); | ||
vec4 direction = cam.view_inverse * vec4(normalize(target.xyz), 0); | ||
|
||
out_color = vec3(0.0); | ||
|
||
origin.xyz = vec3(0, 0, 1); | ||
direction.xyz = vec3(0, 0, -1); | ||
|
||
float tmin = 0.001; | ||
float tmax = 10000.0; | ||
traceRayEXT(accel_struct, gl_RayFlagsOpaqueEXT, 0xff, 0, 0, 0, origin.xyz, | ||
tmin, direction.xyz, tmax, 0); | ||
|
||
imageStore(storage_image, ivec2(gl_LaunchIDEXT.xy), vec4(out_color, 1.0)); | ||
} |
Binary file not shown.
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,6 @@ | ||
#version 460 | ||
#extension GL_EXT_ray_tracing : enable | ||
|
||
layout(location = 0) rayPayloadInEXT vec3 out_color; | ||
|
||
void main() { out_color = vec3(0.8, 0.8, 0.8); } |
Binary file not shown.
Oops, something went wrong.