diff options
| author | ladevieq <ladevie.quentin@gmail.com> | 2021-01-09 20:42:24 +0100 |
|---|---|---|
| committer | ladevieq <ladevie.quentin@gmail.com> | 2021-01-09 20:43:09 +0100 |
| commit | 2db0d27e7f1744443958717c19b732eed57455f2 (patch) | |
| tree | 839b8ea513c8c239f015071ab083bd50f03854a5 /shaders | |
| parent | 4379b46b46563c5a709df8d567ef75affc3fd31c (diff) | |
Replace old classes with compute shader structs
Diffstat (limited to 'shaders')
| -rw-r--r-- | shaders/compute.comp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/shaders/compute.comp b/shaders/compute.comp index 6e6e8a1..f179b63 100644 --- a/shaders/compute.comp +++ b/shaders/compute.comp @@ -34,13 +34,16 @@ struct sphere { struct camera { vec4 position; + vec4 up; vec4 right; - vec4 forward; - float viewport_width; - float viewport_height; + + vec4 horizontal; + vec4 vertical; + vec4 first_pixel; + float lens_radius; - float focus_distance; + float[3] padding; }; layout(set = 0, binding = 0) buffer Inputs { @@ -207,9 +210,6 @@ void main() { uint y = gl_GlobalInvocationID.y; vec2 uv = vec2(float(x) / (width - 1), 1.0 - (float(y) / (height - 1))); - vec3 horizontal = cam.focus_distance * cam.right.xyz * cam.viewport_width; - vec3 vertical = cam.focus_distance * cam.up.xyz * cam.viewport_height; - vec3 first = cam.position.xyz - horizontal / 2.0 - vertical / 2.0 + cam.focus_distance * cam.forward.xyz; vec4 out_color = vec4(0.0); @@ -217,9 +217,9 @@ void main() { vec2 jittered_uvs = uv + vec2(random_disk[sample_index].x / (width - 1), random_disk[sample_index].y / (height - 1)); vec2 lens_disk = random_disk[sample_index] * cam.lens_radius; vec3 offset = lens_disk.x * cam.right.xyz + lens_disk.y * cam.up.xyz; - vec3 proj_plane_pos = first + jittered_uvs.x * horizontal + jittered_uvs.y * vertical; + vec4 proj_plane_pos = cam.first_pixel + jittered_uvs.x * cam.horizontal + jittered_uvs.y * cam.vertical; - out_color += ray_color(ray(cam.position.xyz + offset, proj_plane_pos - cam.position.xyz - offset), sample_index); + out_color += ray_color(ray(cam.position.xyz + offset, proj_plane_pos.xyz - cam.position.xyz - offset), sample_index); } float spp_scale = (1.0 / samples_per_pixel); |
