This commit is contained in:
2016-10-26 19:42:22 -07:00
parent d71967565d
commit f6b0068ec2
4 changed files with 42 additions and 9 deletions

View File

@@ -4,6 +4,7 @@
in vec2 v_uv;
flat in uint v_tileidx;
in float v_fade;
out vec4 pixcolor;
uniform sampler2DArray t_tiles;
uniform b_constants {
@@ -11,6 +12,8 @@ uniform b_constants {
float R1;
float R2;
float R3;
float haze;
vec4 hazecolor;
};
uniform b_locals {
uint millis;
@@ -24,5 +27,6 @@ void main() {
anim_uv = vec2(v_uv.x, v_uv.y + float(millis % MILLIS_PER_TILE) / MILLIS_PER_TILE);
}
pixcolor = texture(t_tiles, vec3(anim_uv.x, 1.0 - anim_uv.y, v_tileidx));
vec4 texcolor = texture(t_tiles, vec3(anim_uv.x, 1.0 - anim_uv.y, v_tileidx));
pixcolor = mix(texcolor, hazecolor, v_fade);
}

View File

@@ -8,7 +8,9 @@ in vec2 a_uv;
in uint a_tileidx;
out vec2 v_uv;
flat out uint v_tileidx;
out float v_fade;
uniform b_trans {
mat4 u_viewmodel;
mat4 u_matrix;
};
uniform b_constants {
@@ -16,6 +18,8 @@ uniform b_constants {
float R1;
float R2;
float R3;
float haze;
vec4 hazecolor;
};
uniform b_locals {
uint millis;
@@ -38,5 +42,9 @@ void main() {
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);
vec4 model_pos = vec4(toroid(thetaphi, R1, R2, R3) + a_pos.z * normal, 1.0);
gl_Position = u_matrix * model_pos;
vec4 view_pos = u_viewmodel * model_pos;
v_fade = min(1.0, length(view_pos.xyz) / R1 / 2 * haze);
}