blob: 5c89cf644d6eb5abae4863c2c880df06ac818230 (
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
|
uniform mat4 ViewProjectionMatrix;
/* ---- Instantiated Attribs ---- */
in vec2 pos;
/* ---- Per instance Attribs ---- */
/* Assumed to be in world coordinate already. */
in mat4 InstanceModelMatrix;
in vec4 color;
in vec2 amin;
in vec2 amax;
flat out vec4 finalColor;
vec3 sphere_project(float ax, float az)
{
float sine = 1.0 - ax * ax - az * az;
float q3 = sqrt(max(0.0, sine));
return vec3(-az * q3, 0.5 - sine, ax * q3) * 2.0;
}
void main()
{
vec3 final_pos = sphere_project(pos.x * abs((pos.x > 0.0) ? amax.x : amin.x),
pos.y * abs((pos.y > 0.0) ? amax.y : amin.y));
gl_Position = ViewProjectionMatrix * (InstanceModelMatrix * vec4(final_pos, 1.0));
finalColor = color;
}
|