function _get(e,t,n){return(_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=_superPropBase(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _possibleConstructorReturn(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n>8&255]+Wt[e>>16&255]+Wt[e>>24&255]+"-"+Wt[255&t]+Wt[t>>8&255]+"-"+Wt[t>>16&15|64]+Wt[t>>24&255]+"-"+Wt[63&n|128]+Wt[n>>8&255]+"-"+Wt[n>>16&255]+Wt[n>>24&255]+Wt[255&r]+Wt[r>>8&255]+Wt[r>>16&255]+Wt[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*Yt.DEG2RAD},radToDeg:function(e){return e*Yt.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))},setQuaternionFromProperEuler:function(e,t,n,r,i){var a=Math.cos,o=Math.sin,s=a(n/2),l=o(n/2),c=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),h=o((t-r)/2),p=a((r-t)/2),f=o((r-t)/2);"XYX"===i?e.set(s*u,l*d,l*h,s*c):"YZY"===i?e.set(l*h,s*u,l*d,s*c):"ZXZ"===i?e.set(l*d,l*h,s*u,s*c):"XZX"===i?e.set(s*u,l*f,l*p,s*c):"YXY"===i?e.set(l*p,s*u,l*f,s*c):"ZYZ"===i?e.set(l*f,l*p,s*u,s*c):console.warn("v3d.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")},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)},angleToRange_mPi_Pi:function(e){var t=e+Math.PI;return t%=2*Math.PI,t+=2*Math.PI,t%=2*Math.PI,t-=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+d*b,l=l*m+h*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(nn.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(nn.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),d=s(n/2),h=s(r/2),p=s(i/2);return"XYZ"===a?(this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p):"YXZ"===a?(this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p):"ZXY"===a?(this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p):"ZYX"===a?(this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p):"YZX"===a?(this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p):"XZY"===a&&(this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*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],d=n[10],h=r+s+d;return 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),this._w=n,this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(Yt.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 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=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(),this._onChangeCallback(),this}var c=Math.sqrt(s),u=Math.atan2(c,o),d=Math.sin((1-t)*u)/c,h=Math.sin(t*u)/c;return this._w=a*d+this._w*h,this._x=n*d+this._x*h,this._y=r*d+this._y*h,this._z=i*d+this._z*h,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(){}});var rn=new on,an=new nn;function on(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}Object.assign(on.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:function(e){return e&&e.isEuler||console.error("v3d.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(an.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(an.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},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},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,d=-i*t-a*n-o*r;return this.x=l*s+d*-i+c*-o-u*-a,this.y=c*s+d*-a+u*-i-l*-o,this.z=u*s+d*-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:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},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.lengthSq();if(0===t)return this.set(0,0,0);var n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)},projectOnPlane:function(e){return rn.copy(this).projectOnVector(e),this.sub(rn)},reflect:function(e){return this.sub(rn.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;var n=this.dot(e)/t;return Math.acos(Yt.clamp(n,-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)},setFromMatrix3Column:function(e,t){return this.fromArray(e.elements,3*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}});var sn=new on,ln=new fn,cn=new on(0,0,0),un=new on(1,1,1),dn=new on,hn=new on,pn=new on;function fn(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0t&&(t=e[n]);return t}function _n(e){return void 0!==e}function bn(e,t,n){for(var r=0;rs)return!1}return!0}Object.assign(Kn.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,l=e.length;sthis.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 on),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:function(e){return this.clampPoint(e.center,zn),zn.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var t,n;return n=0=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(Yn),qn.subVectors(this.max,Yn),Vn.subVectors(e.a,Yn),Gn.subVectors(e.b,Yn),jn.subVectors(e.c,Yn),Wn.subVectors(Gn,Vn),Xn.subVectors(jn,Gn),Hn.subVectors(Vn,jn);var t=[0,-Wn.z,Wn.y,0,-Xn.z,Xn.y,0,-Hn.z,Hn.y,Wn.z,0,-Wn.x,Xn.z,0,-Xn.x,Hn.z,0,-Hn.x,-Wn.y,Wn.x,0,-Xn.y,Xn.x,0,-Hn.y,Hn.x,0];return!!Jn(t,Vn,Gn,jn,qn)&&(!!Jn(t=[1,0,0,0,1,0,0,0,1],Vn,Gn,jn,qn)&&(Qn.crossVectors(Wn,Xn),Jn(t=[Qn.x,Qn.y,Qn.z],Vn,Gn,jn,qn)))},clampPoint:function(e,t){return void 0===t&&(console.warn("v3d.Box3: .clampPoint() target is now required"),t=new on),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return zn.copy(e).clamp(this.min,this.max).sub(e).length()},getBoundingSphere:function(e){return void 0===e&&console.error("v3d.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(zn).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:function(e){return this.isEmpty()||(Un[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Un[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Un[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Un[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Un[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Un[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Un[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Un[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Un)),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)}});var $n,er,tr=new Kn;function nr(e,t){this.center=void 0!==e?e:new on,this.radius=void 0!==t?t:0}Object.assign(nr.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){var n=this.center;void 0!==t?n.copy(t):tr.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 Kn),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},union:($n=new on,er=new on,function(e){var t=this.center,n=this.radius,r=e.center,i=e.radius;$n.subVectors(r,t);var a=$n.length();if(a+i<=n)return this;if(a+n<=i)return this.copy(e),this;var o=.5*(n+a+i);return er.copy($n).multiplyScalar((o-n)/a),er.add(t),this.center.copy(er),this.radius=o,this})});var rr=new on,ir=new on,ar=new on,or=new on,sr=new on,lr=new on,cr=new on;function ur(e,t){this.origin=void 0!==e?e:new on,this.direction=void 0!==t?t:new on(0,0,-1)}Object.assign(ur.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("v3d.Ray: .at() target is now required"),t=new on),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(e){return this.origin.copy(this.at(e,rr)),this},closestPointToPoint:function(e,t){void 0===t&&(console.warn("v3d.Ray: .closestPointToPoint() target is now required"),t=new on),t.subVectors(e,this.origin);var n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var t=rr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(rr.copy(this.direction).multiplyScalar(t).add(this.origin),rr.distanceToSquared(e))},distanceSqToSegment:function(e,t,n,r){ir.copy(e).add(t).multiplyScalar(.5),ar.copy(t).sub(e).normalize(),or.copy(this.origin).sub(ir);var i,a,o,s,l=.5*e.distanceTo(t),c=-this.direction.dot(ar),u=or.dot(this.direction),d=-or.dot(ar),h=or.lengthSq(),p=Math.abs(1-c*c);if(0>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(e,t,n){if(e=Yt.euclideanModulo(e,1),t=Yt.clamp(t,0,1),n=Yt.clamp(n,0,1),0===t)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Lr(i,r,e+1/3),this.g=Lr(i,r,e),this.b=Lr(i,r,e-1/3)}return this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("v3d.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],a=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,l=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(o,s,l)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var c=n[1],u=c.length;if(3===u)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}return t&&0n.far?null:{distance:l,point:xi.clone(),object:e}}function wi(e,t,n,r,i,a,o,s,l,c,u,d){oi.fromBufferAttribute(i,c),si.fromBufferAttribute(i,u),li.fromBufferAttribute(i,d);var h=e.morphTargetInfluences;if(t.morphTargets&&a&&h){hi.set(0,0,0),pi.set(0,0,0),fi.set(0,0,0);for(var p=0,f=a.length;p"," #include ","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {"," vec3 direction = normalize(vWorldDirection);"," vec2 sampleUV;"," sampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;"," sampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;"," gl_FragColor = texture2D(tEquirect, sampleUV);","}"].join("\n")},i=new Fi({type:"CubemapFromEquirect",uniforms:Li(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Le,blending:ie});i.uniforms.tEquirect.value=t;var a=new _i(new Ci(5,5,5),i);n.add(a);var o=new Ui(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(e,n),a.geometry.dispose(),a.material.dispose(),this},((ki.prototype=Object.create(Jt.prototype)).constructor=ki).prototype.isDataTexture=!0;var Vi=new nr,Gi=new on;function ji(e,t,n,r,i,a){this.planes=[void 0!==e?e:new fr,void 0!==t?t:new fr,void 0!==n?n:new fr,void 0!==r?r:new fr,void 0!==i?i:new fr,void 0!==a?a:new fr]}Object.assign(ji.prototype,{set:function(e,t,n,r,i,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this},setFromProjectionMatrix:function(e){var t=this.planes,n=e.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],l=n[5],c=n[6],u=n[7],d=n[8],h=n[9],p=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return t[0].setComponents(o-r,u-s,f-d,y-m).normalize(),t[1].setComponents(o+r,u+s,f+d,y+m).normalize(),t[2].setComponents(o+i,u+l,f+h,y+v).normalize(),t[3].setComponents(o-i,u-l,f-h,y-v).normalize(),t[4].setComponents(o-a,u-c,f-p,y-g).normalize(),t[5].setComponents(o+a,u+c,f+p,y+g).normalize(),this},intersectsObject:function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Vi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Vi)},intersectsSprite:function(e){return Vi.center.set(0,0,0),Vi.radius=.7071067811865476,Vi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Vi)},intersectsSphere:function(e){for(var t=this.planes,n=e.center,r=-e.radius,i=0;i<6;i++){if(t[i].distanceToPoint(n) 0.0) {\n distanceFalloff *= pow2(saturate(1.0 - pow4(lightDistance / cutoffDistance)));\n }\n return distanceFalloff;\n#elif defined(MT_BLENDER)\n return cutoffDistance / (cutoffDistance + pow2(lightDistance));\n#else\n if(cutoffDistance > 0.0 && decayExponent > 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}\nvec3 F_Schlick_RoughnessDependent(const in vec3 F0, const in float dotNV, const in float roughness) {\n float fresnel = exp2((-5.55473 * dotNV - 6.98316) * dotNV);\n vec3 Fr = max(vec3(1.0 - roughness), F0) - F0;\n return Fr * fresnel + F0;\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(clamp(roughness, 0.04, 1.0));\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}\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}\nvec2 get_BRDF_SpecCoeffsBlender(float x, float y) {\n vec3 xyFactors0 = vec3(x * x, y * y, x * y);\n vec3 xyFactors1 = vec3(x, y, 1);\n vec3 a0a1a2 = vec3(0.33749372, 0.15167605, 1.09684597);\n vec3 a3a4a5 = vec3(-1.26123466, -0.927699, 0.9199188);\n vec3 b0b1b2 = vec3(0.41699717, 0.44675109, 0.79947684);\n vec3 b3b4b5 = vec3(-1.19307849, -0.89813958, 0.89305222);\n vec3 c0c1c2 = vec3(0.29920727, 0.09505591, -0.9136233);\n vec3 c3c4c5 = vec3(0.77055201, 0.13006674, -0.23085581);\n vec3 d0d1d2 = vec3(15.05004149, 7.98517355, 13.30473726);\n vec3 d3d4d5 = vec3(-32.00353547, -12.97743434, 17.83646751);\n float coeff0 = (dot(xyFactors0, a0a1a2) + dot(xyFactors1, a3a4a5))\n / (dot(xyFactors0, b0b1b2) + dot(xyFactors1, b3b4b5));\n float coeff1 = (dot(xyFactors0, c0c1c2) + dot(xyFactors1, c3c4c5))\n / (dot(xyFactors0, d0d1d2) + dot(xyFactors1, d3d4d5));\n coeff1 = clamp(coeff1, 0.0, 1.0);\n return vec2(coeff0, coeff1);\n}\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 #ifdef CLEARCOAT\n if (useCoat == 1) {\n normal = geometry.clearcoatNormal;\n }\n #endif\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}\nvec3 BRDF_Specular_GGX_Environment_Blender_Approx(const in GeometricContext geometry,\n const in vec3 fresnelRefl0, const in vec3 fresnelRefl90,\n const in float roughness, const int useCoat) {\n vec3 normal = geometry.normal;\n #ifdef CLEARCOAT\n if (useCoat == 1) {\n normal = geometry.clearcoatNormal;\n }\n #endif\n float dotNV = saturate(dot(normal, geometry.viewDir));\n float angle = acos(abs(dotNV)) / PI_HALF;\n vec2 specCoeffs = get_BRDF_SpecCoeffsBlender(angle, roughness);\n vec3 specular = specCoeffs.x * fresnelRefl0\n + specCoeffs.y * fresnelRefl90\n * vec3(saturate(50.0 * linearToRelativeLuminance(fresnelRefl0)));\n #if defined (COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX)\n specular = saturate(specular);\n #endif\n return specular;\n}\nvoid BRDF_Specular_Multiscattering_Environment(const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\n float dotNV = saturate(dot(geometry.normal, geometry.viewDir));\n vec3 F = F_Schlick_RoughnessDependent(specularColor, dotNV, roughness);\n vec2 brdf = integrateSpecularBRDF(dotNV, roughness);\n vec3 FssEss = F * brdf.x + brdf.y;\n float Ess = brdf.x + brdf.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = specularColor + (1.0 - specularColor) * 0.047619;\n vec3 Fms = FssEss * Favg / (1.0 - Ems * Favg);\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\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}\n#if defined(USE_SHEEN)\nfloat D_Charlie(float roughness, float NoH) {\n float invAlpha = 1.0 / roughness;\n float cos2h = NoH * NoH;\n float sin2h = max(1.0 - cos2h, 0.0078125);\n return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen(const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor) {\n vec3 N = geometry.normal;\n vec3 V = geometry.viewDir;\n vec3 H = normalize(V + L);\n float dotNH = saturate(dot(N, H));\n return specularColor * D_Charlie(roughness, dotNH) * V_Neubelt(dot(N, V), dot(N, L));\n}\n#endif",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(STANDARD) && !defined(PHONG) && !defined(MATCAP)&& !defined(NODE) && !defined(LAMBERT)\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(STANDARD) && !defined(PHONG) && !defined(MATCAP) && !defined(NODE) && !defined(LAMBERT)\n varying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && !defined(STANDARD) && !defined(PHONG) && !defined(MATCAP) && !defined(NODE) && !defined(LAMBERT)\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#ifndef saturate\n#define saturate(a) clamp(a, 0.0, 1.0)\n#endif\n#define whiteComplement(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}\n#ifdef HIGH_PRECISION\n float precisionSafeLength(vec3 v) { return length(v); }\n#else\n float max3(vec3 v) { return max(max(v.x, v.y), v.z); }\n float precisionSafeLength(vec3 v) {\n float maxComponent = max3(abs(v));\n return length(v / maxComponent) * maxComponent;\n }\n#endif\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#ifdef CLEARCOAT\n vec3 clearcoatNormal;\n#endif\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}\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == - 1.0;\n}\nhighp vec3 rand3(const in vec3 v) {\n const highp float c = 43758.5453;\n const highp mat3 coeffs = mat3(\n 165.15, 253.34, 323.22,\n 241.49, 329.07, 147.79,\n 376.31, 143.45, 281.63\n );\n highp vec3 sn = mod(coeffs * v, PI);\n return fract(sin(sn) * c);\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(abs(val), power);\n else\n return -pow(abs(val), power);\n } else if (val == 0.0)\n return 0.0;\n return pow(abs(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}\nvec3 octUVToCubeVec(vec2 octUV, vec2 texelSize) {\n octUV = (1.0 + 2.0 * texelSize) * octUV - texelSize;\n octUV = octUV * 2.0 - 1.0;\n float x = octUV.x;\n float z = -octUV.y;\n float absX = abs(x);\n float absZ = abs(z);\n vec3 cubeVec = vec3(x, 1.0 - absX - absZ, z);\n if (absX + absZ > 1.0) {\n cubeVec.xz = -(vec2(absZ, absX) - 1.0) * sign(vec2(x, z));\n }\n return cubeVec;\n}\nvec2 cubeVecToOctUV(vec3 cubeVec, vec2 texelSize) {\n cubeVec /= dot(vec3(1.0), abs(cubeVec));\n vec2 octUV = vec2(cubeVec.x, -cubeVec.z);\n if (cubeVec.y < 0.0) {\n octUV = sign(octUV) * (1.0 - abs(octUV.ts));\n }\n octUV = (octUV + 1.0) / 2.0;\n octUV = (1.0 - 2.0 * texelSize) * octUV + texelSize;\n return octUV;\n}\n#if __VERSION__ == 100\nfloat cosh(float x) {\n return (exp(x) + exp(-x)) / 2.0;\n}\nvec2 cosh(vec2 x) {\n return (exp(x) + exp(-x)) / 2.0;\n}\nvec3 cosh(vec3 x) {\n return (exp(x) + exp(-x)) / 2.0;\n}\nvec4 cosh(vec4 x) {\n return (exp(x) + exp(-x)) / 2.0;\n}\nfloat sinh(float x) {\n return (exp(x) - exp(-x)) / 2.0;\n}\nvec2 sinh(vec2 x) {\n return (exp(x) - exp(-x)) / 2.0;\n}\nvec3 sinh(vec3 x) {\n return (exp(x) - exp(-x)) / 2.0;\n}\nvec4 sinh(vec4 x) {\n return (exp(x) - exp(-x)) / 2.0;\n}\nfloat tanh(float x) {\n float exp2x = exp(2.0 * x);\n return (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec2 tanh(vec2 x) {\n vec2 exp2x = exp(2.0 * x);\n return (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec3 tanh(vec3 x) {\n vec3 exp2x = exp(2.0 * x);\n return (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec4 tanh(vec4 x) {\n vec4 exp2x = exp(2.0 * x);\n return (exp2x - 1.0) / (exp2x + 1.0);\n}\nfloat trunc(float x) {\n return floor(abs(x)) * sign(x);\n}\nvec2 trunc(vec2 x) {\n return floor(abs(x)) * sign(x);\n}\nvec3 trunc(vec3 x) {\n return floor(abs(x)) * sign(x);\n}\nvec4 trunc(vec4 x) {\n return floor(abs(x)) * sign(x);\n}\n#endif\nfloat getSmoothFactor(float a, float b, float smoothness) {\n return max(smoothness - abs(a - b), 0.0) / smoothness;\n}\nfloat smoothMin(float a, float b, float smoothness) {\n float smoothFac = getSmoothFactor(a, b, smoothness);\n return min(a, b) - smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}\nfloat smoothMax(float a, float b, float smoothness) {\n float smoothFac = getSmoothFactor(a, b, smoothness);\n return max(a, b) + smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y) {\n face = direction.x > 0.0 ? 0.0 : 3.0;\n } else {\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n } else {\n if (absDirection.z > absDirection.y) {\n face = direction.z > 0.0 ? 2.0 : 5.0;\n } else {\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if (mipInt < cubeUV_maxMipLevel) {\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness);\n }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#undef r0\n#undef v0\n#undef m0\n#undef r1\n#undef v1\n#undef m1\n#undef r4\n#undef v4\n#undef m4\n#undef r5\n#undef v5\n#undef m5\n#undef r6\n#undef v6\n#undef m6\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n transformedNormal = mat3(instanceMatrix) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n vec3 transformedTangent = (modelViewMatrix * vec4(objectTangent, 0.0)).xyz;\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, vUv).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 value = max(value, vec4(0.0));\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 value = max(value, vec4(0.0));\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 = clamp(floor(D) / 255.0, 0.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 #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n \n if (isOrthographic) {\n cameraToFrag = normalize(vec3(- viewMatrix[0][2], - viewMatrix[1][2], - viewMatrix[2][2]));\n } else {\n cameraToFrag = normalize(vWorldPosition - cameraPosition);\n }\n vec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect(cameraToFrag, worldNormal);\n #else\n vec3 reflectVec = refract(cameraToFrag, 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_common_pars_fragment:"#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform int maxMipLevel;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n #ifdef ENVMAP_TYPE_CUBE_UV\n float calcGeometryRoughness(vec3 geometryNormal) {\n vec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\n return max(max(dxy.x, dxy.y), dxy.z);\n }\n float calcCubeUVAdjustedRoughness(float origRoughness, float geomRoughness) {\n return min(max(origRoughness, 0.0525) + geomRoughness, 1.0);\n }\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 #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \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)\n #ifdef ENVMAP_MODE_REFRACTION\n uniform float refractionRatio;\n #endif\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, 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 clapmedBlinnShininessExponent = min(blinnShininessExponent, 30000.0);\n float desiredMIPLevel = maxMIPLevelScalar + 0.79248\n - 0.5 * log2(pow2(clapmedBlinnShininessExponent) + 1.0);\n return clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n }\n vec3 _getLightProbeIndirect(const float blinnShininessExponent,\n const int maxMIPLevel, vec3 directionVec) {\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 vec4 envMapColor = textureCubeUV(envMap, queryVec,\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 #ifdef CLEARCOAT\n if (useCoat == 1) {\n normal = geometry.clearcoatNormal;\n }\n #endif\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 return _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\n directionVec);\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 return _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\n directionVec);\n }\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if (isOrthographic) { \n cameraToVertex = normalize(vec3(- viewMatrix[0][2], - viewMatrix[1][2], - viewMatrix[2][2]));\n } else {\n cameraToVertex = normalize(worldPosition.xyz - cameraPosition);\n }\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 = 1.0 - exp(- fogDensity * fogDensity * fogDepth * fogDepth);\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 USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 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}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n vec4 lightMapTexel= texture2D(lightMap, vUv2);\n reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear(lightMapTexel).rgb * 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.viewDir = (isOrthographic) ? vec3(0, 0, 1) : normalize(-mvPosition.xyz);\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\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 bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[9];\nvec3 shGetIrradianceAt(in vec3 normal, in vec3 shCoefficients[9]) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[0] * 0.886227;\n result += shCoefficients[1] * 2.0 * 0.511664 * y;\n result += shCoefficients[2] * 2.0 * 0.511664 * z;\n result += shCoefficients[3] * 2.0 * 0.511664 * x;\n result += shCoefficients[4] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[5] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[6] * (0.743125 * z * z - 0.247708);\n result += shCoefficients[7] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[8] * 0.429043 * (x * x - y * y);\n return result;\n}\nvec3 getLightProbeIrradiance(const in vec3 lightProbe[9], const in GeometricContext geometry) {\n vec3 worldNormal = inverseTransformDirection(geometry.normal, viewMatrix);\n vec3 irradiance = shGetIrradianceAt(worldNormal, lightProbe);\n return irradiance;\n}\nvec3 getAmbientLightIrradiance(const in vec3 ambientLightColor) {\n vec3 irradiance = ambientLightColor;\n #if defined(MT_BLENDER) || !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 vec3 position;\n float maxDistance;\n float expBias;\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 float expBias;\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 float shadowCameraNear;\n float shadowCameraFar;\n float expBias;\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 defined(MT_MAX) && defined(PHYSICALLY_CORRECT_LIGHTS)\n float coneCosDecayed = 2.0 * spotLight.coneCos - spotLight.penumbraCos;\n if (angleCos > coneCosDecayed) {\n float spotEffect = pow(max(angleCos, 0.0), log(0.5) / log(spotLight.penumbraCos) - 1.0);\n if (angleCos < spotLight.coneCos) {\n float decayFac = 1.0 + (spotLight.coneCos - angleCos)\n / (spotLight.coneCos - spotLight.penumbraCos);\n spotEffect *= pow2(decayFac) * (3.0 - 2.0 * decayFac);\n }\n directLight.color = spotLight.color * spotEffect\n * punctualLightIntensityToIrradianceFactor(lightDistance,\n spotLight.distance, spotLight.decay);\n directLight.visible = true;\n } else {\n directLight.color = vec3(0.0);\n directLight.visible = false;\n }\n #else\n if (angleCos > spotLight.coneCos) {\n float spotEffect = smoothstep(spotLight.coneCos, spotLight.penumbraCos, angleCos);\n directLight.color = spotLight.color * spotEffect\n * punctualLightIntensityToIrradianceFactor(lightDistance,\n spotLight.distance, spotLight.decay);\n directLight.visible = true;\n } else {\n directLight.color = vec3(0.0);\n directLight.visible = false;\n }\n #endif\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_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_Toon(const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight) {\n vec3 irradiance = getGradientIrradiance(geometry.normal, directLight.direction) * directLight.color;\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_Toon(const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD(material) (0)",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 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 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.0, 1.0);\n#ifdef REFLECTIVITY\n material.specularColor = mix(vec3(MAXIMUM_SPECULAR_COEFFICIENT * pow2(reflectivity)), diffuseColor.rgb, metalnessFactor);\n#else\n material.specularColor = mix(vec3(DEFAULT_SPECULAR_COEFFICIENT), diffuseColor.rgb, metalnessFactor);\n#endif\n#ifdef CLEARCOAT\n material.clearcoat = saturate(clearcoat);\n material.clearcoatRoughness = clamp(clearcoatRoughness, 0.0, 1.0);\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n vec3 diffuseColor;\n float specularRoughness;\n vec3 specularColor;\n#ifdef CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n vec3 sheenColor;\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 #ifdef CLEARCOAT\n float clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, dotNL);\n reflectedLight.directSpecular += irradiance * material.clearcoat * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n #else\n float clearcoatDHR = 0.0;\n #endif\n #ifdef USE_SHEEN\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_Sheen(\n material.specularRoughness,\n directLight.direction,\n geometry,\n material.sheenColor\n );\n #else\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\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 #ifdef CLEARCOAT\n float ccDotNV = saturate(dot(geometry.clearcoatNormal, geometry.viewDir));\n float ccDotNL = ccDotNV;\n float clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\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(abs(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 = (isOrthographic) ? vec3(0, 0, 1) : normalize(vViewPosition);\n#if defined(CLEARCOAT)\n #if defined(COAT_NORMAL)\n geometry.clearcoatNormal = COAT_NORMAL;\n #else\n geometry.clearcoatNormal = clearcoatNormal;\n #endif\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 #if defined(USE_SHADOWMAP) && ((i) < NUM_POINT_LIGHT_SHADOWS)\n directLight.color *= all(bvec2(pointLight.shadow, directLight.visible)) ?\n getPointShadow(pointLight, pointShadowMap[i], vPointShadowCoord[i]) : 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 #if defined(USE_SHADOWMAP) && ((i) < NUM_SPOT_LIGHT_SHADOWS)\n if (directLight.visible) {\n if (spotLight.shadow == 1) {\n float distWorld = 0.0;\n #if defined(SHADOWMAP_TYPE_ESM)\n distWorld = length((invViewMatrix * vec4(spotLight.position\n - geometry.position, 0.0)).xyz);\n #endif\n directLight.color *= getSpotShadow(spotLight, spotShadowMap[i],\n vSpotShadowCoord[i], distWorld);\n } else if (spotLight.shadow == 2) {\n directLight.color *= getSpotOmniShadow(spotLight,\n spotShadowMap[i], vSpotShadowCoord[i]);\n }\n }\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 #if defined(USE_SHADOWMAP) && ((i) < NUM_DIR_LIGHT_SHADOWS)\n float distWorld = 0.0;\n #if defined(SHADOWMAP_TYPE_ESM)\n distWorld = length((invViewMatrix * vec4(directionalLight.position\n - geometry.position, 0.0)).xyz);\n #endif\n directLight.color *= all(bvec3(directionalLight.shadow, directLight.visible,\n vViewPosition.z < directionalLight.maxDistance)) ?\n getShadow(directionalShadowMap[i], directionalLight.shadowMapSize,\n directionalLight.shadowBias, directionalLight.expBias,\n directionalLight.shadowRadius, vDirectionalShadowCoord[i], distWorld) : 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(MT_BLENDER) && !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 vec4 lightMapTexel= texture2D(lightMap, vUv2);\n vec3 lightMapIrradiance = lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\n #endif\n #if defined(USE_ENVMAP) && defined(STANDARD) && 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 #if defined(USE_SSR) && !defined(USE_SSR_REFRACT)\n radiance = computeSSR(radiance, geometry.normal, 0.0);\n #endif\n #ifdef CLEARCOAT\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 #ifdef USE_SSR_REFRACT\n refraction = computeSSR(refraction, geometry.normal, material.refractionIOR);\n #endif\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 = vIsPerspective == 0.0 ? gl_FragCoord.z : 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 varying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n varying float vIsPerspective;\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 vIsPerspective = float(isPerspectiveMatrix(projectionMatrix));\n #else\n if (isPerspectiveMatrix(projectionMatrix)) {\n gl_Position.z = log2(max(EPSILON, gl_Position.w + 1.0)) * logDepthBufFC - 1.0;\n gl_Position.z *= gl_Position.w;\n }\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:"#if defined(USE_MAP) || defined(USE_ALPHAMAP)\n vec2 uv = (uvTransform * vec3(gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1)).xy;\n#endif\n#ifdef USE_MAP\n vec4 mapTexel = texture2D(map, uv);\n diffuseColor *= mapTexelToLinear(mapTexel);\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D(alphaMap, uv).g;\n#endif",map_particle_pars_fragment:"#if defined(USE_MAP) || defined(USE_ALPHAMAP)\n uniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\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 #if NUM_MORPH_TARGETS > 0\n objectNormal += (morphNormal0 - normal) * morphTargetInfluences[0];\n #endif\n #if NUM_MORPH_TARGETS > 1\n objectNormal += (morphNormal1 - normal) * morphTargetInfluences[1];\n #endif\n #if NUM_MORPH_TARGETS > 2\n objectNormal += (morphNormal2 - normal) * morphTargetInfluences[2];\n #endif\n #if NUM_MORPH_TARGETS > 3\n objectNormal += (morphNormal3 - normal) * morphTargetInfluences[3];\n #endif\n #if NUM_MORPH_TARGETS > 4\n objectNormal += (morphNormal4 - normal) * morphTargetInfluences[4];\n #endif\n #if NUM_MORPH_TARGETS > 5\n objectNormal += (morphNormal5 - normal) * morphTargetInfluences[5];\n #endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n uniform float morphTargetBaseInfluence;\n #ifndef USE_MORPHNORMALS\n uniform float morphTargetInfluences[12];\n #else\n uniform float morphTargetInfluences[6];\n #endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n #if NUM_MORPH_TARGETS > 0\n transformed += morphTarget0 * morphTargetInfluences[0];\n #endif\n #if NUM_MORPH_TARGETS > 1\n transformed += morphTarget1 * morphTargetInfluences[1];\n #endif\n #if NUM_MORPH_TARGETS > 2\n transformed += morphTarget2 * morphTargetInfluences[2];\n #endif\n #if NUM_MORPH_TARGETS > 3\n transformed += morphTarget3 * morphTargetInfluences[3];\n #endif\n #if NUM_MORPH_TARGETS > 4\n transformed += morphTarget4 * morphTargetInfluences[4];\n #endif\n #if NUM_MORPH_TARGETS > 5\n transformed += morphTarget5 * morphTargetInfluences[5];\n #endif\n #ifndef USE_MORPHNORMALS\n #if NUM_MORPH_TARGETS > 6\n transformed += morphTarget6 * morphTargetInfluences[6];\n #endif\n #if NUM_MORPH_TARGETS > 7\n transformed += morphTarget7 * morphTargetInfluences[7];\n #endif\n #if NUM_MORPH_TARGETS > 8\n transformed += morphTarget8 * morphTargetInfluences[8];\n #endif\n #if NUM_MORPH_TARGETS > 9\n transformed += morphTarget9 * morphTargetInfluences[9];\n #endif\n #if NUM_MORPH_TARGETS > 10\n transformed += morphTarget10 * morphTargetInfluences[10];\n #endif\n #if NUM_MORPH_TARGETS > 11\n transformed += morphTarget1 * morphTargetInfluences[11];\n #endif\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 #ifdef FRONT_FACING_VALUE\n bool frontFacing = FRONT_FACING_VALUE;\n #else\n bool frontFacing = gl_FrontFacing;\n #endif\n normal = normal * (float(frontFacing) * 2.0 - 1.0);\n #endif\n #ifdef USE_TANGENT\n vec3 tangent = normalize(vTangent);\n vec3 bitangent = normalize(vBitangent);\n #ifdef DOUBLE_SIDED\n tangent = tangent * (float(gl_FrontFacing) * 2.0 - 1.0);\n bitangent = bitangent * (float(gl_FrontFacing) * 2.0 - 1.0);\n #endif\n #if defined(TANGENTSPACE_NORMALMAP) || defined(USE_CLEARCOAT_NORMALMAP)\n mat3 vTBN = mat3(tangent, bitangent, normal);\n #endif\n #endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#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#elif defined(TANGENTSPACE_NORMALMAP)\n vec3 mapN = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n #ifdef USE_TANGENT\n normal = normalize(vTBN * mapN);\n #else\n normal = perturbNormal2Arb(-vViewPosition, normal, mapN);\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#endif\n#ifdef OBJECTSPACE_NORMALMAP\n uniform mat3 normalMatrix;\n#endif\n#if !defined (USE_TANGENT) && (defined (TANGENTSPACE_NORMALMAP) || defined (USE_CLEARCOAT_NORMALMAP))\n vec3 perturbNormal2Arb(vec3 eye_pos, vec3 surf_norm, vec3 mapN) {\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 mapN.xy *= (float(gl_FrontFacing) * 2.0 - 1.0);\n return normalize(tsn * mapN);\n }\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n vec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D(clearcoatNormalMap, vUv).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n #ifdef USE_TANGENT\n clearcoatNormal = normalize(vTBN * clearcoatMapN);\n #else\n clearcoatNormal = perturbNormal2Arb(- vViewPosition, clearcoatNormal, clearcoatMapN);\n #endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\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}\nvec4 pack2HalfToRGBA(vec2 v) {\n vec4 r = vec4(v.x, fract(v.x * 255.0), v.y, fract(v.y * 255.0));\n return vec4(r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half(vec4 v) {\n return vec2(v.x + (v.y / 255.0), v.z + (v.w / 255.0));\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 = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;\n#if defined(BACKGROUND_DEPTH)\n gl_Position.z = gl_Position.w;\n#endif",dithering_fragment:"#ifdef DITHERING\n gl_FragColor.rgb = dithering(gl_FragColor.rgb);\n#endif",dithering_pars_fragment:"#ifdef 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:"\n#define BLENDER_BIAS_MULT_POINT 0.05\n#define BLENDER_ESM_SPOT_SINGLE_BLUR_COEFF 0.25\n#define MAX_PCF_POISSON_SPOT_OMNI_BLUR_COEFF 4.0\n#define MAX_PCF_POISSON_POINT_BLUR_COEFF 2.5\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform sampler2D directionalShadowMap[NUM_DIR_LIGHT_SHADOWS];\n varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform sampler2D spotShadowMap[NUM_SPOT_LIGHT_SHADOWS];\n varying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform sampler2D pointShadowMap[NUM_POINT_LIGHT_SHADOWS];\n varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];\n #endif\n const vec3 PERMUTE_DIR_X = vec3(1.0, 0.0, 0.0);\n const vec3 PERMUTE_DIR_Y = vec3(0.0, 1.0, 0.0);\n const vec3 PERMUTE_DIR_Z = vec3(0.0, 0.0, 1.0);\n const mat4 POISSON_DISK_0 = mat4(\n 0.954845, 0.242214, -0.623893, -0.235473,\n -0.173288, 0.799228, 0.605969, -0.548050,\n -0.560406, 0.327647, -0.448307, -0.774344,\n 0.308258, 0.417332, -0.125623, -0.056098\n );\n const mat4 POISSON_DISK_1 = mat4(\n 0.145585, -0.305634, 0.264060, -0.661648,\n 0.617942, 0.652121, -0.041412, -0.893582,\n 0.463911, 0.039752, 0.212664, 0.810727,\n -0.955989, -0.014390, -0.652588, 0.671204\n );\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,\n float expBias, float shadowRadius, vec4 shadowCoord, float distWorld) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\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 bvec3 frustumTestVec = bvec3(inFrustum, shadowCoord.z <= 1.0, shadowCoord.z >= 0.0);\n bool frustumTest = all(frustumTestVec);\n if (frustumTest) {\n #if defined(SHADOWMAP_TYPE_PCF)\n shadowCoord.z += shadowBias;\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 shadowCoord.z += shadowBias;\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 #elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\n shadowCoord.z += shadowBias;\n vec2 texelSize = vec2(1.0) / shadowMapSize;\n float randAngle = rand(gl_FragCoord.xy) * PI2;\n float c = cos(randAngle), s = sin(randAngle);\n mat2 sampleMat = mat2(c, s, -s, c)\n * mat2(shadowRadius * texelSize.x, 0.0, 0.0, shadowRadius * texelSize.y);\n shadow = (\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[0].xy, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[0].zw, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[1].xy, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[1].zw, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[2].xy, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[2].zw, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[3].xy, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[3].zw, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[0].xy, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[0].zw, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[1].xy, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[1].zw, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[2].xy, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[2].zw, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[3].xy, shadowCoord.z) +\n texture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[3].zw, shadowCoord.z)\n ) / 16.0;\n #elif defined(SHADOWMAP_TYPE_ESM)\n shadow = saturate(exp(expBias * (texture2D(shadowMap, shadowCoord.xy).x\n - length(distWorld) - BLENDER_BIAS_MULT_POINT * shadowBias)));\n #else\n shadowCoord.z += shadowBias;\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 getOmniShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias,\n float expBias, float shadowRadius, vec4 shadowCoord,\n float shadowCameraNear, float shadowCameraFar) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n float dp = (length(lightToPosition) - shadowCameraNear)\n / (shadowCameraFar - shadowCameraNear);\n bvec2 frustumTestVec = bvec2(dp <= 1.0, dp >= 0.0);\n bool frustumTest = all(frustumTestVec);\n if (frustumTest) {\n dp += shadowBias;\n vec3 bd3D = normalize(lightToPosition);\n vec2 texelSize = 1.0 / shadowMapSize;\n #if defined(SHADOWMAP_TYPE_ESM)\n shadow = saturate(exp(expBias * (texture2D(shadowMap,\n cubeVecToOctUV(bd3D, texelSize)).x\n - length(lightToPosition) - BLENDER_BIAS_MULT_POINT * shadowBias)));\n #elif defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\n vec2 offset = vec2(-1, 1) * shadowRadius * texelSize.y;\n shadow = (\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 #elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\n float randAngle = rand(gl_FragCoord.xy) * PI2;\n float c = cos(randAngle), s = sin(randAngle);\n mat2 sampleMat = mat2(c, s, -s, c)\n * mat2(shadowRadius * texelSize.y, 0.0, 0.0, shadowRadius * texelSize.y);\n vec3 absBd3D = abs(bd3D);\n absBd3D /= max(absBd3D.x, max(absBd3D.y, absBd3D.z));\n bvec2 isPointingCubeFace = greaterThan(absBd3D.xy, vec2(0.999));\n mat3 permuteMat = mat3(\n isPointingCubeFace.x ? PERMUTE_DIR_Y : PERMUTE_DIR_X,\n isPointingCubeFace.x || isPointingCubeFace.y ? PERMUTE_DIR_Z : PERMUTE_DIR_Y,\n isPointingCubeFace.x ? PERMUTE_DIR_X : isPointingCubeFace.y ? PERMUTE_DIR_Y : PERMUTE_DIR_Z\n );\n shadow = (\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[0].xy, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[0].zw, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[1].xy, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[1].zw, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[2].xy, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[2].zw, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[3].xy, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[3].zw, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[0].xy, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[0].zw, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[1].xy, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[1].zw, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[2].xy, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[2].zw, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[3].xy, 0.0), texelSize.y), dp) +\n texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[3].zw, 0.0), texelSize.y), dp)\n ) / 16.0;\n #else\n shadow = texture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp);\n #endif\n }\n return shadow;\n }\n #if NUM_POINT_LIGHT_SHADOWS > 0\n float getPointShadow(PointLight light, sampler2D shadowMap, vec4 shadowCoord) {\n float shadowRadius = light.shadowRadius;\n vec2 mapSize = light.shadowMapSize;\n #if defined(SHADOWMAP_TYPE_ESM)\n mapSize *= 2.0;\n #else\n mapSize *= vec2(4.0, 2.0);\n #if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\n shadowRadius *= MAX_PCF_POISSON_POINT_BLUR_COEFF;\n #endif\n #endif\n return getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\n shadowRadius, shadowCoord, light.shadowCameraNear,\n light.shadowCameraFar);\n }\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n float getSpotOmniShadow(SpotLight light, sampler2D shadowMap, vec4 shadowCoord) {\n float shadowRadius = light.shadowRadius;\n vec2 mapSize = light.shadowMapSize;\n #if defined(SHADOWMAP_TYPE_ESM)\n #else\n mapSize *= vec2(4.0, 2.0);\n #if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\n shadowRadius *= MAX_PCF_POISSON_SPOT_OMNI_BLUR_COEFF;\n #endif\n #endif\n return getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\n shadowRadius, shadowCoord, light.shadowCameraNear,\n light.shadowCameraFar);\n }\n float biasLinearNormalizedToNonlinear(float bias, float near, float far,\n float projZ, float projW) {\n return (bias * (far + near) + 2.0 * projZ) / (bias * (far - near) + 2.0 * projW)\n - projZ / projW;\n }\n float getSpotShadow(SpotLight light, sampler2D shadowMap, vec4 shadowCoord,\n float distWorld) {\n float shadowRadius = light.shadowRadius;\n float shadowBias = light.shadowBias;\n #if defined(SHADOWMAP_TYPE_ESM)\n shadowRadius *= BLENDER_ESM_SPOT_SINGLE_BLUR_COEFF;\n #elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\n shadowBias = biasLinearNormalizedToNonlinear(shadowBias,\n light.shadowCameraNear, light.shadowCameraFar, shadowCoord.z,\n shadowCoord.w);\n #endif\n return getShadow(shadowMap, light.shadowMapSize, shadowBias,\n light.expBias, shadowRadius, shadowCoord, distWorld);\n }\n #endif\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[NUM_DIR_LIGHT_SHADOWS];\n varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n uniform mat4 spotShadowMatrix[NUM_SPOT_LIGHT_SHADOWS];\n varying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[NUM_POINT_LIGHT_SHADOWS];\n varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];\n #endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\n vDirectionalShadowCoord[i] = directionalShadowMatrix[i] * worldPosition;\n }\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\n vSpotShadowCoord[i] = spotShadowMatrix[i] * worldPosition;\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop\n for (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; 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_LIGHT_SHADOWS > 0\n DirectionalLight directionalLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\n directionalLight = directionalLights[i];\n float distWorld = 0.0;\n #if defined(SHADOWMAP_TYPE_ESM)\n distWorld = length((invViewMatrix * vec4(directionalLight.position\n + vViewPosition, 0.0)).xyz);\n #endif\n shadow *= all(bvec2(directionalLight.shadow, vViewPosition.z\n < directionalLight.maxDistance)) ? getShadow(directionalShadowMap[i],\n directionalLight.shadowMapSize, directionalLight.shadowBias,\n directionalLight.expBias, directionalLight.shadowRadius,\n vDirectionalShadowCoord[i], distWorld) : 1.0;\n }\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLight spotLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\n spotLight = spotLights[i];\n if (spotLight.shadow == 1) {\n float distWorld = 0.0;\n #if defined(SHADOWMAP_TYPE_ESM)\n distWorld = length((invViewMatrix * vec4(spotLight.position\n + vViewPosition, 0.0)).xyz);\n #endif\n shadow *= getSpotShadow(spotLight, spotShadowMap[i], vSpotShadowCoord[i],\n distWorld);\n } else if (spotLight.shadow == 2) {\n shadow *= getSpotOmniShadow(spotLight, spotShadowMap[i],\n vSpotShadowCoord[i]);\n }\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n PointLight pointLight;\n #pragma unroll_loop\n for (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i++) {\n pointLight = pointLights[i];\n shadow *= bool(pointLight.shadow) ?\n getPointShadow(pointLight, pointShadowMap[i], vPointShadowCoord[i]) : 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 highp 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 toneMappingMidTones;\nuniform float toneMappingPhysicalScale;\nuniform float toneMappingWhitePoint;\nuniform float toneMappingBrightness;\nuniform float toneMappingContrast;\nuniform bool toneMappingChromaticAdaptation;\nuniform vec3 toneMappingWhiteColor;\nuniform bool toneMappingColorDifferentiation;\nuniform bool toneMappingExteriorDaylight;\nuniform vec3 toneMappingWhiteBalance;\nuniform float toneMappingHighlights;\nuniform float toneMappingShadows;\nuniform float toneMappingSaturation;\nuniform float toneMappingAperture;\nuniform float toneMappingShutter;\nuniform float toneMappingISO;\nuniform float toneMappingVignetting;\nuniform vec2 toneMappingResolution;\nconst float FILMIC_BLENDER_LOG_MIN = -12.473931188;\nconst float FILMIC_BLENDER_LOG_MAX = 12.526068812;\nconst float FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO = 0.66;\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}\nfloat maxExposurePhotographic(in vec4 color1, in vec4 color2)\n{\n return ((color1.r * color2.r) + (color1.g * color2.g)) + (color1.b * color2.b);\n}\nvec3 PhysicalMaxToneMapping(vec3 color) {\n float vignettingInfluence = 1.0;\n if (toneMappingVignetting > 0.0) {\n vec3 vignettingCoords = vec3(0.0, 0.0, 0.0);\n float aspect = toneMappingResolution.x / toneMappingResolution.y;\n vignettingCoords.x = gl_FragCoord.x / toneMappingResolution.x - 0.5;\n vignettingCoords.y = (gl_FragCoord.y / toneMappingResolution.y - 0.5) / aspect;\n vignettingCoords.z = 1.0;\n vignettingCoords = normalize(vignettingCoords);\n vignettingInfluence = pow(vignettingCoords.z, toneMappingVignetting);\n }\n float inputScaleFactor = toneMappingPhysicalScale / PI;\n float filmISO = toneMappingISO;\n float camShutter = 1.0 / toneMappingShutter;\n float fNumber = toneMappingAperture;\n float cm2 = 1.0;\n float burnHighlights = toneMappingHighlights;\n float crushBlacks = toneMappingShadows;\n float saturation = toneMappingSaturation;\n vec3 whitePointInfluence = toneMappingWhiteBalance;\n if (whitePointInfluence.r > 0.0) {\n whitePointInfluence.r = 1.0 / whitePointInfluence.r;\n } else {\n whitePointInfluence.r = 1.0;\n }\n if (whitePointInfluence.g > 0.0) {\n whitePointInfluence.g = 1.0 / whitePointInfluence.g;\n } else {\n whitePointInfluence.g = 1.0;\n }\n if (whitePointInfluence.b > 0.0) {\n whitePointInfluence.b = 1.0 / whitePointInfluence.b;\n } else {\n whitePointInfluence.b = 1.0;\n }\n vec4 lumFactor = vec4(0.212671, 0.715160, 0.072169, 0.0);\n float whiteLumFactor = maxExposurePhotographic(lumFactor, vec4(whitePointInfluence, 0.0));\n whitePointInfluence.r /= whiteLumFactor;\n whitePointInfluence.g /= whiteLumFactor;\n whitePointInfluence.b /= whiteLumFactor;\n float isoInfluence = 0.0;\n float camShutterInv = 1.0 / camShutter;\n if (filmISO > 0.0) {\n isoInfluence = ((cm2 * 0.169811) * (filmISO * camShutterInv)) / ((15.4 * fNumber) * fNumber);\n } else {\n isoInfluence = cm2;\n }\n vec3 outColor = inputScaleFactor * color;\n outColor.r = outColor.r * whitePointInfluence.r * isoInfluence * vignettingInfluence;\n outColor.g = outColor.g * whitePointInfluence.g * isoInfluence * vignettingInfluence;\n outColor.b = outColor.b * whitePointInfluence.b * isoInfluence * vignettingInfluence;\n outColor.r = (outColor.r * (1.0 + (outColor.r * burnHighlights))) / (1.0 + outColor.r);\n outColor.g = (outColor.g * (1.0 + (outColor.g * burnHighlights))) / (1.0 + outColor.g);\n outColor.b = (outColor.b * (1.0 + (outColor.b * burnHighlights))) / (1.0 + outColor.b);\n float lumFactor2 = maxExposurePhotographic(lumFactor, vec4(outColor, 0.0));\n float tmpFloat = 1.0 - saturation;\n outColor.r = outColor.r * saturation + lumFactor2 * tmpFloat;\n outColor.g = outColor.g * saturation + lumFactor2 * tmpFloat;\n outColor.b = outColor.b * saturation + lumFactor2 * tmpFloat;\n outColor = max(vec3(0.0), outColor);\n float crushBlacksFac = crushBlacks * 2.0 + 1.0;\n float crushBlacksFac2 = pow(maxExposurePhotographic(lumFactor, vec4(outColor, 0.0)), 0.5);\n tmpFloat = (1.0 - crushBlacksFac2);\n if (crushBlacksFac2 < 1.0) {\n outColor.r = outColor.r * crushBlacksFac2 + pow(outColor.r, crushBlacksFac) * tmpFloat;\n outColor.g = outColor.g * crushBlacksFac2 + pow(outColor.g, crushBlacksFac) * tmpFloat;\n outColor.b = outColor.b * crushBlacksFac2 + pow(outColor.b, crushBlacksFac) * tmpFloat;\n }\n return outColor;\n}\nfloat filmicBlenderDesaturationMinIntensity(vec3 color) {\n float maxChannel = max(color.r, max(color.g, color.b));\n float x = max(maxChannel, 0.6251);\n return (1.2192868 * x - 0.63221059)\n * ((x - 0.65069831) / (abs(x - 0.65069831) + 0.00952982) + 0.73015231);\n}\nvec3 filmicBlenderDesaturationTransform(vec3 color) {\n const float CURVE_SMOOTHNESS = 0.03;\n float minIntensity = filmicBlenderDesaturationMinIntensity(color);\n vec4 x = vec4(color, 1.0) - minIntensity;\n x = pow(x, vec4(2.0)) / (abs(x) + CURVE_SMOOTHNESS);\n return (x.rgb - x.a + color + 1.0) / 2.0;\n}\nvec3 filmicBlenderDynamicRangeTransform(vec3 color) {\n return pow(\n (0.28882259 * color - 0.15880336)\n / (pow(color - 0.6229693, vec3(2.0)) + 0.16965022)\n + 0.20453365 * color + 0.37847142,\n vec3(3.0)\n );\n}\nvec3 FilmicBlenderToneMapping(vec3 color) {\n color *= toneMappingExposure;\n color = max(color, 0.000175);\n color = clamp((log2(color) - FILMIC_BLENDER_LOG_MIN)\n / (FILMIC_BLENDER_LOG_MAX - FILMIC_BLENDER_LOG_MIN), 0.0, 1.0);\n color = filmicBlenderDesaturationTransform(color);\n color = clamp(color / FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO, 0.0, 1.0);\n color = filmicBlenderDynamicRangeTransform(color);\n return color;\n}",uv_pars_fragment:"#if (defined(USE_UV) && !defined(UVS_VERTEX_ONLY))\n varying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n #ifdef UVS_VERTEX_ONLY\n vec2 vUv;\n #else\n varying vec2 vUv;\n #endif\n uniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\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 uniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\n vUv2 = (uv2Transform * vec3(uv2, 1)).xy;\n#endif",worldpos_vertex:"#if defined(USE_ENVMAP) || defined(DISTANCE) || defined (USE_SHADOWMAP) || defined(MASK) || defined(NODE)\n vec4 worldPosition = vec4(transformed, 1.0);\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\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:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 vReflect = vWorldDirection;\n #include \n gl_FragColor = envColor;\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 == 3202\n varying vec3 vViewPosition;\n#else\n varying vec2 vProjectedPosZW;\n#endif\n#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#ifdef USE_SLOPE_SCALED_BIAS\n uniform float slopeScaledBias;\n const float ONE_MINUS_EPS = 0.9999999;\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 != 3202\n float depth = vProjectedPosZW.x / vProjectedPosZW.y;\n depth = (depth + 1.0) / 2.0;\n #ifdef USE_SLOPE_SCALED_BIAS\n vec2 dxdy = abs(vec2(dFdx(depth), dFdy(depth)));\n float bias = slopeScaledBias * max(dxdy.x, dxdy.y);\n depth = clamp(depth + max(bias, 1e-7), 0.0, ONE_MINUS_EPS);\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4(vec3(1.0 - depth), opacity);\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA(depth);\n #endif\n #else\n gl_FragColor = vec4(vViewPosition.z);\n #endif\n}",depth_vert:"varying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\n#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 vViewPosition = mvPosition.xyz;\n vProjectedPosZW = mat2(\n projectionMatrix[2][2], projectionMatrix[2][3],\n projectionMatrix[3][2], projectionMatrix[3][3]\n ) * mvPosition.zw;\n}",distanceRGBA_frag:"#define DISTANCE\n#ifdef USE_SLOPE_SCALED_BIAS\n uniform float slopeScaledBias;\n const float ONE_MINUS_EPS = 0.9999999;\n#endif\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 #if DISTANCE_PACKING == 3301\n dist = (dist - nearDistance) / (farDistance - nearDistance);\n dist = saturate(dist);\n #ifdef USE_SLOPE_SCALED_BIAS\n vec2 dxdy = abs(vec2(dFdx(dist), dFdy(dist)));\n float bias = slopeScaledBias * max(dxdy.x, dxdy.y);\n dist = clamp(dist + bias, 0.0, ONE_MINUS_EPS);\n #endif\n gl_FragColor = packDepthToRGBA(dist);\n #elif DISTANCE_PACKING == 3302\n gl_FragColor = vec4(dist, 0.0, 0.0, 1.0);\n #endif\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 \n vec4 lightMapTexel= texture2D(lightMap, vUv2);\n reflectedLight.indirectDiffuse += lightMapTexelToLinear(lightMapTexel).rgb * 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:"#define LAMBERT\nuniform 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#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\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 \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#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\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 #ifdef USE_SHADOWMAP\n vViewPosition = - mvPosition.xyz;\n #endif\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}",meshtoon_frag:"#define TOON\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 \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 gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n #include \n #include \n}",meshtoon_vert:"#define TOON\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 \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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\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 \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 \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 vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n #define REFLECTIVITY\n #define CLEARCOAT\n #define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n uniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n uniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheen;\n#endif\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\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 \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 #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #ifdef TRANSPARENCY\n diffuseColor.a *= saturate(1. - transparency + linearToRelativeLuminance(reflectedLight.directSpecular + reflectedLight.indirectSpecular));\n #endif\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n #include \n #include \n #include \n #include \n #include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\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 #ifdef USE_TANGENT\n vTangent = normalize(transformedTangent);\n vBitangent = normalize(cross(vNormal, vTangent) * tangent.w);\n #endif\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}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\n varying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\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 gl_FragColor = vec4(packNormalToRGB(normal), opacity);\n}",normal_vert:"#define NORMAL\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\n varying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif\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 #ifdef USE_TANGENT\n vTangent = normalize(transformedTangent);\n vBitangent = normalize(cross(vNormal, vTangent) * tangent.w);\n #endif\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(TANGENTSPACE_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 = isPerspectiveMatrix(projectionMatrix);\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#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\n#endif\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 #include \n #include \n}",shadow_vert:"#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\n#endif\n#include \n#include \nvoid main() {\n #include \n #include \n #ifdef USE_SHADOWMAP\n vViewPosition = - mvPosition.xyz;\n #endif\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 \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}",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 = isPerspectiveMatrix(projectionMatrix);\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#define STANDARD\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) || defined(SHADOWMAP_TYPE_ESM) && (defined(NODE_BSDF_DIFFUSE) || defined(NODE_BSDF_GLOSSY) || defined(NODE_BSDF_REFRACTION) || defined(NODE_MATERIAL_MAX) || defined(NODE_PHYSICAL_MAX)) || defined(NODE_BITMAP_MAX) || defined(NODE_GRADIENT_RAMP_MAX)\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) || defined(USE_SSR)\nuniform mat4 projectionMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM) || defined(NODE_TEX_COORD) || defined(NODE_NEW_GEOMETRY) || defined(NODE_BITMAP_MAX) || defined(NODE_GRADIENT_RAMP_MAX)\nuniform mat4 modelMatrix;\nuniform mat4 invModelMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM) || defined(NODE_NORMAL_MAP) || defined(NODE_NORMAL_BUMP_MAX) || defined(NODE_MATERIAL_GF)\nuniform mat4 modelViewMatrix;\n#endif\n#if defined(NODE_TEX_IMAGE)\nuniform mat3 normalMatrix;\n#endif\n#if defined(NODE_TEX_COORD) || defined(NODE_NEW_GEOMETRY)\nuniform vec3 boundingBoxMin;\nuniform vec3 boundingBoxMax;\n#endif\n#if defined(NODE_REFLECT_REFRACT_MAX) || defined(NODE_BITMAP_ENV_MAX) || defined(NODE_BUMP) || defined(NODE_PHY_SUN_SKY_ENV_MAX) || defined(NODE_AI_SKYDOME_LIGHT_MY)\nvarying vec3 vWorldPosition;\n#endif\n#if defined(NODE_TEX_COORD)\nuniform vec2 viewWidthHeight;\n#endif\n#include \n#include \n#include \nvoid main() {\n bool _frontFacingValue = gl_FrontFacing;\n #define FRONT_FACING_VALUE _frontFacingValue\n #include \n #include \n #include \n vec4 outgoingLight = vec4(0.0);\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\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#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) || defined(NODE_AI_SKYDOME_LIGHT_MY)\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) || defined(NODE_AI_SKYDOME_LIGHT_MY)\n vWorldPosition = worldPosition.xyz;\n#endif\n #include \n}",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 CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n vec3 sheenColor;\n#endif\n #ifdef PHYSICAL\n vec3 fresnelRefl90;\n float specularRoughness;\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 #ifdef CLEARCOAT\n float coatDotNL = saturate(dot(geometry.clearcoatNormal, directLight.direction));\n vec3 coatIrradiance = coatDotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n coatIrradiance *= PI;\n #endif\n #endif\n #ifdef CLEARCOAT\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 #ifdef CLEARCOAT\n reflectedLight.directSpecular += coatIrradiance * material.clearcoat\n * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.clearcoatNormal,\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 #ifdef CLEARCOAT\n float coatDotNL = saturate(dot(geometry.clearcoatNormal, 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_Blender_Approx(geometry,\n material.specularColor, material.fresnelRefl90, 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 #elif defined(MT_MAYA)\n vec3 specEnv = BRDF_Specular_GGX_Environment(geometry, material.specularColor, material.specularRoughness, 0);\n #else\n vec3 specEnv = vec3(1.0);\n #endif\n reflectedLight.indirectSpecular += (1.0 - clearcoatDHR) * radiance * specEnv;\n #ifdef CLEARCOAT\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(MT_BLENDER) && 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(abs(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",ssr_pars_fragment:"#ifdef USE_SSR\nuniform sampler2D ssrSourceBuffer;\nuniform sampler2D ssrDepthBuffer;\nuniform sampler2D ssrBackfaceDepthBuffer;\nuniform mat4 invProjectionMatrix;\nuniform vec2 ssrResolution;\nuniform float ssrThickness;\nuniform float ssrStride;\nuniform float ssrJitter;\nuniform float ssrMaxDistance;\n#ifdef USE_SSR_REFRACT\n#define STEPS_FADE_AMOUNT 0.1\n#define SCREEN_FADE_THRESHOLD 0.6\n#else\n#define STEPS_FADE_AMOUNT 1.0\n#define SCREEN_FADE_THRESHOLD 0.4\n#endif\nvec3 deproject(vec3 p) {\n vec4 res = invProjectionMatrix * vec4(p, 1);\n return res.xyz / res.w;\n}\nbool doesIntersect(float rayzmax, float rayzmin, vec2 uv) {\n float sceneZMin = texture2D(ssrDepthBuffer, uv).r;\n #ifdef USE_SSR_REFRACT\n return rayzmin >= (sceneZMin-ssrThickness) && rayzmax <= sceneZMin;\n #else\n float sceneZMax = texture2D(ssrBackfaceDepthBuffer, uv).r;\n return rayzmin >= sceneZMax && rayzmax <= sceneZMin;\n #endif\n}\nfloat distanceSquared(vec2 a, vec2 b) { a -= b; return dot(a, a); }\nvoid swapIfBigger(inout float a, inout float b) {\n if (a > b) {\n float t = a;\n a = b;\n b = t;\n }\n}\nbool isOutsideUvBounds(float x) { return x < 0.0 || x > 1.0; }\nbool isOutsideUvBounds(vec2 uv) { return isOutsideUvBounds(uv.x) || isOutsideUvBounds(uv.y); }\nvec3 computeSSR(vec3 color, vec3 normal, float ior) {\n vec2 uv = gl_FragCoord.xy / ssrResolution;\n vec2 screenCoord = uv * 2.0 - vec2(1, 1);\n float nearClip = deproject(vec3(0, 0, -1)).z;\n vec3 ray = deproject(vec3(screenCoord, -1));\n ray /= ray.z;\n float depthSample = -vViewPosition.z;\n vec3 vpos = depthSample * ray;\n #ifdef USE_SSR_REFRACT\n vec3 dir = normalize(refract(normalize(vpos), normalize(normal), 1.0/ior));\n #else\n vec3 dir = normalize(reflect(normalize(vpos), normalize(normal)));\n #endif\n float maxDist = ssrMaxDistance;\n float rayLength = (vpos.z + dir.z * maxDist) > nearClip ? (nearClip - vpos.z) / dir.z : maxDist;\n vec3 csOrig = vpos;\n vec3 csEndPoint = csOrig + dir * rayLength;\n vec4 H0 = projectionMatrix * vec4(csOrig, 1.0);\n vec4 H1 = projectionMatrix * vec4(csEndPoint, 1.0);\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n vec3 Q0 = csOrig.xyz * k0, Q1 = csEndPoint.xyz * k1;\n vec2 P0 = H0.xy * k0, P1 = H1.xy * k1;\n P0 = P0 * 0.5 + vec2(0.5), P1 = P1 * 0.5 + vec2(0.5);\n #ifndef SSR_SIMPLE_REFRACT\n P0 *= ssrResolution, P1 *= ssrResolution;\n P1 += vec2((distanceSquared(P0, P1) < 0.0001) ? 0.01 : 0.0);\n vec2 delta = P1 - P0;\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true; delta = delta.yx; P0 = P0.yx; P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n vec2 dP = vec2(stepDir, delta.y * invdx);\n float pixelStride = ssrStride;\n float jitterMod = (gl_FragCoord.x + gl_FragCoord.y) * 0.25;\n vec4 PQK = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n dPQK *= pixelStride;\n PQK += dPQK * mod(jitterMod, 1.0) * ssrJitter;\n float end = P1.x * stepDir;\n float prevZMaxEstimate = PQK.z / PQK.w;\n float rayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;\n float stepped = 0.0;\n vec2 hitUV;\n bool intersected = false;\n for (float stepCount = 1.0; stepCount <= float(MAX_STEPS); stepCount ++) {\n PQK += dPQK;\n rayZMin = prevZMaxEstimate;\n rayZMax = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);\n prevZMaxEstimate = rayZMax;\n swapIfBigger(rayZMax, rayZMin);\n \n stepped = stepCount;\n hitUV = (permute ? PQK.yx: PQK.xy) / ssrResolution;\n if (isOutsideUvBounds(hitUV)) break;\n intersected = doesIntersect(rayZMax, rayZMin, hitUV);\n if (intersected || (P0.x * stepDir) > end) break;\n }\n if (intersected && pixelStride > 1.0) {\n PQK -= dPQK;\n dPQK /= ssrStride;\n float ogStride = pixelStride * 0.5;\n float currStride = pixelStride;\n prevZMaxEstimate = PQK.z / PQK.w;\n rayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;\n for(int j = 0; j < int(BINARY_SEARCH_ITERATIONS); j ++) {\n PQK += dPQK * currStride;\n rayZMin = prevZMaxEstimate;\n rayZMax = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);\n prevZMaxEstimate = rayZMax;\n swapIfBigger(rayZMax, rayZMin);\n vec2 newUV = (permute ? PQK.yx: PQK.xy) / ssrResolution;\n ogStride *= 0.5;\n if (doesIntersect(rayZMax, rayZMin, newUV)) {\n hitUV = newUV;\n currStride = -ogStride;\n } else {\n currStride = ogStride;\n }\n }\n }\n vec3 result = color;\n #ifdef USE_SSR_REFRACT\n #endif\n if (intersected) {\n vec4 col = texture2D(ssrSourceBuffer, hitUV);\n vec2 ndc = abs(hitUV * 2.0 - 1.0);\n float maxndc = max(ndc.x, ndc.y);\n float fadeVal =\n (1.0 - (max(0.0, maxndc - SCREEN_FADE_THRESHOLD) / (1.0 - SCREEN_FADE_THRESHOLD))) *\n (1.0 - STEPS_FADE_AMOUNT * (stepped / float(MAX_STEPS)));\n col.a = fadeVal;\n result = mix(result, col.rgb, col.a);\n }\n #else\n vec3 result = texture2D(ssrSourceBuffer, P1).xyz;\n #endif\n return result;\n}\n#endif",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) || defined(NODE_AI_SKYDOME_LIGHT_MY)\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 #ifdef MT_MAYA\n sampleUV.x = atan(reflectVec.z, reflectVec.x) * RECIPROCAL_PI2 + 0.25;\n #else\n sampleUV.x = atan(reflectVec.x, reflectVec.z) * RECIPROCAL_PI2 + 0.5;\n #endif\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) || defined(NODE_GRADIENT_RAMP_MAX)\n#define MAPPING_EXPLICIT_MAP_CHANNEL 1\n#define MAPPING_VERTEX_COLOR_CHANNEL 2\n#define MAPPING_PLANAR_OBJECT_XYZ 3\n#define MAPPING_PLANAR_WORLD_XYZ 4\n#define AXIS_XY 1\n#define AXIS_YZ 2\n#define AXIS_ZX 3\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 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 __VERSION__ == 300\n if (i <= octavesInt) {\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 } else {\n i = MAX_OCTAVES_NUM;\n }\n #else\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 #endif\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_material_gf_frag:"void node_material_gf(\n vec3 normal, vec3 geometryNormal, vec4 tangent,\n vec4 baseColorFactor, vec4 baseColorTexture,\n float metallicFactor, float roughnessFactor, vec3 metallicRoughnessTexture,\n float normalmapScale, vec3 normalmapTexture, \n float occlusionStrength, float directLightOcclusionFactor, vec3 occlusionTexture,\n vec3 emissiveFactor, vec3 emissiveTexture, \n out vec4 outgoingLight) {\n NodeMaterial material;\n float metalness = metallicFactor * metallicRoughnessTexture.b;\n vec3 baseColor = baseColorTexture.rgb * baseColorFactor.rgb;\n material.diffuseColor = baseColor * (1.0 - metalness);\n vec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\n float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\n float roughness = roughnessFactor * metallicRoughnessTexture.g;\n material.specularRoughness = max(roughness, 0.0525);\n material.specularRoughness += geometryRoughness;\n material.specularRoughness = min(material.specularRoughness, 1.0);\n material.specularColor = mix(vec3(DEFAULT_SPECULAR_COEFFICIENT), baseColor, metalness);\n if (normalmapScale > 0.0) {\n vec3 normalTex = normalmapTexture * 2.0 - 1.0;\n #ifdef MT_BLENDER\n normalTex.y = -normalTex.y;\n #endif\n vec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\n vec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\n \n normal = mix(normal, normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n + normalTex.z * normal), normalmapScale);\n }\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #include \n #include \n #include \n float ambientOcclusion = occlusionStrength * occlusionTexture.r;\n if (ambientOcclusion < 1.0) {\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n float dotNV = saturate(dot(geometry.normal, geometry.viewDir));\n float specularOcclusion = computeSpecularOcclusion(dotNV, ambientOcclusion, material.specularRoughness);\n reflectedLight.indirectSpecular *= specularOcclusion;\n reflectedLight.directDiffuse *= (1.0 + (ambientOcclusion - 1.0) * directLightOcclusionFactor);\n reflectedLight.directSpecular *= (1.0 + (specularOcclusion - 1.0) * directLightOcclusionFactor);\n }\n vec3 totalEmissiveRadiance = emissiveFactor * emissiveTexture;\n vec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\n + reflectedLight.directSpecular + reflectedLight.indirectSpecular\n + totalEmissiveRadiance;\n float alpha = baseColorFactor.a * baseColorTexture.a;\n outgoingLight = vec4(outColor3, alpha);\n}",node_texture_gf_frag:"void node_texture_gf(sampler2D map, vec2 uv, const mat3 uvTransform,\n const int encoding, out vec3 color)\n{\n uv = (uvTransform * vec3(uv, 1.0)).xy;\n color = texture2D(map, uv).rgb;\n color = nodeTexelToLinear(vec4(color, 0.0), encoding).rgb;\n}\nvoid node_texture_gf(sampler2D map, vec2 uv, const mat3 uvTransform,\n const int encoding, out vec4 color)\n{\n uv = (uvTransform * vec3(uv, 1.0)).xy;\n color = texture2D(map, uv);\n color = nodeTexelToLinear(color, encoding);\n}",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, float distance, vec3 normal,\n out vec4 outColor, out float outAO) {\n outColor = color;\n outAO = 1.0;\n}\nvoid 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_bevel_frag:"void node_bevel(float radius, vec3 normal, out vec3 outNormal) {\n outNormal = normal;\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 geometryNormal,\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 #include \n #include \n #include \n outColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, 1.0);\n}",node_bsdf_glass_frag:"void node_bsdf_glass(\n vec3 geometryNormal,\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 = vec3(1.0);\n material.fresnelRefl90 = vec3(1.0);\n material.specularRoughness = clamp(roughness, 0.0, 1.0);\n material.refractionColor = vec3(1.0);\n material.refractionIOR = ior;\n material.refractionRoughness = pow2(roughness);\n #ifdef ENVMAP_TYPE_CUBE_UV\n float geomRoughness = calcGeometryRoughness(geometryNormal);\n material.specularRoughness = calcCubeUVAdjustedRoughness(\n material.specularRoughness, geomRoughness);\n material.refractionRoughness = calcCubeUVAdjustedRoughness(\n material.refractionRoughness, geomRoughness);\n #endif\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0),\n vec3(0.0), vec3(0.0));\n #define USE_REFRACTED_LIGHT\n vec3 refractedLight = vec3(0.0);\n #include \n #include \n #include \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(color.rgb * mix(refractedLight, reflectedLight.directSpecular\n + reflectedLight.indirectSpecular, fresnel), 1.0);\n}",node_bsdf_glossy_frag:"\nvoid node_bsdf_glossy(\n vec3 geometryNormal,\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.fresnelRefl90 = vec3(1.0);\n material.specularRoughness = clamp(roughness, 0.0, 1.0);\n #ifdef ENVMAP_TYPE_CUBE_UV\n float geomRoughness = calcGeometryRoughness(geometryNormal);\n material.specularRoughness = calcCubeUVAdjustedRoughness(\n material.specularRoughness, geomRoughness);\n #endif\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #include \n #include \n #include \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}\nvoid node_bsdf_principled(\n vec3 geometryNormal,\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, vec4 emission, float alpha,\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 #ifndef CLEARCOAT\n float dielReflCoeff = BLENDER_SPECULAR_COEFFICIENT;\n #else\n float dielReflCoeff = MAXIMUM_SPECULAR_COEFFICIENT;\n material.clearcoat = saturate(clearcoat);\n material.clearcoatRoughness = clamp(clearcoatRoughness, 0.0, 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.0, 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 float isStrictDielectric = step(0.0, -length(vec4(subsurface, clearcoat,\n transmission, float(metallic == 1.0))));\n material.fresnelRefl90 = mix(vec3(1.0), material.specularColor,\n (1.0 - specular) * metallic * (1.0 - isStrictDielectric));\n material.refractionColor = baseColor.rgb;\n material.refractionIOR = ior;\n material.refractionRoughness = pow2(roughness);\n #ifdef ENVMAP_TYPE_CUBE_UV\n float geomRoughness = calcGeometryRoughness(geometryNormal);\n material.specularRoughness = calcCubeUVAdjustedRoughness(\n material.specularRoughness, geomRoughness);\n material.refractionRoughness = calcCubeUVAdjustedRoughness(\n material.refractionRoughness, geomRoughness);\n #ifdef CLEARCOAT\n material.clearcoatRoughness = calcCubeUVAdjustedRoughness(\n material.clearcoatRoughness, geomRoughness);\n #endif\n #endif\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #define USE_REFRACTED_LIGHT\n vec3 refractedLight = vec3(0.0);\n #include \n #include \n #include \n #undef USE_REFRACTED_LIGHT\n vec3 outColor3 = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * (1.0 - transmission)\n + reflectedLight.directSpecular + reflectedLight.indirectSpecular\n + refractedLight * transmission * (1.0 - fresnel)\n + emission.rgb;\n outColor = vec4(outColor3, alpha);\n}\nvoid node_bsdf_principled(\n vec3 geometryNormal,\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 node_bsdf_principled(geometryNormal, baseColor, subsurface, subsurfaceRadius,\n subsurfaceColor, metallic, specular, specularTint, roughness,\n anisotropic, anisotropicRotation, sheen, sheenTint, clearcoat,\n clearcoatRoughness, ior, transmission, transmissionRoughness,\n vec4(0.0, 0.0, 0.0, 1.0), 1.0, normal, clearcoatNormal, tangent,\n outColor);\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 geometryNormal, 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 #ifdef ENVMAP_TYPE_CUBE_UV\n float geomRoughness = calcGeometryRoughness(geometryNormal);\n material.refractionRoughness = calcCubeUVAdjustedRoughness(\n material.refractionRoughness, geomRoughness);\n #endif\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #define USE_REFRACTED_LIGHT\n vec3 refractedLight = vec3(0.0);\n #include \n #include \n #include \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, float height_dx,\n float height_dy, vec3 normal,\n out vec3 outNormal) {\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}\nvoid node_bump(\n const int invert,\n float strength, float bumpDist, float height, vec3 normal,\n out vec3 outNormal) {\n node_bump(invert, strength, bumpDist, height, 0.0, 0.0, normal, outNormal);\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_clamp_frag:"void node_clamp(float value, float minVal, float maxVal, out float result) {\n result = clamp(value, minVal, maxVal);\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_displacement_frag:"void node_displacement(float height, float midlevel, float scale, vec3 normal, out vec3 outDisplacement) {\n outDisplacement = vec3(0.0);\n}",node_eevee_specular_frag:"void node_eevee_specular(\n vec4 baseColor, vec4 specular, float roughness, vec4 emissiveColor,\n float transparency, vec3 normal, float clearcoat, float clearcoatRoughness, \n vec3 clearcoatNormal, float ambientOcclusion,\n out vec4 outColor) {\n outColor = baseColor;\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_hair_info_frag:"void node_hair_info(out float isStrand, out float intercept, out float thickness,\n out vec3 tangentNormal, out float random) {\n isStrand = 0.0;\n intercept = 0.0;\n thickness = 0.0;\n tangentNormal = vec3(0.0);\n random = 0.0;\n}\nvoid 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 inSmooth,\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}\nmat3 rotationMatrix(float angleX, float angleY, float angleZ) {\n float cx = cos(angleX);\n float sx = sin(angleX);\n float cy = cos(angleY);\n float sy = sin(angleY);\n float cz = cos(angleZ);\n float sz = sin(angleZ);\n \n mat3 mat;\n mat[0][0] = cy * cz;\n mat[0][1] = cy * sz;\n mat[0][2] = -sy;\n \n mat[1][0] = sy * sx * cz - cx * sz;\n mat[1][1] = sy * sx * sz + cx * cz;\n mat[1][2] = cy * sx;\n \n mat[2][0] = sy * cx * cz + sx * sz;\n mat[2][1] = sy * cx * sz - sx * cz;\n mat[2][2] = cy * cx;\n \n return mat;\n}\n#define NODE_MAPPING_POINT 1\n#define NODE_MAPPING_TEXTURE 2\n#define NODE_MAPPING_VECTOR 3\n#define NODE_MAPPING_NORMAL 4\nvoid node_mapping(int type, vec3 vec, vec3 loc, vec3 rot, vec3 scale, out vec3 outVec)\n{\n if (type == NODE_MAPPING_POINT)\n outVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale) + loc;\n else if (type == NODE_MAPPING_TEXTURE)\n outVec = transposeMat3(rotationMatrix(rot.x, rot.y, rot.z)) * (vec - loc) / scale;\n else if (type == NODE_MAPPING_VECTOR)\n outVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale);\n else\n outVec = normalize(rotationMatrix(rot.x, rot.y, rot.z) * vec / scale);\n}",node_map_range_frag:"#define NODE_MAP_RANGE_INTERP_LINEAR 0\n#define NODE_MAP_RANGE_INTERP_STEPPED_LINEAR 1\n#define NODE_MAP_RANGE_INTERP_SMOOTHSTEP 2\n#define NODE_MAP_RANGE_INTERP_SMOOTHERSTEP 3\nvoid node_map_range(const int interpolation, int inClamp, float value, float fromMin, float fromMax,\n float toMin, float toMax, float steps, out float result) {\n if (fromMax == fromMin) {\n result = 0.0;\n } else {\n result = (value - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin;\n }\n if (inClamp == 1) {\n result = clamp(result, toMin, toMax);\n }\n}\nvoid node_map_range(const int interpolation, int inClamp, float value,\n float fromMin, float fromMax, float toMin, float toMax, out float result) {\n node_map_range(NODE_MAP_RANGE_INTERP_LINEAR, inClamp, value, fromMin,\n fromMax, toMin, toMax, 0.0, result);\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, float val3, out float outVal)\n{\n outVal = val1 + val2;\n}\nvoid node_math_subtract(float val1, float val2, float val3, out float outVal)\n{\n outVal = val1 - val2;\n}\nvoid node_math_multiply(float val1, float val2, float val3, out float outVal)\n{\n outVal = val1 * val2;\n}\nvoid node_math_divide(float val1, float val2, float val3, 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, float val3, out float outVal)\n{\n outVal = sin(val);\n}\nvoid node_math_cosine(float val, float val2, float val3, out float outVal)\n{\n outVal = cos(val);\n}\nvoid node_math_tangent(float val, float val2, float val3, out float outVal)\n{\n outVal = tan(val);\n}\nvoid node_math_arcsine(float val, float val2, float val3, 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, float val3, 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, float val3, out float outVal)\n{\n outVal = atan(val);\n}\nvoid node_math_arctan2(float val, float val2, float val3, out float outVal)\n{\n outVal = atan(val, val2);\n}\nvoid node_math_power(float val1, float val2, float val3, 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, float val3, 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, float val3, out float outVal)\n{\n outVal = sqrt(val1);\n}\nvoid node_math_maximum(float val1, float val2, float val3, out float outVal)\n{\n outVal = max(val1, val2);\n}\nvoid node_math_minimum(float val1, float val2, float val3, out float outVal)\n{\n outVal = min(val1, val2);\n}\nvoid node_math_round(float val1, float val2, float val3, out float outVal)\n{\n outVal = floor(val1 + 0.5);\n}\nvoid node_math_floor(float val1, float val2, float val3, out float outVal)\n{\n outVal = floor(val1);\n}\nvoid node_math_ceil(float val1, float val2, float val3, out float outVal)\n{\n outVal = ceil(val1);\n}\nvoid node_math_fract(float val1, float val2, float val3, out float outVal)\n{\n outVal = fract(val1);\n}\nvoid node_math_less_than(float val1, float val2, float val3, 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, float val3, 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, float val3, 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, float val3, out float outVal)\n{\n outVal = abs(val1);\n}\nvoid node_math_compare(float val1, float val2, float val3, out float outVal) {\n outVal = step(abs(val1 - val2), val3);\n}\nvoid node_math_cosh(float val1, float val2, float val3, out float outVal) {\n outVal = cosh(val1);\n}\nvoid node_math_degrees(float val1, float val2, float val3, out float outVal) {\n outVal = val1 / PI * 180.0;\n}\nvoid node_math_exponent(float val1, float val2, float val3, out float outVal) {\n outVal = exp(val1);\n}\nvoid node_math_inverse_sqrt(float val1, float val2, float val3, out float outVal) {\n if (val1 >= 0.0) {\n outVal = 1.0 / sqrt(val1);\n } else {\n outVal = 0.0;\n }\n}\nvoid node_math_multiply_add(float val1, float val2, float val3, out float outVal) {\n outVal = val1 * val2 + val3;\n}\nvoid node_math_pingpong(float val1, float val2, float val3, out float outVal) {\n if (val2 == 0.0) {\n outVal = 0.0;\n } else {\n float absVal2 = abs(val2);\n float rem = mod(val1, absVal2);\n outVal = mix(rem, absVal2 - rem, mod(floor(val1 / absVal2), 2.0));\n }\n}\nvoid node_math_radians(float val1, float val2, float val3, out float outVal) {\n outVal = val1 / 180.0 * PI;\n}\nvoid node_math_sign(float val1, float val2, float val3, out float outVal) {\n outVal = sign(val1);\n}\nvoid node_math_sinh(float val1, float val2, float val3, out float outVal) {\n outVal = sinh(val1);\n}\nvoid node_math_smooth_max(float val1, float val2, float val3, out float outVal) {\n outVal = smoothMax(val1, val2, val3);\n}\nvoid node_math_smooth_min(float val1, float val2, float val3, out float outVal) {\n outVal = smoothMin(val1, val2, val3);\n}\nvoid node_math_snap(float val1, float val2, float val3, out float outVal) {\n val1 += 1e-5 * sign(val2);\n float quot = val1 / val2;\n outVal = floor(quot) * val2;\n}\nvoid node_math_tanh(float val1, float val2, float val3, out float outVal) {\n outVal = tanh(val1);\n}\nvoid node_math_trunc(float val1, float val2, float val3, out float outVal) {\n val1 += 1e-5;\n outVal = trunc(val1);\n}\nvoid node_math_wrap(float val1, float val2, float val3, out float outVal) {\n val1 += 1e-5;\n outVal = mod(val1 - val3, val2 - val3) + val3;\n}\nvoid node_math_add(float val1, float val2, out float outVal) {\n node_math_add(val1, val2, 0.0, outVal);\n}\nvoid node_math_subtract(float val1, float val2, out float outVal) {\n node_math_subtract(val1, val2, 0.0, outVal);\n}\nvoid node_math_multiply(float val1, float val2, out float outVal) {\n node_math_multiply(val1, val2, 0.0, outVal);\n}\nvoid node_math_divide(float val1, float val2, out float outVal) {\n node_math_divide(val1, val2, 0.0, outVal);\n}\nvoid node_math_sine(float val1, float val2, out float outVal) {\n node_math_sine(val1, val2, 0.0, outVal);\n}\nvoid node_math_cosine(float val1, float val2, out float outVal) {\n node_math_cosine(val1, val2, 0.0, outVal);\n}\nvoid node_math_tangent(float val1, float val2, out float outVal) {\n node_math_tangent(val1, val2, 0.0, outVal);\n}\nvoid node_math_arcsine(float val1, float val2, out float outVal) {\n node_math_arcsine(val1, val2, 0.0, outVal);\n}\nvoid node_math_arccosine(float val1, float val2, out float outVal) {\n node_math_arccosine(val1, val2, 0.0, outVal);\n}\nvoid node_math_arctangent(float val1, float val2, out float outVal) {\n node_math_arctangent(val1, val2, 0.0, outVal);\n}\nvoid node_math_arctan2(float val1, float val2, out float outVal) {\n node_math_arctan2(val1, val2, 0.0, outVal);\n}\nvoid node_math_power(float val1, float val2, out float outVal) {\n node_math_power(val1, val2, 0.0, outVal);\n}\nvoid node_math_logarithm(float val1, float val2, out float outVal) {\n node_math_logarithm(val1, val2, 0.0, outVal);\n}\nvoid node_math_sqrt(float val1, float val2, out float outVal) {\n node_math_sqrt(val1, val2, 0.0, outVal);\n}\nvoid node_math_maximum(float val1, float val2, out float outVal) {\n node_math_maximum(val1, val2, 0.0, outVal);\n}\nvoid node_math_minimum(float val1, float val2, out float outVal) {\n node_math_minimum(val1, val2, 0.0, outVal);\n}\nvoid node_math_round(float val1, float val2, out float outVal) {\n node_math_round(val1, val2, 0.0, outVal);\n}\nvoid node_math_floor(float val1, float val2, out float outVal) {\n node_math_floor(val1, val2, 0.0, outVal);\n}\nvoid node_math_ceil(float val1, float val2, out float outVal) {\n node_math_ceil(val1, val2, 0.0, outVal);\n}\nvoid node_math_fract(float val1, float val2, out float outVal) {\n node_math_fract(val1, val2, 0.0, outVal);\n}\nvoid node_math_less_than(float val1, float val2, out float outVal) {\n node_math_less_than(val1, val2, 0.0, outVal);\n}\nvoid node_math_greater_than(float val1, float val2, out float outVal) {\n node_math_greater_than(val1, val2, 0.0, outVal);\n}\nvoid node_math_modulo(float val1, float val2, out float outVal) {\n node_math_modulo(val1, val2, 0.0, outVal);\n}\nvoid node_math_absolute(float val1, float val2, out float outVal) {\n node_math_absolute(val1, val2, 0.0, outVal);\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 outColor = mix(color1, color2, fac);\n}",node_new_geometry_frag:"void node_new_geometry(\n bool frontFacing, 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, out float randomPerIsland)\n{\n vec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\n position = swizzleUpZ(posWorld.xyz);\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 tangent = vec3(0.0);\n #else\n vec3 norWorld = normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz;\n normal = swizzleUpZ(norWorld);\n vec4 posLocal = invModelMatrix * posWorld;\n vec3 posLocalDelta = posLocal.xyz - boundingBoxMin;\n vec3 bbDelta = boundingBoxMax - boundingBoxMin;\n vec3 posOrco = vec3(\n bbDelta.x < 1e-5 ? -sign(posLocal.y) : posLocalDelta.x / bbDelta.x,\n 0.0,\n bbDelta.z < 1e-5 ? sign(posLocal.y) : posLocalDelta.z / bbDelta.z\n );\n posOrco -= 0.5;\n vec3 tangWorld = (modelMatrix * vec4(posOrco.z, 0.0, -posOrco.x, 0.0)).xyz;\n tangWorld = cross(norWorld, normalize(cross(tangWorld, norWorld)));\n tangent = swizzleUpZ(tangWorld);\n #endif\n trueNormal = normal;\n incoming = incomingVec;\n parametric = vec3(0.0);\n backfacing = (frontFacing) ? 0.0 : 1.0;\n #if WORLD_NODES == 1\n pointiness = 0.0;\n #else\n pointiness = 0.5;\n #endif\n randomPerIsland = 0.0;\n}\nvoid node_new_geometry(\n bool frontFacing, 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 float randomPerIsland;\n node_new_geometry(frontFacing, viewPos, viewNorm, position, normal, tangent,\n trueNormal, incoming, parametric, backfacing, pointiness, randomPerIsland);\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 vec4 color, out float objIndex,\n out float matIndex, out float random) {\n #if WORLD_NODES == 1\n location = vec3(0.0);\n color = vec4(1.0);\n objIndex = 0.0;\n matIndex = 0.0;\n random = 0.0;\n #else\n location = vec3(0.0);\n color = vec4(1.0);\n objIndex = 0.0;\n matIndex = 0.0;\n random = 0.5;\n #endif\n}\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 random, out float age,\n out float lifeTime, out vec3 location, out float size, out vec3 velocity,\n out vec3 angularVelocity) {\n #if WORLD_NODES == 1\n index = 0.0;\n random = 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 random = 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}\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_principled_volume_frag:"void node_principled_volume(vec4 color, float colorAttribute, float density,\n float densityAttribute, float anisotropy, vec4 absorptionColor,\n float emissionStrength, vec4 emissionColor, float blackbodyIntensity,\n vec4 blackbodyTint, float temperature, float temperatureAttribute,\n out vec4 volume) {\n volume = vec4(0.0);\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_shadertorgb_frag:"void node_shadertorgb(vec4 shader, out vec4 color, out float alpha) {\n color = vec4(shader.rgb, 1.0);\n alpha = shader.a;\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 mat4 nodeTexCoordObjectMatrices[NODE_TEX_COORD_NUM];\nvoid node_tex_coord(\n mat4 objectMat, 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 vec4 posWorld = invViewMatrix * view;\n vec3 loc = swizzleUpZ((invModelMatrix * posWorld).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 #if WORLD_NODES == 1\n outObject = loc;\n #else\n outObject = swizzleUpZ((objectMat * posWorld).xyz);\n #endif\n outCamera = vec3(view.xy, -view.z);\n #if WORLD_NODES == 1\n outWindow = vec3(0.0);\n #else\n outWindow = vec3(gl_FragCoord.xy / viewWidthHeight, 0.0);\n #endif\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:"#define TEX_PROJ_EQUIRECTANGULAR 0\n#define TEX_PROJ_MIRROR_BALL 1\nvoid node_tex_environment(sampler2D tex, const int encoding, const int projection, vec3 vector, out vec4 outColor) {\n vec2 uv;\n float bias;\n if (projection == TEX_PROJ_EQUIRECTANGULAR) {\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 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 #if WORLD_NODES == 1\n bias = -16.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 bias = seamBiasFactor * seam;\n #endif\n } else {\n vec3 normal = normalize(vector);\n normal.y -= 1.0;\n normal /= (2.0 * sqrt(max(-0.5 * normal.y, 0.0)));\n uv = clamp(0.5 * normal.xz + 0.5, 0.0, 1.0);\n bias = 0.0;\n }\n uv.y = 1.0 - uv.y;\n outColor = texture2D(tex, uv, bias);\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_ies_frag:"void node_tex_ies(vec3 vector, float strength, out float fac) {\n fac = 0.0;\n}",node_tex_image_frag:"#define TEX_PROJ_FLAT 0\n#define TEX_PROJ_BOX 1\n#define TEX_PROJ_SPHERE 2\n#define TEX_PROJ_TUBE 3\nvoid node_tex_image(sampler2D ima, const int encoding, vec3 viewNorm,\n const int projection, const float projectionBlend, const bool clampToEdgeNoExtend,\n vec3 vector,\n out vec4 outColor, out float outAlpha) {\n if (projection == TEX_PROJ_FLAT) {\n vec2 uv = vector.xy;\n uv.y = 1.0 - uv.y;\n if (clampToEdgeNoExtend && (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)) {\n outColor = vec4(0.0);\n outAlpha = 0.0;\n } else {\n outColor = texture2D(ima, uv);\n outAlpha = outColor.a;\n }\n outColor = nodeTexelToLinear(outColor, encoding);\n } else if (projection == TEX_PROJ_BOX) {\n vec3 norm = normalize(viewNorm * normalMatrix);\n vector = swizzleUpY(vector);\n vec2 uvX = vec2(-sign(norm.x) * vector.z, -vector.y);\n vec2 uvY = vec2(sign(norm.y) * vector.z, -vector.x);\n vec2 uvZ = vec2(sign(norm.z) * vector.x, -vector.y);\n vec4 colX = nodeTexelToLinear(texture2D(ima, uvX), encoding);\n vec4 colY = nodeTexelToLinear(texture2D(ima, uvY), encoding);\n vec4 colZ = nodeTexelToLinear(texture2D(ima, uvZ), encoding);\n vec3 barycentric = abs(norm);\n barycentric /= barycentric.x + barycentric.y + barycentric.z;\n vec3 edgeShape = min(min(barycentric.yzx, barycentric.zxy),\n (projectionBlend - 1.0) / (projectionBlend - 3.0));\n vec3 edgeValue = (1.0 - projectionBlend) * (1.0 - edgeShape) / 2.0;\n vec3 weight = max((barycentric - edgeValue) / (1.0 - edgeValue), 0.0);\n weight /= (weight.x + weight.y + weight.z);\n outColor = weight.x * colX + weight.y * colY + weight.z * colZ;\n outAlpha = outColor.a;\n } else if (projection == TEX_PROJ_SPHERE) {\n vector = normalize(vector * 2.0 - 1.0);\n vector = swizzleUpY(vector);\n vec2 uv = vec2(atan(vector.x, vector.z) / PI2, acos(vector.y) / PI);\n uv.x = mod(uv.x, 1.0);\n outColor = texture2D(ima, uv);\n outAlpha = outColor.a;\n outColor = nodeTexelToLinear(outColor, encoding);\n } else if (projection == TEX_PROJ_TUBE) {\n vector = vector * 2.0 - 1.0;\n vector = swizzleUpY(vector);\n vec2 uv = vec2(atan(vector.x, vector.z) / PI2, (1.0 - vector.y) / 2.0);\n uv.x = mod(uv.x, 1.0);\n outColor = texture2D(ima, uv);\n outAlpha = outColor.a;\n outColor = nodeTexelToLinear(outColor, encoding);\n }\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(vec3 vector, float w, float scale, float detail,\n float dimension, float lacunarity, float offset, float gain,\n out float outFac) {\n outFac = 0.0;\n}\nvoid 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 w, float scale, float detail, float distortion,\n out float outFac, out vec4 outColor) {\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}\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 node_tex_noise(falloffFactor, dispersionFactor, vector, 0.0, scale, detail, distortion, outFac, outColor);\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:"#define DISTANCE_EUCLIDEAN 0\n#define DISTANCE_MANHATTAN 1\n#define DISTANCE_CHEBYCHEV 2\n#define DISTANCE_MINKOWSKI 3\n#define FEATURE_F1 0\n#define FEATURE_F2 1\n#define FEATURE_SMOOTH_F1 2\n#define FEATURE_DISTANCE_TO_EDGE 3\n#define FEATURE_N_SPHERE_RADIUS 4\nstruct VoronoiGridData {\n vec3 point;\n vec3 randVec;\n vec3 toClosest;\n float dist;\n};\nfloat worleyLength(vec3 vec, int distance, float exponent) {\n if (distance == DISTANCE_EUCLIDEAN) {\n return length(vec);\n } else if (distance == DISTANCE_MANHATTAN) {\n return abs(vec.x) + abs(vec.y) + abs(vec.z);\n } else if (distance == DISTANCE_CHEBYCHEV) {\n return max(max(abs(vec.x), abs(vec.y)), abs(vec.z));\n } else if (distance == DISTANCE_MINKOWSKI) {\n return pow(pow(abs(vec.x), exponent)\n + pow(abs(vec.y), exponent)\n + pow(abs(vec.z), exponent), 1.0 / exponent);\n }\n return 0.0;\n}\nvoid worleyNoise(vec3 pos, int distance, float exponent, int feature,\n float smoothness, float randomness, out float outDist, out vec4 outColor,\n out vec3 outPosition, out float outW, out float outRadius) {\n const highp float RAND_FIX_ZERO = 0.125;\n vec3 posI = floor(pos);\n vec3 posF = fract(pos);\n VoronoiGridData vgd[27];\n #pragma unroll_loop\n for (int i = 0; i <= 2; i++) {\n #pragma unroll_loop\n for (int j = 0; j <= 2; j++) {\n #pragma unroll_loop\n for (int k = 0; k <= 2; k++) {\n vec3 point = vec3((i), (j), (k)) - 1.0;\n vec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\n vec3 toClosest = point + randomness * randVec - posF;\n const int counter = (i) + (j) * 3 + (k) * 9;\n vgd[counter].point = point;\n vgd[counter].randVec = randVec;\n vgd[counter].toClosest = toClosest;\n vgd[counter].dist = worleyLength(toClosest, distance, exponent);\n }\n }\n }\n float f1 = 1e10;\n float f2 = 1e10;\n vec3 edgeToClosest = vec3(0.0);\n float distToEdge = 1e10;\n vec3 randColF1 = vec3(0.0);\n vec3 randColF2 = vec3(0.0);\n vec3 toClosestF1 = vec3(0.0);\n vec3 toClosestF2 = vec3(0.0);\n vec3 radPoint = vec3(0.0);\n vec3 radToClosest = vec3(0.0);\n #pragma unroll_loop\n for (int i = 0; i < 27; i++) {\n if (feature == FEATURE_F1) {\n if (vgd[i].dist < f1) {\n f1 = vgd[i].dist;\n randColF1 = vgd[i].randVec;\n toClosestF1 = vgd[i].toClosest;\n }\n } else if (feature == FEATURE_F2) {\n if (vgd[i].dist < f1) {\n f2 = f1;\n f1 = vgd[i].dist;\n randColF2 = randColF1;\n randColF1 = vgd[i].randVec;\n toClosestF2 = toClosestF1;\n toClosestF1 = vgd[i].toClosest;\n } else if (vgd[i].dist < f2) {\n f2 = vgd[i].dist;\n randColF2 = vgd[i].randVec;\n toClosestF2 = vgd[i].toClosest;\n }\n } else if (feature == FEATURE_SMOOTH_F1) {\n f1 = smoothMin(f1, vgd[i].dist, smoothness);\n } else if (feature == FEATURE_DISTANCE_TO_EDGE) {\n float dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\n if (dist < f1) {\n f1 = dist;\n edgeToClosest = vgd[i].toClosest;\n }\n } else if (feature == FEATURE_N_SPHERE_RADIUS) {\n float dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\n if (dist < f1) {\n f1 = dist;\n radPoint = vgd[i].point;\n radToClosest = vgd[i].toClosest;\n }\n }\n }\n if (feature == FEATURE_F1) {\n outDist = f1;\n outColor = vec4(randColF1, 1.0);\n outPosition = pos + toClosestF1;\n } else if (feature == FEATURE_F2) {\n outDist = f2;\n outColor = vec4(randColF2, 1.0);\n outPosition = pos + toClosestF2;\n } else if (feature == FEATURE_SMOOTH_F1) {\n outDist = f1;\n vec3 avgCol = vec3(0.0);\n vec3 avgOff = vec3(0.0);\n float sumWeightsCol = 0.0;\n float sumWeightsOff = 0.0;\n #pragma unroll_loop\n for (int i = 0; i < 27; i++) {\n float smoothFac = getSmoothFactor(f1, vgd[i].dist, smoothness);\n float weightOff = smoothFac * smoothFac * smoothFac;\n float weightCol = weightOff * smoothFac;\n avgCol += vgd[i].randVec * weightCol;\n avgOff += vgd[i].toClosest * weightOff;\n sumWeightsCol += weightCol;\n sumWeightsOff += weightOff;\n }\n outColor = vec4(avgCol / sumWeightsCol, 1.0);\n outPosition = pos + avgOff / sumWeightsOff;\n } else if (feature == FEATURE_DISTANCE_TO_EDGE) {\n #pragma unroll_loop\n for (int i = 0; i < 27; i++) {\n if (vgd[i].toClosest != edgeToClosest) {\n float dist = dot(0.5 * (edgeToClosest + vgd[i].toClosest),\n normalize(vgd[i].toClosest - edgeToClosest));\n distToEdge = min(distToEdge, dist);\n }\n }\n outDist = distToEdge;\n } else if (feature == FEATURE_N_SPHERE_RADIUS) {\n float diam = 1e10;\n #pragma unroll_loop\n for (int i = 0; i <= 2; i++) {\n #pragma unroll_loop\n for (int j = 0; j <= 2; j++) {\n #pragma unroll_loop\n for (int k = 0; k <= 2; k++) {\n vec3 localPoint = vec3((i), (j), (k)) - 1.0;\n if (length(localPoint) > 0.0) {\n vec3 point = localPoint + radPoint;\n vec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\n vec3 toClosest = point + randomness * randVec - posF;\n diam = min(diam, length(toClosest - radToClosest));\n }\n }\n }\n }\n outRadius = diam / 2.0;\n }\n}\n#define VORONOI_SMOOTH_COEFF 0.74\nvoid node_tex_voronoi(\n int distance, int feature,\n vec3 vector, float w, float scale, float smoothness, float exponent,\n float randomness,\n out float outDistance, out vec4 outColor, out vec3 outPosition,\n out float outW, out float outRadius) {\n vector = scale * (vector - 0.0001);\n smoothness = clamp(smoothness, 1e-3, 1.0);\n smoothness *= VORONOI_SMOOTH_COEFF;\n worleyNoise(vector, distance, exponent, feature, smoothness, randomness,\n outDistance, outColor, outPosition, outW, outRadius);\n outPosition /= scale;\n}\n#define DISTANCE_DISTANCE DISTANCE_EUCLIDEAN\n#define FEATURE_F3 5\n#define FEATURE_F4 6\n#define FEATURE_F2F1 7\n#define COLORING_INTENSITY 0\n#define COLORING_CELLS 1\nstruct VoronoiClosest {\n vec4 closestDists;\n vec4 closestInds;\n};\nvoid updateVoronoiClosest(inout VoronoiClosest vf, vec3 newDistances,\n 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}\nvec3 worleyPermute(vec3 x) {\n return mod((34.0 * x + 1.0) * x, 289.0);\n}\nvec3 worleyDist(vec3 x, vec3 y, vec3 z, int distance, float exponent) {\n if (distance == DISTANCE_EUCLIDEAN) {\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 vec3 expVec = vec3(exponent);\n return pow(pow(abs(x), expVec)\n + pow(abs(y), expVec)\n + pow(abs(z), expVec), 1.0 / expVec);\n }\n return vec3(0.0);\n}\nVoronoiClosest worleyClosest(vec3 P, float jitter, int distance, float exponent) {\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, exponent);\n vec3 d12 = worleyDist(dx12, dy12, dz12, distance, exponent);\n vec3 d13 = worleyDist(dx13, dy13, dz13, distance, exponent);\n vec3 d21 = worleyDist(dx21, dy21, dz21, distance, exponent);\n vec3 d22 = worleyDist(dx22, dy22, dz22, distance, exponent);\n vec3 d23 = worleyDist(dx23, dy23, dz23, distance, exponent);\n vec3 d31 = worleyDist(dx31, dy31, dz31, distance, exponent);\n vec3 d32 = worleyDist(dx32, dy32, dz32, distance, exponent);\n vec3 d33 = worleyDist(dx33, dy33, dz33, distance, exponent);\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}\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, exponent);\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_tex_white_noise_frag:"void node_tex_white_noise(vec3 vector, float w, out float value) {\n value = 0.0;\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:"void node_vect_math_add(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = v1 + v2;\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = v1 - v2;\n}\nvoid node_vect_math_multiply(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = v1 * v2;\n}\nvoid node_vect_math_divide(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec.x = v2.x == 0.0 ? 0.0 : v1.x / v2.x;\n outVec.y = v2.y == 0.0 ? 0.0 : v1.y / v2.y;\n outVec.z = v2.z == 0.0 ? 0.0 : v1.z / v2.z;\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = cross(v1, v2);\n}\nvoid node_vect_math_project(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n float d = dot(v2, v2);\n outVec = (d != 0.0) ? (dot(v1, v2) / d) * v2 : vec3(0.0);\n}\nvoid node_vect_math_reflect(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n if (v2 != vec3(0.0)) {\n v2 = normalize(v2);\n }\n outVec = reflect(v1, v2);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVal = dot(v1, v2);\n}\nvoid node_vect_math_distance(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVal = distance(v1, v2);\n}\nvoid node_vect_math_length(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVal = length(v1);\n}\nvoid node_vect_math_scale(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = v1 * val;\n}\nvoid node_vect_math_normalize(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n if (v1 != vec3(0.0)) {\n v1 = normalize(v1);\n }\n outVec = v1;\n}\nvoid node_vect_math_snap(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec.x = v2.x == 0.0 ? 0.0 : floor(v1.x / v2.x) * v2.x;\n outVec.y = v2.y == 0.0 ? 0.0 : floor(v1.y / v2.y) * v2.y;\n outVec.z = v2.z == 0.0 ? 0.0 : floor(v1.z / v2.z) * v2.z;\n}\nvoid node_vect_math_floor(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = floor(v1);\n}\nvoid node_vect_math_ceil(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = ceil(v1);\n}\nvoid node_vect_math_modulo(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n vec3 signProduct = sign(v1) * sign(v2);\n v1 += 1e-5 * signProduct;\n outVec.x = signProduct.x > 0.0 ? mod(v1.x, abs(v2.x)) : 0.0;\n outVec.y = signProduct.y > 0.0 ? mod(v1.y, abs(v2.y)) : 0.0;\n outVec.z = signProduct.z > 0.0 ? mod(v1.z, abs(v2.z)) : 0.0;\n}\nvoid node_vect_math_fraction(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = fract(v1);\n}\nvoid node_vect_math_absolute(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = abs(v1);\n}\nvoid node_vect_math_minimum(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = min(v1, v2);\n}\nvoid node_vect_math_maximum(vec3 v1, vec3 v2, float val, out vec3 outVec, out float outVal)\n{\n outVec = max(v1, v2);\n}\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_vector_displacement_frag:"void node_vector_displacement(vec4 vector, float midLevel, float scale,\n out vec3 displacement) {\n displacement = vec3(0.0);\n}",node_vertex_color_frag:"void node_vertex_color(out vec4 color, out float alpha) {\n color = vec4(vec3(0.0), 1.0);\n alpha = 1.0;\n}",node_volume_absorption_frag:"void node_volume_absorption(vec4 color, float density, out vec4 outColor)\n{\n outColor = color;\n}",node_volume_info_frag:"void node_volume_info(out vec4 color, out float density, out float flame,\n out float temperature) {\n color = vec4(vec3(0.0), 1.0);\n density = 0.0;\n flame = 0.0;\n temperature = 0.0;\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 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 mapping, const int axis,\n const ivec2 clampToEdgeNoExtend,\n const int encoding, 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 vec3 coordsIn;\n if (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\n coordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n } else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\n coordsIn = vec3(0.0);\n } else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\n coordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n } else {\n coordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n }\n if (axis == AXIS_XY)\n coordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\n else if (axis == AXIS_YZ)\n coordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\n else if (axis == AXIS_ZX)\n coordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\n vec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\n vec2 uv = vec2(coordsOut.x, 1.0 - coordsOut.y);\n if ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n (clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\n color = vec4(0.0, 0.0, 0.0, 1.0);\n } else {\n color = texture2D(map, uv);\n color = nodeTexelToLinear(color, encoding);\n }\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(abs(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_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 geometryNormal,\n vec3 viewPos, int mapping, int axis, ivec2 clampToEdgeNoExtend,\n vec4 sourceMap, float uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\n out vec4 outCol)\n{\n vec3 coordsIn;\n if (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\n coordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n } else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\n coordsIn = vec3(0.0);\n } else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\n coordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-viewPos, 1.0)).xyz);\n } else {\n coordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n }\n if (axis == AXIS_XY)\n coordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\n else if (axis == AXIS_YZ)\n coordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\n else if (axis == AXIS_ZX)\n coordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\n vec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\n float coord = uvIn.x;\n uvIn = coordsOut.xy;\n if ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n (clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\n outCol = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\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(geometryNormal, 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(geometryNormal, 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(geometryNormal, 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(geometryNormal, 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_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 = clampColor ? saturate(color3) : color3;\n color3 = color3 * rgbLevel + vec3(rgbOffset);\n color3 = invert ? (vec3(1.0) - color3) : color3;\n color = outputAmount * vec4(color3, 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 geometryNormal, 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 clearcoatNormal, 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#ifdef CLEARCOAT\n material.clearcoat = saturate(coating);\n material.clearcoatRoughness = clamp(coatRoughness, 0.0, 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 #ifdef ENVMAP_TYPE_CUBE_UV\n float geomRoughness = calcGeometryRoughness(geometryNormal);\n material.specularRoughness = calcCubeUVAdjustedRoughness(\n material.specularRoughness, geomRoughness);\n material.refractionRoughness = calcCubeUVAdjustedRoughness(\n material.refractionRoughness, geomRoughness);\n #ifdef CLEARCOAT\n material.clearcoatRoughness = calcCubeUVAdjustedRoughness(\n material.clearcoatRoughness, geomRoughness);\n #endif\n #endif\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n #define COAT_NORMAL clearcoatNormal\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 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_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_vertex_color_max_frag:"void node_vertex_color_max(vec3 color, out vec4 outColor)\n{\n outColor = vec4(color, 1.0);\n}",node_ai_skydome_light_my_frag:"void node_ai_skydome_light_my(sampler2D envMap, int encoding, vec3 normal,\n float intensity,\n out vec4 outgoingLight)\n{\n vec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\n vec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\n vec3 reflectVec = normalize(cameraToVertex);\n mat3 uvTransform = mat3(1.0);\n vec4 color = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\n #if LIGHT_PATH_IS_CAM_RAY\n intensity = 1.0;\n #endif\n outgoingLight = color * intensity;\n}",node_output_my_frag:"void node_output_my(vec4 rgb, out vec4 outgoingLight)\n{\n outgoingLight = rgb;\n}",pp_plane_vert:"varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",pp_bloom_composite_frag:"varying vec2 vUv;\nuniform sampler2D blurTexture1;\nuniform sampler2D blurTexture2;\nuniform sampler2D blurTexture3;\nuniform sampler2D blurTexture4;\nuniform sampler2D blurTexture5;\nuniform sampler2D dirtTexture;\nuniform float bloomStrength;\nuniform float bloomRadius;\nuniform float bloomFactors[NUM_MIPS];\nuniform vec3 bloomTintColors[NUM_MIPS];\nfloat lerpBloomFactor(const in float factor) {\n float mirrorFactor = 1.2 - factor;\n return mix(factor, mirrorFactor, bloomRadius);\n}\nvoid main() {\n gl_FragColor = bloomStrength * (\n lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv)\n );\n}",pp_bloom_lum_high_pass_frag:"uniform sampler2D tDiffuse;\nuniform vec3 defaultColor;\nuniform float defaultOpacity;\nuniform float luminosityThreshold;\nuniform float smoothWidth;\nvarying vec2 vUv;\nvoid main() {\n vec4 texel = texture2D(tDiffuse, vUv);\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float v = dot(texel.xyz, luma);\n vec4 outputColor = vec4(defaultColor.rgb, defaultOpacity);\n float alpha = smoothstep(luminosityThreshold, luminosityThreshold + smoothWidth, v);\n gl_FragColor = mix(outputColor, texel, alpha);\n gl_FragColor = clamp(gl_FragColor, 0.0, 10.0);\n}",pp_bloom_separable_blur_frag:"#include \nvarying vec2 vUv;\nuniform sampler2D colorTexture;\nuniform vec2 texSize;\nuniform vec2 direction;\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 fSigma = float(SIGMA);\n float weightSum = gaussianPdf(0.0, fSigma);\n vec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\n for (int i = 1; i < KERNEL_RADIUS; i++) {\n float x = float(i);\n float w = gaussianPdf(x, fSigma);\n vec2 uvOffset = direction * invSize * x;\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 }\n gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n}",pp_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 #if LOG_SPACE == 1\n vec3 origDiffuse = texture2D(colorTexture, vUv).rgb;\n vec3 diffuseSum = vec3(weightSum);\n #else\n vec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\n #endif\n vec2 delta = direction * invSize * kernelRadius/float(MAX_SAMPLE_RADIUS);\n vec2 uvOffset = delta;\n #if OCTAHEDRAL_MAP == 1\n vec3 cubeDir = normalize(octUVToCubeVec(vUv, invSize));\n vec3 dirX = normalize(abs(cubeDir.y) < 0.99999 ? vec3(cubeDir.z, 0.0, -cubeDir.x)\n : vec3(0.0, -cubeDir.z, cubeDir.y));\n vec3 dirY = cross(cubeDir, dirX);\n #endif\n #pragma unroll_loop\n for (int i = 1; i <= MAX_SAMPLE_RADIUS; i++) {\n float w = gaussianPdf(uvOffset.x, kernelRadius);\n #if OCTAHEDRAL_MAP == 1\n vec3 cubeOffset = uvOffset.x * dirX + uvOffset.y * dirY;\n vec2 uv1 = cubeVecToOctUV(cubeDir + cubeOffset, invSize);\n vec2 uv2 = cubeVecToOctUV(cubeDir - cubeOffset, invSize);\n #else\n vec2 uv1 = vUv + uvOffset;\n vec2 uv2 = vUv - uvOffset;\n #endif\n vec3 sample1 = texture2D(colorTexture, uv1).rgb;\n vec3 sample2 = texture2D(colorTexture, uv2).rgb;\n #if LOG_SPACE == 1\n diffuseSum += (\n clamp(exp(sample1 - origDiffuse), 0.0, 1e38) +\n clamp(exp(sample2 - origDiffuse), 0.0, 1e38)\n ) * w;\n #else\n diffuseSum += ((sample1 + sample2) * w);\n #endif\n weightSum += 2.0 * w;\n uvOffset += delta;\n }\n #if LOG_SPACE == 1\n gl_FragColor = vec4(origDiffuse + log(diffuseSum/weightSum), 1.0);\n #else\n gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n #endif\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_cube_octahedral_proj_frag:"#include \nuniform samplerCube tCube;\nuniform vec2 texelSize;\nvarying vec2 vUv;\nvoid main() {\n gl_FragColor = textureCube(tCube, octUVToCubeVec(gl_FragCoord.xy * texelSize,\n texelSize));\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 vec4 visibleEdgeColor;\nuniform vec4 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 vec4 edgeColor = (1.0 - visibilityFactor > 0.001) ? visibleEdgeColor : hiddenEdgeColor;\n gl_FragColor = edgeColor * 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 vec4 diffuseSum = texture2D(colorTexture, vUv);\n #if defined(LOG_SPACE)\n diffuseSum = exp(diffuseSum);\n #endif\n diffuseSum *= 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 vec4 sample1 = texture2D(colorTexture, vUv + uvOffset);\n vec4 sample2 = texture2D(colorTexture, vUv - uvOffset);\n #if defined(LOG_SPACE)\n sample1 = exp(sample1);\n sample2 = exp(sample2);\n #endif\n diffuseSum += ((sample1 + sample2) * w);\n weightSum += (2.0 * w);\n uvOffset += delta;\n }\n vec4 finalCol = diffuseSum / weightSum;\n #if defined(LOG_SPACE)\n finalCol = log(finalCol);\n #endif\n gl_FragColor = finalCol;\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 float maxChannel = max(finalColor.r, max(finalColor.g, finalColor.b));\n if (maxChannel != 0.0) {\n finalColor.rgb /= maxChannel;\n }\n gl_FragColor = finalColor;\n}",pp_ssao_blur_frag:"uniform sampler2D tDiffuse;\nuniform vec2 resolution;\nvarying vec2 vUv;\nvoid main() {\n vec2 texelSize = (1.0 / resolution);\n float result = 0.0;\n for (int i = - 2; i <= 2; i++) {\n for (int j = - 2; j <= 2; j ++) {\n vec2 offset = (vec2(float(i), float(j))) * texelSize;\n result += texture2D(tDiffuse, vUv + offset).r;\n }\n }\n gl_FragColor = vec4(vec3(result / (5.0 * 5.0)), 1.0);\n}",pp_ssao_depth_frag:"uniform sampler2D tDepth;\nuniform float cameraNear;\nuniform float cameraFar;\nvarying vec2 vUv;\n#include \nfloat getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(depthSampler, coord).x;\n #endif\n}\nvoid main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n}",pp_ssao_frag:"uniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tDepth;\nuniform sampler2D tNoise;\nuniform vec3 kernel[KERNEL_SIZE];\nuniform vec2 resolution;\nuniform float cameraNear;\nuniform float cameraFar;\nuniform mat4 cameraProjectionMatrix;\nuniform mat4 cameraInverseProjectionMatrix;\nuniform float kernelRadius;\nuniform float minDistance;\nuniform float maxDistance;\nvarying vec2 vUv;\n#include \nfloat getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n}\nfloat getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(depthSampler, coord).x;\n #endif\n}\nfloat getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n}\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n}\nvec3 getViewNormal(const in vec2 screenPosition) {\n return unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n}\nvoid main() {\n float depth = getDepth(vUv);\n float viewZ = getViewZ(depth);\n vec3 viewPosition = getViewPosition(vUv, depth, viewZ);\n vec3 viewNormal = getViewNormal(vUv);\n vec2 noiseScale = vec2(resolution.x / 4.0, resolution.y / 4.0);\n vec3 random = texture2D(tNoise, vUv * noiseScale).xyz;\n vec3 tangent = normalize(random - viewNormal * dot(random, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n float occlusion = 0.0;\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 sampleVector = kernelMatrix * kernel[i];\n vec3 samplePoint = viewPosition + (sampleVector * kernelRadius);\n vec4 samplePointNDC = cameraProjectionMatrix * vec4(samplePoint, 1.0);\n samplePointNDC /= samplePointNDC.w;\n vec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5;\n float realDepth = getLinearDepth(samplePointUv);\n float sampleDepth = viewZToOrthographicDepth(samplePoint.z, cameraNear, cameraFar);\n float delta = sampleDepth - realDepth;\n if (delta > minDistance && delta < maxDistance) {\n occlusion += 1.0;\n }\n }\n occlusion = clamp(occlusion / float(KERNEL_SIZE), 0.0, 1.0);\n gl_FragColor = vec4(vec3(1.0 - occlusion), 1.0);\n}",pp_tonemap_frag:"uniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\n vec4 texel = texture2D(tDiffuse, vUv);\n float alpha = clamp(texel.a, 0.0, 1.0);\n gl_FragColor = texel;\n gl_FragColor.rgb /= alpha;\n #include \n gl_FragColor = LinearTosRGB(gl_FragColor);\n gl_FragColor.rgb *= alpha;\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;\n#include \nvoid main() {\n vec4 c = vec4(color, opacity);\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}"},Ji={basic:{uniforms:Ri([Wi.common,Wi.specularmap,Wi.envmap,Wi.aomap,Wi.lightmap,Wi.fog]),vertexShader:Ki.meshbasic_vert,fragmentShader:Ki.meshbasic_frag},lambert:{uniforms:Ri([Wi.common,Wi.specularmap,Wi.envmap,Wi.aomap,Wi.lightmap,Wi.emissivemap,Wi.fog,Wi.lights,{emissive:{value:new Cr(0)}}]),vertexShader:Ki.meshlambert_vert,fragmentShader:Ki.meshlambert_frag},phong:{uniforms:Ri([Wi.common,Wi.specularmap,Wi.envmap,Wi.aomap,Wi.lightmap,Wi.emissivemap,Wi.bumpmap,Wi.normalmap,Wi.displacementmap,Wi.fog,Wi.lights,{emissive:{value:new Cr(0)},specular:{value:new Cr(1118481)},shininess:{value:30}}]),vertexShader:Ki.meshphong_vert,fragmentShader:Ki.meshphong_frag},standard:{uniforms:Ri([Wi.common,Wi.envmap,Wi.aomap,Wi.lightmap,Wi.emissivemap,Wi.bumpmap,Wi.normalmap,Wi.displacementmap,Wi.roughnessmap,Wi.metalnessmap,Wi.fog,Wi.lights,{emissive:{value:new Cr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Ki.meshphysical_vert,fragmentShader:Ki.meshphysical_frag},toon:{uniforms:Ri([Wi.common,Wi.specularmap,Wi.aomap,Wi.lightmap,Wi.emissivemap,Wi.bumpmap,Wi.normalmap,Wi.displacementmap,Wi.gradientmap,Wi.fog,Wi.lights,{emissive:{value:new Cr(0)},specular:{value:new Cr(1118481)},shininess:{value:30}}]),vertexShader:Ki.meshtoon_vert,fragmentShader:Ki.meshtoon_frag},matcap:{uniforms:Ri([Wi.common,Wi.bumpmap,Wi.normalmap,Wi.displacementmap,Wi.fog,{matcap:{value:null}}]),vertexShader:Ki.meshmatcap_vert,fragmentShader:Ki.meshmatcap_frag},points:{uniforms:Ri([Wi.points,Wi.fog]),vertexShader:Ki.points_vert,fragmentShader:Ki.points_frag},dashed:{uniforms:Ri([Wi.common,Wi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ki.linedashed_vert,fragmentShader:Ki.linedashed_frag},depth:{uniforms:Ri([Wi.common,Wi.displacementmap,{slopeScaledBias:{value:0}}]),vertexShader:Ki.depth_vert,fragmentShader:Ki.depth_frag},normal:{uniforms:Ri([Wi.common,Wi.bumpmap,Wi.normalmap,Wi.displacementmap,{opacity:{value:1}}]),vertexShader:Ki.normal_vert,fragmentShader:Ki.normal_frag},sprite:{uniforms:Ri([Wi.sprite,Wi.fog]),vertexShader:Ki.sprite_vert,fragmentShader:Ki.sprite_frag},background:{uniforms:{uvTransform:{value:new Qt},t2D:{value:null}},vertexShader:Ki.background_vert,fragmentShader:Ki.background_frag},cube:{uniforms:Ri([Wi.envmap,{opacity:{value:1}}]),vertexShader:Ki.cube_vert,fragmentShader:Ki.cube_frag},equirect:{uniforms:{tEquirect:{value:null},invertU:{value:!1},offsetU:{value:0}},vertexShader:Ki.equirect_vert,fragmentShader:Ki.equirect_frag},distanceRGBA:{uniforms:Ri([Wi.common,Wi.displacementmap,{referencePosition:{value:new on},nearDistance:{value:1},farDistance:{value:1e3},slopeScaledBias:{value:0}}]),vertexShader:Ki.distanceRGBA_vert,fragmentShader:Ki.distanceRGBA_frag},shadow:{uniforms:Ri([Wi.lights,Wi.fog,{color:{value:new Cr(0)},opacity:{value:1}}]),vertexShader:Ki.shadow_vert,fragmentShader:Ki.shadow_frag},mask:{uniforms:Ri([Wi.common,Wi.displacementmap,Wi.mask]),vertexShader:Ki.mask_vert,fragmentShader:Ki.mask_frag},equicube:{uniforms:{tEquirect:{value:null},faceIndex:{value:0},invertU:{value:!1},offsetU:{value:0}},vertexShader:Ki.equicube_vert,fragmentShader:Ki.equicube_frag},node:{uniforms:Ri([Wi.common,Wi.displacementmap,Wi.envmap,Wi.fog,Wi.lights,Wi.ssr,Wi.node,{envMapIntensity:{value:1}}]),vertexShader:Ki.meshnode_vert,fragmentShader:Ki.meshnode_frag},cubeOctahedral:{uniforms:{tCube:{value:null},texelSize:{value:new qt(.5,.5)}},vertexShader:Ki.pp_plane_vert,fragmentShader:Ki.pp_cube_octahedral_proj_frag}};function $i(p,n,f,r){var m,v,g,y,x=new Cr(0),_=0;function b(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return x},setClearColor:function(e,t){x.set(e),b(x,_=void 0!==t?t:1)},getClearAlpha:function(){return _},setClearAlpha:function(e){b(x,_=e)},dispose:function(){v&&(v.geometry.dispose(),v.material.dispose()),v=m=void 0,g&&(g.geometry.dispose(),g.material.dispose()),g=void 0,y&&(y.geometry.dispose(),y.material.dispose()),y=void 0},render:function(e,t,n,r){var i=t.background&&t.background.isSceneBackground,a=i?t.background.data:t.background,o=p.xr,s=o.getSession&&o.getSession();s&&"additive"===s.environmentBlendMode&&(a=null),null===a?b(x,_):a&&a.isColor&&(b(a,1),r=!0),(p.autoClear||r)&&p.clear(p.autoClearColor,p.autoClearDepth,p.autoClearStencil);var l=!!i&&t.background.useHDR;if(a&&(a.isCubeTexture||a.isWebGLCubeRenderTarget)){void 0===g&&((g=new _i(new Ci(1,1,1),new Fi({type:"BackgroundCubeMaterial",uniforms:Di.clone(Ji.cube.uniforms),vertexShader:Ji.cube.vertexShader,fragmentShader:Ji.cube.fragmentShader,side:Le,depthTest:!1,depthWrite:!1,fog:!1,polygonOffset:!0,useHDR:l}))).geometry.deleteAttribute("normal"),g.geometry.deleteAttribute("uv"),g.onBeforeRender=function(e,t,n){var r=n.far;this.matrixWorld.makeScale(r,r,r),this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(g.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),f.update(g)),f.update(g);var c=a.isCubeTexture?a:a.texture;g.material.uniforms.envMap.value=c;var u=a.isCubeTexture?-1:1;g.material.uniforms.flipEnvMap.value=u,e.unshift(g,g.geometry,g.material,0,0,null)}else if(a&&a.isTexture)if(a.mapping===Ge){var d=!!i&&t.background.equirecInvertU,h=i?t.background.equirecOffsetU:0;void 0===y&&((y=new _i(new Ci(1,1,1),new Fi({vertexShader:Ji.equirect.vertexShader,fragmentShader:Ji.equirect.fragmentShader,uniforms:Ji.equirect.uniforms,side:Le,depthTest:!1,depthWrite:!1,polygonOffset:!0,useHDR:l}))).geometry.deleteAttribute("normal"),y.geometry.deleteAttribute("uv"),y.onBeforeRender=function(e,t,n){var r=n.far;this.matrixWorld.makeScale(r,r,r),this.matrixWorld.copyPosition(n.matrixWorld)}),f.update(y),y.material.uniforms.invertU.value=d,y.material.uniforms.offsetU.value=h,y.material.uniforms.tEquirect.value=a,e.unshift(y,y.geometry,y.material,0,0,null)}else void 0===m&&(m=new qi(-1,1,1,-1,0,1),v=new _i(new Zi(2,2),new Ir({depthTest:!1,depthWrite:!1,fog:!1}))),f.update(v),v.material.map=a,p.renderBufferDirect(m,null,v.geometry,v.material,v,null)}}}function ea(o,s,l,e){var c,u=e.isWebGL2;this.setMode=function(e){c=e},this.render=function(e,t){o.drawArrays(c,e,t),l.update(t,c)},this.renderInstances=function(e,t,n,r){if(0!==r){var i,a;if(u)i=o,a="drawArraysInstanced";else if(a="drawArraysInstancedANGLE",null===(i=s.get("ANGLE_instanced_arrays")))return void console.error("v3d.WebGLBufferRenderer: using v3d.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");i[a](c,t,n,r),l.update(n,c,r)}}}function ta(t,n,e){var r;function i(e){if("highp"===e){if(0",t[n]);return e}var xo=/^[ \t]*#include +<([\w\d./]+)>/gm;function _o(e){return e.replace(xo,bo)}function bo(e,t){var n=Ki[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return _o(n)}function wo(e){for(var t,n=new RegExp("#pragma unroll_loop[\\s]+?for \\(int (\\w+) \\= (\\d+)\\; (\\w+) <(=?) (\\w+)\\; (\\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&&0Do.OMNI_MAP_ANGLE?2:1:0,g.castShadow){M=g.shadow;A.shadowBias=M.bias,A.expBias=M.expBias,A.shadowRadius=M.radius,A.shadowMapSize=M.mapSize,E.spotShadowMap[c]=b,E.spotShadowMatrix[c]=g.shadow.matrix,f++,A.shadowCameraNear=M.camera.near,A.shadowCameraFar=M.camera.far}E.spot[c]=A,c++}else if(g.isRectAreaLight){(A=T.get(g)).color.copy(y).multiplyScalar(x),A.position.setFromMatrixPosition(g.matrixWorld),A.position.applyMatrix4(m),L.identity(),C.copy(g.matrixWorld),C.premultiply(m),L.extractRotation(C),A.halfWidth.set(.5*g.width,0,0),A.halfHeight.set(0,.5*g.height,0),A.halfWidth.applyMatrix4(L),A.halfHeight.applyMatrix4(L),E.rectArea[u]=A,u++}else if(g.isPointLight){if((A=T.get(g)).position.setFromMatrixPosition(g.matrixWorld),A.position.applyMatrix4(m),A.color.copy(g.color).multiplyScalar(g.intensity),A.distance=g.distance,A.decay=g.decay,A.shadow=g.castShadow,g.castShadow){M=g.shadow;A.shadowBias=M.bias,A.expBias=M.expBias,A.shadowRadius=M.radius,A.shadowMapSize=M.mapSize,A.shadowCameraNear=M.camera.near,A.shadowCameraFar=M.camera.far,E.pointShadowMap[l]=b,E.pointShadowMatrix[l]=g.shadow.matrix,p++}E.point[l]=A,l++}else if(g.isHemisphereLight){var A;(A=T.get(g)).direction.setFromMatrixPosition(g.matrixWorld),A.direction.transformDirection(m),A.direction.normalize(),A.skyColor.copy(g.color).multiplyScalar(x),A.groundColor.copy(g.groundColor).multiplyScalar(x),E.hemi[d]=A,d++}}E.ambient[0]=r,E.ambient[1]=i,E.ambient[2]=a;var S=E.hash;S.directionalLength===s&&S.pointLength===l&&S.spotLength===c&&S.rectAreaLength===u&&S.hemiLength===d&&S.numDirectionalShadows===h&&S.numPointShadows===p&&S.numSpotShadows===f||(E.directional.length=s,E.spot.length=c,E.rectArea.length=u,E.point.length=l,E.hemi.length=d,E.directionalShadowMap.length=h,E.pointShadowMap.length=p,E.spotShadowMap.length=f,E.directionalShadowMatrix.length=h,E.pointShadowMatrix.length=p,E.spotShadowMatrix.length=f,S.directionalLength=s,S.pointLength=l,S.spotLength=c,S.rectAreaLength=u,S.hemiLength=d,S.numDirectionalShadows=h,S.numPointShadows=p,S.numSpotShadows=f,E.version=No++)},state:E}}function Bo(){var t=new Io,n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:t},setupLights:function(e){t.setup(n,r,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){r.push(e)}}}function Uo(){var r=new WeakMap;function i(e){var t=e.target;t.removeEventListener("dispose",i),r.delete(t)}return{get:function(e,t){var n;return!1===r.has(e)?(n=new Bo,r.set(e,new WeakMap),r.get(e).set(t,n),e.addEventListener("dispose",i)):!1===r.get(e).has(t)?(n=new Bo,r.get(e).set(t,n)):n=r.get(e).get(t),n},dispose:function(){r=new WeakMap}}}function zo(e){Fr.call(this),this.type="MeshDepthMaterial",this.depthPacking=Dt,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}function ko(e){Fr.call(this),this.type="MeshDistanceMaterial",this.distancePacking=Nt,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.referencePosition=new on,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}((zo.prototype=Object.create(Fr.prototype)).constructor=zo).prototype.isMeshDepthMaterial=!0,zo.prototype.copy=function(e){return Fr.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.useSlopeScaledBias=e.useSlopeScaledBias,this.slopeScaledBias=e.slopeScaledBias,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},((ko.prototype=Object.create(Fr.prototype)).constructor=ko).prototype.isMeshDistanceMaterial=!0,ko.prototype.copy=function(e){return Fr.prototype.copy.call(this,e),this.distancePacking=e.distancePacking,this.useSlopeScaledBias=e.useSlopeScaledBias,this.slopeScaledBias=e.slopeScaledBias,this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this};var Vo=.8,Go=.2,jo=.8,Wo=3;function Xo(y,v,g){var x=new ji,_=new fn,h=new fn,b=new qt,w=new qt(g.maxTextureSize,g.maxTextureSize),M=new on,A=new on,S=1,T=2,e=1+(S|T),E=new Array(e),P=new Array(e),C={},L={0:Le,1:ne,2:re},R=[new on(1,0,0),new on(-1,0,0),new on(0,1,0),new on(0,-1,0),new on(0,0,1),new on(0,0,-1)],D=[new on(0,1,0),new on(0,1,0),new on(0,0,1),new on(0,0,-1),new on(0,1,0),new on(0,1,0)],c=[new $t,new $t,new $t,new $t,new $t,new $t],f=new nr,p=[new on,new on,new on,new on,new on,new on,new on,new on],O=0,N=1,F=0,m=1,I=new qi(-1,1,1,-1,0,10),B=new _i(new Zi(2,2)),U=new Fi({type:"ShadowCubeOctahedral",defines:Object.assign({},Ji.cubeOctahedral.defines),uniforms:Di.clone(Ji.cubeOctahedral.uniforms),vertexShader:Ji.cubeOctahedral.vertexShader,fragmentShader:Ji.cubeOctahedral.fragmentShader}),u={};var d={};function z(e,t,n,r,i,a,o){var s,l,c=B.material=o===F?((l=r)in u||((u[l]=new Fi({type:"ShadowBlur",defines:Object.assign({},Ji.blur.defines,{LOG_SPACE:1,OCTAHEDRAL_MAP:1}),uniforms:Di.clone(Ji.blur.uniforms),customPrepTokens:Object.assign({},Ji.blur.customPrepTokens),vertexShader:Ji.blur.vertexShader,fragmentShader:Ji.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=l),u[l]):((s=r)in d||((d[s]=new Fi({type:"ShadowBlur",defines:Object.assign({},Ji.blur.defines,{LOG_SPACE:1}),uniforms:Di.clone(Ji.blur.uniforms),customPrepTokens:Object.assign({},Ji.blur.customPrepTokens),vertexShader:Ji.blur.vertexShader,fragmentShader:Ji.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=s),d[s]);c.uniforms.direction.value.set(+(a===O),+(a===N)),c.uniforms.colorTexture.value=t.texture,c.uniforms.texSize.value.set(t.width,t.height),c.uniforms.kernelRadius.value=i,c.uniformsNeedUpdate=!0,e.setRenderTarget(n),e.clear(),e.updateGeometry(B),e.renderBufferDirect(I,!1,B.geometry,c,B,null)}for(var t=0;t!==e;++t){var n=0!=(t&S),r=0!=(t&T),i=new zo({depthPacking:Ot,morphTargets:n,skinning:r});E[t]=i;var a=new ko({distancePacking:Nt,morphTargets:n,skinning:r});P[t]=a}var k=this;function V(e,t,n,r,i,a,o){var s=e.geometry,l=null,c=E,u=e.customDepthMaterial;if(!r&&k.type!==ee||(c=P,u=e.customDistanceMaterial),u)l=u;else{var d=!1;t.morphTargets&&(s&&s.isBufferGeometry?d=s.morphAttributes&&s.morphAttributes.position&&0>2&1,a>>1&1,s).multiplyScalar(2).subScalar(1).applyMatrix4(e.projectionMatrixInverse),1==s&&o.multiplyScalar(i)}r.setFromPoints(p),h.multiplyMatrices(t.camera.matrixWorldInverse,e.matrixWorld);var l=r.center.applyMatrix4(h),c=r.radius*=h.getMaxScaleOnAxis(),u=n.x/2/c,d=n.y/2/c;return l.x=Math.round(l.x*u)/u,l.y=Math.round(l.y*d)/d,r}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Q,this.render=function(e,t,n){if(!1!==k.enabled&&(!1!==k.autoUpdate||!1!==k.needsUpdate)&&0!==e.length){var r=y.getRenderTarget(),i=y.getActiveCubeFace(),a=y.getActiveMipmapLevel(),o=y.state;o.setBlending(ie),o.buffers.color.setClear(1,1,1,1),o.buffers.depth.setTest(!0),o.setScissorTest(!1);for(var s=0,l=e.length;sDo.OMNI_MAP_ANGLE)if(k.type===q||k.type===Q||k.type===$||k.type===te)W(t,n,c);else{if(k.type!==ee)continue;j(t,n,c)}else{if(!c.isSpotLight&&!c.isDirectionalLight)continue;if(k.type===q||k.type===Q||k.type===$||k.type===te)H(t,n,c);else{if(k.type!==ee)continue;X(t,n,c)}}else console.warn("v3d.WebGLShadowMap:",c,"has no shadow.")}k.needsUpdate=!1,y.setRenderTarget(r,i,a)}}}function Ho(u,n,e){var t,r,i=e.isWebGL2;var a=new function(){var t=!1,a=new $t,n=null,o=new $t(0,0,0,0);return{setMask:function(e){n===e||t||(u.colorMask(e,e,e,e),n=e)},setLocked:function(e){t=e},setClear:function(e,t,n,r,i){!0===i&&(e*=r,t*=r,n*=r),a.set(e,t,n,r),!1===o.equals(a)&&(u.clearColor(e,t,n,r),o.copy(a))},reset:function(){t=!1,n=null,o.set(-1,0,0,0)}}},o=new function(){var t=!1,n=null,r=null,i=null;return{setTest:function(e){(e?k:V)(2929)},setMask:function(e){n===e||t||(u.depthMask(e),n=e)},setFunc:function(e){if(r!==e){if(e)switch(e){case Te:u.depthFunc(512);break;case Ee:u.depthFunc(519);break;case Pe:u.depthFunc(513);break;case Re:u.depthFunc(515);break;case De:u.depthFunc(514);break;case Oe:u.depthFunc(518);break;case Ne:u.depthFunc(516);break;case Fe:u.depthFunc(517);break;default:u.depthFunc(515)}else u.depthFunc(515);r=e}},setLocked:function(e){t=e},setClear:function(e){i!==e&&(u.clearDepth(e),i=e)},reset:function(){t=!1,i=r=n=null}}},s=new function(){var t=!1,n=null,r=null,i=null,a=null,o=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?k:V)(2960)},setMask:function(e){n===e||t||(u.stencilMask(e),n=e)},setFunc:function(e,t,n){r===e&&i===t&&a===n||(u.stencilFunc(e,t,n),r=e,i=t,a=n)},setOp:function(e,t,n){o===e&&s===t&&l===n||(u.stencilOp(e,t,n),o=e,s=t,l=n)},setLocked:function(e){t=e},setClear:function(e){c!==e&&(u.clearStencil(e),c=e)},reset:function(){t=!1,c=l=s=o=a=i=r=n=null}}},l=u.getParameter(34921),c=new Uint8Array(l),d=new Uint8Array(l),h=new Uint8Array(l),p={},f=null,m=null,v=null,g=null,y=null,x=null,_=null,b=null,w=null,M=!1,A=null,S=null,T=null,E=null,P=null,C=u.getParameter(35661),L=!1,R=0,D=u.getParameter(7938);-1!==D.indexOf("WebGL")?(R=parseFloat(/^WebGL\ ([0-9])/.exec(D)[1]),L=1<=R):-1!==D.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(D)[1]),L=2<=R);var O=null,N={},F=new $t,I=new $t;function B(e,t,n){var r=new Uint8Array(4),i=u.createTexture();u.bindTexture(e,i),u.texParameteri(e,10241,9728),u.texParameteri(e,10240,9728);for(var a=0;ar||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?Yt.floorPowerOfTwo:Math.floor,o=a(i*e.width),s=a(i*e.height);void 0===c&&(c=u(o,s));var l=n?u(o,s):c;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 T(e){return Yt.isPowerOfTwo(e.width)&&Yt.isPowerOfTwo(e.height)}function E(e,t){return e.generateMipmaps&&t&&e.minFilter!==Ze&&e.minFilter!==$e}function P(e,t,n,r){x.generateMipmap(e),w.get(t).__maxMipLevel=Math.log(Math.max(n,r))*Math.LOG2E}function C(e,t,n){if(!1===S)return t;if(null!==e){if(void 0!==x[e])return x[e];console.warn("v3d.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}var r=t;return 6403===t&&(5126===n&&(r=33326),5131===n&&(r=33325),5121===n&&(r=33321)),6407===t&&(5126===n&&(r=34837),5131===n&&(r=34843),5121===n&&(r=32849)),6408===t&&(5126===n&&(r=34836),5131===n&&(r=34842),5121===n&&(r=32856)),33325===r||33326===r||34842===r||34836===r?_.get("EXT_color_buffer_float"):34843!==r&&34837!==r||console.warn("v3d.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),r}function s(e){return e===Ze||e===Ke||e===Je?9728:9729}function l(e){var t=e.target;t.removeEventListener("dispose",l),function(e){var t=w.get(e);if(void 0===t.__webglInit)return;x.deleteTexture(t.__webglTexture),w.remove(e)}(t),t.isVideoTexture&&o.delete(t),A.memory.textures--}function L(e){var t=e.target;t.removeEventListener("dispose",L),function(e){var t=w.get(e),n=w.get(e.texture);if(!e)return;void 0!==n.__webglTexture&&x.deleteTexture(n.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(var r=0;r<6;r++)x.deleteFramebuffer(t.__webglFramebuffer[r]),t.__webglDepthbuffer&&x.deleteRenderbuffer(t.__webglDepthbuffer[r]);else x.deleteFramebuffer(t.__webglFramebuffer),t.__webglDepthbuffer&&x.deleteRenderbuffer(t.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){x.deleteTexture(t.__webglColorTexture),x.deleteTexture(t.__webglDepthStencilTexture),A.memory.textures-=2;r=0;for(var i=t.__webglViewFramebuffers.length;ru)return!1;for(var n=1,r=t.length;n",'Find out how to fix it here.'].join("\n"):["Ouch! Your browser does not support WebGL.
",'Find out how to fix it here.'].join("\n"),e},showWebGLErrorMessage:function(e){(e=e||document.body).appendChild($o.genWebGLErrorMessage());var t=document.getElementById("v3d_preloader_container");t&&(t.style.visibility="hidden")},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")&&t.getExtension("OES_texture_float")&&t.getExtension("OES_texture_float_linear"))},checkFloatTex:function(e,t){var n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float")||t&&!n.getExtension("OES_texture_float_linear"))||!(!n.getExtension("OES_texture_float")||t&&!n.getExtension("OES_texture_float_linear"))},checkHalfFloatTex:function(e,t){var n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float")||t&&!n.getExtension("OES_texture_float_linear"))||!(!n.getExtension("OES_texture_half_float")||t&&!n.getExtension("OES_texture_half_float_linear"))},checkDepthTex:function(e){var t=e.getContext();return!(!e.capabilities.isWebGL2&&!t.getExtension("WEBGL_depth_texture"))},getGPUVendor:function(e){var t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl"),n=t.getExtension("WEBGL_debug_renderer_info");return null!=n?t.getParameter(n.UNMASKED_VENDOR_WEBGL):""},getGPUModel:function(e){var t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl"),n=t.getExtension("WEBGL_debug_renderer_info");return null!=n?t.getParameter(n.UNMASKED_RENDERER_WEBGL):""},checkWebXR:function(e,t,n){"xr"in navigator&&navigator.xr.isSessionSupported?navigator.xr.isSessionSupported(e).then(function(e){(e?t:n)()}).catch(n):n()},checkNativeWebXR:function(){var e="polyfill"in window&&"WebXRPolyfill"in window&&polyfill instanceof WebXRPolyfill;return"xr"in navigator&&(!e||e&&polyfill.nativeWebXR)},checkSwiftShader:function(e){return"Google SwiftShader"==this.getGPUModel(e)}};function es(e,t,n,r){this.ray=new ur(e,t),this.near=n||0,this.far=r||1/0,this.camera=null,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 ts(e,t){return e.distance-t.distance}function ns(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:hs.clone(),uv:Sr.getUV(hs,ys,xs,_s,bs,ws,Ms,new qt),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return In.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}});var Ts=new on,Es=new on;function Ps(){In.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function Cs(e,t){e&&e.isGeometry&&console.error("v3d.SkinnedMesh no longer supports v3d.Geometry. Use v3d.BufferGeometry instead."),_i.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new fn,this.bindMatrixInverse=new fn,this.normalizeSkinWeights()}Ps.prototype=Object.assign(Object.create(In.prototype),{constructor:Ps,isLOD:!0,copy:function(e){In.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+=d){var b;if(!(oe.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Hs=new on,Ys=new on;function qs(e,t){Xs.call(this,e,t),this.type="LineSegments"}function Qs(e,t){Xs.call(this,e,t),this.type="LineLoop"}function Zs(e){Fr.call(this),this.type="PointsMaterial",this.color=new Cr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}qs.prototype=Object.assign(Object.create(Xs.prototype),{constructor:qs,isLineSegments:!0,computeLineDistances: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:c,distanceToRay:Math.sqrt(s),point:l,index:t,face:null,object:o})}}function rl(e,t,n,r,i,a,o,s,l){Jt.call(this,e,t,n,r,i,a,o,s,l),this.format=void 0!==o?o:lt,this.minFilter=void 0!==a?a:$e,this.magFilter=void 0!==i?i:$e,this.generateMipmaps=!1}function il(e,t,n,r,i,a,o,s,l,c,u,d){Jt.call(this,null,a,o,s,l,c,r,i,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function al(e,t,n,r,i,a,o,s,l){Jt.call(this,e,t,n,r,i,a,o,s,l),this.needsUpdate=!0}function ol(e,t,n,r,i,a,o,s,l,c){if((c=void 0!==c?c:ut)!==ut&&c!==dt)throw new Error("DepthTexture format must be either v3d.DepthFormat or v3d.DepthStencilFormat");void 0===n&&c===ut&&(n=rt),void 0===n&&c===dt&&(n=st),Jt.call(this,null,r,i,a,o,s,c,n,l),this.image={width:e,height:t},this.magFilter=void 0!==o?o:Ze,this.minFilter=void 0!==s?s:Ze,this.flipY=!1,this.generateMipmaps=!1}function sl(e){ni.call(this),this.type="WireframeGeometry";var t,n,r,i,a,o,s,l,c,u,d=[],h=[0,0],p={},f=["a","b","c"];if(e&&e.isGeometry){var m=e.faces;for(t=0,r=m.length;t=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),((il.prototype=Object.create(Jt.prototype)).constructor=il).prototype.isCompressedTexture=!0,((al.prototype=Object.create(Jt.prototype)).constructor=al).prototype.isCanvasTexture=!0,((ol.prototype=Object.create(Jt.prototype)).constructor=ol).prototype.isDepthTexture=!0,(sl.prototype=Object.create(ni.prototype)).constructor=sl,(ll.prototype=Object.create(Ei.prototype)).constructor=ll,(cl.prototype=Object.create(ni.prototype)).constructor=cl,(ul.prototype=Object.create(Ei.prototype)).constructor=ul,(dl.prototype=Object.create(ni.prototype)).constructor=dl,(hl.prototype=Object.create(Ei.prototype)).constructor=hl,(pl.prototype=Object.create(dl.prototype)).constructor=pl,(fl.prototype=Object.create(Ei.prototype)).constructor=fl,(ml.prototype=Object.create(dl.prototype)).constructor=ml,(vl.prototype=Object.create(Ei.prototype)).constructor=vl,(gl.prototype=Object.create(dl.prototype)).constructor=gl,(yl.prototype=Object.create(Ei.prototype)).constructor=yl,(xl.prototype=Object.create(dl.prototype)).constructor=xl,(_l.prototype=Object.create(Ei.prototype)).constructor=_l,((bl.prototype=Object.create(ni.prototype)).constructor=bl).prototype.toJSON=function(){var e=ni.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e},(wl.prototype=Object.create(Ei.prototype)).constructor=wl,(Ml.prototype=Object.create(ni.prototype)).constructor=Ml,(Al.prototype=Object.create(Ei.prototype)).constructor=Al,(Sl.prototype=Object.create(ni.prototype)).constructor=Sl;var Tl=function(e,t,n){n=n||2;var r,i,a,o,s,l,c,u=t&&t.length,d=u?t[0]*n:e.length,h=El(e,0,d,n,!0),p=[];if(!h||h.next===h.prev)return p;if(u&&(h=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,d=Il(s,l,t,n,r),h=Il(c,u,t,n,r),p=e.prevZ,f=e.nextZ;p&&p.z>=d&&f&&f.z<=h;){if(p!==e.prev&&p!==e.next&&Ul(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=zl(p.prev,p,p.next))return;if(p=p.prevZ,f!==e.prev&&f!==e.next&&Ul(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&0<=zl(f.prev,f,f.next))return;f=f.nextZ}for(;p&&p.z>=d;){if(p!==e.prev&&p!==e.next&&Ul(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=zl(p.prev,p,p.next))return;p=p.prevZ}for(;f&&f.z<=h;){if(f!==e.prev&&f!==e.next&&Ul(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&0<=zl(f.prev,f,f.next))return;f=f.nextZ}return 1}}function Dl(e,t,n){var r=e;do{var i=r.prev,a=r.next.next;!kl(i,a)&&Vl(i,r,r.next,a)&&Gl(i,a)&&Gl(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),Xl(r),Xl(r.next),r=e=a),r=r.next}while(r!==e);return r}function Ol(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&&Vl(n,n.next,e,t))return 1;n=n.next}while(n!==e);return}(o,s)&&Gl(o,s)&&Gl(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=jl(l,c);return l=Pl(l,l.next),u=Pl(u,u.next),Cl(l,t,n,r,i,a),void Cl(u,t,n,r,i,a)}c=c.next}l=l.next}while(l!==e)}function Nl(e,t){return e.x-t.x}function Fl(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&&Ul(an.x)&&Gl(r,e)&&(n=r,h=l),r=r.next;return n}(e,t)){var n=jl(t,e);Pl(n,n.next)}}function Il(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 Bl(e){for(var t=e,n=e;(t.xNumber.EPSILON){var h=Math.sqrt(u),p=Math.sqrt(l*l+c*c),f=t.x-s/h,m=t.y+o/h,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 qt(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 qt(r/a,i/a)}for(var I=[],B=0,U=S.length,z=U-1,k=B+1;B>>1;e "+r[i]+";"}}t+="}",console.log(t)},c.DiGraph=d;function s(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;function l(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;function M(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.BellmanFord=M;function A(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.TopologicalSortShortestPaths=A;function S(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}}S.prototype.hasAugmentedPath=function(e){var t=e.V;this.marked=[],this.edgeTo=[];for(var n=0;na.tracks[s].times[0]&&(m=a.tracks[s].times[0]);for(s=0;st;)--a;if(++a,0!==i||a!==r){a<=i&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=mu.arraySlice(n,i,a),this.values=mu.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(Yt.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(Yt.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(qu(o,s.x,l.x,c.x,u.x),qu(o,s.y,l.y,c.y,u.y)),n},rd.prototype.copy=function(e){zu.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 1}else{var u=c*(e.x-o.x)-l*(e.y-o.y);if(0==u)return 1;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 1}}return r}var i=Yl.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 ud).curves=s.curves,c.push(l),c;var u=!i(a[0].getPoints());u=e?!u:u;var d,h,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=Yt.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=Yt.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 d=(this.time-t)%r;d<0&&(d+=r),this.time=i?n-d:d+t,s||this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:l})}}return this.time},_setEndings:function(e,t,n){var r=this._interpolantSettings;n?(r.endingStart=wt,r.endingEnd=wt):(r.endingStart=e?this.zeroSlopeAtStart?wt:bt:Mt,r.endingEnd=t?this.zeroSlopeAtEnd?wt:bt:Mt)},_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}}),Mh.prototype=Object.assign(Object.create(o.prototype),{constructor:Mh,_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 d=r[u],h=d.name,p=c[h];if(void 0!==p)a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,h));continue}var f=t&&t._propertyBindings[u].binding.parsedPath;++(p=new ch(_h.create(n,h,f),d.ValueTypeName,d.getValueSize())).referenceCount,this._addInactiveBinding(p,s,h),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 qt),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 qt),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Eh.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)}});var Ch=new on,Lh=new on;function Rh(e,t){this.start=void 0!==e?e:new on,this.end=void 0!==t?t:new on}function Dh(e){In.call(this),this.material=e,this.render=function(){}}Object.assign(Rh.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 on),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 on),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 on),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,t){Ch.subVectors(e,this.start),Lh.subVectors(this.end,this.start);var n=Lh.dot(Lh),r=Lh.dot(Ch)/n;return t&&(r=Yt.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 on),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)}}),((Dh.prototype=Object.create(In.prototype)).constructor=Dh).prototype.isImmediateRenderObject=!0;var Oh=new on;function Nh(e,t){In.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;for(var n=new ni,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],i=0,a=1;i<32;i++,a++){var o=i/32*Math.PI*2,s=a/32*Math.PI*2;r.push(Math.cos(o),Math.sin(o),1,Math.cos(s),Math.sin(s),1)}n.setAttribute("position",new Hr(r,3));var l=new zs({fog:!1});this.cone=new qs(n,l),this.add(this.cone),this.update()}((Nh.prototype=Object.create(In.prototype)).constructor=Nh).prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},Nh.prototype.update=function(){this.light.updateMatrixWorld();var e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Oh.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Oh),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var Fh=new on,Ih=new fn,Bh=new fn;function Uh(e){for(var t=function e(t){var n=[];t&&t.isBone&&n.push(t);for(var r=0;rn.far?null:{distance:l,point:_p.clone(),object:e}}(e,e.material,t,n,pp,fp,mp,xp);if(l){i&&(vp.fromBufferAttribute(i,a),gp.fromBufferAttribute(i,o),yp.fromBufferAttribute(i,s),l.uv=Sr.getUV(xp,pp,fp,mp,vp,gp,yp,new qt));var c=new on;l.face=new Or(a,o,s,Sr.getNormal(pp,fp,mp,c)),l.faceIndex=a}return l}function wp(e,t,n,r,i,a){var o=3*i,s=t.index.getX(o),l=t.index.getX(1+o),c=t.index.getX(2+o),u=bp(e,n,r,t.attributes.position,t.attributes.uv,s,l,c);return u?(u.faceIndex=i,a&&a.push(u),u):null}function Mp(e,t){return t.min.x=e[0],t.min.y=e[1],t.min.z=e[2],t.max.x=e[3],t.max.y=e[4],t.max.z=e[5],t}function Ap(e){for(var t=-1,n=-1/0,r=0;r<3;r++){var i=e[r+3]-e[r];ne.max||e.min>this.max}}]),e}();Tp.prototype.setFromBox=(Sp=new on,function(e,t){for(var n=t.min,r=t.max,i=1/0,a=-1/0,o=0;o<=1;o++)for(var s=0;s<=1;s++)for(var l=0;l<=1;l++){Sp.x=n.x*o+r.x*(1-o),Sp.y=n.y*s+r.y*(1-s),Sp.z=n.z*l+r.z*(1-l);var c=e.dot(Sp);i=Math.min(c,i),a=Math.max(c,a)}this.min=i,this.max=a});var Ep,Pp,Cp,Lp,Rp,Dp,Op,Np,Fp,Ip,Bp,Up,zp,kp,Vp,Gp,jp,Wp,Xp,Hp,Yp,qp,Qp,Zp=(Ep=new on,Pp=new on,Cp=new on,function(e,t,n){var r=e.start,i=Ep,a=t.start,o=Pp;Cp.subVectors(r,a),Ep.subVectors(e.end,t.start),Pp.subVectors(t.end,t.start);var s,l,c=Cp.dot(o),u=o.dot(i),d=o.dot(o),h=Cp.dot(i),p=i.dot(i)*d-u*u;l=(c+(s=0!=p?(c*u-h*d)/p:0)*u)/d,n.x=s,n.y=l}),Kp=(Lp=new qt,Rp=new on,Dp=new on,function(e,t,n,r){Zp(e,t,Lp);var i,a,o=Lp.x,s=Lp.y;if(0<=o&&o<=1&&0<=s&&s<=1)return e.at(o,n),void t.at(s,r);if(0<=o&&o<=1)return s<0?t.at(0,r):t.at(1,r),void e.closestPointToPoint(r,!0,n);if(0<=s&&s<=1)return o<0?e.at(0,n):e.at(1,n),void t.closestPointToPoint(n,!0,r);i=o<0?e.start:e.end,a=s<0?t.start:t.end;var l=Rp,c=Dp;return e.closestPointToPoint(a,!0,Rp),t.closestPointToPoint(i,!0,Dp),l.distanceToSquared(a)<=c.distanceToSquared(i)?(n.copy(l),void r.copy(a)):(n.copy(i),void r.copy(c))}),Jp=(Op=new on,Np=new on,Fp=new fr,Ip=new Rh,function(e,t){var n=e.radius,r=e.center,i=t.a,a=t.b,o=t.c;if(Ip.start=i,Ip.end=a,Ip.closestPointToPoint(r,!0,Op).distanceTo(r)<=n)return!0;if(Ip.start=i,Ip.end=o,Ip.closestPointToPoint(r,!0,Op).distanceTo(r)<=n)return!0;if(Ip.start=a,Ip.end=o,Ip.closestPointToPoint(r,!0,Op).distanceTo(r)<=n)return!0;var s=t.getPlane(Fp);if(Math.abs(s.distanceToPoint(r))<=n){var l=s.projectPoint(r,Np);if(t.containsPoint(l))return!0}return!1}),$p=function(){function a(){var e,t;_classCallCheck(this,a);for(var n=arguments.length,r=new Array(n),i=0;i=a;)i--;if(!(r=h.maxDepth&&(f=!0),n<=h.maxLeafTris||r>=h.maxDepth)return e.offset=t,e.count=n,e;var i=p.getOptimalSplit(e.boundingData,t,n,h.strategy);if(-1===i.axis)return e.offset=t,e.count=n,e;var a=p.partition(t,n,i);if(a===t||a===t+n)e.offset=t,e.count=n;else{e.splitAxis=i.axis;var o=e.left=new Of,s=t,l=a-t;o.boundingData=p.getBounds(s,l,new Float32Array(6)),m(o,s,l,r+1);var c=e.right=new Of,u=a,d=n-l;c.boundingData=p.getBounds(u,d,new Float32Array(6)),m(c,u,d,r+1)}return e},r=[],i=this._getRootIndexRanges(e);if(1===i.length){var a=new Of,o=i[0];null!=e.boundingBox?a.boundingData=(t=e.boundingBox,(n=new Float32Array(6))[0]=t.min.x,n[1]=t.min.y,n[2]=t.min.z,n[3]=t.max.x,n[4]=t.max.y,n[5]=t.max.z,n):a.boundingData=p.getBounds(o.offset,o.count,new Float32Array(6)),m(a,o.offset,o.count),r.push(a)}else for(var s=0;sa;)this.remove(this.children.pop())}}}]),i}(),Gf=function(){function r(e){var t,n=1t;)this._roots.pop();for(var n=0;n=this._roots.length){var r=new Vf(this._mesh,this.depth,n);this.add(r),this._roots.push(r)}else{var i=this._roots[n];i.depth=this.depth,i.update()}this.position.copy(this._mesh.position),this.rotation.copy(this._mesh.rotation),this.scale.copy(this._mesh.scale)}}]),r}(),jf=new ur,Wf=new fn,Xf=_i.prototype.raycast;function Hf(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;try{Wf.getInverse(this.matrixWorld,!0)}catch(e){return}if(jf.copy(e.ray).applyMatrix4(Wf),!0===e.firstHitOnly){var n=this.geometry.boundsTree.raycastFirst(this,e,jf);n&&t.push(n)}else this.geometry.boundsTree.raycast(this,e,jf,t)}else Xf.call(this,e,t)}function Yf(e){return this.boundsTree=new Bf(this,e),this.boundsTree}function qf(){this.boundsTree=null}var Qf,Zf,Kf,Jf,$f,em,tm,nm,rm,im,am,om,sm,lm,cm,um,dm,hm,pm,fm,mm,vm,gm,ym,xm,_m,bm,wm,Mm,Am,Sm=["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","gradientMap","lightMap","map","metalnessMap","normalMap","roughnessMap","specularMap"],Tm={disposeTextures:function(t){if(Sm.forEach(function(e){t[e]&&t[e].isTexture&&t[e].dispose()}),"MeshNodeMaterial"==t.type)for(var e in t.nodeTextures)t.nodeTextures[e]&&t.nodeTextures[e].dispose()}};function Em(){this.name="",this.type="Constraint",this.mute=!1}function Pm(e){Em.call(this),this.type="TargetConstraint",this.target=e}function Cm(e){Pm.call(this,e),this.type="ChildOfConstraint",this.offsetMatrix=new fn}function Lm(e){Pm.call(this,e),this.type="CopyLocationConstraint"}function Rm(e){Pm.call(this,e),this.type="CopyRotationConstraint"}function Dm(e){Pm.call(this,e),this.type="CopyScaleConstraint"}function Om(e){Pm.call(this,e),this.type="FloorConstraint",this.floorLocation="Y",this.offset=0}function Nm(){Em.call(this),this.type="LimitLocationConstraint",this.min=(new on).setScalar(-1/0),this.max=(new on).setScalar(1/0)}function Fm(){Em.call(this),this.type="LimitRotationConstraint",this.axis="Y",this.min=0,this.max=2*Math.PI}function Im(){Em.call(this),this.type="LimitScaleConstraint",this.min=(new on).setScalar(-1/0),this.max=(new on).setScalar(1/0)}function Bm(e){Pm.call(this,e),this.type="LockedTrackConstraint",this.trackAxis="X",this.lockAxis="Y"}function Um(e){Pm.call(this,e),this.type="TrackToConstraint",this.trackAxis="X",this.upAxis="Y"}Object.assign(Em.prototype,{isConstraint:!0,update:function(e){this.mute},copy:function(e){return this.name=e.name,this.mute=e.mute,this},clone:function(){return(new this.constructor).copy(this)}}),Pm.prototype=Object.assign(Object.create(Em.prototype),{constructor:Pm,isTargetConstraint:!0,copy:function(e){Em.prototype.copy.call(this,e),this.target=e.target}}),Cm.prototype=Object.assign(Object.create(Pm.prototype),{constructor:Cm,isChildOfConstraint:!0,copy:function(e){Pm.prototype.copy.call(this,e),this.offsetMatrix.copy(e.offsetMatrix)},update:(Qf=new fn,Zf=(new nn).setFromAxisAngle(new on(1,0,0),-Math.PI/2),function(e){Pm.prototype.update.call(this,e),this.mute||(Qf.multiplyMatrices(this.target.matrixWorld,this.offsetMatrix),Qf.decompose(e.position,e.quaternion,e.scale),e.isCamera&&e.quaternion.multiply(Zf))})}),Lm.prototype=Object.assign(Object.create(Pm.prototype),{constructor:Lm,isCopyLocationConstraint:!0,update:(Kf=new nn,Jf=new on,function(e){Pm.prototype.update.call(this,e),this.mute||(this.target.matrixWorld.decompose(e.position,Kf,Jf),e.parent&&e.parent.worldToLocal(e.position))})}),Rm.prototype=Object.assign(Object.create(Pm.prototype),{constructor:Rm,isCopyRotationConstraint:!0,update:($f=new on,em=new nn,tm=new on,nm=(new nn).setFromAxisAngle(new on(1,0,0),-Math.PI/2),function(e){Pm.prototype.update.call(this,e),this.mute||(this.target.matrixWorld.decompose($f,e.quaternion,tm),e.parent&&(e.parent.matrixWorld.decompose($f,em,tm),e.quaternion.premultiply(em.inverse())),e.isCamera&&e.quaternion.multiply(nm))})}),Dm.prototype=Object.assign(Object.create(Pm.prototype),{constructor:Dm,isCopyScaleConstraint:!0,update:function(e){Pm.prototype.update.call(this,e),this.mute||e.scale.copy(this.target.scale)}}),Om.prototype=Object.assign(Object.create(Pm.prototype),{constructor:Om,isFloorConstraint:!0,copy:function(e){Pm.prototype.copy.call(this,e),this.floorLocation=e.floorLocation,this.offset=e.offset},update:function(e){if(Pm.prototype.update.call(this,e),!this.mute){var t=e.position,n=this.target.position,r=this.offset;switch(this.floorLocation){case"X":t.x=Math.max(t.x,n.x+r);break;case"Y":t.y=Math.max(t.y,n.y+r);break;case"Z":t.z=Math.max(t.z,n.z+r);break;case"-X":t.x=Math.min(t.x,n.x+r);break;case"-Y":t.y=Math.min(t.y,n.y+r);break;case"-Z":t.z=Math.min(t.z,n.z+r)}}}}),Nm.prototype=Object.assign(Object.create(Em.prototype),{constructor:Nm,isLimitLocationConstraint:!0,copy:function(e){Em.prototype.copy.call(this,e),this.min.copy(e.min),this.max.copy(e.max)},update:function(e){Em.prototype.update.call(this,e),this.mute||e.position.clamp(this.min,this.max)}}),Fm.prototype=Object.assign(Object.create(Em.prototype),{constructor:Fm,isLimitRotationConstraint:!0,copy:function(e){Em.prototype.copy.call(this,e),this.axis=e.axis,this.min=e.min,this.max=e.max},update:(rm=new gn,function(e){Em.prototype.update.call(this,e),this.mute||("X"==this.axis?(rm.setFromQuaternion(e.quaternion,"XYZ"),rm.x=this._clampAngle(rm.x,this.min,this.max)):"Y"==this.axis?(rm.setFromQuaternion(e.quaternion,"YZX"),rm.y=this._clampAngle(rm.y,this.min,this.max)):"Z"==this.axis&&(rm.setFromQuaternion(e.quaternion,"ZXY"),rm.z=this._clampAngle(rm.z,this.min,this.max)),e.quaternion.setFromEuler(rm))}),_clampAngle:function(e,t,n){return Math.abs(n-t)<2*Math.PI&&(e=Yt.clampAngle(e,t,n)),e}}),Im.prototype=Object.assign(Object.create(Em.prototype),{constructor:Im,isLimitScaleConstraint:!0,copy:function(e){Em.prototype.copy.call(this,e),this.min.copy(e.min),this.max.copy(e.max)},update:function(e){Em.prototype.update.call(this,e),this.mute||e.scale.clamp(this.min,this.max)}}),Bm.prototype=Object.assign(Object.create(Pm.prototype),{constructor:Bm,isLockedTrackConstraint:!0,copy:function(e){Pm.prototype.copy.call(this,e),this.trackAxis=e.trackAxis,this.lockAxis=e.lockAxis},update:(im=new on,am=new on,om=new on,sm=new on,lm=new on,cm=new fr,um=new on,dm=new on,hm=new nn,pm=(new nn).setFromAxisAngle(new on(1,0,0),-Math.PI/2),function(e){if(Pm.prototype.update.call(this,e),!this.mute&&(om.set("X"==this.trackAxis?1:"-X"==this.trackAxis?-1:0,"Y"==this.trackAxis?1:"-Y"==this.trackAxis?-1:0,"Z"==this.trackAxis?1:"-Z"==this.trackAxis?-1:0),sm.set("X"==this.lockAxis?1:0,"Y"==this.lockAxis?1:0,"Z"==this.lockAxis?1:0),1!=Math.abs(om.dot(sm)))){im.setFromMatrixPosition(e.matrixWorld),am.setFromMatrixPosition(this.target.matrixWorld),cm.setFromNormalAndCoplanarPoint(sm,im),cm.projectPoint(am,lm).sub(im);var t=0Math.abs(s)&&(A+=i,S=c.zoomSpeedTouch,T=c.zoomInertiaTouch),c.enablePan&&Math.abs(i)<=Math.abs(s)&&(L.add(o),R=c.panSpeedTouch,D=c.panInertiaTouch)}}}function ae(e){if(!1!==c.enabled){switch(e.touches.length){case 0:h=a.NONE;break;case 1:if(!1===c.enableRotate)return;h=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 on,function(){if(F){var e=G.getElapsedTime()/V;if(e=Yt.smootherstep(e,0,1),c.object.position.lerpVectors(B,z,e),c.object.lookAt(Y.lerpVectors(U,k,e)),1<=e){for(var t in F=!1,I(),g.set(0,0,0),y.set(0,0),A=M=0,C.set(0,0),L.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,M):c.object.isOrthographicCamera&&(c.object.zoom*=1+.15*M,c.object.updateProjectionMatrix()),i.copy(p).cross(c.object.up).setLength(-C.x),i.add(o.copy(c.object.up).setLength(C.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?Yt.expAverage(y.x,0,e,_):0,y.y=c.enableDamping?Yt.expAverage(y.y,0,e,_):0,g.set(g.radius,g.phi-y.y,g.theta-y.x),C.copy(L),L.x=c.enableDamping?Yt.expAverage(L.x,0,e,D):0,L.y=c.enableDamping?Yt.expAverage(L.y,0,e,D):0,C.sub(L),C.multiplyScalar(R),M=A,A=c.enableDamping?Yt.expAverage(A,0,e,T):0,M-=A,M*=S,f){var n=t==zm.A||t==zm.LEFT_ARROW||t==zm.D||t==zm.RIGHT_ARROW,r=t==zm.W||t==zm.UP_ARROW||t==zm.S||t==zm.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]=Yt.expAverage(f[t],0,e,i),o=s-f[t]}c.enabled&&(n&&!c.enablePan||r&&!c.enableZoom||(o*=60*e*a,t==zm.A||t==zm.LEFT_ARROW?C.x+=o:t==zm.D||t==zm.RIGHT_ARROW?C.x-=o:t==zm.W||t==zm.UP_ARROW?M+=o:t!=zm.S&&t!=zm.DOWN_ARROW||(M-=o)))}}();var n=!1;1e-6g||8*(1-l.dot(d.object.quaternion))>g)||(d.dispatchEvent(h),s.copy(d.object.position),l.copy(d.object.quaternion),w=!1))}),this.dispose=function(){d.domElement.removeEventListener("contextmenu",fe,!1),d.domElement.removeEventListener("mousedown",se,!1),d.domElement.removeEventListener("wheel",ue,!1),d.domElement.removeEventListener("touchstart",de,!1),d.domElement.removeEventListener("touchend",pe,!1),d.domElement.removeEventListener("touchmove",he,!1),document.removeEventListener("mousemove",le,!1),document.removeEventListener("mouseup",ce,!1),document.removeEventListener("mouseleave",ce,!1),A.dispose()},this.tween=(c=new on,u=new on,function(e,t,n,r){d.targetObj.updateWorldMatrix(!0,!1),u.setFromMatrixPosition(d.targetObj.matrixWorld),d.object.parent&&(e=c.copy(e),d.object.parent.worldToLocal(e)),e.manhattanDistanceTo(d.object.position)<1e-5&&t.manhattanDistanceTo(u)<1e-5||(d.inTween=!0,d.tweenCallback="function"==typeof r?r:function(){},G.copy(d.object.position),j.copy(u),W.copy(e),X.copy(t),H=n,Y.start())});var d=this,h={type:"change"},p={type:"start"},f={type:"end"},m={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},v=m.NONE,g=1e-6,y=new Yc,x=new Yc,_=1,b=new on,w=!1,M={};M[zm.W]=M[zm.S]=M[zm.A]=M[zm.D]=M[zm.UP_ARROW]=M[zm.DOWN_ARROW]=M[zm.LEFT_ARROW]=M[zm.RIGHT_ARROW]=0;var A=new km(window);A.onKeyDown=function(e){e.keyCode in M&&(M[e.keyCode]=1)};var S=new qt,T=new qt,E=new qt,P=new qt,C=1,L=1,R=new qt,D=new qt,O=new qt,N=new qt,F=new qt,I=new qt,B=new qt,U=1,z=1,k=1,V=new Zd,G=new on,j=new on,W=new on,X=new on,H=0,Y=new Zd;function q(){return Math.pow(.95,z)}function Q(e){x.theta-=e}function Z(e,t){T.set(e,t),P.add(T).sub(S),S.copy(T)}var K,J,$,ee,te=(K=new on,function(e,t){K.setFromMatrixColumn(t,0),K.multiplyScalar(-e),b.add(K)}),ne=(J=new on,function(e,t){J.setFromMatrixColumn(t,1),J.multiplyScalar(e),b.add(J)}),re=($=new on,ee=new on,function(e,t){var n=d.domElement===document?d.domElement.body:d.domElement,r=n.clientWidth,i=n.clientHeight;if(r&&i)if(d.object.isPerspectiveCamera){d.targetObj.updateWorldMatrix(!0,!1),ee.setFromMatrixPosition(d.targetObj.matrixWorld);var a=d.object.position;$.copy(a).sub(ee);var o=$.length();o*=Math.tan(d.object.fov/2*Yt.DEG2RAD),te(2*e*o/i,d.object.matrix),ne(2*t*o/i,d.object.matrix)}else d.object.isOrthographicCamera?(te(e*(d.object.right-d.object.left)/d.object.zoom/r,d.object.matrix),ne(t*(d.object.top-d.object.bottom)/d.object.zoom/i,d.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),d.enablePan=!1)});function ie(e){d.object.isPerspectiveCamera?U/=e:d.object.isOrthographicCamera?(U/=e,w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),d.enableZoom=!1)}function ae(e){d.object.isPerspectiveCamera?U*=e:d.object.isOrthographicCamera?(U*=e,w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),d.enableZoom=!1)}function oe(e){var t,n;t=e.clientX,n=e.clientY,D.set(t,n),N.add(D).sub(R),R.copy(D)}function se(e){if(!1!==d.enabled){switch(e.preventDefault(),e.button){case d.mouseButtons.ROTATE:if(!1===d.enableRotate)return;n=e,S.set(n.clientX,n.clientY),v=m.ROTATE;break;case d.mouseButtons.ZOOM:case d.mouseButtons.PAN:if(!1===d.enablePan)return;t=e,R.set(t.clientX,t.clientY),v=m.PAN}var t,n;v!==m.NONE&&(document.addEventListener("mousemove",le,!1),document.addEventListener("mouseup",ce,!1),document.addEventListener("mouseleave",ce,!1),d.dispatchEvent(p))}}function le(e){var t,n;if(!1!==d.enabled)switch(e.preventDefault(),v){case m.ROTATE:if(!1===d.enableRotate)return;Z((n=e).clientX,n.clientY),C=d.rotateSpeed,L=d.rotateInertia;break;case m.DOLLY:if(!1===d.enableZoom)return;t=e,I.set(t.clientX,t.clientY),B.subVectors(I,F),0Math.abs(O.length())&&(0').concat("MADE WITH VERGE3D TRIAL",""),t.appendChild(r),setTimeout(function(){t.contains(r)&&890310108==Yt.hashString(r.textContent)||e.dispose()},1e3)}},isXML:function(e){return null!==e.match(/.*\.xml$/)},isJS:function(e){return null!==e.match(/.*\.js$/)},createLineObjectHTML:function(m,v,g,e,t,y){console.warn("v3d.AppUtils.createLineObjectHTML has been deprecated. Use v3d.LineHTML instead."),e=e||2,t=t?t.convertSRGBToLinear():new v3d.Color(1,0,.2),y=y||5;var x=new v3d.Vector3(1,0,0),n=new v3d.MeshLine;n.setGeometry([0,0,0,x.x,x.y,x.z]);var r=new v3d.MeshLineMaterial({color:t,lineWidth:e,sizeAttenuation:0}),_=new v3d.Mesh(n.geometry,r);_.name=v.name+"_LINE",v.add(_);var b=new v3d.Vector3,w=new v3d.Vector3,M=new v3d.Quaternion;m.renderCallbacks.push(function(){m.camera.updateMatrixWorld(),v.traverseAncestors(function(e){e.updateMatrixWorld()});var e=g.getBoundingClientRect(),t=(e.left+e.right)/2,n=(e.top+e.bottom)/2,r=v.getWorldPosition(b);r.project(m.camera);var i=(r.x+1)/2*m.getWidth(),a=(1-r.y)/2*m.getHeight(),o=(n-a)/(t-i),s=(e.height+2*y)/(e.width+2*y);if(Math.abs(o)>s)var l=((c=nClick here to enable iOS VR mode',t.onclick=function(){window.DeviceMotionEvent.requestPermission().then(function(e){"granted"==e?console.log("DeviceMotion permissions granted"):console.log("DeviceMotion permissions not granted"),document.querySelector("body").removeChild(t)}).catch(function(){console.error(e)})},document.querySelector("body").appendChild(t)}}};function qm(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}function Qm(e){this._mesh=new _i(Hm,e)}function Zm(e,t,n,r,i){qm.call(this),this.strength=void 0!==t?t:1,this.radius=n,this.threshold=r,this.resolution=void 0!==e?new qt(e.x,e.y):new qt(256,256),i=i||{minFilter:$e,magFilter:$e,format:ct},this.clearColor=new Cr(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;var a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new en(a,o,i),this.renderTargetBright.texture.name="BloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(var s=0;s>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>>0)a(0|e,0|t,0|n);else{r=e+n|0;e:if(3&(e^t))if(r>>>0<4)n=e;else if((i=r-4|0)>>>0>>0)n=e;else for(n=e;_[0|n]=w[0|t],_[n+1|0]=w[t+1|0],_[n+2|0]=w[t+2|0],_[n+3|0]=w[t+3|0],t=t+4|0,(n=n+4|0)>>>0<=i>>>0;);else{t:if((0|n)<1)n=e;else if(3&e)for(n=e;;){if(_[0|n]=w[0|t],t=t+1|0,r>>>0<=(n=n+1|0)>>>0)break t;if(!(3&n))break}else n=e;if(!((e=-4&r)>>>0<64||(i=e+-64|0)>>>0>>0))for(;b[n>>2]=b[t>>2],b[n+4>>2]=b[t+4>>2],b[n+8>>2]=b[t+8>>2],b[n+12>>2]=b[t+12>>2],b[n+16>>2]=b[t+16>>2],b[n+20>>2]=b[t+20>>2],b[n+24>>2]=b[t+24>>2],b[n+28>>2]=b[t+28>>2],b[n+32>>2]=b[t+32>>2],b[n+36>>2]=b[t+36>>2],b[n+40>>2]=b[t+40>>2],b[n+44>>2]=b[t+44>>2],b[n+48>>2]=b[t+48>>2],b[n+52>>2]=b[t+52>>2],b[n+56>>2]=b[t+56>>2],b[n+60>>2]=b[t+60>>2],t=t- -64|0,(n=n- -64|0)>>>0<=i>>>0;);if(e>>>0<=n>>>0)break e;for(;b[n>>2]=b[t>>2],t=t+4|0,(n=n+4|0)>>>0>>0;);}if(n>>>0>>0)for(;_[0|n]=w[0|t],t=t+1|0,(0|r)!=(0|(n=n+1|0)););}}function T(e,t,n){if(n^=-1,t)for(;n=b[1056+((w[0|e]^255&n)<<2)>>2]^n>>>8,e=e+1|0,t=t+-1|0;);return-1^n}function o(e){var t=0;e&&(t=b[e+1200>>2],b[t+60>>2]&&s(b[t+24>>2]),s(t),s(e))}function p(e){var t;return(0|(e=(t=b[263312])+(e+3&-4)|0))<=-1?(b[263185]=48,-1):e>>>0<=(n.byteLength/65536|0)<<16>>>0||i(0|e)?(b[263312]=e,t):(b[263185]=48,-1)}function s(e){var t=0,n=0,r=0,i=0,a=0,o=0,s=0;e:if(e){a=(r=e+-8|0)+(e=-8&(n=b[e+-4>>2]))|0;t:if(!(1&n)){if(!(3&n))break e;if((r=r-(n=b[r>>2])|0)>>>0>2])))return b[263188]=e,b[a+4>>2]=-2&n,b[r+4>>2]=1|e,void(b[e+r>>2]=e)}else{if(n>>>0<=255){if(i=b[r+8>>2],n=n>>>3|0,(0|(t=b[r+12>>2]))==(0|i)){b[263186]=b[263186]&v(n);break t}b[i+12>>2]=t,b[t+8>>2]=i;break t}if(s=b[r+24>>2],(0|r)==(0|(n=b[r+12>>2])))if((t=b[(i=r+20|0)>>2])||(t=b[(i=r+16|0)>>2])){for(;o=i,(t=b[(i=(n=t)+20|0)>>2])||(i=n+16|0,t=b[n+16>>2]););b[o>>2]=0}else n=0;else t=b[r+8>>2],b[t+12>>2]=n,b[n+8>>2]=t;if(!s)break t;i=b[r+28>>2];n:{if(b[(t=1053048+(i<<2)|0)>>2]==(0|r)){if(b[t>>2]=n)break n;b[263187]=b[263187]&v(i);break t}if(!(b[s+(b[s+16>>2]==(0|r)?16:20)>>2]=n))break t}if(b[n+24>>2]=s,(t=b[r+16>>2])&&(b[n+16>>2]=t,b[t+24>>2]=n),!(t=b[r+20>>2]))break t;b[n+20>>2]=t,b[t+24>>2]=n}}if(!(a>>>0<=r>>>0)&&1&(n=b[a+4>>2])){t:{if(!(2&n)){if(b[263192]==(0|a)){if(b[263192]=r,e=b[263189]+e|0,b[263189]=e,b[r+4>>2]=1|e,b[263191]!=(0|r))break e;return b[263188]=0,void(b[263191]=0)}if(b[263191]==(0|a))return b[263191]=r,e=b[263188]+e|0,b[263188]=e,b[r+4>>2]=1|e,void(b[e+r>>2]=e);e=(-8&n)+e|0;n:if(n>>>0<=255){if(n=n>>>3|0,(0|(t=b[a+8>>2]))==(0|(i=b[a+12>>2]))){b[263186]=b[263186]&v(n);break n}b[t+12>>2]=i,b[i+8>>2]=t}else{if(s=b[a+24>>2],(0|a)==(0|(n=b[a+12>>2])))if((t=b[(i=a+20|0)>>2])||(t=b[(i=a+16|0)>>2])){for(;o=i,(t=b[(i=(n=t)+20|0)>>2])||(i=n+16|0,t=b[n+16>>2]););b[o>>2]=0}else n=0;else t=b[a+8>>2],b[t+12>>2]=n,b[n+8>>2]=t;if(s){i=b[a+28>>2];r:{if(b[(t=1053048+(i<<2)|0)>>2]==(0|a)){if(b[t>>2]=n)break r;b[263187]=b[263187]&v(i);break n}if(!(b[s+(b[s+16>>2]==(0|a)?16:20)>>2]=n))break n}b[n+24>>2]=s,(t=b[a+16>>2])&&(b[n+16>>2]=t,b[t+24>>2]=n),(t=b[a+20>>2])&&(b[n+20>>2]=t,b[t+24>>2]=n)}}if(b[r+4>>2]=1|e,b[e+r>>2]=e,b[263191]!=(0|r))break t;return void(b[263188]=e)}b[a+4>>2]=-2&n,b[r+4>>2]=1|e,b[e+r>>2]=e}if(e>>>0<=255)return n=1052784+((e=e>>>3|0)<<3)|0,e=(t=b[263186])&(e=1<>2]:(b[263186]=e|t,n),b[n+8>>2]=r,b[e+12>>2]=r,b[r+12>>2]=n,void(b[r+8>>2]=e);b[r+16>>2]=0,t=b[r+20>>2]=0,(i=e>>>8|0)&&(t=31,16777215>>0||(t=i,t<<=i=i+1048320>>>16&8,t=28+((t=((t<<=s=t+520192>>>16&4)<<(o=t+245760>>>16&2)>>>15|0)-(o|i|s)|0)<<1|e>>>t+21&1)|0)),o=1053048+((b[(n=r)+28>>2]=t)<<2)|0;t:{n:{if((i=b[263187])&(n=1<>>1|0)|0),n=b[o>>2];;){if((-8&b[(t=n)+4>>2])==(0|e))break n;if(n=i>>>29|0,i<<=1,!(n=b[16+(o=t+(4&n)|0)>>2]))break}b[o+16>>2]=r,b[r+24>>2]=t}else b[263187]=n|i,b[o>>2]=r,b[r+24>>2]=o;b[r+12>>2]=r,b[r+8>>2]=r;break t}e=b[t+8>>2],b[e+12>>2]=r,b[t+8>>2]=r,b[r+24>>2]=0,b[r+12>>2]=t,b[r+8>>2]=e}if(e=b[263194]+-1|0,!(b[263194]=e)){for(r=1053200;r=(e=b[r>>2])+8|0,e;);b[263194]=-1}}}}function E(e,t){var n=0;if(t&&(_[(n=e+t|0)-1|0]=0,!(t>>>(_[0|e]=0)<3||(_[n+-2|0]=0,_[e+1|0]=0,_[n+-3|0]=0,t>>>(_[e+2|0]=0)<7||(_[n+-4|0]=0,t>>>(_[e+3|0]=0)<9||(b[(e=(n=0-e&3)+e|0)>>2]=0,(n=t-n&-4)>>>(b[(t=n+e|0)-4>>2]=0)<9||(b[e+8>>2]=0,b[e+4>>2]=0,b[t+-8>>2]=0,n>>>(b[t+-12>>2]=0)<25||(b[e+24>>2]=0,b[e+20>>2]=0,b[e+16>>2]=0,b[e+12>>2]=0,b[t+-16>>2]=0,b[t+-20>>2]=0,b[t+-24>>2]=0,b[t+-28>>2]=0,(t=(t=n)-(n=4&e|24)|0)>>>0<32))))))))for(e=e+n|0;b[e+24>>2]=0,b[e+28>>2]=0,b[e+16>>2]=0,b[e+20>>2]=0,b[e+8>>2]=0,b[e+12>>2]=0,b[e>>2]=0,e=e+32|(b[e+4>>2]=0),31<(t=t+-32|0)>>>0;);}function l(e){var t,n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,d=0;h=t=h-16|0;e:{t:{n:{r:{i:{a:{o:{s:{l:{c:{u:{if(e>>>0<=244){if(3&(n=(o=b[263186])>>>(e=(s=e>>>0<11?16:e+11&-8)>>>3|0)|0)){e=(n=b[1052792+(a=(r=e+(1&(-1^n))|0)<<3)>>2])+8|0,(0|(i=b[n+8>>2]))!=(0|(a=a+1052784|0))?(b[i+12>>2]=a,b[a+8>>2]=i):b[263186]=v(r)&o,r<<=3,b[n+4>>2]=3|r,b[4+(n=n+r|0)>>2]=1|b[n+4>>2];break e}if(s>>>0<=(c=b[263188])>>>0)break u;if(n){r=n=(e=(0-(e=(0-(r=2<>>12&16,r|=n=(e=e>>>n|0)>>>5&8,r|=n=(e=e>>>n|0)>>>2&4,n=b[1052792+(i=(r=((r|=n=(e=e>>>n|0)>>>1&2)|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)|0)<<3)>>2],(0|(e=b[n+8>>2]))!=(0|(i=i+1052784|0))?(b[e+12>>2]=i,b[i+8>>2]=e):(o=v(r)&o,b[263186]=o),e=n+8|0,b[n+4>>2]=3|s,a=(r<<=3)-s|0,b[4+(l=n+s|0)>>2]=1|a,b[n+r>>2]=a,c&&(n=1052784+((r=c>>>3|0)<<3)|0,i=b[263191],r=(r=1<>2]:(b[263186]=r|o,n),b[n+8>>2]=i,b[r+12>>2]=i,b[i+12>>2]=n,b[i+8>>2]=r),b[263191]=l,b[263188]=a;break e}if(!(d=b[263187]))break u;for(r=n=(e=(d&0-d)-1|0)>>>12&16,r|=n=(e=e>>>n|0)>>>5&8,r|=n=(e=e>>>n|0)>>>2&4,n=b[1053048+(((r|=n=(e=e>>>n|0)>>>1&2)|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)<<2)>>2],i=(-8&b[n+4>>2])-s|0,r=n;e=(e=b[r+16>>2])||b[r+20>>2];)i=(r=(a=(-8&b[e+4>>2])-s|0)>>>0>>0)?a:i,n=r?e:n,r=e;if(u=b[n+24>>2],(0|(a=b[n+12>>2]))!=(0|n)){e=b[n+8>>2],b[e+12>>2]=a,b[a+8>>2]=e;break t}if(!(e=b[(r=n+20|0)>>2])){if(!(e=b[n+16>>2]))break c;r=n+16|0}for(;l=r,(e=b[(r=(a=e)+20|0)>>2])||(r=a+16|0,e=b[a+16>>2]););b[l>>2]=0;break t}if(s=-1,!(4294967231>>0)&&(s=-8&(n=e+11|0),c=b[263187])){r=0-s|0,(n=n>>>8|(o=0))&&(o=31,16777215>>0||(o=28+((e=((o=(n<<=i=n+1048320>>>16&8)<<(e=n+520192>>>16&4))<<(n=o+245760>>>16&2)>>>15|0)-(n|e|i)|0)<<1|s>>>e+21&1)|0));d:{h:{if(i=b[1053048+(o<<2)>>2])for(n=s<<(31==(0|o)?0:25-(o>>>1|0)|0),e=0;;){if(!(r>>>0<=(l=(-8&b[i+4>>2])-s|0)>>>0||(a=i,r=l))){r=0,e=i;break h}if(l=b[i+20>>2],i=b[16+((n>>>29&4)+i|0)>>2],e=l?(0|l)==(0|i)?e:l:e,n<<=0!=(0|i),!i)break}else e=0;if(!(e|a)){if(!(e=(0-(e=2<>>12&16,i|=n=(e=e>>>n|0)>>>5&8,i|=n=(e=e>>>n|0)>>>2&4,e=b[1053048+(((i|=n=(e=e>>>n|0)>>>1&2)|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)<<2)>>2]}if(!e)break d}for(;r=(n=(i=(-8&b[e+4>>2])-s|0)>>>0>>0)?i:r,a=n?e:a,e=(n=b[e+16>>2])||b[e+20>>2];);}if(!(!a|r>>>0>=b[263188]-s>>>0)){if(l=b[a+24>>2],(0|a)!=(0|(n=b[a+12>>2]))){e=b[a+8>>2],b[e+12>>2]=n,b[n+8>>2]=e;break n}if(!(e=b[(i=a+20|0)>>2])){if(!(e=b[a+16>>2]))break l;i=a+16|0}for(;o=i,(e=b[(i=(n=e)+20|0)>>2])||(i=n+16|0,e=b[n+16>>2]););b[o>>2]=0;break n}}}if(s>>>0<=(n=b[263188])>>>0){e=b[263191],16<=(r=n-s|0)>>>0?(b[263188]=r,i=e+s|0,b[263191]=i,b[i+4>>2]=1|r,b[e+n>>2]=r,b[e+4>>2]=3|s):(b[263191]=0,b[263188]=0,b[e+4>>2]=3|n,b[4+(n=e+n|0)>>2]=1|b[n+4>>2]),e=e+8|0;break e}if(s>>>0<(i=b[263189])>>>0){n=i-s|0,b[263189]=n,r=(e=b[263192])+s|0,b[263192]=r,b[r+4>>2]=1|n,b[e+4>>2]=3|s,e=e+8|0;break e}if((r=(o=(r=a=s+47|(e=0))+(n=b[263304]?b[263306]:(b[263307]=-1,b[263308]=-1,b[263305]=4096,b[263306]=4096,b[263304]=12+t&-16^1431655768,b[263309]=0,b[263297]=0,4096))|0)&(l=0-n|0))>>>0<=s>>>0)break e;if((n=b[263296])&&(u=(c=b[263294])+r|0)>>>0<=c>>>0|n>>>0>>0)break e;if(4&w[1053188])break a;u:{d:{if(n=b[263192])for(e=1053192;;){if((c=b[e>>2])+b[e+4>>2]>>>0>n>>>0&&c>>>0<=n>>>0)break d;if(!(e=b[e+8>>2]))break}if(-1==(0|(n=p(0))))break o;if(o=r,(i=(e=b[263305])+-1|0)&n&&(o=(r-n|0)+(n+i&0-e)|0),o>>>0<=s>>>0|2147483646>>0)break o;if((e=b[263296])&&(l=(i=b[263294])+o|0)>>>0<=i>>>0|e>>>0>>0)break o;if((0|n)!=(0|(e=p(o))))break u;break i}if(2147483646<(o=l&o-i)>>>0)break o;if((0|(n=p(o)))==(b[e>>2]+b[e+4>>2]|0))break s;e=n}if(!(s+48>>>0<=o>>>0|2147483646>>0|-1==(0|(n=e)))){if(2147483646<(e=(e=b[263306])+(a-o|0)&0-e)>>>0)break i;if(-1!=(0|p(e))){o=e+o|0;break i}p(0-o|0);break o}if(-1!=(0|n))break i;break o}a=0;break t}n=0;break n}if(-1!=(0|n))break i}b[263297]=4|b[263297]}if(2147483646>>0)break r;if(n=p(r),(e=p(0))>>>0<=n>>>0|-1==(0|n)|-1==(0|e))break r;if((o=e-n|0)>>>0<=s+40>>>0)break r}e=b[263294]+o|0,(b[263294]=e)>>>0>M[263295]&&(b[263295]=e);i:{a:{o:{if(r=b[263192]){for(e=1053192;;){if(((i=b[e>>2])+(a=b[e+4>>2])|0)==(0|n))break o;if(!(e=b[e+8>>2]))break}break a}for((e=b[263190])>>>0<=n>>>0&&e||(b[263190]=n),e=0,b[263299]=o,b[263298]=n,b[263194]=-1,b[263195]=b[263304],b[263301]=0;i=1052784+(r=e<<3)|0,b[r+1052792>>2]=i,b[r+1052796>>2]=i,32!=(0|(e=e+1|0)););i=(e=o+-40|0)-(r=n+8&7?-8-n&7:0)|0,b[263189]=i,r=n+r|0,b[263192]=r,b[r+4>>2]=1|i,b[4+(e+n|0)>>2]=40,b[263193]=b[263308];break i}if(!(8&w[e+12|0]|n>>>0<=r>>>0|r>>>0>>0)){b[e+4>>2]=a+o,n=(e=r+8&7?-8-r&7:0)+r|0,b[263192]=n,e=(i=b[263189]+o|0)-e|0,b[263189]=e,b[n+4>>2]=1|e,b[4+(r+i|0)>>2]=40,b[263193]=b[263308];break i}}n>>>0<(a=b[263190])>>>0&&(b[263190]=n,a=0),i=n+o|0,e=1053192;a:{o:{s:{l:{c:{u:{for(;(0|i)!=b[e>>2];)if(!(e=b[e+8>>2]))break u;if(!(8&w[e+12|0]))break c}for(e=1053192;;){if((i=b[e>>2])>>>0<=r>>>0&&r>>>0<(a=i+b[e+4>>2]|0)>>>0)break l;e=b[e+8>>2]}}if(b[e>>2]=n,b[e+4>>2]=b[e+4>>2]+o,b[4+(u=(n+8&7?-8-n&7:0)+n|0)>>2]=3|s,e=((n=i+(i+8&7?-8-i&7:0)|0)-u|0)-s|0,l=s+u|0,(0|n)==(0|r)){b[263192]=l,e=b[263189]+e|0,b[263189]=e,b[l+4>>2]=1|e;break o}if(b[263191]==(0|n)){b[263191]=l,e=b[263188]+e|0,b[263188]=e,b[l+4>>2]=1|e,b[e+l>>2]=e;break o}if(1==(3&(r=b[n+4>>2]))){d=-8&r;c:if(r>>>0<=255){if(a=r>>>3|0,r=b[n+8>>2],(0|(i=b[n+12>>2]))==(0|r)){b[263186]=b[263186]&v(a);break c}b[r+12>>2]=i,b[i+8>>2]=r}else{if(c=b[n+24>>2],(0|(o=b[n+12>>2]))==(0|n))if((s=b[(i=n+20|0)>>2])||(s=b[(i=n+16|0)>>2])){for(;r=i,(s=b[(i=(o=s)+20|0)>>2])||(i=o+16|0,s=b[o+16>>2]););b[r>>2]=0}else o=0;else r=b[n+8>>2],b[r+12>>2]=o,b[o+8>>2]=r;if(c){r=b[n+28>>2];u:{if(b[(i=1053048+(r<<2)|0)>>2]==(0|n)){if(b[i>>2]=o)break u;b[263187]=b[263187]&v(r);break c}if(!(b[c+(b[c+16>>2]==(0|n)?16:20)>>2]=o))break c}b[o+24>>2]=c,(r=b[n+16>>2])&&(b[o+16>>2]=r,b[r+24>>2]=o),(r=b[n+20>>2])&&(b[o+20>>2]=r,b[r+24>>2]=o)}}n=n+d|0,e=e+d|0}if(b[n+4>>2]=-2&b[n+4>>2],b[l+4>>2]=1|e,(b[e+l>>2]=e)>>>0<=255){e=1052784+((n=e>>>3|0)<<3)|0,n=(r=b[263186])&(n=1<>2]:(b[263186]=n|r,e),b[e+8>>2]=l,b[n+12>>2]=l,b[l+12>>2]=e,b[l+8>>2]=n;break o}if((i=e>>>8|(n=0))&&(n=31,16777215>>0||(n=28+((n=((s=(i<<=a=i+1048320>>>16&8)<<(n=i+520192>>>16&4))<<(i=s+245760>>>16&2)>>>15|0)-(i|n|a)|0)<<1|e>>>n+21&1)|0)),b[(r=l)+28>>2]=n,b[l+16>>2]=0,r=1053048+(n<<2)|(b[l+20>>2]=0),(i=b[263187])&(a=1<>>1|0)|0),n=b[r>>2];;){if((-8&b[(r=n)+4>>2])==(0|e))break s;if(n=i>>>29|0,i<<=1,!(n=b[16+(a=(4&n)+r|0)>>2]))break}b[a+16>>2]=l}else b[263187]=i|a,b[r>>2]=l;b[l+24>>2]=r,b[l+12>>2]=l,b[l+8>>2]=l;break o}for(l=(e=o+-40|0)-(i=n+8&7?-8-n&7:0)|0,b[263189]=l,i=n+i|0,b[263192]=i,b[i+4>>2]=1|l,b[4+(e+n|0)>>2]=40,b[263193]=b[263308],b[(i=(e=(a+(a+-39&7?39-a&7:0)|0)-47|0)>>>0>>0?r:e)+4>>2]=27,e=b[263301],b[i+16>>2]=b[263300],b[i+20>>2]=e,e=b[263299],b[i+8>>2]=b[263298],b[i+12>>2]=e,b[263300]=i+8,b[263299]=o,b[263298]=n,e=i+24|(b[263301]=0);b[e+4>>2]=7,n=e+8|0,e=e+4|0,n>>>0>>0;);if((0|r)==(0|i))break i;if(b[i+4>>2]=-2&b[i+4>>2],a=i-r|0,b[r+4>>2]=1|a,(b[i>>2]=a)>>>0<=255){e=1052784+((n=a>>>3|0)<<3)|0,n=(i=b[263186])&(n=1<>2]:(b[263186]=n|i,e),b[e+8>>2]=r,b[n+12>>2]=r,b[r+12>>2]=e,b[r+8>>2]=n;break i}if(b[r+16>>2]=0,e=b[r+20>>2]=0,(i=a>>>8|0)&&(e=31,16777215>>0||(e=28+((e=((l=(i<<=o=i+1048320>>>16&8)<<(e=i+520192>>>16&4))<<(i=l+245760>>>16&2)>>>15|0)-(i|e|o)|0)<<1|a>>>e+21&1)|0)),n=1053048+((b[(n=r)+28>>2]=e)<<2)|0,(i=b[263187])&(o=1<>>1|0)|0),n=b[n>>2];;){if((0|a)==(-8&b[(i=n)+4>>2]))break a;if(n=e>>>29|0,e<<=1,!(n=b[16+(o=i+(4&n)|0)>>2]))break}b[o+16>>2]=r,b[r+24>>2]=i}else b[263187]=i|o,b[n>>2]=r,b[r+24>>2]=n;b[r+12>>2]=r,b[r+8>>2]=r;break i}e=b[r+8>>2],b[e+12>>2]=l,b[r+8>>2]=l,b[l+24>>2]=0,b[l+12>>2]=r,b[l+8>>2]=e}e=u+8|0;break e}e=b[i+8>>2],b[e+12>>2]=r,b[i+8>>2]=r,b[r+24>>2]=0,b[r+12>>2]=i,b[r+8>>2]=e}if(!((e=b[263189])>>>0<=s>>>0)){n=e-s|0,b[263189]=n,r=(e=b[263192])+s|0,b[263192]=r,b[r+4>>2]=1|n,b[e+4>>2]=3|s,e=e+8|0;break e}}b[263185]=48,e=0;break e}n:if(l){e=b[a+28>>2];r:{if(b[(i=1053048+(e<<2)|0)>>2]==(0|a)){if(b[i>>2]=n)break r;c=v(e)&c,b[263187]=c;break n}if(!(b[l+(b[l+16>>2]==(0|a)?16:20)>>2]=n))break n}b[n+24>>2]=l,(e=b[a+16>>2])&&(b[n+16>>2]=e,b[e+24>>2]=n),(e=b[a+20>>2])&&(b[n+20>>2]=e,b[e+24>>2]=n)}n:if(r>>>0<=15)e=r+s|0,b[a+4>>2]=3|e,b[4+(e=e+a|0)>>2]=1|b[e+4>>2];else if(b[a+4>>2]=3|s,b[4+(i=a+s|0)>>2]=1|r,(b[r+i>>2]=r)>>>0<=255)e=1052784+((n=r>>>3|0)<<3)|0,n=(r=b[263186])&(n=1<>2]:(b[263186]=n|r,e),b[e+8>>2]=i,b[n+12>>2]=i,b[i+12>>2]=e,b[i+8>>2]=n;else{(s=r>>>8|(e=0))&&(e=31,16777215>>0||(e=28+((e=((l=(s<<=o=s+1048320>>>16&8)<<(e=s+520192>>>16&4))<<(s=l+245760>>>16&2)>>>15|0)-(s|e|o)|0)<<1|r>>>e+21&1)|0)),b[(n=i)+28>>2]=e,b[i+16>>2]=0,n=1053048+(e<<2)|(b[i+20>>2]=0);r:{if((s=1<>>1|0)|0),s=b[n>>2];;){if((-8&b[(n=s)+4>>2])==(0|r))break r;if(s=e>>>29|0,e<<=1,!(s=b[16+(o=(4&s)+n|0)>>2]))break}b[o+16>>2]=i}else b[263187]=s|c,b[n>>2]=i;b[i+24>>2]=n,b[i+12>>2]=i,b[i+8>>2]=i;break n}e=b[n+8>>2],b[e+12>>2]=i,b[n+8>>2]=i,b[i+24>>2]=0,b[i+12>>2]=n,b[i+8>>2]=e}e=a+8|0;break e}t:if(u){e=b[n+28>>2];n:{if(b[(r=1053048+(e<<2)|0)>>2]==(0|n)){if(b[r>>2]=a)break n;b[263187]=v(e)&d;break t}if(!(b[u+(b[u+16>>2]==(0|n)?16:20)>>2]=a))break t}b[a+24>>2]=u,(e=b[n+16>>2])&&(b[a+16>>2]=e,b[e+24>>2]=a),(e=b[n+20>>2])&&(b[a+20>>2]=e,b[e+24>>2]=a)}i>>>0<=15?(e=i+s|0,b[n+4>>2]=3|e,b[4+(e=e+n|0)>>2]=1|b[e+4>>2]):(b[n+4>>2]=3|s,b[4+(s=n+s|0)>>2]=1|i,b[i+s>>2]=i,c&&(e=1052784+((r=c>>>3|0)<<3)|0,a=b[263191],r=(r=1<>2]:(b[263186]=r|o,e),b[e+8>>2]=a,b[r+12>>2]=a,b[a+12>>2]=e,b[a+8>>2]=r),b[263191]=s,b[263188]=i),e=n+8|0}return h=16+t|0,e}function f(e){var t=0,n=0,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=0,v=0;if(!((n=b[e+40>>2])>>>0<=(c=b[e+32>>2])>>>0)&&(t=b[e+104>>2])&&(a=b[e+84>>2],!(M[e+36>>2]<=a>>>0|M[e+48>>2]<=a>>>0))){if(o=(n=n-c|0)>>>0>>0?n:t,b[e+104>>2]=t-o,t=(-1^a)+c|0,t=c>>>0<=a>>>0?b[e+44>>2]+t|0:t,a=b[e+24>>2],n=w[t+a|0],b[e+32>>2]=c+1,_[a+c|0]=n,r=o+-1|0)for(;t=(0|(n=t+1|0))==b[e+44>>2]?0:n,o=b[e+24>>2],a=w[t+o|0],n=b[e+32>>2],b[e+32>>2]=n+1,_[n+o|0]=a,r=r+-1|0;);c=b[e+32>>2],M[e+36>>2]>=c>>>0||(b[e+36>>2]=c)}e:{t:if(!(c>>>0>=M[e+40>>2]))for(p=e+1756|0,f=e+2784|0,m=e+84|0;;){if((a=b[e+16>>2])>>>0>M[e+20>>2])break t;o=u=(((d=b[e+100>>2])<<5)+e|0)+((s=b[e+116>>2]&c)<<1)|0,16777216<=(i=b[e>>2])>>>0?r=b[e+4>>2]:(i<<=8,b[e>>2]=i,n=a+1|0,b[e+16>>2]=n,r=w[b[e+12>>2]+a|0]|b[e+4>>2]<<8,b[e+4>>2]=r,a=n),n=y[o+120>>1];n:if(r>>>0<(t=x(n,i>>>11|0))>>>0){b[e>>2]=t,g[o+120>>1]=n+(2048-n>>>5|0),i=c+-1|0,i=c?i:b[e+44>>2]+i|0,s=b[e+108>>2],n=(b[e+112>>2]&c)<>2])&&(u=w[b[e+24>>2]+i|0]),h=n+(u>>>8-s|0)|0,i=1;r:{if(d>>>0<=6)for(;;)if(o=3812+((i<<=1)+(x(h,1536)+e|0)|0)|0,16777215>>0?n=t:(n=t<<8,b[e>>2]=n,t=a+1|0,b[e+16>>2]=t,r=w[b[e+12>>2]+a|0]|r<<8,b[e+4>>2]=r,a=t),s=y[o>>1],(t=x(s,n>>>11|0))>>>0<=r>>>0?(r=r-t|0,b[e+4>>2]=r,t=n-t|0,b[e>>2]=t,g[o>>1]=s-(s>>>5|0),i|=1):(b[e>>2]=t,g[o>>1]=s+(2048-s>>>5|0)),!(i>>>0<256))break r;for(i=(-1^(n=b[e+84>>2]))+c|0,i=c>>>0<=n>>>0?b[e+44>>2]+i|0:i,o=o?w[b[e+24>>2]+i|0]:0,i=1,l=256;d=l&(o<<=1),s=3812+((x(h,1536)+e|0)+((d+l|0)+i<<1)|0)|0,16777215>>0?u=t:(u=t<<8,b[e>>2]=u,n=a+1|0,b[e+16>>2]=n,r=w[b[e+12>>2]+a|0]|r<<8,b[e+4>>2]=r,a=n),s=y[(v=n=s)>>1],n=(t=x(s,u>>>11|0))>>>0<=r>>>0?(r=r-t|0,b[e+4>>2]=r,t=u-t|0,b[e>>2]=t,u=1,s-(s>>>5|(l=0))|0):(b[e>>2]=t,s+(2048-s>>>5|(u=0))|0),g[v>>1]=n,l^=d,(i=i<<1|u)>>>0<256;);}if(b[e+32>>2]=c+1,_[b[e+24>>2]+c|0]=i,c=b[e+32>>2],M[e+36>>2]>>0&&(b[e+36>>2]=c),(n=b[e+100>>2])>>>0<=3){b[e+100>>2]=0;break n}if(n>>>0<=9){b[e+100>>2]=n+-3;break n}b[e+100>>2]=n+-6}else{r=r-t|0,b[e+4>>2]=r,t=i-t|0,b[e>>2]=t,g[o+120>>1]=n-(n>>>5|0),o=h=(d<<1)+e|0,16777215>>0?n=a:(t<<=8,b[e>>2]=t,n=a+1|0,b[e+16>>2]=n,r=w[b[e+12>>2]+a|0]|r<<8,b[e+4>>2]=r),d=y[o+504>>1];r:if((a=x(d,t>>>11|0))>>>0<=r>>>0){r=r-a|0,b[e+4>>2]=r,t=t-a|0,b[e>>2]=t,g[o+504>>1]=d-(d>>>5|0),16777215>>0?o=n:(t<<=8,b[e>>2]=t,o=n+1|0,b[e+16>>2]=o,r=w[b[e+12>>2]+n|0]|r<<8,b[e+4>>2]=r),n=y[h+528>>1];i:{if(r>>>0<(i=x(n,t>>>11|0))>>>0){if(b[e>>2]=i,g[h+528>>1]=n+(2048-n>>>5|0),i>>>0<=16777215&&(i<<=8,b[e>>2]=i,b[e+16>>2]=o+1,r=w[b[e+12>>2]+o|0]|r<<8,b[e+4>>2]=r),t=y[u+600>>1],(n=x(t,i>>>11|0))>>>0<=r>>>0){b[e+4>>2]=r-n,b[e>>2]=i-n,g[u+600>>1]=t-(t>>>5|0);break i}b[e>>2]=n,g[u+600>>1]=t+(2048-t>>>5|0),b[e+104>>2]=1,b[e+100>>2]=M[e+100>>2]<7?9:11;break r}r=r-i|0,b[e+4>>2]=r,t=t-i|0,b[e>>2]=t,g[h+528>>1]=n-(n>>>5|0),16777215>>0?n=o:(t<<=8,b[e>>2]=t,n=o+1|0,b[e+16>>2]=n,r=w[b[e+12>>2]+o|0]|r<<8,b[e+4>>2]=r),o=y[h+552>>1],r>>>0<(a=x(o,t>>>11|0))>>>0?(b[e>>2]=a,g[h+552>>1]=o+(2048-o>>>5|0),t=b[e+88>>2]):(r=r-a|0,b[e+4>>2]=r,t=t-a|0,b[e>>2]=t,g[h+552>>1]=o-(o>>>5|0),t>>>0<=16777215&&(t<<=8,b[e>>2]=t,b[e+16>>2]=n+1,r=w[b[e+12>>2]+n|0]|r<<8,b[e+4>>2]=r),a=y[h+576>>1],r>>>0<(n=x(a,t>>>11|0))>>>0?(b[e>>2]=n,g[h+576>>1]=a+(2048-a>>>5|0),t=b[e+92>>2]):(b[e+4>>2]=r-n,b[e>>2]=t-n,g[h+576>>1]=a-(a>>>5|0),t=b[e+96>>2],b[e+96>>2]=b[e+92>>2]),b[e+92>>2]=b[e+88>>2]),b[e+88>>2]=b[e+84>>2],b[e+84>>2]=t}b[e+100>>2]=M[e+100>>2]<7?8:11,C(e,f,s)}else{for(b[e>>2]=a,g[o+504>>1]=d+(2048-d>>>5|0),b[e+96>>2]=b[e+92>>2],n=b[e+88>>2],b[e+88>>2]=b[e+84>>2],b[e+92>>2]=n,b[e+100>>2]=M[e+100>>2]<7?7:10,C(e,p,s),a=(n=b[e+104>>2])>>>0<6?n+-2|0:3,t=b[e>>2],r=1;o=(r<<=1)+((a<<7)+e|0)|0,16777216<=t>>>0?i=b[e+4>>2]:(t<<=8,b[e>>2]=t,n=b[e+16>>2],b[e+16>>2]=n+1,i=w[n+b[e+12>>2]|0]|b[e+4>>2]<<8,b[e+4>>2]=i),s=y[o+984>>1],(n=x(s,t>>>11|0))>>>0<=i>>>0?(i=i-n|0,b[e+4>>2]=i,t=t-n|0,b[e>>2]=t,g[o+984>>1]=s-(s>>>5|0),r|=1):(b[e>>2]=n,g[o+984>>1]=s+(2048-s>>>5|0),t=n),r>>>0<64;);if((a=r+-64|0)>>>0<=3)b[e+84>>2]=a;else if(l=1&a|2,b[e+84>>2]=l,n=a>>>1|0,a>>>0<=13)for(u=l<<(o=n+-1|0),a=1538+((((b[e+84>>2]=u)<<(l=1))+m|0)+(0-r<<1)|0)|0,r=0;s=a+(l<<=1)|0,16777215>>0?n=t:(n=t<<8,b[e>>2]=n,t=b[e+16>>2],b[e+16>>2]=t+1,i=w[t+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),d=y[s>>1],i>>>0<(t=x(d,n>>>11|0))>>>0?(b[e>>2]=t,g[s>>1]=d+(2048-d>>>5|0)):(i=i-t|0,b[e+4>>2]=i,t=n-t|0,b[e>>2]=t,g[s>>1]=d-(d>>>5|0),u=(1<>2]=u,l|=1),(r=r+1|0)>>>0>>0;);else{for(a=n+-5|0;16777215>>0?r=t:(r=t<<8,b[e>>2]=r,n=b[e+16>>2],b[e+16>>2]=n+1,i=w[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),t=r>>>1|0,l=(n=(o=i-(b[e>>2]=t)|0)>>31)+(l<<1|1)|0,b[e+84>>2]=l,i=o+(t&n)|0,b[e+4>>2]=i,a=a+-1|0;);l<<=4,b[e+84>>2]=l,r>>>0<=33554431&&(t<<=8,b[e>>2]=t,n=b[e+16>>2],b[e+16>>2]=n+1,i=w[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),a=y[(n=e)+1726>>1],o=1724+(n+(a=(t=i>>>0<(r=x(a,t>>>11|0))>>>0?(b[e>>2]=r,g[e+1726>>1]=a+(2048-a>>>5|0),2):(i=i-r|0,b[e+4>>2]=i,r=t-r|0,b[e>>2]=r,l|=1,b[e+84>>2]=l,g[e+1726>>1]=a-(a>>>5|0),3))<<1)|0)|0,r>>>0<=16777215&&(r<<=8,b[e>>2]=r,n=b[e+16>>2],b[e+16>>2]=n+1,i=w[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),n=y[o>>1],(t=x(n,r>>>11|0))>>>0<=i>>>0?(i=i-t|0,b[e+4>>2]=i,t=r-t|0,b[e>>2]=t,g[o>>1]=n-(n>>>5|0),l=l+2|0,b[e+84>>2]=l,a|=1):(b[e>>2]=t,g[o>>1]=n+(2048-n>>>5|0)),o=1724+((a<<=1)+e|0)|0,t>>>0<=16777215&&(t<<=8,b[e>>2]=t,n=b[e+16>>2],b[e+16>>2]=n+1,i=w[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),n=y[o>>1],(r=x(n,t>>>11|0))>>>0<=i>>>0?(i=i-r|0,b[e+4>>2]=i,r=t-r|0,b[e>>2]=r,g[o>>1]=n-(n>>>5|0),l=l+4|0,b[e+84>>2]=l,a|=1):(b[e>>2]=r,g[o>>1]=n+(2048-n>>>5|0)),r>>>0<=16777215&&(r<<=8,b[e>>2]=r,n=b[e+16>>2],b[e+16>>2]=n+1,i=w[n+b[e+12>>2]|0]|i<<8,b[e+4>>2]=i),a=y[(n=1724+((a<<1)+e|0)|0)>>1],(t=x(a,r>>>11|0))>>>0<=i>>>0?(b[e+4>>2]=i-t,b[e>>2]=r-t,g[n>>1]=a-(a>>>5|0),b[e+84>>2]=l+8):(b[e>>2]=t,g[n>>1]=a+(2048-a>>>5|0))}}if(t=0,a=b[e+84>>2],M[e+36>>2]<=a>>>0|M[e+48>>2]<=a>>>0)break e;if(s=b[e+32>>2],o=(n=b[e+40>>2]-s|0)>>>0<(t=b[e+104>>2])>>>0?n:t,b[e+104>>2]=t-o,t=s+(-1^a)|0,t=s>>>0<=a>>>0?b[e+44>>2]+t|0:t,a=b[e+24>>2],n=w[t+a|0],b[e+32>>2]=s+1,_[a+s|0]=n,i=o+-1|0)for(;t=(0|(n=t+1|0))==b[e+44>>2]?0:n,o=b[e+24>>2],a=w[t+o|0],n=b[e+32>>2],b[e+32>>2]=n+1,_[n+o|0]=a,i=i+-1|0;);c=b[e+32>>2],M[e+36>>2]>=c>>>0||(b[e+36>>2]=c)}if(!(c>>>0>2]))break}t=1,16777215<(n=b[e>>2])>>>0||(b[e>>2]=n<<8,n=b[e+16>>2],b[e+16>>2]=n+1,b[e+4>>2]=w[n+b[e+12>>2]|0]|b[e+4>>2]<<8)}return t}function P(e,t,n){var r=0,i=0,a=0;e:if(n){for(;(0|(r=w[0|e]))==(0|(i=w[0|t]));)if(t=t+1|0,e=e+1|0,!(n=n+-1|0))break e;a=r-i|0}return a}function C(e,t,n){var r=0,i=0,a=0,o=0,s=0,l=0,c=0;for(16777216<=(o=b[e>>2])>>>0?a=b[e+4>>2]:(o<<=8,b[e>>2]=o,i=b[e+16>>2],b[e+16>>2]=i+1,a=w[i+b[e+12>>2]|0]|b[e+4>>2]<<8,b[e+4>>2]=a),i=y[t>>1],i=a>>>0<(r=x(i,o>>>11|0))>>>0?(b[e>>2]=r,g[t>>1]=i+(2048-i>>>5|0),c=4+((n<<4)+t|0)|0,l=2,8):(a=a-r|0,b[e+4>>2]=a,o=o-r|0,b[e>>2]=o,g[t>>1]=i-(i>>>5|0),o>>>0<=16777215&&(o<<=8,b[e>>2]=o,i=b[e+16>>2],b[e+16>>2]=i+1,a=w[i+b[e+12>>2]|0]|a<<8,b[e+4>>2]=a),i=y[t+2>>1],a>>>0<(r=x(i,o>>>11|0))>>>0?(b[e>>2]=r,g[t+2>>1]=i+(2048-i>>>5|0),c=260+((n<<4)+t|0)|0,l=10,8):(a=a-r|0,b[e+4>>2]=a,r=o-r|0,b[e>>2]=r,g[t+2>>1]=i-(i>>>5|0),c=t+516|0,l=18,256)),b[e+104>>2]=l,t=1;o=c+(t<<=1)|0,16777215>>0?n=r:(n=r<<8,b[e>>2]=n,r=b[e+16>>2],b[e+16>>2]=r+1,a=w[r+b[e+12>>2]|0]|a<<8,b[e+4>>2]=a),s=y[o>>1],(r=x(s,n>>>11|0))>>>0<=a>>>0?(a=a-r|0,b[e+4>>2]=a,r=n-r|0,b[e>>2]=r,g[o>>1]=s-(s>>>5|0),t|=1):(b[e>>2]=r,g[o>>1]=(2048-s>>>5|0)+s),t>>>0>>0;);b[e+104>>2]=(t-i|0)+l}function L(e){var t,n,r=0,i=0,a=0,o=0,s=0,l=0,c=0,u=0,d=0;for(t=e+28392|0,n=e+28388|0;;){r=b[e+64>>2];e:{t:{n:{r:{i:{a:{o:{s:{l:{c:{u:{d:{h:{p:{f:{if(i=b[132105],(a=b[132106])>>>0<=i>>>0){if(7==(0|r))break f;return 0}if(8>>0)continue;switch(r-1|0){case 4:break l;case 3:break c;case 2:break u;case 1:break d;case 0:break h;case 6:break f;case 7:break a;case 5:break s;default:break p}}r=b[e+76>>2];break o}if(s=1,b[132105]=i+1,!(r=w[b[132104]+i|0]))break i;if(!(1!=(0|r)&&r>>>0<=223)){g[e+80>>1]=256,b[e+60>>2]||(a=b[132108],b[e+24>>2]=a+b[132107],b[e+44>>2]=b[132109]-a),b[e+28>>2]=0,b[e+32>>2]=0,b[e+36>>2]=0,b[e+40>>2]=0;break n}if(!w[e+80|0])break n;return 7}b[132105]=i+1,r=w[b[132104]+i|0],b[e+64>>2]=2,b[e+72>>2]=b[e+72>>2]+(r<<8);continue}b[132105]=i+1,r=w[b[132104]+i|0],b[e+64>>2]=3,b[e+72>>2]=1+(r+b[e+72>>2]|0);continue}b[132105]=i+1,r=w[b[132104]+i|0],b[e+64>>2]=4,b[e+76>>2]=r<<8;continue}b[132105]=i+1,r=w[b[132104]+i|0],b[e+64>>2]=b[e+68>>2],b[e+76>>2]=1+(r+b[e+76>>2]|0);continue}if(b[132105]=i+1,s=7,224<(r=w[b[132104]+i|0])>>>0)break i;if(a=e,o=r>>>(i=0)<45?0:(r=(r=r+-45|0)-x(o=((255&r)>>>0)/45|0,45)|0,o+1|0),b[a+116>>2]=-1<>>0&&(i=1+(a=((255&(r=r+-9|0))>>>0)/9|0)|0,r=r-x(a,9)|0),b[e+112>>2]=i,r&=255,4<(b[e+108>>2]=r)+i>>>0)break i;for(b[e+112>>2]=-1<>2]=0,b[e+92>>2]=0,b[e+96>>2]=0,b[e+84>>2]=0,b[e+88>>2]=0;g[120+((r<<1)+e|0)>>1]=1024,14134!=(0|(r=r+1|0)););b[e+64>>2]=6,b[e+8>>2]=5,b[e>>2]=-1,b[e+4>>2]=0}if((s=b[e+76>>2])>>>0<5)return 7;if(i=b[e+8>>2])for(r=b[132105],o=b[132106];;){if((0|r)==(0|o))return 0;if(l=b[e+4>>2],a=r+1|0,b[132105]=a,r=w[b[132104]+r|0],i=i+-1|0,b[e+8>>2]=i,b[e+4>>2]=r|l<<8,r=a,!i)break}b[e+64>>2]=7,r=s+-5|0,b[e+76>>2]=r}a=b[e+32>>2],i=(i=b[132109]-b[132108]|0)>>>0<(s=b[e+72>>2])>>>0?i:s,s=b[e+44>>2],b[e+40>>2]=i>>>0>>0?a+i|0:s,i=(o=b[132106])-(a=b[132105])|0,s=b[e+28388>>2];o:{if(!r||s){if(S(4+(s+n|0)|0,o=b[132104]+a|0,r=i>>>0<(r=(r=r-s|0)>>>0<(a=42-s|0)>>>0?r:a)>>>0?i:r),(0|(a=(i=b[e+28388>>2])+r|0))!=b[e+76>>2]){if(a>>>0<=20){b[e+28388>>2]=a,b[132105]=r+b[132105];break o}a=a+-21|0}else E(4+(r+(i+n|0)|0)|0,63-a|0),a=r+b[e+28388>>2]|0;if(b[e+16>>2]=0,b[e+12>>2]=t,b[e+20>>2]=a,s=7,!f(e))break i;if(a=b[e+16>>2],(i=b[e+28388>>2])+r>>>0>>0)break i;if(r=b[e+76>>2]-a|0,b[e+76>>2]=r,a>>>0>>0){r=i-a|0,m(t,4+(a+n|0)|0,b[e+28388>>2]=r);break o}a=b[132105]+(a-i|0)|0,b[132105]=a,b[e+28388>>2]=0,i=(o=b[132106])-a|0}if(21<=i>>>0){if(s=b[132104],b[e+16>>2]=a,b[e+12>>2]=s,b[e+20>>2]=i>>>0>>0?o+-21|0:r+a|0,s=7,!f(e))break i;if((r=b[e+76>>2])>>>0<(i=(a=b[e+16>>2])-b[132105]|0)>>>0)break i;if(r=r-i|0,b[e+76>>2]=r,b[132105]=a,20<(i=b[132106]-a|0)>>>0)break o}r=r>>>0>>0?r:i,S(t,b[132104]+a|0,r),b[e+28388>>2]=r,b[132105]=r+b[132105]}if(i=(r=b[e+32>>2])-(s=b[e+28>>2])|0,b[(a=e)+60>>2]&&((0|r)==b[e+44>>2]&&(b[e+32>>2]=0),S(b[132107]+b[132108]|0,s+b[e+24>>2]|0,i),r=b[e+32>>2]),b[a+28>>2]=r,r=i+b[132108]|0,b[132108]=r,a=b[e+72>>2]-i|0,!(b[e+72>>2]=a)){if(s=7,b[e+4>>2]|(b[e+76>>2]|b[e+104>>2]))break i;b[e+64>>2]=0;break t}if(((s=0)|r)==b[132109])break i;if(b[132105]!=b[132106]|M[e+28388>>2]>=M[e+76>>2])continue;break i}if(!(o=b[e+76>>2]))break r;if(!(a>>>(s=0)<=i>>>0))for(;;){if((r=b[132109])>>>0<=(l=b[132108])>>>0)break i;if(d=o,c=b[e+32>>2],o=o>>>0<(r=(u=b[e+44>>2]-c|0)>>>0<(r=(a=a-i|0)>>>0<(r=r-l|0)>>>0?a:r)>>>0?u:r)>>>0?o:r,b[e+76>>2]=d-o,S(b[e+24>>2]+c|0,b[132104]+i|0,o),r=o+b[e+32>>2]|0,b[e+32>>2]=r,M[e+36>>2]>>0&&(b[e+36>>2]=r),b[(a=e)+60>>2]&&((0|r)==b[e+44>>2]&&(b[e+32>>2]=0),S(b[132107]+b[132108]|0,b[132104]+b[132105]|0,o),r=b[e+32>>2]),b[a+28>>2]=r,b[132108]=o+b[132108],i=o+b[132105]|0,b[132105]=i,!(o=b[e+76>>2]))break r;if(!(i>>>0<(a=b[132106])>>>0))break}}return s}b[e+64>>2]=0;continue}if(-1>24)break e;if(b[e+64>>2]=1,b[e+72>>2]=r<<16&2031616,192<=r>>>0){b[e+68>>2]=5,_[e+81|0]=0;continue}if(w[e+81|0])return 7;if(b[e+68>>2]=6,r>>>0<160)continue;for(b[e+84>>2]=0,r=b[e+88>>2]=0,b[e+100>>2]=0,b[e+92>>2]=0,b[e+96>>2]=0;g[120+((r<<1)+e|0)>>1]=1024,14134!=(0|(r=r+1|0)););}b[e+8>>2]=5,b[e>>2]=-1,b[e+4>>2]=0;continue}if(!(r>>>0<=2))break;b[e+64>>2]=3,b[e+68>>2]=8}return 7}function c(){var e,t,n=0;if(e=l(1208)){if(b[e+36>>2]=2,n=(t=l(28456))?(b[t+52>>2]=8388608,b[t+60>>2]=2,b[t+56>>2]=0,b[t+24>>2]=0,t):0,b[e+1200>>2]=n)return _[e+40|0]=0,b[e>>2]=0,b[e+4>>2]=0,b[e+24>>2]=0,E(e+72|(b[e+28>>2]=0),100),b[e+172>>2]=12,e;s(e)}return 0}function R(e,t,n,r){var i=0;if(n^=-1,r^=-1,t)for(;i=2080+((w[0|e]^255&n)<<3)|0,n=b[i>>2]^((255&r)<<24|n>>>8),r=b[i+4>>2]^r>>>8,e=e+1|0,t=t+-1|0;);return A=-1^r,-1^n}function m(e,t,n){var r=0,i=0;e:if((0|e)!=(0|t)){if(!(e>>>0>>0&&t>>>0<(i=e+n|0)>>>0))return void S(e,t,n);if(r=3&(e^t),e>>>0>>0){if(!r){if(3&e)for(;;){if(!n)break e;if(_[0|e]=w[0|t],t=t+1|0,n=n+-1|0,!(3&(e=e+1|0)))break}if(!(n>>>0<=3)){for(r=n;b[e>>2]=b[t>>2],t=t+4|0,e=e+4|0,3<(r=r+-4|0)>>>0;);n&=3}}if(n)for(;_[0|e]=w[0|t],e=e+1|0,t=t+1|0,n=n+-1|0;);}else{if(!r){if(3&i)for(;;){if(!n)break e;if(_[0|(r=(n=n+-1|0)+e|0)]=w[t+n|0],!(3&r))break}if(!(n>>>0<=3))for(;b[(n=n+-4|0)+e>>2]=b[t+n>>2],3>>0;);}if(!n)break e;for(;_[(n=n+-1|0)+e|0]=w[t+n|0],n;);}}}function D(e,t){var n=0,r=0;n=6;e:if(!(39>>0)){if(t=(1&t|2)<<11+(t>>>1|0),b[e+48>>2]=t,r=b[e+60>>2]){if(n=4,t>>>0>M[e+52>>2])break e;if(b[e+44>>2]=t,!(2!=(0|r)|M[e+56>>2]>=t>>>0||(s(b[e+24>>2]),t=l(b[e+48>>2]),b[e+24>>2]=t)))return b[e+56>>2]=0,3}b[e+28388>>2]=0,b[e+64>>2]=0,_[e+80|0]=1,n=b[e+104>>2]=0}return n}function v(e){var t;return(-1>>>(t=31&e)&-2)<>>e}return{__wasm_call_ctors:function(){},init_decompressor:function(){var e=0;return b[132108]=0,b[132109]=524288,b[132107]=528448,b[132105]=0,b[132106]=0,b[132104]=4128,function(){for(var e=0,t=0,n=0;e=((t=(0-(1&(e=(0-(1&(e=((t=n>>>1|0)^0-(1&n)&-306674912)>>>1|0))&-306674912^(t=(e^0-(1&t)&-306674912)>>>1|0))>>>1|0))&-306674912^(e=(e^0-(1&t)&-306674912)>>>1|0))>>>1|0)^0-(1&e)&-306674912)>>>1|0,b[1056+(n<<2)>>2]=0-(1&e)&-306674912^(e^0-(1&t)&-306674912)>>>1,256!=(0|(n=n+1|0)););}(),function(){for(var e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0,l=0;t=(e=o)>>>1|0,n=1&(e=(1&e)<<31|s>>>1),t^=0-(0<(a=1&s)>>>0)&-915646571,a=e^(i=0-a&-679014590),e=t>>>1|0,e^=0-(0>>0)&-915646571,n=(t=(1&t)<<31|a>>>1)^(r=0-n&-679014590),r=e>>>1|0,n=1&(e=(1&e)<<31|n>>>1),i=0-(t&=1)&-679014590,t=r^0-(0>>0)&-915646571,r=e^i,e=t>>>1|0,r=0-n&-679014590^(t=(1&t)<<31|r>>>1),e=(n=e^0-(0>>0)&-915646571)>>>1|0,t=(1&(e^=0-(0<(t&=1)>>>0)&-915646571))<<31|(t=(n=(1&n)<<31|r>>>1)^(i=0-t&-679014590))>>>1,e=(n=0-(0<(r=1&n)>>>0)&-915646571^e>>>1)>>>1|0,r=1&(n=(1&n)<<31|(r=t^(a=0-r&-679014590))>>>1),n^=0-(t&=1)&-679014590,t=(e^=0-(0>>0)&-915646571)>>>1|0,b[(i=2080+(l<<3)|0)>>2]=0-r&-679014590^((1&e)<<31|n>>>1),b[i+4>>2]=t^0-(0>>0)&-915646571,l=l+1|0,e=o,(o=s+1|0)>>>0<1&&(e=e+1|0),256!=(0|(s=o))|(o=e););}(),e=c(),0|(e=(b[263184]=e)?0:(o(0),1))},decompress:function(){var e,t=0;e:{if((e=function(e){var t,n,r,i,a=0,o=0,s=0,l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0;o=b[e+36>>2]?b[e>>2]:(_[e+40|0]=0,b[e>>2]=0,b[e+4>>2]=0,b[e+24>>2]=0,E(e+72|(b[e+28>>2]=0),100),b[e+172>>2]=12,0),n=b[132108],t=b[132105],b[e+16>>2]=t,r=e+96|0,v=(a=e)+182|0,i=a+176|0,d=a+168|0;t:{n:{r:{i:{a:{for(;;)if(!(9>>0)){e=d;o:{s:{l:{c:{u:{d:switch(o-1|0){case 1:u=b[132106],o=b[132104],l=b[a+172>>2],s=b[a+168>>2];break u;default:if(s=b[132105],o=b[132106]-s|0,c=b[a+168>>2],o=o>>>0<(u=b[a+172>>2]-c|0)>>>0?o:u,S(8+(c+d|0)|0,s+b[132104]|0,o),b[132105]=o+b[132105],l=0,o=o+b[a+168>>2]|0,s=b[a+172>>2],b[a+168>>2]=(0|s)==(0|o)?0:o,(0|o)!=(0|s))break t;if(b[a>>2]=1,P(i,1024,6)){l=5;break t}if((0|T(v,2,0))!=(w[a+184|0]|w[a+185|0]<<8|(w[a+186|0]<<16|w[a+187|0]<<24))){l=7;break t}if(l=6,w[0|v])break t;if(o=w[a+183|0],15<(b[a+32>>2]=o)>>>0)break t;if(l=2,!(1<>>0)break t;break;case 4:break s;case 3:break l;case 2:break c;case 0:break d;case 8:break r;case 7:break i;case 6:break a;case 5:break o}if((0|(u=b[132106]))==(0|(s=b[132105]))){l=0;break t}if(o=b[132104],!(c=w[s+o|0])){b[132105]=s+1,b[a+16>>2]=s,o=6,b[a>>2]=6;continue}b[a+168>>2]=0,l=4+(c<<(b[a>>2]=2))|0,b[a+172>>2]=l,b[a+64>>2]=l,s=0}if(c=u,S(8+(e+s|0)|0,o+(u=b[132105])|0,c=(c=c-u|0)>>>0<(l=l-s|0)>>>0?c:l),b[132105]=c+b[132105],l=0,e=c+b[a+168>>2]|0,o=b[a+172>>2],b[a+168>>2]=(0|o)==(0|e)?0:e,(0|e)!=(0|o))break t;if(e=e+-4|0,o=T(i,b[a+172>>2]=e,0),p=b[a+172>>2],(0|o)!=(w[176+(e=p+a|0)|0]|w[e+177|0]<<8|(w[e+178|0]<<16|w[e+179|0]<<24))){l=7;break t}if(b[a+168>>2]=2,63&(g=_[a+177|0])){l=6;break t}if(o=2,c=s=y=h=-1,64&g){for((u=b[a+4>>2])||(b[a+8>>2]=0,b[a+12>>2]=0);;){if(p>>>0<=o>>>0){l=7;break t}f=w[8+(o+d|0)|0],o=o+1|0,b[a+168>>2]=o,x=b[(e=a)+12>>2],m=127&f,l=31&(s=u),s=32<=(63&s)>>>0?(c=m<>>32-l,m<>2],c=l=c|x,b[e+8>>2]=s,b[e+12>>2]=c;u:{if(!(128&f)){if(f|!u)break u;l=7;break t}if(u=u+(l=7)|0,63!=(0|(b[a+4>>2]=u)))continue;break t}break}b[a+4>>2]=0}if(b[a+48>>2]=s,b[a+52>>2]=c,(0|g)<=-1){for((u=b[a+4>>2])||(b[a+8>>2]=0,b[a+12>>2]=0);;){if(p>>>0<=o>>>0){l=7;break t}f=w[8+(o+d|0)|0],o=o+1|0,b[a+168>>2]=o,m=b[(e=a)+12>>2],h=127&f,l=31&(s=u),h=(s=32<=(63&s)>>>0?(c=h<>>32-l,h<>2],y=s=c|m,b[e+8>>2]=h,b[e+12>>2]=s;u:{if(!(128&f)){if(f|!u)break u;l=7;break t}if(u=u+(l=7)|0,63!=(0|(b[a+4>>2]=u)))continue;break t}break}b[a+4>>2]=0}if(b[a+56>>2]=h,b[a+60>>2]=y,p-o>>>0<2){l=7;break t}if(s=o+1|0,b[a+168>>2]=s,33!=w[8+(o+d|0)|0]){l=6;break t}if(e=o+2|0,b[a+168>>2]=e,1!=w[8+(s+d|0)|0]){l=6;break t}if(l=7,(0|e)==(0|p))break t;if(b[a+168>>2]=o+3,l=D(b[a+1200>>2],w[8+(e+d|0)|0]))break t;o=b[a+168>>2],s=b[a+172>>2];u:{for(;;){if(s>>>0<=o>>>0)break u;if(e=o+1|0,c=o+d|0,o=b[a+168>>2]=e,w[c+8|0])break}l=6;break t}b[a+168>>2]=0,b[a+80>>2]=0,b[a+84>>2]=0,b[a+72>>2]=0,b[a+76>>2]=0,b[a>>2]=3}if(b[a+16>>2]=b[132105],b[a+20>>2]=b[132108],l=L(b[a+1200>>2]),e=b[(o=a)+76>>2],(c=(s=b[132105]-b[a+16>>2]|0)+b[a+72>>2]|0)>>>0>>0&&(e=e+1|0),u=c,s=e,b[o+72>>2]=c,b[o+76>>2]=e,e=b[a+84>>2],p=b[a+20>>2],(f=(c=h=b[132108]-p|0)+b[a+80>>2]|0)>>>0>>0&&(e=e+1|0),c=e,b[o+80>>2]=f,b[o+84>>2]=e,(0|(e=b[a+52>>2]))==(0|s)&u>>>0>M[a+48>>2]|e>>>0>>0){l=7;break t}if((0|(e=b[a+60>>2]))==(0|c)&f>>>0>M[a+56>>2]|e>>>0>>0){l=7;break t}c:if(!(3<(o=b[a+32>>2]+-1|0)>>>0)){e=a;u:{d:switch(o-1|0){default:o=T(p+b[132107]|0,h,b[a+24>>2]),s=0;break u;case 0:case 1:break c;case 2:}o=R(p+b[132107]|0,h,b[a+24>>2],b[a+28>>2]),s=A}b[e+24>>2]=o,b[e+28>>2]=s}if(1!=(0|l))break t;if(o=e=b[a+52>>2],!(-1==(0|(s=b[a+48>>2]))&-1==(0|o)|b[a+72>>2]==(0|s)&b[a+76>>2]==(0|o))){l=7;break t}if(e=b[a+80>>2],o=b[a+84>>2],c=u=b[a+60>>2],-1==(0|(s=b[a+56>>2]))&-1==(0|c))s=e,c=o;else if(l=7,(0|e)!=(0|s)|(0|o)!=(0|c))break t;c=c+b[a+108>>2]|0,(o=s+b[a+104>>2]|0)>>>0>>0&&(c=c+1|0),b[a+104>>2]=o,b[a+108>>2]=c,c=b[a+100>>2],e=b[a+76>>2],(u=(s=b[a+64>>2])+b[a+72>>2]|0)>>>0>>0&&(e=e+1|0),e=e+c|0,e=(s=u+b[a+96>>2]|0)>>>0>>0?e+1|0:e,(s=(c=s)+w[b[a+32>>2]+1040|0]|0)>>>0>>0&&(e=e+1|0),b[a+96>>2]=s,b[a+100>>2]=e,b[a+112>>2]=T(r,24,b[a+112>>2]),b[a>>2]=4,o=b[a+92>>2],(s=b[a+88>>2]+1|0)>>>0<1&&(o=o+1|0),b[a+88>>2]=s,b[a+92>>2]=o}if(c=b[a+76>>2],3&(s=b[a+72>>2]))for(o=b[132105],u=b[132106];;){if((0|o)==(0|u)){l=0;break t}if(e=o+1|0,b[132105]=e,w[b[132104]+o|0]){l=7;break t}if((s=s+1|0)>>>0<1&&(c=c+1|0),b[a+72>>2]=s,b[a+76>>2]=c,o=e,!(3&s))break}b[a>>2]=5}s:{l:if(!(3<(o=(e=b[a+32>>2])+-1|0)>>>0)){c:switch(o-1|0){default:for(o=b[132105],l=b[132106];;){if((0|o)==(0|l)){l=0;break t}if(u=b[a+24>>2],s=b[a+28>>2],e=b[a+4>>2],c=o+1|0,b[132105]=c,h=w[b[132104]+o|0],p=u,o=s,u=31&e,(0|h)!=(255&(32<=(63&e)>>>0?o>>>u|0:((1<>>u))){l=7;break t}if(e=e+8|0,o=c,!((b[a+4>>2]=e)>>>0<32))break}b[a+24>>2]=0,b[a+28>>2]=0;break s;case 0:case 1:break l;case 2:}for(o=b[132105],l=b[132106];;){if((0|o)==(0|l)){l=0;break t}if(u=b[a+24>>2],s=b[a+28>>2],e=b[a+4>>2],c=o+1|0,b[132105]=c,h=w[b[132104]+o|0],p=u,o=s,u=31&e,(0|h)!=(255&(32<=(63&e)>>>0?o>>>u|0:((1<>>u))){l=7;break t}if(e=e+8|0,o=c,!((b[a+4>>2]=e)>>>0<64))break}b[a+24>>2]=0,b[a+28>>2]=0;break s}if(o=b[a+4>>2],!((e=w[e+1040|0])>>>0<=o>>>0))for(l=b[132105],s=b[132106];;){if((0|l)==(0|s)){l=0;break t}if(l=l+1|0,b[132105]=l,o=o+1|0,(0|e)==(0|(b[a+4>>2]=o)))break}}b[a+4>>2]=0,o=1,b[a>>2]=1;continue}break}for(f=a+144|0;;){m=b[132106],h=b[132104],(e=b[a+4>>2])||(b[a+8>>2]=0,b[a+12>>2]=0),o=b[132105];o:{for(;;){if(m>>>0<=o>>>0)l=0;else if(d=w[o+h|0],o=o+1|0,b[132105]=o,v=b[(u=a)+12>>2],p=127&d,l=31&e,s=32<=(63&e)>>>0?(c=p<>>32-l,p<>2],c=l=c|v,b[u+8>>2]=s,b[u+12>>2]=c,128&d){if(e=e+(l=7)|0,63!=(0|(b[a+4>>2]=e)))continue}else{if(d|!e)break o;l=7}break}e=b[a+132>>2],(d=(c=(s=o)-(o=b[a+16>>2])|0)+b[a+128>>2]|0)>>>0>>0&&(e=e+1|0),b[a+128>>2]=d,b[a+132>>2]=e,b[a+24>>2]=T(o+h|0,c,b[a+24>>2]),b[a+28>>2]=0;break t}b[a+4>>2]=0;o:{if((e=b[a+120>>2])>>>0<=2){s:switch(e-1|0){default:if(b[a+136>>2]=s,b[a+140>>2]=c,(0|s)!=b[a+88>>2]|(0|c)!=b[a+92>>2]){l=7;break t}b[a+120>>2]=1;break o;case 1:e=c+b[a+156>>2]|0,(c=s+b[a+152>>2]|0)>>>0>>0&&(e=e+1|0),b[a+152>>2]=c,b[a+156>>2]=e,b[a+160>>2]=T(f,24,b[a+160>>2]),b[a+120>>2]=1,c=b[a+140>>2]+-1|0,(o=b[a+136>>2]+-1|0)>>>0<4294967295&&(c=c+1|0),s=o,b[a+136>>2]=o,b[a+140>>2]=c;break o;case 0:}b[a+120>>2]=2,e=c+b[a+148>>2]|0,(c=s+b[a+144>>2]|0)>>>0>>0&&(e=e+1|0),b[a+144>>2]=c,b[a+148>>2]=e}s=b[a+136>>2],c=b[a+140>>2]}if(!(s|c))break}b[a>>2]=7}s=b[a+132>>2],p=((o=b[132105])+(((c=b[a+16>>2])-o|0)-(d=b[a+128>>2])&3)|0)-c|0;a:{for(;;){if(e=s,(l=(u=h=o-c|0)+d|0)>>>0>>0&&(e=e+1|0),!(3&(u=l)))break a;if(l=b[132104],b[132106]==(0|o)){b[a+128>>2]=u,b[a+132>>2]=e,b[a+24>>2]=T(l+c|0,h,b[a+24>>2]),l=b[a+28>>2]=0;break t}if(e=o+1|0,u=o+l|0,o=b[132105]=e,w[0|u])break}l=7;break t}if(o=b[132104],b[a+128>>2]=u,b[a+132>>2]=e,b[a+24>>2]=T(o+c|0,p,b[a+24>>2]),l=7,P(r,a+144|(b[a+28>>2]=0),24))break t;b[a>>2]=8}for(o=b[132105],l=b[132106];;){if((0|o)==(0|l)){l=0;break t}if(d=b[a+24>>2],c=b[a+28>>2],s=b[a+4>>2],e=o+1|0,b[132105]=e,u=b[132104],h=w[u+o|0],p=d,o=c,d=31&s,(0|h)!=(255&(32<=(63&s)>>>0?o>>>d|0:((1<>>d))){l=7;break t}if(s=s+8|0,o=e,!((b[a+4>>2]=s)>>>0<32))break}b[a+172>>2]=12,b[a+24>>2]=0,b[a+28>>2]=0,b[a>>2]=9,b[a+4>>2]=0,o=12;break n}e=b[132105],u=b[132104],l=b[132106],o=b[a+172>>2]}s=l-e|0,S(176+(a+(c=b[a+168>>2])|0)|0,e+u|0,o=s>>>0<(o=o-c|0)>>>0?s:o),b[132105]=o+b[132105],l=0,e=o+b[a+168>>2]|0,o=b[a+172>>2],b[a+168>>2]=(0|o)==(0|e)?0:e,(0|e)==(0|o)&&(l=7,23129==(w[a+186|0]|w[a+187|0]<<8)&&(0|T(a+180|0,6,0))==(w[a+176|0]|w[a+177|0]<<8|(w[a+178|0]<<16|w[a+179|0]<<24))&&(e=(o=b[a+132>>2])>>>2|0,w[a+184|0]|(w[a+180|0]|w[a+181|0]<<8|(w[a+182|0]<<16|w[a+183|0]<<24))!=((3&o)<<30|b[a+128>>2]>>>2)|e||(l=b[a+32>>2]==w[a+185|0]?1:7)))}t:{if(!b[a+36>>2]){if(l){if(a=1==(0|l),e=l,l=1,a)break t}else e=b[132105]==b[132106]?7:8;return b[132108]=n,b[132105]=t,e}if(!(b[132105]!=(0|t)|l|b[132108]!=(0|n)))return e=w[a+40|0],_[a+40|0]=1,e<<3;_[a+40|0]=0}return l}(b[263184]))>>>0<=8){t:switch(e-1|0){case 0:return o(b[263184]),0;case 2:return o(b[263184]),1;case 3:return o(b[263184]),2;case 4:return o(b[263184]),4;case 5:return o(b[263184]),5;case 6:case 7:break t;default:break e}return o(b[263184]),6}o(b[263184]),t=7}return 0|t},get_in_buffer_ptr:function(){return b[132104]},get_out_buffer_ptr:function(){return b[132107]},in_buffer_set_pos:function(e){e|=0,b[132105]=e},in_buffer_set_size:function(e){e|=0,b[132106]=e>>>0<524288?e:524288},out_buffer_set_pos:function(e){e|=0,b[132108]=e},out_buffer_set_size:function(e){e|=0,b[132109]=e>>>0<524288?e:524288},get_curr_output_length:function(){return b[132108]},is_input_end_reached:function(){return b[132105]==b[132106]|0},stackSave:function(){return 0|h},stackAlloc:function(e){return 0|(h=e=h-(e|=0)&-16)},stackRestore:function(e){h=e|=0},__growWasmMemory:function(e){return 0|r()}}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array,NaN:NaN,Infinity:1/0,Math:Math},n,r.buffer))}},instantiate:function(t,n){return{then:function(e){e({instance:new Av.Instance(new Av.Module(t,n))})}}},RuntimeError:Error};_v=[],"object"!=typeof Av&&wv("no native wasm support detected");var Sv=new Av.Table({initial:1,maximum:1,element:"anyfunc"}),Tv=!1;function Ev(e,t){e||Wv("Assertion failed: "+t)}function Pv(e){var t=lv["_"+e];return Ev(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function Cv(e,t,n,r){var i={string:function(e){var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);t=ig(n),function(e,t,n,r){if(0>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,Ov,t,n)}return t},array:function(e){var t,n,r=ig(e.length);return t=e,n=r,Dv.set(t,n),r}};var a=Pv(e),o=[],s=0;if(r)for(var l=0;l>10,56320|1023&c)}}else a+=String.fromCharCode((31&o)<<6|s)}else a+=String.fromCharCode(o)}return a}(Ov,d,h):"":"boolean"===t?Boolean(u):u,0!==s&&ag(s),p}var Lv="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var Rv,Dv,Ov,Nv;var Fv,Iv=lv.TOTAL_MEMORY||16777216;function Bv(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>16&32768,r=t>>12&2047,i=t>>23&255;return i<103?n:142>114-i)+(r>>113-i&1):(n|=i-112<<10|r>>1,n+=1&r)}var n=new Uint8Array(e);n.pos=0;var r,i,c,u,d,h,p=function(e){var t,n,r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,s={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};if(e.pos>=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")}(n);if(-1!==p){var f=p.width,m=p.height,v=function(e,t,n){var r,i,a,o,s,l,c,u,d,h,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(wg.S8S_V3D_DATA)&&(a[wg.S8S_V3D_DATA]=new Mg(o)),0<=o.extensionsUsed.indexOf(wg.S8S_V3D_MATERIAL_DATA)&&(a[wg.S8S_V3D_MATERIAL_DATA]=new Ag(o))),new Jg(o,a,{path:t||this.path,crossOrigin:this.crossOrigin,loadBinXZ:r,manager:this.manager,onProgress:function(e){l.onProgress&&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&&l.onProgress(100),s(o)},n))}});var wg={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 Mg(e){this.name=wg.S8S_V3D_DATA;var t=e.extensions&&e.extensions[wg.S8S_V3D_DATA]||{};this.lights={};var n=t.lights||{};for(var r in n){var i,a=n[r],o=(new Cr).fromArray(a.color),s=a.intensity;switch(a.type){case"point":i=new md(o,s);break;case"directional":i=new yd(o,s),_n(a.shadow)&&_n(a.shadow.csm)&&(i.shadow=new gd);break;case"spot":i=new pd(o,s);break;case"hemisphere":i=new hd(o,new Cr(0,0,0),s);break;case"ambient":i=new xd(o,s)}i&&(_n(a.distance)&&(i.distance=a.distance),_n(a.decay)&&(i.decay=a.decay,"blender"==a.profile&&2<=a.decay&&(i.intensity/=4*Math.PI)),_n(a.angle)&&(i.angle=a.angle),_n(a.penumbra)&&(i.penumbra=a.penumbra),_n(a.shadow)?(i.castShadow=!0,i.shadow.bias=a.shadow.bias,_n(a.shadow.expBias)&&(i.shadow.expBias=a.shadow.expBias),_n(a.shadow.slopeScaledBias)&&(i.shadow.slopeScaledBias=a.shadow.slopeScaledBias),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=Yt.radToDeg(a.shadow.cameraFov),i.shadow.useMinFov90="blender"===a.profile):i.isDirectionalLight&&(_n(a.shadow.cameraOrthoLeft)&&_n(a.shadow.cameraOrthoRight)&&_n(a.shadow.cameraOrthoBottom)&&_n(a.shadow.cameraOrthoTop)&&(i.shadow.camera.left=a.shadow.cameraOrthoLeft,i.shadow.camera.right=a.shadow.cameraOrthoRight,i.shadow.camera.bottom=a.shadow.cameraOrthoBottom,i.shadow.camera.top=a.shadow.cameraOrthoTop),i.shadow.isDirectionalLightShadowCSM&&(i.shadow.maxDistance=a.shadow.csm.maxDistance)),i.shadow.camera.updateProjectionMatrix()):i.castShadow=!1,i.name=a.name||"light_"+r,this.lights[r]=i)}this.nodeGraphs={};var l=t.nodeGraphs||[];for(var c in l){var u=l[c];this.nodeGraphs[c]=u}}function Ag(e){this.name=wg.S8S_V3D_MATERIAL_DATA}Mg.prototype.loadCurves=function(e,t){var n=e.extensions&&e.extensions[wg.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 Nd(o.font),l=0\n\nvoid main() {\n gl_FragColor = vec4(0.0);\n for (int i = 0; i < n; i++) {\n if (i >= samples)\n break;\n for (int dir = -1; dir < 2; dir += 2) {\n if (i == 0 && dir == 1)\n continue;\n vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n if (all(equal(axis, vec3(0.0))))\n axis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);\n axis = normalize(axis);\n float theta = dTheta * float(dir * i);\n float cosTheta = cos(theta);\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross(axis, vOutputDirection) * sin(theta)\n + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n gl_FragColor.rgb +=\n weights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);\n }\n }\n gl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n "),blending:ie,depthTest:!1,depthWrite:!1})).type="SphericalGaussianBlur",iy),fy=null,my=null,vy=function(){for(var e=[],t=[],n=[],r=oy,i=0;i\n\nvec4 inputTexelToLinear(vec4 value){\n if(inputEncoding == 0){\n return value;\n }else if(inputEncoding == 1){\n return sRGBToLinear(value);\n }else if(inputEncoding == 2){\n return RGBEToLinear(value);\n }else if(inputEncoding == 3){\n return RGBMToLinear(value, 7.0);\n }else if(inputEncoding == 4){\n return RGBMToLinear(value, 16.0);\n }else if(inputEncoding == 5){\n return RGBDToLinear(value, 256.0);\n }else{\n return GammaToLinear(value, 2.2);\n }\n}\n\nvec4 linearToOutputTexel(vec4 value){\n if(outputEncoding == 0){\n return value;\n }else if(outputEncoding == 1){\n return LinearTosRGB(value);\n }else if(outputEncoding == 2){\n return LinearToRGBE(value);\n }else if(outputEncoding == 3){\n return LinearToRGBM(value, 7.0);\n }else if(outputEncoding == 4){\n return LinearToRGBM(value, 16.0);\n }else if(outputEncoding == 5){\n return LinearToRGBD(value, 256.0);\n }else{\n return LinearToGamma(value, 2.2);\n }\n}\n\nvec4 envMapTexelToLinear(vec4 color) {\n return inputTexelToLinear(color);\n}\n "}function zy(e,t,n,r,i){qm.call(this),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=void 0!==i?i:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1}function ky(e,t){var n=(this.sourceTexture=e).image.width,r=e.image.height,i={format:ct,magFilter:$e,minFilter:1008,type:t,generateMipmaps:!0,anisotropy:e.anisotropy,encoding:At,wrapS:e.wrapS,wrapT:e.wrapT};this.renderTarget=new en(n,r,i),this.renderTarget.texture.name=e.name,this.renderTarget.texture.flipY=e.flipY,this.camera=new qi(-1,1,1,-1,0,1),this.shader=new Fi({type:"RGBEToFloat",uniforms:Di.clone(Ji.copy.uniforms),vertexShader:Ji.copy.vertexShader,fragmentShader:Ji.copy.fragmentShader,defines:{MAP_TEXELS:1}}),this.planeMesh=new _i(new Zi(2,2,0),this.shader),this.planeMesh.material.map=e,this.scene=new Bn,this.scene.add(this.planeMesh),this.scene.add(this.camera),this.shader.uniforms.tDiffuse.value=e,this.shader.uniforms.opacity.value=1}Ty.prototype={constructor:Ty,fromScene:function(e){var t=1m)var v=((g=u