Browse files

Made number of fold points programmatic

  • Loading branch information...
1 parent 3621e01 commit d162934df047d717b84f556f34833f1f4523f835 @njx committed Oct 2, 2012
Showing with 8 additions and 7 deletions.
  1. +4 −3 shader.vs
  2. +4 −4 styles.css
View
7 shader.vs
@@ -31,6 +31,7 @@ uniform vec2 u_textureSize;
uniform mat4 transform;
uniform float mapDepth;
+uniform float foldPoints;
uniform float t;
// Varyings
@@ -46,12 +47,12 @@ const float PI = 3.1415629;
void main()
{
vec4 pos = a_position;
- float ramp = step(0.5, 1.0 - a_meshCoord.y) * a_meshCoord.y + step(0.5, a_meshCoord.y) * (1.0 - a_meshCoord.y);
+ float depth = cos(a_meshCoord.y * PI * foldPoints) / 2.0 - 0.5;
- pos.z = ramp * -50.0 * mapDepth * t;
+ pos.z = depth * 25.0 * mapDepth * t;
pos.y = (pos.y + 0.5) * (1.0 - t) - 0.5;
- v_lighting = 1.0 - (ramp * t * 0.5);
+ v_lighting = 1.0 + (depth * t * 0.5);
gl_Position = u_projectionMatrix * transform * pos;
}
View
8 styles.css
@@ -43,19 +43,19 @@
@-webkit-keyframes fold {
from {
- -webkit-filter: custom(url(shader.vs) mix(url(shader.fs) multiply source-atop), 2 2 border-box, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), t 0, mapDepth 5);
+ -webkit-filter: custom(url(shader.vs) mix(url(shader.fs) multiply source-atop), 8 8 border-box, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), t 0, mapDepth 5, foldPoints 8);
}
to {
- -webkit-filter: custom(url(shader.vs) mix(url(shader.fs) multiply source-atop), 2 2 border-box, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), t 1, mapDepth 5);
+ -webkit-filter: custom(url(shader.vs) mix(url(shader.fs) multiply source-atop), 8 8 border-box, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), t 1, mapDepth 5, foldPoints 8);
}
}
@-webkit-keyframes unfold {
from {
- -webkit-filter: custom(url(shader.vs) mix(url(shader.fs) multiply source-atop), 2 2 border-box, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), t 1, mapDepth 5);
+ -webkit-filter: custom(url(shader.vs) mix(url(shader.fs) multiply source-atop), 8 8 border-box, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), t 1, mapDepth 5, foldPoints 8);
}
to {
- -webkit-filter: custom(url(shader.vs) mix(url(shader.fs) multiply source-atop), 2 2 border-box, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), t 0, mapDepth 5);
+ -webkit-filter: custom(url(shader.vs) mix(url(shader.fs) multiply source-atop), 8 8 border-box, transform perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), t 0, mapDepth 5, foldPoints 8);
}
}

0 comments on commit d162934

Please sign in to comment.