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: 195d4849d992f291b55d49522a9dca811ba5b4dd (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

uniform mat4 ViewMatrix;
uniform mat4 ViewProjectionMatrix;
uniform mat4 ObjectModelMatrix;

/* ---- Instanciated Attribs ---- */
in vec3 pos;
in vec3 nor;

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

out vec3 normal;
flat out vec4 finalColor;

void main()
{
	mat4 FinalModelMatrix = ObjectModelMatrix * InstanceModelMatrix;
	mat4 ModelViewProjectionMatrix = ViewProjectionMatrix * FinalModelMatrix;
	/* 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 attrib */
	mat3 NormalMatrix = transpose(inverse(mat3(ViewMatrix * FinalModelMatrix)));

	gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
	normal = NormalMatrix * nor;

	finalColor = color;
}