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

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

uniform mat4 ViewProjectionMatrix;
uniform mat4 ModelMatrix;

uniform vec3 screenVecs[3];

/* ---- Instantiated Attrs ---- */
in float axis; /* position on the axis. [0.0-1.0] is X axis, [1.0-2.0] is Y, etc... */
in vec2 screenPos;

/* ---- Per instance Attrs ---- */
in vec3 color;
in float size;
in mat4 InstanceModelMatrix;

flat out vec4 finalColor;

void main()
{
	float draw_size = 4.0 * size;
	vec3 chosen_axis = InstanceModelMatrix[int(axis)].xyz;
	vec3 loc = InstanceModelMatrix[3].xyz;
	vec3 wpos = loc + chosen_axis * fract(axis) * draw_size;
	vec3 spos = screenVecs[0].xyz * screenPos.x + screenVecs[1].xyz * screenPos.y;
	/* Scale uniformly by axis length */
	spos *= length(chosen_axis) * draw_size;

	vec4 pos = vec4(wpos + spos, 1.0);
	gl_Position = ViewProjectionMatrix * pos;

	finalColor = vec4(color, 1.0);

#ifdef USE_WORLD_CLIP_PLANES
	world_clip_planes_calc_clip_distance((ModelMatrix * pos).xyz);
#endif
}