Sha256: 918df4a2711a711e9d484defd6eeeae44fa8ac8b16aeee8566854f1b99fed7a4

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 KB

Contents

(function (global, factory) {
  if (typeof define === "function" && define.amd) {
    define(["exports"], factory);
  } else if (typeof exports !== "undefined") {
    factory(exports);
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports);
    global.KaleidoShader = mod.exports;
  }
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.KaleidoShader = void 0;

  /**
   * Kaleidoscope Shader
   * Radial reflection around center point
   * Ported from: http://pixelshaders.com/editor/
   * by Toby Schachman / http://tobyschachman.com/
   *
   * sides: number of reflections
   * angle: initial angle in radians
   */
  var KaleidoShader = {
    uniforms: {
      'tDiffuse': {
        value: null
      },
      'sides': {
        value: 6.0
      },
      'angle': {
        value: 0.0
      }
    },
    vertexShader:
    /* glsl */
    "\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",
    fragmentShader:
    /* glsl */
    "\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float sides;\n\t\tuniform float angle;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec2 p = vUv - 0.5;\n\t\t\tfloat r = length(p);\n\t\t\tfloat a = atan(p.y, p.x) + angle;\n\t\t\tfloat tau = 2. * 3.1416 ;\n\t\t\ta = mod(a, tau/sides);\n\t\t\ta = abs(a - tau/sides/2.) ;\n\t\t\tp = r * vec2(cos(a), sin(a));\n\t\t\tvec4 color = texture2D(tDiffuse, p + 0.5);\n\t\t\tgl_FragColor = color;\n\n\t\t}"
  };
  _exports.KaleidoShader = KaleidoShader;
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opal-js_wrap-three-0.1.5 lib-opal/js_wrap/three/shaders/KaleidoShader.js
opal-js_wrap-three-0.1.4 lib-opal/js_wrap/three/shaders/KaleidoShader.js
opal-js_wrap-three-0.1.3 lib-opal/js_wrap/three/shaders/KaleidoShader.js
opal-js_wrap-three-0.1.2 lib-opal/js_wrap/three/shaders/KaleidoShader.js