aframe-deferred-renderer
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,2 +0,2 @@ | ||
!function(e){function r(i){if(t[i])return t[i].exports;var n=t[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,r),n.loaded=!0,n.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register beforeAFRAME was available.");t(5),t(6),t(1),t(2),t(3),t(4),AFRAME.registerComponent("deferred-renderer",{schema:{lightPrePass:{type:"boolean",default:!0}},init:function(){this.renderer=null},update:function(){if(null===this.renderer){var e=this.data,r=this.el,t=r.sceneEl,i=t.renderer;if(void 0!==i){var n=i.getSize(),a=new THREE.WebGLDeferredRenderer({renderer:i});a.enableLightPrePass(e.lightPrePass),a.setSize(n.width,n.height);for(var o=Object.keys(i),s=0,l=o.length;s<l;s++){var d=o[s];void 0===a[d]&&(a[d]="function"==typeof i[d]?i[d].bind(i):i[d])}this.renderer=a,t.renderer=a,t.effect=new THREE.VREffect(this.renderer)}}},play:function(){this.update()}})},function(e,r){THREE.EffectComposer=function(e,r){if(this.renderer=e,void 0===r){var t={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,stencilBuffer:!1},i=e.getSize();r=new THREE.WebGLRenderTarget(i.width,i.height,t)}this.renderTarget1=r,this.renderTarget2=r.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.passes=[],void 0===THREE.CopyShader&&console.error("THREE.EffectComposer relies on THREE.CopyShader"),this.copyPass=new THREE.ShaderPass(THREE.CopyShader)},Object.assign(THREE.EffectComposer.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},addPass:function(e){this.passes.push(e);var r=this.renderer.getSize();e.setSize(r.width,r.height)},insertPass:function(e,r){this.passes.splice(r,0,e)},render:function(e){var r,t,i=!1,n=this.passes.length;for(t=0;t<n;t++)if(r=this.passes[t],r.enabled!==!1){if(r.render(this.renderer,this.writeBuffer,this.readBuffer,e,i),r.needsSwap){if(i){var a=this.renderer.context;a.stencilFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),a.stencilFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==THREE.MaskPass&&(r instanceof THREE.MaskPass?i=!0:r instanceof THREE.ClearMaskPass&&(i=!1))}},reset:function(e){if(void 0===e){var r=this.renderer.getSize();e=this.renderTarget1.clone(),e.setSize(r.width,r.height)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(e,r){this.renderTarget1.setSize(e,r),this.renderTarget2.setSize(e,r);for(var t=0;t<this.passes.length;t++)this.passes[t].setSize(e,r)}}),THREE.Pass=function(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1},Object.assign(THREE.Pass.prototype,{setSize:function(e,r){},render:function(e,r,t,i,n){console.error("THREE.Pass: .render() must be implemented in derived pass.")}})},function(e,r){THREE.RenderPass=function(e,r,t,i,n){THREE.Pass.call(this),this.scene=e,this.camera=r,this.overrideMaterial=t,this.clearColor=i,this.clearAlpha=void 0!==n?n:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1},THREE.RenderPass.prototype=Object.assign(Object.create(THREE.Pass.prototype),{constructor:THREE.RenderPass,render:function(e,r,t,i,n){var a=e.autoClear;e.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial;var o,s;this.clearColor&&(o=e.getClearColor().getHex(),s=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.render(this.scene,this.camera,this.renderToScreen?null:t,this.clear),this.clearColor&&e.setClearColor(o,s),this.scene.overrideMaterial=null,e.autoClear=a}})},function(e,r){THREE.ShaderPass=function(e,r){THREE.Pass.call(this),this.textureID=void 0!==r?r:"tDiffuse",e instanceof THREE.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=THREE.UniformsUtils.clone(e.uniforms),this.material=new THREE.ShaderMaterial({defines:e.defines||{},uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.camera=new THREE.OrthographicCamera(-1,1,1,-1,0,1),this.scene=new THREE.Scene,this.quad=new THREE.Mesh(new THREE.PlaneBufferGeometry(2,2),null),this.scene.add(this.quad)},THREE.ShaderPass.prototype=Object.assign(Object.create(THREE.Pass.prototype),{constructor:THREE.ShaderPass,render:function(e,r,t,i,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=t.texture),this.quad.material=this.material,this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,r,this.clear)}})},function(e,r){THREE.WebGLDeferredRenderer=function(e){function r(e){we.renderer=void 0!==e.renderer?e.renderer:new THREE.WebGLRenderer({antialias:!1}),we.domElement=we.renderer.domElement,oe=we.renderer.context,se=void 0!==e.width?e.width:we.renderer.getSize().width,le=void 0!==e.height?e.height:we.renderer.getSize().height;var r=void 0!==e.antialias&&e.antialias;void 0!==e.cacheKeepAlive&&(be=e.cacheKeepAlive),t(),i(),n(),a(),o(),s(),we.setSize(se,le),we.setAntialias(r),we.enableLightPrePass(!1)}function t(){Ce=new THREE.DepthTexture(se,le,THREE.UnsignedInt248Type,void 0,void 0,void 0,void 0,void 0,void 0,THREE.DepthStencilFormat)}function i(){ge=new THREE.RenderPass,ge.clear=!0;var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType,stencilBuffer:!0,depthTexture:Ce});e.texture.generateMipamps=!1,ce=new THREE.EffectComposer(we.renderer,e),ce.addPass(ge)}function n(){ue=new THREE.RenderPass,ue.clear=!0;var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType,depthTexture:Ce});e.texture.generateMipamps=!1,de=new THREE.EffectComposer(we.renderer,e),de.addPass(ue)}function a(){Re=new THREE.RenderPass,Re.clear=!0,Re.camera=new THREE.OrthographicCamera(-1,1,1,-1,0,1),Te=new THREE.RenderPass,Te.clear=!1;var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType,depthTexture:Ce});e.texture.generateMipamps=!1,ve=new THREE.EffectComposer(we.renderer,e),ve.addPass(Re),ve.addPass(Te)}function o(){Ee=new THREE.RenderPass,Ee.clear=!0;var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType,depthTexture:Ce});e.texture.generateMipamps=!1,fe=new THREE.EffectComposer(we.renderer,e),fe.addPass(Ee)}function s(){Se=new THREE.ShaderPass(THREE.ShaderDeferred.final),Se.clear=!0,Se.uniforms.samplerResult.value=ve.renderTarget2.texture,Se.material.blending=THREE.NoBlending,Se.material.depthWrite=!1,Se.material.depthTest=!1,he=new THREE.RenderPass,he.clear=!1,me=new THREE.ShaderPass(THREE.CopyShader),He=new THREE.ShaderPass(THREE.FXAAShader);var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat,type:THREE.UnsignedByteType,depthTexture:Ce});e.texture.generateMipamps=!1,pe=new THREE.EffectComposer(we.renderer,e),pe.addPass(Se),pe.addPass(he),pe.addPass(me),pe.addPass(He)}function l(e){var r=Ve[e.uuid],t=Ne[e.uuid];if(void 0===r){var i=new THREE.Scene;i.userData.lights={},r=$(),r.scene=i,Ve[e.uuid]=r}if(void 0===t){var i=new THREE.Scene;i.userData.lights={};var n=_();i.userData.emissiveLight=n,i.add(n),t=$(),t.scene=i,Ne[e.uuid]=t}r.used=!0,t.used=!0;var a=r.scene,o=t.scene;o.userData.emissiveLight.visible=!ye,De=a,ke=o}function d(e,r,t){var i=r[e.uuid];if(void 0===i){i=$();var n;if(e.isMultiMaterial===!0){for(var a=[],o=0,s=e.materials.length;o<s;o++)a.push(t(e.materials[o]));n=new THREE.MultiMaterial(a)}else n=t(e);i.material=n,r[e.uuid]=i}return i.material}function u(e){if(void 0!==e.material){var r=Oe[e.uuid],t=h(r);if(Oe[t.uuid]=r,t.isMultiMaterial===!0)for(var i=0,n=t.materials.length;i<n;i++)Oe[t.materials[i].uuid]=r.materials[i],f(t.materials[i],r.materials[i]);else f(t,r);e.material=t,e.onBeforeRender=E}}function h(e){return d(e,ye?Ue:je,m)}function m(e){var r=ye?THREE.ShaderDeferred.normalDepthShininess:THREE.ShaderDeferred.normalDepth;return new THREE.ShaderMaterial({uniforms:Object.assign({},r.uniforms),fragmentShader:r.fragmentShader,vertexShader:r.vertexShader,blending:THREE.NoBlending})}function f(e,r){void 0!==r.skinning&&(e.skinning=r.skinning),void 0!==r.morphTargets&&(e.morphTargets=r.morphTargets),r.visible===!0?e.visible=!r.transparent:e.visible=!1}function E(e,r,t,i,n,a){if(ye){var o=Oe[n.uuid];void 0!==o&&void 0!==o.shininess&&(n.uniforms.shininess.value=o.shininess)}}function c(e){if(void 0!==e.material){var r=Oe[e.uuid],t=v(r);if(Oe[t.uuid]=r,r.isMultiMaterial===!0)for(var i=0,n=r.materials.length;i<n;i++)Oe[t.materials[i].uuid]=r.materials[i],g(t.materials[i],r.materials[i]);else g(t,r);e.material=t,e.onBeforeRender=T}}function v(e){return d(e,Le,p)}function p(e){var r=THREE.ShaderDeferred.color,t=new THREE.ShaderMaterial({uniforms:Object.assign({},r.uniforms),fragmentShader:r.fragmentShader,vertexShader:r.vertexShader,blending:THREE.NoBlending});return void 0!==e.map&&(t.map=e.map),t}function g(e,r){void 0!==r.map&&(e.map=r.map),void 0!==r.skinning&&(e.skinning=r.skinning),void 0!==r.morphTargets&&(e.morphTargets=r.morphTargets),r.visible===!0?e.visible=!r.transparent:e.visible=!1}function T(e,r,t,i,n,a){var o,s,l=Oe[n.uuid],d=n.uniforms;l.isMeshBasicMaterial===!0?s=l.color:(o=l.color,s=l.emissive);var u=l.specular,h=l.shininess,m=l.map;void 0!==o&&d.diffuse.value.copy(o),void 0!==s&&d.emissive.value.copy(s),void 0!==u&&d.specular.value.copy(u),void 0!==h&&void 0!==d.shininess&&(d.shininess.value=h),void 0!==m&&(d.map.value=m)}function R(e){if(void 0!==e.material){var r=Oe[e.uuid];if(r.transparent===!0)return e.material=r,void(e.onBeforeRender=Ge[e.uuid]);var t=S(r);if(Oe[t.uuid]=r,r.isMultiMaterial===!0)for(var i=0,n=r.materials.length;i<n;i++)Oe[t.materials[i].uuid]=r.materials[i],C(t.materials[i],r.materials[i]);else C(t,r);e.material=t,e.onBeforeRender=x}}function S(e){return d(e,Ae,H)}function H(e){var r=THREE.ShaderDeferred.reconstruction,t=new THREE.ShaderMaterial({uniforms:Object.assign({},r.uniforms),fragmentShader:r.fragmentShader,vertexShader:r.vertexShader,blending:THREE.NoBlending});return void 0!==e.map&&(t.map=e.map),t}function C(e,r){g(e,r)}function x(e,r,t,i,n,a){T(e,r,t,i,n,a),n.uniforms.samplerLight.value=ve.renderTarget2.texture}function D(e){if(void 0!==e.material){var r=Oe[e.uuid];if(r.isMultiMaterial===!0){for(var t=k(r),i=0,n=r.materials.length;i<n;i++)t.materials[i]=P(r.materials[i]);e.material=t}else e.material=P(r);e.onBeforeRender=Ge[e.uuid]}}function k(e){return d(e,ze,w)}function w(e){return Me}function P(e){return e.transparent===!0&&e.visible===!0?e:Me}function _(){var e=THREE.ShaderDeferred.emissiveLight,r=new THREE.ShaderMaterial({uniforms:Object.assign({},e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:THREE.NoBlending,depthWrite:!1}),t=new THREE.PlaneBufferGeometry(2,2),i=new THREE.Mesh(t,r);return i.onBeforeRender=function(e,r,t,i,n,a){n.uniforms.samplerColor.value=de.renderTarget2.texture},i}function y(e){return e.isPointLight?U(e):e.isSpotLight?B(e):e.isDirectionalLight?O(e):null}function b(e){return e.isPointLight?L():e.isSpotLight?W():e.isDirectionalLight?G():null}function M(e){var r=ye?Ie:We,t=r[e.uuid];return void 0===t&&(t=$(),t.material=b(e.userData.originalLight),r[e.uuid]=t),t.material}function F(e){var r=e.userData.originalLight;r.isPointLight&&A(e)}function V(e,r){var t=new THREE.Mesh(r,Me);return t.userData.originalLight=e,t}function N(e){var r=new THREE.ShaderMaterial({uniforms:Object.assign({},e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,transparent:!0,blending:THREE.AdditiveBlending,depthWrite:!1});return ye&&(r.premultipliedAlpha=!0),r}function j(e){ye?e.samplerNormalDepthShininess.value=ce.renderTarget2.texture:(e.samplerNormalDepth.value=ce.renderTarget2.texture,e.samplerColor.value=de.renderTarget2.texture)}function U(e){var r=V(e,new THREE.SphereGeometry(1,16,8));return r.onBeforeRender=z,r}function L(){var e=ye?THREE.ShaderDeferred.pointLightPre:THREE.ShaderDeferred.pointLight,r=N(e);return r.side=THREE.BackSide,r.depthFunc=THREE.GreaterEqualDepth,r}function A(e){var r=e.userData.originalLight,t=r.distance;t>0&&(e.scale.set(1,1,1).multiplyScalar(t),e.position.setFromMatrixPosition(r.matrixWorld))}function z(e,r,t,i,n,a){var o=this,s=o.userData.originalLight,l=s.distance,d=n.uniforms;d.lightColor.value.copy(s.color),l>0?(d.lightRadius.value=l,d.lightIntensity.value=s.intensity,d.lightPositionVS.value.setFromMatrixPosition(s.matrixWorld).applyMatrix4(xe.matrixWorldInverse)):d.lightRadius.value=1/0,j(d)}function B(e){var r=V(e,new THREE.PlaneBufferGeometry(2,2));return r.onBeforeRender=I,r}function W(){var e=ye?THREE.ShaderDeferred.spotLightPre:THREE.ShaderDeferred.spotLight,r=N(e);return r.depthTest=!1,r}function I(e,r,t,i,n,a){var o=this,s=o.userData.originalLight,l=o.material.uniforms;l.lightAngle.value=s.angle,l.lightColor.value.copy(s.color),l.lightIntensity.value=s.intensity,l.lightPositionVS.value.setFromMatrixPosition(s.matrixWorld).applyMatrix4(xe.matrixWorldInverse);var d=l.lightDirectionVS.value,u=Fe;d.setFromMatrixPosition(s.matrixWorld),u.setFromMatrixPosition(s.target.matrixWorld),d.sub(u).normalize().transformDirection(xe.matrixWorldInverse),j(l)}function O(e){var r=V(e,new THREE.PlaneBufferGeometry(2,2));return r.onBeforeRender=X,r}function G(){var e=ye?THREE.ShaderDeferred.directionalLightPre:THREE.ShaderDeferred.directionalLight,r=N(e);return r.depthTest=!1,r}function X(e,r,t,i,n,a){var o=this,s=o.userData.originalLight,l=o.material.uniforms;l.lightColor.value.copy(s.color),l.lightIntensity.value=s.intensity;var d=l.lightDirectionVS.value,u=Fe;d.setFromMatrixPosition(s.matrixWorld),u.setFromMatrixPosition(s.target.matrixWorld),d.sub(u).normalize().transformDirection(xe.matrixWorldInverse),j(l)}function K(e){if(void 0!==e.material&&(Oe[e.uuid]=e.material,Ge[e.uuid]=e.onBeforeRender,!_e&&!ye))if(e.material.isMultiMaterial===!0){for(var r=0,t=e.material.materials.length;r<t;r++)if(e.material.materials[r].transparent===!0){_e=!0;break}}else e.material.transparent===!0&&(_e=!0)}function q(e){void 0!==e.material&&(e.material=Oe[e.uuid],e.onBeforeRender=Ge[e.uuid])}function Q(e){if(e.isLight===!0){var r=Be[e.uuid];void 0===r&&(r=$(),r.light=y(e),Be[e.uuid]=r);var t=r.light;if(null!==t){var i=e.isPointLight===!0?De:ke,n=i.userData.lights;void 0===n[t.uuid]&&(i.add(t),n[t.uuid]={light:t,found:!0}),n[t.uuid].found=!0}}}function Y(e){for(var r=e.userData.lights,t=Object.keys(r),i=0,n=t.length;i<n;i++){var a=t[i];if(r[a].found===!1)e.remove(r[a].light),delete r[a];else{var o=r[a].light;o.material=M(o),F(o),r[a].found=!1}}}function J(e){var r=THREE.ShaderDeferredCommon.commonUniforms;r.viewWidth.value=se,r.viewHeight.value=le,r.matProjInverse.value.getInverse(e.projectionMatrix)}function Z(){ye?(he.renderToScreen=!1,he.enabled=!1,me.renderToScreen=!1,me.enabled=!1,Pe?(Se.renderToScreen=!1,He.renderToScreen=!0,He.enabled=!0):(Se.renderToScreen=!0,He.renderToScreen=!1,He.enabled=!1)):_e?Pe?(Se.renderToScreen=!1,he.renderToScreen=!1,he.enabled=!0,me.renderToScreen=!1,me.enabled=!1,He.renderToScreen=!0,He.enabled=!0):(Se.renderToScreen=!1,he.renderToScreen=!1,he.enabled=!0,me.renderToScreen=!0,me.enabled=!0,He.renderToScreen=!1,He.enabled=!1):Pe?(Se.renderToScreen=!1,he.renderToScreen=!1,he.enabled=!1,me.renderToScreen=!1,me.enabled=!1,He.renderToScreen=!0,He.enabled=!0):(Se.renderToScreen=!0,he.renderToScreen=!1,he.enabled=!1,me.renderToScreen=!1,me.enabled=!1,He.renderToScreen=!1,He.enabled=!1)}function $(){return{used:!0,keepAlive:be,count:0}}function ee(e,r){e.traverse(u),ge.scene=e,ge.camera=r,we.renderer.autoClearDepth=!0,we.renderer.autoClearStencil=!0,oe.enable(oe.STENCIL_TEST),oe.stencilFunc(oe.ALWAYS,1,4294967295),oe.stencilOp(oe.REPLACE,oe.REPLACE,oe.REPLACE),ce.render()}function re(e,r){e.traverse(c),ue.scene=e,ue.camera=r,we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,oe.stencilFunc(oe.EQUAL,1,4294967295),oe.stencilOp(oe.KEEP,oe.KEEP,oe.KEEP),de.render()}function te(e,r){e.traverse(Q),Y(De),Y(ke),Te.scene=De,Te.camera=r,Re.scene=ke,we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,ve.render(),oe.disable(oe.STENCIL_TEST)}function ie(e,r){e.traverse(Q),Y(De),Y(ke),Te.scene=De,Te.camera=r,Re.scene=ke,we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,oe.stencilFunc(oe.EQUAL,1,4294967295),oe.stencilOp(oe.KEEP,oe.KEEP,oe.KEEP),ve.render()}function ne(e,r){e.traverse(R),Ee.scene=e,Ee.camera=r,we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,fe.render(),oe.disable(oe.STENCIL_TEST)}function ae(e,r){!ye&&_e&&(e.traverse(D),he.scene=e,he.camera=r),Z(),we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,pe.render()}e=e||{};var oe,se,le,de,ue,he,me,fe,Ee,ce,ve,pe,ge,Te,Re,Se,He,Ce,xe,De,ke,we=this,Pe=!1,_e=!1,ye=!1,be=!1,Me=new THREE.ShaderMaterial({visible:!1}),Fe=new THREE.Vector3,Ve={},Ne={},je={},Ue={},Le={},Ae={},ze={},Be={},We={},Ie={},Oe={},Ge={};this.renderer=void 0,this.domElement=void 0,this.forwardRendering=!1,this.setSize=function(e,r){se=e,le=r,this.renderer.setSize(se,le),ce.setSize(se,le),de.setSize(se,le),ve.setSize(se,le),fe.setSize(se,le),pe.setSize(se,le),Ce.image.width=se,Ce.image.height=le,Ce.needsUpdate=!0,He.uniforms.resolution.value.set(1/se,1/le)},this.setAntialias=function(e){Pe=e},this.enableLightPrePass=function(e){ye=e,Se.uniforms.samplerResult.value=ye?fe.renderTarget2.texture:ve.renderTarget2.texture},this.render=function(e,r){if(this.forwardRendering)return void this.renderer.render(e,r);var t=e.autoUpdate,i=this.renderer.autoClearColor,n=this.renderer.autoClearDepth,a=this.renderer.autoClearStencil;xe=r,l(e),e.autoUpdate=!1,e.updateMatrixWorld(),_e=!1,e.traverse(K),J(r),ee(e,r),ye?(ie(e,r),ne(e,r)):(re(e,r),te(e,r)),ae(e,r),e.traverse(q),e.autoUpdate=t,this.renderer.autoClearColor=i,this.renderer.autoClearDepth=n,this.renderer.autoClearStencil=a},r(e)},THREE.DeferredShaderChunk={packVector3:["float vec3_to_float( vec3 data ) {","\tconst float unit = 255.0/256.0;","\thighp float compressed = fract( data.x * unit ) + floor( data.y * unit * 255.0 ) + floor( data.z * unit * 255.0 ) * 255.0;","\treturn compressed;","}"].join("\n"),unpackFloat:["vec3 float_to_vec3( float data ) {","\tconst float unit = 255.0;","\tvec3 uncompressed;","\tuncompressed.x = fract( data );","\tfloat zInt = floor( data / unit );","\tuncompressed.z = fract( zInt / unit );","\tuncompressed.y = fract( floor( data - ( zInt * unit ) ) / unit );","\treturn uncompressed;","}"].join("\n"),packNormal:["vec2 normal_to_vec2( vec3 normal ) {","\treturn normal.xy / sqrt( normal.z * 8.0 + 8.0 ) + 0.5;","}"].join("\n"),unpackVector2:["vec3 vec2_to_normal( vec2 data ) {","\tvec2 fenc = data * 4.0 - 2.0;","\tfloat f = dot( fenc, fenc );","\tfloat g = sqrt( 1.0 - f / 4.0 );","\tvec3 normal;","\tnormal.xy = fenc * g;","\tnormal.z = 1.0 - f / 2.0;","\treturn normal;","}"].join("\n"),computeTextureCoord:["vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );"].join("\n"),packNormalDepth:["vec4 packedNormalDepth;","packedNormalDepth.xyz = normal * 0.5 + 0.5;","packedNormalDepth.w = position.z / position.w;"].join("\n"),unpackNormalDepth:["vec4 normalDepthMap = texture2D( samplerNormalDepth, texCoord );","float depth = normalDepthMap.w;","if ( depth == 0.0 ) discard;","vec3 normal = normalDepthMap.xyz * 2.0 - 1.0;"].join("\n"),packNormalDepthShininess:["vec4 packedNormalDepthShininess;","packedNormalDepthShininess.xy = normal_to_vec2( normal );","packedNormalDepthShininess.z = shininess;","packedNormalDepthShininess.w = position.z / position.w;"].join("\n"),unpackNormalDepthShininess:["vec4 normalDepthMap = texture2D( samplerNormalDepthShininess, texCoord );","float depth = normalDepthMap.w;","if ( depth == 0.0 ) discard;","vec3 normal = vec2_to_normal( normalDepthMap.xy );","float shininess = normalDepthMap.z;"].join("\n"),packColor:["vec4 packedColor;","packedColor.x = vec3_to_float( diffuseColor.rgb );","packedColor.y = vec3_to_float( emissiveColor );","packedColor.z = vec3_to_float( specularColor );","packedColor.w = shininess;"].join("\n"),unpackColor:["vec4 colorMap = texture2D( samplerColor, texCoord );","vec3 diffuseColor = float_to_vec3( colorMap.x );","vec3 emissiveColor = float_to_vec3( colorMap.y );","vec3 specularColor = float_to_vec3( colorMap.z );","float shininess = colorMap.w;"].join("\n"),packLight:["vec4 packedLight;","packedLight.xyz = lightIntensity * lightColor * max( dot( lightVector, normal ), 0.0 ) * attenuation;","packedLight.w = lightIntensity * specular * max( dot( lightVector, normal ), 0.0 ) * attenuation;"].join("\n"),computeVertexPositionVS:["vec2 xy = texCoord * 2.0 - 1.0;","vec4 vertexPositionProjected = vec4( xy, depth, 1.0 );","vec4 vertexPositionVS = matProjInverse * vertexPositionProjected;","vertexPositionVS.xyz /= vertexPositionVS.w;","vertexPositionVS.w = 1.0;"].join("\n"),computeSpecular:["vec3 halfVector = normalize( lightVector - normalize( vertexPositionVS.xyz ) );","float dotNormalHalf = max( dot( normal, halfVector ), 0.0 );","float specular = 0.31830988618 * ( shininess * 0.5 + 1.0 ) * pow( dotNormalHalf, shininess );"].join("\n"),combine:["gl_FragColor = vec4( lightIntensity * lightColor * max( dot( lightVector, normal ), 0.0 ) * ( diffuseColor + specular * specularColor ) * attenuation, 1.0 );"].join("\n")},THREE.ShaderDeferredCommon={commonUniforms:{matProjInverse:new THREE.Uniform(new THREE.Matrix4),viewWidth:new THREE.Uniform(800),viewHeight:new THREE.Uniform(600)}},THREE.ShaderDeferred={normalDepth:{uniforms:{},vertexShader:["varying vec3 vNormal;","varying vec4 vPosition;",THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,"\tvNormal = normalize( normalMatrix * objectNormal );","\tvPosition = gl_Position;","}"].join("\n"),fragmentShader:["varying vec3 vNormal;","varying vec4 vPosition;","void main() {","\tvec3 normal = vNormal;","\tvec4 position = vPosition;",THREE.DeferredShaderChunk.packNormalDepth,"\tgl_FragColor = packedNormalDepth;","}"].join("\n")},color:{uniforms:{map:new THREE.Uniform(null),offsetRepeat:new THREE.Uniform(new THREE.Vector4(0,0,1,1)),diffuse:new THREE.Uniform(new THREE.Color(0)),emissive:new THREE.Uniform(new THREE.Color(0)),specular:new THREE.Uniform(new THREE.Color(0)),shininess:new THREE.Uniform(30)},vertexShader:[THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;",THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.DeferredShaderChunk.packVector3,"void main() {","\tvec4 diffuseColor = vec4( diffuse, 1.0 );","\tvec3 emissiveColor = emissive;","\tvec3 specularColor = specular;",THREE.ShaderChunk.map_fragment,THREE.DeferredShaderChunk.packColor,"\tgl_FragColor = packedColor;","}"].join("\n")},emissiveLight:{uniforms:Object.assign({samplerColor:new THREE.Uniform(null)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;",THREE.DeferredShaderChunk.unpackFloat,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackColor,"\tgl_FragColor = vec4( emissiveColor, 1.0 );","}"].join("\n")},pointLight:{uniforms:Object.assign({samplerNormalDepth:new THREE.Uniform(null),samplerColor:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightPositionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightIntensity:new THREE.Uniform(1),lightRadius:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform float lightIntensity;","uniform float lightRadius;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepth,THREE.DeferredShaderChunk.computeVertexPositionVS,"\tvec3 lightVector = lightPositionVS - vertexPositionVS.xyz;","\tfloat distance = length( lightVector );","\tif ( distance > lightRadius ) discard;","\tlightVector = normalize( lightVector );",THREE.DeferredShaderChunk.unpackColor,THREE.DeferredShaderChunk.computeSpecular,"\t//float cutoff = 0.3;","\t//float denom = distance / lightRadius + 1.0;","\t//float attenuation = 1.0 / ( denom * denom );","\t//attenuation = ( attenuation - cutoff ) / ( 1.0 - cutoff );","\t//attenuation = max( attenuation, 0.0 );","\t//attenuation *= attenuation;","\t//diffuseColor *= saturate( -distance / lightRadius + 1.0 );","\t//float attenuation = 1.0;","\tfloat attenuation = saturate( -distance / lightRadius + 1.0 );",THREE.DeferredShaderChunk.combine,"}"].join("\n")},spotLight:{uniforms:Object.assign({samplerNormalDepth:new THREE.Uniform(null),samplerColor:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightDirectionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightPositionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightAngle:new THREE.Uniform(1),lightIntensity:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform vec3 lightDirectionVS;","uniform float lightAngle;","uniform float lightIntensity;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepth,THREE.DeferredShaderChunk.computeVertexPositionVS,THREE.DeferredShaderChunk.unpackColor,"\tvec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );","\tfloat rho = dot( lightDirectionVS, lightVector );","\tfloat rhoMax = cos( lightAngle );","\tif ( rho <= rhoMax ) discard;","\tfloat theta = rhoMax + 0.0001;","\tfloat phi = rhoMax + 0.05;","\tfloat falloff = 4.0;","\tfloat spot = 0.0;","\tif ( rho >= phi ) {","\t\tspot = 1.0;","\t} else if ( rho <= theta ) {","\t\tspot = 0.0;","\t} else { ","\t\tspot = pow( ( rho - theta ) / ( phi - theta ), falloff );","\t}","\tdiffuseColor *= spot;",THREE.DeferredShaderChunk.computeSpecular,"\tconst float attenuation = 1.0;",THREE.DeferredShaderChunk.combine,"}"].join("\n")},directionalLight:{uniforms:Object.assign({samplerNormalDepth:new THREE.Uniform(null),samplerColor:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightDirectionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightIntensity:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightDirectionVS;","uniform float lightIntensity;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepth,THREE.DeferredShaderChunk.computeVertexPositionVS,THREE.DeferredShaderChunk.unpackColor,"\tvec3 lightVector = normalize( lightDirectionVS );",THREE.DeferredShaderChunk.computeSpecular,"\tconst float attenuation = 1.0;",THREE.DeferredShaderChunk.combine,"}"].join("\n")},normalDepthShininess:{uniforms:{shininess:new THREE.Uniform(30)},vertexShader:["varying vec3 vNormal;","varying vec4 vPosition;",THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,"\tvNormal = normalize( normalMatrix * objectNormal );","\tvPosition = gl_Position;","}"].join("\n"),fragmentShader:["varying vec3 vNormal;","varying vec4 vPosition;","uniform float shininess;",THREE.DeferredShaderChunk.packNormal,"void main() {","\tvec3 normal = vNormal;","\tvec4 position = vPosition;",THREE.DeferredShaderChunk.packNormalDepthShininess,"\tgl_FragColor = packedNormalDepthShininess;","}"].join("\n")},pointLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightPositionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightIntensity:new THREE.Uniform(1),lightRadius:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform float lightIntensity;","uniform float lightRadius;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,THREE.DeferredShaderChunk.unpackVector2,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepthShininess,THREE.DeferredShaderChunk.computeVertexPositionVS,"\tvec3 lightVector = lightPositionVS - vertexPositionVS.xyz;","\tfloat distance = length( lightVector );","\tif ( distance > lightRadius ) discard;","\tlightVector = normalize( lightVector );",THREE.DeferredShaderChunk.computeSpecular,"\tfloat attenuation = saturate( -distance / lightRadius + 1.0 );",THREE.DeferredShaderChunk.packLight,"\tgl_FragColor = packedLight;","}"].join("\n")},spotLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightDirectionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightPositionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightAngle:new THREE.Uniform(1),lightIntensity:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform vec3 lightDirectionVS;","uniform float lightAngle;","uniform float lightIntensity;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,THREE.DeferredShaderChunk.unpackVector2,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepthShininess,THREE.DeferredShaderChunk.computeVertexPositionVS,"\tvec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );","\tfloat rho = dot( lightDirectionVS, lightVector );","\tfloat rhoMax = cos( lightAngle );","\tif ( rho <= rhoMax ) discard;","\tfloat theta = rhoMax + 0.0001;","\tfloat phi = rhoMax + 0.05;","\tfloat falloff = 4.0;","\tfloat spot = 0.0;","\tif ( rho >= phi ) {","\t\tspot = 1.0;","\t} else if ( rho <= theta ) {","\t\tspot = 0.0;","\t} else { ","\t\tspot = pow( ( rho - theta ) / ( phi - theta ), falloff );","\t}",THREE.DeferredShaderChunk.computeSpecular,"\tconst float attenuation = 1.0;",THREE.DeferredShaderChunk.packLight,"\tgl_FragColor = spot * packedLight;","}"].join("\n") | ||
!function(e){function r(i){if(t[i])return t[i].exports;var n=t[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,r),n.loaded=!0,n.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register beforeAFRAME was available.");t(5),t(6),t(1),t(2),t(3),t(4),AFRAME.registerComponent("deferred-renderer",{schema:{lightPrePass:{type:"boolean",default:!0}},init:function(){this.renderer=null},update:function(){this.setupDeferredRenderer()},play:function(){this.setupDeferredRenderer()},setupDeferredRenderer:function(){if(null===this.renderer){var e=this.data,r=this.el,t=r.sceneEl,i=t.renderer;if(void 0!==i){var n=i.getSize(),a=new THREE.WebGLDeferredRenderer({renderer:i});a.enableLightPrePass(e.lightPrePass),a.setSize(n.width,n.height);for(var o=Object.keys(i),s=0,l=o.length;s<l;s++){var d=o[s];void 0===a[d]&&(a[d]="function"==typeof i[d]?i[d].bind(i):i[d])}this.renderer=a,t.renderer=a,t.effect=new THREE.VREffect(this.renderer)}}}})},function(e,r){THREE.EffectComposer=function(e,r){if(this.renderer=e,void 0===r){var t={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,stencilBuffer:!1},i=e.getSize();r=new THREE.WebGLRenderTarget(i.width,i.height,t)}this.renderTarget1=r,this.renderTarget2=r.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.passes=[],void 0===THREE.CopyShader&&console.error("THREE.EffectComposer relies on THREE.CopyShader"),this.copyPass=new THREE.ShaderPass(THREE.CopyShader)},Object.assign(THREE.EffectComposer.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},addPass:function(e){this.passes.push(e);var r=this.renderer.getSize();e.setSize(r.width,r.height)},insertPass:function(e,r){this.passes.splice(r,0,e)},render:function(e){var r,t,i=!1,n=this.passes.length;for(t=0;t<n;t++)if(r=this.passes[t],r.enabled!==!1){if(r.render(this.renderer,this.writeBuffer,this.readBuffer,e,i),r.needsSwap){if(i){var a=this.renderer.context;a.stencilFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),a.stencilFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==THREE.MaskPass&&(r instanceof THREE.MaskPass?i=!0:r instanceof THREE.ClearMaskPass&&(i=!1))}},reset:function(e){if(void 0===e){var r=this.renderer.getSize();e=this.renderTarget1.clone(),e.setSize(r.width,r.height)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(e,r){this.renderTarget1.setSize(e,r),this.renderTarget2.setSize(e,r);for(var t=0;t<this.passes.length;t++)this.passes[t].setSize(e,r)}}),THREE.Pass=function(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1},Object.assign(THREE.Pass.prototype,{setSize:function(e,r){},render:function(e,r,t,i,n){console.error("THREE.Pass: .render() must be implemented in derived pass.")}})},function(e,r){THREE.RenderPass=function(e,r,t,i,n){THREE.Pass.call(this),this.scene=e,this.camera=r,this.overrideMaterial=t,this.clearColor=i,this.clearAlpha=void 0!==n?n:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1},THREE.RenderPass.prototype=Object.assign(Object.create(THREE.Pass.prototype),{constructor:THREE.RenderPass,render:function(e,r,t,i,n){var a=e.autoClear;e.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial;var o,s;this.clearColor&&(o=e.getClearColor().getHex(),s=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.render(this.scene,this.camera,this.renderToScreen?null:t,this.clear),this.clearColor&&e.setClearColor(o,s),this.scene.overrideMaterial=null,e.autoClear=a}})},function(e,r){THREE.ShaderPass=function(e,r){THREE.Pass.call(this),this.textureID=void 0!==r?r:"tDiffuse",e instanceof THREE.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=THREE.UniformsUtils.clone(e.uniforms),this.material=new THREE.ShaderMaterial({defines:e.defines||{},uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.camera=new THREE.OrthographicCamera(-1,1,1,-1,0,1),this.scene=new THREE.Scene,this.quad=new THREE.Mesh(new THREE.PlaneBufferGeometry(2,2),null),this.scene.add(this.quad)},THREE.ShaderPass.prototype=Object.assign(Object.create(THREE.Pass.prototype),{constructor:THREE.ShaderPass,render:function(e,r,t,i,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=t.texture),this.quad.material=this.material,this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,r,this.clear)}})},function(e,r){THREE.WebGLDeferredRenderer=function(e){function r(e){we.renderer=void 0!==e.renderer?e.renderer:new THREE.WebGLRenderer({antialias:!1}),we.domElement=we.renderer.domElement,oe=we.renderer.context,se=void 0!==e.width?e.width:we.renderer.getSize().width,le=void 0!==e.height?e.height:we.renderer.getSize().height;var r=void 0!==e.antialias&&e.antialias;void 0!==e.cacheKeepAlive&&(be=e.cacheKeepAlive),t(),i(),n(),a(),o(),s(),we.setSize(se,le),we.setAntialias(r),we.enableLightPrePass(!1)}function t(){Ce=new THREE.DepthTexture(se,le,THREE.UnsignedInt248Type,void 0,void 0,void 0,void 0,void 0,void 0,THREE.DepthStencilFormat)}function i(){ge=new THREE.RenderPass,ge.clear=!0;var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType,stencilBuffer:!0,depthTexture:Ce});e.texture.generateMipamps=!1,ce=new THREE.EffectComposer(we.renderer,e),ce.addPass(ge)}function n(){ue=new THREE.RenderPass,ue.clear=!0;var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType,depthTexture:Ce});e.texture.generateMipamps=!1,de=new THREE.EffectComposer(we.renderer,e),de.addPass(ue)}function a(){Re=new THREE.RenderPass,Re.clear=!0,Re.camera=new THREE.OrthographicCamera(-1,1,1,-1,0,1),Te=new THREE.RenderPass,Te.clear=!1;var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType,depthTexture:Ce});e.texture.generateMipamps=!1,ve=new THREE.EffectComposer(we.renderer,e),ve.addPass(Re),ve.addPass(Te)}function o(){Ee=new THREE.RenderPass,Ee.clear=!0;var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat,type:THREE.FloatType,depthTexture:Ce});e.texture.generateMipamps=!1,fe=new THREE.EffectComposer(we.renderer,e),fe.addPass(Ee)}function s(){Se=new THREE.ShaderPass(THREE.ShaderDeferred.final),Se.clear=!0,Se.uniforms.samplerResult.value=ve.renderTarget2.texture,Se.material.blending=THREE.NoBlending,Se.material.depthWrite=!1,Se.material.depthTest=!1,he=new THREE.RenderPass,he.clear=!1,me=new THREE.ShaderPass(THREE.CopyShader),He=new THREE.ShaderPass(THREE.FXAAShader);var e=new THREE.WebGLRenderTarget(se,le,{minFilter:THREE.NearestFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat,type:THREE.UnsignedByteType,depthTexture:Ce});e.texture.generateMipamps=!1,pe=new THREE.EffectComposer(we.renderer,e),pe.addPass(Se),pe.addPass(he),pe.addPass(me),pe.addPass(He)}function l(e){var r=Ve[e.uuid],t=Ne[e.uuid];if(void 0===r){var i=new THREE.Scene;i.userData.lights={},r=$(),r.scene=i,Ve[e.uuid]=r}if(void 0===t){var i=new THREE.Scene;i.userData.lights={};var n=_();i.userData.emissiveLight=n,i.add(n),t=$(),t.scene=i,Ne[e.uuid]=t}r.used=!0,t.used=!0;var a=r.scene,o=t.scene;o.userData.emissiveLight.visible=!ye,De=a,ke=o}function d(e,r,t){var i=r[e.uuid];if(void 0===i){i=$();var n;if(e.isMultiMaterial===!0){for(var a=[],o=0,s=e.materials.length;o<s;o++)a.push(t(e.materials[o]));n=new THREE.MultiMaterial(a)}else n=t(e);i.material=n,r[e.uuid]=i}return i.material}function u(e){if(void 0!==e.material){var r=Oe[e.uuid],t=h(r);if(Oe[t.uuid]=r,t.isMultiMaterial===!0)for(var i=0,n=t.materials.length;i<n;i++)Oe[t.materials[i].uuid]=r.materials[i],f(t.materials[i],r.materials[i]);else f(t,r);e.material=t,e.onBeforeRender=E}}function h(e){return d(e,ye?Ue:je,m)}function m(e){var r=ye?THREE.ShaderDeferred.normalDepthShininess:THREE.ShaderDeferred.normalDepth;return new THREE.ShaderMaterial({uniforms:Object.assign({},r.uniforms),fragmentShader:r.fragmentShader,vertexShader:r.vertexShader,blending:THREE.NoBlending})}function f(e,r){void 0!==r.skinning&&(e.skinning=r.skinning),void 0!==r.morphTargets&&(e.morphTargets=r.morphTargets),r.visible===!0?e.visible=!r.transparent:e.visible=!1}function E(e,r,t,i,n,a){if(ye){var o=Oe[n.uuid];void 0!==o&&void 0!==o.shininess&&(n.uniforms.shininess.value=o.shininess)}}function c(e){if(void 0!==e.material){var r=Oe[e.uuid],t=v(r);if(Oe[t.uuid]=r,r.isMultiMaterial===!0)for(var i=0,n=r.materials.length;i<n;i++)Oe[t.materials[i].uuid]=r.materials[i],g(t.materials[i],r.materials[i]);else g(t,r);e.material=t,e.onBeforeRender=T}}function v(e){return d(e,Le,p)}function p(e){var r=THREE.ShaderDeferred.color,t=new THREE.ShaderMaterial({uniforms:Object.assign({},r.uniforms),fragmentShader:r.fragmentShader,vertexShader:r.vertexShader,blending:THREE.NoBlending});return void 0!==e.map&&(t.map=e.map),t}function g(e,r){void 0!==r.map&&(e.map=r.map),void 0!==r.skinning&&(e.skinning=r.skinning),void 0!==r.morphTargets&&(e.morphTargets=r.morphTargets),r.visible===!0?e.visible=!r.transparent:e.visible=!1}function T(e,r,t,i,n,a){var o,s,l=Oe[n.uuid],d=n.uniforms;l.isMeshBasicMaterial===!0?s=l.color:(o=l.color,s=l.emissive);var u=l.specular,h=l.shininess,m=l.map;void 0!==o&&d.diffuse.value.copy(o),void 0!==s&&d.emissive.value.copy(s),void 0!==u&&d.specular.value.copy(u),void 0!==h&&void 0!==d.shininess&&(d.shininess.value=h),void 0!==m&&(d.map.value=m)}function R(e){if(void 0!==e.material){var r=Oe[e.uuid];if(r.transparent===!0)return e.material=r,void(e.onBeforeRender=Ge[e.uuid]);var t=S(r);if(Oe[t.uuid]=r,r.isMultiMaterial===!0)for(var i=0,n=r.materials.length;i<n;i++)Oe[t.materials[i].uuid]=r.materials[i],C(t.materials[i],r.materials[i]);else C(t,r);e.material=t,e.onBeforeRender=x}}function S(e){return d(e,Ae,H)}function H(e){var r=THREE.ShaderDeferred.reconstruction,t=new THREE.ShaderMaterial({uniforms:Object.assign({},r.uniforms),fragmentShader:r.fragmentShader,vertexShader:r.vertexShader,blending:THREE.NoBlending});return void 0!==e.map&&(t.map=e.map),t}function C(e,r){g(e,r)}function x(e,r,t,i,n,a){T(e,r,t,i,n,a),n.uniforms.samplerLight.value=ve.renderTarget2.texture}function D(e){if(void 0!==e.material){var r=Oe[e.uuid];if(r.isMultiMaterial===!0){for(var t=k(r),i=0,n=r.materials.length;i<n;i++)t.materials[i]=P(r.materials[i]);e.material=t}else e.material=P(r);e.onBeforeRender=Ge[e.uuid]}}function k(e){return d(e,ze,w)}function w(e){return Me}function P(e){return e.transparent===!0&&e.visible===!0?e:Me}function _(){var e=THREE.ShaderDeferred.emissiveLight,r=new THREE.ShaderMaterial({uniforms:Object.assign({},e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:THREE.NoBlending,depthWrite:!1}),t=new THREE.PlaneBufferGeometry(2,2),i=new THREE.Mesh(t,r);return i.onBeforeRender=function(e,r,t,i,n,a){n.uniforms.samplerColor.value=de.renderTarget2.texture},i}function y(e){return e.isPointLight?U(e):e.isSpotLight?B(e):e.isDirectionalLight?O(e):null}function b(e){return e.isPointLight?L():e.isSpotLight?W():e.isDirectionalLight?G():null}function M(e){var r=ye?Ie:We,t=r[e.uuid];return void 0===t&&(t=$(),t.material=b(e.userData.originalLight),r[e.uuid]=t),t.material}function F(e){var r=e.userData.originalLight;r.isPointLight&&A(e)}function V(e,r){var t=new THREE.Mesh(r,Me);return t.userData.originalLight=e,t}function N(e){var r=new THREE.ShaderMaterial({uniforms:Object.assign({},e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,transparent:!0,blending:THREE.AdditiveBlending,depthWrite:!1});return ye&&(r.premultipliedAlpha=!0),r}function j(e){ye?e.samplerNormalDepthShininess.value=ce.renderTarget2.texture:(e.samplerNormalDepth.value=ce.renderTarget2.texture,e.samplerColor.value=de.renderTarget2.texture)}function U(e){var r=V(e,new THREE.SphereGeometry(1,16,8));return r.onBeforeRender=z,r}function L(){var e=ye?THREE.ShaderDeferred.pointLightPre:THREE.ShaderDeferred.pointLight,r=N(e);return r.side=THREE.BackSide,r.depthFunc=THREE.GreaterEqualDepth,r}function A(e){var r=e.userData.originalLight,t=r.distance;t>0&&(e.scale.set(1,1,1).multiplyScalar(t),e.position.setFromMatrixPosition(r.matrixWorld))}function z(e,r,t,i,n,a){var o=this,s=o.userData.originalLight,l=s.distance,d=n.uniforms;d.lightColor.value.copy(s.color),l>0?(d.lightRadius.value=l,d.lightIntensity.value=s.intensity,d.lightPositionVS.value.setFromMatrixPosition(s.matrixWorld).applyMatrix4(xe.matrixWorldInverse)):d.lightRadius.value=1/0,j(d)}function B(e){var r=V(e,new THREE.PlaneBufferGeometry(2,2));return r.onBeforeRender=I,r}function W(){var e=ye?THREE.ShaderDeferred.spotLightPre:THREE.ShaderDeferred.spotLight,r=N(e);return r.depthTest=!1,r}function I(e,r,t,i,n,a){var o=this,s=o.userData.originalLight,l=o.material.uniforms;l.lightAngle.value=s.angle,l.lightColor.value.copy(s.color),l.lightIntensity.value=s.intensity,l.lightPositionVS.value.setFromMatrixPosition(s.matrixWorld).applyMatrix4(xe.matrixWorldInverse);var d=l.lightDirectionVS.value,u=Fe;d.setFromMatrixPosition(s.matrixWorld),u.setFromMatrixPosition(s.target.matrixWorld),d.sub(u).normalize().transformDirection(xe.matrixWorldInverse),j(l)}function O(e){var r=V(e,new THREE.PlaneBufferGeometry(2,2));return r.onBeforeRender=X,r}function G(){var e=ye?THREE.ShaderDeferred.directionalLightPre:THREE.ShaderDeferred.directionalLight,r=N(e);return r.depthTest=!1,r}function X(e,r,t,i,n,a){var o=this,s=o.userData.originalLight,l=o.material.uniforms;l.lightColor.value.copy(s.color),l.lightIntensity.value=s.intensity;var d=l.lightDirectionVS.value,u=Fe;d.setFromMatrixPosition(s.matrixWorld),u.setFromMatrixPosition(s.target.matrixWorld),d.sub(u).normalize().transformDirection(xe.matrixWorldInverse),j(l)}function K(e){if(void 0!==e.material&&(Oe[e.uuid]=e.material,Ge[e.uuid]=e.onBeforeRender,!_e&&!ye))if(e.material.isMultiMaterial===!0){for(var r=0,t=e.material.materials.length;r<t;r++)if(e.material.materials[r].transparent===!0){_e=!0;break}}else e.material.transparent===!0&&(_e=!0)}function q(e){void 0!==e.material&&(e.material=Oe[e.uuid],e.onBeforeRender=Ge[e.uuid])}function Q(e){if(e.isLight===!0){var r=Be[e.uuid];void 0===r&&(r=$(),r.light=y(e),Be[e.uuid]=r);var t=r.light;if(null!==t){var i=e.isPointLight===!0?De:ke,n=i.userData.lights;void 0===n[t.uuid]&&(i.add(t),n[t.uuid]={light:t,found:!0}),n[t.uuid].found=!0}}}function Y(e){for(var r=e.userData.lights,t=Object.keys(r),i=0,n=t.length;i<n;i++){var a=t[i];if(r[a].found===!1)e.remove(r[a].light),delete r[a];else{var o=r[a].light;o.material=M(o),F(o),r[a].found=!1}}}function J(e){var r=THREE.ShaderDeferredCommon.commonUniforms;r.viewWidth.value=se,r.viewHeight.value=le,r.matProjInverse.value.getInverse(e.projectionMatrix)}function Z(){ye?(he.renderToScreen=!1,he.enabled=!1,me.renderToScreen=!1,me.enabled=!1,Pe?(Se.renderToScreen=!1,He.renderToScreen=!0,He.enabled=!0):(Se.renderToScreen=!0,He.renderToScreen=!1,He.enabled=!1)):_e?Pe?(Se.renderToScreen=!1,he.renderToScreen=!1,he.enabled=!0,me.renderToScreen=!1,me.enabled=!1,He.renderToScreen=!0,He.enabled=!0):(Se.renderToScreen=!1,he.renderToScreen=!1,he.enabled=!0,me.renderToScreen=!0,me.enabled=!0,He.renderToScreen=!1,He.enabled=!1):Pe?(Se.renderToScreen=!1,he.renderToScreen=!1,he.enabled=!1,me.renderToScreen=!1,me.enabled=!1,He.renderToScreen=!0,He.enabled=!0):(Se.renderToScreen=!0,he.renderToScreen=!1,he.enabled=!1,me.renderToScreen=!1,me.enabled=!1,He.renderToScreen=!1,He.enabled=!1)}function $(){return{used:!0,keepAlive:be,count:0}}function ee(e,r){e.traverse(u),ge.scene=e,ge.camera=r,we.renderer.autoClearDepth=!0,we.renderer.autoClearStencil=!0,oe.enable(oe.STENCIL_TEST),oe.stencilFunc(oe.ALWAYS,1,4294967295),oe.stencilOp(oe.REPLACE,oe.REPLACE,oe.REPLACE),ce.render()}function re(e,r){e.traverse(c),ue.scene=e,ue.camera=r,we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,oe.stencilFunc(oe.EQUAL,1,4294967295),oe.stencilOp(oe.KEEP,oe.KEEP,oe.KEEP),de.render()}function te(e,r){e.traverse(Q),Y(De),Y(ke),Te.scene=De,Te.camera=r,Re.scene=ke,we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,ve.render(),oe.disable(oe.STENCIL_TEST)}function ie(e,r){e.traverse(Q),Y(De),Y(ke),Te.scene=De,Te.camera=r,Re.scene=ke,we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,oe.stencilFunc(oe.EQUAL,1,4294967295),oe.stencilOp(oe.KEEP,oe.KEEP,oe.KEEP),ve.render()}function ne(e,r){e.traverse(R),Ee.scene=e,Ee.camera=r,we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,fe.render(),oe.disable(oe.STENCIL_TEST)}function ae(e,r){!ye&&_e&&(e.traverse(D),he.scene=e,he.camera=r),Z(),we.renderer.autoClearDepth=!1,we.renderer.autoClearStencil=!1,pe.render()}e=e||{};var oe,se,le,de,ue,he,me,fe,Ee,ce,ve,pe,ge,Te,Re,Se,He,Ce,xe,De,ke,we=this,Pe=!1,_e=!1,ye=!1,be=!1,Me=new THREE.ShaderMaterial({visible:!1}),Fe=new THREE.Vector3,Ve={},Ne={},je={},Ue={},Le={},Ae={},ze={},Be={},We={},Ie={},Oe={},Ge={};this.renderer=void 0,this.domElement=void 0,this.forwardRendering=!1,this.setSize=function(e,r){se=e,le=r,this.renderer.setSize(se,le),ce.setSize(se,le),de.setSize(se,le),ve.setSize(se,le),fe.setSize(se,le),pe.setSize(se,le),Ce.image.width=se,Ce.image.height=le,Ce.needsUpdate=!0,He.uniforms.resolution.value.set(1/se,1/le)},this.setAntialias=function(e){Pe=e},this.enableLightPrePass=function(e){ye=e,Se.uniforms.samplerResult.value=ye?fe.renderTarget2.texture:ve.renderTarget2.texture},this.render=function(e,r){if(this.forwardRendering)return void this.renderer.render(e,r);var t=e.autoUpdate,i=this.renderer.autoClearColor,n=this.renderer.autoClearDepth,a=this.renderer.autoClearStencil;xe=r,l(e),e.autoUpdate=!1,e.updateMatrixWorld(),_e=!1,e.traverse(K),J(r),ee(e,r),ye?(ie(e,r),ne(e,r)):(re(e,r),te(e,r)),ae(e,r),e.traverse(q),e.autoUpdate=t,this.renderer.autoClearColor=i,this.renderer.autoClearDepth=n,this.renderer.autoClearStencil=a},r(e)},THREE.DeferredShaderChunk={packVector3:["float vec3_to_float( vec3 data ) {","\tconst float unit = 255.0/256.0;","\thighp float compressed = fract( data.x * unit ) + floor( data.y * unit * 255.0 ) + floor( data.z * unit * 255.0 ) * 255.0;","\treturn compressed;","}"].join("\n"),unpackFloat:["vec3 float_to_vec3( float data ) {","\tconst float unit = 255.0;","\tvec3 uncompressed;","\tuncompressed.x = fract( data );","\tfloat zInt = floor( data / unit );","\tuncompressed.z = fract( zInt / unit );","\tuncompressed.y = fract( floor( data - ( zInt * unit ) ) / unit );","\treturn uncompressed;","}"].join("\n"),packNormal:["vec2 normal_to_vec2( vec3 normal ) {","\treturn normal.xy / sqrt( normal.z * 8.0 + 8.0 ) + 0.5;","}"].join("\n"),unpackVector2:["vec3 vec2_to_normal( vec2 data ) {","\tvec2 fenc = data * 4.0 - 2.0;","\tfloat f = dot( fenc, fenc );","\tfloat g = sqrt( 1.0 - f / 4.0 );","\tvec3 normal;","\tnormal.xy = fenc * g;","\tnormal.z = 1.0 - f / 2.0;","\treturn normal;","}"].join("\n"),computeTextureCoord:["vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );"].join("\n"),packNormalDepth:["vec4 packedNormalDepth;","packedNormalDepth.xyz = normal * 0.5 + 0.5;","packedNormalDepth.w = position.z / position.w;"].join("\n"),unpackNormalDepth:["vec4 normalDepthMap = texture2D( samplerNormalDepth, texCoord );","float depth = normalDepthMap.w;","if ( depth == 0.0 ) discard;","vec3 normal = normalDepthMap.xyz * 2.0 - 1.0;"].join("\n"),packNormalDepthShininess:["vec4 packedNormalDepthShininess;","packedNormalDepthShininess.xy = normal_to_vec2( normal );","packedNormalDepthShininess.z = shininess;","packedNormalDepthShininess.w = position.z / position.w;"].join("\n"),unpackNormalDepthShininess:["vec4 normalDepthMap = texture2D( samplerNormalDepthShininess, texCoord );","float depth = normalDepthMap.w;","if ( depth == 0.0 ) discard;","vec3 normal = vec2_to_normal( normalDepthMap.xy );","float shininess = normalDepthMap.z;"].join("\n"),packColor:["vec4 packedColor;","packedColor.x = vec3_to_float( diffuseColor.rgb );","packedColor.y = vec3_to_float( emissiveColor );","packedColor.z = vec3_to_float( specularColor );","packedColor.w = shininess;"].join("\n"),unpackColor:["vec4 colorMap = texture2D( samplerColor, texCoord );","vec3 diffuseColor = float_to_vec3( colorMap.x );","vec3 emissiveColor = float_to_vec3( colorMap.y );","vec3 specularColor = float_to_vec3( colorMap.z );","float shininess = colorMap.w;"].join("\n"),packLight:["vec4 packedLight;","packedLight.xyz = lightIntensity * lightColor * max( dot( lightVector, normal ), 0.0 ) * attenuation;","packedLight.w = lightIntensity * specular * max( dot( lightVector, normal ), 0.0 ) * attenuation;"].join("\n"),computeVertexPositionVS:["vec2 xy = texCoord * 2.0 - 1.0;","vec4 vertexPositionProjected = vec4( xy, depth, 1.0 );","vec4 vertexPositionVS = matProjInverse * vertexPositionProjected;","vertexPositionVS.xyz /= vertexPositionVS.w;","vertexPositionVS.w = 1.0;"].join("\n"),computeSpecular:["vec3 halfVector = normalize( lightVector - normalize( vertexPositionVS.xyz ) );","float dotNormalHalf = max( dot( normal, halfVector ), 0.0 );","float specular = 0.31830988618 * ( shininess * 0.5 + 1.0 ) * pow( dotNormalHalf, shininess );"].join("\n"),combine:["gl_FragColor = vec4( lightIntensity * lightColor * max( dot( lightVector, normal ), 0.0 ) * ( diffuseColor + specular * specularColor ) * attenuation, 1.0 );"].join("\n")},THREE.ShaderDeferredCommon={commonUniforms:{matProjInverse:new THREE.Uniform(new THREE.Matrix4),viewWidth:new THREE.Uniform(800),viewHeight:new THREE.Uniform(600)}},THREE.ShaderDeferred={normalDepth:{uniforms:{},vertexShader:["varying vec3 vNormal;","varying vec4 vPosition;",THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,"\tvNormal = normalize( normalMatrix * objectNormal );","\tvPosition = gl_Position;","}"].join("\n"),fragmentShader:["varying vec3 vNormal;","varying vec4 vPosition;","void main() {","\tvec3 normal = vNormal;","\tvec4 position = vPosition;",THREE.DeferredShaderChunk.packNormalDepth,"\tgl_FragColor = packedNormalDepth;","}"].join("\n")},color:{uniforms:{map:new THREE.Uniform(null),offsetRepeat:new THREE.Uniform(new THREE.Vector4(0,0,1,1)),diffuse:new THREE.Uniform(new THREE.Color(0)),emissive:new THREE.Uniform(new THREE.Color(0)),specular:new THREE.Uniform(new THREE.Color(0)),shininess:new THREE.Uniform(30)},vertexShader:[THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;",THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.DeferredShaderChunk.packVector3,"void main() {","\tvec4 diffuseColor = vec4( diffuse, 1.0 );","\tvec3 emissiveColor = emissive;","\tvec3 specularColor = specular;",THREE.ShaderChunk.map_fragment,THREE.DeferredShaderChunk.packColor,"\tgl_FragColor = packedColor;","}"].join("\n")},emissiveLight:{uniforms:Object.assign({samplerColor:new THREE.Uniform(null)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;",THREE.DeferredShaderChunk.unpackFloat,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackColor,"\tgl_FragColor = vec4( emissiveColor, 1.0 );","}"].join("\n")},pointLight:{uniforms:Object.assign({samplerNormalDepth:new THREE.Uniform(null),samplerColor:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightPositionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightIntensity:new THREE.Uniform(1),lightRadius:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform float lightIntensity;","uniform float lightRadius;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepth,THREE.DeferredShaderChunk.computeVertexPositionVS,"\tvec3 lightVector = lightPositionVS - vertexPositionVS.xyz;","\tfloat distance = length( lightVector );","\tif ( distance > lightRadius ) discard;","\tlightVector = normalize( lightVector );",THREE.DeferredShaderChunk.unpackColor,THREE.DeferredShaderChunk.computeSpecular,"\t//float cutoff = 0.3;","\t//float denom = distance / lightRadius + 1.0;","\t//float attenuation = 1.0 / ( denom * denom );","\t//attenuation = ( attenuation - cutoff ) / ( 1.0 - cutoff );","\t//attenuation = max( attenuation, 0.0 );","\t//attenuation *= attenuation;","\t//diffuseColor *= saturate( -distance / lightRadius + 1.0 );","\t//float attenuation = 1.0;","\tfloat attenuation = saturate( -distance / lightRadius + 1.0 );",THREE.DeferredShaderChunk.combine,"}"].join("\n")},spotLight:{uniforms:Object.assign({samplerNormalDepth:new THREE.Uniform(null),samplerColor:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightDirectionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightPositionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightAngle:new THREE.Uniform(1),lightIntensity:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform vec3 lightDirectionVS;","uniform float lightAngle;","uniform float lightIntensity;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepth,THREE.DeferredShaderChunk.computeVertexPositionVS,THREE.DeferredShaderChunk.unpackColor,"\tvec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );","\tfloat rho = dot( lightDirectionVS, lightVector );","\tfloat rhoMax = cos( lightAngle );","\tif ( rho <= rhoMax ) discard;","\tfloat theta = rhoMax + 0.0001;","\tfloat phi = rhoMax + 0.05;","\tfloat falloff = 4.0;","\tfloat spot = 0.0;","\tif ( rho >= phi ) {","\t\tspot = 1.0;","\t} else if ( rho <= theta ) {","\t\tspot = 0.0;","\t} else { ","\t\tspot = pow( ( rho - theta ) / ( phi - theta ), falloff );","\t}","\tdiffuseColor *= spot;",THREE.DeferredShaderChunk.computeSpecular,"\tconst float attenuation = 1.0;",THREE.DeferredShaderChunk.combine,"}"].join("\n")},directionalLight:{uniforms:Object.assign({samplerNormalDepth:new THREE.Uniform(null),samplerColor:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightDirectionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightIntensity:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepth;","uniform sampler2D samplerColor;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightDirectionVS;","uniform float lightIntensity;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepth,THREE.DeferredShaderChunk.computeVertexPositionVS,THREE.DeferredShaderChunk.unpackColor,"\tvec3 lightVector = normalize( lightDirectionVS );",THREE.DeferredShaderChunk.computeSpecular,"\tconst float attenuation = 1.0;",THREE.DeferredShaderChunk.combine,"}"].join("\n")},normalDepthShininess:{uniforms:{shininess:new THREE.Uniform(30)},vertexShader:["varying vec3 vNormal;","varying vec4 vPosition;",THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,"\tvNormal = normalize( normalMatrix * objectNormal );","\tvPosition = gl_Position;","}"].join("\n"),fragmentShader:["varying vec3 vNormal;","varying vec4 vPosition;","uniform float shininess;",THREE.DeferredShaderChunk.packNormal,"void main() {","\tvec3 normal = vNormal;","\tvec4 position = vPosition;",THREE.DeferredShaderChunk.packNormalDepthShininess,"\tgl_FragColor = packedNormalDepthShininess;","}"].join("\n")},pointLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightPositionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightIntensity:new THREE.Uniform(1),lightRadius:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform float lightIntensity;","uniform float lightRadius;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,THREE.DeferredShaderChunk.unpackVector2,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepthShininess,THREE.DeferredShaderChunk.computeVertexPositionVS,"\tvec3 lightVector = lightPositionVS - vertexPositionVS.xyz;","\tfloat distance = length( lightVector );","\tif ( distance > lightRadius ) discard;","\tlightVector = normalize( lightVector );",THREE.DeferredShaderChunk.computeSpecular,"\tfloat attenuation = saturate( -distance / lightRadius + 1.0 );",THREE.DeferredShaderChunk.packLight,"\tgl_FragColor = packedLight;","}"].join("\n")},spotLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightDirectionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightPositionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightAngle:new THREE.Uniform(1),lightIntensity:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightPositionVS;","uniform vec3 lightDirectionVS;","uniform float lightAngle;","uniform float lightIntensity;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,THREE.DeferredShaderChunk.unpackVector2,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepthShininess,THREE.DeferredShaderChunk.computeVertexPositionVS,"\tvec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );","\tfloat rho = dot( lightDirectionVS, lightVector );","\tfloat rhoMax = cos( lightAngle );","\tif ( rho <= rhoMax ) discard;","\tfloat theta = rhoMax + 0.0001;","\tfloat phi = rhoMax + 0.05;","\tfloat falloff = 4.0;","\tfloat spot = 0.0;","\tif ( rho >= phi ) {","\t\tspot = 1.0;","\t} else if ( rho <= theta ) {","\t\tspot = 0.0;","\t} else { ","\t\tspot = pow( ( rho - theta ) / ( phi - theta ), falloff );","\t}",THREE.DeferredShaderChunk.computeSpecular,"\tconst float attenuation = 1.0;",THREE.DeferredShaderChunk.packLight,"\tgl_FragColor = spot * packedLight;","}"].join("\n") | ||
},directionalLightPre:{uniforms:Object.assign({samplerNormalDepthShininess:new THREE.Uniform(null),lightColor:new THREE.Uniform(new THREE.Color(0)),lightDirectionVS:new THREE.Uniform(new THREE.Vector3(0,1,0)),lightIntensity:new THREE.Uniform(1)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:["void main() { ","\tgl_Position = vec4( sign( position.xy ), 0.0, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D samplerNormalDepthShininess;","uniform float viewHeight;","uniform float viewWidth;","uniform vec3 lightColor;","uniform vec3 lightDirectionVS;","uniform float lightIntensity;","uniform mat4 matProjInverse;",THREE.DeferredShaderChunk.unpackFloat,THREE.DeferredShaderChunk.unpackVector2,"void main() {",THREE.DeferredShaderChunk.computeTextureCoord,THREE.DeferredShaderChunk.unpackNormalDepthShininess,THREE.DeferredShaderChunk.computeVertexPositionVS,"\tvec3 lightVector = normalize( lightDirectionVS );",THREE.DeferredShaderChunk.computeSpecular,"\tconst float attenuation = 1.0;",THREE.DeferredShaderChunk.packLight,"\tgl_FragColor = packedLight;","}"].join("\n")},reconstruction:{uniforms:Object.assign({samplerLight:new THREE.Uniform(null),map:new THREE.Uniform(null),offsetRepeat:new THREE.Uniform(new THREE.Vector4(0,0,1,1)),diffuse:new THREE.Uniform(new THREE.Color(0)),emissive:new THREE.Uniform(new THREE.Color(0)),specular:new THREE.Uniform(new THREE.Color(0)),shininess:new THREE.Uniform(30)},THREE.ShaderDeferredCommon.commonUniforms),vertexShader:[THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,"}"].join("\n"),fragmentShader:["uniform sampler2D samplerLight;","uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;","uniform float viewHeight;","uniform float viewWidth;",THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.DeferredShaderChunk.unpackFloat,"void main() {","\tvec4 diffuseColor = vec4( diffuse, 1.0 );","\tvec3 emissiveColor = emissive;","\tvec3 specularColor = specular;",THREE.DeferredShaderChunk.computeTextureCoord,"\tvec4 light = texture2D( samplerLight, texCoord );",THREE.ShaderChunk.map_fragment,"\tvec3 diffuseFinal = diffuseColor.rgb * light.rgb;","\tvec3 emissiveFinal = emissiveColor;","\tvec3 specularFinal = specularColor * light.rgb * light.a;","\tgl_FragColor = vec4( diffuseFinal + emissiveFinal + specularFinal, 1.0 );","}"].join("\n")},final:{uniforms:{samplerResult:new THREE.Uniform(null)},vertexShader:["varying vec2 texCoord;","void main() {","\tvec4 pos = vec4( sign( position.xy ), 0.0, 1.0 );","\ttexCoord = pos.xy * vec2( 0.5 ) + 0.5;","\tgl_Position = pos;","}"].join("\n"),fragmentShader:["varying vec2 texCoord;","uniform sampler2D samplerResult;","void main() {","\tgl_FragColor = texture2D( samplerResult, texCoord );","}"].join("\n")}}},function(e,r){THREE.CopyShader={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","gl_FragColor = opacity * texel;","}"].join("\n")}},function(e,r){THREE.FXAAShader={uniforms:{tDiffuse:{value:null},resolution:{value:new THREE.Vector2(1/1024,1/512)}},vertexShader:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","#define FXAA_REDUCE_MIN (1.0/128.0)","#define FXAA_REDUCE_MUL (1.0/8.0)","#define FXAA_SPAN_MAX 8.0","void main() {","vec3 rgbNW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbNE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbSW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ).xyz;","vec3 rgbSE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ).xyz;","vec4 rgbaM = texture2D( tDiffuse, gl_FragCoord.xy * resolution );","vec3 rgbM = rgbaM.xyz;","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float lumaNW = dot( rgbNW, luma );","float lumaNE = dot( rgbNE, luma );","float lumaSW = dot( rgbSW, luma );","float lumaSE = dot( rgbSE, luma );","float lumaM = dot( rgbM, luma );","float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );","float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );","vec2 dir;","dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));","dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));","float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );","float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );","dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),","max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),","dir * rcpDirMin)) * resolution;","vec4 rgbA = (1.0/2.0) * (","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (1.0/3.0 - 0.5)) +","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (2.0/3.0 - 0.5)));","vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (0.0/3.0 - 0.5)) +","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (3.0/3.0 - 0.5)));","float lumaB = dot(rgbB, vec4(luma, 0.0));","if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) ) {","gl_FragColor = rgbA;","} else {","gl_FragColor = rgbB;","}","}"].join("\n")}}]); |
14
index.js
@@ -27,2 +27,11 @@ /** | ||
update: function () { | ||
this.setupDeferredRenderer(); | ||
}, | ||
play: function () { | ||
// just in case | ||
this.setupDeferredRenderer(); | ||
}, | ||
setupDeferredRenderer: function () { | ||
if (this.renderer !== null) { return; } | ||
@@ -57,8 +66,3 @@ | ||
sceneEl.effect = new THREE.VREffect(this.renderer); | ||
}, | ||
play: function () { | ||
// just in case | ||
this.update(); | ||
} | ||
}); |
{ | ||
"name": "aframe-deferred-renderer", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A-Frame Deferred Renderer component", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,6 +20,6 @@ # A-Frame Deferred Renderer component | ||
``` | ||
```html | ||
<head> | ||
<script src="./libs/aframe.min.js"></script> | ||
<script src="./build/aframe-deferred-renderer.min.js"></script> | ||
<script src="https://cdn.rawgit.com/aframevr/aframe/v0.4.0/dist/aframe-master.min.js"></script> | ||
<script src="https://rawgit.com/takahirox/aframe-deferred-renderer/master/build/aframe-deferred-renderer.min.js"></script> | ||
</head> | ||
@@ -26,0 +26,0 @@ |
Sorry, the diff of this file is too big to display
510438
2106