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

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

/**
 * Select the visible items inside the active view and put them inside the sorting buffer.
 */

#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(common_math_geom_lib.glsl)
#pragma BLENDER_REQUIRE(common_intersection_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_light_lib.glsl)

void main()
{
  uint l_idx = gl_GlobalInvocationID.x;
  if (l_idx >= lights_cull_buf.items_count) {
    return;
  }

  LightData light = lights_buf[l_idx];

  /* Sun lights are packed at the start of the array. */
  if (light.type == LIGHT_SUN) {
    keys_buf[l_idx] = l_idx;
    return;
  }

  Sphere sphere;
  switch (light.type) {
    case LIGHT_SPOT:
      /* TODO cone culling. */
    case LIGHT_RECT:
    case LIGHT_ELLIPSE:
    case LIGHT_POINT:
      sphere = Sphere(light._position, light.influence_radius_max);
      break;
  }

  if (intersect_view(sphere)) {
    uint index = lights_cull_buf.items_no_cull_count +
                 atomicAdd(lights_cull_buf.visible_count, 1u);
    keys_buf[index] = l_idx;
  }
}