vulkan triangle
This commit is contained in:
parent
8b2fd773b1
commit
96b5d1a299
8 changed files with 170 additions and 48 deletions
|
|
@ -3,10 +3,45 @@
|
|||
#extension GL_EXT_shader_image_load_formatted : enable
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;
|
||||
layout(binding = 1, set = 0) uniform image2D image;
|
||||
layout(binding = 1, set = 0, rgba32f) uniform image2D image;
|
||||
|
||||
layout(location = 0) rayPayloadEXT vec3 hitValue;
|
||||
|
||||
void main() {
|
||||
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(1,1,1, 0.0));
|
||||
}
|
||||
void main()
|
||||
{
|
||||
// Pixel coordinates
|
||||
uvec2 pixel = gl_LaunchIDEXT.xy;
|
||||
uvec2 resolution = gl_LaunchSizeEXT.xy;
|
||||
|
||||
// Normalized coordinates in range [-1, 1]
|
||||
vec2 uv = (vec2(pixel) + 0.5) / vec2(resolution);
|
||||
vec2 ndc = uv * 2.0 - 1.0;
|
||||
|
||||
// Camera parameters
|
||||
vec3 origin = vec3(0.0, 0.0, -300.0);
|
||||
|
||||
float aspect = float(resolution.x) / float(resolution.y);
|
||||
float fov = radians(60.0);
|
||||
float tanHalfFov = tan(fov * 0.5);
|
||||
|
||||
// Simple pinhole camera facing +Z
|
||||
vec3 direction = normalize(vec3(
|
||||
ndc.x * aspect * tanHalfFov,
|
||||
-ndc.y * tanHalfFov,
|
||||
1.0
|
||||
));
|
||||
|
||||
traceRayEXT(
|
||||
topLevelAS,
|
||||
gl_RayFlagsNoneEXT,
|
||||
0xff,
|
||||
0, 0, 0,
|
||||
origin,
|
||||
0.001,
|
||||
direction,
|
||||
10000.0,
|
||||
0
|
||||
);
|
||||
|
||||
imageStore(image, ivec2(pixel), vec4(hitValue, 1.0));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue