blob: 819199c26c772cbe7e0d9a35f1b52e02836b496f (
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
|
/* This shader takes a 2D shape, puts it in 3D Object space such that is stays aligned with view,
* and scales the shape according to per-instance attributes
* Note that if the stiffness is zero, it assumes the scale is directly multiplied by the radius */
#define M_PI_2 1.570796f // pi/2
uniform mat4 ViewProjectionMatrix;
uniform vec3 screen_vecs[2];
/* ---- Instanciated Attribs ---- */
in vec2 pos;
/* ---- Per instance Attribs ---- */
in mat3x4 ScaleTranslationMatrix;
in float radius;
in vec3 color;
flat out vec4 finalColor;
void main()
{
mat3 Scamat = mat3(ScaleTranslationMatrix);
vec4 world_pos = vec4(
ScaleTranslationMatrix[0][3],
ScaleTranslationMatrix[1][3],
ScaleTranslationMatrix[2][3],
1.0);
vec3 screen_pos = screen_vecs[0].xyz * pos.x + screen_vecs[1].xyz * pos.y;
world_pos.xyz += Scamat * (screen_pos * radius);
gl_Position = ViewProjectionMatrix * world_pos;
finalColor = vec4(color, 1.0);
}
|