!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.v3d=e.v3d||{})}(this,function(e){"use strict";function t(){}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:0>8&255]+i[e>>16&255]+i[e>>24&255]+"-"+i[255&t]+i[t>>8&255]+"-"+i[t>>16&15|64]+i[t>>24&255]+"-"+i[63&n|128]+i[n>>8&255]+"-"+i[n>>16&255]+i[n>>24&255]+i[255&r]+i[r>>8&255]+i[r>>16&255]+i[r>>24&255]).toUpperCase()}}(),clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:n<=e?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:n<=e?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*Nt.DEG2RAD},radToDeg:function(e){return e*Nt.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},hashString:function(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return t>>>0},expAverage:function(e,t,n,r){var i=Math.exp(-n/r);return e*i+(1-i)*t},angleToRange_0_2Pi:function(e){return this.clamp(e-2*Math.PI*Math.floor(e/(2*Math.PI)),0,2*Math.PI)},clampAngle:function(e,t,n){var r=this.angleToRange_0_2Pi(e-t),i=this.angleToRange_0_2Pi(n-t);return iNumber.EPSILON){var x=Math.sqrt(y),_=Math.atan2(x,v*g);m=Math.sin(m*_)/x,o=Math.sin(o*_)/x}var b=o*g;if(s=s*m+h*b,l=l*m+d*b,c=c*m+p*b,u=u*m+f*b,m===1-o){var w=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=w,l*=w,c*=w,u*=w}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}}),Object.defineProperties(Ut.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(Ut.prototype,{isQuaternion:!0,set:function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("v3d.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=e._x,r=e._y,i=e._z,a=e.order,o=Math.cos,s=Math.sin,l=o(n/2),c=o(r/2),u=o(i/2),h=s(n/2),d=s(r/2),p=s(i/2);return"XYZ"===a?(this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p):"YXZ"===a?(this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p):"ZXY"===a?(this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p):"ZYX"===a?(this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p):"YZX"===a?(this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p):"XZY"===a&&(this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],s=n[5],l=n[9],c=n[2],u=n[6],h=n[10],d=r+s+h;return this._z=0Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x),n),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(Nt.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var n=this.angleTo(e);if(0===n)return this;var r=Math.min(1,t/n);return this.slerp(e,r),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return this._w=0===e?(this._x=0,this._y=0,this._z=0,1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("v3d.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions(a, b) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+a*o+r*l-i*s,this._y=r*c+a*s+i*o-n*l,this._z=i*c+a*l+n*s-r*o,this._w=a*c-n*o-r*s-i*l,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),1<=o)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var l=1-t;return this._w=l*a+t*this._w,this._x=l*n+t*this._x,this._y=l*r+t*this._y,this._z=l*i+t*this._z,this.normalize()}var c=Math.sqrt(s),u=Math.atan2(c,o),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=i*h+this._z*d,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(Bt.prototype,{isVector3:!0,set:function(e,t,n){return this.x=e,this.y=t,this.z=n,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("v3d.Vector3: .add() now only accepts one argument. Use .addVectors(a, b) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("v3d.Vector3: .sub() now only accepts one argument. Use .subVectors(a, b) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("v3d.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors(a, b) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:(c=new Ut,function(e){return e&&e.isEuler||console.error("v3d.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(c.setFromEuler(e))}),applyAxisAngle:(l=new Ut,function(e,t){return this.applyQuaternion(l.setFromAxisAngle(e,t))}),applyMatrix3:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this},applyMatrix4:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this},applyQuaternion:function(e){var t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,l=s*t+a*r-o*n,c=s*n+o*t-i*r,u=s*r+i*n-a*t,h=-i*t-a*n-o*r;return this.x=l*s+h*-i+c*-o-u*-a,this.y=c*s+h*-a+u*-i-l*-o,this.z=u*s+h*-o+l*-a-c*-i,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)},transformDirection:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:(o=new Bt,s=new Bt,function(e,t){return o.set(e,e,e),s.set(t,t,t),this.clamp(o,s)}),clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},cross:function(e,t){return void 0!==t?(console.warn("v3d.Vector3: .cross() now only accepts one argument. Use .crossVectors(a, b) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:(a=new Bt,function(e){return a.copy(this).projectOnVector(e),this.sub(a)}),reflect:(i=new Bt,function(e){return this.sub(i.copy(e).multiplyScalar(2*this.dot(e)))}),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(Nt.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,n){var r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("v3d.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}}),Object.assign(zt.prototype,{isMatrix3:!0,set:function(e,t,n,r,i,a,o,s,l){var c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=t,c[4]=i,c[5]=s,c[6]=n,c[7]=a,c[8]=l,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:(u=new Bt,function(e){for(var t=0,n=e.count;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn("v3d.Box3: .getParameter() target is now required"),t=new Bt),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:(Xt=new Bt,function(e){return this.clampPoint(e.center,Xt),Xt.distanceToSquared(e.center)<=e.radius*e.radius}),intersectsPlane:function(e){var t,n;return n=0=-e.constant},intersectsTriangle:function(){var s=new Bt,l=new Bt,c=new Bt,n=new Bt,r=new Bt,i=new Bt,u=new Bt,a=new Bt,h=new Bt,o=new Bt;function d(e){var t,n;for(t=0,n=e.length-3;t<=n;t+=3){u.fromArray(e,t);var r=h.x*Math.abs(u.x)+h.y*Math.abs(u.y)+h.z*Math.abs(u.z),i=s.dot(u),a=l.dot(u),o=c.dot(u);if(Math.max(-Math.max(i,a,o),Math.min(i,a,o))>r)return!1}return!0}return function(e){if(this.isEmpty())return!1;this.getCenter(a),h.subVectors(this.max,a),s.subVectors(e.a,a),l.subVectors(e.b,a),c.subVectors(e.c,a),n.subVectors(l,s),r.subVectors(c,l),i.subVectors(s,c);var t=[0,-n.z,n.y,0,-r.z,r.y,0,-i.z,i.y,n.z,0,-n.x,r.z,0,-r.x,i.z,0,-i.x,-n.y,n.x,0,-r.y,r.x,0,-i.y,i.x,0];return!!d(t)&&(!!d(t=[1,0,0,0,1,0,0,0,1])&&(o.crossVectors(n,r),d(t=[o.x,o.y,o.z])))}}(),clampPoint:function(e,t){return void 0===t&&(console.warn("v3d.Box3: .clampPoint() target is now required"),t=new Bt),t.copy(e).clamp(this.min,this.max)},distanceToPoint:(Wt=new Bt,function(e){return Wt.copy(e).clamp(this.min,this.max).sub(e).length()}),getBoundingSphere:(jt=new Bt,function(e){return void 0===e&&console.error("v3d.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(jt).length(),e}),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:(Vt=[new Bt,new Bt,new Bt,new Bt,new Bt,new Bt,new Bt,new Bt],function(e){return this.isEmpty()||(Vt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Vt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Vt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Vt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Vt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Vt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Vt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Vt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Vt)),this}),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(bn.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:(Yt=new _n,function(e,t){var n=this.center;void 0!==t?n.copy(t):Yt.setFromPoints(e).getCenter(n);for(var r=0,i=0,a=e.length;ithis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("v3d.Sphere: .getBoundingBox() target is now required"),e=new _n),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.assign(wn.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:(Kt=new Bt,Jt=new Bt,function(e,t,n){var r=Kt.subVectors(n,t).cross(Jt.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("v3d.Plane: .projectPoint() target is now required"),t=new Bt),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:(Zt=new Bt,function(e,t){void 0===t&&(console.warn("v3d.Plane: .intersectLine() target is now required"),t=new Bt);var n=e.delta(Zt),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):void 0;var i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||1 0.0) {\n distanceFalloff *= pow2(saturate(1.0 - pow4(lightDistance / cutoffDistance)));\n }\n return distanceFalloff;\n#elif defined(BLENDER_LIGHTS)\n return cutoffDistance / (cutoffDistance + pow2(lightDistance));\n#else\n if(cutoffDistance > 0.0) {\n return pow(saturate(-lightDistance / cutoffDistance + 1.0), decayExponent);\n }\n return 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert(const in vec3 diffuseColor) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {\n float fresnel = exp2((-5.55473 * dotLH - 6.98316) * dotLH);\n return (1.0 - specularColor) * fresnel + specularColor;\n}\nfloat G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {\n float a2 = pow2(alpha);\n float gl = dotNL + sqrt(a2 + (1.0 - a2) * pow2(dotNL));\n float gv = dotNV + sqrt(a2 + (1.0 - a2) * pow2(dotNV));\n return 1.0 / (gl * gv);\n}\nfloat G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {\n float a2 = pow2(alpha);\n float gv = dotNL * sqrt(a2 + (1.0 - a2) * pow2(dotNV));\n float gl = dotNV * sqrt(a2 + (1.0 - a2) * pow2(dotNL));\n return 0.5 / max(gv + gl, EPSILON);\n}\nfloat D_GGX(const in float alpha, const in float dotNH) {\n float a2 = pow2(alpha);\n float denom = pow2(dotNH) * (a2 - 1.0) + 1.0;\n return RECIPROCAL_PI * a2 / pow2(denom);\n}\nvec3 BRDF_Specular_GGX(const in IncidentLight incidentLight, const in vec3 viewDir,\n const in vec3 normal, const in vec3 specularColor, const in float roughness) {\n float alpha = pow2(roughness);\n vec3 halfDir = normalize(incidentLight.direction + viewDir);\n float dotNL = saturate(dot(normal, incidentLight.direction));\n float dotNV = saturate(dot(normal, viewDir));\n float dotNH = saturate(dot(normal, halfDir));\n float dotLH = saturate(dot(incidentLight.direction, halfDir));\n vec3 F = F_Schlick(specularColor, dotLH);\n float G = G_GGX_SmithCorrelated(alpha, dotNL, dotNV);\n float D = D_GGX(alpha, dotNH);\n return F * (G * D);\n}\n#if NUM_RECT_AREA_LIGHTS > 0\nvec2 LTC_Uv(const in vec3 N, const in vec3 V, const in float roughness) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = (LUT_SIZE - 1.0) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate(dot(N, V));\n vec2 uv = vec2(roughness, sqrt(1.0 - dotNV));\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor(const in vec3 f) {\n float l = length(f);\n return max((l * l + f.z) / (l + 1.0), 0.0);\n}\nvec3 LTC_EdgeVectorFormFactor(const in vec3 v1, const in vec3 v2) {\n float x = dot(v1, v2);\n float y = abs(x);\n float a = 0.8543985 + (0.4965155 + 0.0145206 * y) * y;\n float b = 3.4175940 + (4.1616724 + y) * y;\n float v = a / b;\n float theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt(max(1.0 - x * x, 1e-7)) - v;\n return cross(v1, v2) * theta_sintheta;\n}\nvec3 LTC_Evaluate(const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[4]) {\n vec3 v1 = rectCoords[1] - rectCoords[0];\n vec3 v2 = rectCoords[3] - rectCoords[0];\n vec3 lightNormal = cross(v1, v2);\n if(dot(lightNormal, P - rectCoords[0]) < 0.0) return vec3(0.0);\n vec3 T1, T2;\n T1 = normalize(V - N * dot(V, N));\n T2 = - cross(N, T1);\n mat3 mat = mInv * transposeMat3(mat3(T1, T2, N));\n vec3 coords[4];\n coords[0] = mat * (rectCoords[0] - P);\n coords[1] = mat * (rectCoords[1] - P);\n coords[2] = mat * (rectCoords[2] - P);\n coords[3] = mat * (rectCoords[3] - P);\n coords[0] = normalize(coords[0]);\n coords[1] = normalize(coords[1]);\n coords[2] = normalize(coords[2]);\n coords[3] = normalize(coords[3]);\n vec3 vectorFormFactor = vec3(0.0);\n vectorFormFactor += LTC_EdgeVectorFormFactor(coords[0], coords[1]);\n vectorFormFactor += LTC_EdgeVectorFormFactor(coords[1], coords[2]);\n vectorFormFactor += LTC_EdgeVectorFormFactor(coords[2], coords[3]);\n vectorFormFactor += LTC_EdgeVectorFormFactor(coords[3], coords[0]);\n float result = LTC_ClippedSphereFormFactor(vectorFormFactor);\n return vec3(result);\n}\n#endif\nvec3 BRDF_Specular_GGX_Environment(const in GeometricContext geometry,\n const in vec3 specularColor, const in float roughness, const int useCoat) {\n vec3 normal = geometry.normal;\n if (useCoat == 1) {\n normal = geometry.coatNormal;\n }\n float dotNV = saturate(dot(normal, geometry.viewDir));\n const vec4 c0 = vec4(- 1, - 0.0275, - 0.572, 0.022);\n const vec4 c1 = vec4(1, 0.0425, 1.04, - 0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min(r.x * r.x, exp2(- 9.28 * dotNV)) * r.x + r.y;\n vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\n return specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit() {\n return 0.25;\n}\nfloat D_BlinnPhong(const in float shininess, const in float dotNH) {\n return RECIPROCAL_PI * (shininess * 0.5 + 1.0) * pow(dotNH, shininess);\n}\nvec3 BRDF_Specular_BlinnPhong(const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess) {\n vec3 halfDir = normalize(incidentLight.direction + geometry.viewDir);\n float dotNH = saturate(dot(geometry.normal, halfDir));\n float dotLH = saturate(dot(incidentLight.direction, halfDir));\n vec3 F = F_Schlick(specularColor, dotLH);\n float G = G_BlinnPhong_Implicit();\n float D = D_BlinnPhong(shininess, dotNH);\n return F * (G * D);\n}\nfloat GGXRoughnessToBlinnExponent(const in float ggxRoughness) {\n return (2.0 / pow2(ggxRoughness + 0.0001) - 2.0);\n}\nfloat BlinnExponentToGGXRoughness(const in float blinnExponent) {\n return sqrt(2.0 / (blinnExponent + 2.0));\n}",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx(vUv);\n vec2 dSTdy = dFdy(vUv);\n float Hll = bumpScale * texture2D(bumpMap, vUv).x;\n float dBx = bumpScale * texture2D(bumpMap, vUv + dSTdx).x - Hll;\n float dBy = bumpScale * texture2D(bumpMap, vUv + dSTdy).x - Hll;\n return vec2(dBx, dBy);\n }\n vec3 perturbNormalArb(vec3 surf_pos, vec3 surf_norm, vec2 dHdxy) {\n vec3 vSigmaX = vec3(dFdx(surf_pos.x), dFdx(surf_pos.y), dFdx(surf_pos.z));\n vec3 vSigmaY = vec3(dFdy(surf_pos.x), dFdy(surf_pos.y), dFdy(surf_pos.z));\n vec3 vN = surf_norm;\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n float fDet = dot(vSigmaX, R1);\n fDet *= (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\n return normalize(abs(fDet) * surf_norm - vGrad);\n }\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #pragma unroll_loop\n for (int i = 0; i < UNION_CLIPPING_PLANES; i++) {\n plane = clippingPlanes[i];\n if (dot(vViewPosition, plane.xyz) > plane.w) discard;\n }\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop\n for (int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i++) {\n plane = clippingPlanes[i];\n clipped = (dot(vViewPosition, plane.xyz) > plane.w) && clipped;\n }\n if (clipped) discard;\n #endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n #if !defined(PHYSICAL) && !defined(PHONG) && !defined(MATCAP)&& !defined(NODE)\n varying vec3 vViewPosition;\n #endif\n uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && !defined(PHYSICAL) && !defined(PHONG) && !defined(MATCAP) && !defined(NODE)\n varying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && !defined(PHYSICAL) && !defined(PHONG) && !defined(MATCAP) && !defined(NODE)\n vViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n diffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n varying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n varying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n vColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp(a, 0.0, 1.0)\n#define whiteCompliment(a) (1.0 - saturate(a))\n#define RECIPROCAL_3 0.333333333333\nfloat pow2(const in float x) { return x*x; }\nfloat pow3(const in float x) { return x*x*x; }\nfloat pow4(const in float x) { float x2 = x*x; return x2*x2; }\nfloat average(const in vec3 color) { return dot(color, vec3(0.3333)); }\nhighp float rand(const in vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, PI);\n return fract(sin(sn) * c);\n}\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n vec3 originalNormal;\n vec3 coatNormal;\n};\nvec3 transformDirection(in vec3 dir, in mat4 matrix) {\n return normalize((matrix * vec4(dir, 0.0)).xyz);\n}\nvec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {\n return normalize((vec4(dir, 0.0) * matrix).xyz);\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\n float distance = dot(planeNormal, point - pointOnPlane);\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\n return sign(dot(point - pointOnPlane, planeNormal));\n}\nvec3 linePlaneIntersect(in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal) {\n return lineDirection * (dot(planeNormal, pointOnPlane - pointOnLine) / dot(planeNormal, lineDirection)) + pointOnLine;\n}\nmat3 transposeMat3(const in mat3 m) {\n mat3 tmp;\n tmp[0] = vec3(m[0].x, m[1].x, m[2].x);\n tmp[1] = vec3(m[0].y, m[1].y, m[2].y);\n tmp[2] = vec3(m[0].z, m[1].z, m[2].z);\n return tmp;\n}\nfloat linearToRelativeLuminance(const in vec3 color) {\n vec3 weights = vec3(0.2126, 0.7152, 0.0722);\n return dot(weights, color.rgb);\n}\nfloat powCompat(const in float val, const in float power) {\n if (power == 0.0)\n return 1.0;\n else if (val < 0.0) {\n if (mod(-power, 2.0) == 0.0)\n return pow(-val, power);\n else\n return -pow(-val, power);\n } else if (val == 0.0)\n return 0.0;\n return pow(val, power);\n}\nfloat maxFromRGB(vec3 rgb) {\n return max(max(rgb.r, rgb.g), rgb.b);\n}\nbool isOrtho(const in mat4 m) {\n if (m[3][3] != 0.0)\n return true;\n else\n return false;\n}\nvec3 swizzleUpZ(const vec3 vec) {\n return vec3(vec[0], -vec[2], vec[1]);\n}\nvec3 swizzleUpY(const vec3 vec) {\n return vec3(vec[0], vec[2], -vec[1]);\n}\nvec3 xyz_to_sRGB(vec3 xyz) {\n mat3 convMat = mat3(\n 3.2406, -0.9689, 0.0557,\n -1.5372, 1.8758, -0.2040,\n -0.4986, 0.0415, 1.0570\n );\n return convMat * xyz;\n}\nvec3 xyY_to_XYZ(float x, float y, float Y) {\n float X = 0.0;\n float Z = 0.0;\n if (y != 0.0) {\n X = (Y / y) * x;\n Z = (Y / y) * (1.0 - x - y);\n }\n return vec3(X, Y, Z);\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\n#define cubeUV_faceSize (cubeUV_textureSize * 0.25)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo(vec3 dir, float roughnessLevel) {\n dir = normalize(dir) * (sqrt(3.0) + 1.0) / 2.0;\n vec3 dx = dFdx(dir);\n vec3 dy = dFdy(dir);\n \n float derivCoeff = cubeUV_faceSize / exp2(roughnessLevel) / 2.0;\n dx *= derivCoeff;\n dy *= derivCoeff;\n float d = max(dot(dx, dx), dot(dy, dy));\n d = clamp(d, 1.0, cubeUV_rangeClamp);\n float mipLevel = 0.5 * log2(d);\n return vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_faceSize) - 2.0)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n mipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n float a = 16.0 * cubeUV_rcpTextureSize;\n vec2 exp2_packed = exp2(vec2(roughnessLevel, mipLevel));\n vec2 rcp_exp2_packed = vec2(1.0) / exp2_packed;\n float powScale = exp2_packed.x * exp2_packed.y;\n float scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n float mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n bool bRes = mipLevel == 0.0;\n scale = bRes && (scale < a) ? a : scale;\n vec3 absDir = abs(direction);\n float maxAbsVal = max(max(absDir.x, absDir.y), absDir.z);\n bool Xy = absDir.x >= absDir.y, Xz = absDir.x >= absDir.z, Yz = absDir.y >= absDir.z;\n vec3 projMax = vec3(Xy && Xz, !Xy && Yz, !Xz && !Yz); \n \n mat3 vecToUV = mat3(\n projMax.y + projMax.z * sign(direction.z), 0.0, projMax.x,\n 0.0, projMax.x + projMax.z, projMax.y,\n sign(-direction.x) * projMax.x, sign(direction.y) * projMax.y, projMax.z\n );\n vec2 uv = (vecToUV * (direction / maxAbsVal)).xy;\n uv = (uv + vec2(1.0)) * 0.5;\n \n float offCoeffX = dot(projMax, vec3(0.0, 1.0, 2.0));\n float rowBottomOrTop = (sign(dot(projMax, direction)) + 1.0) / 2.0;\n float offCoeffY = 0.5 + 0.25 * rowBottomOrTop;\n float zeroMipCoeff = a * rowBottomOrTop;\n vec2 offset = vec2(offCoeffX * scale + mipOffset, offCoeffY / powScale);\n offset.y = bRes && (offset.y < 2.0 * a) ? zeroMipCoeff : offset.y;\n float texelOffset = 0.5 * cubeUV_rcpTextureSize;\n vec2 base = offset + vec2(texelOffset);\n return base + uv * (scale - 2.0 * texelOffset);\n}\n#define cubeUV_maxLods3 (log2(cubeUV_faceSize) - 3.0)\nvec4 textureCubeUV(sampler2D envMap, vec3 reflDir, vec3 reflDirMipLevel, float roughness) {\n float roughnessVal = roughness * cubeUV_maxLods3;\n float r0 = floor(roughnessVal);\n float r1 = r0 + 1.0;\n float rfactor = fract(roughnessVal);\n vec2 mipInfo = MipLevelInfo(reflDirMipLevel, r0);\n float l0 = mipInfo.x;\n float l1 = min(l0 + 1.0, 5.0);\n float lfactor = mipInfo.y;\n vec2 uv_r0_l0 = getCubeUV(reflDir, r0, l0);\n vec2 uv_r0_l1 = getCubeUV(reflDir, r0, l1);\n vec2 uv_r1_l0 = getCubeUV(reflDir, r1, l0);\n vec2 uv_r1_l1 = getCubeUV(reflDir, r1, l1);\n vec4 color_r0_l0 = envMapTexelToLinear(texture2D(envMap, uv_r0_l0));\n vec4 color_r0_l1 = envMapTexelToLinear(texture2D(envMap, uv_r0_l1));\n vec4 color_r1_l0 = envMapTexelToLinear(texture2D(envMap, uv_r1_l0));\n vec4 color_r1_l1 = envMapTexelToLinear(texture2D(envMap, uv_r1_l1));\n \n vec4 color_r0 = mix(color_r0_l0, color_r0_l1, lfactor);\n vec4 color_r1 = mix(color_r1_l0, color_r1_l1, lfactor);\n vec4 result = mix(color_r0, color_r1, rfactor);\n return vec4(result.rgb, 1.0);\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n vec3 transformedTangent = normalMatrix * objectTangent;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n transformed += normalize(objectNormal) * (texture2D(displacementMap, uv).x * displacementScale + displacementBias);\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D(emissiveMap, vUv);\n emissiveColor.rgb = emissiveMapTexelToLinear(emissiveColor).rgb;\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel(gl_FragColor);",encodings_pars_fragment:"\nvec4 LinearToLinear(in vec4 value) {\n return value;\n}\nvec4 GammaToLinear(in vec4 value, in float gammaFactor) {\n return vec4(pow(value.rgb, vec3(gammaFactor)), value.a);\n}\nvec4 LinearToGamma(in vec4 value, in float gammaFactor) {\n return vec4(pow(value.rgb, vec3(1.0 / gammaFactor)), value.a);\n}\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.a);\n}\nvec4 LinearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.a);\n}\nvec4 RGBEToLinear(in vec4 value) {\n return vec4(value.rgb * exp2(value.a * 255.0 - 128.0), 1.0);\n}\nvec4 LinearToRGBE(in vec4 value) {\n float maxComponent = max(max(value.r, value.g), value.b);\n float fExp = clamp(ceil(log2(maxComponent)), -128.0, 127.0);\n return vec4(value.rgb / exp2(fExp), (fExp + 128.0) / 255.0);\n}\nvec4 RGBMToLinear(in vec4 value, in float maxRange) {\n return vec4(value.rgb * value.a * maxRange, 1.0);\n}\nvec4 LinearToRGBM(in vec4 value, in float maxRange) {\n float maxRGB = max(value.r, max(value.g, value.b));\n float M = clamp(maxRGB / maxRange, 0.0, 1.0);\n M = ceil(M * 255.0) / 255.0;\n return vec4(value.rgb / (M * maxRange), M);\n}\nvec4 RGBDToLinear(in vec4 value, in float maxRange) {\n return vec4(value.rgb * ((maxRange / 255.0) / value.a), 1.0);\n}\nvec4 LinearToRGBD(in vec4 value, in float maxRange) {\n float maxRGB = max(value.r, max(value.g, value.b));\n float D = max(maxRange / maxRGB, 1.0);\n D = min(floor(D) / 255.0, 1.0);\n return vec4(value.rgb * (D * (255.0 / maxRange)), D);\n}\nconst mat3 cLogLuvM = mat3(0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969);\nvec4 LinearToLogLuv(in vec4 value) {\n vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w * 255.0)) / 255.0) / 255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3(6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268);\nvec4 LogLuvToLinear(in vec4 value) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n return vec4(max(vRGB, 0.0), 1.0);\n}",envmap_fragment:"#ifdef USE_ENVMAP\n #if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(PHONG) || defined(NODE)\n vec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\n vec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect(cameraToVertex, worldNormal);\n #else\n vec3 reflectVec = refract(cameraToVertex, worldNormal, refractionRatio);\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube(envMap, vec3(flipEnvMap * reflectVec.x, reflectVec.yz));\n #elif defined(ENVMAP_TYPE_EQUIREC)\n vec2 sampleUV;\n reflectVec = normalize(reflectVec);\n sampleUV.y = asin(clamp(reflectVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan(reflectVec.z, reflectVec.x) * RECIPROCAL_PI2 + 0.5;\n vec4 envColor = texture2D(envMap, sampleUV);\n #elif defined(ENVMAP_TYPE_SPHERE)\n reflectVec = normalize(reflectVec);\n vec3 reflectView = normalize((viewMatrix * vec4(reflectVec, 0.0)).xyz + vec3(0.0, 0.0, 1.0));\n vec4 envColor = texture2D(envMap, reflectView.xy * 0.5 + 0.5);\n #else\n vec4 envColor = vec4(0.0);\n #endif\n envColor = envMapTexelToLinear(envColor);\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix(outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity);\n #elif defined(ENVMAP_BLENDING_MIX)\n outgoingLight = mix(outgoingLight, envColor.xyz, specularStrength * reflectivity);\n #elif defined(ENVMAP_BLENDING_ADD)\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif",envmap_pars_fragment:"#if defined(USE_ENVMAP) || defined(PHYSICAL)\n uniform float reflectivity;\n uniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n #if !defined(PHYSICAL) && (defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(PHONG))\n varying vec3 vWorldPosition;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n uniform float flipEnvMap;\n uniform int maxMipLevel;\n #if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(PHONG) || defined(NODE) || defined(PHYSICAL)\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n #if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(PHONG) || defined(NODE)\n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",envmap_physical_pars_fragment:"#if defined(USE_ENVMAP) && defined(PHYSICAL)\n vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel) {\n vec3 worldNormal = inverseTransformDirection(geometry.normal, viewMatrix);\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT(envMap, queryVec, float(maxMIPLevel));\n #else\n vec4 envMapColor = textureCube(envMap, queryVec, float(maxMIPLevel));\n #endif\n envMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n #elif defined(ENVMAP_TYPE_CUBE_UV)\n vec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\n vec4 envMapColor = textureCubeUV(envMap, queryVec, queryVec, 1.0);\n #else\n vec4 envMapColor = vec4(0.0);\n #endif\n return PI * envMapColor.rgb * envMapIntensity;\n }\n float getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {\n float maxMIPLevelScalar = float(maxMIPLevel);\n float desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2(pow2(blinnShininessExponent) + 1.0);\n return clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n }\n vec3 _getLightProbeIndirect(const float blinnShininessExponent,\n const int maxMIPLevel, vec3 directionVec, vec3 directionVecMipLevel) {\n float specularMIPLevel = getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT(envMap, queryVec, specularMIPLevel);\n #else\n vec4 envMapColor = textureCube(envMap, queryVec, specularMIPLevel);\n #endif\n envMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n #elif defined(ENVMAP_TYPE_CUBE_UV)\n vec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\n vec3 queryVecMipLevel = vec3(flipEnvMap * directionVecMipLevel.x,\n directionVecMipLevel.yz);\n vec4 envMapColor = textureCubeUV(envMap, queryVec, queryVecMipLevel,\n BlinnExponentToGGXRoughness(blinnShininessExponent));\n #elif defined(ENVMAP_TYPE_EQUIREC)\n vec2 sampleUV;\n sampleUV.y = asin(clamp(directionVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan(directionVec.z, directionVec.x) * RECIPROCAL_PI2 + 0.5;\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT(envMap, sampleUV, specularMIPLevel);\n #else\n vec4 envMapColor = texture2D(envMap, sampleUV, specularMIPLevel);\n #endif\n envMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n #elif defined(ENVMAP_TYPE_SPHERE)\n vec3 reflectView = normalize((viewMatrix * vec4(directionVec, 0.0)).xyz + vec3(0.0,0.0,1.0));\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT(envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel);\n #else\n vec4 envMapColor = texture2D(envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel);\n #endif\n envMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n #endif\n return envMapColor.rgb * envMapIntensity;\n }\n vec3 getLightProbeIndirectRadiance(\n const GeometricContext geometry, const float blinnShininessExponent,\n const int maxMIPLevel, const int useCoat) {\n vec3 normal = geometry.normal;\n if (useCoat == 1) {\n normal = geometry.coatNormal;\n }\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 directionVec = reflect(-geometry.viewDir, normal);\n #else\n vec3 directionVec = refract(-geometry.viewDir, normal, refractionRatio);\n #endif\n directionVec = inverseTransformDirection(directionVec, viewMatrix);\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 directionVecMipLevel = reflect(-geometry.viewDir, geometry.originalNormal);\n #else\n vec3 directionVecMipLevel = refract(-geometry.viewDir, geometry.originalNormal, refractionRatio);\n #endif\n directionVecMipLevel = inverseTransformDirection(directionVecMipLevel, viewMatrix);\n return _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\n directionVec, directionVecMipLevel);\n }\n vec3 getLightProbeIndirectRefraction(\n const GeometricContext geometry, const float blinnShininessExponent,\n const int maxMIPLevel, const float refrRatio) {\n vec3 directionVec = refract(-geometry.viewDir, geometry.normal, refrRatio);\n directionVec = inverseTransformDirection(directionVec, viewMatrix);\n vec3 directionVecMipLevel = refract(-geometry.viewDir, geometry.originalNormal, refrRatio);\n directionVecMipLevel = inverseTransformDirection(directionVecMipLevel, viewMatrix);\n return _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\n directionVec, directionVecMipLevel);\n }\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(PHONG) || defined(NODE)\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex = normalize(worldPosition.xyz - cameraPosition);\n vec3 worldNormal = inverseTransformDirection(transformedNormal, viewMatrix);\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect(cameraToVertex, worldNormal);\n #else\n vReflect = refract(cameraToVertex, worldNormal, refractionRatio);\n #endif\n #endif\n#endif",fog_vertex:"#ifdef USE_FOG\n fogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = whiteCompliment(exp2(- fogDensity * fogDensity * fogDepth * fogDepth * LOG2));\n #else\n float fogFactor = smoothstep(fogNear, fogFar, fogDepth);\n #endif\n gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor);\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float fogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",gradientmap_pars_fragment:"#ifdef TOON\n uniform sampler2D gradientMap;\n vec3 getGradientIrradiance(vec3 normal, vec3 lightDirection) {\n float dotNL = dot(normal, lightDirection);\n vec2 coord = vec2(dotNL * 0.5 + 0.5, 0.0);\n #ifdef USE_GRADIENTMAP\n return texture2D(gradientMap, coord).rgb;\n #else\n return (coord.x < 0.7) ? vec3(0.7) : vec3(1.0);\n #endif\n }\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\n reflectedLight.indirectDiffuse += PI * texture2D(lightMap, vUv2).xyz * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3(1.0);\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize(transformedNormal);\ngeometry.originalNormal = geometry.normal;\ngeometry.viewDir = normalize(-mvPosition.xyz);\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.originalNormal = -geometry.originalNormal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3(0.0);\nvIndirectFront = vec3(0.0);\n#ifdef DOUBLE_SIDED\n vLightBack = vec3(0.0);\n vIndirectBack = vec3(0.0);\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n getPointDirectLightIrradiance(pointLights[i], geometry, directLight);\n dotNL = dot(geometry.normal, directLight.direction);\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate(dotNL) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n getSpotDirectLightIrradiance(spotLights[i], geometry, directLight);\n dotNL = dot(geometry.normal, directLight.direction);\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate(dotNL) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n getDirectionalDirectLightIrradiance(directionalLights[i], geometry, directLight);\n dotNL = dot(geometry.normal, directLight.direction);\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate(dotNL) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\n vIndirectFront += getHemisphereLightIrradiance(hemisphereLights[i], geometry);\n #ifdef DOUBLE_SIDED\n vIndirectBack += getHemisphereLightIrradiance(hemisphereLights[i], backGeometry);\n #endif\n }\n#endif",lights_pars_begin:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance(const in vec3 ambientLightColor) {\n vec3 irradiance = ambientLightColor;\n #if defined(BLENDER_LIGHTS) || !defined(PHYSICALLY_CORRECT_LIGHTS)\n irradiance *= PI;\n #endif\n return irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];\n void getDirectionalDirectLightIrradiance(const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight) {\n directLight.color = directionalLight.color;\n directLight.direction = directionalLight.direction;\n directLight.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLight pointLights[NUM_POINT_LIGHTS];\n void getPointDirectLightIrradiance(const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight) {\n vec3 lVector = pointLight.position - geometry.position;\n directLight.direction = normalize(lVector);\n float lightDistance = length(lVector);\n directLight.color = pointLight.color;\n directLight.color *= punctualLightIntensityToIrradianceFactor(lightDistance, pointLight.distance, pointLight.decay);\n directLight.visible = (directLight.color != vec3(0.0));\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLight spotLights[NUM_SPOT_LIGHTS];\n void getSpotDirectLightIrradiance(const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight) {\n vec3 lVector = spotLight.position - geometry.position;\n directLight.direction = normalize(lVector);\n float lightDistance = length(lVector);\n float angleCos = dot(directLight.direction, spotLight.direction);\n if (angleCos > spotLight.coneCos) {\n float spotEffect = smoothstep(spotLight.coneCos, spotLight.penumbraCos, angleCos);\n directLight.color = spotLight.color;\n directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor(lightDistance, spotLight.distance, spotLight.decay);\n directLight.visible = true;\n } else {\n directLight.color = vec3(0.0);\n directLight.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1;\n uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[NUM_RECT_AREA_LIGHTS];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[NUM_HEMI_LIGHTS];\n vec3 getHemisphereLightIrradiance(const in HemisphereLight hemiLight, const in GeometricContext geometry) {\n float dotNL = dot(geometry.normal, hemiLight.direction);\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix(hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight);\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n }\n#endif",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong(const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef TOON\n vec3 irradiance = getGradientIrradiance(geometry.normal, directLight.direction) * directLight.color;\n #else\n float dotNL = saturate(dot(geometry.normal, directLight.direction));\n vec3 irradiance = dotNL * directLight.color;\n #endif\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(directLight, geometry, material.specularColor, material.specularShininess) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong(const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD(material) (0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * (1.0 - metalnessFactor);\nmaterial.specularRoughness = clamp(roughnessFactor, 0.04, 1.0);\n#ifdef STANDARD\n material.specularColor = mix(vec3(DEFAULT_SPECULAR_COEFFICIENT), diffuseColor.rgb, metalnessFactor);\n#else\n material.specularColor = mix(vec3(MAXIMUM_SPECULAR_COEFFICIENT * pow2(reflectivity)), diffuseColor.rgb, metalnessFactor);\n material.clearCoat = saturate(clearCoat);\n material.clearCoatRoughness = clamp(clearCoatRoughness, 0.04, 1.0);\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n vec3 diffuseColor;\n float specularRoughness;\n vec3 specularColor;\n #ifndef STANDARD\n float clearCoat;\n float clearCoatRoughness;\n #endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox(const in float roughness, const in float dotNL) {\n return DEFAULT_SPECULAR_COEFFICIENT + (1.0 - DEFAULT_SPECULAR_COEFFICIENT) * (pow(1.0 - dotNL, 5.0) * pow(1.0 - roughness, 2.0));\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical(const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n vec3 normal = geometry.normal;\n vec3 viewDir = geometry.viewDir;\n vec3 position = geometry.position;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.specularRoughness;\n vec3 rectCoords[4];\n rectCoords[0] = lightPos + halfWidth - halfHeight;\n rectCoords[1] = lightPos - halfWidth - halfHeight;\n rectCoords[2] = lightPos - halfWidth + halfHeight;\n rectCoords[3] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv(normal, viewDir, roughness);\n vec4 t1 = texture2D(ltc_1, uv);\n vec4 t2 = texture2D(ltc_2, uv);\n mat3 mInv = mat3(\n vec3(t1.x, 0, t1.y),\n vec3( 0, 1, 0),\n vec3(t1.z, 0, t1.w)\n );\n vec3 fresnel = (material.specularColor * t2.x + (vec3(1.0) - material.specularColor) * t2.y);\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate(normal, viewDir, position, mInv, rectCoords);\n reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate(normal, viewDir, position, mat3(1.0), rectCoords);\n }\n#endif\nvoid RE_Direct_Physical(const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n float dotNL = saturate(dot(geometry.normal, directLight.direction));\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n #ifndef STANDARD\n float clearCoatDHR = material.clearCoat * clearCoatDHRApprox(material.clearCoatRoughness, dotNL);\n #else\n float clearCoatDHR = 0.0;\n #endif\n reflectedLight.directSpecular += (1.0 - clearCoatDHR) * irradiance\n * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.normal,\n material.specularColor, material.specularRoughness);\n reflectedLight.directDiffuse += (1.0 - clearCoatDHR) * irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n #ifndef STANDARD\n reflectedLight.directSpecular += irradiance * material.clearCoat\n * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.coatNormal,\n vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearCoatRoughness);\n #endif\n}\nvoid RE_IndirectDiffuse_Physical(const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectSpecular_Physical(const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifndef STANDARD\n float coatDotNL = saturate(dot(geometry.coatNormal, geometry.viewDir));\n float clearCoatDHR = material.clearCoat * clearCoatDHRApprox(material.clearCoatRoughness, coatDotNL);\n #else\n float clearCoatDHR = 0.0;\n #endif\n reflectedLight.indirectSpecular += (1.0 - clearCoatDHR) * radiance\n * BRDF_Specular_GGX_Environment(geometry, material.specularColor,\n material.specularRoughness, 0);\n #ifndef STANDARD\n reflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat\n * BRDF_Specular_GGX_Environment(geometry, vec3(DEFAULT_SPECULAR_COEFFICIENT),\n material.clearCoatRoughness, 1);\n #endif\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness)\n#define Material_ClearCoat_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.clearCoatRoughness)\nfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\n return saturate(pow(dotNV + ambientOcclusion, exp2(- 16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize(vViewPosition);\n#if defined(ORIGINAL_NORMAL)\n geometry.originalNormal = ORIGINAL_NORMAL;\n#else\n geometry.originalNormal = geometry.normal;\n#endif\n#if defined(COAT_NORMAL)\n geometry.coatNormal = COAT_NORMAL;\n#else\n geometry.coatNormal = geometry.normal;\n#endif\nIncidentLight directLight;\n#if (NUM_POINT_LIGHTS > 0) && defined(RE_Direct)\n PointLight pointLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n pointLight = pointLights[i];\n getPointDirectLightIrradiance(pointLight, geometry, directLight);\n #ifdef USE_SHADOWMAP\n directLight.color *= all(bvec2(pointLight.shadow, directLight.visible)) ? getPointShadow(pointShadowMap[i], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[i], pointLight.shadowCameraNear, pointLight.shadowCameraFar) : 1.0;\n #endif\n RE_Direct(directLight, geometry, material, reflectedLight);\n }\n#endif\n#if (NUM_SPOT_LIGHTS > 0) && defined(RE_Direct)\n SpotLight spotLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n spotLight = spotLights[i];\n getSpotDirectLightIrradiance(spotLight, geometry, directLight);\n #ifdef USE_SHADOWMAP\n directLight.color *= all(bvec2(spotLight.shadow, directLight.visible)) ? getShadow(spotShadowMap[i], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[i]) : 1.0;\n #endif\n RE_Direct(directLight, geometry, material, reflectedLight);\n }\n#endif\n#if (NUM_DIR_LIGHTS > 0) && defined(RE_Direct)\n DirectionalLight directionalLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n directionalLight = directionalLights[i];\n getDirectionalDirectLightIrradiance(directionalLight, geometry, directLight);\n #ifdef USE_SHADOWMAP\n directLight.color *= all(bvec2(directionalLight.shadow, directLight.visible)) ? getShadow(directionalShadowMap[i], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[i]) : 1.0;\n #endif\n RE_Direct(directLight, geometry, material, reflectedLight);\n }\n#endif\n#if (NUM_RECT_AREA_LIGHTS > 0) && defined(RE_Direct_RectArea)\n RectAreaLight rectAreaLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_RECT_AREA_LIGHTS; i++) {\n rectAreaLight = rectAreaLights[i];\n RE_Direct_RectArea(rectAreaLight, geometry, material, reflectedLight);\n }\n#endif\n#if defined(RE_IndirectDiffuse)\n vec3 irradiance = getAmbientLightIrradiance(ambientLightColor);\n #if (NUM_HEMI_LIGHTS > 0)\n #pragma unroll_loop\n for (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\n irradiance += getHemisphereLightIrradiance(hemisphereLights[i], geometry);\n #if defined(BLENDER_LIGHTS) && !defined(PHYSICAL)\n RE_HemiSpec_Blender(hemisphereLights[i], geometry, material, reflectedLight);\n #endif\n }\n #endif\n#endif\n#if defined(RE_IndirectSpecular)\n vec3 radiance = vec3(0.0);\n vec3 clearCoatRadiance = vec3(0.0);\n#endif\n#if defined(RE_Refraction) && defined(USE_REFRACTED_LIGHT)\n vec3 refraction = vec3(0.0);\n#endif",lights_fragment_maps:"#if defined(RE_IndirectDiffuse)\n #ifdef USE_LIGHTMAP\n vec3 lightMapIrradiance = texture2D(lightMap, vUv2).xyz * lightMapIntensity;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\n #endif\n #if defined(USE_ENVMAP) && defined(PHYSICAL) && defined(ENVMAP_TYPE_CUBE_UV)\n irradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel);\n #endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_IndirectSpecular)\n radiance += getLightProbeIndirectRadiance(geometry,\n Material_BlinnShininessExponent(material), maxMipLevel, 0);\n #ifndef STANDARD\n clearCoatRadiance += getLightProbeIndirectRadiance(geometry,\n Material_ClearCoat_BlinnShininessExponent(material), maxMipLevel, 1);\n #endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_Refraction) && defined(USE_REFRACTED_LIGHT)\n refraction += getLightProbeIndirectRefraction(geometry,\n Material_Refraction_BlinnShininessExponent(material), maxMipLevel,\n 1.0 / material.refractionIOR);\n#endif",lights_fragment_end:"#if defined(RE_IndirectDiffuse)\n RE_IndirectDiffuse(irradiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_IndirectSpecular)\n RE_IndirectSpecular(radiance, clearCoatRadiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_Refraction) && defined(USE_REFRACTED_LIGHT)\n RE_Refraction(refraction, material, refractedLight);\n#endif",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n gl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n uniform float logDepthBufFC;\n varying float vFragDepth;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n #else\n uniform float logDepthBufFC;\n #endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n vFragDepth = 1.0 + gl_Position.w;\n #else\n gl_Position.z = log2(max(EPSILON, gl_Position.w + 1.0)) * logDepthBufFC - 1.0;\n gl_Position.z *= gl_Position.w;\n #endif\n#endif",map_fragment:"#ifdef USE_MAP\n vec4 texelColor = texture2D(map, vUv);\n texelColor = mapTexelToLinear(texelColor);\n diffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n uniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\n vec2 uv = (uvTransform * vec3(gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1)).xy;\n vec4 mapTexel = texture2D(map, uv);\n diffuseColor *= mapTexelToLinear(mapTexel);\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\n uniform mat3 uvTransform;\n uniform sampler2D map;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D(metalnessMap, vUv);\n metalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n objectNormal += (morphNormal0 - normal) * morphTargetInfluences[0];\n objectNormal += (morphNormal1 - normal) * morphTargetInfluences[1];\n objectNormal += (morphNormal2 - normal) * morphTargetInfluences[2];\n objectNormal += (morphNormal3 - normal) * morphTargetInfluences[3];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n #ifndef USE_MORPHNORMALS\n uniform float morphTargetInfluences[8];\n #else\n uniform float morphTargetInfluences[4];\n #endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed += (morphTarget0 - position) * morphTargetInfluences[0];\n transformed += (morphTarget1 - position) * morphTargetInfluences[1];\n transformed += (morphTarget2 - position) * morphTargetInfluences[2];\n transformed += (morphTarget3 - position) * morphTargetInfluences[3];\n #ifndef USE_MORPHNORMALS\n transformed += (morphTarget4 - position) * morphTargetInfluences[4];\n transformed += (morphTarget5 - position) * morphTargetInfluences[5];\n transformed += (morphTarget6 - position) * morphTargetInfluences[6];\n transformed += (morphTarget7 - position) * morphTargetInfluences[7];\n #endif\n#endif",normal_fragment_begin:"#ifdef FLAT_SHADED\n vec3 fdx = vec3(dFdx(vViewPosition.x), dFdx(vViewPosition.y), dFdx(vViewPosition.z));\n vec3 fdy = vec3(dFdy(vViewPosition.x), dFdy(vViewPosition.y), dFdy(vViewPosition.z));\n vec3 normal = normalize(cross(fdx, fdy));\n#else\n vec3 normal = normalize(vNormal);\n #ifdef DOUBLE_SIDED\n normal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n #endif\n#endif\n vec3 originalNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP\n #ifdef OBJECTSPACE_NORMALMAP\n normal = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n #endif\n normal = normalize(normalMatrix * normal);\n #else\n #ifdef USE_TANGENT\n normal = perturbNormalTang(vNormal);\n #else\n normal = perturbNormal2Arb(-vViewPosition, normal);\n #endif\n #endif\n#elif defined(USE_BUMPMAP)\n normal = perturbNormalArb(-vViewPosition, normal, dHdxy_fwd());\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n #ifdef OBJECTSPACE_NORMALMAP\n uniform mat3 normalMatrix;\n #elif defined(USE_TANGENT)\n \n uniform mat4 modelViewMatrix;\n varying vec4 vTangent;\n vec3 perturbNormalTang(vec3 normal) {\n vec3 normalTex = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\n normalTex.xy *= normalScale;\n normalTex = normalize(normalTex);\n vec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(vTangent.xyz, 0.0)).xyz), vTangent.w);\n vec3 bitangent = -viewTangent.w * cross(normal, viewTangent.xyz);\n vec3 normalOut = normalTex.x * (viewTangent.xyz) + normalTex.y * bitangent \n + normalTex.z * normal;\n normalOut = normalize(normalOut);\n return normalOut;\n }\n #else\n vec3 perturbNormal2Arb(vec3 eye_pos, vec3 surf_norm) {\n vec3 q0 = vec3(dFdx(eye_pos.x), dFdx(eye_pos.y), dFdx(eye_pos.z));\n vec3 q1 = vec3(dFdy(eye_pos.x), dFdy(eye_pos.y), dFdy(eye_pos.z));\n vec2 st0 = dFdx(vUv.st);\n vec2 st1 = dFdy(vUv.st);\n float scale = sign(st1.t * st0.s - st0.t * st1.s);\n vec3 S = normalize((q0 * st1.t - q1 * st0.t) * scale);\n vec3 T = normalize((- q0 * st1.s + q1 * st0.s) * scale);\n vec3 N = normalize(surf_norm);\n mat3 tsn = mat3(S, T, N);\n vec3 mapN = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n mapN.xy *= (float(gl_FrontFacing) * 2.0 - 1.0);\n return normalize(tsn * mapN);\n }\n #endif\n#endif",packing:"vec3 packNormalToRGB(const in vec3 normal) {\n return normalize(normal) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal(const in vec3 rgb) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;\nconst float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3(256. * 256. * 256., 256. * 256., 256.);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.);\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA(const in float v) {\n vec4 r = vec4(fract(v * PackFactors), v);\n r.yzw -= r.xyz * ShiftRight8;\n return r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\n return dot(v, UnpackFactors);\n}\nfloat viewZToOrthographicDepth(const in float viewZ, const in float near, const in float far) {\n return (viewZ + near) / (near - far);\n}\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\n return linearClipZ * (near - far) - near;\n}\nfloat viewZToPerspectiveDepth(const in float viewZ, const in float near, const in float far) {\n return ((near + viewZ) * far) / ((far - near) * viewZ);\n}\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\n return (near * far) / ((far - near) * invClipZ - far);\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4(transformed, 1.0);\ngl_Position = projectionMatrix * mvPosition;\n#if defined(BACKGROUND_DEPTH)\n gl_Position.z = gl_Position.w;\n#endif",dithering_fragment:"#if defined(DITHERING)\n gl_FragColor.rgb = dithering(gl_FragColor.rgb);\n#endif",dithering_pars_fragment:"#if defined(DITHERING)\n vec3 dithering(vec3 color) {\n float grid_position = rand(gl_FragCoord.xy);\n vec3 dither_shift_RGB = vec3(0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0);\n dither_shift_RGB = mix(2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position);\n return color + dither_shift_RGB;\n }\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D(roughnessMap, vUv);\n roughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n uniform sampler2D directionalShadowMap[NUM_DIR_LIGHTS];\n varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHTS];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n uniform sampler2D spotShadowMap[NUM_SPOT_LIGHTS];\n varying vec4 vSpotShadowCoord[NUM_SPOT_LIGHTS];\n #endif\n #if NUM_POINT_LIGHTS > 0\n uniform sampler2D pointShadowMap[NUM_POINT_LIGHTS];\n varying vec4 vPointShadowCoord[NUM_POINT_LIGHTS];\n #endif\n float texture2DCompare(sampler2D depths, vec2 uv, float compare) {\n return step(compare, unpackRGBAToDepth(texture2D(depths, uv)));\n }\n float texture2DShadowLerp(sampler2D depths, vec2 size, vec2 uv, float compare) {\n const vec2 offset = vec2(0.0, 1.0);\n vec2 texelSize = vec2(1.0) / size;\n vec2 centroidUV = floor(uv * size + 0.5) / size;\n float lb = texture2DCompare(depths, centroidUV + texelSize * offset.xx, compare);\n float lt = texture2DCompare(depths, centroidUV + texelSize * offset.xy, compare);\n float rb = texture2DCompare(depths, centroidUV + texelSize * offset.yx, compare);\n float rt = texture2DCompare(depths, centroidUV + texelSize * offset.yy, compare);\n vec2 f = fract(uv * size + 0.5);\n float a = mix(lb, lt, f.y);\n float b = mix(rb, rt, f.y);\n float c = mix(a, b, f.x);\n return c;\n }\n float getShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bvec4 inFrustumVec = bvec4 (shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0);\n bool inFrustum = all(inFrustumVec);\n bvec2 frustumTestVec = bvec2(inFrustum, shadowCoord.z <= 1.0);\n bool frustumTest = all(frustumTestVec);\n if (frustumTest) {\n #if defined(SHADOWMAP_TYPE_PCF)\n vec2 texelSize = vec2(1.0) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n shadow = (\n texture2DCompare(shadowMap, shadowCoord.xy + vec2(dx0, dy0), shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + vec2(0.0, dy0), shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + vec2(dx1, dy0), shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + vec2(dx0, 0.0), shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + vec2(dx1, 0.0), shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + vec2(dx0, dy1), shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + vec2(0.0, dy1), shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + vec2(dx1, dy1), shadowCoord.z)\n ) * (1.0 / 9.0);\n #elif defined(SHADOWMAP_TYPE_PCF_SOFT)\n vec2 texelSize = vec2(1.0) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n shadow = (\n texture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx0, dy0), shadowCoord.z) +\n texture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(0.0, dy0), shadowCoord.z) +\n texture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx1, dy0), shadowCoord.z) +\n texture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx0, 0.0), shadowCoord.z) +\n texture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z) +\n texture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx1, 0.0), shadowCoord.z) +\n texture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx0, dy1), shadowCoord.z) +\n texture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(0.0, dy1), shadowCoord.z) +\n texture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx1, dy1), shadowCoord.z)\n ) * (1.0 / 9.0);\n #else\n shadow = texture2DCompare(shadowMap, shadowCoord.xy, shadowCoord.z);\n #endif\n }\n return shadow;\n }\n vec2 cubeToUV(vec3 v, float texelSizeY) {\n vec3 absV = abs(v);\n float scaleToCube = 1.0 / max(absV.x, max(absV.y, absV.z));\n absV *= scaleToCube;\n v *= scaleToCube * (1.0 - 2.0 * texelSizeY);\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if (absV.z >= almostOne) {\n if (v.z > 0.0)\n planar.x = 4.0 - v.x;\n } else if (absV.x >= almostOne) {\n float signX = sign(v.x);\n planar.x = v.z * signX + 2.0 * signX;\n } else if (absV.y >= almostOne) {\n float signY = sign(v.y);\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2(0.125, 0.25) * planar + vec2(0.375, 0.75);\n }\n float getPointShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar) {\n vec2 texelSize = vec2(1.0) / (shadowMapSize * vec2(4.0, 2.0));\n vec3 lightToPosition = shadowCoord.xyz;\n float dp = (length(lightToPosition) - shadowCameraNear) / (shadowCameraFar - shadowCameraNear);\n dp += shadowBias;\n vec3 bd3D = normalize(lightToPosition);\n #if defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\n vec2 offset = vec2(- 1, 1) * shadowRadius * texelSize.y;\n return (\n texture2DCompare(shadowMap, cubeToUV(bd3D + offset.xyy, texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + offset.yyy, texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + offset.xyx, texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + offset.yyx, texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + offset.xxy, texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + offset.yxy, texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + offset.xxx, texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + offset.yxx, texelSize.y), dp)\n ) * (1.0 / 9.0);\n #else\n return texture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp);\n #endif\n }\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n uniform mat4 directionalShadowMatrix[NUM_DIR_LIGHTS];\n varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHTS];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n uniform mat4 spotShadowMatrix[NUM_SPOT_LIGHTS];\n varying vec4 vSpotShadowCoord[NUM_SPOT_LIGHTS];\n #endif\n #if NUM_POINT_LIGHTS > 0\n uniform mat4 pointShadowMatrix[NUM_POINT_LIGHTS];\n varying vec4 vPointShadowCoord[NUM_POINT_LIGHTS];\n #endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n vDirectionalShadowCoord[i] = directionalShadowMatrix[i] * worldPosition;\n }\n #endif\n #if NUM_SPOT_LIGHTS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n vSpotShadowCoord[i] = spotShadowMatrix[i] * worldPosition;\n }\n #endif\n #if NUM_POINT_LIGHTS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n vPointShadowCoord[i] = pointShadowMatrix[i] * worldPosition;\n }\n #endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n DirectionalLight directionalLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n directionalLight = directionalLights[i];\n shadow *= bool(directionalLight.shadow) ? getShadow(directionalShadowMap[i], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[i]) : 1.0;\n }\n #endif\n #if NUM_SPOT_LIGHTS > 0\n SpotLight spotLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n spotLight = spotLights[i];\n shadow *= bool(spotLight.shadow) ? getShadow(spotShadowMap[i], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[i]) : 1.0;\n }\n #endif\n #if NUM_POINT_LIGHTS > 0\n PointLight pointLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n pointLight = pointLights[i];\n shadow *= bool(pointLight.shadow) ? getPointShadow(pointShadowMap[i], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[i], pointLight.shadowCameraNear, pointLight.shadowCameraFar) : 1.0;\n }\n #endif\n #endif\n return shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix(skinIndex.x);\n mat4 boneMatY = getBoneMatrix(skinIndex.y);\n mat4 boneMatZ = getBoneMatrix(skinIndex.z);\n mat4 boneMatW = getBoneMatrix(skinIndex.w);\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n #ifdef BONE_TEXTURE\n uniform sampler2D boneTexture;\n uniform int boneTextureSize;\n mat4 getBoneMatrix(const in float i) {\n float j = i * 4.0;\n float x = mod(j, float(boneTextureSize));\n float y = floor(j / float(boneTextureSize));\n float dx = 1.0 / float(boneTextureSize);\n float dy = 1.0 / float(boneTextureSize);\n y = dy * (y + 0.5);\n vec4 v1 = texture2D(boneTexture, vec2(dx * (x + 0.5), y));\n vec4 v2 = texture2D(boneTexture, vec2(dx * (x + 1.5), y));\n vec4 v3 = texture2D(boneTexture, vec2(dx * (x + 2.5), y));\n vec4 v4 = texture2D(boneTexture, vec2(dx * (x + 3.5), y));\n mat4 bone = mat4(v1, v2, v3, v4);\n return bone;\n }\n #else\n uniform mat4 boneMatrices[MAX_BONES];\n mat4 getBoneMatrix(const in float i) {\n mat4 bone = boneMatrices[int(i)];\n return bone;\n }\n #endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4(transformed, 1.0);\n vec4 skinned = vec4(0.0);\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = (bindMatrixInverse * skinned).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n mat4 skinMatrix = mat4(0.0);\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4(skinMatrix * vec4(objectNormal, 0.0)).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4(skinMatrix * vec4(objectTangent, 0.0)).xyz;\n #endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D(specularMap, vUv);\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined(TONE_MAPPING)\n gl_FragColor.rgb = toneMapping(gl_FragColor.rgb);\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n #define saturate(a) clamp(a, 0.0, 1.0)\n#endif\n#ifndef PI\n #define PI 3.14159265359\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nuniform float toneMappingBrightness;\nuniform float toneMappingContrast;\nuniform float toneMappingMidTones;\nuniform float toneMappingPhysicalScale;\nuniform bool toneMappingChromaticAdaptation;\nuniform vec3 toneMappingWhiteColor;\nuniform bool toneMappingColorDifferentiation;\nuniform bool toneMappingExteriorDaylight;\nvec3 LinearToneMapping(vec3 color) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping(vec3 color) {\n color *= toneMappingExposure;\n return saturate(color / (vec3(1.0) + color));\n}\n#define Uncharted2Helper(x) max(((x * (0.15 * x + 0.10 * 0.50) + 0.20 * 0.02) / (x * (0.15 * x + 0.50) + 0.20 * 0.30)) - 0.02 / 0.30, vec3(0.0))\nvec3 Uncharted2ToneMapping(vec3 color) {\n color *= toneMappingExposure;\n return saturate(Uncharted2Helper(color) / Uncharted2Helper(vec3(toneMappingWhitePoint)));\n}\nvec3 OptimizedCineonToneMapping(vec3 color) {\n color *= toneMappingExposure;\n color = max(vec3(0.0), color - 0.004);\n return pow((color * (6.2 * color + 0.5)) / (color * (6.2 * color + 1.7) + 0.06), vec3(2.2));\n}\nvec3 ACESFilmicToneMapping(vec3 color) {\n color *= toneMappingExposure;\n return saturate((color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14));\n}\n#define ORDERS_OF_MAG 5.0\nfloat toneCalcBrightness(in vec3 color)\n{\n return (abs(color.r) * 0.263 + abs(color.g) * 0.655 + abs(color.b) * 0.082);\n}\nfloat toneApproximateScotopicLuminance(vec3 color)\n{\n return (0.062 * color.r + 0.608 * color.g + 0.330 * color.b);\n}\nvec3 LogarithmicMaxToneMapping(vec3 color) {\n float inputScaleFactor = toneMappingPhysicalScale / PI;\n float brightness = (toneMappingBrightness < 0.0) ? 0.0 : (toneMappingBrightness * 0.7);\n float powerBot = toneMappingExteriorDaylight ? 4.0 : 2.0;\n float res = 100.0 / ORDERS_OF_MAG;\n float mag = floor((50.0 / res));\n float power = ((brightness / 20.0 - ORDERS_OF_MAG) - powerBot) + mag;\n float stepsize = 9.0 / res;\n float step = 50.0 - (mag * res);\n float param_c = (0.02 * toneMappingContrast) * 2.0;\n float param_b = pow(10.0, power) * (1.0 + (stepsize * step));\n float param_a = param_b * (1.0 + param_c);\n param_c /= pow(2.0, toneMappingMidTones - 1.0);\n param_b *= PI;\n vec3 whiteConstancyFactor = toneMappingWhiteColor;\n if (toneMappingChromaticAdaptation) {\n float luminance = toneCalcBrightness(whiteConstancyFactor);\n whiteConstancyFactor.r = (whiteConstancyFactor.r > 0.001) ? luminance / whiteConstancyFactor.r : luminance / 0.001;\n whiteConstancyFactor.g = (whiteConstancyFactor.g > 0.001) ? luminance / whiteConstancyFactor.g : luminance / 0.001;\n whiteConstancyFactor.b = (whiteConstancyFactor.b > 0.001) ? luminance / whiteConstancyFactor.b : luminance / 0.001;\n }\n vec3 outColor = inputScaleFactor * color;\n if (toneMappingChromaticAdaptation) {\n outColor *= whiteConstancyFactor.rgb;\n }\n float luminance = toneCalcBrightness(outColor);\n if (toneMappingColorDifferentiation && (luminance < 5.62)) {\n float sLuminance = toneApproximateScotopicLuminance(outColor);\n if (luminance <= 5.62e-3) {\n outColor = vec3(sLuminance);\n } else {\n float w = (luminance - 5.62e-3) / 5.61438;\n outColor = outColor * w + sLuminance * (1.0 - w);\n }\n }\n outColor = outColor * (param_a / (param_b * outColor + param_c));\n return outColor;\n}",uv_pars_fragment:"#if defined(USE_MAP) || defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(USE_SPECULARMAP) || defined(USE_ALPHAMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP)\n varying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined(USE_MAP) || defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(USE_SPECULARMAP) || defined(USE_ALPHAMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP)\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif",uv_vertex:"#if defined(USE_MAP) || defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(USE_SPECULARMAP) || defined(USE_ALPHAMAP) || defined(USE_EMISSIVEMAP) || defined(USE_ROUGHNESSMAP) || defined(USE_METALNESSMAP)\n vUv = (uvTransform * vec3(uv, 1)).xy;\n#endif",uv2_pars_fragment:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\n varying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\n attribute vec2 uv2;\n varying vec2 vUv2;\n#endif",uv2_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\n vUv2 = uv2;\n#endif",worldpos_vertex:"#if defined(USE_ENVMAP) || defined(DISTANCE) || defined (USE_SHADOWMAP) || defined(MASK) || defined(NODE)\n vec4 worldPosition = modelMatrix * vec4(transformed, 1.0);\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D(t2D, vUv);\n gl_FragColor = mapTexelToLinear(texColor);\n #include \n #include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = (uvTransform * vec3(uv, 1)).xy;\n gl_Position = vec4(position.xy, 1.0, 1.0);\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube(tCube, vec3(tFlip * vWorldDirection.x, vWorldDirection.yz));\n gl_FragColor = mapTexelToLinear(texColor);\n gl_FragColor.a *= opacity;\n #include \n #include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection(position, modelMatrix);\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4(1.0);\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include \n #include \n #include \n #include \n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4(vec3(1.0 - gl_FragCoord.z), opacity);\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n #endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n #include \n vec4 diffuseColor = vec4(1.0);\n #include \n #include \n #include \n float dist = length(vWorldPosition - referencePosition);\n dist = (dist - nearDistance) / (farDistance - nearDistance);\n dist = saturate(dist);\n gl_FragColor = packDepthToRGBA(dist);\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nuniform bool invertU;\nuniform float offsetU;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 direction = normalize(vWorldDirection);\n vec2 sampleUV;\n sampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\n \n if (invertU) {\n sampleUV.x = 1.0 - sampleUV.x;\n }\n \n sampleUV.x += offsetU;\n vec4 texColor = texture2D(tEquirect, sampleUV);\n gl_FragColor = mapTexelToLinear(texColor);\n #include \n #include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection(position, modelMatrix);\n #include \n #include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n if (mod(vLineDistance, totalSize) > dashSize) {\n discard;\n }\n vec3 outgoingLight = vec3(0.0);\n vec4 diffuseColor = vec4(diffuse, opacity);\n #include \n #include \n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n #include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vLineDistance = scale * lineDistance;\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4(diffuse, opacity);\n #include \n #include \n #include \n #include \n #include \n #include \n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #ifdef USE_LIGHTMAP\n reflectedLight.indirectDiffuse += texture2D(lightMap, vUv2).xyz * lightMapIntensity;\n #else\n reflectedLight.indirectDiffuse += vec3(1.0);\n #endif\n #include \n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include \n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n #include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_ENVMAP\n #include \n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4(diffuse, opacity);\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n reflectedLight.indirectDiffuse = getAmbientLightIrradiance(ambientLightColor);\n #ifdef DOUBLE_SIDED\n reflectedLight.indirectDiffuse += (gl_FrontFacing) ? vIndirectFront : vIndirectBack;\n #else\n reflectedLight.indirectDiffuse += vIndirectFront;\n #endif\n #include \n reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert(diffuseColor.rgb);\n #ifdef DOUBLE_SIDED\n reflectedLight.directDiffuse = (gl_FrontFacing) ? vLightFront : vLightBack;\n #else\n reflectedLight.directDiffuse = vLightFront;\n #endif\n reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert(diffuseColor.rgb) * getShadowMask();\n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n #include \n #include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n varying vec3 vLightBack;\n varying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4(diffuse, opacity);\n #include \n #include \n #include \n #include \n #include \n #include \n vec3 viewDir = normalize(vViewPosition);\n vec3 x = normalize(vec3(viewDir.z, 0.0, - viewDir.x));\n vec3 y = cross(viewDir, x);\n vec2 uv = vec2(dot(x, normal), dot(y, normal)) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D(matcap, uv);\n matcapColor = matcapTexelToLinear(matcapColor);\n #else\n vec4 matcapColor = vec4(1.0);\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n #include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #ifndef FLAT_SHADED\n vNormal = normalize(transformedNormal);\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4(diffuse, opacity);\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include \n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n #include \n #include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#ifndef FLAT_SHADED\n vNormal = normalize(transformedNormal);\n#endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n uniform float clearCoat;\n uniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 diffuseColor = vec4(diffuse, opacity);\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #define ORIGINAL_NORMAL originalNormal\n #include \n #include \n #include \n #undef ORIGINAL_NORMAL\n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n #include \n #include \n}",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#ifndef FLAT_SHADED\n vNormal = normalize(transformedNormal);\n#endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || (defined(USE_NORMALMAP) && !defined(OBJECTSPACE_NORMALMAP))\n varying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n gl_FragColor = vec4(packNormalToRGB(normal), opacity);\n}",normal_vert:"#define NORMAL\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || (defined(USE_NORMALMAP) && !defined(OBJECTSPACE_NORMALMAP))\n varying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n#ifndef FLAT_SHADED\n vNormal = normalize(transformedNormal);\n#endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || (defined(USE_NORMALMAP) && !defined(OBJECTSPACE_NORMALMAP))\n vViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec3 outgoingLight = vec3(0.0);\n vec4 diffuseColor = vec4(diffuse, opacity);\n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n #include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = (projectionMatrix[2][3] == - 1.0);\n if (isPerspective) gl_PointSize *= (scale / - mvPosition.z);\n #endif\n #include \n #include \n #include \n #include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n gl_FragColor = vec4(color, opacity * (1.0 - getShadowMask()));\n #include \n}",shadow_vert:"#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec3 outgoingLight = vec3(0.0);\n vec4 diffuseColor = vec4(diffuse, opacity);\n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 mvPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\n vec2 scale;\n scale.x = length(vec3(modelMatrix[0].x, modelMatrix[0].y, modelMatrix[0].z));\n scale.y = length(vec3(modelMatrix[1].x, modelMatrix[1].y, modelMatrix[1].z));\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = (projectionMatrix[2][3] == - 1.0);\n if (isPerspective) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = (position.xy - (center - vec2(0.5))) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #include \n}",equicube_frag:"uniform sampler2D tEquirect;\nuniform int faceIndex;\nuniform bool invertU;\nuniform float offsetU;\nvarying vec2 vUv;\n#include \nvoid main() {\n vec3 direction;\n vec2 uv = vUv * 2.0 - 1.0;\n if (faceIndex==0) {\n direction = vec3(1.0, -uv.y, -uv.x);\n } else if (faceIndex==1) {\n direction = vec3(-1.0, -uv.y, uv.x);\n } else if (faceIndex==2) {\n direction = vec3(uv.x, 1.0, uv.y);\n } else if (faceIndex==3) {\n direction = vec3(uv.x, -1.0, -uv.y);\n } else if (faceIndex==4) {\n direction = vec3(uv.x, -uv.y, 1.0);\n } else {\n direction = vec3(-uv.x, -uv.y, -1.0);\n }\n direction = normalize(direction);\n vec2 sampleUV;\n sampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\n if (invertU) {\n sampleUV.x = 1.0 - sampleUV.x;\n }\n \n sampleUV.x += offsetU;\n gl_FragColor = texture2D(tEquirect, sampleUV);\n}",equicube_vert:"varying vec2 vUv;\n#include \nvoid main() {\n vUv = uv;\n #include \n #include \n}",mask_frag:"#define MASK\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nuniform mat4 projectionMatrix;\nuniform float opacity;\nuniform sampler2D depthTexture;\nuniform vec2 cameraNearFar;\nvarying vec3 vViewPosition;\nvarying vec4 projTexCoord;\nvoid main() {\n #include \n vec4 diffuseColor = vec4(1.0);\n diffuseColor.a = opacity;\n #include \n #include \n #include \n #include \n float depth = unpackRGBAToDepth(texture2DProj(depthTexture, projTexCoord));\n float viewZ;\n if (isOrtho(projectionMatrix))\n viewZ = -orthographicDepthToViewZ(depth,\n cameraNearFar.x, cameraNearFar.y);\n else\n viewZ = -perspectiveDepthToViewZ(depth,\n cameraNearFar.x, cameraNearFar.y);\n float depthTest = (vViewPosition.z > viewZ) ? 1.0 : 0.0;\n gl_FragColor = vec4(0.0, depthTest, 1.0, 0.0);\n}",mask_vert:"#define MASK\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nuniform mat4 textureMatrix;\nvarying vec3 vViewPosition;\nvarying vec4 projTexCoord;\nvoid main() {\n #include \n #include \n#ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n#endif\n #include \n #include \n #include \n #include \n #include \n vViewPosition = -mvPosition.xyz;\n #include \n projTexCoord = textureMatrix * worldPosition;\n #include \n #include \n}",meshnode_frag:"#define NODE\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(NODE_GEOMETRY) || defined(NODE_NEW_GEOMETRY) || defined(NODE_VECT_TRANSFORM) || defined(NODE_TEX_COORD) || defined(NODE_MATERIAL) || defined(NODE_MATERIAL_EXT) || defined(NODE_NORMAL_MAP) || defined(NODE_LAYER_WEIGHT) || defined(NODE_FRESNEL) || defined(NODE_BUMP) || defined(NODE_BSDF_GLASS) || defined(NODE_BSDF_PRINCIPLED)\nuniform mat4 invViewMatrix;\n#endif\n#if defined(NODE_GEOMETRY) || defined(NODE_NEW_GEOMETRY) || defined(NODE_LAYER_WEIGHT) || defined(NODE_FRESNEL) || defined(NODE_BSDF_GLASS) || defined(NODE_BSDF_PRINCIPLED)\nuniform mat4 projectionMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM) || defined(NODE_TEX_COORD)\nuniform mat4 modelMatrix;\nuniform mat4 invModelMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM) || defined(NODE_NORMAL_MAP) || defined(NODE_NORMAL_BUMP_MAX)\nuniform mat4 modelViewMatrix;\n#endif\n#if defined(NODE_REFLECT_REFRACT_MAX) || defined(NODE_BITMAP_ENV_MAX) || defined(NODE_BUMP) || defined(NODE_PHY_SUN_SKY_ENV_MAX)\nvarying vec3 vWorldPosition;\n#endif\n#include \n#include \nvoid main() {\n #include \n #include \n vec4 outgoingLight = vec4(0.0);\n #include \n #include \n #include \n #if WORLD_NODES == 1\n outgoingLight.a = 1.0;\n #endif\n #ifdef ALPHATEST\n if (outgoingLight.a < ALPHATEST)\n discard;\n else\n outgoingLight.a = 1.0;\n #endif\n gl_FragColor = vec4(outgoingLight);\n #include \n #include \n #include \n #include \n #include \n}",meshnode_vert:"#define NODE\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(NODE_REFLECT_REFRACT_MAX) || defined(NODE_BITMAP_ENV_MAX) || defined(NODE_BUMP) || defined(NODE_PHY_SUN_SKY_ENV_MAX) || defined(NODE_PHY_SUN_SKY_ENV_MAX)\nvarying vec3 vWorldPosition;\n#endif\n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#ifndef FLAT_SHADED\n vNormal = normalize(transformedNormal);\n#endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n#if defined(NODE_REFLECT_REFRACT_MAX) || defined(NODE_BITMAP_ENV_MAX) || defined(NODE_BUMP) || defined(NODE_PHY_SUN_SKY_ENV_MAX)\n vWorldPosition = worldPosition.xyz;\n#endif\n #include \n}",normalmap_pars_vertex:"#if defined(USE_TANGENT)\nvarying vec4 vTangent;\n#endif",normalmap_vertex:"#if defined(USE_TANGENT)\n vTangent = tangent;\n#endif",lights_node_pars_fragment:"\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct NodeMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n vec3 refractionColor;\n float refractionRoughness;\n float refractionIOR;\n #ifdef PHYSICAL\n float specularRoughness;\n #ifndef STANDARD\n float clearCoat;\n float clearCoatRoughness;\n #endif\n #else\n float diffuseIntensity;\n float specularIntensity;\n float specularHardness;\n #endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n#define BLENDER_SPECULAR_COEFFICIENT 0.08\nfloat shadeSpecPhong(vec3 normal, vec3 lightDir, vec3 viewDir, float hard)\n{\n float specFac;\n vec3 h = normalize(lightDir + viewDir);\n float rslt = max(dot(h, normal), 0.0);\n specFac = pow(rslt, hard);\n return specFac;\n}\nfloat shadeSpecHemi(vec3 normal, vec3 lightDir, vec3 viewDir, float hard)\n{\n float specFac;\n vec3 h = normalize(lightDir + viewDir);\n float rslt = 0.5 * max(dot(h, normal), 0.0) + 0.5;\n specFac = pow(rslt, hard);\n return specFac;\n}\nfloat clearCoatDHRApprox(const in float roughness, const in float dotNL) {\n return DEFAULT_SPECULAR_COEFFICIENT + (1.0 - DEFAULT_SPECULAR_COEFFICIENT) * (pow(1.0 - dotNL, 5.0) * pow(1.0 - roughness, 2.0));\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Node(const in RectAreaLight rectAreaLight,\n const in GeometricContext geometry, const in NodeMaterial material,\n inout ReflectedLight reflectedLight) {\n vec3 normal = geometry.normal;\n vec3 viewDir = geometry.viewDir;\n vec3 position = geometry.position;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.specularRoughness;\n vec3 rectCoords[4];\n rectCoords[0] = lightPos - halfWidth - halfHeight;\n rectCoords[1] = lightPos + halfWidth - halfHeight;\n rectCoords[2] = lightPos + halfWidth + halfHeight;\n rectCoords[3] = lightPos - halfWidth + halfHeight;\n vec2 uv = LTC_Uv(normal, viewDir, roughness);\n vec4 t1 = texture2D(ltc_1, uv);\n vec4 t2 = texture2D(ltc_2, uv);\n mat3 mInv = mat3(\n vec3(t1.x, 0, t1.y),\n vec3( 0, 1, 0),\n vec3(t1.z, 0, t1.w)\n );\n vec3 fresnel = (material.specularColor * t2.x + (vec3(1.0) - material.specularColor) * t2.y);\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate(normal, viewDir, position, mInv, rectCoords);\n reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate(normal, viewDir, position, mat3(1.0), rectCoords);\n }\n#endif\nvoid RE_Direct_Node(const in IncidentLight directLight,\n const in GeometricContext geometry, const in NodeMaterial material,\n inout ReflectedLight reflectedLight) {\n float dotNL = saturate(dot(geometry.normal, directLight.direction));\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n #ifdef PHYSICAL\n #ifndef STANDARD\n float coatDotNL = saturate(dot(geometry.coatNormal, directLight.direction));\n vec3 coatIrradiance = coatDotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n coatIrradiance *= PI;\n #endif\n #endif\n #ifndef STANDARD\n float clearCoatDHR = material.clearCoat * clearCoatDHRApprox(material.clearCoatRoughness, coatDotNL);\n #else\n float clearCoatDHR = 0.0;\n #endif\n reflectedLight.directSpecular += (1.0 - clearCoatDHR) * irradiance\n * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.normal,\n material.specularColor, material.specularRoughness);\n reflectedLight.directDiffuse += (1.0 - clearCoatDHR) * irradiance\n * BRDF_Diffuse_Lambert(material.diffuseColor);\n #ifndef STANDARD\n reflectedLight.directSpecular += coatIrradiance * material.clearCoat\n * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.coatNormal,\n vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearCoatRoughness);\n #endif\n #else\n reflectedLight.directDiffuse += irradiance * material.diffuseIntensity * BRDF_Diffuse_Lambert(material.diffuseColor);\n reflectedLight.directSpecular += material.specularIntensity *\n shadeSpecPhong(geometry.normal, directLight.direction,\n geometry.viewDir, material.specularHardness) *\n directLight.color * material.specularColor;\n #endif\n}\nvoid RE_IndirectDiffuse_Node(const in vec3 irradiance, const in\n GeometricContext geometry, const in NodeMaterial material,\n inout ReflectedLight reflectedLight) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#ifdef PHYSICAL\n void RE_IndirectSpecular_Node(const in vec3 radiance, const in vec3 clearCoatRadiance,\n const in GeometricContext geometry, const in NodeMaterial material,\n inout ReflectedLight reflectedLight) {\n #ifndef STANDARD\n float coatDotNL = saturate(dot(geometry.coatNormal, geometry.viewDir));\n float clearCoatDHR = material.clearCoat * clearCoatDHRApprox(\n material.clearCoatRoughness, coatDotNL);\n #else\n float clearCoatDHR = 0.0;\n #endif\n #ifdef MT_BLENDER\n vec3 specEnv = BRDF_Specular_GGX_Environment(geometry,\n material.specularColor, material.specularRoughness, 0);\n #elif defined(MT_MAX)\n float alphaEnv = pow2(pow2(material.specularRoughness));\n vec3 specEnv = material.specularColor / (1.0 - alphaEnv + PI * alphaEnv);\n #else\n vec3 specEnv = vec3(1.0);\n #endif\n reflectedLight.indirectSpecular += (1.0 - clearCoatDHR) * radiance * specEnv;\n #ifndef STANDARD\n #ifdef MT_BLENDER\n vec3 specEnvCC = BRDF_Specular_GGX_Environment(geometry,\n vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearCoatRoughness, 1);\n #elif defined(MT_MAX)\n vec3 specEnvCC = BRDF_Specular_GGX_Environment(geometry,\n vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearCoatRoughness, 1);\n #else\n vec3 specEnvCC = vec3(1.0);\n #endif\n reflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * specEnvCC;\n #endif\n }\n#else\n #if defined(BLENDER_LIGHTS) && NUM_HEMI_LIGHTS > 0\n void RE_HemiSpec_Blender(const in HemisphereLight hemiLight,\n const in GeometricContext geometry, const in NodeMaterial material,\n inout ReflectedLight reflectedLight)\n {\n reflectedLight.indirectSpecular += material.specularIntensity *\n shadeSpecHemi(geometry.normal, hemiLight.direction,\n geometry.viewDir, material.specularHardness) *\n hemiLight.skyColor * material.specularColor;\n }\n #endif\n#endif\nvoid RE_Refraction_Node(const vec3 refraction, const NodeMaterial material,\n inout vec3 refractedLight) {\n refractedLight += refraction * material.refractionColor;\n}\n#ifdef MT_BLENDER\n #define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness)\n #define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness)\n#elif defined(MT_MAX)\n #define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness * exp(0.35*(1.0-pow2(material.specularRoughness))))\n #define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness * exp(0.35*(1.0-pow2(material.refractionRoughness))))\n#else\n #define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.specularRoughness)\n #define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness)\n#endif\n#define Material_ClearCoat_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.clearCoatRoughness)\nfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\n return saturate(pow(dotNV + ambientOcclusion, exp2(- 16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n}\n#define RE_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_Direct_RectArea RE_Direct_RectArea_Node\n#ifdef PHYSICAL\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#endif\n#define RE_Refraction RE_Refraction_Node",node_common_frag:"#define LUMENS_PER_WATT 683.0\n#define MAX_ENV_COORDS_DIR 0\n#define MAX_ENV_COORDS_REFLECT 1\n#define MAX_ENV_COORDS_REFRACT 2\nvec4 nodeTexelToLinear(in vec4 color, in int sourceType) {\n if (sourceType == 1)\n return sRGBToLinear(color);\n else if (sourceType == 2)\n return RGBEToLinear(color);\n else\n return color;\n}\n#if defined(NODE_COMBHSV) || defined(NODE_SEPHSV) || defined(NODE_HUE_SAT) || defined(NODE_MIX_RGB_HSV) || defined(NODE_COLOR_CORRECTION_MAX) || defined(NODE_COMPOSITE_LAYER_MAX)\nvoid hsvToRGB(vec4 hsv, out vec4 outCol)\n{\n float i, f, p, q, t, h, s, v;\n vec3 rgb;\n h = hsv[0];\n s = hsv[1];\n v = hsv[2];\n if (s == 0.0)\n rgb = vec3(v, v, v);\n else {\n if (h == 1.0)\n h = 0.0;\n h *= 6.0;\n i = floor(h);\n f = h - i;\n rgb = vec3(f, f, f);\n p = v * (1.0 - s);\n q = v * (1.0 - (s * f));\n t = v * (1.0 - (s * (1.0 - f)));\n if (i == 0.0)\n rgb = vec3(v, t, p);\n else if (i == 1.0)\n rgb = vec3(q, v, p);\n else if (i == 2.0)\n rgb = vec3(p, v, t);\n else if (i == 3.0)\n rgb = vec3(p, q, v);\n else if (i == 4.0)\n rgb = vec3(t, p, v);\n else\n rgb = vec3(v, p, q);\n }\n outCol = vec4(rgb, hsv.w);\n}\nvoid rgbToHSV(vec4 rgb, out vec4 outCol)\n{\n float cmax, cmin, h, s, v, cdelta;\n vec3 c;\n cmax = max(rgb[0], max(rgb[1], rgb[2]));\n cmin = min(rgb[0], min(rgb[1], rgb[2]));\n cdelta = cmax - cmin;\n v = cmax;\n if (cmax != 0.0)\n s = cdelta / cmax;\n else {\n s = 0.0;\n h = 0.0;\n }\n if (s == 0.0)\n h = 0.0;\n else {\n c = (vec3(cmax, cmax, cmax) - rgb.xyz) / cdelta;\n if (rgb.x == cmax) h = c[2] - c[1];\n else if (rgb.y == cmax) h = 2.0 + c[0] - c[2];\n else h = 4.0 + c[1] - c[0];\n h /= 6.0;\n if (h < 0.0)\n h += 1.0;\n }\n outCol = vec4(h, s, v, rgb.w);\n}\n#endif\nbool isPerspective(const mat4 projMatrix)\n{\n return (projMatrix[3][3] == 0.0);\n}\n#if defined(NODE_REFLECT_REFRACT_MAX) || defined(NODE_BITMAP_ENV_MAX)\nvec4 sampleEquirectangular(sampler2D map, vec3 reflectVec, mat3 uvTransform, int encoding)\n{\n reflectVec = normalize(reflectVec);\n vec2 sampleUV;\n sampleUV.y = asin(clamp(reflectVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n sampleUV.x = atan(reflectVec.x, reflectVec.z) * RECIPROCAL_PI2 + 0.5;\n sampleUV.y *= -1.0;\n const float seamWidth = 0.15;\n const float seamBiasFactor = -10.0;\n float seam = max(0.0, 1.0 - abs (reflectVec.x) / seamWidth) *\n clamp (1.0 - reflectVec.z / seamWidth, 0.0, 1.0);\n sampleUV = (uvTransform * vec3(sampleUV, 1.0)).xy;\n vec4 color = texture2D(map, sampleUV, seamBiasFactor * seam);\n color = nodeTexelToLinear(color, encoding);\n return color;\n}\n#endif\n#if defined(NODE_FRESNEL) || defined(NODE_LAYER_WEIGHT) || defined(NODE_FALLOFF_MAX) || defined(NODE_BSDF_GLASS) || defined(NODE_BSDF_PRINCIPLED)\nfloat fresnelReflection(const vec3 dir, const vec3 normal, const float ior) {\n float cosTheta = clamp(abs(dot(dir, normal)), -1.0, 1.0);\n float gSquared = pow2(ior) + pow2(cosTheta) - 1.0;\n if (gSquared < 0.0) return 1.0;\n float g = sqrt(gSquared);\n return 0.5 * pow2((g - cosTheta) / (g + cosTheta))\n * (1.0 + pow2(\n ((g + cosTheta) * cosTheta - 1.0) /\n ((g - cosTheta) * cosTheta + 1.0)\n ));\n}\n#endif\n#if defined(NODE_BITMAP_MAX) || defined(NODE_BITMAP_ENV_MAX)\nmat3 calcUvTransform(float uOffset, float vOffset, float uTiling, float vTiling, float wAngle)\n{\n if (abs(uOffset) < EPSILON && abs(vOffset) < EPSILON &&\n (abs(uTiling - 1.0)) < EPSILON && (abs(vTiling - 1.0)) < EPSILON &&\n abs(wAngle) < EPSILON)\n return mat3(1.0);\n vOffset = -vOffset;\n float sx = uTiling;\n float sy = vTiling;\n float tx = -uOffset;\n float ty = -vOffset;\n float cx = uOffset + 0.5;\n float cy = vOffset + 0.5;\n float c = cos(wAngle);\n float s = sin(wAngle);\n return mat3(sx * c, -sy * s, 0.0,\n sx * s, sy * c, 0.0,\n -sx * (c * cx + s * cy) + cx + tx, -sy * (- s * cx + c * cy) + cy + ty, 1.0);\n}\n#endif\n#if defined(NODE_TEX_NOISE) || defined(NODE_TEX_WAVE)\n#define NOISE_AMP_HACK 0.75\n#define NOISE_BLENDER_MEAN 0.78\n#define NOISE_SCALE_HACK 0.5\n#define noiseModulo(x) (x - floor(x * (1.0 / 289.0)) * 289.0)\nvec4 noisePermute(vec4 x) {\n return noiseModulo(((x * 34.0) + 1.0) * x);\n}\nvec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n}\nfloat noisePerlin(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n i = noiseModulo(i);\n vec4 p = noisePermute(noisePermute(noisePermute(i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0)) + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n float n_ = 0.142857142857;\n vec3 ns = n_ * D.wyz - D.xzx;\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1),\n dot(p2, x2), dot(p3, x3)));\n}\nfloat noiseBlender(vec3 p) {\n return 0.5 * NOISE_AMP_HACK * (noisePerlin(NOISE_SCALE_HACK * vec3(p.x, p.y, p.z))) + 0.5;\n}\nfloat noiseSmooth(vec3 p, float octaveLenPerPixel, float falloffFactor,\n float dispersionFactor) {\n float mixFac = mix(1.0, smoothstep(0.0, 1.0, octaveLenPerPixel) * falloffFactor,\n dispersionFactor);\n return mix(noiseBlender(p), NOISE_BLENDER_MEAN, mixFac);\n}\n#define MAX_OCTAVES_NUM 16\nfloat noiseTurbulence(vec3 p, float octaves, float octaveLenPerPixel,\n float falloffFactor, float dispersionFactor) {\n float fscale = 1.0;\n float amp = 1.0;\n float sum = 0.0;\n octaves = clamp(octaves, 0.0, 16.0);\n int octavesInt = int(octaves);\n for (int i = 0; i <= MAX_OCTAVES_NUM; i++) {\n if (i > octavesInt) break;\n float t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\n dispersionFactor);\n sum += t * amp;\n amp *= 0.5;\n fscale *= 2.0;\n octaveLenPerPixel *= 2.0;\n }\n float octavesFrac = fract(octaves);\n float octavesCoeff = pow(2.0, float(octavesInt));\n if (octavesFrac != 0.0) {\n float t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\n dispersionFactor);\n float sum2 = sum + t * amp;\n sum *= octavesCoeff / (2.0 * octavesCoeff - 1.0);\n sum2 *= 2.0 * octavesCoeff / (4.0 * octavesCoeff - 1.0);\n return mix(sum, sum2, octavesFrac);\n } else {\n return sum * octavesCoeff / (2.0 * octavesCoeff - 1.0);\n }\n}\n#endif",node_add_shader_frag:"void node_add_shader(vec4 color1, vec4 color2, out vec4 outColor) {\n outColor.rgb = color1.rgb + color2.rgb;\n outColor.a = clamp(color1.a + color2.a, 0.0, 1.0);\n}",node_ambient_occlusion_frag:"void node_ambient_occlusion(vec4 color, out vec4 outColor)\n{\n outColor = color;\n}",node_attribute_frag:"void node_attribute(\n vec3 paramAttr,\n out vec4 outColor, out vec3 outVector, out float outFac)\n{\n outColor = vec4(paramAttr, 1.0);\n outVector = paramAttr;\n outFac = average(paramAttr);\n}",node_background_frag:"void node_background(vec4 color, float strength, out vec4 outColor)\n{\n outColor = strength * color;\n}",node_blackbody_frag:"void node_blackbody(float temp, out vec4 outColor)\n{\n outColor = vec4(0.0);\n}",node_brightcontrast_frag:"\nvoid node_brightcontrast(vec4 color, float bright, float contrast, out vec4 outColor)\n{\n float bminc = bright - contrast * 0.5;\n outColor.r = max((1.0 + contrast) * color.r + bminc, 0.0);\n outColor.g = max((1.0 + contrast) * color.g + bminc, 0.0);\n outColor.b = max((1.0 + contrast) * color.b + bminc, 0.0);\n outColor.a = color.a;\n}",node_bsdf_anisotropic_frag:"void node_bsdf_anisotropic(\n vec4 color, float roughness, float anisotropy, float rotation, vec3 normal, vec3 tangent,\n out vec4 outColor)\n{\n outColor = color;\n}",node_bsdf_diffuse_frag:"\nvoid node_bsdf_diffuse(\n vec3 originalNormal,\n vec4 color, float roughness, vec3 normal,\n out vec4 outColor) {\n normal = vec3(normal[0], normal[2], -normal[1]);\n normal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\n NodeMaterial material;\n material.diffuseColor = color.rgb;\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #define ORIGINAL_NORMAL originalNormal\n #include \n #include \n #include \n #undef ORIGINAL_NORMAL\n outColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, 1.0);\n}",node_bsdf_glass_frag:"void node_bsdf_glass(\n vec3 originalNormal,\n vec4 color, float roughness, float ior, vec3 normal,\n out vec4 outColor) {\n normal = swizzleUpY(normal);\n vec3 normalWorld = normal;\n normal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\n NodeMaterial material;\n material.specularColor = color.rgb;\n material.specularRoughness = clamp(roughness, 0.04, 1.0);\n material.refractionColor = color.rgb;\n material.refractionIOR = ior;\n material.refractionRoughness = pow2(roughness);\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0),\n vec3(0.0), vec3(0.0));\n #define ORIGINAL_NORMAL originalNormal\n #define USE_REFRACTED_LIGHT\n vec3 refractedLight = vec3(0.0);\n #include \n #include \n #include \n #undef ORIGINAL_NORMAL\n #undef USE_REFRACTED_LIGHT\n vec3 viewWorld;\n if (isPerspective(projectionMatrix))\n viewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\n else\n viewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n viewWorld = normalize(viewWorld);\n float fresnel = fresnelReflection(viewWorld, normalWorld, ior);\n outColor = vec4(mix(refractedLight, reflectedLight.directSpecular\n + reflectedLight.indirectSpecular, fresnel), 1.0);\n}",node_bsdf_glossy_frag:"\nvoid node_bsdf_glossy(\n vec3 originalNormal,\n vec4 color, float roughness, vec3 normal,\n out vec4 outColor) {\n normal = vec3(normal[0], normal[2], -normal[1]);\n normal = normalize((viewMatrix * vec4(normal.xyz, 0.0)).xyz);\n NodeMaterial material;\n material.specularColor = vec3(1.0);\n material.specularRoughness = clamp(roughness, 0.04, 1.0);\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #define ORIGINAL_NORMAL originalNormal\n #include \n #include \n #include \n #undef ORIGINAL_NORMAL\n outColor = vec4(color.rgb * (reflectedLight.directSpecular\n + reflectedLight.indirectSpecular), 1.0);\n}",node_bsdf_hair_frag:"void node_bsdf_hair(vec4 color, float offset, float roughnessU, float roughnessV, vec3 tangent, out vec4 outColor)\n{\n outColor = color;\n}",node_bsdf_principled_frag:"\nvec3 tintFromColor(vec3 color) {\n\tfloat lum = dot(color, vec3(0.3, 0.6, 0.1));\n\treturn lum > 0.0 ? color / lum : vec3(1.0);\n}\nvec3 fresnelBlend(float ior, float fresnel, vec3 fresnelColor) {\n float fresnelFac = fresnelReflection(vec3(1.0, 0.0, 0.0), vec3(1.0, 0.0, 0.0), ior);\n\tfloat mixFac = saturate((fresnel - fresnelFac) / max(1e-8, 1.0 - fresnelFac));\n\treturn mix(fresnelColor, vec3(1.0), mixFac);\n}\n#define LOW_SPECULAR_FROM 0.00016\n#define LOW_SPECULAR_TO 0.0004\n#define SPEC_SLOPE_COEFF_FROM 2.4\n#define SPEC_SLOPE_COEFF_TO 2.8\nvoid node_bsdf_principled(\n vec3 originalNormal,\n vec4 baseColor, float subsurface, vec3 subsurfaceRadius, vec4 subsurfaceColor,\n float metallic, float specular, float specularTint, float roughness,\n float anisotropic, float anisotropicRotation, float sheen, float sheenTint,\n float clearcoat, float clearcoatRoughness, float ior,\n float transmission, float transmissionRoughness,\n vec3 normal, vec3 clearcoatNormal, vec3 tangent,\n out vec4 outColor) {\n normal = vec3(normal[0], normal[2], -normal[1]);\n vec3 normalWorld = normal;\n normal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\n NodeMaterial material;\n metallic = clamp(metallic, 0.0, 1.0);\n float dielectric = 1.0 - metallic;\n transmission *= dielectric;\n material.diffuseColor = baseColor.rgb * dielectric;\n #ifdef STANDARD\n float dielReflCoeff = BLENDER_SPECULAR_COEFFICIENT;\n #else\n float dielReflCoeff = MAXIMUM_SPECULAR_COEFFICIENT * pow2(reflectivity);\n material.clearCoat = saturate(clearcoat);\n material.clearCoatRoughness = clamp(clearcoatRoughness, 0.04, 1.0);\n #endif\n vec3 dielRefl = dielReflCoeff * specular\n * mix(vec3(1.0), tintFromColor(baseColor.rgb), specularTint);\n material.specularColor = mix(dielRefl, baseColor.rgb, metallic);\n material.specularRoughness = clamp(roughness, 0.04, 1.0);\n vec3 viewWorld;\n if (isPerspective(projectionMatrix))\n viewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\n else\n viewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n viewWorld = normalize(viewWorld);\n float fresnel = fresnelReflection(viewWorld, normalWorld, ior);\n vec3 fresnelColor = mix(vec3(1.0), baseColor.rgb, specularTint);\n material.specularColor = mix(material.specularColor,\n fresnelBlend(ior, fresnel, fresnelColor) * fresnel, transmission);\n material.refractionColor = baseColor.rgb;\n material.refractionIOR = ior;\n material.refractionRoughness = pow2(roughness);\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #define ORIGINAL_NORMAL originalNormal\n #define USE_REFRACTED_LIGHT\n vec3 refractedLight = vec3(0.0);\n #include \n #include \n #include \n #undef ORIGINAL_NORMAL\n #undef USE_REFRACTED_LIGHT\n vec3 spec = material.specularColor;\n vec3 spec2 = spec * spec;\n vec3 spec3 = spec2 * spec;\n vec3 lowSpecCoeff = clamp(spec, LOW_SPECULAR_FROM, LOW_SPECULAR_TO);\n vec3 lowSpecMixFac = (lowSpecCoeff - LOW_SPECULAR_FROM) / (LOW_SPECULAR_TO - LOW_SPECULAR_FROM);\n vec3 lowSpecSlopeCoeff = mix(vec3(SPEC_SLOPE_COEFF_FROM), vec3(SPEC_SLOPE_COEFF_TO),\n lowSpecMixFac);\n vec3 specSlope = pow(spec, 1.0 / (lowSpecSlopeCoeff + 7e2 * spec + 2e3 * spec2 + 1e5 * spec3));\n float specCoeffBlender = max(max(specSlope.x, specSlope.y), specSlope.z);\n vec3 outColor3 = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * (1.0 - transmission)\n + reflectedLight.directSpecular + specCoeffBlender * reflectedLight.indirectSpecular\n + refractedLight * transmission * (1.0 - fresnel);\n outColor = vec4(outColor3, saturate(1.0 - transmission));\n}",node_bsdf_refraction_frag:"#define BSDF_REFRACTION_GGX 0\n#define BSDF_REFRACTION_BECKMANN 1\n#define BSDF_REFRACTION_SHARP 2\nvoid node_bsdf_refraction(\n vec3 originalNormal, const int distribution,\n vec4 color, float roughness, float ior, vec3 normal,\n out vec4 outColor) {\n normal = swizzleUpY(normal);\n normal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\n NodeMaterial material;\n material.refractionColor = color.rgb;\n material.refractionIOR = ior;\n if (distribution == BSDF_REFRACTION_SHARP) {\n material.refractionRoughness = 0.0;\n } else {\n material.refractionRoughness = pow2(roughness);\n }\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #define ORIGINAL_NORMAL originalNormal\n #define USE_REFRACTED_LIGHT\n vec3 refractedLight = vec3(0.0);\n #include \n #include \n #include \n #undef ORIGINAL_NORMAL\n #undef USE_REFRACTED_LIGHT\n outColor = vec4(refractedLight, 1.0);\n}",node_bsdf_toon_frag:"void node_bsdf_toon(\n vec4 color, float size, float smooth, vec3 normal, \n out vec4 outColor)\n{\n outColor = color;\n}",node_bsdf_translucent_frag:"void node_bsdf_translucent(vec4 color, vec3 normal, out vec4 outColor)\n{\n outColor = color;\n}",node_bsdf_transparent_frag:"\nvoid node_bsdf_transparent(vec4 color, out vec4 outColor)\n{\n float alpha = saturate(1.0 - dot(color.rgb, vec3(0.333333)));\n outColor = vec4(0.0, 0.0, 0.0, alpha);\n}",node_bsdf_velvet_frag:"void node_bsdf_velvet(vec4 color, float sigma, vec3 normal, out vec4 outColor)\n{\n outColor = color;\n}",node_bump_frag:"\nvoid node_bump(\n const int invert,\n float strength, float bumpDist, float height, vec3 normal,\n out vec3 outNormal)\n{\n vec3 position = swizzleUpZ(vWorldPosition);\n if (invert == 1)\n bumpDist *= -1.0;\n vec3 dPdx = dFdx(position);\n vec3 dPdy = dFdy(position);\n float dHdx = dFdx(height);\n float dHdy = dFdy(height);\n vec3 tanX = cross(dPdy, normal);\n vec3 tanY = cross(normal, dPdx);\n vec3 surfaceGrad = dHdx * tanX + dHdy * tanY;\n float dotPosTanX = dot(dPdx, tanX);\n outNormal = normalize(normal * abs(dotPosTanX) - surfaceGrad * bumpDist * sign(dotPosTanX));\n outNormal = normalize(mix(normal, outNormal, max(0.0, strength)));\n}",node_camera_frag:"\nvoid node_camera(\n vec3 viewPos, const int invCamZ,\n out vec3 outViewVector, out float outViewZDepth, out float outViewDistance)\n{\n viewPos = -viewPos;\n if (invCamZ == 1)\n viewPos.z = -viewPos.z;\n outViewVector = normalize(viewPos);\n outViewZDepth = abs(viewPos.z);\n outViewDistance = length(viewPos);\n}",node_combhsv_frag:"\nvoid node_combhsv(float h, float s, float v, out vec4 col)\n{\n hsvToRGB(vec4(h, s, v, 1.0), col);\n}",node_combrgb_frag:"\nvoid node_combrgb(float r, float g, float b, out vec4 col)\n{\n col = vec4(r, g, b, 1.0);\n}",node_combxyz_frag:"void node_combxyz(float x, float y, float z, out vec3 outVector)\n{\n outVector = vec3(x, y, z);\n}",node_curve_rgb_frag:"\nvoid node_curve_rgb(sampler2D curveData, float fac, vec4 col, out vec4 outCol)\n{\n outCol.r = texture2D(curveData, vec2(texture2D(curveData, vec2(col.r, 0.0)).a, 0.0)).r;\n outCol.g = texture2D(curveData, vec2(texture2D(curveData, vec2(col.g, 0.0)).a, 0.0)).g;\n outCol.b = texture2D(curveData, vec2(texture2D(curveData, vec2(col.b, 0.0)).a, 0.0)).b;\n outCol = mix(col, outCol, fac);\n outCol.a = col.a;\n}",node_curve_vec_frag:"\nvoid node_curve_vec(sampler2D curveData, float fac, vec3 vec, out vec3 outVec)\n{\n outVec.x = texture2D(curveData, vec2((vec.x + 1.0) * 0.5, 0.0)).x;\n outVec.y = texture2D(curveData, vec2((vec.y + 1.0) * 0.5, 0.0)).y;\n outVec.z = texture2D(curveData, vec2((vec.z + 1.0) * 0.5, 0.0)).z;\n outVec = mix(vec, outVec * 2.0 - vec3(1.0), fac);\n}",node_emission_frag:"\nvoid node_emission(vec4 color, float strength, out vec4 outColor)\n{\n outColor = strength * color;\n}",node_fresnel_frag:"void node_fresnel(vec3 viewPos, float IOR, vec3 normal, out float fac)\n{\n vec3 worldDir;\n if (isPerspective(projectionMatrix))\n worldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\n else\n worldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n \n worldDir = normalize(swizzleUpZ(worldDir));\n float eta = max(IOR, 0.00001);\n fac = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\n}",node_gamma_frag:"\nvoid node_gamma(vec4 col, float gamma, out vec4 outCol)\n{\n outCol = col;\n if (col.r > 0.0)\n outCol.r = powCompat(col.r, gamma);\n if (col.g > 0.0)\n outCol.g = powCompat(col.g, gamma);\n if (col.b > 0.0)\n outCol.b = powCompat(col.b, gamma);\n}",node_geometry_frag:"\nvoid node_geometry(\n vec3 viewPos, vec3 viewNorm, vec3 orcoIn, vec2 uvIn, vec4 vcolIn,\n out vec3 global, out vec3 local, out vec3 view, out vec3 orco, out vec3 uv,\n out vec3 normal, out vec4 vcol, out float vcolAlpha, out float frontBack)\n{\n local = -viewPos;\n view = (projectionMatrix[3][3] == 0.0) ? normalize(local) : vec3(0.0, 0.0, -1.0);\n global = (invViewMatrix * vec4(local, 1.0)).xyz;\n global = swizzleUpZ(global);\n orco = global;\n uvIn.y = 1.0 - uvIn.y;\n uv = vec3(uvIn * 2.0 - vec2(1.0, 1.0), 0.0);\n normal = normalize(invViewMatrix * vec4(viewNorm, 0.0)).rgb;\n normal = swizzleUpZ(normal);\n vcol = sRGBToLinear(vec4(vcolIn.rgb, 1.0));\n vcolAlpha = vcolIn.a;\n frontBack = (gl_FrontFacing) ? 1.0 : 0.0;\n}",node_gradient_ramp_max_frag:"#define GRAD_TYPE_4_CORNER 0\n#define GRAD_TYPE_BOX 1\n#define GRAD_TYPE_DIAGONAL 2\n#define GRAD_TYPE_LIGHTING 3\n#define GRAD_TYPE_LINEAR 4\n#define GRAD_TYPE_MAPPED 5\n#define GRAD_TYPE_NORMAL 6\n#define GRAD_TYPE_PONG 7\n#define GRAD_TYPE_RADIAL 8\n#define GRAD_TYPE_SPIRAL 9\n#define GRAD_TYPE_SWEEP 10\n#define GRAD_TYPE_TARTAN 11\nvoid node_gradient_ramp_max(\n sampler2D gradientData, int gradientType, vec2 uvIn, vec3 originalNormal,\n vec3 viewPos,\n vec4 sourceMap,\n out vec4 outCol)\n{\n float coord = uvIn.x;\n uvIn.y = 1.0 - uvIn.y;\n uvIn = fract(uvIn);\n if (gradientType == GRAD_TYPE_4_CORNER) {\n coord = pow(uvIn.x, 2.0);\n } else if (gradientType == GRAD_TYPE_BOX) {\n vec2 boxUv = abs(uvIn - vec2(0.5)) * 2.0;\n coord = max(boxUv.x, boxUv.y);\n } else if (gradientType == GRAD_TYPE_DIAGONAL) {\n coord = abs(uvIn.x - uvIn.y) * sqrt(2.0);\n } else if (gradientType == GRAD_TYPE_LIGHTING) {\n IncidentLight directLight;\n GeometricContext geometry;\n geometry.position = -viewPos;\n vec3 irr = vec3(0.0);\n #if (NUM_POINT_LIGHTS > 0)\n #pragma unroll_loop\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n getPointDirectLightIrradiance(pointLights[i], geometry, directLight);\n float dotNL = saturate(dot(originalNormal, directLight.direction));\n irr += dotNL * directLight.color;\n }\n #endif\n #if (NUM_SPOT_LIGHTS > 0)\n #pragma unroll_loop\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n getSpotDirectLightIrradiance(spotLights[i], geometry, directLight);\n float dotNL = saturate(dot(originalNormal, directLight.direction));\n irr += dotNL * directLight.color;\n }\n #endif\n #if (NUM_DIR_LIGHTS > 0)\n #pragma unroll_loop\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n getDirectionalDirectLightIrradiance(directionalLights[i], geometry, directLight);\n float dotNL = saturate(dot(originalNormal, directLight.direction));\n irr += dotNL * directLight.color;\n }\n #endif\n #if defined(PHYSICALLY_CORRECT_LIGHTS)\n irr /= PI;\n #endif\n vec3 ambIrr = getAmbientLightIrradiance(ambientLightColor);\n #if !defined(PHYSICALLY_CORRECT_LIGHTS)\n ambIrr /= PI;\n #endif\n irr += ambIrr;\n coord = (irr.x + irr.y + irr.z) / 3.0;\n } else if (gradientType == GRAD_TYPE_LINEAR) {\n coord = uvIn.x;\n } else if (gradientType == GRAD_TYPE_MAPPED) {\n coord = (sourceMap.x + sourceMap.y + sourceMap.z) / 3.0;\n } else if (gradientType == GRAD_TYPE_NORMAL) {\n float angle = acos(clamp(dot(originalNormal, normalize(viewPos)), -1.0, 1.0));\n float k = 100.0;\n coord = 1.0 - sin(pow2(k) - k * sqrt(pow2(k) - pow2(angle)));\n } else if (gradientType == GRAD_TYPE_PONG) {\n float y = min(uvIn.y, uvIn.x);\n float x = max(uvIn.y, uvIn.x);\n coord = y / x;\n } else if (gradientType == GRAD_TYPE_RADIAL) {\n coord = length(uvIn - vec2(0.5)) * 2.0;\n } else if (gradientType == GRAD_TYPE_SPIRAL) {\n vec2 uvSpiral = mat2(0.0, 1.0, -1.0, 0.0) * (uvIn - vec2(0.5));\n coord = atan(uvSpiral.y, uvSpiral.x) / PI2 + 0.5;\n } else if (gradientType == GRAD_TYPE_SWEEP) {\n coord = atan(uvIn.x, uvIn.y) / PI_HALF;\n } else if (gradientType == GRAD_TYPE_TARTAN) {\n vec2 uvTartan = abs(uvIn - vec2(0.5));\n coord = 1.0 - min(uvTartan.x, uvTartan.y) * 2.0;\n }\n outCol = texture2D(gradientData, vec2(coord, 0.0));\n}",node_hair_info_frag:"void node_hair_info(\n out float isStrand, out float intercept, out float thickness, out vec3 tangentNormal)\n{\n isStrand = 0.0;\n intercept = 0.0;\n thickness = 0.0;\n tangentNormal = vec3(0.0);\n}",node_holdout_frag:"void node_holdout(out vec4 outColor)\n{\n outColor = vec4(0.0);\n}",node_hue_sat_frag:"\nvoid node_hue_sat(float hue, float sat, float value, float fac, vec4 col, out vec4 outCol)\n{\n vec4 hsv;\n rgbToHSV(col, hsv);\n hsv[0] += (hue - 0.5);\n if (hsv[0] > 1.0) hsv[0] -= 1.0; else if (hsv[0] < 0.0) hsv[0] += 1.0;\n hsv[1] *= sat;\n if (hsv[1] > 1.0) hsv[1] = 1.0; else if (hsv[1] < 0.0) hsv[1] = 0.0;\n hsv[2] *= value;\n if (hsv[2] > 1.0) hsv[2] = 1.0; else if (hsv[2] < 0.0) hsv[2] = 0.0;\n hsvToRGB(hsv, outCol);\n outCol = mix(col, outCol, fac);\n}",node_invert_frag:"\nvoid node_invert(float fac, vec4 col, out vec4 outCol)\n{\n outCol.xyz = mix(col.xyz, vec3(1.0, 1.0, 1.0) - col.xyz, fac);\n outCol.w = col.w;\n}",node_lamp_frag:"\nvoid node_lamp(out vec4 outCol, out vec3 outLv, out float outDist, out vec4 outShadow, out float outVisibility)\n{\n outCol = vec4(0.0);\n outLv = vec3(0.0);\n outDist = 0.0;\n outShadow = vec4(0.0);\n outVisibility = 1.0;\n}",node_layer_weight_frag:"\nvoid node_layer_weight(vec3 viewPos, float blend, vec3 normal, out float fresnel, out float facing)\n{\n vec3 worldDir;\n if (isPerspective(projectionMatrix))\n worldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\n else\n worldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n \n worldDir = normalize(swizzleUpZ(worldDir));\n float eta = max(1.0 - blend, EPSILON);\n fresnel = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? 1.0 / eta : eta);\n facing = abs(dot(worldDir, normal));\n if (blend != 0.5) {\n blend = clamp(blend, 0.0, 1.0 - EPSILON);\n blend = (blend < 0.5) ? blend * 2.0 : 0.5 / (1.0 - blend);\n facing = pow(facing, blend);\n }\n facing = 1.0 - facing;\n}",node_light_falloff_frag:"void node_light_falloff(\n float strength, float smooth,\n out float quadratic, out float linear, out float constant)\n{\n quadratic = 1.0;\n linear = 1.0;\n constant = 1.0;\n}",node_light_path_frag:"void node_light_path(\n out float isCameraRay, out float isShadowRay, out float isDiffuseRay, \n out float isGlossyRay, out float isSingularRay, out float isReflectionRay,\n out float isTransmissionRay, out float rayLength, out float rayDepth, \n out float diffuseDepth, out float glossyDepth, out float transparentDepth, \n out float transmissionDepth)\n{\n #if LIGHT_PATH_IS_CAM_RAY\n isCameraRay = 1.0;\n #else\n isCameraRay = 0.0;\n #endif\n isShadowRay = 0.0;\n isDiffuseRay = 0.0;\n isGlossyRay = 0.0;\n isSingularRay = 0.0;\n isReflectionRay = 0.0;\n isTransmissionRay = 0.0;\n rayLength = 1.0;\n rayDepth = 1.0;\n diffuseDepth = 1.0;\n glossyDepth = 1.0;\n transparentDepth = 1.0; \n transmissionDepth = 1.0;\n}",node_mapping_frag:"\nvoid node_mapping(mat4 mat, vec3 minVec, vec3 maxVec, int useMin, int useMax, vec3 vec, out vec3 outVec)\n{\n outVec = (mat * vec4(vec, 1.0)).xyz;\n if (useMin == 1)\n outVec = max(outVec, minVec);\n if (useMax == 1)\n outVec = min(outVec, maxVec);\n}",node_material_ext_frag:"\nvoid node_material_ext(\n const int useDiffuse, const int useSpec, const int invertNormal,\n const float specularIntensity, const float specularHardness,\n const int useShadeless, const int normalBlendWorld,\n const vec4 diffuseColor, const vec4 specularColor, const float diffuseIntensity,\n vec3 normal, const vec4 mirror, const float ambient,\n const float emit, const float specularAlpha, const float reflectivity,\n const float alpha, const float translucency,\n out vec4 outColor, out float outAlpha, out vec3 outNormal, out vec4 outDiffuse,\n out vec4 outSpec, out vec4 outAO)\n{\n if (normalBlendWorld == 1) {\n normal = vec3(normal[0], normal[2], -normal[1]);\n normal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\n }\n vec3 diffuse, specular;\n if (useShadeless == 0) {\n NodeMaterial material;\n if (useDiffuse == 1)\n material.diffuseColor = diffuseColor.rgb;\n else\n material.diffuseColor = vec3(0.0);\n if (useSpec == 1)\n material.specularColor = specularColor.rgb;\n else\n material.specularColor = vec3(0.0);\n material.diffuseIntensity = diffuseIntensity;\n material.specularHardness = specularHardness;\n material.specularIntensity = specularIntensity;\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #include \n #include \n #include \n vec3 totalEmissiveRadiance = emit * material.diffuseColor;\n diffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\n totalEmissiveRadiance;\n specular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n } else {\n diffuse = diffuseColor.rgb;\n specular = vec3(0.0);\n }\n outColor = vec4(diffuse + specular, 1.0);\n outAlpha = alpha - saturate(maxFromRGB(specular) * specularAlpha) * (alpha - 1.0);\n outNormal = normal;\n outDiffuse = vec4(diffuse, 1.0);\n outSpec = vec4(specular, 1.0);\n outAO = vec4(1.0, 1.0, 1.0, 1.0);\n}",node_material_frag:"\nvoid node_material(\n const int useDiffuse, const int useSpec, const int invertNormal,\n const float specularIntensity, const float specularHardness,\n const float ambient, const float emit, const float alpha,\n const int useShadeless, const int normalBlendWorld,\n const vec4 diffuseColor, const vec4 specularColor, const float diffuseIntensity,\n vec3 normal,\n out vec4 outColor, out float outAlpha, out vec3 outNormal)\n{\n if (normalBlendWorld == 1) {\n normal = vec3(normal[0], normal[2], -normal[1]);\n normal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\n }\n vec3 diffuse, specular;\n if (useShadeless == 0) {\n NodeMaterial material;\n if (useDiffuse == 1)\n material.diffuseColor = diffuseColor.rgb;\n else\n material.diffuseColor = vec3(0.0);\n if (useSpec == 1)\n material.specularColor = specularColor.rgb;\n else\n material.specularColor = vec3(0.0);\n material.diffuseIntensity = diffuseIntensity;\n material.specularHardness = specularHardness;\n material.specularIntensity = specularIntensity;\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #include \n #include \n #include \n vec3 totalEmissiveRadiance = emit * material.diffuseColor;\n diffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\n totalEmissiveRadiance;\n specular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n } else {\n diffuse = diffuseColor.rgb;\n specular = vec3(0.0);\n }\n outColor = vec4(diffuse + specular, 1.0);\n outAlpha = alpha;\n outNormal = normalize(invViewMatrix * vec4(normal, 0.0)).rgb;\n outNormal = swizzleUpZ(outNormal);\n}",node_math_frag:"\nvoid node_math_add(float val1, float val2, out float outVal)\n{\n outVal = val1 + val2;\n}\nvoid node_math_subtract(float val1, float val2, out float outVal)\n{\n outVal = val1 - val2;\n}\nvoid node_math_multiply(float val1, float val2, out float outVal)\n{\n outVal = val1 * val2;\n}\nvoid node_math_divide(float val1, float val2, out float outVal)\n{\n if (val2 == 0.0)\n outVal = 0.0;\n else\n outVal = val1 / val2;\n}\nvoid node_math_sine(float val, float val2, out float outVal)\n{\n outVal = sin(val);\n}\nvoid node_math_cosine(float val, float val2, out float outVal)\n{\n outVal = cos(val);\n}\nvoid node_math_tangent(float val, float val2, out float outVal)\n{\n outVal = tan(val);\n}\nvoid node_math_arcsine(float val, float val2, out float outVal)\n{\n if (val <= 1.0 && val >= -1.0)\n outVal = asin(val);\n else\n outVal = 0.0;\n}\nvoid node_math_arccosine(float val, float val2, out float outVal)\n{\n if (val <= 1.0 && val >= -1.0)\n outVal = acos(val);\n else\n outVal = 0.0;\n}\nvoid node_math_arctangent(float val, float val2, out float outVal)\n{\n outVal = atan(val);\n}\nvoid node_math_arctan2(float val, float val2, out float outVal)\n{\n outVal = atan(val, val2);\n}\nvoid node_math_power(float val1, float val2, out float outVal)\n{\n if (val1 >= 0.0)\n outVal = powCompat(val1, val2);\n else {\n float val2_mod_1 = mod(abs(val2), 1.0);\n if (val2_mod_1 > 0.999 || val2_mod_1 < 0.001)\n outVal = powCompat(val1, floor(val2 + 0.5));\n else\n outVal = 0.0;\n }\n}\nvoid node_math_logarithm(float val1, float val2, out float outVal)\n{\n if (val1 > 0.0 && val2 > 0.0)\n outVal = log2(val1) / log2(val2);\n else\n outVal = 0.0;\n}\nvoid node_math_sqrt(float val1, float val2, out float outVal)\n{\n outVal = sqrt(val1);\n}\nvoid node_math_maximum(float val1, float val2, out float outVal)\n{\n outVal = max(val1, val2);\n}\nvoid node_math_minimum(float val1, float val2, out float outVal)\n{\n outVal = min(val1, val2);\n}\nvoid node_math_round(float val1, float val2, out float outVal)\n{\n outVal = floor(val1 + 0.5);\n}\nvoid node_math_floor(float val1, float val2, out float outVal)\n{\n outVal = floor(val1);\n}\nvoid node_math_ceil(float val1, float val2, out float outVal)\n{\n outVal = ceil(val1);\n}\nvoid node_math_fract(float val1, float val2, out float outVal)\n{\n outVal = fract(val1);\n}\nvoid node_math_less_than(float val1, float val2, out float outVal)\n{\n if (val1 < val2)\n outVal = 1.0;\n else\n outVal = 0.0;\n}\nvoid node_math_greater_than(float val1, float val2, out float outVal)\n{\n if (val1 > val2)\n outVal = 1.0;\n else\n outVal = 0.0;\n}\nvoid node_math_modulo(float val1, float val2, out float outVal)\n{\n if (val2 == 0.0)\n outVal = 0.0;\n else\n outVal = mod(val1, val2);\n outVal = (val1 > 0.0) ? outVal : outVal - val2;\n}\nvoid node_math_absolute(float val1, float val2, out float outVal)\n{\n outVal = abs(val1);\n}",node_mix_rgb_frag:"\nvoid node_mix_rgb_mix(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n outCol = mix(col1, col2, fac);\n outCol.a = col1.a;\n}\nvoid node_mix_rgb_add(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n outCol = mix(col1, col1 + col2, fac);\n outCol.a = col1.a;\n}\nvoid node_mix_rgb_multiply(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n outCol = mix(col1, col1 * col2, fac);\n outCol.a = col1.a;\n}\nvoid node_mix_rgb_screen(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n float facm = 1.0 - fac;\n outCol = vec4(1.0) - (vec4(facm) + fac * (vec4(1.0) - col2)) * (vec4(1.0) - col1);\n outCol.a = col1.a;\n}\nvoid node_mix_rgb_overlay(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n float facm = 1.0 - fac;\n outCol = col1;\n if (outCol.r < 0.5)\n outCol.r *= facm + 2.0 * fac * col2.r;\n else\n outCol.r = 1.0 - (facm + 2.0 * fac * (1.0 - col2.r)) * (1.0 - outCol.r);\n if (outCol.g < 0.5)\n outCol.g *= facm + 2.0 * fac * col2.g;\n else\n outCol.g = 1.0 - (facm + 2.0 * fac * (1.0 - col2.g)) * (1.0 - outCol.g);\n if (outCol.b < 0.5)\n outCol.b *= facm + 2.0 * fac * col2.b;\n else\n outCol.b = 1.0 - (facm + 2.0 * fac * (1.0 - col2.b)) * (1.0 - outCol.b);\n}\nvoid node_mix_rgb_subtract(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n outCol = mix(col1, col1 - col2, fac);\n outCol.a = col1.a;\n}\nvoid node_mix_rgb_divide(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n float facm = 1.0 - fac;\n outCol = col1;\n if (col2.r != 0.0) outCol.r = facm * outCol.r + fac * outCol.r / col2.r;\n if (col2.g != 0.0) outCol.g = facm * outCol.g + fac * outCol.g / col2.g;\n if (col2.b != 0.0) outCol.b = facm * outCol.b + fac * outCol.b / col2.b;\n}\nvoid node_mix_rgb_difference(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n outCol = mix(col1, abs(col1 - col2), fac);\n outCol.a = col1.a;\n}\nvoid node_mix_rgb_darken(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n outCol.rgb = min(col1.rgb, col2.rgb * fac);\n outCol.a = col1.a;\n}\nvoid node_mix_rgb_lighten(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n outCol.rgb = max(col1.rgb, col2.rgb * fac);\n outCol.a = col1.a;\n}\nvoid node_mix_rgb_dodge(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n outCol = col1;\n if (outCol.r != 0.0) {\n float tmp = 1.0 - fac * col2.r;\n if (tmp <= 0.0)\n outCol.r = 1.0;\n else if ((tmp = outCol.r / tmp) > 1.0)\n outCol.r = 1.0;\n else\n outCol.r = tmp;\n }\n if (outCol.g != 0.0) {\n float tmp = 1.0 - fac * col2.g;\n if (tmp <= 0.0)\n outCol.g = 1.0;\n else if ((tmp = outCol.g / tmp) > 1.0)\n outCol.g = 1.0;\n else\n outCol.g = tmp;\n }\n if (outCol.b != 0.0) {\n float tmp = 1.0 - fac * col2.b;\n if (tmp <= 0.0)\n outCol.b = 1.0;\n else if ((tmp = outCol.b / tmp) > 1.0)\n outCol.b = 1.0;\n else\n outCol.b = tmp;\n }\n}\nvoid node_mix_rgb_burn(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n float tmp, facm = 1.0 - fac;\n outCol = col1;\n tmp = facm + fac * col2.r;\n if (tmp <= 0.0)\n outCol.r = 0.0;\n else if ((tmp = (1.0 - (1.0 - outCol.r) / tmp)) < 0.0)\n outCol.r = 0.0;\n else if (tmp > 1.0)\n outCol.r = 1.0;\n else\n outCol.r = tmp;\n tmp = facm + fac * col2.g;\n if (tmp <= 0.0)\n outCol.g = 0.0;\n else if ((tmp = (1.0 - (1.0 - outCol.g) / tmp)) < 0.0)\n outCol.g = 0.0;\n else if (tmp > 1.0)\n outCol.g = 1.0;\n else\n outCol.g = tmp;\n tmp = facm + fac * col2.b;\n if (tmp <= 0.0)\n outCol.b = 0.0;\n else if ((tmp = (1.0 - (1.0 - outCol.b) / tmp)) < 0.0)\n outCol.b = 0.0;\n else if (tmp > 1.0)\n outCol.b = 1.0;\n else\n outCol.b = tmp;\n}\n#ifdef NODE_MIX_RGB_HSV\nvoid node_mix_rgb_hue(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n float facm = 1.0 - fac;\n outCol = col1;\n vec4 hsv, hsv2, tmp;\n rgbToHSV(col2, hsv2);\n if (hsv2.y != 0.0) {\n rgbToHSV(outCol, hsv);\n hsv.x = hsv2.x;\n hsvToRGB(hsv, tmp);\n outCol = mix(outCol, tmp, fac);\n outCol.a = col1.a;\n }\n}\nvoid node_mix_rgb_saturation(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n float facm = 1.0 - fac;\n outCol = col1;\n vec4 hsv, hsv2;\n rgbToHSV(outCol, hsv);\n if (hsv.y != 0.0) {\n rgbToHSV(col2, hsv2);\n hsv.y = facm * hsv.y + fac * hsv2.y;\n hsvToRGB(hsv, outCol);\n }\n}\nvoid node_mix_rgb_value(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n float facm = 1.0 - fac;\n vec4 hsv, hsv2;\n rgbToHSV(col1, hsv);\n rgbToHSV(col2, hsv2);\n hsv.z = facm * hsv.z + fac * hsv2.z;\n hsvToRGB(hsv, outCol);\n}\nvoid node_mix_rgb_color(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n float facm = 1.0 - fac;\n outCol = col1;\n vec4 hsv, hsv2, tmp;\n rgbToHSV(col2, hsv2);\n if (hsv2.y != 0.0) {\n rgbToHSV(outCol, hsv);\n hsv.x = hsv2.x;\n hsv.y = hsv2.y;\n hsvToRGB(hsv, tmp);\n outCol = mix(outCol, tmp, fac);\n outCol.a = col1.a;\n }\n}\n#endif\nvoid node_mix_rgb_soft_light(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n float facm = 1.0 - fac;\n vec4 one = vec4(1.0);\n vec4 scr = one - (one - col2) * (one - col1);\n outCol = facm * col1 + fac * ((one - col1) * col2 * col1 + col1 * scr);\n}\nvoid node_mix_rgb_linear_light(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\n fac = clamp(fac, 0.0, 1.0);\n outCol = col1 + fac * (2.0 * (col2 - vec4(0.5)));\n}",node_mix_shader_frag:"\nvoid node_mix_shader(int transpShaderNum,\n float fac, vec4 color1, vec4 color2, out vec4 outColor)\n{\n if (transpShaderNum == 0)\n color1.rgb = color2.rgb;\n else if (transpShaderNum == 1)\n color2.rgb = color1.rgb;\n fac = clamp(fac, 0.0, 1.0);\n outColor = mix(color1, color2, fac);\n}",node_new_geometry_frag:"void node_new_geometry(\n vec3 viewPos, vec3 viewNorm, \n out vec3 position, out vec3 normal, out vec3 tangent,\n out vec3 trueNormal, out vec3 incoming, out vec3 parametric,\n out float backfacing, out float pointiness)\n{\n position = (invViewMatrix * vec4(-viewPos, 1.0)).xyz;\n position = swizzleUpZ(position);\n vec4 viewDir = isOrtho(projectionMatrix) ? vec4(0.0, 0.0, -1.0, 0.0) : vec4(normalize(-viewPos), 0.0);\n viewDir = invViewMatrix * viewDir;\n vec3 incomingVec = -swizzleUpZ(viewDir.xyz);\n #if WORLD_NODES == 1\n normal = incomingVec;\n #else\n normal = normalize(invViewMatrix * vec4(viewNorm, 0.0)).rgb;\n normal = swizzleUpZ(normal);\n #endif\n tangent = vec3(0.0);\n trueNormal = normal;\n incoming = incomingVec;\n parametric = vec3(0.0);\n backfacing = (gl_FrontFacing) ? 0.0 : 1.0;\n #if WORLD_NODES == 1\n pointiness = 0.0;\n #else\n pointiness = 0.5;\n #endif\n}",node_normal_frag:"\nvoid node_normal(vec3 norParam, vec3 norIn, out vec3 norOut, out float dotOut)\n{\n norOut = norParam;\n dotOut = dot(normalize(norIn), norParam);\n}",node_normal_map_frag:"\nvoid node_normal_map(vec4 tangent, vec3 normal, float strength, vec4 normalColor, out vec3 normalOut)\n{\n#ifdef DOUBLE_SIDED\n normal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\n vec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\n vec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\n vec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\n normalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n + normalTex.z * normal);\n normalOut = mix(normal, normalOut, strength);\n normalOut = normalize((invViewMatrix * vec4(normalOut, 0.0)).xyz);\n normalOut = swizzleUpZ(normalOut);\n}",node_object_info_frag:"\nvoid node_object_info(out vec3 location, out float objIndex, out float matIndex, out float random) {\n #if WORLD_NODES == 1\n location = vec3(0.0);\n objIndex = 0.0;\n matIndex = 0.0;\n random = 0.0;\n #else\n location = vec3(0.0);\n objIndex = 0.0;\n matIndex = 0.0;\n random = 0.5;\n #endif\n}",node_output_frag:"\nvoid node_output(vec4 rgb, float alpha, out vec4 outgoingLight)\n{\n outgoingLight = vec4(rgb.rgb, alpha);\n}",node_output_lamp_frag:"void node_output_lamp(out vec4 outColor)\n{\n outColor = vec4(0.0);\n}",node_output_material_frag:"\nvoid node_output_material(vec4 surface, vec4 volume, float displacement, out vec4 outgoingLight) {\n outgoingLight = surface + volume;\n}\nvoid node_output_material(vec4 surface, vec4 volume, vec3 displacement, out vec4 outgoingLight) {\n outgoingLight = surface + volume;\n}",node_output_world_frag:"void node_output_world(vec4 surface, vec4 volume, out vec4 outgoingLight)\n{\n outgoingLight = surface;\n}",node_particle_info_frag:"\nvoid node_particle_info(out float index, out float age, out float lifeTime, out vec3 location,\n out float size, out vec3 velocity, out vec3 angularVelocity) {\n #if WORLD_NODES == 1\n index = 0.0;\n age = 0.0;\n lifeTime = 0.0;\n location = vec3(0.0);\n size = 0.0;\n velocity = vec3(0.0);\n angularVelocity = vec3(0.0);\n #else\n index = 0.0;\n age = 0.0;\n lifeTime = 0.0;\n location = vec3(0.0);\n size = 0.0;\n velocity = vec3(0.0);\n angularVelocity = vec3(0.0);\n #endif\n}",node_rgb_frag:"\nuniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\n outColor = color;\n}",node_rgbtobw_frag:"\nvoid node_rgbtobw(vec4 color, out float outVal) {\n outVal = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722;\n}",node_script_frag:"void node_script(out vec4 outColor)\n{\n outColor = vec4(0.0);\n}",node_sephsv_frag:"\nvoid node_sephsv(vec4 col, out float h, out float s, out float v)\n{\n vec4 hsv;\n rgbToHSV(col, hsv);\n h = hsv[0];\n s = hsv[1];\n v = hsv[2];\n}",node_seprgb_frag:"\nvoid node_seprgb(vec4 col, out float r, out float g, out float b)\n{\n r = col.r;\n g = col.g;\n b = col.b;\n}",node_sepxyz_frag:"void node_sepxyz(vec3 vector, out float x, out float y, out float z)\n{\n x = vector.x;\n y = vector.y;\n z = vector.z;\n}",node_squeeze_frag:"\nvoid node_squeeze(float val, float width, float center, out float outVal)\n{\n outVal = 1.0 / (1.0 + pow(2.71828183, -((val - center) * width)));\n}",node_subsurface_scattering_frag:"void node_subsurface_scattering(\n vec4 color, float scale, vec3 radius, float sharpen, float textureBlur, vec3 normal,\n out vec4 outColor)\n{\n outColor = color;\n}",node_tangent_frag:"void node_tangent(out vec3 outTangent)\n{\n outTangent = vec3(0.0);\n}",node_tex_brick_frag:"void node_tex_brick(\n vec3 vector, vec4 color1, vec4 color2, vec4 mortar, float scale,\n float mortarSize, float mortarSmooth, float bias, float brickWidth,\n float rowHeight,\n out vec4 outColor, out float fac)\n{\n outColor = color1;\n}",node_tex_checker_frag:"void node_tex_checker(vec3 vector, vec4 color1, vec4 color2, float scale, \n out vec4 outColor, out float outFac)\n{\n vec3 p = vector * scale;\n p = (p + 0.00001) * 0.99999;\n float cx = floor(p.x);\n float cy = floor(p.y);\n float cz = floor(p.z);\n float result = sign(mod(cx + cy + cz, 2.0));\n outFac = max(result, 0.0);\n outColor = mix(color2, color1, outFac);\n}",node_tex_coord_frag:"uniform vec3 boundingBoxMin;\nuniform vec3 boundingBoxMax;\nvoid node_tex_coord(\n vec3 viewPos, vec3 viewNorm, vec2 uv,\n out vec3 outGenerated, out vec3 outNormal, out vec3 outUV, out vec3 outObject,\n out vec3 outCamera, out vec3 outWindow, out vec3 outReflection)\n{\n vec4 view = vec4(-viewPos, 1.0);\n vec3 loc = swizzleUpZ((invModelMatrix * invViewMatrix * view).xyz);\n #if WORLD_NODES == 1\n loc = normalize(loc);\n #endif\n #if WORLD_NODES == 1\n outGenerated = loc;\n #else\n vec3 boxMin = vec3(boundingBoxMin.x, -boundingBoxMax.z, boundingBoxMin.y);\n vec3 boxMax = vec3(boundingBoxMax.x, -boundingBoxMin.z, boundingBoxMax.y);\n vec3 boxSize = boxMax - boxMin;\n if (abs(boxSize.x) < 0.001) {\n outGenerated.x = 0.5;\n } else {\n outGenerated.x = (loc.x - boxMin.x) / boxSize.x;\n }\n if (abs(boxSize.y) < 0.001) {\n outGenerated.y = 0.5;\n } else {\n outGenerated.y = (loc.y - boxMin.y) / boxSize.y;\n }\n if (abs(boxSize.z) < 0.001) {\n outGenerated.z = 0.5;\n } else {\n outGenerated.z = (loc.z - boxMin.z) / boxSize.z;\n }\n #endif\n #if WORLD_NODES == 1\n outNormal = -loc;\n #else\n outNormal = normalize(invModelMatrix * invViewMatrix * vec4(viewNorm, 0.0)).rgb;\n outNormal = swizzleUpZ(outNormal);\n #endif\n #if WORLD_NODES == 1\n outUV = vec3(0.0);\n #else\n uv.y = 1.0 - uv.y;\n outUV = vec3(uv, 0.0);\n #endif\n outObject = loc;\n outCamera = vec3(view.xy, -view.z);\n outWindow = vec3(0.0);\n #if WORLD_NODES == 1\n outReflection = -loc;\n #else\n vec4 reflection = (invViewMatrix * vec4(reflect(view.xyz, normalize(viewNorm)), 0.0));\n outReflection = normalize(swizzleUpZ(reflection.xyz));\n #endif\n}",node_tex_environment_frag:"void node_tex_environment(sampler2D tex, const int encoding, vec3 vector, out vec4 outColor) {\n vec3 direction = swizzleUpY(vector);\n if (length(direction) == 0.0) {\n direction = vec3(0.0, 1.0, 0.0);\n } else {\n direction = normalize(direction);\n }\n vec2 uv;\n uv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n uv.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\n uv.y = 1.0 - uv.y;\n #if WORLD_NODES == 1\n float bias = -100.0;\n #else\n const float seamWidth = 0.15;\n const float seamBiasFactor = -10.0;\n float seam = max(0.0, 1.0 - abs (direction.z) / seamWidth) *\n clamp (1.0 - direction.x / seamWidth, 0.0, 1.0);\n float bias = seamBiasFactor * seam;\n #endif\n outColor = texture2D(tex, uv, bias);\n outColor = nodeTexelToLinear(outColor, encoding);\n}",node_tex_environment_max_frag:"\nvoid node_tex_environment_max(sampler2D tex, const int encoding, vec3 vector, out vec4 outColor) {\n \n vec3 direction = swizzleUpY(vector);\n if (length(direction) == 0.0) {\n direction = vec3(0.0, 1.0, 0.0);\n } else {\n direction = normalize(direction);\n }\n vec2 uv;\n uv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n uv.x = atan(direction.x, direction.z) * RECIPROCAL_PI2 + 0.5;\n uv.y *= -1.0;\n const float seamWidth = 0.15;\n const float seamBiasFactor = -10.0;\n float seam = max(0.0, 1.0 - abs (direction.x) / seamWidth) *\n clamp (1.0 - direction.z / seamWidth, 0.0, 1.0);\n outColor = texture2D(tex, uv, seamBiasFactor * seam);\n outColor = nodeTexelToLinear(outColor, encoding);\n}",node_tex_environment_none_frag:"void node_tex_environment_none(vec3 vector, out vec4 outColor) {\n outColor = vec4(1.0, 0.0, 1.0, 1.0);\n}",node_tex_gradient_frag:"#define TEX_GRAD_LINEAR 0\n#define TEX_GRAD_QUADRATIC 1\n#define TEX_GRAD_EASING 2\n#define TEX_GRAD_DIAGONAL 3\n#define TEX_GRAD_SPHERICAL 4\n#define TEX_GRAD_QUADRATIC_SPHERE 5\n#define TEX_GRAD_RADIAL 6\nvoid node_tex_gradient(const int type, vec3 vector, out vec4 outColor, out float outFac)\n{\n float x, y, z, r;\n x = vector.x;\n y = vector.y;\n z = vector.z;\n if (type == TEX_GRAD_LINEAR) {\n outFac = x;\n } else if (type == TEX_GRAD_QUADRATIC) {\n r = max(x, 0.0);\n outFac = pow2(r);\n } else if (type == TEX_GRAD_EASING) {\n r = min(max(x, 0.0), 1.0);\n outFac = (3.0 * pow2(r) - 2.0 * pow3(r));\n } else if (type == TEX_GRAD_DIAGONAL) {\n outFac = (x + y) * 0.5;\n } else if (type == TEX_GRAD_RADIAL) {\n outFac = atan(y, x) / PI2 + 0.5;\n } else {\n r = max(0.99999 - sqrt(x * x + y * y + z * z), 0.0);\n if (type == TEX_GRAD_QUADRATIC_SPHERE) {\n outFac = pow2(r);\n } else if (type == TEX_GRAD_SPHERICAL) {\n outFac = r;\n }\n }\n outFac = clamp(outFac, 0.0, 1.0);\n outColor = vec4(outFac, outFac, outFac, 1.0);\n}",node_tex_image_frag:"void node_tex_image(\n sampler2D ima, const int encoding, \n vec3 vector,\n out vec4 outColor, out float outAlpha)\n{\n vec2 uv = vector.xy;\n uv.y = 1.0 - uv.y;\n outColor = texture2D(ima, uv);\n outAlpha = outColor.a;\n outColor = nodeTexelToLinear(outColor, encoding);\n}",node_tex_image_none_frag:"void node_tex_image_none(vec3 vector, out vec4 color, out float alpha)\n{\n color = vec4(1.0, 0.0, 1.0, 1.0);\n alpha = 1.0;\n}",node_tex_magic_frag:"void node_tex_magic(vec3 vector, float scale, float distortion,\n out vec4 outColor, out float outFac)\n{\n outColor = vec4(0.0);\n outFac = 0.0;\n}",node_tex_musgrave_frag:"void node_tex_musgrave(\n vec3 vector, float scale, float detail, float dimension, float lacunarity,\n float offset, float gain,\n out vec4 outColor, out float outFac)\n{\n outColor = vec4(0.0);\n outFac = 0.0;\n}",node_tex_noise_frag:"\nvoid node_tex_noise(\n float falloffFactor, float dispersionFactor,\n vec3 vector, float scale, float detail, float distortion,\n out vec4 outColor, out float outFac) {\n vec3 p = vector * scale;\n vec3 dx = dFdx(p);\n vec3 dy = dFdy(p);\n float octaveLenPerPixel = (length(dx) + length(dy)) / 4.0;\n if (distortion != 0.0) {\n vec3 r, offset = vec3(13.5, 13.5, 13.5);\n r.x = noiseSmooth(p + offset, octaveLenPerPixel, falloffFactor,\n dispersionFactor) * distortion;\n r.y = noiseSmooth(p, octaveLenPerPixel, falloffFactor,\n dispersionFactor) * distortion;\n r.z = noiseSmooth(p - offset, octaveLenPerPixel, falloffFactor,\n dispersionFactor) * distortion;\n p += r;\n }\n outFac = noiseTurbulence(p, detail, octaveLenPerPixel, falloffFactor,\n dispersionFactor);\n vec3 color = vec3(outFac,\n noiseTurbulence(vec3(p.y, p.x, p.z), detail, octaveLenPerPixel,\n falloffFactor, dispersionFactor),\n noiseTurbulence(vec3(p.y, p.z, p.x), detail, octaveLenPerPixel,\n falloffFactor, dispersionFactor)\n );\n outColor = vec4(color, 1.0);\n}",node_tex_pointdensity_frag:"void node_tex_pointdensity(\n vec3 vector,\n out vec4 outColor, out float outDensity)\n{\n outColor = vec4(0.0);\n outDensity = 0.0;\n}",node_tex_sky_frag:"\n#define TEX_SKY_PREETHAM 0\n#define TEX_SKY_HOSEK_WILKIE 1\n#define Km 683.0\nvoid node_tex_sky(const int skyType, vec3 param0, vec3 param1, vec3 param2, \n vec3 param3, vec3 param4, vec3 param5, vec3 param6, vec3 param7, \n vec3 param8, vec3 radiance, vec3 sunDirection, vec3 vectorIn, \n out vec4 outColor) {\n if (length(vectorIn) == 0.0) {\n vectorIn = vec3(0.0, 1.0, 0.0);\n } else {\n vectorIn = normalize(vectorIn);\n }\n vectorIn = swizzleUpY(vectorIn);\n sunDirection = swizzleUpY(sunDirection);\n float cosGamma = clamp(dot(vectorIn, sunDirection), -1.0, 1.0);\n float cosTheta = clamp(vectorIn.y, 0.0, 1.0);\n if (skyType == TEX_SKY_PREETHAM) {\n vec3 radInternal = (1.0 + param0 * exp(param1 / cosTheta)) * (\n 1.0 + param2 * exp(param3 * acos(cosGamma)) \n + param4 * pow(cosGamma, 2.0)\n );\n vec3 XYZ = xyY_to_XYZ(radInternal.y * radiance.y,\n radInternal.z * radiance.z, radInternal.x * radiance.x);\n outColor = vec4(max(xyz_to_sRGB(XYZ), 0.0), 1.0);\n } else if (skyType == TEX_SKY_HOSEK_WILKIE) {\n float cosGammaSq = pow(cosGamma, 2.0);\n vec3 chi = (1.0 + cosGammaSq) / pow(1.0 + pow(param8, vec3(2.0))\n - 2.0 * param8 * cosGamma, vec3(1.5));\n vec3 radInternal = (1.0 + param0 * exp(param1 / (cosTheta + 0.01))) * (\n param2 + param3 * exp(param4 * acos(cosGamma)) \n + param5 * cosGammaSq + param6 * chi + param7 * sqrt(cosTheta)\n );\n outColor = vec4(max(xyz_to_sRGB(radInternal * radiance), 0.0) * PI2/Km, 1.0);\n } else {\n outColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n}",node_tex_voronoi_frag:"\nstruct VoronoiClosest {\n vec4 closestDists;\n vec4 closestInds;\n};\nvec3 worleyPermute(vec3 x) {\n return mod((34.0 * x + 1.0) * x, 289.0);\n}\n#define DISTANCE_DISTANCE 0\n#define DISTANCE_MANHATTAN 1\n#define DISTANCE_CHEBYCHEV 2\n#define DISTANCE_MINKOWSKI 3\nvec3 worleyDist(vec3 x, vec3 y, vec3 z, int distance) {\n if (distance == DISTANCE_DISTANCE) {\n return x * x + y * y + z * z;\n } else if (distance == DISTANCE_MANHATTAN) {\n return abs(x) + abs(y) + abs(z);\n } else if (distance == DISTANCE_CHEBYCHEV) {\n return max(max(abs(x), abs(y)), abs(z));\n } else if (distance == DISTANCE_MINKOWSKI) {\n return pow(sqrt(abs(x)) + sqrt(abs(y)) + sqrt(abs(z)), vec3(2.0));\n }\n return vec3(0.0);\n}\nvoid updateVoronoiClosest(inout VoronoiClosest vf, vec3 newDistances, vec3 newIndices) {\n #pragma unroll_loop\n for (int i = 0; i < 3; i++) {\n float currDist = newDistances[i];\n float currIdx = newIndices[i];\n #pragma unroll_loop\n for (int j = 0; j < 4; j++) {\n if (currDist < vf.closestDists[j]) {\n float tmp = vf.closestDists[j];\n vf.closestDists[j] = currDist;\n currDist = tmp;\n tmp = vf.closestInds[j];\n vf.closestInds[j] = currIdx;\n currIdx = tmp;\n }\n }\n }\n}\nVoronoiClosest worleyClosest(vec3 P, float jitter, int distance) {\n float K = 0.142857142857;\n float Ko = 0.428571428571;\n float K2 = 0.020408163265306;\n float Kz = 0.166666666667;\n float Kzo = 0.416666666667;\n vec3 Pi = mod(floor(P), 289.0);\n vec3 Pf = fract(P) - 0.5;\n vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\n vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\n vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\n vec3 p = worleyPermute(Pi.x + vec3(-1.0, 0.0, 1.0));\n vec3 p1 = worleyPermute(p + Pi.y - 1.0);\n vec3 p2 = worleyPermute(p + Pi.y);\n vec3 p3 = worleyPermute(p + Pi.y + 1.0);\n vec3 p11 = worleyPermute(p1 + Pi.z - 1.0);\n vec3 p12 = worleyPermute(p1 + Pi.z);\n vec3 p13 = worleyPermute(p1 + Pi.z + 1.0);\n vec3 p21 = worleyPermute(p2 + Pi.z - 1.0);\n vec3 p22 = worleyPermute(p2 + Pi.z);\n vec3 p23 = worleyPermute(p2 + Pi.z + 1.0);\n vec3 p31 = worleyPermute(p3 + Pi.z - 1.0);\n vec3 p32 = worleyPermute(p3 + Pi.z);\n vec3 p33 = worleyPermute(p3 + Pi.z + 1.0);\n vec3 ox11 = fract(p11*K) - Ko;\n vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\n vec3 oz11 = floor(p11*K2)*Kz - Kzo;\n vec3 ox12 = fract(p12*K) - Ko;\n vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\n vec3 oz12 = floor(p12*K2)*Kz - Kzo;\n vec3 ox13 = fract(p13*K) - Ko;\n vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\n vec3 oz13 = floor(p13*K2)*Kz - Kzo;\n vec3 ox21 = fract(p21*K) - Ko;\n vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\n vec3 oz21 = floor(p21*K2)*Kz - Kzo;\n vec3 ox22 = fract(p22*K) - Ko;\n vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\n vec3 oz22 = floor(p22*K2)*Kz - Kzo;\n vec3 ox23 = fract(p23*K) - Ko;\n vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\n vec3 oz23 = floor(p23*K2)*Kz - Kzo;\n vec3 ox31 = fract(p31*K) - Ko;\n vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\n vec3 oz31 = floor(p31*K2)*Kz - Kzo;\n vec3 ox32 = fract(p32*K) - Ko;\n vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\n vec3 oz32 = floor(p32*K2)*Kz - Kzo;\n vec3 ox33 = fract(p33*K) - Ko;\n vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\n vec3 oz33 = floor(p33*K2)*Kz - Kzo;\n vec3 dx11 = Pfx + jitter*ox11;\n vec3 dy11 = Pfy.x + jitter*oy11;\n vec3 dz11 = Pfz.x + jitter*oz11;\n vec3 dx12 = Pfx + jitter*ox12;\n vec3 dy12 = Pfy.x + jitter*oy12;\n vec3 dz12 = Pfz.y + jitter*oz12;\n vec3 dx13 = Pfx + jitter*ox13;\n vec3 dy13 = Pfy.x + jitter*oy13;\n vec3 dz13 = Pfz.z + jitter*oz13;\n vec3 dx21 = Pfx + jitter*ox21;\n vec3 dy21 = Pfy.y + jitter*oy21;\n vec3 dz21 = Pfz.x + jitter*oz21;\n vec3 dx22 = Pfx + jitter*ox22;\n vec3 dy22 = Pfy.y + jitter*oy22;\n vec3 dz22 = Pfz.y + jitter*oz22;\n vec3 dx23 = Pfx + jitter*ox23;\n vec3 dy23 = Pfy.y + jitter*oy23;\n vec3 dz23 = Pfz.z + jitter*oz23;\n vec3 dx31 = Pfx + jitter*ox31;\n vec3 dy31 = Pfy.z + jitter*oy31;\n vec3 dz31 = Pfz.x + jitter*oz31;\n vec3 dx32 = Pfx + jitter*ox32;\n vec3 dy32 = Pfy.z + jitter*oy32;\n vec3 dz32 = Pfz.y + jitter*oz32;\n vec3 dx33 = Pfx + jitter*ox33;\n vec3 dy33 = Pfy.z + jitter*oy33;\n vec3 dz33 = Pfz.z + jitter*oz33;\n vec3 d11 = worleyDist(dx11, dy11, dz11, distance);\n vec3 d12 = worleyDist(dx12, dy12, dz12, distance);\n vec3 d13 = worleyDist(dx13, dy13, dz13, distance);\n vec3 d21 = worleyDist(dx21, dy21, dz21, distance);\n vec3 d22 = worleyDist(dx22, dy22, dz22, distance);\n vec3 d23 = worleyDist(dx23, dy23, dz23, distance);\n vec3 d31 = worleyDist(dx31, dy31, dz31, distance);\n vec3 d32 = worleyDist(dx32, dy32, dz32, distance);\n vec3 d33 = worleyDist(dx33, dy33, dz33, distance);\n VoronoiClosest vf = VoronoiClosest(vec4(1e10), vec4(0.0));\n updateVoronoiClosest(vf, d11, p11);\n updateVoronoiClosest(vf, d12, p12);\n updateVoronoiClosest(vf, d13, p13);\n updateVoronoiClosest(vf, d21, p21);\n updateVoronoiClosest(vf, d22, p22);\n updateVoronoiClosest(vf, d23, p23);\n updateVoronoiClosest(vf, d31, p31);\n updateVoronoiClosest(vf, d32, p32);\n updateVoronoiClosest(vf, d33, p33);\n return vf;\n}\n#define COLORING_INTENSITY 0\n#define COLORING_CELLS 1\n#define FEATURE_F1 0\n#define FEATURE_F2 1\n#define FEATURE_F3 2\n#define FEATURE_F4 3\n#define FEATURE_F2F1 4\nvoid node_tex_voronoi(int coloring, int distance, int feature, vec3 vector,\n float scale, float exponent, out vec4 outColor, out float outFac) {\n vector = scale * (vector - 0.0001);\n VoronoiClosest vf = worleyClosest(vector, 1.0, distance);\n vec4 vorColorData;\n if (coloring == COLORING_INTENSITY) {\n vorColorData = vf.closestDists;\n } else if (coloring == COLORING_CELLS) {\n vorColorData = vf.closestInds;\n }\n float vorColorFac;\n if (feature == FEATURE_F1) {\n vorColorFac = vorColorData.x;\n } else if (feature == FEATURE_F2) {\n vorColorFac = vorColorData.y;\n } else if (feature == FEATURE_F3) {\n vorColorFac = vorColorData.z;\n } else if (feature == FEATURE_F4) {\n vorColorFac = vorColorData.w;\n } else if (feature == FEATURE_F2F1) {\n vorColorFac = vorColorData.y - vorColorData.x;\n }\n if (coloring == COLORING_INTENSITY) {\n outFac = vorColorFac;\n outColor = vec4(vec3(outFac), 1.0);\n } else if (coloring == COLORING_CELLS) {\n vorColorFac += 1e-3;\n float r = rand(vec2(vorColorFac / 289.0));\n float g = rand(vec2(vorColorFac / 23535.0));\n float b = rand(vec2(vorColorFac / 4353.0));\n outFac = (r + g + b) / 3.0;\n outColor = vec4(r, g, b, 1.0);\n }\n}",node_tex_wave_frag:"#define TEX_WAVE_TYPE_BANDS 0\n#define TEX_WAVE_TYPE_RINGS 1\n#define TEX_WAVE_PROFILE_SIN 0\n#define TEX_WAVE_PROFILE_SAW 1\nvoid node_tex_wave(int waveType, int waveProfile, vec3 vector, float scale,\n float distortion, float detail, float detailScale, out vec4 outColor,\n out float outFac) {\n vec3 coScaled = vector * scale;\n float waveFac;\n if (waveType == TEX_WAVE_TYPE_BANDS) {\n waveFac = (coScaled.x + coScaled.y + coScaled.z) * 10.0;\n } else {\n waveFac = length(coScaled) * 20.0;\n }\n if (distortion != 0.0) {\n waveFac += distortion * noiseTurbulence(coScaled * detailScale, detail,\n 0.0, 0.0, 1.0);\n }\n if (waveProfile == TEX_WAVE_PROFILE_SIN) {\n waveFac = 0.5 + 0.5 * sin(waveFac);\n } else {\n waveFac = fract(waveFac / PI2);\n }\n outColor = vec4(waveFac, waveFac, waveFac, 1.0);\n outFac = waveFac;\n}",node_texture_cube_frag:"\nuniform float flipCubeMap;\nvoid node_texture_cube(samplerCube ima, const int encoding, vec3 vec, out float value, out vec4 color, out vec3 normal)\n{\n vec = vec3(flipCubeMap * vec.x, vec.z, -vec.y);\n color = textureCube(ima, vec);\n value = color.a;\n normal.x = 2.0 * (color.r - 0.5);\n normal.y = 2.0 * (0.5 - color.g);\n normal.z = 2.0 * (color.b - 0.5);\n color = nodeTexelToLinear(color, encoding);\n}",node_texture_frag:"\nvoid node_texture(sampler2D ima, const int encoding, vec3 vec, out float value, out vec4 color, out vec3 normal)\n{\n vec2 uv = (vec.xy + vec2(1.0, 1.0)) * 0.5;\n uv.y = 1.0 - uv.y;\n color = texture2D(ima, uv);\n value = color.a;\n normal.x = 2.0 * (color.r - 0.5);\n normal.y = 2.0 * (0.5 - color.g);\n normal.z = 2.0 * (color.b - 0.5);\n color = nodeTexelToLinear(color, encoding);\n}",node_texture_none_frag:"\nvoid node_texture_none(vec3 vec, out float value, out vec4 color, out vec3 normal)\n{\n value = 0.0;\n color = vec4(0.0);\n normal = vec3(0.0);\n}",node_uvmap_frag:"void node_uvmap(vec2 uv, out vec3 outUV) {\n #if WORLD_NODES == 1\n outUV = vec3(0.0);\n #else\n uv.y = 1.0 - uv.y;\n outUV = vec3(uv, 0.0);\n #endif\n}",node_valtorgb_frag:"\nvoid node_valtorgb(sampler2D colormap, float fac, out vec4 colOut, out float alphaOut)\n{\n colOut = texture2D(colormap, vec2(fac, 0.0));\n alphaOut = colOut.a;\n}",node_value_frag:"\nuniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\n outVal = val;\n}",node_vect_math_frag:"\nvoid node_vect_math_add(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\n outVec = v1 + v2;\n outVal = (abs(outVec[0]) + abs(outVec[1]) + abs(outVec[2])) * RECIPROCAL_3;\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\n outVec = v1 - v2;\n outVal = (abs(outVec[0]) + abs(outVec[1]) + abs(outVec[2])) * RECIPROCAL_3;\n}\nvoid node_vect_math_average(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\n outVec = v1 + v2;\n outVal = length(outVec);\n outVec = normalize(outVec);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\n outVec = vec3(0, 0, 0);\n outVal = dot(v1, v2);\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\n outVec = cross(v1, v2);\n outVal = length(outVec);\n outVec /= outVal;\n}\nvoid node_vect_math_normalize(vec3 v, vec3 v2, out vec3 outVec, out float outVal)\n{\n outVal = length(v);\n outVec = normalize(v);\n}",node_vect_transform_frag:"\n#define VEC_TRANS_NONE 0\n#define VEC_TRANS_W_O 1\n#define VEC_TRANS_W_C 2\n#define VEC_TRANS_O_W 3\n#define VEC_TRANS_O_C 4\n#define VEC_TRANS_C_W 5\n#define VEC_TRANS_C_O 6\n#define VEC_TRANS_W_O_DIR 7\n#define VEC_TRANS_W_C_DIR 8\n#define VEC_TRANS_O_W_DIR 9\n#define VEC_TRANS_O_C_DIR 10\n#define VEC_TRANS_C_W_DIR 11\n#define VEC_TRANS_C_O_DIR 12\nvoid node_vect_transform(const int vecTransType, const int invCamZ, vec3 vIn, out vec3 vOut)\n{\n if (vecTransType == VEC_TRANS_NONE)\n vOut = vIn;\n else {\n vec4 vec;\n if (vecTransType < VEC_TRANS_W_O_DIR)\n vec = vec4(vIn.xyz, 1.0);\n else\n vec = vec4(vIn.xyz, 0.0);\n if (vecTransType == VEC_TRANS_W_O || vecTransType == VEC_TRANS_W_O_DIR) {\n vec = vec4(vec.x, vec.z, -vec.y, vec.w);\n vec = invModelMatrix * vec;\n vec = vec4(vec.x, -vec.z, vec.y, vec.w);\n } else if (vecTransType == VEC_TRANS_W_C || vecTransType == VEC_TRANS_W_C_DIR) {\n vec = vec4(vec.x, vec.z, -vec.y, vec.w);\n vec = viewMatrix * vec;\n if (invCamZ == 1)\n vec[2] = -vec[2];\n } else if (vecTransType == VEC_TRANS_O_W || vecTransType == VEC_TRANS_O_W_DIR) {\n vec = vec4(vec.x, vec.z, -vec.y, vec.w);\n vec = modelMatrix * vec;\n vec = vec4(vec.x, -vec.z, vec.y, vec.w);\n } else if (vecTransType == VEC_TRANS_O_C || vecTransType == VEC_TRANS_O_C_DIR) {\n vec = vec4(vec.x, vec.z, -vec.y, vec.w);\n vec = modelViewMatrix * vec;\n if (invCamZ == 1)\n vec[2] = -vec[2];\n } else if (vecTransType == VEC_TRANS_C_W || vecTransType == VEC_TRANS_C_W_DIR) {\n if (invCamZ == 1)\n vec[2] = -vec[2];\n vec = invViewMatrix * vec;\n vec = vec4(vec.x, -vec.z, vec.y, vec.w);\n } else if (vecTransType == VEC_TRANS_C_O || vecTransType == VEC_TRANS_C_O_DIR) {\n if (invCamZ == 1)\n vec[2] = -vec[2];\n vec = invModelMatrix * invViewMatrix * vec;\n vec = vec4(vec.x, -vec.z, vec.y, vec.w);\n }\n vOut = vec.xyz;\n }\n}",node_volume_absorption_frag:"void node_volume_absorption(vec4 color, float density, out vec4 outColor)\n{\n outColor = color;\n}",node_volume_scatter_frag:"void node_volume_scatter(vec4 color, float density, float anisotropy, out vec4 outColor)\n{\n outColor = vec4(color);\n}",node_wavelength_frag:"void node_wavelength(float wavelength, out vec4 outColor)\n{\n outColor = vec4(0.0);\n}",node_wireframe_frag:"void node_wireframe(float size, out float outFac)\n{\n outFac = 0.0;\n}",node_bitmap_none_max_frag:"void node_bitmap_none_max(out vec4 color)\n{\n color = vec4(1.0);\n}",node_bitmap_env_max_frag:"void node_bitmap_env_max(sampler2D envMap, int reflectMode, float IOR,\n const int encoding, const int alphaAsMono, const int alphaAsRGB,\n \n float uOffset, float vOffset, float uTiling, float vTiling, float wAngle, vec3 normal,\n out vec4 color, out float value)\n{\n vec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\n vec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\n vec3 reflectVec;\n #if WORLD_NODES\n reflectVec = normalize(cameraToVertex);\n #else\n if (reflectMode == MAX_ENV_COORDS_REFLECT)\n reflectVec = reflect(cameraToVertex, worldNormal);\n else {\n float refrRatio = 1.0 / IOR;\n reflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n }\n #endif\n mat3 uvTransform = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle);\n color = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\n if (alphaAsMono == 1)\n value = color.a;\n else\n value = average(color.rgb);\n if (alphaAsRGB == 1)\n color = vec4(color.a);\n}",node_bitmap_max_frag:"void node_bitmap_max(sampler2D map, const vec2 uvIn, const int encoding,\n const int alphaAsMono, const int alphaAsRGB,\n float uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\n out vec4 color, out float value)\n{\n vec2 uv = (calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * vec3(uvIn, 1.0)).xy;\n color = texture2D(map, uv);\n color = nodeTexelToLinear(color, encoding);\n if (alphaAsMono == 1)\n value = color.a;\n else\n value = average(color.rgb);\n if (alphaAsRGB == 1)\n color = vec4(color.a);\n}",node_bump_max_frag:"void node_bump_max(sampler2D bumpMap, const vec3 eyePos, const vec3 normal, const vec2 uv,\n out vec3 normalOut)\n{\n vec2 dSTdx = dFdx(uv);\n vec2 dSTdy = dFdy(uv);\n if (any(equal(dSTdx, vec2(0.0))) || any(equal(dSTdy, vec2(0.0)))) {\n normalOut = normal;\n } else {\n const float bumpScale = 1.0;\n vec3 vSigmaX = vec3(dFdx(eyePos.x), dFdx(eyePos.y), dFdx(eyePos.z));\n vec3 vSigmaY = vec3(dFdy(eyePos.x), dFdy(eyePos.y), dFdy(eyePos.z));\n vec3 vN = normal;\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n float fDet = dot(vSigmaX, R1);\n float Hll = bumpScale * texture2D(bumpMap, uv).x;\n float dBx = bumpScale * texture2D(bumpMap, uv + dSTdx).x - Hll;\n float dBy = bumpScale * texture2D(bumpMap, uv + dSTdy).x - Hll;\n vec2 dHdxy = vec2(dBx, dBy);\n vec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\n normalOut = normalize(abs(fDet) * normal - vGrad);\n }\n}",node_blend_max_frag:"void node_blend_max(\n const int useCurve, const float curveLower, const float curveUpper,\n const vec4 color1, const vec4 color2, float mask,\n out vec4 color)\n{\n if (useCurve == 1)\n mask = smoothstep(curveLower, curveUpper, mask);\n else\n mask = clamp(mask, 0.0, 1.0);\n color = mix(color1, color2, mask);\n}",node_color_correction_max_frag:"#define REWIRE_RED 0\n#define REWIRE_GREEN 1\n#define REWIRE_BLUE 2\n#define REWIRE_ALPHA 3\n#define REWIRE_RED_INV 4\n#define REWIRE_GREEN_INV 5\n#define REWIRE_BLUE_INV 6\n#define REWIRE_ALPHA_INV 7\n#define REWIRE_MONOCHROME 8\n#define REWIRE_ONE 9\n#define REWIRE_ZERO 10\nfloat rewireChannel(int type, vec4 color)\n{\n if (type == REWIRE_RED)\n return color.r;\n else if (type == REWIRE_GREEN)\n return color.g;\n else if (type == REWIRE_BLUE)\n return color.b;\n else if (type == REWIRE_ALPHA)\n return color.a;\n else if (type == REWIRE_RED_INV)\n return 1.0-color.r;\n else if (type == REWIRE_GREEN_INV)\n return 1.0-color.g;\n else if (type == REWIRE_BLUE_INV)\n return 1.0-color.b;\n else if (type == REWIRE_ALPHA_INV)\n return 1.0-color.a;\n else if (type == REWIRE_MONOCHROME)\n return average(color.rgb);\n else if (type == REWIRE_ONE)\n return 1.0;\n else\n return 0.0;\n}\nvoid node_color_correction_max(const ivec4 rewire,\n const vec4 color, const float hueShift, const float saturation,\n const vec4 tint, const float tintStrength,\n const float brightness, const float contrast,\n out vec4 outColor)\n{\n if (all(equal(rewire, ivec4(REWIRE_RED, REWIRE_GREEN, REWIRE_BLUE, REWIRE_ALPHA)))) {\n outColor = color;\n } else {\n outColor.r = rewireChannel(rewire.x, color);\n outColor.g = rewireChannel(rewire.y, color);\n outColor.b = rewireChannel(rewire.z, color);\n outColor.a = rewireChannel(rewire.w, color);\n }\n vec4 hsv;\n rgbToHSV(outColor, hsv);\n hsv[0] += hueShift / 360.0;\n if (hsv[0] > 1.0)\n hsv[0] -= 1.0;\n else if (hsv[0] < 0.0)\n hsv[0] += 1.0;\n hsv[1] *= (saturation / 100.0 + 1.0);\n hsv[1] = saturate(hsv[1]);\n if (tintStrength > 0.0) {\n vec4 hsvTint;\n rgbToHSV(tint, hsvTint);\n hsv[0] = hsv[0] + (hsvTint[0] - hsv[0]) * tintStrength / 100.0;\n }\n hsvToRGB(hsv, outColor);\n outColor = (outColor - 0.5) * (contrast / 100.0 + 1.0) + 0.5 + brightness / 100.0;\n outColor = max(outColor, 0.0);\n}",node_color_map_max_frag:"void node_color_map_max(const int reverseGamma, \n const vec4 color, const float gamma, const float gain,\n out vec4 outColor)\n{\n float p = (reverseGamma == 1) ? gamma : 1.0 / gamma;\n float g = (reverseGamma == 1) ? (gain > EPSILON ? 1.0 / gain : 1.0) : gain;\n outColor = vec4(g * pow(color.rgb, vec3(p)), color.a);\n}",node_composite_layer_max_frag:"#define COMP_BLEND_NORMAL 0\n#define COMP_BLEND_AVERAGE 1\n#define COMP_BLEND_ADD 2\n#define COMP_BLEND_SUBTRACT 3\n#define COMP_BLEND_DARKEN 4\n#define COMP_BLEND_MULTIPLY 5\n#define COMP_BLEND_COLORBURN 6\n#define COMP_BLEND_LINEARBURN 7\n#define COMP_BLEND_LIGHTEN 8\n#define COMP_BLEND_SCREEN 9\n#define COMP_BLEND_COLORDODGE 10\n#define COMP_BLEND_LINEARDODGE 11\n#define COMP_BLEND_SPOT 12\n#define COMP_BLEND_SPOTBLEND 13\n#define COMP_BLEND_OVERLAY 14\n#define COMP_BLEND_SOFTLIGHT 15\n#define COMP_BLEND_HARDLIGHT 16\n#define COMP_BLEND_PINLIGHT 17\n#define COMP_BLEND_HARDMIX 18\n#define COMP_BLEND_DIFFERENCE 19\n#define COMP_BLEND_EXCLUSION 20\n#define COMP_BLEND_HUE 21\n#define COMP_BLEND_SATURATION 22\n#define COMP_BLEND_COLOR 23\n#define COMP_BLEND_VALUE 24\nvec4 calcBlending(const vec4 colorBG, const vec4 colorFG, const int blendMode) {\n if (blendMode == COMP_BLEND_NORMAL)\n return colorFG;\n else if (blendMode == COMP_BLEND_AVERAGE)\n return (colorFG + colorBG) / 2.0;\n else if (blendMode == COMP_BLEND_ADD)\n return colorBG + colorFG;\n else if (blendMode == COMP_BLEND_SUBTRACT)\n return colorBG - colorFG;\n else if (blendMode == COMP_BLEND_DARKEN)\n return min(colorFG, colorBG);\n else if (blendMode == COMP_BLEND_MULTIPLY)\n return colorBG * colorFG;\n else if (blendMode == COMP_BLEND_COLORBURN) {\n if (colorFG.r == 0.0 && colorFG.g == 0.0 && colorFG.b == 0.0)\n return vec4(0.0, 0.0, 0.0, 1.0);\n else\n return max(1.0 - (1.0 - colorBG) / colorFG, 0.0);\n } else if (blendMode == COMP_BLEND_LINEARBURN)\n return max(colorFG + colorBG - 1.0, 0.0);\n else if (blendMode == COMP_BLEND_LIGHTEN)\n return max(colorFG, colorBG);\n else if (blendMode == COMP_BLEND_SCREEN)\n return colorFG + colorBG - colorFG * colorBG;\n else if (blendMode == COMP_BLEND_COLORDODGE) {\n if (colorFG.r == 1.0 && colorFG.g == 1.0 && colorFG.b == 1.0)\n return vec4(1.0);\n else\n return min(colorBG / (1.0 - colorFG), 1.0);\n } else if (blendMode == COMP_BLEND_LINEARDODGE)\n return min(colorFG + colorBG, 1.0);\n else if (blendMode == COMP_BLEND_SPOT)\n return min(2.0 * colorFG * colorBG, 1.0);\n else if (blendMode == COMP_BLEND_SPOTBLEND)\n return min(colorFG * colorBG + colorBG, 1.0);\n else if (blendMode == COMP_BLEND_OVERLAY) {\n if (colorBG.r <= 0.5 && colorBG.g <= 0.5 && colorBG.b <= 0.5)\n return saturate(2.0 * colorFG * colorBG);\n else\n return saturate(1.0 - 2.0 * (1.0-colorFG) * (1.0-colorBG));\n } else if (blendMode == COMP_BLEND_SOFTLIGHT) {\n if (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\n return saturate(colorBG * (colorBG + 2.0 * colorFG * (1.0 - colorBG)));\n else\n return saturate(colorBG + (2.0 * colorFG - 1.0) * (sqrt(colorBG) - colorBG));\n } else if (blendMode == COMP_BLEND_HARDLIGHT) {\n if (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\n return saturate(2.0 * colorFG * colorBG);\n else\n return saturate(1.0 - 2.0*(1.0 - colorFG)*(1.0 - colorBG));\n } else if (blendMode == COMP_BLEND_PINLIGHT) {\n if (((colorFG.r > 0.5 && colorFG.g > 0.5 && colorFG.b > 0.5) && all(greaterThan(colorFG, colorBG))) ||\n ((colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5) && all(lessThan(colorFG, colorBG))))\n return colorFG;\n else\n return colorBG;\n } else if (blendMode == COMP_BLEND_HARDMIX) {\n if (colorFG.r + colorBG.r <= 1.0 && colorFG.g + colorBG.g <= 1.0 && colorFG.b + colorBG.b <= 1.0)\n return vec4(0.0, 0.0, 0.0, 1.0);\n else\n return vec4(1.0);\n } else if (blendMode == COMP_BLEND_DIFFERENCE)\n return abs(colorFG - colorBG);\n else if (blendMode == COMP_BLEND_EXCLUSION)\n return colorFG + colorBG - 2.0 * colorFG * colorBG;\n}\nvec4 calcBlendingHSV(const vec4 colorBG, const vec4 colorFG, const int blendMode)\n{\n vec4 hsvBG, hsvFG;\n vec4 outColor;\n if (blendMode == COMP_BLEND_HUE) {\n rgbToHSV(colorBG, hsvBG);\n rgbToHSV(colorFG, hsvFG);\n hsvToRGB(vec4(hsvFG[0], hsvBG[1], hsvBG[2], 1.0), outColor);\n } else if (blendMode == COMP_BLEND_SATURATION) {\n rgbToHSV(colorBG, hsvBG);\n rgbToHSV(colorFG, hsvFG);\n hsvToRGB(vec4(hsvBG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n } else if (blendMode == COMP_BLEND_COLOR) {\n rgbToHSV(colorBG, hsvBG);\n rgbToHSV(colorFG, hsvFG);\n hsvToRGB(vec4(hsvFG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n } else if (blendMode == COMP_BLEND_VALUE) {\n rgbToHSV(colorBG, hsvBG);\n rgbToHSV(colorFG, hsvFG);\n hsvToRGB(vec4(hsvBG[0], hsvBG[1], hsvFG[2], 1.0), outColor);\n }\n return outColor;\n}\nvoid node_composite_layer_max(const int blendMode, const float opacity, \n const vec4 colorBG, const vec4 colorFG, const vec4 mask,\n out vec4 outColor)\n{\n float fac = saturate(opacity * average(mask.rgb));\n if (blendMode < COMP_BLEND_HUE)\n outColor = calcBlending(colorBG, colorFG, blendMode);\n else\n outColor = calcBlendingHSV(colorBG, colorFG, blendMode);\n outColor = mix(colorBG, outColor, fac);\n}",node_falloff_max_frag:"void node_falloff_max(vec3 viewPos, float IOR,\n const vec4 color1, const vec4 color2, vec3 normal, out vec4 color)\n{\n float fac;\n \n vec3 dir = normalize(viewPos);\n float eta = max(IOR, 0.00001);\n fac = fresnelReflection(dir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\n color = mix(color1, color2, fac);\n}",node_map_max_frag:"\nvoid node_map_max(const vec4 colorIn, out vec4 color)\n{\n color = colorIn;\n}",node_mask_max_frag:"void node_mask_max(const int maskInverted, \n const vec4 color, vec4 mask,\n out vec4 outColor)\n{\n mask = (maskInverted == 1) ? vec4(vec3(1.0) - mask.rgb, mask.a) : mask;\n outColor = color * mask;\n}",node_material_max_frag:"\nvoid node_material_max(\n float reflectionRatio, const float refractionRatio,\n const int selfIllumColorOn,\n const vec4 ambientColor, const vec4 diffuseColor, const vec4 specularColor,\n const float glossiness, const float specularLevel, const vec4 selfIllum,\n const float opacity, const vec4 filterColor, const vec3 normal,\n const vec4 reflection, const vec4 refraction, const float displacement,\n out vec4 outColor)\n{\n vec3 diffuse, specular;\n NodeMaterial material;\n material.diffuseColor = diffuseColor.rgb;\n material.specularColor = specularColor.rgb;\n material.diffuseIntensity = 1.0;\n material.specularHardness = 4.0 * exp2(glossiness * 10.0);\n material.specularIntensity = specularLevel;\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #include \n #include \n #include \n vec3 totalEmissiveRadiance;\n if (selfIllumColorOn == 1)\n totalEmissiveRadiance = selfIllum.rgb;\n else\n totalEmissiveRadiance = vec3(selfIllum[0] * material.diffuseColor);\n diffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\n totalEmissiveRadiance;\n specular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n float specularStrength = maxFromRGB(specular);\n outColor = vec4(saturate(diffuse + specular), 1.0);\n float alpha = opacity - saturate(maxFromRGB(specular)) * (opacity - 1.0);\n outColor += reflection * specularColor * reflectionRatio;\n outColor += refraction * refractionRatio;\n alpha += saturate(maxFromRGB(reflection.rgb) * maxFromRGB(specularColor.rgb)) * reflectionRatio;\n alpha += saturate(maxFromRGB(refraction.rgb)) * refractionRatio;\n outColor.a = alpha;\n}",node_mix_max_frag:"void node_mix_max(const vec4 color1, const vec4 color2, const float amount, out vec4 color)\n{\n color = mix(color1, color2, clamp(amount, 0.0, 1.0));\n}",node_normal_bump_max_frag:"void node_normal_bump_max(const vec4 tangent, const vec3 normal, ivec2 flip,\n vec4 normalColor, vec3 additionalBump, float normalMult, float addBumpMult,\n out vec3 normalOut)\n{\n if (flip[0] == 1)\n normalColor.x = 1.0 - normalColor.x;\n if (flip[1] == 0)\n normalColor.y = 1.0 - normalColor.y;\n vec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\n vec4 viewTangent = vec4(normalize(modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz, tangent.w);\n vec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\n normalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n + normalTex.z * normal);\n normalOut = mix(normal, normalOut, normalMult);\n additionalBump = mix(normal, additionalBump, addBumpMult);\n normalOut = normalize(normalOut + additionalBump);\n}",node_output_map_max_frag:"vec4 processOutputColor(vec4 color, const bool invert, const bool clampColor, const bool alphaFromRGB, \n const float rgbLevel, const float rgbOffset, const float outputAmount)\n{\n vec3 color3 = color.rgb;\n color3 = invert ? (vec3(1.0) - color3) : color3;\n color3 = clampColor ? saturate(color3) : color3;\n color = outputAmount * vec4(color3 * rgbLevel + vec3(rgbOffset), color.a);\n color.a = alphaFromRGB ? average(color.rgb) : color.a;\n return color;\n}\nvoid node_output_map_max(\n const bool invert, const bool clampColor, const bool alphaFromRGB, \n const vec4 color, const float rgbLevel, const float rgbOffset, \n const float outputAmount, const float bumpAmount,\n out vec4 outColor)\n{\n outColor = processOutputColor(color, invert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}\nvoid node_output_map_max(\n const bool invert, const bool clampColor, const bool alphaFromRGB, sampler2D colormap,\n vec4 color, const float rgbLevel, const float rgbOffset, \n const float outputAmount, const float bumpAmount,\n out vec4 outColor)\n{\n float r = texture2D(colormap, vec2(color.r, 0.0)).r;\n float g = texture2D(colormap, vec2(color.g, 0.0)).g;\n float b = texture2D(colormap, vec2(color.b, 0.0)).b;\n outColor = processOutputColor(vec4(r, g, b, color.a),\n invert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}",node_output_max_frag:"void node_output_max(vec4 color, out vec4 outgoingLight)\n{\n outgoingLight = color;\n}",node_physical_max_frag:"#define DEFAULT_REFLECTION_EDGE 1.0\n#define DEFAULT_REFLECTION_SLOPE 5.0\nvoid node_physical_max(\n vec3 originalNormal, const float emitLuminance, const int useCustomReflCurve,\n const float reflFacing, const float reflEdge, const float reflSlope,\n const bool roughnessInv, const bool transRoughnessLock, const bool transRoughnessInv,\n const bool thinWalled,\n const float baseWeight, const vec4 baseColor, const float reflectivity,\n const vec4 reflColor, const float roughness, const float metalness,\n const float diffRoughness, const float anisotropy, const float anisoangle,\n const float transparency, const vec4 transColor, const float transRoughness,\n const float ior, const float scattering, const vec4 sssColor,\n const float sssScale, const float emission, const vec4 emitColor,\n const float coating, const vec4 coatColor, const float coatRoughness,\n const vec3 normal, const vec3 coatNormal, const float displacement,\n const float cutout,\n out vec4 outColor)\n{\n NodeMaterial material;\n vec3 baseColorWeighted = baseWeight * baseColor.rgb;\n material.diffuseColor = baseColorWeighted * (1.0 - transparency);\n#ifndef STANDARD\n material.clearCoat = saturate(coating);\n material.clearCoatRoughness = clamp(coatRoughness, 0.04, 1.0);\n#endif\n float facing, edge, slope;\n if (useCustomReflCurve == 1) {\n facing = reflFacing;\n edge = reflEdge;\n slope = reflSlope;\n } else {\n facing = pow2((1.0 - ior) / (1.0 + ior));\n edge = DEFAULT_REFLECTION_EDGE;\n slope = DEFAULT_REFLECTION_SLOPE;\n }\n float cosTheta = saturate(dot(normal, normalize(vViewPosition)));\n float fresnelRefl = (facing + (edge - facing) * pow(1.0 - cosTheta, slope))\n * saturate(reflectivity + metalness);\n float kd = 1.0 - (metalness * (1.0 - fresnelRefl) + fresnelRefl);\n material.specularColor = mix(metalness * baseColorWeighted, reflColor.rgb, fresnelRefl);\n material.diffuseColor *= kd;\n material.specularRoughness = clamp(roughnessInv ? (1.0 - roughness) : roughness, 0.0, 1.0);\n material.refractionColor = pow(transparency * (1.0 - metalness) * transColor.rgb, vec3(2.0));\n material.refractionIOR = ior;\n float tRough;\n if (transRoughnessLock) {\n tRough = roughnessInv ? 1.0 - roughness : roughness;\n } else {\n tRough = transRoughnessInv ? 1.0 - transRoughness : transRoughness;\n }\n material.refractionRoughness = pow2(tRough);\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #define ORIGINAL_NORMAL originalNormal\n #define COAT_NORMAL coatNormal\n #define USE_REFRACTED_LIGHT\n vec3 refractedLight = vec3(0.0);\n #include \n #include \n #include \n #undef USE_REFRACTED_LIGHT\n #undef COAT_NORMAL\n #undef ORIGINAL_NORMAL\n vec3 totalEmissiveRadiance = emitLuminance / LUMENS_PER_WATT * emission * emitColor.rgb;\n vec3 specular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n vec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\n specular + totalEmissiveRadiance;\n float alpha = 1.0;\n if (thinWalled) {\n alpha = 1.0 - saturate(transparency) + maxFromRGB(specular) * saturate(transparency);\n } else {\n outColor3 += refractedLight;\n }\n outColor = vec4(outColor3, saturate(alpha));\n}",node_phy_sun_sky_env_max_frag:"vec3 perezSky(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\n vec3 radiance, vec3 sunDirection, vec3 direction)\n{\n float cosGamma = clamp(dot(direction, sunDirection), -1.0, 1.0);\n float cosTheta = clamp(direction.y, 0.0, 1.0);\n vec3 radInternal = (1.0 + paramA * exp(paramB / cosTheta)) * (\n 1.0 + paramC * exp(paramD * acos(cosGamma))\n + paramE * pow(cosGamma, 2.0)\n );\n float ciex = radInternal.y * radiance.y;\n float ciey = radInternal.z * radiance.z;\n float cieY = clamp(radInternal.x * radiance.x, 0.0, 1000000.0);\n vec3 XYZ = xyY_to_XYZ(ciex, ciey, cieY);\n return max(xyz_to_sRGB(XYZ), 0.0);\n}\n#define GROUND_SKY_SAMPLES 16\nvec3 groundSky(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE, vec3 radiance, vec3 sunDirection, vec3 sunIlluminance)\n{\n const int horizSamples = GROUND_SKY_SAMPLES;\n const int vertSamples = GROUND_SKY_SAMPLES / 2;\n vec3 result = vec3(0.0);\n for (int horizSampleIdx = 0; horizSampleIdx < horizSamples; horizSampleIdx++) {\n float horizSample = float(horizSampleIdx) / float(horizSamples);\n float horizAngle = PI2 * horizSample;\n for (int vertSampleIdx = 0; vertSampleIdx < vertSamples; vertSampleIdx++) {\n float vertSample = float(vertSampleIdx) / float(vertSamples);\n float y = 1.0 - vertSample;\n float x = sqrt(1.0 - y*y) * cos(horizAngle);\n float z = -sqrt(1.0 - y*y) * sin(horizAngle);\n vec3 direction = vec3(x, y, z);\n vec3 sampleColor = perezSky(paramA, paramB, paramC, paramD, paramE,\n radiance, sunDirection, direction);\n \n result += direction.y * sampleColor;\n }\n }\n result /= float(horizSamples * vertSamples);\n result += (sunIlluminance * sunDirection.y) / PI;\n return result;\n}\nvoid node_phy_sun_sky_env_max(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\n vec3 radiance, vec3 sunDirection, vec3 sunIlluminance, vec3 sunLuminance, \n float globalIntensity, vec4 groundColor,\n out vec4 outColor) \n{\n vec3 dir = vWorldPosition;\n if (length(dir) == 0.0) {\n dir = vec3(0.0, 0.0, -1.0);\n } else {\n dir = normalize(dir);\n }\n if (dir.y < 0.0) {\n outColor = groundColor * vec4(groundSky(paramA, paramB, paramC, paramD, paramE, radiance, sunDirection, sunIlluminance), 1.0);\n } else {\n outColor = vec4(perezSky(paramA, paramB, paramC, paramD, paramE,\n radiance, sunDirection, dir), 1.0);\n }\n outColor = globalIntensity * outColor;\n}",node_reflect_refract_max_frag:"void node_reflect_refract_max(sampler2D envMap,\n int reflectMode, const float IOR, const int encoding,\n vec3 normal, out vec4 color)\n{\n vec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\n vec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\n vec3 reflectVec;\n if (reflectMode == MAX_ENV_COORDS_REFLECT)\n reflectVec = reflect(cameraToVertex, worldNormal);\n else {\n float refrRatio = 1.0 / IOR;\n reflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n }\n reflectVec = normalize(reflectVec);\n color = sampleEquirectangular(envMap, reflectVec, mat3(1.0), encoding);\n}",node_reflect_refract_color_max_frag:"void node_reflect_refract_color_max(const vec4 colorIn, out vec4 color)\n{\n color = vec4(colorIn);\n}",node_rgb_multiply_max_frag:"void node_rgb_multiply_max(const vec4 color1, const vec4 color2, out vec4 color)\n{\n color = color1 * color2;\n}",node_rgb_tint_max_frag:"void node_rgb_tint_max(const vec4 color, const vec4 red, const vec4 green, const vec4 blue,\n out vec4 outColor)\n{\n mat3 tintMatrix = mat3(red.rgb, green.rgb, blue.rgb);\n outColor = vec4(tintMatrix * color.rgb, color.a);\n}",node_shellac_max_frag:"void node_shellac_max(const vec4 color1, const vec4 color2, const float amount,\n out vec4 color)\n{\n color = mix(color1, color2, clamp(amount, 0.0, 1.0));\n}",node_vertex_color_max_frag:"void node_vertex_color_max(vec3 color, out vec4 outColor)\n{\n outColor = vec4(color, 1.0);\n}",pp_plane_vert:"varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",pp_brightness_contrast_frag:"\nuniform sampler2D tDiffuse;\nuniform float brightness;\nuniform float contrast;\nvarying vec2 vUv;\nvoid main() {\n vec4 texel = texture2D(tDiffuse, vUv);\n texel.rgb += brightness;\n if (contrast > 0.0)\n texel.rgb = (texel.rgb - 0.5) / (1.0 - contrast) + 0.5;\n else\n texel.rgb = (texel.rgb - 0.5) * (1.0 + contrast) + 0.5;\n gl_FragColor = texel;\n}",pp_bokeh_frag:"#include \nvarying vec2 vUv;\nuniform sampler2D tColor;\nuniform sampler2D tDepth;\nuniform float maxblur;\nuniform float aperture;\nuniform float nearClip;\nuniform float farClip;\nuniform float focus;\nuniform float aspect;\nuniform float depthLeakThreshold;\n#include \nfloat getDepth(const in vec2 screenPosition) {\n#if DEPTH_PACKING == 1\n return unpackRGBAToDepth(texture2D(tDepth, screenPosition));\n#else\n return texture2D(tDepth, screenPosition).x;\n#endif\n}\nfloat getViewZ(const in float depth) {\n#if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, nearClip, farClip);\n#else\n return orthoDepthToViewZ(depth, nearClip, farClip);\n#endif\n}\nvec4 blurSample(vec2 uvOffset, vec4 centerCol, float viewZCenter) {\n float viewZ = -getViewZ(getDepth(vUv + uvOffset));\n float blurFactor = (viewZ >= viewZCenter) ? 1.0 : \n min(depthLeakThreshold * abs((focus - viewZ) / aperture), 1.0);\n return mix(centerCol, texture2D(tColor, vUv + uvOffset), blurFactor);\n}\nvoid main() {\n vec2 aspectcorrect = vec2(1.0, aspect);\n float viewZ = -getViewZ(getDepth(vUv));\n float factor = abs(focus - viewZ);\n \n float dofblur = maxblur * min(factor / aperture, 1.0);\n float dofblur9 = dofblur * 0.9;\n float dofblur7 = dofblur * 0.7;\n float dofblur4 = dofblur * 0.4;\n vec4 centerCol = texture2D(tColor, vUv);\n vec4 col = centerCol;\n col += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2( 0.15, 0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2(-0.37, 0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2( 0.40, 0.0 ) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2( 0.37, -0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2(-0.15, -0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2(-0.15, 0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2( 0.37, 0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2(-0.37, -0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\n col += blurSample((vec2( 0.15, -0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\n \n col += blurSample((vec2( 0.15, 0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\n col += blurSample((vec2(-0.37, 0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\n col += blurSample((vec2( 0.37, -0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\n col += blurSample((vec2(-0.15, -0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\n col += blurSample((vec2(-0.15, 0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\n col += blurSample((vec2( 0.37, 0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\n col += blurSample((vec2(-0.37, -0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\n col += blurSample((vec2( 0.15, -0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\n \n col += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\n col += blurSample((vec2( 0.40, 0.0 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\n col += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\n col += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\n col += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\n col += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\n col += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\n col += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\n \n col += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\n col += blurSample((vec2( 0.4, 0.0 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\n col += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\n col += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\n col += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\n col += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\n col += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\n col += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\n gl_FragColor = col / 41.0;\n gl_FragColor.a = centerCol.a;\n}",pp_copy_frag:"uniform sampler2D tDiffuse;\nuniform float opacity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texel = (texture2D(tDiffuse, vUv));\n #if MAP_TEXELS == 1\n texel = mapTexelToLinear(texel);\n #endif\n gl_FragColor = opacity * texel;\n #if MAP_TEXELS == 1\n #include \n #include \n #endif\n}",pp_fxaa_frag:"precision highp float;\nuniform sampler2D tDiffuse;\nuniform vec2 resolution;\nvarying vec2 vUv;\n#define FXAA_PC 1\n#define FXAA_GLSL_100 1\n#define FXAA_QUALITY_PRESET 12\n#define FXAA_GREEN_AS_LUMA 1\n#ifndef FXAA_PC_CONSOLE\n #define FXAA_PC_CONSOLE 0\n#endif\n#ifndef FXAA_GLSL_120\n #define FXAA_GLSL_120 0\n#endif\n#ifndef FXAA_GLSL_130\n #define FXAA_GLSL_130 0\n#endif\n#ifndef FXAA_HLSL_3\n #define FXAA_HLSL_3 0\n#endif\n#ifndef FXAA_HLSL_4\n #define FXAA_HLSL_4 0\n#endif\n#ifndef FXAA_HLSL_5\n #define FXAA_HLSL_5 0\n#endif\n#ifndef FXAA_GREEN_AS_LUMA\n #define FXAA_GREEN_AS_LUMA 0\n#endif\n#ifndef FXAA_EARLY_EXIT\n #define FXAA_EARLY_EXIT 1\n#endif\n#ifndef FXAA_DISCARD\n #define FXAA_DISCARD 1\n#endif\n#ifndef FXAA_FAST_PIXEL_OFFSET\n #ifdef GL_EXT_gpu_shader4\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifdef GL_NV_gpu_shader5\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifdef GL_ARB_gpu_shader5\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifndef FXAA_FAST_PIXEL_OFFSET\n #define FXAA_FAST_PIXEL_OFFSET 0\n #endif\n#endif\n#ifndef FXAA_GATHER4_ALPHA\n #if (FXAA_HLSL_5 == 1)\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifdef GL_ARB_gpu_shader5\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifdef GL_NV_gpu_shader5\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifndef FXAA_GATHER4_ALPHA\n #define FXAA_GATHER4_ALPHA 0\n #endif\n#endif\n#ifndef FXAA_QUALITY_PRESET\n #define FXAA_QUALITY_PRESET 12\n#endif\n#if (FXAA_QUALITY_PRESET == 10)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 3.0\n #define FXAA_QUALITY_P2 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 11)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 3.0\n #define FXAA_QUALITY_P3 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 12)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 4.0\n #define FXAA_QUALITY_P4 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 13)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 4.0\n #define FXAA_QUALITY_P5 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 14)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 4.0\n #define FXAA_QUALITY_P6 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 15)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 20)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 2.0\n #define FXAA_QUALITY_P2 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 21)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 22)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 23)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 24)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 3.0\n #define FXAA_QUALITY_P6 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 25)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 26)\n #define FXAA_QUALITY_PS 9\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 4.0\n #define FXAA_QUALITY_P8 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 27)\n #define FXAA_QUALITY_PS 10\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 4.0\n #define FXAA_QUALITY_P9 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 28)\n #define FXAA_QUALITY_PS 11\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 4.0\n #define FXAA_QUALITY_P10 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 29)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 39)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.0\n #define FXAA_QUALITY_P2 1.0\n #define FXAA_QUALITY_P3 1.0\n #define FXAA_QUALITY_P4 1.0\n #define FXAA_QUALITY_P5 1.5\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)\n #define FxaaBool bool\n #define FxaaDiscard discard\n #define FxaaFloat float\n #define FxaaFloat2 vec2\n #define FxaaFloat3 vec3\n #define FxaaFloat4 vec4\n #define FxaaHalf float\n #define FxaaHalf2 vec2\n #define FxaaHalf3 vec3\n #define FxaaHalf4 vec4\n #define FxaaInt2 ivec2\n #define FxaaSat(x) clamp(x, 0.0, 1.0)\n #define FxaaTex sampler2D\n#else\n #define FxaaBool bool\n #define FxaaDiscard clip(-1)\n #define FxaaFloat float\n #define FxaaFloat2 float2\n #define FxaaFloat3 float3\n #define FxaaFloat4 float4\n #define FxaaHalf half\n #define FxaaHalf2 half2\n #define FxaaHalf3 half3\n #define FxaaHalf4 half4\n #define FxaaSat(x) saturate(x)\n#endif\n#if (FXAA_GLSL_100 == 1)\n #define FxaaTexTop(t, p) texture2D(t, p, 0.0)\n #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)\n#endif\n#if (FXAA_GLSL_120 == 1)\n #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n #if (FXAA_FAST_PIXEL_OFFSET == 1)\n #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)\n #else\n #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n #endif\n #if (FXAA_GATHER4_ALPHA == 1)\n #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n #define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n #endif\n#endif\n#if (FXAA_GLSL_130 == 1)\n #define FxaaTexTop(t, p) textureLod(t, p, 0.0)\n #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)\n #if (FXAA_GATHER4_ALPHA == 1)\n #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n #define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n #endif\n#endif\n#if (FXAA_HLSL_3 == 1)\n #define FxaaInt2 float2\n #define FxaaTex sampler2D\n #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))\n #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))\n#endif\n#if (FXAA_HLSL_4 == 1)\n #define FxaaInt2 int2\n struct FxaaTex { SamplerState smpl; Texture2D tex; };\n #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n#endif\n#if (FXAA_HLSL_5 == 1)\n #define FxaaInt2 int2\n struct FxaaTex { SamplerState smpl; Texture2D tex; };\n #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)\n #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)\n #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)\n #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)\n#endif\n#if (FXAA_GREEN_AS_LUMA == 0)\n FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }\n#else\n FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }\n#endif\n#if (FXAA_PC == 1)\nFxaaFloat4 FxaaPixelShader(\n FxaaFloat2 pos,\n FxaaFloat4 fxaaConsolePosPos,\n FxaaTex tex,\n FxaaTex fxaaConsole360TexExpBiasNegOne,\n FxaaTex fxaaConsole360TexExpBiasNegTwo,\n FxaaFloat2 fxaaQualityRcpFrame,\n FxaaFloat4 fxaaConsoleRcpFrameOpt,\n FxaaFloat4 fxaaConsoleRcpFrameOpt2,\n FxaaFloat4 fxaaConsole360RcpFrameOpt2,\n FxaaFloat fxaaQualitySubpix,\n FxaaFloat fxaaQualityEdgeThreshold,\n FxaaFloat fxaaQualityEdgeThresholdMin,\n FxaaFloat fxaaConsoleEdgeSharpness,\n FxaaFloat fxaaConsoleEdgeThreshold,\n FxaaFloat fxaaConsoleEdgeThresholdMin,\n FxaaFloat4 fxaaConsole360ConstDir\n) {\n FxaaFloat2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n #if (FXAA_GATHER4_ALPHA == 1)\n #if (FXAA_DISCARD == 0)\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #if (FXAA_GREEN_AS_LUMA == 0)\n #define lumaM rgbyM.w\n #else\n #define lumaM rgbyM.y\n #endif\n #endif\n #if (FXAA_GREEN_AS_LUMA == 0)\n FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);\n FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));\n #else\n FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);\n FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));\n #endif\n #if (FXAA_DISCARD == 1)\n #define lumaM luma4A.w\n #endif\n #define lumaE luma4A.z\n #define lumaS luma4A.x\n #define lumaSE luma4A.y\n #define lumaNW luma4B.w\n #define lumaN luma4B.z\n #define lumaW luma4B.x\n #else\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #if (FXAA_GREEN_AS_LUMA == 0)\n #define lumaM rgbyM.w\n #else\n #define lumaM rgbyM.y\n #endif\n #if (FXAA_GLSL_100 == 1)\n FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(0.0, 1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0, 0.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(0.0,-1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));\n #else\n FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(0, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, 0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(0,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n #endif\n #endif\n FxaaFloat maxSM = max(lumaS, lumaM);\n FxaaFloat minSM = min(lumaS, lumaM);\n FxaaFloat maxESM = max(lumaE, maxSM);\n FxaaFloat minESM = min(lumaE, minSM);\n FxaaFloat maxWN = max(lumaN, lumaW);\n FxaaFloat minWN = min(lumaN, lumaW);\n FxaaFloat rangeMax = max(maxWN, maxESM);\n FxaaFloat rangeMin = min(minWN, minESM);\n FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n FxaaFloat range = rangeMax - rangeMin;\n FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n FxaaBool earlyExit = range < rangeMaxClamped;\n if(earlyExit)\n #if (FXAA_DISCARD == 1)\n return rgbyM;\n #else\n return rgbyM;\n #endif\n #if (FXAA_GATHER4_ALPHA == 0)\n #if (FXAA_GLSL_100 == 1)\n FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0, 1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0,-1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));\n #else\n FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n #endif\n #else\n FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n #endif\n FxaaFloat lumaNS = lumaN + lumaS;\n FxaaFloat lumaWE = lumaW + lumaE;\n FxaaFloat subpixRcpRange = 1.0/range;\n FxaaFloat subpixNSWE = lumaNS + lumaWE;\n FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\n FxaaFloat lumaNESE = lumaNE + lumaSE;\n FxaaFloat lumaNWNE = lumaNW + lumaNE;\n FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n FxaaFloat lumaNWSW = lumaNW + lumaSW;\n FxaaFloat lumaSWSE = lumaSW + lumaSE;\n FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\n FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\n FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\n FxaaFloat lengthSign = fxaaQualityRcpFrame.x;\n FxaaBool horzSpan = edgeHorz >= edgeVert;\n FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n if(!horzSpan) lumaN = lumaW;\n if(!horzSpan) lumaS = lumaE;\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\n FxaaFloat gradientN = lumaN - lumaM;\n FxaaFloat gradientS = lumaS - lumaM;\n FxaaFloat lumaNN = lumaN + lumaM;\n FxaaFloat lumaSS = lumaS + lumaM;\n FxaaBool pairN = abs(gradientN) >= abs(gradientS);\n FxaaFloat gradient = max(abs(gradientN), abs(gradientS));\n if(pairN) lengthSign = -lengthSign;\n FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\n FxaaFloat2 posB;\n posB.x = posM.x;\n posB.y = posM.y;\n FxaaFloat2 offNP;\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n offNP.y = (horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n if(!horzSpan) posB.x += lengthSign * 0.5;\n if(horzSpan) posB.y += lengthSign * 0.5;\n FxaaFloat2 posN;\n posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\n posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\n FxaaFloat2 posP;\n posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\n posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\n FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\n FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));\n FxaaFloat subpixE = subpixC * subpixC;\n FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));\n if(!pairN) lumaNN = lumaSS;\n FxaaFloat gradientScaled = gradient * 1.0/4.0;\n FxaaFloat lumaMM = lumaM - lumaNN * 0.5;\n FxaaFloat subpixF = subpixD * subpixE;\n FxaaBool lumaMLTZero = lumaMM < 0.0;\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n FxaaBool doneN = abs(lumaEndN) >= gradientScaled;\n FxaaBool doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\n FxaaBool doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n #if (FXAA_QUALITY_PS > 3)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n #if (FXAA_QUALITY_PS > 4)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n #if (FXAA_QUALITY_PS > 5)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n #if (FXAA_QUALITY_PS > 6)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n #if (FXAA_QUALITY_PS > 7)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n #if (FXAA_QUALITY_PS > 8)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n #if (FXAA_QUALITY_PS > 9)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n #if (FXAA_QUALITY_PS > 10)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n #if (FXAA_QUALITY_PS > 11)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n #if (FXAA_QUALITY_PS > 12)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n }\n #endif\n }\n #endif\n }\n #endif\n }\n #endif\n }\n #endif\n }\n #endif\n }\n #endif\n }\n #endif\n }\n #endif\n }\n #endif\n }\n FxaaFloat dstN = posM.x - posN.x;\n FxaaFloat dstP = posP.x - posM.x;\n if(!horzSpan) dstN = posM.y - posN.y;\n if(!horzSpan) dstP = posP.y - posM.y;\n FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n FxaaFloat spanLength = (dstP + dstN);\n FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n FxaaFloat spanLengthRcp = 1.0/spanLength;\n FxaaBool directionN = dstN < dstP;\n FxaaFloat dst = min(dstN, dstP);\n FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\n FxaaFloat subpixG = subpixF * subpixF;\n FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n FxaaFloat subpixH = subpixG * fxaaQualitySubpix;\n FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n if(horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n #if (FXAA_DISCARD == 1)\n return FxaaTexTop(tex, posM);\n #else\n return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);\n #endif\n}\n#endif\nvoid main() {\n gl_FragColor = FxaaPixelShader(\n vUv,\n vec4(0.0),\n tDiffuse,\n tDiffuse,\n tDiffuse,\n resolution,\n vec4(0.0),\n vec4(0.0),\n vec4(0.0),\n 0.75,\n 0.166,\n 0.0833,\n 0.0,\n 0.0,\n 0.0,\n vec4(0.0)\n );\n \n}",pp_grayscale_frag:"uniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\n vec4 texel = texture2D(tDiffuse, vUv);\n float bw = texel.r * 0.35 + texel.g * 0.45 + texel.b * 0.2;\n texel = vec4(bw, bw, bw, texel.a);\n gl_FragColor = texel;\n}",pp_outline_edge_frag:"varying vec2 vUv;\nuniform sampler2D maskTexture;\nuniform vec2 texSize;\nuniform vec3 visibleEdgeColor;\nuniform vec3 hiddenEdgeColor;\nvoid main() {\n vec2 invSize = 1.0 / texSize;\n vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n vec4 c1 = texture2D(maskTexture, vUv + uvOffset.xy);\n vec4 c2 = texture2D(maskTexture, vUv - uvOffset.xy);\n vec4 c3 = texture2D(maskTexture, vUv + uvOffset.yw);\n vec4 c4 = texture2D(maskTexture, vUv - uvOffset.yw);\n float diff1 = (c1.r - c2.r) * 0.5;\n float diff2 = (c3.r - c4.r) * 0.5;\n float d = length(vec2(diff1, diff2));\n float a1 = min(c1.g, c2.g);\n float a2 = min(c3.g, c4.g);\n float visibilityFactor = min(a1, a2);\n vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n}",pp_outline_blur_frag:"#include \nvarying vec2 vUv;\nuniform sampler2D colorTexture;\nuniform vec2 texSize;\nuniform vec2 direction;\nuniform float kernelRadius;\nfloat gaussianPdf(in float x, in float sigma) {\n return 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma;\n}\nvoid main() {\n vec2 invSize = 1.0 / texSize;\n float weightSum = gaussianPdf(0.0, kernelRadius);\n vec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\n vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n vec2 uvOffset = delta;\n for (int i = 1; i <= MAX_RADIUS; i++) {\n float w = gaussianPdf(uvOffset.x, kernelRadius);\n vec3 sample1 = texture2D(colorTexture, vUv + uvOffset).rgb;\n vec3 sample2 = texture2D(colorTexture, vUv - uvOffset).rgb;\n diffuseSum += ((sample1 + sample2) * w);\n weightSum += (2.0 * w);\n uvOffset += delta;\n }\n gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n}",pp_outline_overlay_frag:"varying vec2 vUv;\nuniform sampler2D maskTexture;\nuniform sampler2D edgeTexture1;\nuniform sampler2D edgeTexture2;\nuniform sampler2D patternTexture;\nuniform float edgeStrength;\nuniform float edgeGlow;\nuniform bool usePatternTexture;\nvoid main() {\n vec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n vec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n vec4 maskColor = texture2D(maskTexture, vUv);\n vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n vec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n if (usePatternTexture)\n finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n gl_FragColor = finalColor;\n}",pp_ssao_frag:"uniform float cameraNear;\nuniform float cameraFar;\n#ifdef USE_LOGDEPTHBUF\n uniform float logDepthBufFC;\n#endif\nuniform float radius;\nuniform bool onlyAO;\nuniform vec2 size;\nuniform float aoClamp;\nuniform float lumInfluence;\nuniform sampler2D tDiffuse;\nuniform sampler2D tDepth;\nvarying vec2 vUv;\n#define DL 2.399963229728653 \n#define EULER 2.718281828459045\nconst int samples = 64;\nconst bool useNoise = true;\nconst float noiseAmount = 0.0004;\nconst float diffArea = 0.25;\nconst float gDisplace = 0.4;\n#include \nvec2 rand(const vec2 coord) {\n vec2 noise;\n if (useNoise) {\n float nx = dot (coord, vec2(12.9898, 78.233));\n float ny = dot (coord, vec2(12.9898, 78.233) * 2.0);\n noise = clamp(fract (43758.5453 * sin(vec2(nx, ny))), 0.0, 1.0);\n } else {\n float ff = fract(1.0 - coord.s * (size.x / 2.0));\n float gg = fract(coord.t * (size.y / 2.0));\n noise = vec2(0.25, 0.75) * vec2(ff) + vec2(0.75, 0.25) * gg;\n }\n return (noise * 2.0 - 1.0) * noiseAmount;\n}\nfloat readDepth(const in vec2 coord) {\n float cameraFarPlusNear = cameraFar + cameraNear;\n float cameraFarMinusNear = cameraFar - cameraNear;\n float cameraCoef = 2.0 * cameraNear;\n #ifdef USE_LOGDEPTHBUF\n float logz = unpackRGBAToDepth(texture2D(tDepth, coord));\n float w = pow(2.0, (logz / logDepthBufFC)) - 1.0;\n float z = (logz / w) + 1.0;\n #else\n float z = unpackRGBAToDepth(texture2D(tDepth, coord));\n #endif\n return cameraCoef / (cameraFarPlusNear - z * cameraFarMinusNear);\n}\nfloat compareDepths(const in float depth1, const in float depth2, inout int far) {\n float garea = 8.0;\n float diff = (depth1 - depth2) * 100.0;\n if (diff < gDisplace) {\n garea = diffArea;\n } else {\n far = 1;\n }\n float dd = diff - gDisplace;\n float gauss = pow(EULER, -2.0 * (dd * dd) / (garea * garea));\n return gauss;\n}\nfloat calcAO(float depth, float dw, float dh) {\n vec2 vv = vec2(dw, dh);\n vec2 coord1 = vUv + radius * vv;\n vec2 coord2 = vUv - radius * vv;\n float temp1 = 0.0;\n float temp2 = 0.0;\n int far = 0;\n temp1 = compareDepths(depth, readDepth(coord1), far);\n if (far > 0) {\n temp2 = compareDepths(readDepth(coord2), depth, far);\n temp1 += (1.0 - temp1) * temp2;\n }\n return temp1;\n}\nvoid main() {\n vec2 noise = rand(vUv);\n float depth = readDepth(vUv);\n float tt = clamp(depth, aoClamp, 1.0);\n float w = (1.0 / size.x) / tt + (noise.x * (1.0 - noise.x));\n float h = (1.0 / size.y) / tt + (noise.y * (1.0 - noise.y));\n float ao = 0.0;\n float dz = 1.0 / float(samples);\n float l = 0.0;\n float z = 1.0 - dz / 2.0;\n for (int i = 0; i <= samples; i++) {\n float r = sqrt(1.0 - z);\n float pw = cos(l) * r;\n float ph = sin(l) * r;\n ao += calcAO(depth, pw * w, ph * h);\n z = z - dz;\n l = l + DL;\n }\n ao /= float(samples);\n ao = 1.0 - ao;\n vec4 color = texture2D(tDiffuse, vUv);\n vec3 lumcoeff = vec3(0.299, 0.587, 0.114);\n float lum = dot(color.rgb, lumcoeff);\n vec3 luminance = vec3(lum);\n vec3 final = vec3(color.rgb * mix(vec3(ao), vec3(1.0), luminance * lumInfluence));\n if (onlyAO) {\n final = vec3(mix(vec3(ao), vec3(1.0), luminance * lumInfluence));\n }\n gl_FragColor = vec4(final, color.a);\n}",pp_tonemap_frag:"uniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\n gl_FragColor = vec4(texture2D(tDiffuse, vUv));\n #include \n gl_FragColor = LinearTosRGB(gl_FragColor);\n}",raw_meshline_frag:"precision mediump float;\nuniform sampler2D map;\nuniform sampler2D alphaMap;\nuniform float useMap;\nuniform float useAlphaMap;\nuniform float visibility;\nuniform float alphaTest;\nuniform vec2 repeat;\nuniform vec3 color;\nuniform float opacity;\nvarying vec2 vUV;\nvarying float vCounters;\nvec4 LinearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92,\n vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\nvoid main() {\n vec4 c = vec4(color, opacity);\n \n if (useMap == 1.0) {\n c *= texture2D(map, vUV * repeat);\n }\n if (useAlphaMap == 1.0) {\n c.a *= texture2D(alphaMap, vUV * repeat).a;\n }\n if (c.a < alphaTest) {\n discard;\n }\n gl_FragColor = c;\n gl_FragColor.a *= step(vCounters, visibility);\n gl_FragColor = LinearTosRGB(gl_FragColor);\n}",raw_meshline_vert:"precision highp float;\nattribute vec3 position;\nattribute vec3 previous;\nattribute vec3 next;\nattribute float side;\nattribute float width;\nattribute vec2 uv;\nattribute float counters;\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\nuniform vec2 resolution;\nuniform float lineWidth;\nuniform float sizeAttenuation;\nvarying float vCounters;\nvarying vec2 vUV;\nconst float EQ_EPS = 0.000001;\nvec2 fix(vec4 i, float aspect) {\n vec2 res = i.xy / i.w;\n res.x *= aspect;\n return res;\n}\nbool posEqual(vec2 pos0, vec2 pos1) {\n return length(pos0 - pos1) < EQ_EPS;\n}\nvoid main() {\n float aspect = resolution.x / resolution.y;\n vCounters = counters;\n vUV = uv;\n mat4 m = projectionMatrix * modelViewMatrix;\n vec4 finalPosition = m * vec4(position, 1.0);\n vec4 prevPos = m * vec4(previous, 1.0);\n vec4 nextPos = m * vec4(next, 1.0);\n vec2 currentP = fix(finalPosition, aspect);\n vec2 prevP = fix(prevPos, aspect);\n vec2 nextP = fix(nextPos, aspect);\n float w = lineWidth * width;\n if (sizeAttenuation == 0.0) {\n w *= finalPosition.w / resolution.x;\n }\n vec2 dir;\n if (posEqual(nextP, currentP)) {\n dir = normalize(currentP - prevP);\n } else if (posEqual(prevP, currentP)) {\n dir = normalize(nextP - currentP);\n } else {\n vec2 dir1 = normalize(currentP - prevP);\n vec2 dir2 = normalize(nextP - currentP);\n dir = normalize(dir1 + dir2);\n }\n vec2 offset = vec2(-dir.y, dir.x);\n offset.y *= aspect;\n offset *= w;\n finalPosition.xy += offset * side;\n gl_Position = finalPosition;\n}"};function Sn(e){var t={};for(var n in e)for(var r in t[n]={},e[n]){var i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture)?t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}return t}function Ln(e){for(var t={},n=0;n>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,n){return this.r=e,this.g=t,this.b=n,this},setHSL:function(){function a(e,t,n){return n<0&&(n+=1),1t&&(t=e[n]);return t}function jn(e){return void 0!==e}function Wn(e,t,n){for(var r=0;rn.far?null:{distance:l,point:V.clone(),object:e}}function W(e,t,n,r,i,a,o,s,l,c){g.fromBufferAttribute(i,s),y.fromBufferAttribute(i,l),x.fromBufferAttribute(i,c);var u=e.morphTargetInfluences;if(t.morphTargets&&a&&u){A.set(0,0,0),M.set(0,0,0),T.set(0,0,0);for(var h=0,d=a.length;he.far)return;t.push({distance:O,point:V,face:null,faceIndex:null,object:this})}}}(),clone:function(e){return new this.constructor(this.geometry,this.material).copy(this,e)},isVisible:function(){return this.isMaterialGeneratedMesh&&this.parent?this.visible&&this.parent.visible:this.visible}}),((Wi.prototype=Object.create(fn.prototype)).constructor=Wi).prototype.isCubeTexture=!0,Object.defineProperty(Wi.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}}),((Xi.prototype=Object.create(fn.prototype)).constructor=Xi).prototype.isDataTexture2DArray=!0,((Hi.prototype=Object.create(fn.prototype)).constructor=Hi).prototype.isDataTexture3D=!0;var Yi=new fn,qi=new Xi,Qi=new Hi,Zi=new Wi,Ki=[],Ji=[],$i=new Float32Array(16),ea=new Float32Array(9),ta=new Float32Array(4);function na(e,t,n){var r=e[0];if(r<=0||0/gm,function(e,t){var n=Tn[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Xa(n)})}function Ha(e){for(var t,n=new RegExp("#pragma unroll_loop[\\s]+?for \\(int (\\w+) \\= (\\d+)\\; (\\w+) < (\\d+)\\; (\\w+)\\+\\+\\) \\{"),r=new RegExp("\\{|\\}","g");t=n.exec(e);){var i,a;i=a=r.lastIndex=t.index+t[0].length;for(var o,s=1;(o=r.exec(e))&&("{"==o[0]?s++:"}"==o[0]&&s--,a=o.index),o&&0",t[n]);return e}function Qa(d,c,p,u){var h=[],f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite",MeshMaskMaterial:"mask",MeshNodeMaterial:"node"},a=["precision","supportsVertexTextures","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","unitsScaleFactor","useHDR"];function m(e,t){var n;return e?e.isTexture?n=e.encoding:e.isWebGLRenderTarget&&(console.warn("v3d.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),n=e.texture.encoding):n=wt,n===bt&&t&&(n=At),n}this.getParameters=function(e,t,n,r,i,a,o){var s=f[e.type],l=o.isSkinnedMesh?function(e){var t=e.skeleton.bones;if(p.floatVertexTextures)return 1024;var n=p.maxVertexUniforms,r=Math.floor((n-20)/4),i=Math.min(r,t.length);return ir||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){var a=t?Nt.floorPowerOfTwo:Math.floor,o=a(i*e.width),s=a(i*e.height);void 0===u&&(u=h(o,s));var l=n?h(o,s):u;return l.width=o,l.height=s,l.getContext("2d").drawImage(e,0,0,o,s),console.warn("v3d.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+s+")."),l}return"data"in e&&console.warn("v3d.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function w(e){return Nt.isPowerOfTwo(e.width)&&Nt.isPowerOfTwo(e.height)}function A(e,t){return e.generateMipmaps&&t&&e.minFilter!==D&&e.minFilter!==B}function M(e,t,n,r){v.generateMipmap(e),y.get(t).__maxMipLevel=Math.log(Math.max(n,r))*Math.LOG2E}function T(e,t){if(!x.isWebGL2)return e;var n=e;return 6403===e&&(5126===t&&(n=33326),5131===t&&(n=33325),5121===t&&(n=33321)),6407===e&&(5126===t&&(n=34837),5131===t&&(n=34843),5121===t&&(n=32849)),6408===e&&(5126===t&&(n=34836),5131===t&&(n=34842),5121===t&&(n=32856)),33325===n||33326===n||34842===n||34836===n?i.get("EXT_color_buffer_float"):34843!==n&&34837!==n||console.warn("v3d.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),n}function a(e){return e===D||e===O||e===U?9728:9729}function r(e){var t=e.target;t.removeEventListener("dispose",r),function(e){var t=y.get(e);if(void 0===t.__webglInit)return;v.deleteTexture(t.__webglTexture),y.remove(e)}(t),t.isVideoTexture&&delete s[t.id],c.memory.textures--}function d(e){var t=e.target;t.removeEventListener("dispose",d),function(e){var t=y.get(e),n=y.get(e.texture);if(!e)return;void 0!==n.__webglTexture&&v.deleteTexture(n.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var r=0;r<6;r++)v.deleteFramebuffer(t.__webglFramebuffer[r]),t.__webglDepthbuffer&&v.deleteRenderbuffer(t.__webglDepthbuffer[r]);else v.deleteFramebuffer(t.__webglFramebuffer),t.__webglDepthbuffer&&v.deleteRenderbuffer(t.__webglDepthbuffer);y.remove(e.texture),y.remove(e)}(t),c.memory.textures--}var t=0;function o(e,t){var n,r,i,a=y.get(e);if(e.isVideoTexture&&(r=(n=e).id,i=c.render.frame,s[r]!==i&&(s[r]=i,n.update())),0=x.maxTextures&&console.warn("v3d.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+x.maxTextures),t+=1,e},this.resetTextureUnits=function(){t=0},this.setTexture2D=o,this.setTexture2DArray=function(e,t){var n=y.get(e);0",'Find out how to get it here.'].join("\n"):["Your browser does not seem to support WebGL.
",'Find out how to get it here.'].join("\n"),e},showWebGLErrorMessage:function(e){(e=e||document.body).appendChild(Do.genWebGLErrorMessage())},checkIOS:function(){return!!navigator.userAgent.match(/iPhone|iPad|iPod/i)},checkAndroid:function(){return!!navigator.userAgent.match(/Android/i)},checkHDR:function(e){var t=e.getContext();return!!(e.capabilities.isWebGL2&&t.getExtension("EXT_color_buffer_float")&&t.getExtension("OES_texture_float_linear"))||!(!t.getExtension("OES_texture_half_float")||!t.getExtension("OES_texture_half_float_linear"))},getGPUVendor:function(e){var t=e.getContext(),n=t.getExtension("WEBGL_debug_renderer_info");return null!=n?t.getParameter(n.UNMASKED_VENDOR_WEBGL):""},getGPUModel:function(e){var t=e.getContext(),n=t.getExtension("WEBGL_debug_renderer_info");return null!=n?t.getParameter(n.UNMASKED_RENDERER_WEBGL):""},checkNativeWebXR:function(){var e="polyfill"in window&&"WebXRPolyfill"in window&&polyfill instanceof WebXRPolyfill;return"xr"in navigator&&(!e||e&&polyfill.nativeWebXR)}};function Uo(e,t,n,r){this.ray=new Pi(e,t),this.near=n||0,this.far=r||1/0,this.params={Mesh:{omitGeometry:!1},Line:{},LOD:{},Points:{threshold:1},Sprite:{},checkVisibility:!0},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("v3d.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function Bo(e,t){return e.distance-t.distance}function zo(e,t,n,r,i){if(!(i&&(!1===e.visible||e.isMesh&&e.isMaterialGeneratedMesh&&e.parent&&!e.parent.visible)||(e.raycast(t,n),!0!==r)))for(var a=e.children,o=0,s=a.length;oe.far||t.push({distance:s,point:l.clone(),uv:Ri.getUV(l,d,p,f,m,v,g,new Dt),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return hr.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}}),Qo.prototype=Object.assign(Object.create(hr.prototype),{constructor:Qo,copy:function(e){hr.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,r=t.length;n=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(;re.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}))}else for(m=0,v=p.length/3-1;me.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}))}else if(r.isGeometry){var x=r.vertices,_=x.length;for(m=0;m<_-1;m+=h){var b;oe.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}))}}}}),copy:function(e){return hr.prototype.copy.call(this,e),this.geometry.copy(e.geometry),this.material.copy(e.material),this},clone:function(){return(new this.constructor).copy(this)}}),ts.prototype=Object.assign(Object.create(es.prototype),{constructor:ts,isLineSegments:!0,computeLineDistances:(Ro=new Bt,Fo=new Bt,function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,n=[],r=0,i=t.count;ri.far)return;a.push({distance:r,distanceToRay:Math.sqrt(n),point:c.clone(),index:t,face:null,object:o})}}}),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),as.prototype=Object.assign(Object.create(fn.prototype),{constructor:as,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),((os.prototype=Object.create(fn.prototype)).constructor=os).prototype.isCompressedTexture=!0,((ss.prototype=Object.create(fn.prototype)).constructor=ss).prototype.isCanvasTexture=!0,((ls.prototype=Object.create(fn.prototype)).constructor=ls).prototype.isDepthTexture=!0,(cs.prototype=Object.create(qr.prototype)).constructor=cs,(us.prototype=Object.create(Ar.prototype)).constructor=us,(hs.prototype=Object.create(qr.prototype)).constructor=hs,(ds.prototype=Object.create(Ar.prototype)).constructor=ds,(ps.prototype=Object.create(qr.prototype)).constructor=ps,(fs.prototype=Object.create(Ar.prototype)).constructor=fs,(ms.prototype=Object.create(ps.prototype)).constructor=ms,(vs.prototype=Object.create(Ar.prototype)).constructor=vs,(gs.prototype=Object.create(ps.prototype)).constructor=gs,(ys.prototype=Object.create(Ar.prototype)).constructor=ys,(xs.prototype=Object.create(ps.prototype)).constructor=xs,(_s.prototype=Object.create(Ar.prototype)).constructor=_s,(bs.prototype=Object.create(ps.prototype)).constructor=bs,(ws.prototype=Object.create(Ar.prototype)).constructor=ws,((As.prototype=Object.create(qr.prototype)).constructor=As).prototype.toJSON=function(){var e=qr.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e},(Ms.prototype=Object.create(Ar.prototype)).constructor=Ms,(Ts.prototype=Object.create(qr.prototype)).constructor=Ts,(Ss.prototype=Object.create(Ar.prototype)).constructor=Ss,(Ls.prototype=Object.create(qr.prototype)).constructor=Ls;var Cs=function(e,t,n){n=n||2;var r,i,a,o,s,l,c,u=t&&t.length,h=u?t[0]*n:e.length,d=Es(e,0,h,n,!0),p=[];if(!d)return p;if(u&&(d=function(e,t,n,r){var i,a,o,s,l,c=[];for(i=0,a=t.length;i80*n){r=a=e[0],i=o=e[1];for(var f=n;fa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=Bs(s,l,t,n,r),d=Bs(c,u,t,n,r),p=e.nextZ;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&Gs(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=ks(p.prev,p,p.next))return!1;p=p.nextZ}for(p=e.prevZ;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&Gs(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=ks(p.prev,p,p.next))return!1;p=p.prevZ}return!0}function Os(e,t,n){var r=e;do{var i=r.prev,a=r.next.next;!Vs(i,a)&&js(i,r,r.next,a)&&Ws(i,a)&&Ws(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),Ys(r),Ys(r.next),r=e=a),r=r.next}while(r!==e);return r}function Ns(e,t,n,r,i,a){var o,s,l=e;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&(s=c,(o=l).next.i!==s.i&&o.prev.i!==s.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&js(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(o,s)&&Ws(o,s)&&Ws(s,o)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;for(;n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next,n!==e;);return r}(o,s))){var u=Xs(l,c);return l=Ps(l,l.next),u=Ps(u,u.next),Rs(l,t,n,r,i,a),void Rs(u,t,n,r,i,a)}c=c.next}l=l.next}while(l!==e)}function Ds(e,t){return e.x-t.x}function Us(e,t){if(t=function(e,t){var n,r=t,i=e.x,a=e.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&o=r.x&&r.x>=u&&i!==r.x&&Gs(an.x)&&Ws(r,e)&&(n=r,d=l),r=r.next;return n}(e,t)){var n=Xs(t,e);Ps(n,n.next)}}function Bs(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function zs(e){for(var t=e,n=e;t.xNumber.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(l*l+c*c),f=t.x-s/d,m=t.y+o/d,v=((n.x-c/p-f)*c-(n.y+l/p-m)*l)/(o*c-s*l),g=(r=f+o*v-e.x)*r+(i=m+s*v-e.y)*i;if(g<=2)return new Dt(r,i);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?l>Number.EPSILON&&(y=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(c)&&(y=!0),a=y?(r=-s,i=o,Math.sqrt(u)):(r=o,i=s,Math.sqrt(u/2))}return new Dt(r/a,i/a)}for(var N=[],D=0,U=M.length,B=U-1,z=D+1;D "+r[i]+";"}}t+="}",console.log(t)},c.DiGraph=h;var s=function(e,t,n){this.v=e,this.w=t,this.weight=n};s.prototype.either=function(){return this.v},s.prototype.other=function(e){return e==this.v?this.w:this.v},s.prototype.from=function(){return this.v},s.prototype.to=function(){return this.w},s.prototype.copy=function(){var e=new s(0,0,0);for(var t in this)this.hasOwnProperty(t)&&(e[t]=this[t]);return e},c.Edge=s;var l=function(e){this.V=e,this.adjList=[],this.nodeInfo=[];for(var t=0;tthis.cost[t]+e.weight&&(this.cost[n]=this.cost[t]+e.weight,this.edgeTo[n]=e,this.pq.containsIndex(n)?this.pq.decreaseKey(n,this.cost[n]):this.pq.insert(n,this.cost[n]))},w.prototype.hasPathTo=function(e){return this.marked[e]},w.prototype.pathTo=function(e){for(var t=new c.Stack,n=e;n!=this.s;n=this.edgeTo[n].from())t.push(this.edgeTo[n]);return t.toArray()},w.prototype.distanceTo=function(e){return this.cost[e]},c.Dijkstra=w;var A=function(e,t){var n=e.V;this.s=t,this.marked=[],this.edgeTo=[],this.cost=[];for(var r=0;rthis.cost[t]+e.weight&&(this.cost[n]=this.cost[t]+e.weight,this.marked[n]=!0,this.edgeTo[n]=e)},A.prototype.hasPathTo=function(e){return this.marked[e]},A.prototype.pathTo=function(e){for(var t=new c.Stack,n=e;n!=this.s;n=this.edgeTo[n].from())t.push(this.edgeTo[n]);return t.toArray()},A.prototype.distanceTo=function(e){return this.cost[e]},c.BellmanFord=A;var M=function(e,t){var n=e.V;this.s=t,this.marked=[],this.edgeTo=[],this.cost=[];for(var r=0;rthis.cost[t]+e.weight&&(this.cost[n]=this.cost[t]+e.weight,this.marked[n]=!0,this.edgeTo[n]=e)},M.prototype.hasPathTo=function(e){return this.marked[e]},M.prototype.pathTo=function(e){for(var t=new c.Stack,n=e;n!=this.s;n=this.edgeTo[n].from())t.push(this.edgeTo[n]);return t.toArray()},M.prototype.distanceTo=function(e){return this.cost[e]},c.TopologicalSortShortestPaths=M;var T=function(e,t,n){this.value=0;e.V;var r=Number.MAX_VALUE;for(this.marked=null,this.edgeTo=null,this.s=t,this.t=n;this.hasAugmentedPath(e);){for(var i=this.t;i!=this.s;i=this.edgeTo[i].from())r=Math.min(r,this.edgeTo[i].residualCapacityTo(i));for(i=this.t;i!=this.s;i=this.edgeTo[i].from())this.edgeTo[i].addResidualFlowTo(i,r);this.value+=r}};T.prototype.hasAugmentedPath=function(e){var t=e.V;this.marked=[],this.edgeTo=[];for(var n=0;n>>1;et;)--a;if(++a,0!==i||a!==r){a<=i&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=fc.arraySlice(n,i,a),this.values=fc.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("v3d.KeyframeTrack: Invalid value size in track.",this),e=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("v3d.KeyframeTrack: Track is empty.",this),e=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("v3d.KeyframeTrack: Time is not a valid number.",this,o,s),e=!1;break}if(null!==a&&sNumber.EPSILON&&(c.normalize(),i=Math.acos(Nt.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(u.makeRotationAxis(c,i))),l[n].crossVectors(o[n],s[n]);if(!0===t)for(i=Math.acos(Nt.clamp(s[0].dot(s[e]),-1,1)),i/=e,0r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Yc(o,s.x,l.x,c.x,u.x),Yc(o,s.y,l.y,c.y,u.y)),n},nu.prototype.copy=function(e){Bc.prototype.copy.call(this,e),this.points=[];for(var t=0,n=e.points.length;t=t){var i=n[r]-t,a=this.curves[r],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}r++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,n=0,r=this.curves.length;nNumber.EPSILON){if(c<0&&(o=t[a],l=-l,s=t[i],c=-c),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var u=c*(e.x-o.x)-l*(e.y-o.y);if(0===u)return!0;if(u<0)continue;r=!r}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return r}var i=Qs.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===t)return n(a);var o,s,l,c=[];if(1===a.length)return s=a[0],(l=new cu).curves=s.curves,c.push(l),c;var u=!i(a[0].getPoints());u=e?!u:u;var h,d,p=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=a.length;gn.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t},_loopIsPing:function(e){return 2202!==this.loop||(-1==e||0==(1&e)===this._pingIsEven)},_updateTime:function(e){if(0===e)return this.time;if(2200!==this.loop&&this.repetitions<=0)return this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1}),this.time;var t=this.timeStart,n=Math.max(t,this._clip.duration),r=n-t;if(2200===this.loop)return this.time+=e,-1===this._loopCount&&(this._loopCount=0,this._setEndings(!0,!0,!1)),(this.timen)&&(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=Nt.clamp(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})),this.time;var i=2202===this.loop,a=this._loopIsPing(this._loopCount)?1:-1;this.time+=a*e;var o=this.timen,s=!1;if(-1===this._loopCount&&(s=o,this._loopCount=s?-1:0,this._pingIsEven=!s,0<=e?this._setEndings(!0,0===this.repetitions,i):this._setEndings(0===this.repetitions,!0,i)),o){var l=Math.floor((this.time-t)/r);this._loopCount+=Math.abs(l);var c=this.repetitions-this._loopCount;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=Nt.clamp(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1});else{if(1==c){var u=e<0;this._setEndings(u,!u,i)}else this._setEndings(!1,!1,i);var h=(this.time-t)%r;h<0&&(h+=r),this.time=i?n-h:h+t,s||this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:l})}}return this.time},_setEndings:function(e,t,n){var r=this._interpolantSettings;r.endingEnd=n?r.endingStart=yt:(r.endingStart=e?this.zeroSlopeAtStart?yt:gt:xt,t?this.zeroSlopeAtEnd?yt:gt:xt)},_scheduleFading:function(e,t,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}}),Jh.prototype=Object.assign(Object.create(t.prototype),{constructor:Jh,_bindAction:function(e,t){var n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName,c=l[s];void 0===c&&(c={},l[s]=c);for(var u=0;u!==i;++u){var h=r[u],d=h.name,p=c[d];if(void 0!==p)a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=t&&t._propertyBindings[u].binding.parsedPath;++(p=new ph(Qh.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[u]=p}o[u].resultBuffer=p.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}for(var i=e._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,n=0,r=t.length;n!==r;++n){var i=t[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return void 0===t&&(console.warn("v3d.Box2: .getParameter() target is now required"),t=new Dt),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return void 0===t&&(console.warn("v3d.Box2: .clampPoint() target is now required"),t=new Dt),t.copy(e).clamp(this.min,this.max)},distanceToPoint:(wh=new Dt,function(e){return wh.copy(e).clamp(this.min,this.max).sub(e).length()}),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(ad.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("v3d.Line3: .getCenter() target is now required"),e=new Bt),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("v3d.Line3: .delta() target is now required"),e=new Bt),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("v3d.Line3: .at() target is now required"),t=new Bt),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:(Mh=new Bt,Th=new Bt,function(e,t){Mh.subVectors(e,this.start),Th.subVectors(this.end,this.start);var n=Th.dot(Th),r=Th.dot(Mh)/n;return t&&(r=Nt.clamp(r,0,1)),r}),closestPointToPoint:function(e,t,n){var r=this.closestPointToPointParameter(e,t);return void 0===n&&(console.warn("v3d.Line3: .closestPointToPoint() target is now required"),n=new Bt),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),((od.prototype=Object.create(hr.prototype)).constructor=od).prototype.isImmediateRenderObject=!0,((sd.prototype=Object.create(ts.prototype)).constructor=sd).prototype.update=(Sh=new Bt,Lh=new Bt,Ch=new zt,function(){var e=["a","b","c"];this.object.updateMatrixWorld(!0),Ch.getNormalMatrix(this.object.matrixWorld);var t=this.object.matrixWorld,n=this.geometry.attributes.position,r=this.object.geometry;if(r&&r.isGeometry)for(var i=r.vertices,a=r.faces,o=0,s=0,l=a.length;sMath.abs(s)&&(M+=i,T=c.zoomSpeedTouch,S=c.zoomInertiaTouch),c.enablePan&&Math.abs(i)<=Math.abs(s)&&(P.add(o),R=c.panSpeedTouch,F=c.panInertiaTouch)}}}function ae(e){if(!1!==c.enabled){switch(e.touches.length){case 0:d=a.NONE;break;case 1:if(!1===c.enableRotate)return;d=a.TOUCH_ROTATE,w.copy(J(e.touches[0].pageX,e.touches[0].pageY).negate()),b.copy(w)}c.dispatchEvent(n)}}function oe(e){!1!==c.enabled&&e.preventDefault()}this.update=(Y=new Bt,function(){if(N){var e=V.getElapsedTime()/k;if(e=Nt.smootherstep(e,0,1),c.object.position.lerpVectors(U,z,e),c.object.lookAt(Y.lerpVectors(B,G,e)),1<=e){for(var t in N=!1,D(),g.set(0,0,0),y.set(0,0),M=A=0,E.set(0,0),P.set(0,0),f)f[t]=0;l.getDelta()}}else c.object.isCamera||c.object.isLight?p.set(0,0,-1):p.set(0,0,1),p.applyQuaternion(c.object.quaternion).normalize(),v.setFromVector3(p),v.theta+=g.theta*x,v.phi+=g.phi*x,v.theta=Math.max(c.minAzimuthAngle,Math.min(c.maxAzimuthAngle,v.theta)),v.phi=Math.max(c.minPolarAngle,Math.min(c.maxPolarAngle,v.phi)),v.makeSafe(),p.setFromSpherical(v),r.copy(p).add(c.object.position),c.object.lookAt(r),c.object.isPerspectiveCamera?c.object.position.addScaledVector(p,A):c.object.isOrthographicCamera&&(c.object.zoom*=1+.15*A,c.object.updateProjectionMatrix()),i.copy(p).cross(c.object.up).setLength(-E.x),i.add(o.copy(c.object.up).setLength(E.y)),c.object.position.add(i),function(){var e=l.getDelta();for(var t in g.set(g.radius,y.y,y.x),y.x=c.enableDamping?Nt.expAverage(y.x,0,e,_):0,y.y=c.enableDamping?Nt.expAverage(y.y,0,e,_):0,g.set(g.radius,g.phi-y.y,g.theta-y.x),E.copy(P),P.x=c.enableDamping?Nt.expAverage(P.x,0,e,F):0,P.y=c.enableDamping?Nt.expAverage(P.y,0,e,F):0,E.sub(P),E.multiplyScalar(R),A=M,M=c.enableDamping?Nt.expAverage(M,0,e,S):0,A-=M,A*=T,f){var n=t==xp.A||t==xp.LEFT_ARROW||t==xp.D||t==xp.RIGHT_ARROW,r=t==xp.W||t==xp.UP_ARROW||t==xp.S||t==xp.DOWN_ARROW,i=n?c.panInertia:c.zoomInertia,a=n?c.panSpeedKey:c.zoomSpeedKey;if(m.isKeyDown[t])var o=f[t]=1;else{var s=f[t];f[t]=Nt.expAverage(f[t],0,e,i),o=s-f[t]}c.enabled&&(n&&!c.enablePan||r&&!c.enableZoom||(o*=60*e*a,t==xp.A||t==xp.LEFT_ARROW?E.x+=o:t==xp.D||t==xp.RIGHT_ARROW?E.x-=o:t==xp.W||t==xp.UP_ARROW?A+=o:t!=xp.S&&t!=xp.DOWN_ARROW||(A-=o)))}}();var n=!1;1e-6f||8*(1-s.dot(c.object.quaternion))>f)||(c.dispatchEvent(u),o.copy(c.object.position),s.copy(c.object.quaternion),x=!1))}),this.dispose=function(){c.domElement.removeEventListener("contextmenu",ue,!1),c.domElement.removeEventListener("mousedown",re,!1),c.domElement.removeEventListener("wheel",oe,!1),c.domElement.removeEventListener("touchstart",se,!1),c.domElement.removeEventListener("touchend",ce,!1),c.domElement.removeEventListener("touchmove",le,!1),document.removeEventListener("mousemove",ie,!1),document.removeEventListener("mouseup",ae,!1),document.removeEventListener("mouseleave",ae,!1),b.dispose()},this.tween=(l=new Bt,function(e,t,n,r){c.object.parent&&(e=l.copy(e),c.object.parent.worldToLocal(e)),e.manhattanDistanceTo(c.object.position)<1e-5&&t.manhattanDistanceTo(c.target)<1e-5||(c.inTween=!0,c.tweenCallback="function"==typeof r?r:function(){},z.copy(c.object.position),G.copy(c.target),k.copy(e),V.copy(t),j=n,W.start())});var c=this,u={type:"change"},h={type:"start"},n={type:"end"},d={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},p=d.NONE,f=1e-6,m=new ql,v=new ql,g=1,y=new Bt,x=!1,_={};_[xp.W]=_[xp.S]=_[xp.A]=_[xp.D]=_[xp.UP_ARROW]=_[xp.DOWN_ARROW]=_[xp.LEFT_ARROW]=_[xp.RIGHT_ARROW]=0;var b=new _p(window);b.onKeyDown=function(e){e.keyCode in _&&(_[e.keyCode]=1)};var w=new Dt,A=new Dt,M=new Dt,T=new Dt,S=1,L=1,C=new Dt,E=new Dt,P=new Dt,R=new Dt,F=new Dt,I=new Dt,O=new Dt,N=1,D=1,U=1,B=new lh,z=new Bt,G=new Bt,k=new Bt,V=new Bt,j=0,W=new lh;function X(){return Math.pow(.95,D)}function H(e){v.theta-=e}function Y(e,t){A.set(e,t),T.add(A).sub(w),w.copy(A)}var q,Q,Z,K=(q=new Bt,function(e,t){q.setFromMatrixColumn(t,0),q.multiplyScalar(-e),y.add(q)}),J=(Q=new Bt,function(e,t){Q.setFromMatrixColumn(t,1),Q.multiplyScalar(e),y.add(Q)}),$=(Z=new Bt,function(e,t){var n=c.domElement===document?c.domElement.body:c.domElement;if(c.object.isPerspectiveCamera){var r=c.object.position;Z.copy(r).sub(c.target);var i=Z.length();i*=Math.tan(c.object.fov/2*Nt.DEG2RAD),K(2*e*i/n.clientHeight,c.object.matrix),J(2*t*i/n.clientHeight,c.object.matrix)}else c.object.isOrthographicCamera?(K(e*(c.object.right-c.object.left)/c.object.zoom/n.clientWidth,c.object.matrix),J(t*(c.object.top-c.object.bottom)/c.object.zoom/n.clientHeight,c.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),c.enablePan=!1)});function ee(e){c.object.isPerspectiveCamera?N/=e:c.object.isOrthographicCamera?(N/=e,x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),c.enableZoom=!1)}function te(e){c.object.isPerspectiveCamera?N*=e:c.object.isOrthographicCamera?(N*=e,x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),c.enableZoom=!1)}function ne(e){var t,n;t=e.clientX,n=e.clientY,E.set(t,n),R.add(E).sub(C),C.copy(E)}function re(e){if(!1!==c.enabled){switch(e.preventDefault(),e.button){case c.mouseButtons.ROTATE:if(!1===c.enableRotate)return;n=e,w.set(n.clientX,n.clientY),p=d.ROTATE;break;case c.mouseButtons.ZOOM:case c.mouseButtons.PAN:if(!1===c.enablePan)return;t=e,C.set(t.clientX,t.clientY),p=d.PAN}var t,n;p!==d.NONE&&(document.addEventListener("mousemove",ie,!1),document.addEventListener("mouseup",ae,!1),document.addEventListener("mouseleave",ae,!1),c.dispatchEvent(h))}}function ie(e){var t,n;if(!1!==c.enabled)switch(e.preventDefault(),p){case d.ROTATE:if(!1===c.enableRotate)return;Y((n=e).clientX,n.clientY),S=c.rotateSpeed,L=c.rotateInertia;break;case d.DOLLY:if(!1===c.enableZoom)return;t=e,I.set(t.clientX,t.clientY),O.subVectors(I,F),0Math.abs(P.length())&&(0\n varying vec2 vUv;\n uniform int faceIndex;\n uniform float roughness;\n uniform samplerCube envMap;\n uniform float mapSize;\n uniform vec3 testColor;\n uniform vec3 queryScale;\n \n float GGXRoughnessToBlinnExponent(const in float ggxRoughness) {\n float a = ggxRoughness + 0.0001;\n a *= a;\n return (2.0 / a - 2.0);\n }\n float randVanDerCorput(int n, int base) {\n float invBase = 1.0 / float(base);\n float result = 0.0;\n \n for (int i = 0; i < 32; ++i) {\n if (n > 0) {\n result += mod(float(n), 2.0) * invBase;\n invBase = invBase / 2.0;\n n = int(float(n) / 2.0);\n }\n }\n return result;\n }\n vec3 ImportanceSamplePhong(vec2 uv, mat3 vecSpace, float specPow) {\n float phi = uv.y * 2.0 * PI;\n float cosTheta = pow(1.0 - uv.x, 1.0 / (specPow + 1.0));\n float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\n vec3 sampleDir = vec3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);\n return vecSpace * sampleDir;\n }\n vec3 ImportanceSampleGGX(vec2 uv, mat3 vecSpace, float Roughness)\n {\n float a = Roughness * Roughness;\n float Phi = 2.0 * PI * uv.x;\n float CosTheta = sqrt((1.0 - uv.y) / (1.0 + (a*a - 1.0) * uv.y));\n float SinTheta = sqrt(abs(1.0 - CosTheta * CosTheta));\n return vecSpace * vec3(SinTheta * cos(Phi), SinTheta * sin(Phi), CosTheta);\n }\n mat3 matrixFromVector(vec3 n) {\n float a = 1.0 / (1.0 + n.z);\n float b = -n.x * n.y * a;\n vec3 b1 = vec3(1.0 - n.x * n.x * a, b, -n.x);\n vec3 b2 = vec3(b, 1.0 - n.y * n.y * a, -n.y);\n return mat3(b1, b2, n);\n }\n \n vec4 testColorMap(float Roughness) {\n vec4 color;\n if(faceIndex == 0)\n color = vec4(1.0,0.0,0.0,1.0);\n else if(faceIndex == 1)\n color = vec4(0.0,1.0,0.0,1.0);\n else if(faceIndex == 2)\n color = vec4(0.0,0.0,1.0,1.0);\n else if(faceIndex == 3)\n color = vec4(1.0,1.0,0.0,1.0);\n else if(faceIndex == 4)\n color = vec4(0.0,1.0,1.0,1.0);\n else\n color = vec4(1.0,0.0,1.0,1.0);\n color *= (1.0 - Roughness);\n return color;\n }\n void main() {\n vec3 sampleDirection;\n vec2 uv = vUv*2.0 - 1.0;\n float offset = -1.0/mapSize;\n const float a = -1.0;\n const float b = 1.0;\n float c = -1.0 + offset;\n float d = 1.0 - offset;\n float bminusa = b - a;\n uv.x = (uv.x - a)/bminusa * d - (uv.x - b)/bminusa * c;\n uv.y = (uv.y - a)/bminusa * d - (uv.y - b)/bminusa * c;\n if (faceIndex==0) {\n sampleDirection = vec3(1.0, -uv.y, -uv.x);\n } else if (faceIndex==1) {\n sampleDirection = vec3(-1.0, -uv.y, uv.x);\n } else if (faceIndex==2) {\n sampleDirection = vec3(uv.x, 1.0, uv.y);\n } else if (faceIndex==3) {\n sampleDirection = vec3(uv.x, -1.0, -uv.y);\n } else if (faceIndex==4) {\n sampleDirection = vec3(uv.x, -uv.y, 1.0);\n } else {\n sampleDirection = vec3(-uv.x, -uv.y, -1.0);\n }\n vec3 normal = normalize(sampleDirection * queryScale);\n mat3 vecSpace = matrixFromVector(normal);\n vec3 rgbColor = vec3(0.0);\n const int NumSamples = SAMPLES_PER_LEVEL;\n vec3 vect;\n float weight = 0.0;\n \n /**\n * several points from the Van der Corput sequence produce\n * spikes and make the result a bit ugly - practically these\n * are four points from the interval [0.9, 1], which are \n * also distributed evenly, let's just ignore them\n */\n float spikeInterval = exp2(floor(log2(float(NumSamples)))) / 4.0;\n \n for(int i = 0; i < NumSamples; i++) {\n if (mod(float(i) + 1.0, spikeInterval) == 0.0) continue;\n float r = randVanDerCorput(i, 2);\n vect = ImportanceSampleGGX(vec2(float(i) / float(NumSamples), r), vecSpace, roughness);\n vect = normalize(vect);\n \n /**\n * for roughness values above 0.5 don't use the dot formula, \n * just unity weights, because for this case there are\n * many sample directions that would have negative\n * weights when being calculated otherwise, thus \n * being discarded they wouldn't contribute to blurring \n * at all making it too insufficient for high roughness\n * levels\n */ \n if (roughness > 0.5) {\n vec3 color = envMapTexelToLinear(textureCube(envMap, vect)).rgb;\n rgbColor.rgb += color;\n weight += 1.0;\n } else {\n vec3 L = normalize(2.0 * dot(normal, vect) * vect - normal);\n float sampleWeight = max(dot(normal, L), 0.0);\n if (sampleWeight > 0.0) {\n vec3 color = envMapTexelToLinear(textureCube(envMap, vect)).rgb;\n rgbColor.rgb += color * sampleWeight;\n weight += sampleWeight;\n }\n }\n }\n rgbColor /= weight;\n gl_FragColor = linearToOutputTexel(vec4(rgbColor, 1.0));\n }",blending:v3d.NoBlending});return e.type="PMREMGenerator",e},dispose:function(){for(var e=0,t=this.cubeLods.length;e>6,t[n++]=128|63&s}else if(s<=65535){if(a<=n+2)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(a<=n+3)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0}(e,Yp,t,n)}return t},array:function(e){var t,n,r=vf(e.length);return t=e,n=r,Hp.set(t,n),r}};var o=Vp(e),s=[],l=0;if(r)for(var c=0;c>10,56320|1023&c)}}else a+=String.fromCharCode((31&o)<<6|s)}else a+=String.fromCharCode(o)}return a}(Yp,d,p):"":"boolean"===t?Boolean(h):h,0!==l&&gf(l),f}var Wp="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;var Xp,Hp,Yp,qp;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var Qp=Cp.TOTAL_MEMORY||16777216;function Zp(e){for(;0>4,n=(15&i)<<4|(a=s.indexOf(e.charAt(c++)))>>2,r=(3&a)<<6|(o=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(t),64!==a&&(l+=String.fromCharCode(n)),64!==o&&(l+=String.fromCharCode(r)),c>>1;n=(0-(e&1)&-306674912^t)>>>1;t=(0-(t&1)&-306674912^n)>>>1;n=(0-(n&1)&-306674912^t)>>>1;t=(0-(t&1)&-306674912^n)>>>1;n=(0-(n&1)&-306674912^t)>>>1;t=(0-(t&1)&-306674912^n)>>>1;Y[2088+(e<<2)>>2]=0-(t&1)&-306674912^(0-(n&1)&-306674912^t)>>>1;e=e+1|0}while((e|0)!=256);return}function Z(e,t,n){e=e|0;t=t|0;n=n|0;n=~n;if(!t){t=n;t=~t;return t|0}while(1){n=Y[2088+((n&255^(q[e>>0]|0))<<2)>>2]^n>>>8;t=t+-1|0;if(!t)break;else e=e+1|0}t=~n;return t|0}function C(){var e=0,t=0,n=0,r=0,i=0;e=0;do{i=se(e|0,0,1)|0;r=Q()|0;n=ue(0,0,e&1|0,0)|0;r=se(n&-679014590^i|0,(Q()|0)&-915646571^r|0,1)|0;n=Q()|0;i=ue(0,0,i&1|0,0)|0;n=se(i&-679014590^r|0,(Q()|0)&-915646571^n|0,1)|0;i=Q()|0;r=ue(0,0,r&1|0,0)|0;i=se(r&-679014590^n|0,(Q()|0)&-915646571^i|0,1)|0;r=Q()|0;n=ue(0,0,n&1|0,0)|0;r=se(n&-679014590^i|0,(Q()|0)&-915646571^r|0,1)|0;n=Q()|0;i=ue(0,0,i&1|0,0)|0;n=se(i&-679014590^r|0,(Q()|0)&-915646571^n|0,1)|0;i=Q()|0;r=ue(0,0,r&1|0,0)|0;i=se(r&-679014590^n|0,(Q()|0)&-915646571^i|0,1)|0;r=Q()|0;n=ue(0,0,n&1|0,0)|0;r=se(n&-679014590^i|0,(Q()|0)&-915646571^r|0,1)|0;n=Q()|0;i=ue(0,0,i&1|0,0)|0;n=(Q()|0)&-915646571^n;t=40+(e<<3)|0;Y[t>>2]=i&-679014590^r;Y[t+4>>2]=n;e=e+1|0}while((e|0)!=256);return}function K(e,t,n,r){e=e|0;t=t|0;n=n|0;r=r|0;var i=0,a=0;i=~n;n=~r;if(!t){e=i;t=n;e=~e;t=~t;f(t|0);return e|0}while(1){r=40+((i&255^(q[e>>0]|0))<<3)|0;a=Y[r>>2]|0;r=Y[r+4>>2]|0;i=se(i|0,n|0,8)|0;i=a^i;n=r^(Q()|0);t=t+-1|0;if(!t)break;else e=e+1|0}a=~i;e=~n;f(e|0);return a|0}function E(e,t){e=e|0;t=t|0;var n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,h=0,d=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0,_=0,b=0,w=0,A=0,M=0,T=0,S=0,L=0,C=0,E=0,P=0,R=0,F=0,I=0,O=0,N=0,D=0,U=0,B=0,z=0,G=0,k=0,V=0,j=0,W=0,X=0;j=e+36|0;if(!(Y[j>>2]|0)){Y[e>>2]=0;H[e+40>>0]=0;a=e+4|0;Y[a>>2]=0;o=e+24|0;i=o;Y[i>>2]=0;Y[i+4>>2]=0;i=e+172|0;n=e+72|0;r=n+100|0;do{Y[n>>2]=0;n=n+4|0}while((n|0)<(r|0));Y[i>>2]=12;n=0}else{n=Y[e>>2]|0;i=e+172|0;a=e+4|0;o=e+24|0}U=t+4|0;B=Y[U>>2]|0;z=t+16|0;G=Y[z>>2]|0;T=e+16|0;Y[T>>2]=B;D=t+8|0;L=e+168|0;C=e+176|0;E=e+182|0;P=e+184|0;R=e+185|0;F=e+186|0;d=e+187|0;I=e+183|0;O=e+32|0;p=e+64|0;N=e+177|0;f=e+48|0;A=e+8|0;m=e+56|0;v=e+1200|0;g=e+72|0;y=e+20|0;x=e+80|0;S=e+96|0;_=e+104|0;b=e+112|0;M=e+88|0;w=t+12|0;e:while(1){switch(n|0){case 6:{V=79;break e}case 7:{V=94;break e}case 8:{V=101;break e}case 9:{V=106;break e}case 0:{h=Y[U>>2]|0;l=(Y[D>>2]|0)-h|0;c=Y[L>>2]|0;u=(Y[i>>2]|0)-c|0;u=l>>>0>>0?l:u;he(e+176+c|0,(Y[t>>2]|0)+h|0,u|0)|0;Y[U>>2]=(Y[U>>2]|0)+u;u=(Y[L>>2]|0)+u|0;h=(u|0)==(Y[i>>2]|0);Y[L>>2]=h?0:u;if(!h){n=0;break e}Y[e>>2]=1;if(oe(C,8,6)|0){n=5;break e}if((Z(E,2,0)|0)!=(q[R>>0]<<8|q[P>>0]|q[F>>0]<<16|q[d>>0]<<24|0)){n=7;break e}if(H[E>>0]|0){n=6;break e}n=H[I>>0]|0;Y[O>>2]=n&255;if((n&255)>15){n=6;break e}switch(n<<24>>24){case 0:case 1:case 4:{V=13;break}default:{n=2;break e}}break}case 1:{V=13;break}case 2:{r=Y[t>>2]|0;n=Y[D>>2]|0;s=Y[L>>2]|0;l=Y[i>>2]|0;V=17;break}case 3:{V=45;break}case 4:{V=57;break}case 5:{V=63;break}default:{V=125;break e}}do{if((V|0)==13){V=0;n=Y[U>>2]|0;l=Y[D>>2]|0;if((n|0)==(l|0)){n=0;break e}r=Y[t>>2]|0;s=H[r+n>>0]|0;if(!(s<<24>>24)){Y[U>>2]=n+1;Y[T>>2]=n;n=6;break}else{V=((s&255)<<2)+4|0;Y[p>>2]=V;Y[i>>2]=V;Y[L>>2]=0;Y[e>>2]=2;n=l;s=0;l=V;V=17;break}}}while(0);if((V|0)==17){V=0;h=Y[U>>2]|0;u=n-h|0;n=l-s|0;n=u>>>0>>0?u:n;he(e+176+s|0,r+h|0,n|0)|0;Y[U>>2]=n+(Y[U>>2]|0);n=(Y[L>>2]|0)+n|0;h=(n|0)==(Y[i>>2]|0);Y[L>>2]=h?0:n;if(!h){n=0;break}c=n+-4|0;Y[i>>2]=c;c=Z(C,c,0)|0;h=Y[i>>2]|0;u=e+176+h|0;if((c|0)!=(q[u+1>>0]<<8|q[u>>0]|q[u+2>>0]<<16|q[u+3>>0]<<24|0)){n=7;break}Y[L>>2]=2;u=H[N>>0]|0;n=u&255;if(n&63|0){n=6;break}if(!(n&64)){s=-1;n=-1;l=2}else{n=Y[a>>2]|0;if(!n){l=A;Y[l>>2]=0;Y[l+4>>2]=0;l=2;n=0}else l=2;while(1){if(l>>>0>=h>>>0){n=7;break e}r=H[e+176+l>>0]|0;l=l+1|0;Y[L>>2]=l;W=r&255;s=le(W&127|0,0,n|0)|0;X=Q()|0;c=A;s=s|Y[c>>2];c=X|Y[c+4>>2];X=A;Y[X>>2]=s;Y[X+4>>2]=c;if(!(W&128))break;n=n+7|0;Y[a>>2]=n;if((n|0)==63){n=7;break e}}if(!((n|0)==0|r<<24>>24!=0)){n=7;break}Y[a>>2]=0;n=c}X=f;Y[X>>2]=s;Y[X+4>>2]=n;if(u<<24>>24<0){n=Y[a>>2]|0;if(!n){n=A;Y[n>>2]=0;Y[n+4>>2]=0;n=0}while(1){if(l>>>0>=h>>>0){n=7;break e}r=H[e+176+l>>0]|0;l=l+1|0;Y[L>>2]=l;X=r&255;s=le(X&127|0,0,n|0)|0;W=Q()|0;c=A;s=s|Y[c>>2];c=W|Y[c+4>>2];W=A;Y[W>>2]=s;Y[W+4>>2]=c;if(!(X&128))break;n=n+7|0;Y[a>>2]=n;if((n|0)==63){n=7;break e}}if(!((n|0)==0|r<<24>>24!=0)){n=7;break}Y[a>>2]=0;n=c}else{s=-1;n=-1}X=m;Y[X>>2]=s;Y[X+4>>2]=n;if((h-l|0)>>>0<2){n=7;break}n=l+1|0;Y[L>>2]=n;if((H[e+176+l>>0]|0)!=33){n=6;break}r=l+2|0;Y[L>>2]=r;if((H[e+176+n>>0]|0)!=1){n=6;break}if((h|0)==(r|0)){n=7;break}n=Y[v>>2]|0;Y[L>>2]=l+3;n=$(n,H[e+176+r>>0]|0)|0;if(n|0)break;n=Y[i>>2]|0;r=Y[L>>2]|0;while(1){if(r>>>0>=n>>>0)break;X=r;r=r+1|0;Y[L>>2]=r;if(H[e+176+X>>0]|0){n=6;break e}}Y[L>>2]=0;Y[g>>2]=0;Y[g+4>>2]=0;Y[g+8>>2]=0;Y[g+12>>2]=0;Y[e>>2]=3;V=45}if((V|0)==45){V=0;Y[T>>2]=Y[U>>2];Y[y>>2]=Y[z>>2];n=J(Y[v>>2]|0,t)|0;W=g;W=ce(Y[W>>2]|0,Y[W+4>>2]|0,(Y[U>>2]|0)-(Y[T>>2]|0)|0,0)|0;u=Q()|0;r=g;Y[r>>2]=W;Y[r+4>>2]=u;r=Y[y>>2]|0;s=(Y[z>>2]|0)-r|0;l=x;l=ce(Y[l>>2]|0,Y[l+4>>2]|0,s|0,0)|0;c=Q()|0;X=x;Y[X>>2]=l;Y[X+4>>2]=c;X=f;h=Y[X+4>>2]|0;if(u>>>0>h>>>0|((u|0)==(h|0)?W>>>0>(Y[X>>2]|0)>>>0:0)){n=7;break}X=m;W=Y[X+4>>2]|0;if(c>>>0>W>>>0|((c|0)==(W|0)?l>>>0>(Y[X>>2]|0)>>>0:0)){n=7;break}switch(Y[O>>2]|0){case 1:{r=Z((Y[w>>2]|0)+r|0,s,Y[o>>2]|0)|0;s=0;V=50;break}case 4:{V=o;r=K((Y[w>>2]|0)+r|0,s,Y[V>>2]|0,Y[V+4>>2]|0)|0;s=Q()|0;V=50;break}default:{}}if((V|0)==50){V=0;X=o;Y[X>>2]=r;Y[X+4>>2]=s}if((n|0)!=1)break;r=f;n=Y[r>>2]|0;r=Y[r+4>>2]|0;if(!((n|0)==-1&(r|0)==-1)?(X=g,!((n|0)==(Y[X>>2]|0)?(r|0)==(Y[X+4>>2]|0):0)):0){n=7;break}n=m;r=Y[n>>2]|0;n=Y[n+4>>2]|0;l=x;s=Y[l>>2]|0;l=Y[l+4>>2]|0;if(!((r|0)==-1&(n|0)==-1)){if(!((r|0)==(s|0)&(n|0)==(l|0))){n=7;break}}else{r=s;n=l}V=g;V=ce(Y[V>>2]|0,Y[V+4>>2]|0,Y[p>>2]|0,0)|0;W=Q()|0;X=S;X=ce(V|0,W|0,Y[X>>2]|0,Y[X+4>>2]|0)|0;W=Q()|0;W=ce(X|0,W|0,q[14+(Y[O>>2]|0)>>0]|0,0)|0;X=Q()|0;V=S;Y[V>>2]=W;Y[V+4>>2]=X;V=_;V=ce(Y[V>>2]|0,Y[V+4>>2]|0,r|0,n|0)|0;X=Q()|0;W=_;Y[W>>2]=V;Y[W+4>>2]=X;Y[b>>2]=Z(S,24,Y[b>>2]|0)|0;W=M;W=ce(Y[W>>2]|0,Y[W+4>>2]|0,1,0)|0;X=Q()|0;V=M;Y[V>>2]=W;Y[V+4>>2]=X;Y[e>>2]=4;V=57}if((V|0)==57){V=0;r=g;n=Y[r>>2]|0;if(!((n&3|0)==0&0==0)){s=Y[D>>2]|0;l=Y[U>>2]|0;r=Y[r+4>>2]|0;do{if((l|0)==(s|0)){n=0;break e}W=Y[t>>2]|0;X=l;l=l+1|0;Y[U>>2]=l;if(H[W+X>>0]|0){n=7;break e}n=ce(n|0,r|0,1,0)|0;r=Q()|0;X=g;Y[X>>2]=n;Y[X+4>>2]=r}while(!((n&3|0)==0&0==0))}Y[e>>2]=5;V=63}t:do{if((V|0)==63){V=0;n=Y[O>>2]|0;switch(n|0){case 1:{n=Y[D>>2]|0;r=Y[U>>2]|0;do{if((r|0)==(n|0)){n=0;break e}X=o;s=Y[a>>2]|0;X=se(Y[X>>2]|0,Y[X+4>>2]|0,s|0)|0;Q()|0;h=Y[t>>2]|0;W=r;r=r+1|0;Y[U>>2]=r;if((H[h+W>>0]|0)!=(X&255)<<24>>24){n=7;break e}X=s+8|0;Y[a>>2]=X}while(X>>>0<32);n=o;Y[n>>2]=0;Y[n+4>>2]=0;Y[a>>2]=0;n=1;break t}case 4:{n=Y[D>>2]|0;r=Y[U>>2]|0;do{if((r|0)==(n|0)){n=0;break e}X=o;s=Y[a>>2]|0;X=se(Y[X>>2]|0,Y[X+4>>2]|0,s|0)|0;Q()|0;h=Y[t>>2]|0;W=r;r=r+1|0;Y[U>>2]=r;if((H[h+W>>0]|0)!=(X&255)<<24>>24){n=7;break e}X=s+8|0;Y[a>>2]=X}while(X>>>0<64);n=o;Y[n>>2]=0;Y[n+4>>2]=0;Y[a>>2]=0;n=1;break t}default:{r=Y[a>>2]|0;s=q[14+n>>0]|0;if(r>>>0>>0){l=Y[D>>2]|0;c=Y[U>>2]|0;n=r;do{if((c|0)==(l|0)){n=0;break e}c=c+1|0;Y[U>>2]=c;n=n+1|0;Y[a>>2]=n}while(n>>>0>>0)}Y[a>>2]=0;n=1;break t}}}}while(0);Y[e>>2]=n}e:do{if((V|0)==79){d=e+120|0;p=e+136|0;f=e+144|0;m=e+144|0;v=e+152|0;g=e+160|0;t:while(1){u=Y[t>>2]|0;l=Y[D>>2]|0;if(!(Y[a>>2]|0)){X=A;Y[X>>2]=0;Y[X+4>>2]=0}while(1){r=Y[U>>2]|0;if(r>>>0>=l>>>0){n=0;V=86;break t}c=H[u+r>>0]|0;r=r+1|0;Y[U>>2]=r;X=c&255;n=Y[a>>2]|0;s=le(X&127|0,0,n|0)|0;W=Q()|0;h=A;s=s|Y[h>>2];h=W|Y[h+4>>2];W=A;Y[W>>2]=s;Y[W+4>>2]=h;if(!(X&128))break;X=n+7|0;Y[a>>2]=X;if((X|0)==63){n=7;V=86;break t}}if(!(c<<24>>24!=0|(n|0)==0)){n=7;V=86;break}Y[a>>2]=0;switch(Y[d>>2]|0){case 0:{X=p;Y[X>>2]=s;Y[X+4>>2]=h;X=M;if((s|0)==(Y[X>>2]|0)?(h|0)==(Y[X+4>>2]|0):0){n=1;V=91}else{n=7;break e}break}case 1:{n=2;l=f;r=h;V=90;break}case 2:{l=v;s=ce(Y[l>>2]|0,Y[l+4>>2]|0,s|0,h|0)|0;l=Q()|0;n=v;Y[n>>2]=s;Y[n+4>>2]=l;Y[g>>2]=Z(m,24,Y[g>>2]|0)|0;n=1;l=p;s=-1;r=-1;V=90;break}default:{}}if((V|0)==90){w=l;w=ce(Y[w>>2]|0,Y[w+4>>2]|0,s|0,r|0)|0;W=Q()|0;X=l;Y[X>>2]=w;Y[X+4>>2]=W;V=91}if((V|0)==91){V=0;Y[d>>2]=n}X=p;if((Y[X>>2]|0)==0&(Y[X+4>>2]|0)==0){V=93;break}}if((V|0)==86){k=Y[T>>2]|0;W=r-k|0;X=e+128|0;N=X;N=ce(Y[N>>2]|0,Y[N+4>>2]|0,W|0,0)|0;t=Q()|0;Y[X>>2]=N;Y[X+4>>2]=t;X=o;Y[X>>2]=Z(u+k|0,W,Y[o>>2]|0)|0;Y[X+4>>2]=0;break}else if((V|0)==93){Y[e>>2]=7;V=94;break}}else if((V|0)==106){s=Y[U>>2]|0;r=Y[D>>2]|0;a=Y[i>>2]|0;n=Y[t>>2]|0;V=107}else if((V|0)==125)while(1)V=125}while(0);e:do{if((V|0)==94){h=e+128|0;p=h;d=Y[p>>2]|0;p=Y[p+4>>2]|0;s=Y[T>>2]|0;n=Y[U>>2]|0;while(1){l=n-s|0;c=ce(d|0,p|0,l|0,0)|0;u=Q()|0;if((c&3|0)==0&0==0)break;r=Y[t>>2]|0;if((n|0)==(Y[D>>2]|0)){V=97;break}X=n;n=n+1|0;Y[U>>2]=n;if(H[r+X>>0]|0){n=7;break e}}if((V|0)==97){n=h;Y[n>>2]=c;Y[n+4>>2]=u;n=o;Y[n>>2]=Z(r+s|0,l,Y[o>>2]|0)|0;Y[n+4>>2]=0;n=0;break}W=Y[t>>2]|0;X=h;Y[X>>2]=c;Y[X+4>>2]=u;X=o;Y[X>>2]=Z(W+s|0,l,Y[o>>2]|0)|0;Y[X+4>>2]=0;if(!(oe(S,e+144|0,24)|0)){Y[e>>2]=8;V=101}else n=7}}while(0);e:do{if((V|0)==101){r=Y[D>>2]|0;s=Y[U>>2]|0;do{if((s|0)==(r|0)){n=0;break e}X=o;l=Y[a>>2]|0;X=se(Y[X>>2]|0,Y[X+4>>2]|0,l|0)|0;Q()|0;n=Y[t>>2]|0;W=s;s=s+1|0;Y[U>>2]=s;if((H[n+W>>0]|0)!=(X&255)<<24>>24){n=7;break e}X=l+8|0;Y[a>>2]=X}while(X>>>0<32);V=o;Y[V>>2]=0;Y[V+4>>2]=0;Y[a>>2]=0;Y[i>>2]=12;Y[e>>2]=9;a=12;V=107}}while(0);if((V|0)==107){V=r-s|0;X=Y[L>>2]|0;W=a-X|0;W=V>>>0>>0?V:W;he(e+176+X|0,n+s|0,W|0)|0;Y[U>>2]=W+(Y[U>>2]|0);W=(Y[L>>2]|0)+W|0;X=(W|0)==(Y[i>>2]|0);Y[L>>2]=X?0:W;if(X){if((((oe(F,30,2)|0)==0?(k=e+180|0,X=Z(k,6,0)|0,(X|0)==(q[N>>0]<<8|q[C>>0]|q[e+178>>0]<<16|q[e+179>>0]<<24|0)):0)?(X=e+128|0,X=se(Y[X>>2]|0,Y[X+4>>2]|0,2)|0,W=Q()|0,(W|0)==0?(X|0)==(q[e+181>>0]<<8|q[k>>0]|q[E>>0]<<16|q[I>>0]<<24|0):0):0)?(H[P>>0]|0)==0:0)n=(Y[O>>2]|0)==(q[R>>0]|0)?1:7;else n=7}else n=0}r=(n|0)==0;if(!(Y[j>>2]|0)){if(!r){if((n|0)==1){X=1;return X|0}}else n=(Y[U>>2]|0)==(Y[D>>2]|0)?7:8;Y[U>>2]=B;Y[z>>2]=G;X=n;return X|0}else{if(r){if((B|0)==(Y[U>>2]|0)?(G|0)==(Y[z>>2]|0):0){n=(H[e+40>>0]|0)==0?0:8;r=1}else{n=0;r=0}}else r=0;H[e+40>>0]=r;X=n;return X|0}return 0}function P(e,t){e=e|0;t=t|0;var n=0,r=0;r=re(1208)|0;if(!r){r=0;return r|0}Y[r+36>>2]=e;n=F(e,t)|0;Y[r+1200>>2]=n;if(!n){ie(r);r=0;return r|0}else{Y[r>>2]=0;H[r+40>>0]=0;Y[r+4>>2]=0;e=r+24|0;Y[e>>2]=0;Y[e+4>>2]=0;e=r+172|0;t=r+72|0;n=t+100|0;do{Y[t>>2]=0;t=t+4|0}while((t|0)<(n|0));Y[e>>2]=12;return r|0}return 0}function R(e){e=e|0;if(!e)return;I(Y[e+1200>>2]|0);ie(e);return}function J(e,t){e=e|0;t=t|0;var n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,h=0,d=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0,_=0,b=0,w=0,A=0,M=0,T=0,S=0,L=0,C=0,E=0,P=0,R=0,F=0,I=0,O=0,N=0,D=0,U=0,B=0;g=t+4|0;C=t+8|0;R=e+64|0;F=e+81|0;I=e+80|0;O=e+60|0;N=t+12|0;D=t+16|0;s=e+24|0;l=t+20|0;c=e+44|0;u=e+28|0;h=e+72|0;d=e+68|0;p=e+84|0;f=e+4|0;m=e+8|0;v=e+76|0;y=e+116|0;x=e+112|0;_=e+108|0;b=e+32|0;w=e+40|0;A=e+28388|0;M=e+28392|0;T=e+20|0;S=e+12|0;L=e+16|0;E=e+104|0;P=e+36|0;e:while(1){i=Y[g>>2]|0;r=Y[C>>2]|0;n=Y[R>>2]|0;t:do{if(i>>>0>=r>>>0){if((n|0)==7)U=5;else{n=0;U=86;break e}}else{switch(n|0){case 7:{U=5;break t}case 0:{n=Y[t>>2]|0;Y[g>>2]=i+1;n=H[n+i>>0]|0;r=n&255;if(!(n<<24>>24)){n=1;U=86;break e}if(!((n&255)>223|n<<24>>24==1)){if(H[I>>0]|0){n=7;U=86;break e}}else{H[F>>0]=1;H[I>>0]=0;if(!(Y[O>>2]|0)){o=Y[D>>2]|0;Y[s>>2]=(Y[N>>2]|0)+o;Y[c>>2]=(Y[l>>2]|0)-o}Y[u>>2]=0;Y[u+4>>2]=0;Y[u+8>>2]=0;Y[u+12>>2]=0}if(n<<24>>24>=0){if((n&255)>2){n=7;U=86;break e}Y[R>>2]=3;Y[d>>2]=8;continue e}Y[h>>2]=r<<16&2031616;Y[R>>2]=1;if((n&255)>191){H[F>>0]=0;Y[d>>2]=5;continue e}if(H[F>>0]|0){n=7;U=86;break e}Y[d>>2]=6;if((n&255)<=159)continue e;Y[p>>2]=0;Y[p+4>>2]=0;Y[p+8>>2]=0;Y[p+12>>2]=0;Y[p+16>>2]=0;n=0;do{z[e+120+(n<<1)>>1]=1024;n=n+1|0}while((n|0)!=14134);Y[e>>2]=-1;Y[f>>2]=0;Y[m>>2]=5;continue e}case 1:{o=Y[t>>2]|0;Y[g>>2]=i+1;Y[h>>2]=(q[o+i>>0]<<8)+(Y[h>>2]|0);Y[R>>2]=2;continue e}case 2:{o=Y[t>>2]|0;Y[g>>2]=i+1;Y[h>>2]=(q[o+i>>0]|0)+1+(Y[h>>2]|0);Y[R>>2]=3;continue e}case 3:{o=Y[t>>2]|0;Y[g>>2]=i+1;Y[v>>2]=q[o+i>>0]<<8;Y[R>>2]=4;continue e}case 4:{o=Y[t>>2]|0;Y[g>>2]=i+1;Y[v>>2]=(q[o+i>>0]|0)+1+(Y[v>>2]|0);Y[R>>2]=Y[d>>2];continue e}case 5:{n=Y[t>>2]|0;Y[g>>2]=i+1;n=H[n+i>>0]|0;if((n&255)>224){n=7;U=86;break e}if((n&255)>44){n=n+-45<<24>>24;r=(n&255)/45|0;n=(r*211|0)+n<<24>>24;r=r+1&255}else r=0;Y[y>>2]=(1<>2]=0;r=n&255;if((n&255)>8){n=0;do{o=r+247|0;n=n+1|0;r=o&255}while((o&255)>8);Y[x>>2]=n}else n=0;Y[_>>2]=r;if((r+n|0)>>>0>4){n=7;U=86;break e}Y[x>>2]=(1<>2]=0;Y[p+4>>2]=0;Y[p+8>>2]=0;Y[p+12>>2]=0;Y[p+16>>2]=0;n=0;do{z[e+120+(n<<1)>>1]=1024;n=n+1|0}while((n|0)!=14134);Y[e>>2]=-1;Y[f>>2]=0;Y[m>>2]=5;Y[R>>2]=6;break}case 6:break;case 8:{n=Y[v>>2]|0;n:do{if(n|0){if(r>>>0>i>>>0)o=i;else{n=0;U=86;break e}while(1){i=Y[D>>2]|0;a=Y[l>>2]|0;if(a>>>0<=i>>>0){n=0;U=86;break e}o=(r-o|0)>>>0<(a-i|0)>>>0;r=(o?r:a)-(Y[(o?g:D)>>2]|0)|0;o=Y[b>>2]|0;a=(Y[c>>2]|0)-o|0;r=r>>>0>a>>>0?a:r;r=r>>>0>n>>>0?n:r;Y[v>>2]=n-r;he((Y[s>>2]|0)+o|0,(Y[t>>2]|0)+(Y[g>>2]|0)|0,r|0)|0;n=(Y[b>>2]|0)+r|0;Y[b>>2]=n;if((Y[P>>2]|0)>>>0>>0)Y[P>>2]=n;if(Y[O>>2]|0){if((n|0)==(Y[c>>2]|0))Y[b>>2]=0;he((Y[N>>2]|0)+(Y[D>>2]|0)|0,(Y[t>>2]|0)+(Y[g>>2]|0)|0,r|0)|0;n=Y[b>>2]|0}Y[u>>2]=n;Y[D>>2]=(Y[D>>2]|0)+r;o=(Y[g>>2]|0)+r|0;Y[g>>2]=o;n=Y[v>>2]|0;if(!n)break n;r=Y[C>>2]|0;if(r>>>0<=o>>>0){n=0;U=86;break e}}}}while(0);Y[R>>2]=0;continue e}default:continue e}a=Y[v>>2]|0;if(a>>>0<5){n=7;U=86;break e}n=Y[m>>2]|0;if(!n){r=Y[C>>2]|0;i=Y[g>>2]|0;n=a}else{r=Y[C>>2]|0;i=Y[g>>2]|0;do{if((i|0)==(r|0)){n=0;U=86;break e}B=Y[f>>2]<<8;a=Y[t>>2]|0;o=i;i=i+1|0;Y[g>>2]=i;Y[f>>2]=B|q[a+o>>0];n=n+-1|0;Y[m>>2]=n}while((n|0)!=0);n=Y[v>>2]|0}a=n+-5|0;Y[v>>2]=a;Y[R>>2]=7;n=i}}while(0);if((U|0)==5){n=i;a=Y[v>>2]|0}i=(Y[l>>2]|0)-(Y[D>>2]|0)|0;o=Y[h>>2]|0;o=i>>>0>>0?i:o;i=Y[c>>2]|0;B=Y[b>>2]|0;Y[w>>2]=(i-B|0)>>>0>o>>>0?B+o|0:i;i=r-n|0;o=Y[A>>2]|0;if(!o){if(!a){r=0;U=46}else U=56}else{r=a;U=46}t:do{if((U|0)==46){U=0;B=42-o|0;r=r-o|0;r=B>>>0>r>>>0?r:B;i=r>>>0>i>>>0?i:r;he(e+28392+o|0,(Y[t>>2]|0)+n|0,i|0)|0;n=Y[A>>2]|0;r=i+n|0;do{if((r|0)!=(Y[v>>2]|0)){if(r>>>0<21){Y[A>>2]=r;Y[g>>2]=(Y[g>>2]|0)+i;break t}else{n=r+-21|0;break}}else{pe(e+28392+n+i|0,0,63-n-i|0)|0;n=(Y[A>>2]|0)+i|0}}while(0);Y[T>>2]=n;Y[S>>2]=M;Y[L>>2]=0;if(!(G(e)|0)){n=7;U=86;break e}n=Y[L>>2]|0;r=Y[A>>2]|0;if(n>>>0>(r+i|0)>>>0){n=7;U=86;break e}i=(Y[v>>2]|0)-n|0;Y[v>>2]=i;if(r>>>0>n>>>0){B=r-n|0;Y[A>>2]=B;de(M|0,e+28392+n|0,B|0)|0;break}else{n=(Y[g>>2]|0)+(n-r)|0;Y[g>>2]=n;Y[A>>2]=0;r=Y[C>>2]|0;a=i;U=56;break}}}while(0);if((U|0)==56){U=0;i=r-n|0;if(i>>>0>20){Y[S>>2]=Y[t>>2];Y[L>>2]=n;B=i>>>0<(a+21|0)>>>0;Y[T>>2]=(Y[(B?C:g)>>2]|0)+(B?-21:a);if(!(G(e)|0)){n=7;U=86;break}n=Y[L>>2]|0;r=n-(Y[g>>2]|0)|0;i=Y[v>>2]|0;if(i>>>0>>0){n=7;U=86;break}i=i-r|0;Y[v>>2]=i;Y[g>>2]=n;r=Y[C>>2]|0}else i=a;r=r-n|0;if(r>>>0<21){B=r>>>0>i>>>0?i:r;he(M|0,(Y[t>>2]|0)+n|0,B|0)|0;Y[A>>2]=B;Y[g>>2]=(Y[g>>2]|0)+B}}n=Y[b>>2]|0;r=Y[u>>2]|0;i=n-r|0;if(Y[O>>2]|0){if((n|0)==(Y[c>>2]|0))Y[b>>2]=0;he((Y[N>>2]|0)+(Y[D>>2]|0)|0,(Y[s>>2]|0)+r|0,i|0)|0;n=Y[b>>2]|0}Y[u>>2]=n;n=(Y[D>>2]|0)+i|0;Y[D>>2]=n;B=(Y[h>>2]|0)-i|0;Y[h>>2]=B;if(B|0){if((n|0)==(Y[l>>2]|0)){n=0;U=86;break}if((Y[g>>2]|0)!=(Y[C>>2]|0))continue;if((Y[A>>2]|0)>>>0<(Y[v>>2]|0)>>>0){n=0;U=86;break}else continue}if(Y[v>>2]|0){n=7;U=86;break}if(Y[E>>2]|0){n=7;U=86;break}if(Y[f>>2]|0){n=7;U=86;break}Y[e>>2]=-1;Y[f>>2]=0;Y[m>>2]=5;Y[R>>2]=0}if((U|0)==86)return n|0;return 0}function G(e){e=e|0;var t=0,n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,h=0,d=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0,_=0,b=0,w=0,A=0,M=0,T=0,S=0,L=0,C=0,E=0,P=0,R=0,F=0,I=0;I=e+24|0;R=e+32|0;t=Y[R>>2]|0;F=e+40|0;n=Y[F>>2]|0;if(((n>>>0>t>>>0?(r=e+104|0,i=Y[r>>2]|0,(i|0)!=0):0)?(o=Y[e+84>>2]|0,s=e+36|0,(Y[s>>2]|0)>>>0>o>>>0):0)?(Y[e+48>>2]|0)>>>0>o>>>0:0){a=n-t|0;a=a>>>0>>0?a:i;Y[r>>2]=i-a;n=t-o+-1|0;r=e+44|0;if(t>>>0<=o>>>0)n=(Y[r>>2]|0)+n|0;P=Y[I>>2]|0;E=H[P+n>>0]|0;Y[R>>2]=t+1;H[P+t>>0]=E;t=a+-1|0;if(t|0)do{P=n+1|0;n=(P|0)==(Y[r>>2]|0)?0:P;P=Y[R>>2]|0;E=Y[I>>2]|0;C=H[E+n>>0]|0;Y[R>>2]=P+1;H[E+P>>0]=C;t=t+-1|0}while((t|0)!=0);t=Y[R>>2]|0;if((Y[s>>2]|0)>>>0>>0)Y[s>>2]=t}e:do{if(t>>>0<(Y[F>>2]|0)>>>0){h=e+16|0;d=e+20|0;p=e+116|0;f=e+100|0;m=e+4|0;v=e+12|0;g=e+44|0;y=e+36|0;x=e+108|0;_=e+112|0;b=e+24|0;w=e+84|0;A=e+92|0;M=e+96|0;T=e+88|0;S=e+1756|0;L=e+104|0;C=e+1726|0;E=e+48|0;P=e+2784|0;while(1){n=Y[h>>2]|0;if(n>>>0>(Y[d>>2]|0)>>>0){n=e;break e}o=Y[p>>2]&t;a=e+120+(Y[f>>2]<<5)+(o<<1)|0;t=Y[e>>2]|0;if(t>>>0<16777216){t=t<<8;Y[e>>2]=t;u=Y[m>>2]<<8;i=Y[v>>2]|0;Y[h>>2]=n+1;i=u|(q[i+n>>0]|0);Y[m>>2]=i}else i=Y[m>>2]|0;n=O[a>>1]|0;r=N(t>>>11,n)|0;if(i>>>0>=r>>>0){Y[e>>2]=t-r;Y[m>>2]=i-r;z[a>>1]=n-(n>>>5);a=e+504+(Y[f>>2]<<1)|0;t=Y[e>>2]|0;if(t>>>0<16777216){t=t<<8;Y[e>>2]=t;c=Y[m>>2]<<8;u=Y[v>>2]|0;i=Y[h>>2]|0;Y[h>>2]=i+1;i=c|(q[u+i>>0]|0);Y[m>>2]=i}else i=Y[m>>2]|0;n=O[a>>1]|0;r=N(t>>>11,n)|0;t:do{if(i>>>0>>0){Y[e>>2]=r;z[a>>1]=((2048-n|0)>>>5)+n;Y[f>>2]=(Y[f>>2]|0)>>>0<7?7:10;Y[M>>2]=Y[A>>2];Y[A>>2]=Y[T>>2];Y[T>>2]=Y[w>>2];D(e,S,o);o=Y[L>>2]|0;o=o>>>0<6?o+-2|0:3;l=1;t=Y[e>>2]|0;do{s=e+984+(o<<7)+(l<<1)|0;if(t>>>0<16777216){t=t<<8;Y[e>>2]=t;c=Y[m>>2]<<8;u=Y[v>>2]|0;n=Y[h>>2]|0;Y[h>>2]=n+1;n=c|(q[u+n>>0]|0);Y[m>>2]=n}else n=Y[m>>2]|0;a=O[s>>1]|0;i=N(t>>>11,a)|0;if(n>>>0>>0){Y[e>>2]=i;r=0;t=i;n=(2048-a>>5)+a|0}else{t=t-i|0;Y[e>>2]=t;Y[m>>2]=n-i;r=1;n=a-(a>>>5)|0}z[s>>1]=n;l=r|l<<1}while(l>>>0<64);t=l+-64|0;if(t>>>0<4){Y[w>>2]=t;break}n=t>>>1;c=n+-1|0;r=t&1|2;Y[w>>2]=r;if(t>>>0<14){s=r<>2]=s;l=e+1496+(s<<1)+(64-l<<1)+-2|0;s=0;t=1;while(1){o=l+(t<<1)|0;n=Y[e>>2]|0;if(n>>>0<16777216){n=n<<8;Y[e>>2]=n;i=Y[m>>2]<<8;u=Y[v>>2]|0;a=Y[h>>2]|0;Y[h>>2]=a+1;a=i|(q[u+a>>0]|0);Y[m>>2]=a}else a=Y[m>>2]|0;r=O[o>>1]|0;i=N(n>>>11,r)|0;if(a>>>0>>0){Y[e>>2]=i;z[o>>1]=((2048-r|0)>>>5)+r;t=t<<1}else{Y[e>>2]=n-i;Y[m>>2]=a-i;z[o>>1]=r-(r>>>5);Y[w>>2]=(Y[w>>2]|0)+(1<>>0>=c>>>0)break t}}i=n+-5|0;o=Y[e>>2]|0;do{if(o>>>0<16777216){a=o<<8;Y[e>>2]=a;c=Y[m>>2]<<8;u=Y[v>>2]|0;t=Y[h>>2]|0;Y[h>>2]=t+1;t=c|(q[u+t>>0]|0);Y[m>>2]=t}else{a=o;t=Y[m>>2]|0}o=a>>>1;Y[e>>2]=o;n=t-o|0;u=n>>31;n=(u&o)+n|0;Y[m>>2]=n;r=(r<<1|1)+u|0;Y[w>>2]=r;i=i+-1|0}while((i|0)!=0);s=r<<4;Y[w>>2]=s;if(a>>>0<33554432){r=o<<8;Y[e>>2]=r;c=Y[v>>2]|0;u=Y[h>>2]|0;Y[h>>2]=u+1;n=n<<8|(q[c+u>>0]|0);Y[m>>2]=n}else r=o;t=O[C>>1]|0;i=N(r>>>11,t)|0;if(n>>>0>>0){Y[e>>2]=i;z[C>>1]=((2048-t|0)>>>5)+t;l=2;o=s}else{u=r-i|0;Y[e>>2]=u;n=n-i|0;Y[m>>2]=n;z[C>>1]=t-(t>>>5);o=s|1;Y[w>>2]=o;l=3;i=u}a=e+1724+(l<<1)|0;if(i>>>0<16777216){i=i<<8;Y[e>>2]=i;c=Y[v>>2]|0;u=Y[h>>2]|0;Y[h>>2]=u+1;n=n<<8|(q[c+u>>0]|0);Y[m>>2]=n}r=O[a>>1]|0;t=N(i>>>11,r)|0;if(n>>>0>>0){Y[e>>2]=t;z[a>>1]=((2048-r|0)>>>5)+r;o=l<<1}else{u=i-t|0;Y[e>>2]=u;n=n-t|0;Y[m>>2]=n;z[a>>1]=r-(r>>>5);Y[w>>2]=o+2;o=l<<1|1;t=u}a=e+1724+(o<<1)|0;if(t>>>0<16777216){t=t<<8;Y[e>>2]=t;c=Y[v>>2]|0;u=Y[h>>2]|0;Y[h>>2]=u+1;n=n<<8|(q[c+u>>0]|0);Y[m>>2]=n}r=O[a>>1]|0;i=N(t>>>11,r)|0;if(n>>>0>>0){Y[e>>2]=i;z[a>>1]=((2048-r|0)>>>5)+r;t=o<<1}else{Y[e>>2]=t-i;Y[m>>2]=n-i;z[a>>1]=r-(r>>>5);Y[w>>2]=(Y[w>>2]|0)+4;t=o<<1|1}a=e+1724+(t<<1)|0;t=Y[e>>2]|0;if(t>>>0<16777216){t=t<<8;Y[e>>2]=t;c=Y[m>>2]<<8;u=Y[v>>2]|0;i=Y[h>>2]|0;Y[h>>2]=i+1;i=c|(q[u+i>>0]|0);Y[m>>2]=i}else i=Y[m>>2]|0;n=O[a>>1]|0;r=N(t>>>11,n)|0;if(i>>>0>>0){Y[e>>2]=r;z[a>>1]=((2048-n|0)>>>5)+n;break}else{Y[e>>2]=t-r;Y[m>>2]=i-r;z[a>>1]=n-(n>>>5);Y[w>>2]=(Y[w>>2]|0)+8;break}}else{Y[e>>2]=t-r;Y[m>>2]=i-r;z[a>>1]=n-(n>>>5);a=e+528+(Y[f>>2]<<1)|0;t=Y[e>>2]|0;if(t>>>0<16777216){t=t<<8;Y[e>>2]=t;c=Y[m>>2]<<8;u=Y[v>>2]|0;i=Y[h>>2]|0;Y[h>>2]=i+1;i=c|(q[u+i>>0]|0);Y[m>>2]=i}else i=Y[m>>2]|0;n=O[a>>1]|0;r=N(t>>>11,n)|0;do{if(i>>>0>>0){Y[e>>2]=r;z[a>>1]=((2048-n|0)>>>5)+n;a=e+600+(Y[f>>2]<<5)+(o<<1)|0;t=Y[e>>2]|0;if(t>>>0<16777216){t=t<<8;Y[e>>2]=t;c=Y[m>>2]<<8;u=Y[v>>2]|0;i=Y[h>>2]|0;Y[h>>2]=i+1;i=c|(q[u+i>>0]|0);Y[m>>2]=i}else i=Y[m>>2]|0;n=O[a>>1]|0;r=N(t>>>11,n)|0;if(i>>>0>>0){Y[e>>2]=r;z[a>>1]=((2048-n|0)>>>5)+n;Y[f>>2]=(Y[f>>2]|0)>>>0<7?9:11;Y[L>>2]=1;break t}else{Y[e>>2]=t-r;Y[m>>2]=i-r;z[a>>1]=n-(n>>>5);break}}else{Y[e>>2]=t-r;Y[m>>2]=i-r;z[a>>1]=n-(n>>>5);a=e+552+(Y[f>>2]<<1)|0;t=Y[e>>2]|0;if(t>>>0<16777216){t=t<<8;Y[e>>2]=t;c=Y[m>>2]<<8;u=Y[v>>2]|0;i=Y[h>>2]|0;Y[h>>2]=i+1;i=c|(q[u+i>>0]|0);Y[m>>2]=i}else i=Y[m>>2]|0;n=O[a>>1]|0;r=N(t>>>11,n)|0;if(i>>>0>>0){Y[e>>2]=r;z[a>>1]=((2048-n|0)>>>5)+n;t=Y[T>>2]|0}else{Y[e>>2]=t-r;Y[m>>2]=i-r;z[a>>1]=n-(n>>>5);a=e+576+(Y[f>>2]<<1)|0;t=Y[e>>2]|0;if(t>>>0<16777216){t=t<<8;Y[e>>2]=t;c=Y[m>>2]<<8;u=Y[v>>2]|0;i=Y[h>>2]|0;Y[h>>2]=i+1;i=c|(q[u+i>>0]|0);Y[m>>2]=i}else i=Y[m>>2]|0;n=O[a>>1]|0;r=N(t>>>11,n)|0;if(i>>>0>>0){Y[e>>2]=r;z[a>>1]=((2048-n|0)>>>5)+n;t=Y[A>>2]|0}else{Y[e>>2]=t-r;Y[m>>2]=i-r;z[a>>1]=n-(n>>>5);t=Y[M>>2]|0;Y[M>>2]=Y[A>>2]}Y[A>>2]=Y[T>>2]}Y[T>>2]=Y[w>>2];Y[w>>2]=t}}while(0);Y[f>>2]=(Y[f>>2]|0)>>>0<7?8:11;D(e,P,o)}}while(0);t=Y[w>>2]|0;if((Y[y>>2]|0)>>>0<=t>>>0){t=0;r=130;break}if((Y[E>>2]|0)>>>0<=t>>>0){t=0;r=130;break}i=Y[R>>2]|0;r=(Y[F>>2]|0)-i|0;n=Y[L>>2]|0;r=r>>>0>>0?r:n;Y[L>>2]=n-r;n=i-t+-1|0;if(i>>>0<=t>>>0)n=(Y[g>>2]|0)+n|0;t=Y[I>>2]|0;u=H[t+n>>0]|0;Y[R>>2]=i+1;H[t+i>>0]=u;t=r+-1|0;if(t|0)do{u=n+1|0;n=(u|0)==(Y[g>>2]|0)?0:u;u=Y[R>>2]|0;c=Y[I>>2]|0;l=H[c+n>>0]|0;Y[R>>2]=u+1;H[c+u>>0]=l;t=t+-1|0}while((t|0)!=0);t=Y[R>>2]|0;if((Y[y>>2]|0)>>>0>>0)Y[y>>2]=t}else{Y[e>>2]=r;z[a>>1]=((2048-n|0)>>>5)+n;n=Y[R>>2]|0;t=n+-1|0;if(!n)t=(Y[g>>2]|0)+t|0;r=(Y[y>>2]|0)==0;if(r)t=0;else t=q[(Y[b>>2]|0)+t>>0]|0;u=Y[x>>2]|0;u=((Y[_>>2]&n)<>>(8-u|0))|0;if((Y[f>>2]|0)>>>0<7){t=1;n=Y[e>>2]|0;do{s=e+3812+(u*1536|0)+(t<<1)|0;if(n>>>0<16777216){n=n<<8;Y[e>>2]=n;l=Y[m>>2]<<8;c=Y[v>>2]|0;r=Y[h>>2]|0;Y[h>>2]=r+1;r=l|(q[c+r>>0]|0);Y[m>>2]=r}else r=Y[m>>2]|0;o=O[s>>1]|0;a=N(n>>>11,o)|0;if(r>>>0>>0){Y[e>>2]=a;i=0;n=a;r=(2048-o>>5)+o|0}else{n=n-a|0;Y[e>>2]=n;Y[m>>2]=r-a;i=1;r=o-(o>>>5)|0}z[s>>1]=r;t=i|t<<1}while(t>>>0<256)}else{c=Y[w>>2]|0;t=n-c+-1|0;if(n>>>0>c>>>0)n=t;else n=(Y[g>>2]|0)+t|0;if(r){t=1;c=256;s=0}else{t=1;c=256;s=q[(Y[b>>2]|0)+n>>0]|0}while(1){s=s<<1;l=s&c;o=e+3812+(u*1536|0)+(l+c+t<<1)|0;n=Y[e>>2]|0;if(n>>>0<16777216){n=n<<8;Y[e>>2]=n;r=Y[m>>2]<<8;a=Y[v>>2]|0;i=Y[h>>2]|0;Y[h>>2]=i+1;i=r|(q[a+i>>0]|0);Y[m>>2]=i}else i=Y[m>>2]|0;a=O[o>>1]|0;r=N(n>>>11,a)|0;if(i>>>0>>0){Y[e>>2]=r;r=1;n=(2048-a>>5)+a|0}else{Y[e>>2]=n-r;Y[m>>2]=i-r;r=0;n=a-(a>>>5)|0}z[o>>1]=n;t=t<<1|(r^1)&1;if(t>>>0>=256)break;else c=(r?c:0)^l}}c=Y[b>>2]|0;u=Y[R>>2]|0;Y[R>>2]=u+1;H[c+u>>0]=t;t=Y[R>>2]|0;if((Y[y>>2]|0)>>>0>>0)Y[y>>2]=t;u=Y[f>>2]|0;Y[f>>2]=u>>>0<4?0:u-(u>>>0<10?3:6)|0}if(t>>>0>=(Y[F>>2]|0)>>>0){n=e;break e}}if((r|0)==130)return t|0}else n=e}while(0);t=Y[n>>2]|0;if(t>>>0>=16777216){e=1;return e|0}Y[n>>2]=t<<8;I=e+4|0;R=Y[I>>2]<<8;F=Y[e+12>>2]|0;P=e+16|0;e=Y[P>>2]|0;Y[P>>2]=e+1;Y[I>>2]=R|(q[F+e>>0]|0);e=1;return e|0}function D(e,t,n){e=e|0;t=t|0;n=n|0;var r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,h=0,d=0,p=0,f=0;r=Y[e>>2]|0;if(r>>>0<16777216){r=r<<8;Y[e>>2]=r;a=e+4|0;p=Y[a>>2]<<8;f=Y[e+12>>2]|0;d=e+16|0;o=Y[d>>2]|0;Y[d>>2]=o+1;o=p|(q[f+o>>0]|0);Y[a>>2]=o}else{o=e+4|0;a=o;o=Y[o>>2]|0}i=O[t>>1]|0;l=N(r>>>11,i)|0;do{if(o>>>0>=l>>>0){s=r-l|0;Y[e>>2]=s;r=o-l|0;Y[a>>2]=r;z[t>>1]=i-(i>>>5);l=t+2|0;if(s>>>0<16777216){i=s<<8;Y[e>>2]=i;a=e+4|0;f=Y[e+12>>2]|0;p=e+16|0;o=Y[p>>2]|0;Y[p>>2]=o+1;o=r<<8|(q[f+o>>0]|0);Y[a>>2]=o}else{a=e+4|0;i=s;o=r}r=O[l>>1]|0;s=N(i>>>11,r)|0;if(o>>>0>>0){Y[e>>2]=s;z[l>>1]=((2048-r|0)>>>5)+r;f=8;p=t+260+(n<<4)|0;r=s;c=10;break}else{c=i-s|0;Y[e>>2]=c;o=o-s|0;Y[a>>2]=o;z[l>>1]=r-(r>>>5);f=256;p=t+516|0;r=c;c=18;break}}else{Y[e>>2]=l;z[t>>1]=((2048-i|0)>>>5)+i;f=8;p=t+4+(n<<4)|0;r=l;c=2}}while(0);n=e+104|0;Y[n>>2]=c;u=e+4|0;h=e+12|0;d=e+16|0;t=1;do{l=p+(t<<1)|0;if(r>>>0<16777216){r=r<<8;Y[e>>2]=r;a=Y[h>>2]|0;s=Y[d>>2]|0;Y[d>>2]=s+1;o=o<<8|(q[a+s>>0]|0);Y[u>>2]=o}s=O[l>>1]|0;i=N(r>>>11,s)|0;if(o>>>0>>0){Y[e>>2]=i;a=0;r=i;i=(2048-s>>5)+s|0}else{r=r-i|0;Y[e>>2]=r;o=o-i|0;Y[u>>2]=o;a=1;i=s-(s>>>5)|0}z[l>>1]=i;t=a|t<<1}while(t>>>0>>0);Y[n>>2]=t-f+c;return}function F(e,t){e=e|0;t=t|0;var n=0,r=0;n=re(28456)|0;e:do{if(n){r=n+24|0;Y[n+60>>2]=e;Y[n+52>>2]=t;switch(e|0){case 1:break;case 2:{Y[r>>2]=0;Y[n+56>>2]=0;break e}default:break e}t=re(t)|0;Y[r>>2]=t;if(!t){ie(n);n=0}}else n=0}while(0);return n|0}function $(e,t){e=e|0;t=t|0;var n=0,r=0,i=0;n=t&255;if((t&255)>39){i=6;return i|0}r=e+48|0;n=(n&1|2)<<(n>>>1)+11;Y[r>>2]=n;t=Y[e+60>>2]|0;if(t|0){if(n>>>0>(Y[e+52>>2]|0)>>>0){i=4;return i|0}Y[e+44>>2]=n;if(((t|0)==2?(i=e+56|0,(Y[i>>2]|0)>>>0>>0):0)?(n=e+24|0,ie(Y[n>>2]|0),r=re(Y[r>>2]|0)|0,Y[n>>2]=r,(r|0)==0):0){Y[i>>2]=0;i=3;return i|0}}Y[e+104>>2]=0;Y[e+64>>2]=0;H[e+80>>0]=1;Y[e+28388>>2]=0;i=0;return i|0}function I(e){e=e|0;if(!(Y[e+60>>2]|0)){ie(e);return}ie(Y[e+24>>2]|0);ie(e);return}function U(){var e=0;Y[778]=3640;Y[779]=0;Y[780]=0;Y[781]=527928;Y[782]=0;Y[783]=524288;L();C();e=P(2,8388608)|0;Y[784]=e;if(e|0){e=0;return e|0}R(0);e=1;return e|0}function B(){var e=0;switch(E(Y[784]|0,3112)|0){case 2:case 0:{e=0;break}case 1:{R(Y[784]|0);e=0;break}case 3:{R(Y[784]|0);e=1;break}case 4:{R(Y[784]|0);e=2;break}case 5:{R(Y[784]|0);e=4;break}case 6:{R(Y[784]|0);e=5;break}case 8:case 7:{R(Y[784]|0);e=6;break}default:{R(Y[784]|0);e=7}}return e|0}function k(){return Y[778]|0}function V(){return Y[781]|0}function j(e){e=e|0;Y[779]=e;return}function W(e){e=e|0;Y[780]=e>>>0<524288?e:524288;return}function X(e){e=e|0;Y[782]=e;return}function ee(e){e=e|0;Y[783]=e>>>0<524288?e:524288;return}function te(){return Y[782]|0}function ne(){return(Y[779]|0)==(Y[780]|0)|0}function re(e){e=e|0;var t=0,n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,h=0,d=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0,_=0,b=0;b=w;w=w+16|0;d=b;do{if(e>>>0<245){c=e>>>0<11?16:e+11&-8;e=c>>>3;h=Y[785]|0;n=h>>>e;if(n&3|0){t=(n&1^1)+e|0;e=3180+(t<<1<<2)|0;n=e+8|0;r=Y[n>>2]|0;i=r+8|0;a=Y[i>>2]|0;if((a|0)==(e|0))Y[785]=h&~(1<>2]=e;Y[n>>2]=a}_=t<<3;Y[r+4>>2]=_|3;_=r+_+4|0;Y[_>>2]=Y[_>>2]|1;_=i;w=b;return _|0}u=Y[787]|0;if(c>>>0>u>>>0){if(n|0){t=2<>>12&16;t=t>>>s;n=t>>>5&8;t=t>>>n;a=t>>>2&4;t=t>>>a;e=t>>>1&2;t=t>>>e;r=t>>>1&1;r=(n|s|a|e|r)+(t>>>r)|0;t=3180+(r<<1<<2)|0;e=t+8|0;a=Y[e>>2]|0;s=a+8|0;n=Y[s>>2]|0;if((n|0)==(t|0)){e=h&~(1<>2]=t;Y[e>>2]=n;e=h}_=r<<3;o=_-c|0;Y[a+4>>2]=c|3;i=a+c|0;Y[i+4>>2]=o|1;Y[a+_>>2]=o;if(u|0){r=Y[790]|0;t=u>>>3;n=3180+(t<<1<<2)|0;t=1<>2]|0}Y[e>>2]=r;Y[t+12>>2]=r;Y[r+8>>2]=t;Y[r+12>>2]=n}Y[787]=o;Y[790]=i;_=s;w=b;return _|0}a=Y[786]|0;if(a){n=(a&0-a)+-1|0;i=n>>>12&16;n=n>>>i;r=n>>>5&8;n=n>>>r;o=n>>>2&4;n=n>>>o;s=n>>>1&2;n=n>>>s;l=n>>>1&1;l=Y[3444+((r|i|o|s|l)+(n>>>l)<<2)>>2]|0;n=l;s=l;l=(Y[l+4>>2]&-8)-c|0;while(1){e=Y[n+16>>2]|0;if(!e){e=Y[n+20>>2]|0;if(!e)break}o=(Y[e+4>>2]&-8)-c|0;i=o>>>0>>0;n=e;s=i?e:s;l=i?o:l}o=s+c|0;if(o>>>0>s>>>0){i=Y[s+24>>2]|0;t=Y[s+12>>2]|0;do{if((t|0)==(s|0)){e=s+20|0;t=Y[e>>2]|0;if(!t){e=s+16|0;t=Y[e>>2]|0;if(!t){n=0;break}}while(1){r=t+20|0;n=Y[r>>2]|0;if(!n){r=t+16|0;n=Y[r>>2]|0;if(!n)break;else{t=n;e=r}}else{t=n;e=r}}Y[e>>2]=0;n=t}else{n=Y[s+8>>2]|0;Y[n+12>>2]=t;Y[t+8>>2]=n;n=t}}while(0);do{if(i|0){t=Y[s+28>>2]|0;e=3444+(t<<2)|0;if((s|0)==(Y[e>>2]|0)){Y[e>>2]=n;if(!n){Y[786]=a&~(1<>2]|0)==(s|0)?_:i+20|0)>>2]=n;if(!n)break}Y[n+24>>2]=i;t=Y[s+16>>2]|0;if(t|0){Y[n+16>>2]=t;Y[t+24>>2]=n}t=Y[s+20>>2]|0;if(t|0){Y[n+20>>2]=t;Y[t+24>>2]=n}}}while(0);if(l>>>0<16){_=l+c|0;Y[s+4>>2]=_|3;_=s+_+4|0;Y[_>>2]=Y[_>>2]|1}else{Y[s+4>>2]=c|3;Y[o+4>>2]=l|1;Y[o+l>>2]=l;if(u|0){r=Y[790]|0;t=u>>>3;n=3180+(t<<1<<2)|0;t=1<>2]|0}Y[e>>2]=r;Y[t+12>>2]=r;Y[r+8>>2]=t;Y[r+12>>2]=n}Y[787]=l;Y[790]=o}_=s+8|0;w=b;return _|0}else h=c}else h=c}else h=c}else if(e>>>0<=4294967231){e=e+11|0;c=e&-8;r=Y[786]|0;if(r){i=0-c|0;e=e>>>8;if(e){if(c>>>0>16777215)l=31;else{h=(e+1048320|0)>>>16&8;m=e<>>16&4;m=m<>>16&2;l=14-(s|h|l)+(m<>>15)|0;l=c>>>(l+7|0)&1|l<<1}}else l=0;n=Y[3444+(l<<2)>>2]|0;e:do{if(!n){n=0;e=0;m=61}else{e=0;s=c<<((l|0)==31?0:25-(l>>>1)|0);a=0;while(1){o=(Y[n+4>>2]&-8)-c|0;if(o>>>0>>0)if(!o){e=n;i=0;m=65;break e}else{e=n;i=o}m=Y[n+20>>2]|0;n=Y[n+16+(s>>>31<<2)>>2]|0;a=(m|0)==0|(m|0)==(n|0)?a:m;if(!n){n=a;m=61;break}else s=s<<1}}}while(0);if((m|0)==61){if((n|0)==0&(e|0)==0){e=2<>>12&16;h=h>>>o;a=h>>>5&8;h=h>>>a;s=h>>>2&4;h=h>>>s;l=h>>>1&2;h=h>>>l;n=h>>>1&1;e=0;n=Y[3444+((a|o|s|l|n)+(h>>>n)<<2)>>2]|0}if(!n){s=e;o=i}else m=65}if((m|0)==65){a=n;while(1){h=(Y[a+4>>2]&-8)-c|0;n=h>>>0>>0;i=n?h:i;e=n?a:e;n=Y[a+16>>2]|0;if(!n)n=Y[a+20>>2]|0;if(!n){s=e;o=i;break}else a=n}}if(((s|0)!=0?o>>>0<((Y[787]|0)-c|0)>>>0:0)?(u=s+c|0,u>>>0>s>>>0):0){a=Y[s+24>>2]|0;t=Y[s+12>>2]|0;do{if((t|0)==(s|0)){e=s+20|0;t=Y[e>>2]|0;if(!t){e=s+16|0;t=Y[e>>2]|0;if(!t){t=0;break}}while(1){i=t+20|0;n=Y[i>>2]|0;if(!n){i=t+16|0;n=Y[i>>2]|0;if(!n)break;else{t=n;e=i}}else{t=n;e=i}}Y[e>>2]=0}else{_=Y[s+8>>2]|0;Y[_+12>>2]=t;Y[t+8>>2]=_}}while(0);do{if(a){e=Y[s+28>>2]|0;n=3444+(e<<2)|0;if((s|0)==(Y[n>>2]|0)){Y[n>>2]=t;if(!t){r=r&~(1<>2]|0)==(s|0)?_:a+20|0)>>2]=t;if(!t)break}Y[t+24>>2]=a;e=Y[s+16>>2]|0;if(e|0){Y[t+16>>2]=e;Y[e+24>>2]=t}e=Y[s+20>>2]|0;if(e){Y[t+20>>2]=e;Y[e+24>>2]=t}}}while(0);e:do{if(o>>>0<16){_=o+c|0;Y[s+4>>2]=_|3;_=s+_+4|0;Y[_>>2]=Y[_>>2]|1}else{Y[s+4>>2]=c|3;Y[u+4>>2]=o|1;Y[u+o>>2]=o;t=o>>>3;if(o>>>0<256){n=3180+(t<<1<<2)|0;e=Y[785]|0;t=1<>2]|0}Y[e>>2]=u;Y[t+12>>2]=u;Y[u+8>>2]=t;Y[u+12>>2]=n;break}t=o>>>8;if(t){if(o>>>0>16777215)n=31;else{x=(t+1048320|0)>>>16&8;_=t<>>16&4;_=_<>>16&2;n=14-(y|x|n)+(_<>>15)|0;n=o>>>(n+7|0)&1|n<<1}}else n=0;t=3444+(n<<2)|0;Y[u+28>>2]=n;e=u+16|0;Y[e+4>>2]=0;Y[e>>2]=0;e=1<>2]=u;Y[u+24>>2]=t;Y[u+12>>2]=u;Y[u+8>>2]=u;break}t=Y[t>>2]|0;t:do{if((Y[t+4>>2]&-8|0)!=(o|0)){r=o<<((n|0)==31?0:25-(n>>>1)|0);while(1){n=t+16+(r>>>31<<2)|0;e=Y[n>>2]|0;if(!e)break;if((Y[e+4>>2]&-8|0)==(o|0)){t=e;break t}else{r=r<<1;t=e}}Y[n>>2]=u;Y[u+24>>2]=t;Y[u+12>>2]=u;Y[u+8>>2]=u;break e}}while(0);x=t+8|0;_=Y[x>>2]|0;Y[_+12>>2]=u;Y[x>>2]=u;Y[u+8>>2]=_;Y[u+12>>2]=t;Y[u+24>>2]=0}}while(0);_=s+8|0;w=b;return _|0}else h=c}else h=c}else h=-1}while(0);n=Y[787]|0;if(n>>>0>=h>>>0){t=n-h|0;e=Y[790]|0;if(t>>>0>15){_=e+h|0;Y[790]=_;Y[787]=t;Y[_+4>>2]=t|1;Y[e+n>>2]=t;Y[e+4>>2]=h|3}else{Y[787]=0;Y[790]=0;Y[e+4>>2]=n|3;_=e+n+4|0;Y[_>>2]=Y[_>>2]|1}_=e+8|0;w=b;return _|0}o=Y[788]|0;if(o>>>0>h>>>0){y=o-h|0;Y[788]=y;_=Y[791]|0;x=_+h|0;Y[791]=x;Y[x+4>>2]=y|1;Y[_+4>>2]=h|3;_=_+8|0;w=b;return _|0}if(!(Y[903]|0)){Y[905]=4096;Y[904]=4096;Y[906]=-1;Y[907]=-1;Y[908]=0;Y[896]=0;Y[903]=d&-16^1431655768;e=4096}else e=Y[905]|0;s=h+48|0;l=h+47|0;a=e+l|0;i=0-e|0;c=a&i;if(c>>>0<=h>>>0){_=0;w=b;return _|0}e=Y[895]|0;if(e|0?(u=Y[893]|0,d=u+c|0,d>>>0<=u>>>0|d>>>0>e>>>0):0){_=0;w=b;return _|0}e:do{if(!(Y[896]&4)){n=Y[791]|0;t:do{if(n){r=3588;while(1){d=Y[r>>2]|0;if(d>>>0<=n>>>0?(d+(Y[r+4>>2]|0)|0)>>>0>n>>>0:0)break;e=Y[r+8>>2]|0;if(!e){m=128;break t}else r=e}t=a-o&i;if(t>>>0<2147483647){e=fe(t|0)|0;if((e|0)==((Y[r>>2]|0)+(Y[r+4>>2]|0)|0)){if((e|0)!=(-1|0)){o=t;a=e;m=145;break e}}else{r=e;m=136}}else t=0}else m=128}while(0);do{if((m|0)==128){n=fe(0)|0;if((n|0)!=(-1|0)?(t=n,p=Y[904]|0,f=p+-1|0,t=((f&t|0)==0?0:(f+t&0-p)-t|0)+c|0,p=Y[893]|0,f=t+p|0,t>>>0>h>>>0&t>>>0<2147483647):0){d=Y[895]|0;if(d|0?f>>>0<=p>>>0|f>>>0>d>>>0:0){t=0;break}e=fe(t|0)|0;if((e|0)==(n|0)){o=t;a=n;m=145;break e}else{r=e;m=136}}else t=0}}while(0);do{if((m|0)==136){n=0-t|0;if(!(s>>>0>t>>>0&(t>>>0<2147483647&(r|0)!=(-1|0))))if((r|0)==(-1|0)){t=0;break}else{o=t;a=r;m=145;break e}e=Y[905]|0;e=l-t+e&0-e;if(e>>>0>=2147483647){o=t;a=r;m=145;break e}if((fe(e|0)|0)==(-1|0)){fe(n|0)|0;t=0;break}else{o=e+t|0;a=r;m=145;break e}}}while(0);Y[896]=Y[896]|4;m=143}else{t=0;m=143}}while(0);if(((m|0)==143?c>>>0<2147483647:0)?(y=fe(c|0)|0,f=fe(0)|0,v=f-y|0,g=v>>>0>(h+40|0)>>>0,!((y|0)==(-1|0)|g^1|y>>>0>>0&((y|0)!=(-1|0)&(f|0)!=(-1|0))^1)):0){o=g?v:t;a=y;m=145}if((m|0)==145){t=(Y[893]|0)+o|0;Y[893]=t;if(t>>>0>(Y[894]|0)>>>0)Y[894]=t;l=Y[791]|0;e:do{if(l){t=3588;while(1){e=Y[t>>2]|0;n=Y[t+4>>2]|0;if((a|0)==(e+n|0)){m=154;break}r=Y[t+8>>2]|0;if(!r)break;else t=r}if(((m|0)==154?(x=t+4|0,(Y[t+12>>2]&8|0)==0):0)?a>>>0>l>>>0&e>>>0<=l>>>0:0){Y[x>>2]=n+o;_=(Y[788]|0)+o|0;y=l+8|0;y=(y&7|0)==0?0:0-y&7;x=l+y|0;y=_-y|0;Y[791]=x;Y[788]=y;Y[x+4>>2]=y|1;Y[l+_+4>>2]=40;Y[792]=Y[907];break}if(a>>>0<(Y[789]|0)>>>0)Y[789]=a;n=a+o|0;t=3588;while(1){if((Y[t>>2]|0)==(n|0)){m=162;break}e=Y[t+8>>2]|0;if(!e)break;else t=e}if((m|0)==162?(Y[t+12>>2]&8|0)==0:0){Y[t>>2]=a;u=t+4|0;Y[u>>2]=(Y[u>>2]|0)+o;u=a+8|0;u=a+((u&7|0)==0?0:0-u&7)|0;t=n+8|0;t=n+((t&7|0)==0?0:0-t&7)|0;c=u+h|0;s=t-u-h|0;Y[u+4>>2]=h|3;t:do{if((l|0)==(t|0)){_=(Y[788]|0)+s|0;Y[788]=_;Y[791]=c;Y[c+4>>2]=_|1}else{if((Y[790]|0)==(t|0)){_=(Y[787]|0)+s|0;Y[787]=_;Y[790]=c;Y[c+4>>2]=_|1;Y[c+_>>2]=_;break}e=Y[t+4>>2]|0;if((e&3|0)==1){o=e&-8;r=e>>>3;n:do{if(e>>>0<256){e=Y[t+8>>2]|0;n=Y[t+12>>2]|0;if((n|0)==(e|0)){Y[785]=Y[785]&~(1<>2]=n;Y[n+8>>2]=e;break}}else{a=Y[t+24>>2]|0;e=Y[t+12>>2]|0;do{if((e|0)==(t|0)){n=t+16|0;r=n+4|0;e=Y[r>>2]|0;if(!e){e=Y[n>>2]|0;if(!e){e=0;break}}else n=r;while(1){i=e+20|0;r=Y[i>>2]|0;if(!r){i=e+16|0;r=Y[i>>2]|0;if(!r)break;else{e=r;n=i}}else{e=r;n=i}}Y[n>>2]=0}else{_=Y[t+8>>2]|0;Y[_+12>>2]=e;Y[e+8>>2]=_}}while(0);if(!a)break;n=Y[t+28>>2]|0;r=3444+(n<<2)|0;do{if((Y[r>>2]|0)!=(t|0)){_=a+16|0;Y[((Y[_>>2]|0)==(t|0)?_:a+20|0)>>2]=e;if(!e)break n}else{Y[r>>2]=e;if(e|0)break;Y[786]=Y[786]&~(1<>2]=a;n=t+16|0;r=Y[n>>2]|0;if(r|0){Y[e+16>>2]=r;Y[r+24>>2]=e}n=Y[n+4>>2]|0;if(!n)break;Y[e+20>>2]=n;Y[n+24>>2]=e}}while(0);t=t+o|0;i=o+s|0}else i=s;t=t+4|0;Y[t>>2]=Y[t>>2]&-2;Y[c+4>>2]=i|1;Y[c+i>>2]=i;t=i>>>3;if(i>>>0<256){n=3180+(t<<1<<2)|0;e=Y[785]|0;t=1<>2]|0}Y[e>>2]=c;Y[t+12>>2]=c;Y[c+8>>2]=t;Y[c+12>>2]=n;break}t=i>>>8;do{if(!t)r=0;else{if(i>>>0>16777215){r=31;break}x=(t+1048320|0)>>>16&8;_=t<>>16&4;_=_<>>16&2;r=14-(y|x|r)+(_<>>15)|0;r=i>>>(r+7|0)&1|r<<1}}while(0);t=3444+(r<<2)|0;Y[c+28>>2]=r;e=c+16|0;Y[e+4>>2]=0;Y[e>>2]=0;e=Y[786]|0;n=1<>2]=c;Y[c+24>>2]=t;Y[c+12>>2]=c;Y[c+8>>2]=c;break}t=Y[t>>2]|0;n:do{if((Y[t+4>>2]&-8|0)!=(i|0)){r=i<<((r|0)==31?0:25-(r>>>1)|0);while(1){n=t+16+(r>>>31<<2)|0;e=Y[n>>2]|0;if(!e)break;if((Y[e+4>>2]&-8|0)==(i|0)){t=e;break n}else{r=r<<1;t=e}}Y[n>>2]=c;Y[c+24>>2]=t;Y[c+12>>2]=c;Y[c+8>>2]=c;break t}}while(0);x=t+8|0;_=Y[x>>2]|0;Y[_+12>>2]=c;Y[x>>2]=c;Y[c+8>>2]=_;Y[c+12>>2]=t;Y[c+24>>2]=0}}while(0);_=u+8|0;w=b;return _|0}t=3588;while(1){e=Y[t>>2]|0;if(e>>>0<=l>>>0?(_=e+(Y[t+4>>2]|0)|0,_>>>0>l>>>0):0)break;t=Y[t+8>>2]|0}i=_+-47|0;e=i+8|0;e=i+((e&7|0)==0?0:0-e&7)|0;i=l+16|0;e=e>>>0>>0?l:e;t=e+8|0;n=o+-40|0;y=a+8|0;y=(y&7|0)==0?0:0-y&7;x=a+y|0;y=n-y|0;Y[791]=x;Y[788]=y;Y[x+4>>2]=y|1;Y[a+n+4>>2]=40;Y[792]=Y[907];n=e+4|0;Y[n>>2]=27;Y[t>>2]=Y[897];Y[t+4>>2]=Y[898];Y[t+8>>2]=Y[899];Y[t+12>>2]=Y[900];Y[897]=a;Y[898]=o;Y[900]=0;Y[899]=t;t=e+24|0;do{x=t;t=t+4|0;Y[t>>2]=7}while((x+8|0)>>>0<_>>>0);if((e|0)!=(l|0)){a=e-l|0;Y[n>>2]=Y[n>>2]&-2;Y[l+4>>2]=a|1;Y[e>>2]=a;t=a>>>3;if(a>>>0<256){n=3180+(t<<1<<2)|0;e=Y[785]|0;t=1<>2]|0}Y[e>>2]=l;Y[t+12>>2]=l;Y[l+8>>2]=t;Y[l+12>>2]=n;break}t=a>>>8;if(t){if(a>>>0>16777215)r=31;else{x=(t+1048320|0)>>>16&8;_=t<>>16&4;_=_<>>16&2;r=14-(y|x|r)+(_<>>15)|0;r=a>>>(r+7|0)&1|r<<1}}else r=0;n=3444+(r<<2)|0;Y[l+28>>2]=r;Y[l+20>>2]=0;Y[i>>2]=0;t=Y[786]|0;e=1<>2]=l;Y[l+24>>2]=n;Y[l+12>>2]=l;Y[l+8>>2]=l;break}t=Y[n>>2]|0;t:do{if((Y[t+4>>2]&-8|0)!=(a|0)){r=a<<((r|0)==31?0:25-(r>>>1)|0);while(1){n=t+16+(r>>>31<<2)|0;e=Y[n>>2]|0;if(!e)break;if((Y[e+4>>2]&-8|0)==(a|0)){t=e;break t}else{r=r<<1;t=e}}Y[n>>2]=l;Y[l+24>>2]=t;Y[l+12>>2]=l;Y[l+8>>2]=l;break e}}while(0);x=t+8|0;_=Y[x>>2]|0;Y[_+12>>2]=l;Y[x>>2]=l;Y[l+8>>2]=_;Y[l+12>>2]=t;Y[l+24>>2]=0}}else{_=Y[789]|0;if((_|0)==0|a>>>0<_>>>0)Y[789]=a;Y[897]=a;Y[898]=o;Y[900]=0;Y[794]=Y[903];Y[793]=-1;Y[798]=3180;Y[797]=3180;Y[800]=3188;Y[799]=3188;Y[802]=3196;Y[801]=3196;Y[804]=3204;Y[803]=3204;Y[806]=3212;Y[805]=3212;Y[808]=3220;Y[807]=3220;Y[810]=3228;Y[809]=3228;Y[812]=3236;Y[811]=3236;Y[814]=3244;Y[813]=3244;Y[816]=3252;Y[815]=3252;Y[818]=3260;Y[817]=3260;Y[820]=3268;Y[819]=3268;Y[822]=3276;Y[821]=3276;Y[824]=3284;Y[823]=3284;Y[826]=3292;Y[825]=3292;Y[828]=3300;Y[827]=3300;Y[830]=3308;Y[829]=3308;Y[832]=3316;Y[831]=3316;Y[834]=3324;Y[833]=3324;Y[836]=3332;Y[835]=3332;Y[838]=3340;Y[837]=3340;Y[840]=3348;Y[839]=3348;Y[842]=3356;Y[841]=3356;Y[844]=3364;Y[843]=3364;Y[846]=3372;Y[845]=3372;Y[848]=3380;Y[847]=3380;Y[850]=3388;Y[849]=3388;Y[852]=3396;Y[851]=3396;Y[854]=3404;Y[853]=3404;Y[856]=3412;Y[855]=3412;Y[858]=3420;Y[857]=3420;Y[860]=3428;Y[859]=3428;_=o+-40|0;y=a+8|0;y=(y&7|0)==0?0:0-y&7;x=a+y|0;y=_-y|0;Y[791]=x;Y[788]=y;Y[x+4>>2]=y|1;Y[a+_+4>>2]=40;Y[792]=Y[907]}}while(0);t=Y[788]|0;if(t>>>0>h>>>0){y=t-h|0;Y[788]=y;_=Y[791]|0;x=_+h|0;Y[791]=x;Y[x+4>>2]=y|1;Y[_+4>>2]=h|3;_=_+8|0;w=b;return _|0}}Y[(ae()|0)>>2]=12;_=0;w=b;return _|0}function ie(e){e=e|0;var t=0,n=0,r=0,i=0,a=0,o=0,s=0,l=0;if(!e)return;n=e+-8|0;i=Y[789]|0;e=Y[e+-4>>2]|0;t=e&-8;l=n+t|0;do{if(!(e&1)){r=Y[n>>2]|0;if(!(e&3))return;o=n+(0-r)|0;a=r+t|0;if(o>>>0>>0)return;if((Y[790]|0)==(o|0)){e=l+4|0;t=Y[e>>2]|0;if((t&3|0)!=3){s=o;t=a;break}Y[787]=a;Y[e>>2]=t&-2;Y[o+4>>2]=a|1;Y[o+a>>2]=a;return}n=r>>>3;if(r>>>0<256){e=Y[o+8>>2]|0;t=Y[o+12>>2]|0;if((t|0)==(e|0)){Y[785]=Y[785]&~(1<>2]=t;Y[t+8>>2]=e;s=o;t=a;break}}i=Y[o+24>>2]|0;e=Y[o+12>>2]|0;do{if((e|0)==(o|0)){t=o+16|0;n=t+4|0;e=Y[n>>2]|0;if(!e){e=Y[t>>2]|0;if(!e){e=0;break}}else t=n;while(1){r=e+20|0;n=Y[r>>2]|0;if(!n){r=e+16|0;n=Y[r>>2]|0;if(!n)break;else{e=n;t=r}}else{e=n;t=r}}Y[t>>2]=0}else{s=Y[o+8>>2]|0;Y[s+12>>2]=e;Y[e+8>>2]=s}}while(0);if(i){t=Y[o+28>>2]|0;n=3444+(t<<2)|0;if((Y[n>>2]|0)==(o|0)){Y[n>>2]=e;if(!e){Y[786]=Y[786]&~(1<>2]|0)==(o|0)?s:i+20|0)>>2]=e;if(!e){s=o;t=a;break}}Y[e+24>>2]=i;t=o+16|0;n=Y[t>>2]|0;if(n|0){Y[e+16>>2]=n;Y[n+24>>2]=e}t=Y[t+4>>2]|0;if(t){Y[e+20>>2]=t;Y[t+24>>2]=e;s=o;t=a}else{s=o;t=a}}else{s=o;t=a}}else{s=n;o=n}}while(0);if(o>>>0>=l>>>0)return;e=l+4|0;r=Y[e>>2]|0;if(!(r&1))return;if(!(r&2)){if((Y[791]|0)==(l|0)){l=(Y[788]|0)+t|0;Y[788]=l;Y[791]=s;Y[s+4>>2]=l|1;if((s|0)!=(Y[790]|0))return;Y[790]=0;Y[787]=0;return}if((Y[790]|0)==(l|0)){l=(Y[787]|0)+t|0;Y[787]=l;Y[790]=o;Y[s+4>>2]=l|1;Y[o+l>>2]=l;return}i=(r&-8)+t|0;n=r>>>3;do{if(r>>>0<256){t=Y[l+8>>2]|0;e=Y[l+12>>2]|0;if((e|0)==(t|0)){Y[785]=Y[785]&~(1<>2]=e;Y[e+8>>2]=t;break}}else{a=Y[l+24>>2]|0;e=Y[l+12>>2]|0;do{if((e|0)==(l|0)){t=l+16|0;n=t+4|0;e=Y[n>>2]|0;if(!e){e=Y[t>>2]|0;if(!e){n=0;break}}else t=n;while(1){r=e+20|0;n=Y[r>>2]|0;if(!n){r=e+16|0;n=Y[r>>2]|0;if(!n)break;else{e=n;t=r}}else{e=n;t=r}}Y[t>>2]=0;n=e}else{n=Y[l+8>>2]|0;Y[n+12>>2]=e;Y[e+8>>2]=n;n=e}}while(0);if(a|0){e=Y[l+28>>2]|0;t=3444+(e<<2)|0;if((Y[t>>2]|0)==(l|0)){Y[t>>2]=n;if(!n){Y[786]=Y[786]&~(1<>2]|0)==(l|0)?r:a+20|0)>>2]=n;if(!n)break}Y[n+24>>2]=a;e=l+16|0;t=Y[e>>2]|0;if(t|0){Y[n+16>>2]=t;Y[t+24>>2]=n}e=Y[e+4>>2]|0;if(e|0){Y[n+20>>2]=e;Y[e+24>>2]=n}}}}while(0);Y[s+4>>2]=i|1;Y[o+i>>2]=i;if((s|0)==(Y[790]|0)){Y[787]=i;return}}else{Y[e>>2]=r&-2;Y[s+4>>2]=t|1;Y[o+t>>2]=t;i=t}e=i>>>3;if(i>>>0<256){n=3180+(e<<1<<2)|0;t=Y[785]|0;e=1<>2]|0}Y[t>>2]=s;Y[e+12>>2]=s;Y[s+8>>2]=e;Y[s+12>>2]=n;return}e=i>>>8;if(e){if(i>>>0>16777215)r=31;else{o=(e+1048320|0)>>>16&8;l=e<>>16&4;l=l<>>16&2;r=14-(a|o|r)+(l<>>15)|0;r=i>>>(r+7|0)&1|r<<1}}else r=0;e=3444+(r<<2)|0;Y[s+28>>2]=r;Y[s+20>>2]=0;Y[s+16>>2]=0;t=Y[786]|0;n=1<>2]=s;Y[s+24>>2]=e;Y[s+12>>2]=s;Y[s+8>>2]=s}else{e=Y[e>>2]|0;t:do{if((Y[e+4>>2]&-8|0)!=(i|0)){r=i<<((r|0)==31?0:25-(r>>>1)|0);while(1){n=e+16+(r>>>31<<2)|0;t=Y[n>>2]|0;if(!t)break;if((Y[t+4>>2]&-8|0)==(i|0)){e=t;break t}else{r=r<<1;e=t}}Y[n>>2]=s;Y[s+24>>2]=e;Y[s+12>>2]=s;Y[s+8>>2]=s;break e}}while(0);o=e+8|0;l=Y[o>>2]|0;Y[l+12>>2]=s;Y[o>>2]=s;Y[s+8>>2]=l;Y[s+12>>2]=e;Y[s+24>>2]=0}}while(0);l=(Y[793]|0)+-1|0;Y[793]=l;if(l|0)return;e=3596;while(1){e=Y[e>>2]|0;if(!e)break;else e=e+8|0}Y[793]=-1;return}function ae(){return 3636}function oe(e,t,n){e=e|0;t=t|0;n=n|0;var r=0,i=0;e:do{if(!n)e=0;else{while(1){r=H[e>>0]|0;i=H[t>>0]|0;if(r<<24>>24!=i<<24>>24)break;n=n+-1|0;if(!n){e=0;break e}else{e=e+1|0;t=t+1|0}}e=(r&255)-(i&255)|0}}while(0);return e|0}function se(e,t,n){e=e|0;t=t|0;n=n|0;if((n|0)<32){f(t>>>n|0);return e>>>n|(t&(1<>>n-32|0}function le(e,t,n){e=e|0;t=t|0;n=n|0;if((n|0)<32){f(t<>>32-n|0);return e<>>0;return(f(t+r+(n>>>0>>0|0)>>>0|0),n|0)|0}function ue(e,t,n,r){e=e|0;t=t|0;n=n|0;r=r|0;r=t-r-(n>>>0>e>>>0|0)>>>0;return(f(r|0),e-n>>>0|0)|0}function he(e,t,n){e=e|0;t=t|0;n=n|0;var r=0,i=0,a=0;if((n|0)>=8192){g(e|0,t|0,n|0)|0;return e|0}a=e|0;i=e+n|0;if((e&3)==(t&3)){while(e&3){if(!n)return a|0;H[e>>0]=H[t>>0]|0;e=e+1|0;t=t+1|0;n=n-1|0}n=i&-4|0;r=n-64|0;while((e|0)<=(r|0)){Y[e>>2]=Y[t>>2];Y[e+4>>2]=Y[t+4>>2];Y[e+8>>2]=Y[t+8>>2];Y[e+12>>2]=Y[t+12>>2];Y[e+16>>2]=Y[t+16>>2];Y[e+20>>2]=Y[t+20>>2];Y[e+24>>2]=Y[t+24>>2];Y[e+28>>2]=Y[t+28>>2];Y[e+32>>2]=Y[t+32>>2];Y[e+36>>2]=Y[t+36>>2];Y[e+40>>2]=Y[t+40>>2];Y[e+44>>2]=Y[t+44>>2];Y[e+48>>2]=Y[t+48>>2];Y[e+52>>2]=Y[t+52>>2];Y[e+56>>2]=Y[t+56>>2];Y[e+60>>2]=Y[t+60>>2];e=e+64|0;t=t+64|0}while((e|0)<(n|0)){Y[e>>2]=Y[t>>2];e=e+4|0;t=t+4|0}}else{n=i-4|0;while((e|0)<(n|0)){H[e>>0]=H[t>>0]|0;H[e+1>>0]=H[t+1>>0]|0;H[e+2>>0]=H[t+2>>0]|0;H[e+3>>0]=H[t+3>>0]|0;e=e+4|0;t=t+4|0}}while((e|0)<(i|0)){H[e>>0]=H[t>>0]|0;e=e+1|0;t=t+1|0}return a|0}function de(e,t,n){e=e|0;t=t|0;n=n|0;var r=0;if((t|0)<(e|0)&(e|0)<(t+n|0)){r=e;t=t+n|0;e=e+n|0;while((n|0)>0){e=e-1|0;t=t-1|0;n=n-1|0;H[e>>0]=H[t>>0]|0}e=r}else he(e,t,n)|0;return e|0}function pe(e,t,n){e=e|0;t=t|0;n=n|0;var r=0,i=0,a=0,o=0;a=e+n|0;t=t&255;if((n|0)>=67){while(e&3){H[e>>0]=t;e=e+1|0}r=a&-4|0;o=t|t<<8|t<<16|t<<24;i=r-64|0;while((e|0)<=(i|0)){Y[e>>2]=o;Y[e+4>>2]=o;Y[e+8>>2]=o;Y[e+12>>2]=o;Y[e+16>>2]=o;Y[e+20>>2]=o;Y[e+24>>2]=o;Y[e+28>>2]=o;Y[e+32>>2]=o;Y[e+36>>2]=o;Y[e+40>>2]=o;Y[e+44>>2]=o;Y[e+48>>2]=o;Y[e+52>>2]=o;Y[e+56>>2]=o;Y[e+60>>2]=o;e=e+64|0}while((e|0)<(r|0)){Y[e>>2]=o;e=e+4|0}}while((e|0)<(a|0)){H[e>>0]=t;e=e+1|0}return a-n|0}function fe(e){e=e|0;var t=0,n=0;n=Y[i>>2]|0;t=n+e|0;if((e|0)>0&(t|0)<(n|0)|(t|0)<0){x(t|0)|0;m(12);return-1}if((t|0)>(v()|0)?(y(t|0)|0)==0:0){m(12);return-1}Y[i>>2]=t;return n|0}return{_bitshift64Lshr:se,_bitshift64Shl:le,_decompress:B,_free:ie,_get_curr_output_length:te,_get_in_buffer_ptr:k,_get_out_buffer_ptr:V,_i64Add:ce,_i64Subtract:ue,_in_buffer_set_pos:j,_in_buffer_set_size:W,_init_decompressor:U,_is_input_end_reached:ne,_malloc:re,_memcpy:he,_memmove:de,_memset:pe,_out_buffer_set_pos:X,_out_buffer_set_size:ee,_sbrk:fe,establishStackSpace:S,stackAlloc:A,stackRestore:T,stackSave:M}}({Math:Math,Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},{a:Sf,b:function(e){zp=e},c:function(){return zp},d:function(e){return Cp.___errno_location&&(qp[Cp.___errno_location()>>2]=e),e},e:function(){return Hp.length},f:function(e,t,n){Yp.set(Yp.subarray(t,t+n),e)},g:function(e){cf()},h:cf,i:1052480,j:1052240},Xp),vf=(Cp._bitshift64Lshr=mf._bitshift64Lshr,Cp._bitshift64Shl=mf._bitshift64Shl,Cp._decompress=mf._decompress,Cp._free=mf._free,Cp._get_curr_output_length=mf._get_curr_output_length,Cp._get_in_buffer_ptr=mf._get_in_buffer_ptr,Cp._get_out_buffer_ptr=mf._get_out_buffer_ptr,Cp._i64Add=mf._i64Add,Cp._i64Subtract=mf._i64Subtract,Cp._in_buffer_set_pos=mf._in_buffer_set_pos,Cp._in_buffer_set_size=mf._in_buffer_set_size,Cp._init_decompressor=mf._init_decompressor,Cp._is_input_end_reached=mf._is_input_end_reached,Cp._malloc=mf._malloc,Cp._memcpy=mf._memcpy,Cp._memmove=mf._memmove,Cp._memset=mf._memset,Cp._out_buffer_set_pos=mf._out_buffer_set_pos,Cp._out_buffer_set_size=mf._out_buffer_set_size,Cp._sbrk=mf._sbrk,Cp.establishStackSpace=mf.establishStackSpace,Cp.stackAlloc=mf.stackAlloc),gf=Cp.stackRestore=mf.stackRestore,yf=Cp.stackSave=mf.stackSave;if(Cp.asm=mf,Cp.cwrap=function(e,t,n,r){var i=(n=n||[]).every(function(e){return"number"===e});return"string"!==t&&i&&!r?Vp(e):function(){return jp(e,t,n,arguments)}},of)if(lf(of)||(ff=of,of=Cp.locateFile?Cp.locateFile(ff,Dp):Dp+ff),Ip||Rp){var xf=Cp.readBinary(of);Yp.set(xf,8)}else{nf++,Cp.monitorRunDependencies&&Cp.monitorRunDependencies(nf);var _f=function(e){e.byteLength&&(e=new Uint8Array(e)),Yp.set(e,8),Cp.memoryInitializerRequest&&delete Cp.memoryInitializerRequest.response,function(e){if(nf--,Cp.monitorRunDependencies&&Cp.monitorRunDependencies(nf),0==nf&&(null!==rf&&(clearInterval(rf),rf=null),af)){var t=af;af=null,t()}}()},bf=function(){Cp.readAsync(of,_f,function(){throw"could not load memory initializer "+of})},wf=pf(of);if(wf)_f(wf.buffer);else if(Cp.memoryInitializerRequest){var Af=function(){var e=Cp.memoryInitializerRequest,t=e.response;if(200!==e.status&&0!==e.status){var n=pf(Cp.memoryInitializerRequestURL);if(!n)return console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+e.status+", retrying "+of),void bf();t=n.buffer}_f(t)};Cp.memoryInitializerRequest.response?setTimeout(Af,0):Cp.memoryInitializerRequest.addEventListener("load",Af)}else bf()}function Mf(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Tf(e){function t(){Cp.calledRun||(Cp.calledRun=!0,Gp||(tf||(tf=!0,Zp(Jp)),Zp($p),Cp.onRuntimeInitialized&&Cp.onRuntimeInitialized(),function(){if(Cp.postRun)for("function"==typeof Cp.postRun&&(Cp.postRun=[Cp.postRun]);Cp.postRun.length;)e=Cp.postRun.shift(),ef.unshift(e);var e;Zp(ef)}()))}e=e||Cp.arguments,0s)var l=((c=n varying vec2 vUv;\n uniform sampler2D colorTexture;\n uniform vec2 texSize; uniform vec2 direction; float gaussianPdf(in float x, in float sigma) { return 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma; } void main() {\n vec2 invSize = 1.0 / texSize; float fSigma = float(SIGMA); float weightSum = gaussianPdf(0.0, fSigma); vec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum; for(int i = 1; i < KERNEL_RADIUS; i++) { float x = float(i); float w = gaussianPdf(x, fSigma); vec2 uvOffset = direction * invSize * x; vec3 sample1 = texture2D(colorTexture, vUv + uvOffset).rgb; vec3 sample2 = texture2D(colorTexture, vUv - uvOffset).rgb; diffuseSum += (sample1 + sample2) * w; weightSum += 2.0 * w; } gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n }"})},getCompositeMaterial:function(e){return new Ei({type:"BloomComposite",defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"varying vec2 vUv; uniform sampler2D blurTexture1; uniform sampler2D blurTexture2; uniform sampler2D blurTexture3; uniform sampler2D blurTexture4; uniform sampler2D blurTexture5; uniform sampler2D dirtTexture; uniform float bloomStrength; uniform float bloomRadius; uniform float bloomFactors[NUM_MIPS]; uniform vec3 bloomTintColors[NUM_MIPS]; float lerpBloomFactor(const in float factor) { float mirrorFactor = 1.2 - factor; return mix(factor, mirrorFactor, bloomRadius); } void main() { gl_FragColor = bloomStrength * (lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv)); }"})}}),Of.BlurDirectionX=new Dt(1,0),Of.BlurDirectionY=new Dt(0,1),Nf.prototype=Object.assign(Object.create(Ff.prototype),{constructor:Nf,render:function(e,t,n,r,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)),this.fsQuad.render(e)},dispose:function(){this.material.dispose()}}),Df.prototype=Object.assign(Object.create(Nf.prototype),{constructor:Df}),Uf.prototype=Object.assign(Object.create(Ff.prototype),{constructor:Uf,render:function(e,t,n,r,i){this.quad2.material=this.materialBokeh,this.scene.overrideMaterial=this.materialDepth,this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();e.autoClear;e.autoClear=!1,e.setClearColor(16777215),e.setClearAlpha(1),e.setRenderTarget(this.renderTargetDepth),e.clear(),e.render(this.scene,this.camera),this.uniforms.tColor.value=n.texture,this.uniforms.nearClip.value=this.camera.near,this.uniforms.farClip.value=this.camera.far,this.uniforms.aspect.value=this.camera.aspect,this.renderToScreen?e.setRenderTarget(null):(e.setRenderTarget(t),e.clear()),e.render(this.scene2,this.camera2),this.scene.overrideMaterial=null,e.setClearColor(this.oldClearColor),e.setClearAlpha(this.oldClearAlpha),e.autoClear=this.oldAutoClear},setCamera:function(e){this.camera=e},setSize:function(e,t){this.renderTargetDepth.setSize(e,t)},dispose:function(){this.renderTargetDepth.dispose()}}),Bf.prototype=Object.assign(Object.create(Ff.prototype),{constructor:Bf,render:function(e,t,n,r,i){var a,o,s=e.context,l=e.state;l.buffers.color.setMask(!1),l.buffers.depth.setMask(!1),l.buffers.color.setLocked(!0),l.buffers.depth.setLocked(!0),o=this.inverse?(a=0,1):(a=1,0),l.buffers.stencil.setTest(!0),l.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),l.buffers.stencil.setFunc(s.ALWAYS,a,4294967295),l.buffers.stencil.setClear(o),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),l.buffers.color.setLocked(!1),l.buffers.depth.setLocked(!1),l.buffers.stencil.setFunc(s.EQUAL,1,4294967295),l.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP)},setCamera:function(e){this.camera=e}}),zf.prototype=Object.create(Ff.prototype),Object.assign(zf.prototype,{render:function(e,t,n,r,i){e.state.buffers.stencil.setTest(!1)}}),Object.assign(Gf.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},addPass:function(e){this.passes.push(e);var t=this.renderer.getDrawingBufferSize(new Dt);e.setSize(t.width,t.height)},insertPass:function(e,t){this.passes.splice(t,0,e)},isLastEnabledPass:function(e){for(var t=e+1;t=e.byteLength||!(t=l(e)))return y(1,"no header found");if(!(n=t.match(/^#\?(\S+)$/)))return y(3,"bad initial token");for(s.valid|=1,s.programtype=n[1],s.string+=t+"\n";!1!==(t=l(e));)if(s.string+=t+"\n","#"!==t.charAt(0)){if((n=t.match(r))&&(s.gamma=parseFloat(n[1],10)),(n=t.match(i))&&(s.exposure=parseFloat(n[1],10)),(n=t.match(a))&&(s.valid|=2,s.format=n[1]),(n=t.match(o))&&(s.valid|=4,s.height=parseInt(n[1],10),s.width=parseInt(n[2],10)),2&s.valid&&4&s.valid)break}else s.comments+=t+"\n";return 2&s.valid?4&s.valid?s:y(3,"missing image size specifier"):y(3,"missing format specifier")}(t);if(-1!==c){var u=c.width,h=c.height,d=function(e,t,n){var r,i,a,o,s,l,c,u,h,d,p,f,m,v=t,g=n;if(v<8||32767e.byteLength)return y(1);if(m[0]=e[a++],m[1]=e[a++],m[2]=e[a++],m[3]=e[a++],2!=m[0]||2!=m[1]||(m[2]<<8|m[3])!=v)return y(3,"bad rgbe scanline format");for(c=0;c=2.0 are supported.")):(o.extensionsUsed&&(0<=o.extensionsUsed.indexOf(rm.S8S_V3D_DATA)&&(a[rm.S8S_V3D_DATA]=new im(o)),0<=o.extensionsUsed.indexOf(rm.S8S_V3D_MATERIAL_DATA)&&(a[rm.S8S_V3D_MATERIAL_DATA]=new am(o))),new Im(o,a,{path:t||this.path,crossOrigin:this.crossOrigin,loadBinXZ:r,onProgress:function(e){l.onProgress(e)}}).parse(function(e,t,n,r,i,a){var o={scene:e,scenes:t,world:n,cameras:r,animations:i,renderer:a};l.onProgress(100),s(o)},n))}});var rm={KHR_BINARY_GLTF:"KHR_binary_glTF",S8S_V3D_ANIMATION_DATA:"S8S_v3d_animation_data",S8S_V3D_DATA:"S8S_v3d_data",S8S_V3D_CAMERA_DATA:"S8S_v3d_camera_data",S8S_V3D_MATERIAL_DATA:"S8S_v3d_material_data",S8S_V3D_MESH_DATA:"S8S_v3d_mesh_data",S8S_V3D_NODE_DATA:"S8S_v3d_node_data",S8S_V3D_SCENE_DATA:"S8S_v3d_scene_data",S8S_V3D_TEXTURE_DATA:"S8S_v3d_texture_data"};function im(e){this.name=rm.S8S_V3D_DATA;var t=e.extensions&&e.extensions[rm.S8S_V3D_DATA]||{};this.lights={};var n=t.lights||{};for(var r in n){var i,a=n[r],o=(new In).fromArray(a.color),s=jn(a.intensity)?a.intensity:1;switch(a.type){case"point":i=new mu(o,s);break;case"directional":i=new gu(o,s);break;case"spot":i=new fu(o,s);break;case"hemisphere":i=new hu(o,new In(0,0,0),s);break;case"ambient":i=new yu(o,s)}if(i){if(jn(a.distance)&&(i.distance=a.distance),jn(a.decay)&&(i.decay=a.decay,"blender"==a.profile&&2<=a.decay&&(i.intensity/=4*Math.PI)),jn(a.angle)&&(i.angle=a.angle),jn(a.penumbra)&&(i.penumbra=a.penumbra),jn(a.shadow)){if(i.castShadow=!0,i.shadow.bias=a.shadow.bias,i.shadow.radius=a.shadow.radius,i.shadow.mapSize.width=a.shadow.mapSize,i.shadow.mapSize.height=a.shadow.mapSize,i.shadow.camera.near=a.shadow.cameraNear,i.shadow.camera.far=a.shadow.cameraFar,i.isSpotLight)i.shadow.camera.fov=a.shadow.cameraFov;else if(i.isDirectionalLight){var l=a.shadow.cameraSize/2;i.shadow.camera.bottom=-l,i.shadow.camera.left=-l,i.shadow.camera.top=l,i.shadow.camera.right=l}}else i.castShadow=!1;i.name=a.name||"light_"+r,this.lights[r]=i}}this.nodeGraphs={};var c=t.nodeGraphs||[];for(var u in c){var h=c[u];this.nodeGraphs[u]=h}}function am(e){this.name=rm.S8S_V3D_MATERIAL_DATA}im.prototype.loadCurves=function(e,t){var n=e.extensions&&e.extensions[rm.S8S_V3D_DATA]||{};this.curves={};var r=n.curves||{};for(var i in r){var a,o=r[i];switch(o.type){case"font":var s=new Nu(o.font),l=0m)var v=((g=u