text: /**
   * skylark-threejs-ex - A version of threejs extentions library that ported to running on skylarkjs
   * @author Hudaokeji, Inc.
   * @version v0.9.0
   * @link https://github.com/skylark-integration/skylark-threejs-ex/
   * @license MIT
   */
  define(["skylark-threejs","../threex","../postprocessing/Pass","../shaders/CopyShader","../shaders/LuminosityShader","../shaders/ToneMapShader"],function(e,i,t,a,n,r){"use strict";var s=function(i,s){t.call(this),this.resolution=void 0!==s?s:256,this.needsInit=!0,this.adaptive=void 0===i||!!i,this.luminanceRT=null,this.previousLuminanceRT=null,this.currentLuminanceRT=null,void 0===a&&console.error("AdaptiveToneMappingPass relies on CopyShader");var u=a;this.copyUniforms=e.UniformsUtils.clone(u.uniforms),this.materialCopy=new e.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:u.vertexShader,fragmentShader:u.fragmentShader,blending:e.NoBlending,depthTest:!1}),void 0===n&&console.error("AdaptiveToneMappingPass relies on LuminosityShader"),this.materialLuminance=new e.ShaderMaterial({uniforms:e.UniformsUtils.clone(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,blending:e.NoBlending}),this.adaptLuminanceShader={defines:{MIP_LEVEL_1X1:(Math.log(this.resolution)/Math.log(2)).toFixed(1)},uniforms:{lastLum:{value:null},currentLum:{value:null},minLuminance:{value:.01},delta:{value:.016},tau:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec2 vUv;","uniform sampler2D lastLum;","uniform sampler2D currentLum;","uniform float minLuminance;","uniform float delta;","uniform float tau;","void main() {","\tvec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );","\tvec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );","\tfloat fLastLum = max( minLuminance, lastLum.r );","\tfloat fCurrentLum = max( minLuminance, currentLum.r );","\tfCurrentLum *= fCurrentLum;","\tfloat fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));","\tgl_FragColor.r = fAdaptedLum;","}"].join("\n")},this.materialAdaptiveLum=new e.ShaderMaterial({uniforms:e.UniformsUtils.clone(this.adaptLuminanceShader.uniforms),vertexShader:this.adaptLuminanceShader.vertexShader,fragmentShader:this.adaptLuminanceShader.fragmentShader,defines:Object.assign({},this.adaptLuminanceShader.defines),blending:e.NoBlending}),void 0===r&&console.error("AdaptiveToneMappingPass relies on ToneMapShader"),this.materialToneMap=new e.ShaderMaterial({uniforms:e.UniformsUtils.clone(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,blending:e.NoBlending}),this.fsQuad=new t.FullScreenQuad(null)};return s.prototype=Object.assign(Object.create(t.prototype),{constructor:s,render:function(e,i,t,a){this.needsInit&&(this.reset(e),this.luminanceRT.texture.type=t.texture.type,this.previousLuminanceRT.texture.type=t.texture.type,this.currentLuminanceRT.texture.type=t.texture.type,this.needsInit=!1),this.adaptive&&(this.fsQuad.material=this.materialLuminance,this.materialLuminance.uniforms.tDiffuse.value=t.texture,e.setRenderTarget(this.currentLuminanceRT),this.fsQuad.render(e),this.fsQuad.material=this.materialAdaptiveLum,this.materialAdaptiveLum.uniforms.delta.value=a,this.materialAdaptiveLum.uniforms.lastLum.value=this.previousLuminanceRT.texture,this.materialAdaptiveLum.uniforms.currentLum.value=this.currentLuminanceRT.texture,e.setRenderTarget(this.luminanceRT),this.fsQuad.render(e),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.luminanceRT.texture,e.setRenderTarget(this.previousLuminanceRT),this.fsQuad.render(e)),this.fsQuad.material=this.materialToneMap,this.materialToneMap.uniforms.tDiffuse.value=t.texture,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(i),this.clear&&e.clear(),this.fsQuad.render(e))},reset:function(){this.luminanceRT&&this.luminanceRT.dispose(),this.currentLuminanceRT&&this.currentLuminanceRT.dispose(),this.previousLuminanceRT&&this.previousLuminanceRT.dispose();var i={minFilter:e.LinearFilter,magFilter:e.LinearFilter,format:e.RGBAFormat};this.luminanceRT=new e.WebGLRenderTarget(this.resolution,this.resolution,i),this.luminanceRT.texture.name="AdaptiveToneMappingPass.l",this.luminanceRT.texture.generateMipmaps=!1,this.previousLuminanceRT=new e.WebGLRenderTarget(this.resolution,this.resolution,i),this.previousLuminanceRT.texture.name="AdaptiveToneMappingPass.pl",this.previousLuminanceRT.texture.generateMipmaps=!1,i.minFilter=e.LinearMipmapLinearFilter,i.generateMipmaps=!0,this.currentLuminanceRT=new e.WebGLRenderTarget(this.resolution,this.resolution,i),this.currentLuminanceRT.texture.name="AdaptiveToneMappingPass.cl",this.adaptive&&(this.materialToneMap.defines.ADAPTED_LUMINANCE="",this.materialToneMap.uniforms.luminanceMap.value=this.luminanceRT.texture),this.fsQuad.material=new e.MeshBasicMaterial({color:7829367}),this.materialLuminance.needsUpdate=!0,this.materialAdaptiveLum.needsUpdate=!0,this.materialToneMap.needsUpdate=!0},setAdaptive:function(e){e?(this.adaptive=!0,this.materialToneMap.defines.ADAPTED_LUMINANCE="",this.materialToneMap.uniforms.luminanceMap.value=this.luminanceRT.texture):(this.adaptive=!1,delete this.materialToneMap.defines.ADAPTED_LUMINANCE,this.materialToneMap.uniforms.luminanceMap.value=null),this.materialToneMap.needsUpdate=!0},setAdaptionRate:function(e){e&&(this.materialAdaptiveLum.uniforms.tau.value=Math.abs(e))},setMinLuminance:function(e){e&&(this.materialToneMap.uniforms.minLuminance.value=e,this.materialAdaptiveLum.uniforms.minLuminance.value=e)},setMaxLuminance:function(e){e&&(this.materialToneMap.uniforms.maxLuminance.value=e)},setAverageLuminance:function(e){e&&(this.materialToneMap.uniforms.averageLuminance.value=e)},setMiddleGrey:function(e){e&&(this.materialToneMap.uniforms.middleGrey.value=e)},dispose:function(){this.luminanceRT&&this.luminanceRT.dispose(),this.previousLuminanceRT&&this.previousLuminanceRT.dispose(),this.currentLuminanceRT&&this.currentLuminanceRT.dispose(),this.materialLuminance&&this.materialLuminance.dispose(),this.materialAdaptiveLum&&this.materialAdaptiveLum.dispose(),this.materialCopy&&this.materialCopy.dispose(),this.materialToneMap&&this.materialToneMap.dispose()}}),i.postprocessing.AdaptiveToneMappingPass=s});
  //# sourceMappingURL=../sourcemaps/postprocessing/AdaptiveToneMappingPass.js.map
  