1. Sven Anders Robbestad
  2. craftgame

Commits

Eric Fredricksen  committed f12dc2f

Get rid of blur when pressing B which had rotted and served no purpose

  • Participants
  • Parent commits 9114270
  • Branches master

Comments (0)

Files changed (2)

File index.html

View file
  • Ignore whitespace
       1.0/9.0 * texture2D(uSrc, vTexCoord + vec2(+1.0, +1.0) / uResolution);
   }
 </script>
-<script id="blur-horizontal-fs" type="x-shader/x-fragment">
-  precision mediump float;
-  uniform sampler2D uSrc;
-  uniform float uStep;
-  varying vec2 vTexCoord;
-  const int d = 8;
-  void main(void) {
-    gl_FragColor = vec4(0,0,0,0);
-    for (int i = -d; i <= d; ++i)
-      gl_FragColor += texture2D(uSrc, vTexCoord - vec2(float(i) * uStep, 0.0));
-    gl_FragColor /= float(d) * 2.0 + 1.0;
-  }
-</script>
-<script id="blur-vertical-fs" type="x-shader/x-fragment">
-  precision mediump float;
-  uniform sampler2D uSrc;
-  uniform float uStep;
-  varying vec2 vTexCoord;
-  const int d = 8;
-  void main(void) {
-    gl_FragColor = vec4(0,0,0,0);
-    for (int i = -d; i <= d; ++i)
-      gl_FragColor += texture2D(uSrc, vTexCoord - vec2(0.0, float(i) * uStep));
-    gl_FragColor /= float(d) * 2.0 + 1.0;
-  }
-</script>
-
-<!-- Blit -->
-<script id="blit-vs" type="x-shader/x-vertex">
-  attribute vec2 aPos;
-  varying vec2 vTexCoord;
-  void main(void) {
-    gl_Position = vec4(sign(aPos), 0.0, 1.0);
-    vTexCoord = sign(aPos) * 0.5 + 0.5;
-  }
-</script>
-<script id="blit-fs" type="x-shader/x-fragment">
-  precision mediump float;
-  uniform sampler2D uSrc;
-  varying vec2 vTexCoord;
- 
-  void main(void) {
-    gl_FragColor = texture2D(uSrc, vec2(vTexCoord.x, vTexCoord.y));
-  }
-</script>
 
 <!-- Skybox shaders -->
 <script id="skybox-vs" type="x-shader/x-vertex">

File main.js

View file
  • Ignore whitespace
     GAME.clock += elapsed;
 
     if (gl.textures.terrain.loaded) {
-      if (KEYS.B) {
-        blur(AVATAR, 256, 256);
-      } else {
-        gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
-        drawScene(AVATAR, true);
-      }
+      gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
+      drawScene(AVATAR, true);
     }
     
     processInput(AVATAR, elapsed);
 }
 
 
-var FB1, FB2, BLURH, BLURV, SAQ;
-var BLIT;
-function blur(camera, w, h) {
-  if (!FB1) {
-    FB1 = makeFramebuffer(w, h, true, false);
-    FB2 = makeFramebuffer(w, h, false, false);
-    BLURH = new Shader('blur', 'blur-horizontal');
-    BLURV = new Shader('blur', 'blur-vertical');
-    SAQ = makeBuffer([-1,-1, +1,-1, +1,+1, -1,+1], 2);
-    //BLIT = new Shader('blit');
-  }
-  
-  gl.enable(gl.DEPTH_TEST);
-
-  renderToFramebuffer(camera, FB1);
-  
-  gl.disable(gl.DEPTH_TEST);
-  
-  drawScreenAlignedQuad(BLURH, FB1, FB2);
-  drawScreenAlignedQuad(BLURV, FB2);
-}
-
+var SAQ;
 function blurryIntro(time) {
   if (!gl) return;
   if (!SAQ)
 }
 
 
-function drawScreenAlignedQuad(shader, step, sourceFB, destFB) {
-  shader.use();
-  
-  gl.activeTexture(gl.TEXTURE0);
-  gl.bindTexture(gl.TEXTURE_2D, sourceFB.texture);
-  gl.uniform1i(shader.uniforms.uSrc, 0);
-  gl.uniform1f(shader.uniforms.uStep, step);
-  gl.bindFramebuffer(gl.FRAMEBUFFER, destFB);  // destFB may be null
-  gl.viewport(0, 0, 
-              destFB ? destFB.width : gl.viewportWidth, 
-              destFB ? destFB.height : gl.viewportHeight);
-
-  pointToAttribute(shader, {aPos: SAQ}, 'aPos');
-  gl.drawArrays(gl.TRIANGLE_FAN, 0, SAQ.numItems);
-
-  shader.disuse();
-}
-
-
 function vmult(v, w, result) {
   result = result || Array(v.length);
   for (var i = 0; i < v.length; ++i)