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

common_subdiv_normals_finalize_comp.glsl « shaders « intern « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e6a56ff02c7d361ccb1afb7f3d5ce485d3e170c6 (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
48
49
50
51
52
53
54
55

/* To be compiled with common_subdiv_lib.glsl */

#ifdef CUSTOM_NORMALS
struct CustomNormal {
  float x;
  float y;
  float z;
};

layout(std430, binding = 0) readonly buffer inputNormals
{
  CustomNormal custom_normals[];
};
#else
layout(std430, binding = 0) readonly buffer inputNormals
{
  vec3 vertex_normals[];
};

layout(std430, binding = 1) readonly buffer inputSubdivVertLoopMap
{
  uint vert_loop_map[];
};
#endif

layout(std430, binding = 2) buffer outputPosNor
{
  PosNorLoop pos_nor[];
};

void main()
{
  /* We execute for each quad. */
  uint quad_index = get_global_invocation_index();
  if (quad_index >= total_dispatch_size) {
    return;
  }

  uint start_loop_index = quad_index * 4;

#ifdef CUSTOM_NORMALS
  for (int i = 0; i < 4; i++) {
    CustomNormal custom_normal = custom_normals[start_loop_index + i];
    vec3 nor = vec3(custom_normal.x, custom_normal.y, custom_normal.z);
    set_vertex_nor(pos_nor[start_loop_index + i], normalize(nor));
  }
#else
  for (int i = 0; i < 4; i++) {
    uint subdiv_vert_index = vert_loop_map[start_loop_index + i];
    vec3 nor = vertex_normals[subdiv_vert_index];
    set_vertex_nor(pos_nor[start_loop_index + i], nor);
  }
#endif
}