Sha256: 20c7556dd6b644d64bed1f535f6df478b6ad7d1a1cb1c1c321f8f4d551fbe3c4

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 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.VignetteShader = mod.exports;
  }
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
  "use strict";

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

  /**
   * Vignette shader
   * based on PaintEffect postprocess from ro.me
   * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
   */
  var VignetteShader = {
    uniforms: {
      'tDiffuse': {
        value: null
      },
      'offset': {
        value: 1.0
      },
      'darkness': {
        value: 1.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 float offset;\n\t\tuniform float darkness;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t// Eskil's vignette\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tvec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );\n\t\t\tgl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );\n\n\t\t}"
  };
  _exports.VignetteShader = VignetteShader;
});

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/VignetteShader.js
opal-js_wrap-three-0.1.4 lib-opal/js_wrap/three/shaders/VignetteShader.js
opal-js_wrap-three-0.1.3 lib-opal/js_wrap/three/shaders/VignetteShader.js
opal-js_wrap-three-0.1.2 lib-opal/js_wrap/three/shaders/VignetteShader.js