grain.fragment.js 793 B

123456789101112131415
  1. // Do not edit.
  2. import { ShaderStore } from "../Engines/shaderStore.js";
  3. import "./ShadersInclude/helperFunctions.js";
  4. const name = "grainPixelShader";
  5. const shader = `#include<helperFunctions>
  6. uniform sampler2D textureSampler;
  7. uniform float intensity;uniform float animatedSeed;varying vec2 vUV;
  8. #define CUSTOM_FRAGMENT_DEFINITIONS
  9. void main(void)
  10. {gl_FragColor=texture2D(textureSampler,vUV);vec2 seed=vUV*(animatedSeed);float grain=dither(seed,intensity);float lum=getLuminance(gl_FragColor.rgb);float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;gl_FragColor.rgb+=grain*grainAmount;gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);}`;
  11. // Sideeffect
  12. ShaderStore.ShadersStore[name] = shader;
  13. /** @internal */
  14. export const grainPixelShader = { name, shader };
  15. //# sourceMappingURL=grain.fragment.js.map