Sha256: 84281f7ca5bd5f8b8a45e17338f9fedda516a70b09cfd4abbf5c5194089763ae

Contents?: true

Size: 1.94 KB

Versions: 4

Compression:

Stored size: 1.94 KB

Contents

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

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

  /**
   * Luminosity
   * http://en.wikipedia.org/wiki/Luminosity
   */
  var LuminosityHighPassShader = {
    shaderID: 'luminosityHighPass',
    uniforms: {
      'tDiffuse': {
        value: null
      },
      'luminosityThreshold': {
        value: 1.0
      },
      'smoothWidth': {
        value: 1.0
      },
      'defaultColor': {
        value: new _three.Color(0x000000)
      },
      'defaultOpacity': {
        value: 0.0
      }
    },
    vertexShader:
    /* glsl */
    "\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\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 vec3 defaultColor;\n\t\tuniform float defaultOpacity;\n\t\tuniform float luminosityThreshold;\n\t\tuniform float smoothWidth;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\n\t\t\tvec3 luma = vec3( 0.299, 0.587, 0.114 );\n\n\t\t\tfloat v = dot( texel.xyz, luma );\n\n\t\t\tvec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );\n\n\t\t\tfloat alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );\n\n\t\t\tgl_FragColor = mix( outputColor, texel, alpha );\n\n\t\t}"
  };
  _exports.LuminosityHighPassShader = LuminosityHighPassShader;
});

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