blob: c296d90188040d9d753589dce24c6a3ebf627618 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
uniform float sphere_size;
uniform int offset;
uniform ivec3 grid_resolution;
uniform vec3 corner;
uniform vec3 increment_x;
uniform vec3 increment_y;
uniform vec3 increment_z;
uniform vec3 screen_vecs[2];
flat out int cellOffset;
out vec2 quadCoord;
const vec2 pos[6] = vec2[6](vec2(-1.0, -1.0),
vec2(1.0, -1.0),
vec2(-1.0, 1.0),
vec2(1.0, -1.0),
vec2(1.0, 1.0),
vec2(-1.0, 1.0));
void main()
{
int cell_id = gl_VertexID / 6;
int vert_id = gl_VertexID % 6;
vec3 ls_cell_location;
/* Keep in sync with update_irradiance_probe */
ls_cell_location.z = float(cell_id % grid_resolution.z);
ls_cell_location.y = float((cell_id / grid_resolution.z) % grid_resolution.y);
ls_cell_location.x = float(cell_id / (grid_resolution.z * grid_resolution.y));
cellOffset = offset + cell_id;
vec3 ws_cell_location = corner +
(increment_x * ls_cell_location.x + increment_y * ls_cell_location.y +
increment_z * ls_cell_location.z);
quadCoord = pos[vert_id];
vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y;
ws_cell_location += screen_pos * sphere_size;
gl_Position = ProjectionMatrix * (ViewMatrix * vec4(ws_cell_location, 1.0));
gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */
}
|