Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lightprobe_cube_display_vert.glsl « shaders « eevee « engines « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c9af2753baafec4ab2cd73d1fbdf6bbd4d9d6743 (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

#pragma BLENDER_REQUIRE(common_view_lib.glsl)

/* XXX TODO: fix code duplication. */
struct CubeData {
  vec4 position_type;
  vec4 attenuation_fac_type;
  mat4 influencemat;
  mat4 parallaxmat;
};

layout(std140) uniform probe_block
{
  CubeData probes_data[MAX_PROBE];
};

uniform float sphere_size;
uniform vec3 screen_vecs[2];

flat out int pid;
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()
{
  pid = 1 + (gl_VertexID / 6); /* +1 for the world */
  int vert_id = gl_VertexID % 6;

  quadCoord = pos[vert_id];

  vec3 ws_location = probes_data[pid].position_type.xyz;
  vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y;
  ws_location += screen_pos * sphere_size;

  gl_Position = ViewProjectionMatrix * vec4(ws_location, 1.0);
  gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */
}