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

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

uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ViewProjectionMatrix;
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform int screen_space;
uniform float pixel_size;
uniform float draw_size;

in vec3 pos;
in vec4 rot;
in vec3 inst_pos;
in int axis;

flat out int finalAxis;

vec3 rotate(vec3 vec, vec4 quat)
{
	/* The quaternion representation here stores the w component in the first index */
	return vec + 2.0 * cross(quat.yzw, cross(quat.yzw, vec) + quat.x * vec);
}

float mul_project_m4_v3_zfac(in vec3 co)
{
	return (ViewProjectionMatrix[0][3] * co.x) +
	       (ViewProjectionMatrix[1][3] * co.y) +
	       (ViewProjectionMatrix[2][3] * co.z) + ViewProjectionMatrix[3][3];
}

void main()
{
	float pix_size = mul_project_m4_v3_zfac(pos) * pixel_size;

	if (screen_space == 1) {
		gl_Position = ModelViewMatrix * vec4(pos, 1.0) + vec4(inst_pos * pix_size * draw_size, 0.0);
		gl_Position = ProjectionMatrix * gl_Position;
	}
	else {
		gl_Position = ModelViewProjectionMatrix * vec4(pos + rotate(inst_pos * pix_size * draw_size, rot), 1.0);
	}

	finalAxis = axis;
}