walk around reorienting world torus

This commit is contained in:
2016-10-19 15:14:57 -07:00
parent f2a645730c
commit 2583de70b3
5 changed files with 76 additions and 36 deletions

View File

@@ -10,9 +10,9 @@ uniform b_constants {
uvec4 anim;
float R1;
float R2;
float R3;
};
uniform b_locals {
mat4 camera;
uint millis;
float treadmill_x;
float treadmill_y;

View File

@@ -15,16 +15,16 @@ uniform b_constants {
uvec4 anim;
float R1;
float R2;
float R3;
};
uniform b_locals {
mat4 camera;
uint millis;
float treadmill_x;
float treadmill_y;
};
vec3 toroid(vec2 src, float r1, float r2, float r3) {
return vec3(r3 * -1.0 * sin(src.x), // use r3 instead of r2 for "deflated" torus
return vec3(r3 * sin(src.x), // use r3 instead of r2 for "deflated" torus
(r1 + r2 * cos(src.x)) * cos(src.y),
(r1 + r2 * cos(src.x)) * sin(src.y));
}
@@ -35,8 +35,8 @@ void main() {
vec2 thetaphi = vec2(TWO_PI_CIRC * (a_pos.x + treadmill_x),
TWO_PI_CIRC * (a_pos.y + treadmill_y));
float height = R1 * TWO_PI_CIRC;
vec3 normal = vec3(toroid(thetaphi, 0, height, height));
gl_Position = u_matrix * camera *
vec4(toroid(thetaphi, R1, R2, R1) + a_pos.z * normal, 1.0);
float height = R2 * 4 * TWO_PI_CIRC;
vec3 normal = vec3(toroid(thetaphi, 0, height, height)) *
vec3(R2 / R3, 1.0, 1.0);
gl_Position = u_matrix * vec4(toroid(thetaphi, R1, R2, R3) + a_pos.z * normal, 1.0);
}