2021-08-10 02:11:22 +02:00
|
|
|
#version 430
|
|
|
|
|
2021-08-12 22:16:45 +02:00
|
|
|
// writes first hit information into buffers to accelerate later passes
|
|
|
|
|
|
|
|
// local work group
|
|
|
|
layout(local_size_x = 1, local_size_y = 1) in;
|
|
|
|
|
2021-08-13 21:03:19 +02:00
|
|
|
layout (rgba32f, binding = 2) writeonly uniform image2D g0_output;
|
|
|
|
layout (rgba32f, binding = 3) writeonly uniform image2D g1_output;
|
2021-08-12 22:16:45 +02:00
|
|
|
|
|
|
|
#include func.glsl
|
|
|
|
#include constants.glsl
|
|
|
|
#include time.glsl
|
2021-08-10 02:11:22 +02:00
|
|
|
#include sphere.glsl
|
2021-08-12 22:16:45 +02:00
|
|
|
#include ray.glsl
|
|
|
|
#include intersect.glsl
|
|
|
|
#include random.glsl
|
|
|
|
#include camera.glsl
|
|
|
|
#include image.glsl
|
|
|
|
#include scene.glsl
|
2023-02-24 02:12:51 +01:00
|
|
|
#include depth.glsl
|
2021-08-12 22:16:45 +02:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
// x normal.x
|
|
|
|
// y normal.y
|
|
|
|
// z normal.z
|
|
|
|
// w depth
|
|
|
|
|
|
|
|
vec4 pixel= vec4(0);
|
|
|
|
ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy);
|
|
|
|
ivec2 dims = imageSize(g0_output);
|
|
|
|
vec2 uv = pixelUv(pixelCoords, dims);
|
|
|
|
|
|
|
|
Ray ray = createCameraRay(uv);
|
|
|
|
RayHit hit = trace(ray);
|
|
|
|
|
2023-02-24 02:12:51 +01:00
|
|
|
float depth = getLogarithmicDepth(hit.distance);
|
2021-08-12 22:16:45 +02:00
|
|
|
|
2021-08-13 14:43:54 +02:00
|
|
|
// pack normal into texture
|
|
|
|
pixel.xyz = hit.normal*0.5+0.5;
|
|
|
|
pixel.w = depth;
|
2021-08-12 22:16:45 +02:00
|
|
|
|
|
|
|
imageStore(g0_output, pixelCoords, pixel);
|
2021-08-13 21:03:19 +02:00
|
|
|
|
|
|
|
pixel.xyz = hit.albedo;
|
2023-02-26 03:50:32 +01:00
|
|
|
pixel.w = hit.material;
|
2021-08-13 21:03:19 +02:00
|
|
|
imageStore(g1_output, pixelCoords, pixel);
|
2021-08-12 22:16:45 +02:00
|
|
|
}
|