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

gpu_shader_instance_objectspace_variying_color_vert.glsl « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5b3922d7a724830c0e95baf68081863c921a5d68 (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

uniform mat4 ViewMatrixInverse;
uniform mat4 ViewProjectionMatrix;

/* ---- Instantiated Attrs ---- */
in vec3 pos;
in vec3 nor;

/* ---- Per instance Attrs ---- */
in mat4 InstanceModelMatrix;
in vec4 color;

out vec3 normal;
flat out vec4 finalColor;

void main()
{
  gl_Position = ViewProjectionMatrix * (InstanceModelMatrix * vec4(pos, 1.0));

  /* This is slow and run per vertex, but it's still faster than
   * doing it per instance on CPU and sending it on via instance attribute. */
  mat3 normal_mat = transpose(inverse(mat3(InstanceModelMatrix)));
  normal = normalize((transpose(mat3(ViewMatrixInverse)) * (normal_mat * nor)));

  finalColor = color;
}