Sha256: a63de00fcbba18731cc5697f09b819471eb08c71fb18f1aaba3da44b76fbeb0c

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

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

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

  /**
   * Brightness and contrast adjustment
   * https://github.com/evanw/glfx.js
   * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)
   * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
   */
  var BrightnessContrastShader = {
    uniforms: {
      'tDiffuse': {
        value: null
      },
      'brightness': {
        value: 0
      },
      'contrast': {
        value: 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 float brightness;\n\t\tuniform float contrast;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\tgl_FragColor.rgb += brightness;\n\n\t\t\tif (contrast > 0.0) {\n\t\t\t\tgl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;\n\t\t\t} else {\n\t\t\t\tgl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;\n\t\t\t}\n\n\t\t}"
  };
  _exports.BrightnessContrastShader = BrightnessContrastShader;
});

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