depthtest.compute 1.23 KB
Newer Older
's avatar
committed
1
2
3
4
5
6
7
8
9
#version 430

#extension GL_ARB_shading_language_include : require
#extension GL_ARB_compute_variable_group_size : require

#include <raytracer/basic_structs.glh>
#include <raytracer/buffers.glh>
#include <raytracer/random.glh>
#include <raytracer/utilities.glh>
10
#include <raytracer/properties/camera.glh>
's avatar
committed
11
12
13
14
15

layout(rgba32f) uniform readonly image2D u_gbuffer_texture_01;

layout(local_size_variable) in;

unknown's avatar
unknown committed
16
17
18
19
void resetImportance(uint id)
{
	b_traces[id].properties.accuracy_importance = 1.f;
	b_traces[id].properties.shadow_importance = 1.f;
unknown's avatar
unknown committed
20
	b_traces[id].properties.bounce_amount = 0;
21
	b_traces[id].properties.travelled_distance = 0;
unknown's avatar
unknown committed
22
23
}

's avatar
committed
24
25
26
27
28
29
void main()
{
	uint id = gl_GlobalInvocationID.x;

	if (id < b_traces.length())
	{
30
		ivec2 target_size = u_render_target.imageSize();
's avatar
committed
31
		vec2 pixel = vec2(id%target_size.x, id/target_size.x);
32
		vec4 texel_01 = u_gbuffer_texture_01.imageLoad(ivec2(pixel));
's avatar
committed
33

34
35
		b_traces[id].ray = u_camera.getRayFromPixel(pixel, rand2D(random_seed + int(id)));
		b_traces[id].hit.invalidate();
's avatar
committed
36
37
38

		if (length(texel_01) != 0) {

39
40
41
			b_traces[id].hit.barycentric = texel_01.xy;
			b_traces[id].hit.triangle = uint(texel_01.z);
			b_traces[id].hit.mesh = uint(texel_01.w);
's avatar
committed
42
		}
unknown's avatar
unknown committed
43
44
		
		resetImportance(id);
's avatar
committed
45
46
	}
}