function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}}function _arrayWithHoles(e){if(Array.isArray(e))return e}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;nthis.length)&&(t=this.length),this.substring(t-e.length,t)===e}),Object.assign(o.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)},removeEventListener:function(e,t){if(void 0!==this._listeners){var n=this._listeners[e];if(void 0!==n){var r=n.indexOf(t);-1!==r&&n.splice(r,1)}}},dispatchEvent:function(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;for(var n=t.slice(0),r=0,i=n.length;r>8&255]+Xt[e>>16&255]+Xt[e>>24&255]+"-"+Xt[255&t]+Xt[t>>8&255]+"-"+Xt[t>>16&15|64]+Xt[t>>24&255]+"-"+Xt[63&n|128]+Xt[n>>8&255]+"-"+Xt[n>>16&255]+Xt[n>>24&255]+Xt[255&r]+Xt[r>>8&255]+Xt[r>>16&255]+Xt[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*qt.DEG2RAD},radToDeg:function(e){return e*qt.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 y=Math.sqrt(_),x=Math.atan2(y,v*g);m=Math.sin(m*x)/y,o=Math.sin(o*x)/y}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(rn.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(rn.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(qt.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 an=new sn,on=new rn;function sn(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}Object.assign(sn.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(on.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(on.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 an.copy(this).projectOnVector(e),this.sub(an)},reflect:function(e){return this.sub(an.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(qt.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 ln=new sn,cn=new mn,un=new sn(0,0,0),dn=new sn(1,1,1),hn=new sn,pn=new sn,fn=new sn;function mn(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0s)return!1}return!0}Object.assign(Zn.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 sn),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,Bn),Bn.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(Xn),Hn.subVectors(this.max,Xn),Un.subVectors(e.a,Xn),Vn.subVectors(e.b,Xn),kn.subVectors(e.c,Xn),Gn.subVectors(Vn,Un),jn.subVectors(kn,Vn),Wn.subVectors(Un,kn);var t=[0,-Gn.z,Gn.y,0,-jn.z,jn.y,0,-Wn.z,Wn.y,Gn.z,0,-Gn.x,jn.z,0,-jn.x,Wn.z,0,-Wn.x,-Gn.y,Gn.x,0,-jn.y,jn.x,0,-Wn.y,Wn.x,0];return!!Qn(t,Un,Vn,kn,Hn)&&(!!Qn(t=[1,0,0,0,1,0,0,0,1],Un,Vn,kn,Hn)&&(Yn.crossVectors(Gn,jn),Qn(t=[Yn.x,Yn.y,Yn.z],Un,Vn,kn,Hn)))},clampPoint:function(e,t){return void 0===t&&(console.warn("v3d.Box3: .clampPoint() target is now required"),t=new sn),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Bn.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(Bn).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()||(Fn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Fn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Fn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Fn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Fn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Fn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Fn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Fn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Fn)),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 Kn,Jn,$n=new Zn;function er(e,t){this.center=void 0!==e?e:new sn,this.radius=void 0!==t?t:0}Object.assign(er.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):$n.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 Zn),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:(Kn=new sn,Jn=new sn,function(e){var t=this.center,n=this.radius,r=e.center,i=e.radius;Kn.subVectors(r,t);var a=Kn.length();if(a+i<=n)return this;if(a+n<=i)return this.copy(e),this;var o=.5*(n+a+i);return Jn.copy(Kn).multiplyScalar((o-n)/a),Jn.add(t),this.center.copy(Jn),this.radius=o,this})});var tr=new sn,nr=new sn,rr=new sn,ir=new sn,ar=new sn,or=new sn,sr=new sn;function lr(e,t){this.origin=void 0!==e?e:new sn,this.direction=void 0!==t?t:new sn(0,0,-1)}Object.assign(lr.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 sn),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,tr)),this},closestPointToPoint:function(e,t){void 0===t&&(console.warn("v3d.Ray: .closestPointToPoint() target is now required"),t=new sn),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=tr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(tr.copy(this.direction).multiplyScalar(t).add(this.origin),tr.distanceToSquared(e))},distanceSqToSegment:function(e,t,n,r){nr.copy(e).add(t).multiplyScalar(.5),rr.copy(t).sub(e).normalize(),ir.copy(this.origin).sub(nr);var i,a,o,s,l=.5*e.distanceTo(t),c=-this.direction.dot(rr),u=ir.dot(this.direction),d=-ir.dot(rr),h=ir.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=qt.euclideanModulo(e,1),t=qt.clamp(t,0,1),n=qt.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=Cr(i,r,e+1/3),this.g=Cr(i,r,e),this.b=Cr(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&&0t&&(t=e[n]);return t}function Zr(e){return void 0!==e}function Qr(e,t,n){for(var r=0;rn.far?null:{distance:l,point:wi.clone(),object:e}}function Si(e,t,n,r,i,a,o,s,l,c,u,d){ci.fromBufferAttribute(i,c),ui.fromBufferAttribute(i,u),di.fromBufferAttribute(i,d);var h=e.morphTargetInfluences;if(t.morphTargets&&a&&h){mi.set(0,0,0),vi.set(0,0,0),gi.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 zi({type:"CubemapFromEquirect",uniforms:Ii(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Pe,blending:ae});i.uniforms.tEquirect.value=t;var a=new Mi(new Di(5,5,5),i);n.add(a);var o=new ki(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(e,n),a.geometry.dispose(),a.material.dispose(),this},((ji.prototype=Object.create($t.prototype)).constructor=ji).prototype.isDataTexture=!0;var Wi=new er,Xi=new sn;function Hi(e,t,n,r,i,a){this.planes=[void 0!==e?e:new hr,void 0!==t?t:new hr,void 0!==n?n:new hr,void 0!==r?r:new hr,void 0!==i?i:new hr,void 0!==a?a:new hr]}Object.assign(Hi.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],_=n[15];return t[0].setComponents(o-r,u-s,f-d,_-m).normalize(),t[1].setComponents(o+r,u+s,f+d,_+m).normalize(),t[2].setComponents(o+i,u+l,f+h,_+v).normalize(),t[3].setComponents(o-i,u-l,f-h,_-v).normalize(),t[4].setComponents(o-a,u-c,f-p,_-g).normalize(),t[5].setComponents(o+a,u+c,f+p,_+g).normalize(),this},intersectsObject:function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Wi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Wi)},intersectsSprite:function(e){return Wi.center.set(0,0,0),Wi.radius=.7071067811865476,Wi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Wi)},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) {\ndistanceFalloff *= pow2(saturate(1.0 - pow4(lightDistance / cutoffDistance)));\n}\nreturn distanceFalloff;\n#else\nif(cutoffDistance > 0.0 && decayExponent > 0.0) {\nreturn pow(saturate(-lightDistance / cutoffDistance + 1.0), decayExponent);\n}\nreturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert(const in vec3 diffuseColor) {\nreturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {\nfloat fresnel = exp2((-5.55473 * dotLH - 6.98316) * dotLH);\nreturn (1.0 - specularColor) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent(const in vec3 F0, const in float dotNV, const in float roughness) {\nfloat fresnel = exp2((-5.55473 * dotNV - 6.98316) * dotNV);\nvec3 Fr = max(vec3(1.0 - roughness), F0) - F0;\nreturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {\nfloat a2 = pow2(alpha);\nfloat gl = dotNL + sqrt(a2 + (1.0 - a2) * pow2(dotNL));\nfloat gv = dotNV + sqrt(a2 + (1.0 - a2) * pow2(dotNV));\nreturn 1.0 / (gl * gv);\n}\nfloat G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {\nfloat a2 = pow2(alpha);\nfloat gv = dotNL * sqrt(a2 + (1.0 - a2) * pow2(dotNV));\nfloat gl = dotNV * sqrt(a2 + (1.0 - a2) * pow2(dotNL));\nreturn 0.5 / max(gv + gl, EPSILON);\n}\nfloat D_GGX(const in float alpha, const in float dotNH) {\nfloat a2 = pow2(alpha);\nfloat denom = pow2(dotNH) * (a2 - 1.0) + 1.0;\nreturn RECIPROCAL_PI * a2 / pow2(denom);\n}\nvec3 BRDF_Specular_GGX(const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness) {\nfloat alpha = pow2(clamp(roughness, 0.04, 1.0));\nvec3 halfDir = normalize(incidentLight.direction + viewDir);\nfloat dotNL = saturate(dot(normal, incidentLight.direction));\nfloat dotNV = saturate(dot(normal, viewDir));\nfloat dotNH = saturate(dot(normal, halfDir));\nfloat dotLH = saturate(dot(incidentLight.direction, halfDir));\nvec3 F = F_Schlick(specularColor, dotLH);\nfloat G = G_GGX_SmithCorrelated(alpha, dotNL, dotNV);\nfloat D = D_GGX(alpha, dotNH);\nreturn F * (G * D);\n}\nvec2 LTC_Uv(const in vec3 N, const in vec3 V, const in float roughness) {\nconst float LUT_SIZE = 64.0;\nconst float LUT_SCALE = (LUT_SIZE - 1.0) / LUT_SIZE;\nconst float LUT_BIAS = 0.5 / LUT_SIZE;\nfloat dotNV = saturate(dot(N, V));\nvec2 uv = vec2(roughness, sqrt(1.0 - dotNV));\nuv = uv * LUT_SCALE + LUT_BIAS;\nreturn uv;\n}\nfloat LTC_ClippedSphereFormFactor(const in vec3 f) {\nfloat l = length(f);\nreturn max((l * l + f.z) / (l + 1.0), 0.0);\n}\nvec3 LTC_EdgeVectorFormFactor(const in vec3 v1, const in vec3 v2) {\nfloat x = dot(v1, v2);\nfloat y = abs(x);\nfloat a = 0.8543985 + (0.4965155 + 0.0145206 * y) * y;\nfloat b = 3.4175940 + (4.1616724 + y) * y;\nfloat v = a / b;\nfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt(max(1.0 - x * x, 1e-7)) - v;\nreturn 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]) {\nvec3 v1 = rectCoords[1] - rectCoords[0];\nvec3 v2 = rectCoords[3] - rectCoords[0];\nvec3 lightNormal = cross(v1, v2);\nif(dot(lightNormal, P - rectCoords[0]) < 0.0) return vec3(0.0);\nvec3 T1, T2;\nT1 = normalize(V - N * dot(V, N));\nT2 = - cross(N, T1);\nmat3 mat = mInv * transposeMat3(mat3(T1, T2, N));\nvec3 coords[4];\ncoords[0] = mat * (rectCoords[0] - P);\ncoords[1] = mat * (rectCoords[1] - P);\ncoords[2] = mat * (rectCoords[2] - P);\ncoords[3] = mat * (rectCoords[3] - P);\ncoords[0] = normalize(coords[0]);\ncoords[1] = normalize(coords[1]);\ncoords[2] = normalize(coords[2]);\ncoords[3] = normalize(coords[3]);\nvec3 vectorFormFactor = vec3(0.0);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[0], coords[1]);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[1], coords[2]);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[2], coords[3]);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[3], coords[0]);\nfloat result = LTC_ClippedSphereFormFactor(vectorFormFactor);\nreturn vec3(result);\n}\nvec2 get_BRDF_SpecCoeffsBlender(float x, float y) {\nvec3 xyFactors0 = vec3(x * x, y * y, x * y);\nvec3 xyFactors1 = vec3(x, y, 1);\nvec3 a0a1a2 = vec3(0.33749372, 0.15167605, 1.09684597);\nvec3 a3a4a5 = vec3(-1.26123466, -0.927699, 0.9199188);\nvec3 b0b1b2 = vec3(0.41699717, 0.44675109, 0.79947684);\nvec3 b3b4b5 = vec3(-1.19307849, -0.89813958, 0.89305222);\nvec3 c0c1c2 = vec3(0.29920727, 0.09505591, -0.9136233);\nvec3 c3c4c5 = vec3(0.77055201, 0.13006674, -0.23085581);\nvec3 d0d1d2 = vec3(15.05004149, 7.98517355, 13.30473726);\nvec3 d3d4d5 = vec3(-32.00353547, -12.97743434, 17.83646751);\nfloat coeff0 = (dot(xyFactors0, a0a1a2) + dot(xyFactors1, a3a4a5))\n/ (dot(xyFactors0, b0b1b2) + dot(xyFactors1, b3b4b5));\nfloat coeff1 = (dot(xyFactors0, c0c1c2) + dot(xyFactors1, c3c4c5))\n/ (dot(xyFactors0, d0d1d2) + dot(xyFactors1, d3d4d5));\ncoeff1 = clamp(coeff1, 0.0, 1.0);\nreturn vec2(coeff0, coeff1);\n}\nvec3 BRDF_Specular_GGX_Environment(const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness) {\nfloat dotNV = saturate(dot(normal, viewDir));\nvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\nreturn specularColor * brdf.x + brdf.y;\n}\nvec3 BRDF_Specular_GGX_Environment_Blender_Approx(const in GeometricContext geometry,\nconst in vec3 fresnelRefl0, const in vec3 fresnelRefl90,\nconst in float roughness, const int useCoat) {\nvec3 normal = geometry.normal;\n#ifdef CLEARCOAT\nif (useCoat == 1) {\nnormal = geometry.clearcoatNormal;\n}\n#endif\nfloat dotNV = saturate(dot(normal, geometry.viewDir));\nfloat angle = acos(abs(dotNV)) / PI_HALF;\nvec2 specCoeffs = get_BRDF_SpecCoeffsBlender(angle, roughness);\nvec3 specular = specCoeffs.x * fresnelRefl0\n+ specCoeffs.y * fresnelRefl90\n* vec3(saturate(50.0 * linearToRelativeLuminance(fresnelRefl0)));\n#if defined (COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX)\nspecular = saturate(specular);\n#endif\nreturn 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) {\nfloat dotNV = saturate(dot(geometry.normal, geometry.viewDir));\nvec3 F = F_Schlick_RoughnessDependent(specularColor, dotNV, roughness);\nvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\nvec3 FssEss = F * brdf.x + brdf.y;\nfloat Ess = brdf.x + brdf.y;\nfloat Ems = 1.0 - Ess;\nvec3 Favg = specularColor + (1.0 - specularColor) * 0.047619;\nvec3 Fms = FssEss * Favg / (1.0 - Ems * Favg);\nsingleScatter += FssEss;\nmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit() {\nreturn 0.25;\n}\nfloat D_BlinnPhong(const in float shininess, const in float dotNH) {\nreturn 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) {\nvec3 halfDir = normalize(incidentLight.direction + geometry.viewDir);\nfloat dotNH = saturate(dot(geometry.normal, halfDir));\nfloat dotLH = saturate(dot(incidentLight.direction, halfDir));\nvec3 F = F_Schlick(specularColor, dotLH);\nfloat G = G_BlinnPhong_Implicit();\nfloat D = D_BlinnPhong(shininess, dotNH);\nreturn F * (G * D);\n}\nfloat GGXRoughnessToBlinnExponent(const in float ggxRoughness) {\nreturn (2.0 / pow2(ggxRoughness + 0.0001) - 2.0);\n}\nfloat BlinnExponentToGGXRoughness(const in float blinnExponent) {\nreturn sqrt(2.0 / (blinnExponent + 2.0));\n}\n#if defined(USE_SHEEN)\nfloat D_Charlie(float roughness, float NoH) {\nfloat invAlpha = 1.0 / roughness;\nfloat cos2h = NoH * NoH;\nfloat sin2h = max(1.0 - cos2h, 0.0078125);\nreturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\nreturn 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) {\nvec3 N = geometry.normal;\nvec3 V = geometry.viewDir;\nvec3 H = normalize(V + L);\nfloat dotNH = saturate(dot(N, H));\nreturn specularColor * D_Charlie(roughness, dotNH) * V_Neubelt(dot(N, V), dot(N, L));\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\nuniform sampler2D bumpMap;\nuniform float bumpScale;\nvec2 dHdxy_fwd() {\nvec2 dSTdx = dFdx(vUv);\nvec2 dSTdy = dFdy(vUv);\nfloat Hll = bumpScale * texture2D(bumpMap, vUv).x;\nfloat dBx = bumpScale * texture2D(bumpMap, vUv + dSTdx).x - Hll;\nfloat dBy = bumpScale * texture2D(bumpMap, vUv + dSTdy).x - Hll;\nreturn vec2(dBx, dBy);\n}\nvec3 perturbNormalArb(vec3 surf_pos, vec3 surf_norm, vec2 dHdxy) {\nvec3 vSigmaX = vec3(dFdx(surf_pos.x), dFdx(surf_pos.y), dFdx(surf_pos.z));\nvec3 vSigmaY = vec3(dFdy(surf_pos.x), dFdy(surf_pos.y), dFdy(surf_pos.z));\nvec3 vN = surf_norm;\nvec3 R1 = cross(vSigmaY, vN);\nvec3 R2 = cross(vN, vSigmaX);\nfloat fDet = dot(vSigmaX, R1);\nfDet *= (float(gl_FrontFacing) * 2.0 - 1.0);\nvec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\nreturn normalize(abs(fDet) * surf_norm - vGrad);\n}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\nvec4 plane;\n#pragma unroll_loop\nfor (int i = 0; i < UNION_CLIPPING_PLANES; i++) {\nplane = clippingPlanes[i];\nif (dot(vViewPosition, plane.xyz) > plane.w) discard;\n}\n#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\nbool clipped = true;\n#pragma unroll_loop\nfor (int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i++) {\nplane = clippingPlanes[i];\nclipped = (dot(vViewPosition, plane.xyz) > plane.w) && clipped;\n}\nif (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) && !defined(DEPTH)\nvarying vec3 vViewPosition;\n#endif\nuniform 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) && !defined(DEPTH)\nvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && !defined(STANDARD) && !defined(PHONG) && !defined(MATCAP) && !defined(NODE) && !defined(LAMBERT) && !defined(DEPTH)\nvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\ndiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor.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) {\nconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\nhighp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, PI);\nreturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\nfloat precisionSafeLength(vec3 v) { return length(v); }\n#else\nfloat max3(vec3 v) { return max(max(v.x, v.y), v.z); }\nfloat precisionSafeLength(vec3 v) {\nfloat maxComponent = max3(abs(v));\nreturn length(v / maxComponent) * maxComponent;\n}\n#endif\nstruct IncidentLight {\nvec3 color;\nvec3 direction;\nbool visible;\n};\nstruct ReflectedLight {\nvec3 directDiffuse;\nvec3 directSpecular;\nvec3 indirectDiffuse;\nvec3 indirectSpecular;\n};\nstruct GeometricContext {\nvec3 position;\nvec3 normal;\nvec3 viewDir;\n#ifdef CLEARCOAT\nvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection(in vec3 dir, in mat4 matrix) {\nreturn normalize((matrix * vec4(dir, 0.0)).xyz);\n}\nvec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {\nreturn normalize((vec4(dir, 0.0) * matrix).xyz);\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\nfloat distance = dot(planeNormal, point - pointOnPlane);\nreturn - distance * planeNormal + point;\n}\nfloat sideOfPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\nreturn sign(dot(point - pointOnPlane, planeNormal));\n}\nvec3 linePlaneIntersect(in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal) {\nreturn lineDirection * (dot(planeNormal, pointOnPlane - pointOnLine) / dot(planeNormal, lineDirection)) + pointOnLine;\n}\nmat3 transposeMat3(const in mat3 m) {\nmat3 tmp;\ntmp[0] = vec3(m[0].x, m[1].x, m[2].x);\ntmp[1] = vec3(m[0].y, m[1].y, m[2].y);\ntmp[2] = vec3(m[0].z, m[1].z, m[2].z);\nreturn tmp;\n}\nfloat linearToRelativeLuminance(const in vec3 color) {\nvec3 weights = vec3(0.2126, 0.7152, 0.0722);\nreturn dot(weights, color.rgb);\n}\nbool isPerspectiveMatrix(mat4 m) {\nreturn m[2][3] == - 1.0;\n}\nhighp vec3 rand3(const in vec3 v) {\nconst highp float c = 43758.5453;\nconst highp mat3 coeffs = mat3(\n165.15, 253.34, 323.22,\n241.49, 329.07, 147.79,\n376.31, 143.45, 281.63\n);\nhighp vec3 sn = mod(coeffs * v, PI);\nreturn fract(sin(sn) * c);\n}\nfloat powCompat(const in float val, const in float power) {\nif (power == 0.0)\nreturn 1.0;\nelse if (val < 0.0) {\nif (mod(-power, 2.0) == 0.0)\nreturn pow(abs(val), power);\nelse\nreturn -pow(abs(val), power);\n} else if (val == 0.0)\nreturn 0.0;\nreturn pow(abs(val), power);\n}\nfloat maxFromRGB(vec3 rgb) {\nreturn max(max(rgb.r, rgb.g), rgb.b);\n}\nbool isOrtho(const in mat4 m) {\nif (m[3][3] != 0.0)\nreturn true;\nelse\nreturn false;\n}\nvec3 swizzleUpZ(const vec3 vec) {\nreturn vec3(vec[0], -vec[2], vec[1]);\n}\nvec3 swizzleUpY(const vec3 vec) {\nreturn vec3(vec[0], vec[2], -vec[1]);\n}\nvec3 xyz_to_sRGB(vec3 xyz) {\nmat3 convMat = mat3(\n3.2406, -0.9689, 0.0557,\n-1.5372, 1.8758, -0.2040,\n-0.4986, 0.0415, 1.0570\n);\nreturn convMat * xyz;\n}\nvec3 xyY_to_XYZ(float x, float y, float Y) {\nfloat X = 0.0;\nfloat Z = 0.0;\nif (y != 0.0) {\nX = (Y / y) * x;\nZ = (Y / y) * (1.0 - x - y);\n}\nreturn vec3(X, Y, Z);\n}\nvec3 octUVToCubeVec(vec2 octUV, vec2 texelSize) {\noctUV = (1.0 + 2.0 * texelSize) * octUV - texelSize;\noctUV = octUV * 2.0 - 1.0;\nfloat x = octUV.x;\nfloat z = -octUV.y;\nfloat absX = abs(x);\nfloat absZ = abs(z);\nvec3 cubeVec = vec3(x, 1.0 - absX - absZ, z);\nif (absX + absZ > 1.0) {\ncubeVec.xz = -(vec2(absZ, absX) - 1.0) * sign(vec2(x, z));\n}\nreturn cubeVec;\n}\nvec2 cubeVecToOctUV(vec3 cubeVec, vec2 texelSize) {\ncubeVec /= dot(vec3(1.0), abs(cubeVec));\nvec2 octUV = vec2(cubeVec.x, -cubeVec.z);\nif (cubeVec.y < 0.0) {\noctUV = sign(octUV) * (1.0 - abs(octUV.ts));\n}\noctUV = (octUV + 1.0) / 2.0;\noctUV = (1.0 - 2.0 * texelSize) * octUV + texelSize;\nreturn octUV;\n}\n#if __VERSION__ == 100\nfloat cosh(float x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec2 cosh(vec2 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec3 cosh(vec3 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec4 cosh(vec4 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nfloat sinh(float x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec2 sinh(vec2 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec3 sinh(vec3 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec4 sinh(vec4 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nfloat tanh(float x) {\nfloat exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec2 tanh(vec2 x) {\nvec2 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec3 tanh(vec3 x) {\nvec3 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec4 tanh(vec4 x) {\nvec4 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nfloat trunc(float x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec2 trunc(vec2 x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec3 trunc(vec3 x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec4 trunc(vec4 x) {\nreturn floor(abs(x)) * sign(x);\n}\n#endif\nfloat getSmoothFactor(float a, float b, float smoothness) {\nreturn max(smoothness - abs(a - b), 0.0) / smoothness;\n}\nfloat smoothMin(float a, float b, float smoothness) {\nfloat smoothFac = getSmoothFactor(a, b, smoothness);\nreturn min(a, b) - smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}\nfloat smoothMax(float a, float b, float smoothness) {\nfloat smoothFac = getSmoothFactor(a, b, smoothness);\nreturn max(a, b) + smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\nfloat getFace(vec3 direction) {\nvec3 absDirection = abs(direction);\nfloat face = -1.0;\nif (absDirection.x > absDirection.z) {\nif (absDirection.x > absDirection.y) {\nface = direction.x > 0.0 ? 0.0 : 3.0;\n} else {\nface = direction.y > 0.0 ? 1.0 : 4.0;\n}\n} else {\nif (absDirection.z > absDirection.y) {\nface = direction.z > 0.0 ? 2.0 : 5.0;\n} else {\nface = direction.y > 0.0 ? 1.0 : 4.0;\n}\n}\nreturn face;\n}\nvec2 getUV(vec3 direction, float face) {\nvec2 uv;\nif (face == 0.0) {\nuv = vec2(-direction.z, direction.y) / abs(direction.x);\n} else if (face == 1.0) {\nuv = vec2(direction.x, -direction.z) / abs(direction.y);\n} else if (face == 2.0) {\nuv = direction.xy / abs(direction.z);\n} else if (face == 3.0) {\nuv = vec2(direction.z, direction.y) / abs(direction.x);\n} else if (face == 4.0) {\nuv = direction.xz / abs(direction.y);\n} else {\nuv = vec2(-direction.x, direction.y) / abs(direction.z);\n}\nreturn 0.5 * (uv + 1.0);\n}\n#ifndef cubeUV_maxTileSize\n#define cubeUV_maxTileSize 256.0\n#endif\n#define cubeUV_lodIdxMin 0.0\n#define cubeUV_lodIdxLastDownscaled 4.0\n#define cubeUV_lodIdxMax 10.0\n#define cubeUV_minTileSize (cubeUV_maxTileSize / exp2(cubeUV_lodIdxLastDownscaled))\nfloat getLodTileSize(float lodIdx) {\nreturn cubeUV_maxTileSize / exp2(min(lodIdx, cubeUV_lodIdxLastDownscaled));\n}\nfloat getLodFilterLevel(float lodIdx) {\nreturn max(lodIdx - cubeUV_lodIdxLastDownscaled, 0.0);\n}\nvec2 fixCubeUVSeams(vec2 uv, float faceSize) {\nfloat BORDER_WIDTH_PX = max(cubeUV_maxTileSize / 256.0 - 1.0, 0.0);\nfloat scale = (faceSize - BORDER_WIDTH_PX) / faceSize;\nfloat offset = 0.5 * BORDER_WIDTH_PX / faceSize;\nreturn uv * scale + offset;\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float lodIdx) {\nfloat face = getFace(direction);\nfloat faceSize = getLodTileSize(lodIdx);\nfloat filterLevel = getLodFilterLevel(lodIdx);\nfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\nvec2 uv = getUV(direction, face);\nuv = fixCubeUVSeams(uv, faceSize);\nuv *= (faceSize - 1.0);\nvec2 f = fract(uv);\nuv += 0.5 - f;\nif (face > 2.0) {\nuv.y += faceSize;\nface -= 3.0;\n}\nuv.x += face * faceSize;\nif (lodIdx > 0.0) {\nuv.y += 2.0 * cubeUV_maxTileSize;\n}\nuv.y += filterLevel * 2.0 * cubeUV_minTileSize;\nuv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\nuv *= texelSize;\nvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nuv.x += texelSize;\nvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nuv.y += texelSize;\nvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nuv.x -= texelSize;\nvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\nvec3 tm = mix(tl, tr, f.x);\nvec3 bm = mix(bl, br, f.x);\nreturn mix(tm, bm, f.y);\n}\n#define cubeUV_r0 1.0\n#define cubeUV_v0 0.339\n#define cubeUV_m0 -2.0\n#define cubeUV_r1 0.8\n#define cubeUV_v1 0.276\n#define cubeUV_m1 -1.0\n#define cubeUV_r4 0.4\n#define cubeUV_v4 0.046\n#define cubeUV_m4 2.0\n#define cubeUV_r5 0.305\n#define cubeUV_v5 0.016\n#define cubeUV_m5 3.0\n#define cubeUV_r6 0.21\n#define cubeUV_v6 0.0038\n#define cubeUV_m6 4.0\nfloat roughnessToMip(float roughness) {\nfloat r = roughness;\nfloat r2 = r * r;\nfloat r3 = r2 * r;\nroughness = -1.20278049 * r3 + 1.86860137 * r2 + 0.32478081 * r + 0.0098139;\nreturn roughness * (cubeUV_lodIdxMax - cubeUV_lodIdxMin);\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\nfloat lodIdx = clamp(roughnessToMip(roughness), cubeUV_lodIdxMin,\ncubeUV_lodIdxMax);\nfloat lodIdxF = fract(lodIdx);\nfloat lodIdxI = floor(lodIdx);\nvec3 color0 = bilinearCubeUV(envMap, sampleDir, lodIdxI);\nif (lodIdxF == 0.0) {\nreturn vec4(color0, 1.0);\n} else {\nvec3 color1 = bilinearCubeUV(envMap, sampleDir, lodIdxI + 1.0);\nreturn vec4(mix(color0, color1, lodIdxF), 1.0);\n}\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\ntransformedNormal = mat3(instanceMatrix) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\ntransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\nvec3 transformedTangent = (modelViewMatrix * vec4(objectTangent, 0.0)).xyz;\n#ifdef FLIP_SIDED\ntransformedTangent = - transformedTangent;\n#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\nuniform sampler2D displacementMap;\nuniform float displacementScale;\nuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\ntransformed += normalize(objectNormal) * (texture2D(displacementMap, vUv).x * displacementScale + displacementBias);\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\nvec4 emissiveColor = texture2D(emissiveMap, vUv);\nemissiveColor.rgb = emissiveMapTexelToLinear(emissiveColor).rgb;\ntotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\nuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel(gl_FragColor);",encodings_pars_fragment:"\nvec4 LinearToLinear(in vec4 value) {\nreturn value;\n}\nvec4 GammaToLinear(in vec4 value, in float gammaFactor) {\nvalue = max(value, vec4(0.0));\nreturn vec4(pow(value.rgb, vec3(gammaFactor)), value.a);\n}\nvec4 LinearToGamma(in vec4 value, in float gammaFactor) {\nvalue = max(value, vec4(0.0));\nreturn vec4(pow(value.rgb, vec3(1.0 / gammaFactor)), value.a);\n}\nvec4 sRGBToLinear(in vec4 value) {\nvalue = max(value, vec4(0.0));\nreturn 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) {\nvalue = max(value, vec4(0.0));\nreturn 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) {\nreturn vec4(value.rgb * exp2(value.a * 255.0 - 128.0), 1.0);\n}\nvec4 LinearToRGBE(in vec4 value) {\nfloat maxComponent = max(max(value.r, value.g), value.b);\nfloat fExp = clamp(ceil(log2(maxComponent)), -128.0, 127.0);\nreturn vec4(value.rgb / exp2(fExp), (fExp + 128.0) / 255.0);\n}\nvec4 RGBMToLinear(in vec4 value, in float maxRange) {\nreturn vec4(value.rgb * value.a * maxRange, 1.0);\n}\nvec4 LinearToRGBM(in vec4 value, in float maxRange) {\nfloat maxRGB = max(value.r, max(value.g, value.b));\nfloat M = clamp(maxRGB / maxRange, 0.0, 1.0);\nM = ceil(M * 255.0) / 255.0;\nreturn vec4(value.rgb / (M * maxRange), M);\n}\nvec4 RGBDToLinear(in vec4 value, in float maxRange) {\nreturn vec4(value.rgb * ((maxRange / 255.0) / value.a), 1.0);\n}\nvec4 LinearToRGBD(in vec4 value, in float maxRange) {\nfloat maxRGB = max(value.r, max(value.g, value.b));\nfloat D = max(maxRange / maxRGB, 1.0);\nD = clamp(floor(D) / 255.0, 0.0, 1.0);\nreturn 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) {\nvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\nXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\nvec4 vResult;\nvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\nfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\nvResult.w = fract(Le);\nvResult.z = (Le - (floor(vResult.w * 255.0)) / 255.0) / 255.0;\nreturn 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) {\nfloat Le = value.z * 255.0 + value.w;\nvec3 Xp_Y_XYZp;\nXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\nXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\nXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\nvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\nreturn vec4(max(vRGB, 0.0), 1.0);\n}",envmap_fragment:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvec3 cameraToFrag;\nif (isOrthographic) {\ncameraToFrag = normalize(vec3(- viewMatrix[0][2], - viewMatrix[1][2], - viewMatrix[2][2]));\n} else {\ncameraToFrag = normalize(vWorldPosition - cameraPosition);\n}\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 reflectVec = reflect(cameraToFrag, worldNormal);\n#else\nvec3 reflectVec = refract(cameraToFrag, worldNormal, refractionRatio);\n#endif\n#else\nvec3 reflectVec = vReflect;\n#endif\n#ifdef ENVMAP_TYPE_CUBE\nvec4 envColor = textureCube(envMap, vec3(flipEnvMap * reflectVec.x, reflectVec.yz));\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envColor = textureCubeUV(envMap, reflectVec, 0.0);\n#elif defined(ENVMAP_TYPE_EQUIREC)\nvec2 sampleUV;\nreflectVec = normalize(reflectVec);\nsampleUV.y = asin(clamp(reflectVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(reflectVec.z, reflectVec.x) * RECIPROCAL_PI2 + 0.5;\nvec4 envColor = texture2D(envMap, sampleUV);\n#elif defined(ENVMAP_TYPE_SPHERE)\nreflectVec = normalize(reflectVec);\nvec3 reflectView = normalize((viewMatrix * vec4(reflectVec, 0.0)).xyz + vec3(0.0, 0.0, 1.0));\nvec4 envColor = texture2D(envMap, reflectView.xy * 0.5 + 0.5);\n#else\nvec4 envColor = vec4(0.0);\n#endif\n#ifndef ENVMAP_TYPE_CUBE_UV\nenvColor = envMapTexelToLinear(envColor);\n#endif\n#ifdef ENVMAP_BLENDING_MULTIPLY\noutgoingLight = mix(outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity);\n#elif defined(ENVMAP_BLENDING_MIX)\noutgoingLight = mix(outgoingLight, envColor.xyz, specularStrength * reflectivity);\n#elif defined(ENVMAP_BLENDING_ADD)\noutgoingLight += envColor.xyz * specularStrength * reflectivity;\n#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\nuniform float envMapIntensity;\nuniform float flipEnvMap;\nuniform int maxMipLevel;\n#ifdef ENVMAP_TYPE_CUBE\nuniform samplerCube envMap;\n#else\nuniform sampler2D envMap;\n#endif\n#if defined(ENVMAP_TYPE_CUBE) && defined(NODE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat calcGeometryRoughness(vec3 geometryNormal) {\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nreturn max(max(dxy.x, dxy.y), dxy.z);\n}\nfloat calcCubeUVAdjustedRoughness(float origRoughness, float geomRoughness) {\nreturn min(max(origRoughness, 0.0525) + geomRoughness, 1.0);\n}\n#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nuniform float reflectivity;\n#if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\nvarying vec3 vWorldPosition;\nuniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n#if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) ||defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\n\nvarying vec3 vWorldPosition;\n#else\nvarying vec3 vReflect;\nuniform float refractionRatio;\n#endif\n#endif",envmap_physical_pars_fragment:"#if defined(USE_ENVMAP)\n#ifdef ENVMAP_MODE_REFRACTION\nuniform float refractionRatio;\n#endif\nvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel) {\nvec3 worldNormal = inverseTransformDirection(geometry.normal, viewMatrix);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = textureCubeLodEXT(envMap, queryVec, float(maxMIPLevel));\n#else\nvec4 envMapColor = textureCube(envMap, queryVec, float(maxMIPLevel));\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\nvec4 envMapColor = textureCubeUV(envMap, queryVec, 1.0);\n#else\nvec4 envMapColor = vec4(0.0);\n#endif\nreturn PI * envMapColor.rgb * envMapIntensity;\n}\nfloat getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {\nfloat maxMIPLevelScalar = float(maxMIPLevel);\nfloat clapmedBlinnShininessExponent = min(blinnShininessExponent, 30000.0);\nfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248\n- 0.5 * log2(pow2(clapmedBlinnShininessExponent) + 1.0);\nreturn clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n}\nvec3 _getLightProbeIndirect(const float blinnShininessExponent,\nconst int maxMIPLevel, vec3 directionVec) {\nfloat specularMIPLevel = getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = textureCubeLodEXT(envMap, queryVec, specularMIPLevel);\n#else\nvec4 envMapColor = textureCube(envMap, queryVec, specularMIPLevel);\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\nvec4 envMapColor = textureCubeUV(envMap, queryVec,\nBlinnExponentToGGXRoughness(blinnShininessExponent));\n#elif defined(ENVMAP_TYPE_EQUIREC)\nvec2 sampleUV;\nsampleUV.y = asin(clamp(directionVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(directionVec.z, directionVec.x) * RECIPROCAL_PI2 + 0.5;\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = texture2DLodEXT(envMap, sampleUV, specularMIPLevel);\n#else\nvec4 envMapColor = texture2D(envMap, sampleUV, specularMIPLevel);\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#elif defined(ENVMAP_TYPE_SPHERE)\nvec3 reflectView = normalize((viewMatrix * vec4(directionVec, 0.0)).xyz + vec3(0.0,0.0,1.0));\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = texture2DLodEXT(envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel);\n#else\nvec4 envMapColor = texture2D(envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel);\n#endif\nenvMapColor.rgb = envMapTexelToLinear(envMapColor).rgb;\n#endif\nreturn envMapColor.rgb * envMapIntensity;\n}\nvec3 getLightProbeIndirectRadiance(\nconst GeometricContext geometry, const float blinnShininessExponent,\nconst int maxMIPLevel, const int useCoat) {\nvec3 normal = geometry.normal;\n#ifdef CLEARCOAT\nif (useCoat == 1) {\nnormal = geometry.clearcoatNormal;\n}\n#endif\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 directionVec = reflect(-geometry.viewDir, normal);\n#else\nvec3 directionVec = refract(-geometry.viewDir, normal, refractionRatio);\n#endif\ndirectionVec = inverseTransformDirection(directionVec, viewMatrix);\nreturn _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\ndirectionVec);\n}\nvec3 getLightProbeIndirectRefraction(\nconst GeometricContext geometry, const float blinnShininessExponent,\nconst int maxMIPLevel, const float refrRatio) {\nvec3 directionVec = refract(-geometry.viewDir, geometry.normal, refrRatio);\ndirectionVec = inverseTransformDirection(directionVec, viewMatrix);\nreturn _getLightProbeIndirect(blinnShininessExponent, maxMIPLevel,\ndirectionVec);\n}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvWorldPosition = worldPosition.xyz;\n#else\nvec3 cameraToVertex;\nif (isOrthographic) { \ncameraToVertex = normalize(vec3(- viewMatrix[0][2], - viewMatrix[1][2], - viewMatrix[2][2]));\n} else {\ncameraToVertex = normalize(worldPosition.xyz - cameraPosition);\n}\nvec3 worldNormal = inverseTransformDirection(transformedNormal, viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvReflect = reflect(cameraToVertex, worldNormal);\n#else\nvReflect = refract(cameraToVertex, worldNormal, refractionRatio);\n#endif\n#endif\n#endif",fog_vertex:"#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\nvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n#ifdef FOG_EXP2\nfloat fogFactor = 1.0 - exp(- fogDensity * fogDensity * fogDepth * fogDepth);\n#else\nfloat fogFactor = smoothstep(fogNear, fogFar, fogDepth);\n#endif\ngl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor);\n#endif",fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\nvarying float fogDepth;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\nuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance(vec3 normal, vec3 lightDirection) {\nfloat dotNL = dot(normal, lightDirection);\nvec2 coord = vec2(dotNL * 0.5 + 0.5, 0.0);\n#ifdef USE_GRADIENTMAP\nreturn texture2D(gradientMap, coord).rgb;\n#else\nreturn (coord.x < 0.7) ? vec3(0.7) : vec3(1.0);\n#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\nvec4 lightMapTexel= texture2D(lightMap, vUv2);\nreflectedLight.indirectDiffuse += PI * lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nuniform sampler2D lightMap;\nuniform 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\nvLightBack = vec3(0.0);\nvIndirectBack = vec3(0.0);\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\ngetPointDirectLightIrradiance(pointLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = PI * directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\ngetSpotDirectLightIrradiance(spotLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = PI * directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#endif\n#if NUM_DIR_LIGHTS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ngetDirectionalDirectLightIrradiance(directionalLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = PI * directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\nvIndirectFront += getHemisphereLightIrradiance(hemisphereLights[i], geometry);\n#ifdef DOUBLE_SIDED\nvIndirectBack += 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]) {\nfloat x = normal.x, y = normal.y, z = normal.z;\nvec3 result = shCoefficients[0] * 0.886227;\nresult += shCoefficients[1] * 2.0 * 0.511664 * y;\nresult += shCoefficients[2] * 2.0 * 0.511664 * z;\nresult += shCoefficients[3] * 2.0 * 0.511664 * x;\nresult += shCoefficients[4] * 2.0 * 0.429043 * x * y;\nresult += shCoefficients[5] * 2.0 * 0.429043 * y * z;\nresult += shCoefficients[6] * (0.743125 * z * z - 0.247708);\nresult += shCoefficients[7] * 2.0 * 0.429043 * x * z;\nresult += shCoefficients[8] * 0.429043 * (x * x - y * y);\nreturn result;\n}\nvec3 getLightProbeIrradiance(const in vec3 lightProbe[9], const in GeometricContext geometry) {\nvec3 worldNormal = inverseTransformDirection(geometry.normal, viewMatrix);\nvec3 irradiance = shGetIrradianceAt(worldNormal, lightProbe);\nreturn irradiance;\n}\nvec3 getAmbientLightIrradiance(const in vec3 ambientLightColor) {\nvec3 irradiance = ambientLightColor;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\nstruct DirectionalLight {\nvec3 direction;\nvec3 color;\nfloat shadowBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nvec3 position;\nfloat maxDistance;\nfloat expBias;\n};\nuniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];\nvoid getDirectionalDirectLightIrradiance(const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight) {\ndirectLight.color = directionalLight.color;\ndirectLight.direction = directionalLight.direction;\ndirectLight.visible = true;\n}\n#endif\n#if NUM_POINT_LIGHTS > 0\nstruct PointLight {\nvec3 position;\nvec3 color;\nfloat distance;\nfloat decay;\nfloat shadowBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform PointLight pointLights[NUM_POINT_LIGHTS];\nvoid getPointDirectLightIrradiance(const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight) {\nvec3 lVector = pointLight.position - geometry.position;\ndirectLight.direction = normalize(lVector);\nfloat lightDistance = length(lVector);\ndirectLight.color = pointLight.color;\ndirectLight.color *= punctualLightIntensityToIrradianceFactor(lightDistance, pointLight.distance, pointLight.decay);\ndirectLight.visible = (directLight.color != vec3(0.0));\n}\n#endif\n#if NUM_SPOT_LIGHTS > 0\nstruct SpotLight {\nvec3 position;\nvec3 direction;\nvec3 color;\nfloat distance;\nfloat decay;\nfloat coneCos;\nfloat penumbraCos;\nint shadow;\nfloat shadowBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform SpotLight spotLights[NUM_SPOT_LIGHTS];\nvoid getSpotDirectLightIrradiance(const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight) {\nvec3 lVector = spotLight.position - geometry.position;\ndirectLight.direction = normalize(lVector);\nfloat lightDistance = length(lVector);\nfloat angleCos = dot(directLight.direction, spotLight.direction);\n#if defined(MT_MAX) && defined(PHYSICALLY_CORRECT_LIGHTS)\nfloat coneCosDecayed = 2.0 * spotLight.coneCos - spotLight.penumbraCos;\nif (angleCos > coneCosDecayed) {\nfloat spotEffect = pow(max(angleCos, 0.0), log(0.5) / log(spotLight.penumbraCos) - 1.0);\nif (angleCos < spotLight.coneCos) {\nfloat decayFac = 1.0 + (spotLight.coneCos - angleCos)\n/ (spotLight.coneCos - spotLight.penumbraCos);\nspotEffect *= pow2(decayFac) * (3.0 - 2.0 * decayFac);\n}\ndirectLight.color = spotLight.color * spotEffect\n* punctualLightIntensityToIrradianceFactor(lightDistance,\nspotLight.distance, spotLight.decay);\ndirectLight.visible = true;\n} else {\ndirectLight.color = vec3(0.0);\ndirectLight.visible = false;\n}\n#else\nif (angleCos > spotLight.coneCos) {\nfloat spotEffect = smoothstep(spotLight.coneCos, spotLight.penumbraCos, angleCos);\ndirectLight.color = spotLight.color * spotEffect\n* punctualLightIntensityToIrradianceFactor(lightDistance,\nspotLight.distance, spotLight.decay);\ndirectLight.visible = true;\n} else {\ndirectLight.color = vec3(0.0);\ndirectLight.visible = false;\n}\n#endif\n}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\nstruct RectAreaLight {\nvec3 color;\nvec3 position;\nvec3 halfWidth;\nvec3 halfHeight;\n};\nuniform sampler2D ltc_1;\nuniform sampler2D ltc_2;\nuniform RectAreaLight rectAreaLights[NUM_RECT_AREA_LIGHTS];\n#endif\n#if NUM_HEMI_LIGHTS > 0\nstruct HemisphereLight {\nvec3 direction;\nvec3 skyColor;\nvec3 groundColor;\n};\nuniform HemisphereLight hemisphereLights[NUM_HEMI_LIGHTS];\nvec3 getHemisphereLightIrradiance(const in HemisphereLight hemiLight, const in GeometricContext geometry) {\nfloat dotNL = dot(geometry.normal, hemiLight.direction);\nfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\nvec3 irradiance = mix(hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight);\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreturn 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\nvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\nvec3 diffuseColor;\nvec3 specularColor;\nfloat specularShininess;\nfloat specularStrength;\n};\nvoid RE_Direct_Toon(const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight) {\nvec3 irradiance = getGradientIrradiance(geometry.normal, directLight.direction) * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\nreflectedLight.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) {\nreflectedLight.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\nvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\nvec3 diffuseColor;\nvec3 specularColor;\nfloat specularShininess;\nfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong(const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\nreflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\nreflectedLight.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) {\nreflectedLight.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);\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.specularRoughness = max(roughnessFactor, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\n#ifdef REFLECTIVITY\nmaterial.specularColor = mix(vec3(MAXIMUM_SPECULAR_COEFFICIENT * pow2(reflectivity)), diffuseColor.rgb, metalnessFactor);\n#else\nmaterial.specularColor = mix(vec3(DEFAULT_SPECULAR_COEFFICIENT), diffuseColor.rgb, metalnessFactor);\n#endif\n#ifdef CLEARCOAT\nmaterial.clearcoat = saturate(clearcoat);\nmaterial.clearcoatRoughness = max(clearcoatRoughness, 0.0525);\nmaterial.clearcoatRoughness += geometryRoughness;\nmaterial.clearcoatRoughness = min(material.clearcoatRoughness, 1.0);\n#endif\n#ifdef USE_SHEEN\nmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\nvec3 diffuseColor;\nfloat specularRoughness;\nvec3 specularColor;\n#ifdef CLEARCOAT\nfloat clearcoat;\nfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nvec3 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) {\nreturn 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\nvoid RE_Direct_RectArea_Physical(const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\nvec3 normal = geometry.normal;\nvec3 viewDir = geometry.viewDir;\nvec3 position = geometry.position;\nvec3 lightPos = rectAreaLight.position;\nvec3 halfWidth = rectAreaLight.halfWidth;\nvec3 halfHeight = rectAreaLight.halfHeight;\nvec3 lightColor = rectAreaLight.color;\nfloat roughness = material.specularRoughness;\nvec3 rectCoords[4];\nrectCoords[0] = lightPos + halfWidth - halfHeight;\nrectCoords[1] = lightPos - halfWidth - halfHeight;\nrectCoords[2] = lightPos - halfWidth + halfHeight;\nrectCoords[3] = lightPos + halfWidth + halfHeight;\nvec2 uv = LTC_Uv(normal, viewDir, roughness);\nvec4 t1 = texture2D(ltc_1, uv);\nvec4 t2 = texture2D(ltc_2, uv);\nmat3 mInv = mat3(\nvec3(t1.x, 0, t1.y),\nvec3( 0, 1, 0),\nvec3(t1.z, 0, t1.w)\n);\nvec3 fresnel = (material.specularColor * t2.x + (vec3(1.0) - material.specularColor) * t2.y);\nreflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate(normal, viewDir, position, mInv, rectCoords);\nreflectedLight.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) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, directLight.direction));\nvec3 ccIrradiance = ccDotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nccIrradiance *= PI;\n#endif\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\nreflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\n#ifdef USE_SHEEN\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_Sheen(\nmaterial.specularRoughness,\ndirectLight.direction,\ngeometry,\nmaterial.sheenColor\n);\n#else\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n#endif\nreflectedLight.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) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectSpecular_Physical(const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n#ifdef CLEARCOAT\nfloat ccDotNV = saturate(dot(geometry.clearcoatNormal, geometry.viewDir));\nreflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\nfloat ccDotNL = ccDotNV;\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\nfloat clearcoatInv = 1.0 - clearcoatDHR;\nvec3 singleScattering = vec3(0.0);\nvec3 multiScattering = vec3(0.0);\nvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\nBRDF_Specular_Multiscattering_Environment(geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering);\nvec3 diffuse = material.diffuseColor * (1.0 - (singleScattering + multiScattering));\nreflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\nreflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\nreflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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) {\nreturn 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)\ngeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if (NUM_POINT_LIGHTS > 0) && defined(RE_Direct)\nPointLight pointLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\npointLight = pointLights[i];\ngetPointDirectLightIrradiance(pointLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_POINT_LIGHT_SHADOWS)\ndirectLight.color *= all(bvec2(directLight.visible, receiveShadow)) ?\ngetPointShadow(pointLight, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n#endif\nRE_Direct(directLight, geometry, material, reflectedLight);\n}\n#endif\n#if (NUM_SPOT_LIGHTS > 0) && defined(RE_Direct)\nSpotLight spotLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\nspotLight = spotLights[i];\ngetSpotDirectLightIrradiance(spotLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_SPOT_LIGHT_SHADOWS)\nif (all(bvec2(directLight.visible, receiveShadow))) {\nif (spotLight.shadow == 1) {\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(spotLight.position\n- geometry.position, 0.0)).xyz);\n#endif\ndirectLight.color *= getSpotShadow(spotLight, spotShadowMap[i],\nvSpotShadowCoord[i], distWorld);\n} else if (spotLight.shadow == 2) {\ndirectLight.color *= getSpotOmniShadow(spotLight,\nspotShadowMap[i], vSpotShadowCoord[i]);\n}\n}\n#endif\nRE_Direct(directLight, geometry, material, reflectedLight);\n}\n#endif\n#if (NUM_DIR_LIGHTS > 0) && defined(RE_Direct)\nDirectionalLight directionalLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ndirectionalLight = directionalLights[i];\ngetDirectionalDirectLightIrradiance(directionalLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_DIR_LIGHT_SHADOWS)\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(directionalLight.position\n- geometry.position, 0.0)).xyz);\n#endif\ndirectLight.color *= all(bvec3(directLight.visible, receiveShadow,\nvViewPosition.z < directionalLight.maxDistance)) ?\ngetShadow(directionalShadowMap[i], directionalLight.shadowMapSize,\ndirectionalLight.shadowBias, directionalLight.expBias,\ndirectionalLight.shadowRadius, vDirectionalShadowCoord[i], distWorld) : 1.0;\n#endif\nRE_Direct(directLight, geometry, material, reflectedLight);\n}\n#endif\n#if (NUM_RECT_AREA_LIGHTS > 0) && defined(RE_Direct_RectArea)\nRectAreaLight rectAreaLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_RECT_AREA_LIGHTS; i++) {\nrectAreaLight = rectAreaLights[i];\nRE_Direct_RectArea(rectAreaLight, geometry, material, reflectedLight);\n}\n#endif\n#if defined(RE_IndirectDiffuse)\nvec3 iblIrradiance = vec3(0.0);\nvec3 irradiance = getAmbientLightIrradiance(ambientLightColor);\nirradiance += getLightProbeIrradiance(lightProbe, geometry);\n#if (NUM_HEMI_LIGHTS > 0)\n#pragma unroll_loop\nfor (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\nirradiance += getHemisphereLightIrradiance(hemisphereLights[i], geometry);\n#if defined(MT_BLENDER) && !defined(PHYSICAL)\nRE_HemiSpec_Blender(hemisphereLights[i], geometry, material, reflectedLight);\n#endif\n}\n#endif\n#endif\n#if defined(RE_IndirectSpecular)\nvec3 radiance = vec3(0.0);\nvec3 clearcoatRadiance = vec3(0.0);\n#endif\n#if defined(RE_Refraction) && defined(USE_REFRACTED_LIGHT)\nvec3 refraction = vec3(0.0);\n#endif",lights_fragment_maps:"#if defined(RE_IndirectDiffuse)\n#ifdef USE_LIGHTMAP\nvec4 lightMapTexel= texture2D(lightMap, vUv2);\nvec3 lightMapIrradiance = lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nlightMapIrradiance *= PI;\n#endif\nirradiance += lightMapIrradiance;\n#endif\n#if defined(USE_ENVMAP) && defined(STANDARD) && defined(ENVMAP_TYPE_CUBE_UV)\niblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel);\n#endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_IndirectSpecular)\nradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent(material), maxMipLevel, 0);\n#if defined(USE_SSR) && !defined(USE_SSR_REFRACT)\nradiance = computeSSR(radiance, geometry.normal, 0.0);\n#endif\n#ifdef CLEARCOAT\nclearcoatRadiance += getLightProbeIndirectRadiance(geometry, Material_ClearCoat_BlinnShininessExponent(material), maxMipLevel, 1);\n#endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_Refraction) && defined(USE_REFRACTED_LIGHT)\nrefraction += getLightProbeIndirectRefraction(geometry,\nMaterial_Refraction_BlinnShininessExponent(material), maxMipLevel,\n1.0 / material.refractionIOR);\n#ifdef USE_SSR_REFRACT\nrefraction = computeSSR(refraction, geometry.normal, material.refractionIOR);\n#endif\n#endif",lights_fragment_end:"#if defined(RE_IndirectDiffuse)\nRE_IndirectDiffuse(irradiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_IndirectSpecular)\nRE_IndirectSpecular(radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_Refraction) && defined(USE_REFRACTED_LIGHT)\nRE_Refraction(refraction, material, refractedLight);\n#endif",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\ngl_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)\nuniform float logDepthBufFC;\nvarying float vFragDepth;\nvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n#ifdef USE_LOGDEPTHBUF_EXT\nvarying float vFragDepth;\nvarying float vIsPerspective;\n#else\nuniform float logDepthBufFC;\n#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n#ifdef USE_LOGDEPTHBUF_EXT\nvFragDepth = 1.0 + gl_Position.w;\nvIsPerspective = float(isPerspectiveMatrix(projectionMatrix));\n#else\nif (isPerspectiveMatrix(projectionMatrix)) {\ngl_Position.z = log2(max(EPSILON, gl_Position.w + 1.0)) * logDepthBufFC - 1.0;\ngl_Position.z *= gl_Position.w;\n}\n#endif\n#endif",map_fragment:"#ifdef USE_MAP\nvec4 texelColor = texture2D(map, vUv);\ntexelColor = mapTexelToLinear(texelColor);\ndiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined(USE_MAP) || defined(USE_ALPHAMAP)\nvec2 uv = (uvTransform * vec3(gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1)).xy;\n#endif\n#ifdef USE_MAP\nvec4 mapTexel = texture2D(map, uv);\ndiffuseColor *= mapTexelToLinear(mapTexel);\n#endif\n#ifdef USE_ALPHAMAP\ndiffuseColor.a *= texture2D(alphaMap, uv).g;\n#endif",map_particle_pars_fragment:"#if defined(USE_MAP) || defined(USE_ALPHAMAP)\nuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\nuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\nvec4 texelMetalness = texture2D(metalnessMap, vUv);\nmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\nuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n#if NUM_MORPH_TARGETS > 0\nobjectNormal += (morphNormal0 - normal) * morphTargetInfluences[0];\n#endif\n#if NUM_MORPH_TARGETS > 1\nobjectNormal += (morphNormal1 - normal) * morphTargetInfluences[1];\n#endif\n#if NUM_MORPH_TARGETS > 2\nobjectNormal += (morphNormal2 - normal) * morphTargetInfluences[2];\n#endif\n#if NUM_MORPH_TARGETS > 3\nobjectNormal += (morphNormal3 - normal) * morphTargetInfluences[3];\n#endif\n#if NUM_MORPH_TARGETS > 4\nobjectNormal += (morphNormal4 - normal) * morphTargetInfluences[4];\n#endif\n#if NUM_MORPH_TARGETS > 5\nobjectNormal += (morphNormal5 - normal) * morphTargetInfluences[5];\n#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetBaseInfluence;\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[12];\n#else\nuniform float morphTargetInfluences[6];\n#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\ntransformed *= morphTargetBaseInfluence;\n#if NUM_MORPH_TARGETS > 0\ntransformed += morphTarget0 * morphTargetInfluences[0];\n#endif\n#if NUM_MORPH_TARGETS > 1\ntransformed += morphTarget1 * morphTargetInfluences[1];\n#endif\n#if NUM_MORPH_TARGETS > 2\ntransformed += morphTarget2 * morphTargetInfluences[2];\n#endif\n#if NUM_MORPH_TARGETS > 3\ntransformed += morphTarget3 * morphTargetInfluences[3];\n#endif\n#if NUM_MORPH_TARGETS > 4\ntransformed += morphTarget4 * morphTargetInfluences[4];\n#endif\n#if NUM_MORPH_TARGETS > 5\ntransformed += morphTarget5 * morphTargetInfluences[5];\n#endif\n#ifndef USE_MORPHNORMALS\n#if NUM_MORPH_TARGETS > 6\ntransformed += morphTarget6 * morphTargetInfluences[6];\n#endif\n#if NUM_MORPH_TARGETS > 7\ntransformed += morphTarget7 * morphTargetInfluences[7];\n#endif\n#if NUM_MORPH_TARGETS > 8\ntransformed += morphTarget8 * morphTargetInfluences[8];\n#endif\n#if NUM_MORPH_TARGETS > 9\ntransformed += morphTarget9 * morphTargetInfluences[9];\n#endif\n#if NUM_MORPH_TARGETS > 10\ntransformed += morphTarget10 * morphTargetInfluences[10];\n#endif\n#if NUM_MORPH_TARGETS > 11\ntransformed += morphTarget1 * morphTargetInfluences[11];\n#endif\n#endif\n#endif",normal_fragment_begin:"#ifdef FLAT_SHADED\nvec3 fdx = vec3(dFdx(vViewPosition.x), dFdx(vViewPosition.y), dFdx(vViewPosition.z));\nvec3 fdy = vec3(dFdy(vViewPosition.x), dFdy(vViewPosition.y), dFdy(vViewPosition.z));\nvec3 normal = normalize(cross(fdx, fdy));\n#else\nvec3 normal = normalize(vNormal);\n#ifdef DOUBLE_SIDED\n#ifdef FRONT_FACING_VALUE\nbool frontFacing = FRONT_FACING_VALUE;\n#else\nbool frontFacing = gl_FrontFacing;\n#endif\nnormal = normal * (float(frontFacing) * 2.0 - 1.0);\n#endif\n#ifdef USE_TANGENT\nvec3 tangent = normalize(vTangent);\nvec3 bitangent = normalize(vBitangent);\n#ifdef DOUBLE_SIDED\ntangent = tangent * (float(gl_FrontFacing) * 2.0 - 1.0);\nbitangent = bitangent * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\n#if defined(TANGENTSPACE_NORMALMAP) || defined(USE_CLEARCOAT_NORMALMAP)\nmat3 vTBN = mat3(tangent, bitangent, normal);\n#endif\n#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\nnormal = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\n#ifdef FLIP_SIDED\nnormal = - normal;\n#endif\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nnormal = normalize(normalMatrix * normal);\n#elif defined(TANGENTSPACE_NORMALMAP)\nvec3 mapN = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\nmapN.xy *= normalScale;\n#ifdef USE_TANGENT\nnormal = normalize(vTBN * mapN);\n#else\nnormal = perturbNormal2Arb(-vViewPosition, normal, mapN);\n#endif\n#elif defined(USE_BUMPMAP)\nnormal = perturbNormalArb(-vViewPosition, normal, dHdxy_fwd());\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\nuniform sampler2D normalMap;\nuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat3 normalMatrix;\n#endif\n#if !defined (USE_TANGENT) && (defined (TANGENTSPACE_NORMALMAP) || defined (USE_CLEARCOAT_NORMALMAP))\nvec3 perturbNormal2Arb(vec3 eye_pos, vec3 surf_norm, vec3 mapN) {\nvec3 q0 = vec3(dFdx(eye_pos.x), dFdx(eye_pos.y), dFdx(eye_pos.z));\nvec3 q1 = vec3(dFdy(eye_pos.x), dFdy(eye_pos.y), dFdy(eye_pos.z));\nvec2 st0 = dFdx(vUv.st);\nvec2 st1 = dFdy(vUv.st);\nfloat scale = sign(st1.t * st0.s - st0.t * st1.s);\nvec3 S = normalize((q0 * st1.t - q1 * st0.t) * scale);\nvec3 T = normalize((- q0 * st1.s + q1 * st0.s) * scale);\nvec3 N = normalize(surf_norm);\nmat3 tsn = mat3(S, T, N);\nmapN.xy *= (float(gl_FrontFacing) * 2.0 - 1.0);\nreturn normalize(tsn * mapN);\n}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\nvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\nvec3 clearcoatMapN = texture2D(clearcoatNormalMap, vUv).xyz * 2.0 - 1.0;\nclearcoatMapN.xy *= clearcoatNormalScale;\n#ifdef USE_TANGENT\nclearcoatNormal = normalize(vTBN * clearcoatMapN);\n#else\nclearcoatNormal = perturbNormal2Arb(- vViewPosition, clearcoatNormal, clearcoatMapN);\n#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\nuniform sampler2D clearcoatNormalMap;\nuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB(const in vec3 normal) {\nreturn normalize(normal) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal(const in vec3 rgb) {\nreturn 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) {\nvec4 r = vec4(fract(v * PackFactors), v);\nr.yzw -= r.xyz * ShiftRight8;\nreturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\nreturn dot(v, UnpackFactors);\n}\nvec4 pack2HalfToRGBA(vec2 v) {\nvec4 r = vec4(v.x, fract(v.x * 255.0), v.y, fract(v.y * 255.0));\nreturn vec4(r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half(vec4 v) {\nreturn 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) {\nreturn (viewZ + near) / (near - far);\n}\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\nreturn linearClipZ * (near - far) - near;\n}\nfloat viewZToPerspectiveDepth(const in float viewZ, const in float near, const in float far) {\nreturn ((near + viewZ) * far) / ((far - near) * viewZ);\n}\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\nreturn (near * far) / ((far - near) * invClipZ - far);\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\ngl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;\n#if defined(BACKGROUND_DEPTH)\ngl_Position.z = gl_Position.w;\n#endif",dithering_fragment:"#ifdef DITHERING\ngl_FragColor.rgb = dithering(gl_FragColor.rgb);\n#endif",dithering_pars_fragment:"#ifdef DITHERING\nvec3 dithering(vec3 color) {\nfloat grid_position = rand(gl_FragCoord.xy);\nvec3 dither_shift_RGB = vec3(0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0);\ndither_shift_RGB = mix(2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position);\nreturn color + dither_shift_RGB;\n}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\nvec4 texelRoughness = texture2D(roughnessMap, vUv);\nroughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\nuniform 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\nuniform sampler2D directionalShadowMap[NUM_DIR_LIGHT_SHADOWS];\nvarying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nuniform sampler2D spotShadowMap[NUM_SPOT_LIGHT_SHADOWS];\nvarying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nuniform sampler2D pointShadowMap[NUM_POINT_LIGHT_SHADOWS];\nvarying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];\n#endif\nconst vec3 PERMUTE_DIR_X = vec3(1.0, 0.0, 0.0);\nconst vec3 PERMUTE_DIR_Y = vec3(0.0, 1.0, 0.0);\nconst vec3 PERMUTE_DIR_Z = vec3(0.0, 0.0, 1.0);\nconst mat4 POISSON_DISK_0 = mat4(\n0.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,\n0.308258, 0.417332, -0.125623, -0.056098\n);\nconst mat4 POISSON_DISK_1 = mat4(\n0.145585, -0.305634, 0.264060, -0.661648,\n0.617942, 0.652121, -0.041412, -0.893582,\n0.463911, 0.039752, 0.212664, 0.810727,\n-0.955989, -0.014390, -0.652588, 0.671204\n);\nfloat texture2DCompare(sampler2D depths, vec2 uv, float compare) {\nreturn step(compare, unpackRGBAToDepth(texture2D(depths, uv)));\n}\nfloat texture2DShadowLerp(sampler2D depths, vec2 size, vec2 uv, float compare) {\nconst vec2 offset = vec2(0.0, 1.0);\nvec2 texelSize = vec2(1.0) / size;\nvec2 centroidUV = floor(uv * size + 0.5) / size;\nfloat lb = texture2DCompare(depths, centroidUV + texelSize * offset.xx, compare);\nfloat lt = texture2DCompare(depths, centroidUV + texelSize * offset.xy, compare);\nfloat rb = texture2DCompare(depths, centroidUV + texelSize * offset.yx, compare);\nfloat rt = texture2DCompare(depths, centroidUV + texelSize * offset.yy, compare);\nvec2 f = fract(uv * size + 0.5);\nfloat a = mix(lb, lt, f.y);\nfloat b = mix(rb, rt, f.y);\nfloat c = mix(a, b, f.x);\nreturn c;\n}\nfloat getShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias,\nfloat expBias, float shadowRadius, vec4 shadowCoord, float distWorld) {\nfloat shadow = 1.0;\nshadowCoord.xyz /= shadowCoord.w;\nbvec4 inFrustumVec = bvec4 (shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0);\nbool inFrustum = all(inFrustumVec);\nbvec3 frustumTestVec = bvec3(inFrustum, shadowCoord.z <= 1.0, shadowCoord.z >= 0.0);\nbool frustumTest = all(frustumTestVec);\nif (frustumTest) {\n#if defined(SHADOWMAP_TYPE_PCF)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat dx0 = - texelSize.x * shadowRadius;\nfloat dy0 = - texelSize.y * shadowRadius;\nfloat dx1 = + texelSize.x * shadowRadius;\nfloat dy1 = + texelSize.y * shadowRadius;\nshadow = (\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx0, dy0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(0.0, dy0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx1, dy0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx0, 0.0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx1, 0.0), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx0, dy1), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(0.0, dy1), shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + vec2(dx1, dy1), shadowCoord.z)\n) * (1.0 / 9.0);\n#elif defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat dx0 = - texelSize.x * shadowRadius;\nfloat dy0 = - texelSize.y * shadowRadius;\nfloat dx1 = + texelSize.x * shadowRadius;\nfloat dy1 = + texelSize.y * shadowRadius;\nshadow = (\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx0, dy0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(0.0, dy0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx1, dy0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx0, 0.0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx1, 0.0), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx0, dy1), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(0.0, dy1), shadowCoord.z) +\ntexture2DShadowLerp(shadowMap, shadowMapSize, shadowCoord.xy + vec2(dx1, dy1), shadowCoord.z)\n) * (1.0 / 9.0);\n#elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat randAngle = rand(gl_FragCoord.xy) * PI2;\nfloat c = cos(randAngle), s = sin(randAngle);\nmat2 sampleMat = mat2(c, s, -s, c)\n* mat2(shadowRadius * texelSize.x, 0.0, 0.0, shadowRadius * texelSize.y);\nshadow = (\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[0].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[0].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[1].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[1].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[2].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[2].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[3].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_0[3].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[0].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[0].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[1].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[1].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[2].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[2].zw, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[3].xy, shadowCoord.z) +\ntexture2DCompare(shadowMap, shadowCoord.xy + sampleMat * POISSON_DISK_1[3].zw, shadowCoord.z)\n) / 16.0;\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap, shadowCoord.xy).x\n- length(distWorld) - BLENDER_BIAS_MULT_POINT * shadowBias)));\n#else\nshadowCoord.z += shadowBias;\nshadow = texture2DCompare(shadowMap, shadowCoord.xy, shadowCoord.z);\n#endif\n}\nreturn shadow;\n}\nvec2 cubeToUV(vec3 v, float texelSizeY) {\nvec3 absV = abs(v);\nfloat scaleToCube = 1.0 / max(absV.x, max(absV.y, absV.z));\nabsV *= scaleToCube;\nv *= scaleToCube * (1.0 - 2.0 * texelSizeY);\nvec2 planar = v.xy;\nfloat almostATexel = 1.5 * texelSizeY;\nfloat almostOne = 1.0 - almostATexel;\nif (absV.z >= almostOne) {\nif (v.z > 0.0)\nplanar.x = 4.0 - v.x;\n} else if (absV.x >= almostOne) {\nfloat signX = sign(v.x);\nplanar.x = v.z * signX + 2.0 * signX;\n} else if (absV.y >= almostOne) {\nfloat signY = sign(v.y);\nplanar.x = v.x + 2.0 * signY + 2.0;\nplanar.y = v.z * signY - 2.0;\n}\nreturn vec2(0.125, 0.25) * planar + vec2(0.375, 0.75);\n}\nfloat getOmniShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias,\nfloat expBias, float shadowRadius, vec4 shadowCoord,\nfloat shadowCameraNear, float shadowCameraFar) {\nfloat shadow = 1.0;\nvec3 lightToPosition = shadowCoord.xyz;\nfloat dp = (length(lightToPosition) - shadowCameraNear)\n/ (shadowCameraFar - shadowCameraNear);\nbvec2 frustumTestVec = bvec2(dp <= 1.0, dp >= 0.0);\nbool frustumTest = all(frustumTestVec);\nif (frustumTest) {\ndp += shadowBias;\nvec3 bd3D = normalize(lightToPosition);\nvec2 texelSize = 1.0 / shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap,\ncubeVecToOctUV(bd3D, texelSize)).x\n- length(lightToPosition) - BLENDER_BIAS_MULT_POINT * shadowBias)));\n#elif defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nvec2 offset = vec2(-1, 1) * shadowRadius * texelSize.y;\nshadow = (\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.xyy, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.yyy, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.xyx, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.yyx, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.xxy, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.yxy, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.xxx, texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + offset.yxx, texelSize.y), dp)\n) * (1.0 / 9.0);\n#elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nfloat randAngle = rand(gl_FragCoord.xy) * PI2;\nfloat c = cos(randAngle), s = sin(randAngle);\nmat2 sampleMat = mat2(c, s, -s, c)\n* mat2(shadowRadius * texelSize.y, 0.0, 0.0, shadowRadius * texelSize.y);\nvec3 absBd3D = abs(bd3D);\nabsBd3D /= max(absBd3D.x, max(absBd3D.y, absBd3D.z));\nbvec2 isPointingCubeFace = greaterThan(absBd3D.xy, vec2(0.999));\nmat3 permuteMat = mat3(\nisPointingCubeFace.x ? PERMUTE_DIR_Y : PERMUTE_DIR_X,\nisPointingCubeFace.x || isPointingCubeFace.y ? PERMUTE_DIR_Z : PERMUTE_DIR_Y,\nisPointingCubeFace.x ? PERMUTE_DIR_X : isPointingCubeFace.y ? PERMUTE_DIR_Y : PERMUTE_DIR_Z\n);\nshadow = (\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[0].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[0].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[1].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[1].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[2].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[2].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[3].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_0[3].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[0].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[0].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[1].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[1].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[2].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[2].zw, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[3].xy, 0.0), texelSize.y), dp) +\ntexture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * POISSON_DISK_1[3].zw, 0.0), texelSize.y), dp)\n) / 16.0;\n#else\nshadow = texture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp);\n#endif\n}\nreturn shadow;\n}\n#if NUM_POINT_LIGHT_SHADOWS > 0\nfloat getPointShadow(PointLight light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\nmapSize *= 2.0;\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= MAX_PCF_POISSON_POINT_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nfloat getSpotOmniShadow(SpotLight light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= MAX_PCF_POISSON_SPOT_OMNI_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\nfloat biasLinearNormalizedToNonlinear(float bias, float near, float far,\nfloat projZ, float projW) {\nreturn (bias * (far + near) + 2.0 * projZ) / (bias * (far - near) + 2.0 * projW)\n- projZ / projW;\n}\nfloat getSpotShadow(SpotLight light, sampler2D shadowMap, vec4 shadowCoord,\nfloat distWorld) {\nfloat shadowRadius = light.shadowRadius;\nfloat shadowBias = light.shadowBias;\n#if defined(SHADOWMAP_TYPE_ESM)\nshadowRadius *= BLENDER_ESM_SPOT_SINGLE_BLUR_COEFF;\n#elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowBias = biasLinearNormalizedToNonlinear(shadowBias,\nlight.shadowCameraNear, light.shadowCameraFar, shadowCoord.z,\nshadowCoord.w);\n#endif\nreturn getShadow(shadowMap, light.shadowMapSize, shadowBias,\nlight.expBias, shadowRadius, shadowCoord, distWorld);\n}\n#endif\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nuniform mat4 directionalShadowMatrix[NUM_DIR_LIGHT_SHADOWS];\nvarying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nuniform mat4 spotShadowMatrix[NUM_SPOT_LIGHT_SHADOWS];\nvarying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nuniform mat4 pointShadowMatrix[NUM_POINT_LIGHT_SHADOWS];\nvarying 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\nfor (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\nvDirectionalShadowCoord[i] = directionalShadowMatrix[i] * worldPosition;\n}\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\nvSpotShadowCoord[i] = spotShadowMatrix[i] * worldPosition;\n}\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i++) {\nvPointShadowCoord[i] = pointShadowMatrix[i] * worldPosition;\n}\n#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\nfloat shadow = 1.0;\n#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nDirectionalLight directionalLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\ndirectionalLight = directionalLights[i];\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(directionalLight.position\n+ vViewPosition, 0.0)).xyz);\n#endif\nshadow *= all(bvec2(vViewPosition.z < directionalLight.maxDistance, receiveShadow))\n? getShadow(directionalShadowMap[i],\ndirectionalLight.shadowMapSize, directionalLight.shadowBias,\ndirectionalLight.expBias, directionalLight.shadowRadius,\nvDirectionalShadowCoord[i], distWorld) : 1.0;\n}\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nSpotLight spotLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\nspotLight = spotLights[i];\nif (receiveShadow) {\nif (spotLight.shadow == 1) {\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(spotLight.position\n+ vViewPosition, 0.0)).xyz);\n#endif\nshadow *= getSpotShadow(spotLight, spotShadowMap[i], vSpotShadowCoord[i],\ndistWorld);\n} else if (spotLight.shadow == 2) {\nshadow *= getSpotOmniShadow(spotLight, spotShadowMap[i],\nvSpotShadowCoord[i]);\n}\n}\n}\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nPointLight pointLight;\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i++) {\npointLight = pointLights[i];\nshadow *= receiveShadow ? getPointShadow(pointLight, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n}\n#endif\n#endif\nreturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\nmat4 boneMatX = getBoneMatrix(skinIndex.x);\nmat4 boneMatY = getBoneMatrix(skinIndex.y);\nmat4 boneMatZ = getBoneMatrix(skinIndex.z);\nmat4 boneMatW = getBoneMatrix(skinIndex.w);\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 bindMatrix;\nuniform mat4 bindMatrixInverse;\n#ifdef BONE_TEXTURE\nuniform highp sampler2D boneTexture;\nuniform int boneTextureSize;\nmat4 getBoneMatrix(const in float i) {\nfloat j = i * 4.0;\nfloat x = mod(j, float(boneTextureSize));\nfloat y = floor(j / float(boneTextureSize));\nfloat dx = 1.0 / float(boneTextureSize);\nfloat dy = 1.0 / float(boneTextureSize);\ny = dy * (y + 0.5);\nvec4 v1 = texture2D(boneTexture, vec2(dx * (x + 0.5), y));\nvec4 v2 = texture2D(boneTexture, vec2(dx * (x + 1.5), y));\nvec4 v3 = texture2D(boneTexture, vec2(dx * (x + 2.5), y));\nvec4 v4 = texture2D(boneTexture, vec2(dx * (x + 3.5), y));\nmat4 bone = mat4(v1, v2, v3, v4);\nreturn bone;\n}\n#else\nuniform mat4 boneMatrices[MAX_BONES];\nmat4 getBoneMatrix(const in float i) {\nmat4 bone = boneMatrices[int(i)];\nreturn bone;\n}\n#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\nvec4 skinVertex = bindMatrix * vec4(transformed, 1.0);\nvec4 skinned = vec4(0.0);\nskinned += boneMatX * skinVertex * skinWeight.x;\nskinned += boneMatY * skinVertex * skinWeight.y;\nskinned += boneMatZ * skinVertex * skinWeight.z;\nskinned += boneMatW * skinVertex * skinWeight.w;\ntransformed = (bindMatrixInverse * skinned).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\nmat4 skinMatrix = mat4(0.0);\nskinMatrix += skinWeight.x * boneMatX;\nskinMatrix += skinWeight.y * boneMatY;\nskinMatrix += skinWeight.z * boneMatZ;\nskinMatrix += skinWeight.w * boneMatW;\nskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\nobjectNormal = vec4(skinMatrix * vec4(objectNormal, 0.0)).xyz;\n#ifdef USE_TANGENT\nobjectTangent = vec4(skinMatrix * vec4(objectTangent, 0.0)).xyz;\n#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\nvec4 texelSpecular = texture2D(specularMap, vUv);\nspecularStrength = texelSpecular.r;\n#else\nspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\nuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined(TONE_MAPPING)\ngl_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) {\nreturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\nreturn 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) {\ncolor *= toneMappingExposure;\nreturn saturate(Uncharted2Helper(color) / Uncharted2Helper(vec3(toneMappingWhitePoint)));\n}\nvec3 OptimizedCineonToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\ncolor = max(vec3(0.0), color - 0.004);\nreturn pow((color * (6.2 * color + 0.5)) / (color * (6.2 * color + 1.7) + 0.06), vec3(2.2));\n}\nvec3 ACESFilmicToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\nreturn 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{\nreturn (abs(color.r) * 0.263 + abs(color.g) * 0.655 + abs(color.b) * 0.082);\n}\nfloat toneApproximateScotopicLuminance(vec3 color)\n{\nreturn (0.062 * color.r + 0.608 * color.g + 0.330 * color.b);\n}\nvec3 LogarithmicMaxToneMapping(vec3 color) {\nfloat inputScaleFactor = toneMappingPhysicalScale / PI;\nfloat brightness = (toneMappingBrightness < 0.0) ? 0.0 : (toneMappingBrightness * 0.7);\nfloat powerBot = toneMappingExteriorDaylight ? 4.0 : 2.0;\nfloat res = 100.0 / ORDERS_OF_MAG;\nfloat mag = floor((50.0 / res));\nfloat power = ((brightness / 20.0 - ORDERS_OF_MAG) - powerBot) + mag;\nfloat stepsize = 9.0 / res;\nfloat step = 50.0 - (mag * res);\nfloat param_c = (0.02 * toneMappingContrast) * 2.0;\nfloat param_b = pow(10.0, power) * (1.0 + (stepsize * step));\nfloat param_a = param_b * (1.0 + param_c);\nparam_c /= pow(2.0, toneMappingMidTones - 1.0);\nparam_b *= PI;\nvec3 whiteConstancyFactor = toneMappingWhiteColor;\nif (toneMappingChromaticAdaptation) {\nfloat luminance = toneCalcBrightness(whiteConstancyFactor);\nwhiteConstancyFactor.r = (whiteConstancyFactor.r > 0.001) ? luminance / whiteConstancyFactor.r : luminance / 0.001;\nwhiteConstancyFactor.g = (whiteConstancyFactor.g > 0.001) ? luminance / whiteConstancyFactor.g : luminance / 0.001;\nwhiteConstancyFactor.b = (whiteConstancyFactor.b > 0.001) ? luminance / whiteConstancyFactor.b : luminance / 0.001;\n}\nvec3 outColor = inputScaleFactor * color;\nif (toneMappingChromaticAdaptation) {\noutColor *= whiteConstancyFactor.rgb;\n}\nfloat luminance = toneCalcBrightness(outColor);\nif (toneMappingColorDifferentiation && (luminance < 5.62)) {\nfloat sLuminance = toneApproximateScotopicLuminance(outColor);\nif (luminance <= 5.62e-3) {\noutColor = vec3(sLuminance);\n} else {\nfloat w = (luminance - 5.62e-3) / 5.61438;\noutColor = outColor * w + sLuminance * (1.0 - w);\n}\n}\noutColor = outColor * (param_a / (param_b * outColor + param_c));\nreturn outColor;\n}\nfloat maxExposurePhotographic(in vec4 color1, in vec4 color2)\n{\nreturn ((color1.r * color2.r) + (color1.g * color2.g)) + (color1.b * color2.b);\n}\nvec3 PhysicalMaxToneMapping(vec3 color) {\nfloat vignettingInfluence = 1.0;\nif (toneMappingVignetting > 0.0) {\nvec3 vignettingCoords = vec3(0.0, 0.0, 0.0);\nfloat aspect = toneMappingResolution.x / toneMappingResolution.y;\nvignettingCoords.x = gl_FragCoord.x / toneMappingResolution.x - 0.5;\nvignettingCoords.y = (gl_FragCoord.y / toneMappingResolution.y - 0.5) / aspect;\nvignettingCoords.z = 1.0;\nvignettingCoords = normalize(vignettingCoords);\nvignettingInfluence = pow(vignettingCoords.z, toneMappingVignetting);\n}\nfloat inputScaleFactor = toneMappingPhysicalScale / PI;\nfloat filmISO = toneMappingISO;\nfloat camShutter = 1.0 / toneMappingShutter;\nfloat fNumber = toneMappingAperture;\nfloat cm2 = 1.0;\nfloat burnHighlights = toneMappingHighlights;\nfloat crushBlacks = toneMappingShadows;\nfloat saturation = toneMappingSaturation;\nvec3 whitePointInfluence = toneMappingWhiteBalance;\nif (whitePointInfluence.r > 0.0) {\nwhitePointInfluence.r = 1.0 / whitePointInfluence.r;\n} else {\nwhitePointInfluence.r = 1.0;\n}\nif (whitePointInfluence.g > 0.0) {\nwhitePointInfluence.g = 1.0 / whitePointInfluence.g;\n} else {\nwhitePointInfluence.g = 1.0;\n}\nif (whitePointInfluence.b > 0.0) {\nwhitePointInfluence.b = 1.0 / whitePointInfluence.b;\n} else {\nwhitePointInfluence.b = 1.0;\n}\nvec4 lumFactor = vec4(0.212671, 0.715160, 0.072169, 0.0);\nfloat whiteLumFactor = maxExposurePhotographic(lumFactor, vec4(whitePointInfluence, 0.0));\nwhitePointInfluence.r /= whiteLumFactor;\nwhitePointInfluence.g /= whiteLumFactor;\nwhitePointInfluence.b /= whiteLumFactor;\nfloat isoInfluence = 0.0;\nfloat camShutterInv = 1.0 / camShutter;\nif (filmISO > 0.0) {\nisoInfluence = ((cm2 * 0.169811) * (filmISO * camShutterInv)) / ((15.4 * fNumber) * fNumber);\n} else {\nisoInfluence = cm2;\n}\nvec3 outColor = inputScaleFactor * color;\noutColor.r = outColor.r * whitePointInfluence.r * isoInfluence * vignettingInfluence;\noutColor.g = outColor.g * whitePointInfluence.g * isoInfluence * vignettingInfluence;\noutColor.b = outColor.b * whitePointInfluence.b * isoInfluence * vignettingInfluence;\noutColor.r = (outColor.r * (1.0 + (outColor.r * burnHighlights))) / (1.0 + outColor.r);\noutColor.g = (outColor.g * (1.0 + (outColor.g * burnHighlights))) / (1.0 + outColor.g);\noutColor.b = (outColor.b * (1.0 + (outColor.b * burnHighlights))) / (1.0 + outColor.b);\nfloat lumFactor2 = maxExposurePhotographic(lumFactor, vec4(outColor, 0.0));\nfloat tmpFloat = 1.0 - saturation;\noutColor.r = outColor.r * saturation + lumFactor2 * tmpFloat;\noutColor.g = outColor.g * saturation + lumFactor2 * tmpFloat;\noutColor.b = outColor.b * saturation + lumFactor2 * tmpFloat;\noutColor = max(vec3(0.0), outColor);\nfloat crushBlacksFac = crushBlacks * 2.0 + 1.0;\nfloat crushBlacksFac2 = pow(maxExposurePhotographic(lumFactor, vec4(outColor, 0.0)), 0.5);\ntmpFloat = (1.0 - crushBlacksFac2);\nif (crushBlacksFac2 < 1.0) {\noutColor.r = outColor.r * crushBlacksFac2 + pow(outColor.r, crushBlacksFac) * tmpFloat;\noutColor.g = outColor.g * crushBlacksFac2 + pow(outColor.g, crushBlacksFac) * tmpFloat;\noutColor.b = outColor.b * crushBlacksFac2 + pow(outColor.b, crushBlacksFac) * tmpFloat;\n}\nreturn outColor;\n}\nfloat filmicBlenderDesaturationMinIntensity(vec3 color) {\nfloat maxChannel = max(color.r, max(color.g, color.b));\nfloat x = max(maxChannel, 0.6251);\nreturn (1.2192868 * x - 0.63221059)\n* ((x - 0.65069831) / (abs(x - 0.65069831) + 0.00952982) + 0.73015231);\n}\nvec3 filmicBlenderDesaturationTransform(vec3 color) {\nconst float CURVE_SMOOTHNESS = 0.03;\nfloat minIntensity = filmicBlenderDesaturationMinIntensity(color);\nvec4 x = vec4(color, 1.0) - minIntensity;\nx = pow(x, vec4(2.0)) / (abs(x) + CURVE_SMOOTHNESS);\nreturn (x.rgb - x.a + color + 1.0) / 2.0;\n}\nvec3 filmicBlenderDynamicRangeTransform(vec3 color) {\nreturn pow(\n(0.28882259 * color - 0.15880336)\n/ (pow(color - 0.6229693, vec3(2.0)) + 0.16965022)\n+ 0.20453365 * color + 0.37847142,\nvec3(3.0)\n);\n}\nvec3 FilmicBlenderToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\ncolor = max(color, 0.000175);\ncolor = clamp((log2(color) - FILMIC_BLENDER_LOG_MIN)\n/ (FILMIC_BLENDER_LOG_MAX - FILMIC_BLENDER_LOG_MIN), 0.0, 1.0);\ncolor = filmicBlenderDesaturationTransform(color);\ncolor = clamp(color / FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO, 0.0, 1.0);\ncolor = filmicBlenderDynamicRangeTransform(color);\nreturn color;\n}",uv_pars_fragment:"#if (defined(USE_UV) && !defined(UVS_VERTEX_ONLY))\nvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n#ifdef UVS_VERTEX_ONLY\nvec2 vUv;\n#else\nvarying vec2 vUv;\n#endif\nuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\nvUv = (uvTransform * vec3(uv, 1)).xy;\n#endif",uv2_pars_fragment:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nattribute vec2 uv2;\nvarying vec2 vUv2;\nuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nvUv2 = (uv2Transform * vec3(uv2, 1)).xy;\n#endif",worldpos_vertex:"#if defined(USE_ENVMAP) || defined(DISTANCE) || defined (USE_SHADOWMAP) || defined(MASK) || defined(NODE)\nvec4 worldPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nworldPosition = instanceMatrix * worldPosition;\n#endif\nworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\nvec4 texColor = texture2D(t2D, vUv);\ngl_FragColor = mapTexelToLinear(texColor);\n#include \n#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\nvUv = (uvTransform * vec3(uv, 1)).xy;\ngl_Position = vec4(position.xy, 1.0, 1.0);\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\nvec3 vReflect = vWorldDirection;\n#include \ngl_FragColor = envColor;\ngl_FragColor.a *= opacity;\n#include \n#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\nvWorldDirection = transformDirection(position, modelMatrix);\n#include \n#include \ngl_Position.z = gl_Position.w;\n}",depth_frag:"#define DEPTH\nvarying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\n#if DEPTH_PACKING == 3200\nuniform float opacity;\n#endif\n#ifdef USE_SLOPE_SCALED_BIAS\nuniform float slopeScaledBias;\nconst 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 \nvec4 diffuseColor = vec4(1.0);\n#if DEPTH_PACKING == 3200\ndiffuseColor.a = opacity;\n#endif\n#include \n#include \n#include \n#include \n#if DEPTH_PACKING != 3202\nfloat depth = vProjectedPosZW.x / vProjectedPosZW.y;\ndepth = (depth + 1.0) / 2.0;\n#ifdef USE_SLOPE_SCALED_BIAS\nvec2 dxdy = abs(vec2(dFdx(depth), dFdy(depth)));\nfloat bias = slopeScaledBias * max(dxdy.x, dxdy.y);\ndepth = clamp(depth + max(bias, 1e-7), 0.0, ONE_MINUS_EPS);\n#endif\n#if DEPTH_PACKING == 3200\ngl_FragColor = vec4(vec3(1.0 - depth), opacity);\n#elif DEPTH_PACKING == 3201\ngl_FragColor = packDepthToRGBA(depth);\n#endif\n#else\ngl_FragColor = vec4(vViewPosition.z);\n#endif\n}",depth_vert:"#define DEPTH\nvarying 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 \nvViewPosition = mvPosition.xyz;\nvProjectedPosZW = mat2(\nprojectionMatrix[2][2], projectionMatrix[2][3],\nprojectionMatrix[3][2], projectionMatrix[3][3]\n) * mvPosition.zw;\n}",distanceRGBA_frag:"#define DISTANCE\n#ifdef USE_SLOPE_SCALED_BIAS\nuniform float slopeScaledBias;\nconst 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 \nvec4 diffuseColor = vec4(1.0);\n#include \n#include \n#include \nfloat dist = length(vWorldPosition - referencePosition);\n#if DISTANCE_PACKING == 3301\ndist = (dist - nearDistance) / (farDistance - nearDistance);\ndist = saturate(dist);\n#ifdef USE_SLOPE_SCALED_BIAS\nvec2 dxdy = abs(vec2(dFdx(dist), dFdy(dist)));\nfloat bias = slopeScaledBias * max(dxdy.x, dxdy.y);\ndist = clamp(dist + bias, 0.0, ONE_MINUS_EPS);\n#endif\ngl_FragColor = packDepthToRGBA(dist);\n#elif DISTANCE_PACKING == 3302\ngl_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 \nvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nuniform bool invertU;\nuniform float offsetU;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\nvec3 direction = normalize(vWorldDirection);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\n\nif (invertU) {\nsampleUV.x = 1.0 - sampleUV.x;\n}\n\nsampleUV.x += offsetU;\nvec4 texColor = texture2D(tEquirect, sampleUV);\ngl_FragColor = mapTexelToLinear(texColor);\n#include \n#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\nvWorldDirection = 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 \nif (mod(vLineDistance, totalSize) > dashSize) {\ndiscard;\n}\nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \noutgoingLight = diffuseColor.rgb;\ngl_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 \nvLineDistance = scale * lineDistance;\nvec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\ngl_Position = projectionMatrix * mvPosition;\n#include \n#include \n#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \n#include \n#include \n#include \n#include \nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_LIGHTMAP\n\nvec4 lightMapTexel= texture2D(lightMap, vUv2);\nreflectedLight.indirectDiffuse += lightMapTexelToLinear(lightMapTexel).rgb * lightMapIntensity;\n#else\nreflectedLight.indirectDiffuse += vec3(1.0);\n#endif\n#include \nreflectedLight.indirectDiffuse *= diffuseColor.rgb;\nvec3 outgoingLight = reflectedLight.indirectDiffuse;\n#include \ngl_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\nvarying vec3 vLightBack;\nvarying vec3 vIndirectBack;\n#endif\nvarying vec3 vViewPosition;\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 \nvoid main() {\n#include \nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 totalEmissiveRadiance = emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nreflectedLight.indirectDiffuse = getAmbientLightIrradiance(ambientLightColor);\n#ifdef DOUBLE_SIDED\nreflectedLight.indirectDiffuse += (gl_FrontFacing) ? vIndirectFront : vIndirectBack;\n#else\nreflectedLight.indirectDiffuse += vIndirectFront;\n#endif\n#include \nreflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert(diffuseColor.rgb);\n#ifdef DOUBLE_SIDED\nreflectedLight.directDiffuse = (gl_FrontFacing) ? vLightFront : vLightBack;\n#else\nreflectedLight.directDiffuse = vLightFront;\n#endif\nreflectedLight.directDiffuse *= BRDF_Diffuse_Lambert(diffuseColor.rgb) * getShadowMask();\n#include \nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n#include \ngl_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\nvarying vec3 vLightBack;\nvarying vec3 vIndirectBack;\n#endif\nvarying vec3 vViewPosition;\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 \nvViewPosition = - mvPosition.xyz;\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\nvarying 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 \nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \n#include \n#include \n#include \n#include \nvec3 viewDir = normalize(vViewPosition);\nvec3 x = normalize(vec3(viewDir.z, 0.0, - viewDir.x));\nvec3 y = cross(viewDir, x);\nvec2 uv = vec2(dot(x, normal), dot(y, normal)) * 0.495 + 0.5;\n#ifdef USE_MATCAP\nvec4 matcapColor = texture2D(matcap, uv);\nmatcapColor = matcapTexelToLinear(matcapColor);\n#else\nvec4 matcapColor = vec4(1.0);\n#endif\nvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\ngl_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\nvarying 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\nvNormal = normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = - 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 \nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 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 \nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\ngl_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\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = - 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 \nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 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 \nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n#include \ngl_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\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#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\nvNormal = normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = - 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\nuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\nuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\nuniform float clearcoat;\nuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nuniform vec3 sheen;\n#endif\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying 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 \nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 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 \nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n#ifdef TRANSPARENCY\ndiffuseColor.a *= saturate(1. - transparency + linearToRelativeLuminance(reflectedLight.directSpecular + reflectedLight.indirectSpecular));\n#endif\ngl_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\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying 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\nvNormal = normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent = normalize(transformedTangent);\nvBitangent = normalize(cross(vNormal, vTangent) * tangent.w);\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = - 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)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying 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 \ngl_FragColor = vec4(packNormalToRGB(normal), opacity);\n}",normal_vert:"#define NORMAL\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying 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\nvNormal = normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent = normalize(transformedTangent);\nvBitangent = 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)\nvViewPosition = - 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 \nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \n#include \n#include \noutgoingLight = diffuseColor.rgb;\ngl_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 \ngl_PointSize = size;\n#ifdef USE_SIZEATTENUATION\nbool isPerspective = isPerspectiveMatrix(projectionMatrix);\nif (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() {\ngl_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\nvViewPosition = - 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 \nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \n#include \n#include \noutgoingLight = diffuseColor.rgb;\ngl_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 \nvec4 mvPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\nvec2 scale;\nscale.x = length(vec3(modelMatrix[0].x, modelMatrix[0].y, modelMatrix[0].z));\nscale.y = length(vec3(modelMatrix[1].x, modelMatrix[1].y, modelMatrix[1].z));\n#ifndef USE_SIZEATTENUATION\nbool isPerspective = isPerspectiveMatrix(projectionMatrix);\nif (isPerspective) scale *= - mvPosition.z;\n#endif\nvec2 alignedPosition = (position.xy - (center - vec2(0.5))) * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\nmvPosition.xy += rotatedPosition;\ngl_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() {\nvec3 direction;\nvec2 uv = vUv * 2.0 - 1.0;\nif (faceIndex==0) {\ndirection = vec3(1.0, -uv.y, -uv.x);\n} else if (faceIndex==1) {\ndirection = vec3(-1.0, -uv.y, uv.x);\n} else if (faceIndex==2) {\ndirection = vec3(uv.x, 1.0, uv.y);\n} else if (faceIndex==3) {\ndirection = vec3(uv.x, -1.0, -uv.y);\n} else if (faceIndex==4) {\ndirection = vec3(uv.x, -uv.y, 1.0);\n} else {\ndirection = vec3(-uv.x, -uv.y, -1.0);\n}\ndirection = normalize(direction);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\nif (invertU) {\nsampleUV.x = 1.0 - sampleUV.x;\n}\n\nsampleUV.x += offsetU;\ngl_FragColor = texture2D(tEquirect, sampleUV);\n}",equicube_vert:"varying vec2 vUv;\n#include \nvoid main() {\nvUv = 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 \nvec4 diffuseColor = vec4(1.0);\ndiffuseColor.a = opacity;\n#include \n#include \n#include \n#include \nfloat depth = unpackRGBAToDepth(texture2DProj(depthTexture, projTexCoord));\nfloat viewZ;\nif (isOrtho(projectionMatrix))\nviewZ = -orthographicDepthToViewZ(depth,\ncameraNearFar.x, cameraNearFar.y);\nelse\nviewZ = -perspectiveDepthToViewZ(depth,\ncameraNearFar.x, cameraNearFar.y);\nfloat depthTest = (vViewPosition.z > viewZ) ? 1.0 : 0.0;\ngl_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 \nvViewPosition = -mvPosition.xyz;\n#include \nprojTexCoord = textureMatrix * worldPosition;\n#include \n#include \n}",meshnode_frag:"#define NODE\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_TEX_COORD_BL) || defined(NODE_NORMAL_MAP_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FRESNEL_BL) || defined(NODE_BUMP_BL) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL) || defined(SHADOWMAP_TYPE_ESM) && (defined(NODE_BSDF_DIFFUSE_BL) || defined(NODE_BSDF_GLOSSY_BL) || defined(NODE_BSDF_REFRACTION_BL) || defined(NODE_MATERIAL_MX) || defined(NODE_PHYSICAL_MX)) || defined(NODE_BITMAP_MX) || defined(NODE_GRADIENT_RAMP_MX)\nuniform mat4 invViewMatrix;\n#endif\n#if defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FRESNEL_BL) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL) || defined(USE_SSR)\nuniform mat4 projectionMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_TEX_COORD_BL) || defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_BITMAP_MX) || defined(NODE_GRADIENT_RAMP_MX)\nuniform mat4 modelMatrix;\nuniform mat4 invModelMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_NORMAL_MAP_BL) || defined(NODE_NORMAL_BUMP_MX) || defined(NODE_MATERIAL_GF)\nuniform mat4 modelViewMatrix;\n#endif\n#if defined(NODE_TEX_IMAGE_BL)\nuniform mat3 normalMatrix;\n#endif\n#if defined(NODE_TEX_COORD_BL) || defined(NODE_NEW_GEOMETRY_BL)\nuniform vec3 boundingBoxMin;\nuniform vec3 boundingBoxMax;\n#endif\n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_BL) || defined(NODE_PHY_SUN_SKY_ENV_MX) || defined(NODE_AI_SKYDOME_LIGHT_MY)\nvarying vec3 vWorldPosition;\n#endif\n#if defined(NODE_TEX_COORD_BL)\nuniform vec2 viewWidthHeight;\n#endif\n#include \n#include \n#include \nvoid main() {\nbool _frontFacingValue = gl_FrontFacing;\n#define FRONT_FACING_VALUE _frontFacingValue\n#include \n#include \n#include \nvec4 outgoingLight = vec4(0.0);\n#include \n#if WORLD_NODES == 1\noutgoingLight.a = 1.0;\n#endif\n#ifdef ALPHATEST\nif (outgoingLight.a < ALPHATEST)\ndiscard;\nelse\noutgoingLight.a = 1.0;\n#endif\ngl_FragColor = vec4(outgoingLight);\n#include \n#include \n#include \n#include \n#include \n}",meshnode_vert:"#define NODE\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_BL) || defined(NODE_PHY_SUN_SKY_ENV_MX) || 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#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = - mvPosition.xyz;\n#include \n#include \n#include \n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_BL) || defined(NODE_PHY_SUN_SKY_ENV_MX) || defined(NODE_AI_SKYDOME_LIGHT_MY)\nvWorldPosition = worldPosition.xyz;\n#endif\n#include \n}",lights_node_pars_fragment:"\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct NodeMaterial {\nvec3 diffuseColor;\nvec3 specularColor;\nvec3 refractionColor;\nfloat refractionRoughness;\nfloat refractionIOR;\n#ifdef CLEARCOAT\nfloat clearcoat;\nfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\n#endif\n#ifdef PHYSICAL\nvec3 fresnelRefl90;\nfloat specularRoughness;\n#else\nfloat diffuseIntensity;\nfloat specularIntensity;\nfloat 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{\nfloat specFac;\nvec3 h = normalize(lightDir + viewDir);\nfloat rslt = max(dot(h, normal), 0.0);\nspecFac = pow(rslt, hard);\nreturn specFac;\n}\nfloat clearcoatDHRApprox(const in float roughness, const in float dotNL) {\nreturn 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\nvoid RE_Direct_RectArea_Node(const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in NodeMaterial material, inout ReflectedLight reflectedLight) {\nvec3 normal = geometry.normal;\nvec3 viewDir = geometry.viewDir;\nvec3 position = geometry.position;\nvec3 lightPos = rectAreaLight.position;\nvec3 halfWidth = rectAreaLight.halfWidth;\nvec3 halfHeight = rectAreaLight.halfHeight;\nvec3 lightColor = rectAreaLight.color;\nfloat roughness = material.specularRoughness;\nvec3 rectCoords[4];\nrectCoords[0] = lightPos + halfWidth - halfHeight;\nrectCoords[1] = lightPos - halfWidth - halfHeight;\nrectCoords[2] = lightPos - halfWidth + halfHeight;\nrectCoords[3] = lightPos + halfWidth + halfHeight;\nvec2 uv = LTC_Uv(normal, viewDir, roughness);\nvec4 t1 = texture2D(ltc_1, uv);\nvec4 t2 = texture2D(ltc_2, uv);\nmat3 mInv = mat3(\nvec3(t1.x, 0, t1.y),\nvec3( 0, 1, 0),\nvec3(t1.z, 0, t1.w)\n);\nvec3 fresnel = (material.specularColor * t2.x + (vec3(1.0) - material.specularColor) * t2.y);\nreflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate(normal, viewDir, position, mInv, rectCoords);\nreflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate(normal, viewDir, position, mat3(1.0), rectCoords);\n}\n#endif\nvoid RE_Direct_Node(const in IncidentLight directLight, const in GeometricContext geometry, const in NodeMaterial material, inout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nirradiance *= PI;\n#endif\n#ifdef PHYSICAL\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, directLight.direction));\nvec3 ccIrradiance = ccDotNL * directLight.color;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nccIrradiance *= PI;\n#endif\n#endif\n#ifdef CLEARCOAT\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\nreflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance\n* BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.normal,\nmaterial.specularColor, material.specularRoughness);\nreflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance\n* BRDF_Diffuse_Lambert(material.diffuseColor);\n#ifdef CLEARCOAT\nreflectedLight.directSpecular += ccIrradiance * material.clearcoat\n* BRDF_Specular_GGX(directLight, geometry.viewDir, geometry.clearcoatNormal,\nvec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#endif\n#else\nreflectedLight.directDiffuse += irradiance * material.diffuseIntensity * BRDF_Diffuse_Lambert(material.diffuseColor);\nreflectedLight.directSpecular += material.specularIntensity *\nshadeSpecPhong(geometry.normal, directLight.direction,\ngeometry.viewDir, material.specularHardness) *\ndirectLight.color * material.specularColor;\n#endif\n}\nvoid RE_IndirectDiffuse_Node(const in vec3 irradiance, const in GeometricContext geometry, const in NodeMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#ifdef PHYSICAL\nvoid RE_IndirectSpecular_Node(const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout ReflectedLight reflectedLight) {\n#ifdef CLEARCOAT\nfloat ccDotNL = saturate(dot(geometry.clearcoatNormal, geometry.viewDir));\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(\nmaterial.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\n#ifdef MT_BLENDER\n#ifdef COMPAT_USE_SPEC_ENV_BLENDER_APPROX\nvec3 specEnv = BRDF_Specular_GGX_Environment_Blender_Approx(geometry,\nmaterial.specularColor, material.fresnelRefl90,\nmaterial.specularRoughness, 0);\n#else\nvec3 specEnv = BRDF_Specular_GGX_Environment(geometry.viewDir,\ngeometry.normal, material.specularColor,\nmaterial.specularRoughness);\n#endif\n#elif defined(MT_MAX)\nfloat alphaEnv = pow2(pow2(material.specularRoughness));\nvec3 specEnv = material.specularColor / (1.0 - alphaEnv + PI * alphaEnv);\n#elif defined(MT_MAYA)\nvec3 specEnv = BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n#else\nvec3 specEnv = vec3(1.0);\n#endif\nreflectedLight.indirectSpecular += (1.0 - clearcoatDHR) * radiance * specEnv;\n#ifdef CLEARCOAT\n#ifdef MT_BLENDER\nvec3 specEnvCC = BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#elif defined(MT_MAX)\nvec3 specEnvCC = BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.clearcoatNormal, vec3(DEFAULT_SPECULAR_COEFFICIENT), material.clearcoatRoughness);\n#else\nvec3 specEnvCC = vec3(1.0);\n#endif\nreflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * specEnvCC;\n#endif\nreflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n}\n#endif\nvoid RE_Refraction_Node(const vec3 refraction, const NodeMaterial material,\ninout vec3 refractedLight) {\nrefractedLight += 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) {\nreturn 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) {\nvec4 res = invProjectionMatrix * vec4(p, 1);\nreturn res.xyz / res.w;\n}\nbool doesIntersect(float rayzmax, float rayzmin, vec2 uv) {\nfloat sceneZMin = texture2D(ssrDepthBuffer, uv).r;\n#ifdef USE_SSR_REFRACT\nreturn rayzmin >= (sceneZMin-ssrThickness) && rayzmax <= sceneZMin;\n#else\nfloat sceneZMax = texture2D(ssrBackfaceDepthBuffer, uv).r;\nreturn 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) {\nif (a > b) {\nfloat t = a;\na = b;\nb = 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) {\nvec2 uv = gl_FragCoord.xy / ssrResolution;\nvec2 screenCoord = uv * 2.0 - vec2(1, 1);\nfloat nearClip = deproject(vec3(0, 0, -1)).z;\nvec3 ray = deproject(vec3(screenCoord, -1));\nray /= ray.z;\nfloat depthSample = -vViewPosition.z;\nvec3 vpos = depthSample * ray;\n#ifdef USE_SSR_REFRACT\nvec3 dir = normalize(refract(normalize(vpos), normalize(normal), 1.0/ior));\n#else\nvec3 dir = normalize(reflect(normalize(vpos), normalize(normal)));\n#endif\nfloat maxDist = ssrMaxDistance;\nfloat rayLength = (vpos.z + dir.z * maxDist) > nearClip ? (nearClip - vpos.z) / dir.z : maxDist;\nvec3 csOrig = vpos;\nvec3 csEndPoint = csOrig + dir * rayLength;\nvec4 H0 = projectionMatrix * vec4(csOrig, 1.0);\nvec4 H1 = projectionMatrix * vec4(csEndPoint, 1.0);\nfloat k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\nvec3 Q0 = csOrig.xyz * k0, Q1 = csEndPoint.xyz * k1;\nvec2 P0 = H0.xy * k0, P1 = H1.xy * k1;\nP0 = P0 * 0.5 + vec2(0.5), P1 = P1 * 0.5 + vec2(0.5);\n#ifndef SSR_SIMPLE_REFRACT\nP0 *= ssrResolution, P1 *= ssrResolution;\nP1 += vec2((distanceSquared(P0, P1) < 0.0001) ? 0.01 : 0.0);\nvec2 delta = P1 - P0;\nbool permute = false;\nif (abs(delta.x) < abs(delta.y)) {\npermute = true; delta = delta.yx; P0 = P0.yx; P1 = P1.yx;\n}\nfloat stepDir = sign(delta.x);\nfloat invdx = stepDir / delta.x;\nvec3 dQ = (Q1 - Q0) * invdx;\nfloat dk = (k1 - k0) * invdx;\nvec2 dP = vec2(stepDir, delta.y * invdx);\nfloat pixelStride = ssrStride;\nfloat jitterMod = (gl_FragCoord.x + gl_FragCoord.y) * 0.25;\nvec4 PQK = vec4(P0, Q0.z, k0);\nvec4 dPQK = vec4(dP, dQ.z, dk);\ndPQK *= pixelStride;\nPQK += dPQK * mod(jitterMod, 1.0) * ssrJitter;\nfloat end = P1.x * stepDir;\nfloat prevZMaxEstimate = PQK.z / PQK.w;\nfloat rayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;\nfloat stepped = 0.0;\nvec2 hitUV;\nbool intersected = false;\nfor (float stepCount = 1.0; stepCount <= float(MAX_STEPS); stepCount ++) {\nPQK += dPQK;\nrayZMin = prevZMaxEstimate;\nrayZMax = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);\nprevZMaxEstimate = rayZMax;\nswapIfBigger(rayZMax, rayZMin);\n\nstepped = stepCount;\nhitUV = (permute ? PQK.yx: PQK.xy) / ssrResolution;\nif (isOutsideUvBounds(hitUV)) break;\nintersected = doesIntersect(rayZMax, rayZMin, hitUV);\nif (intersected || (P0.x * stepDir) > end) break;\n}\nif (intersected && pixelStride > 1.0) {\nPQK -= dPQK;\ndPQK /= ssrStride;\nfloat ogStride = pixelStride * 0.5;\nfloat currStride = pixelStride;\nprevZMaxEstimate = PQK.z / PQK.w;\nrayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;\nfor(int j = 0; j < int(BINARY_SEARCH_ITERATIONS); j ++) {\nPQK += dPQK * currStride;\nrayZMin = prevZMaxEstimate;\nrayZMax = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);\nprevZMaxEstimate = rayZMax;\nswapIfBigger(rayZMax, rayZMin);\nvec2 newUV = (permute ? PQK.yx: PQK.xy) / ssrResolution;\nogStride *= 0.5;\nif (doesIntersect(rayZMax, rayZMin, newUV)) {\nhitUV = newUV;\ncurrStride = -ogStride;\n} else {\ncurrStride = ogStride;\n}\n}\n}\nvec3 result = color;\n#ifdef USE_SSR_REFRACT\n#endif\nif (intersected) {\nvec4 col = texture2D(ssrSourceBuffer, hitUV);\nvec2 ndc = abs(hitUV * 2.0 - 1.0);\nfloat maxndc = max(ndc.x, ndc.y);\nfloat 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)));\ncol.a = fadeVal;\nresult = mix(result, col.rgb, col.a);\n}\n#else\nvec3 result = texture2D(ssrSourceBuffer, P1).xyz;\n#endif\nreturn 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) {\nif (sourceType == 1)\nreturn sRGBToLinear(color);\nelse if (sourceType == 2)\nreturn RGBEToLinear(color);\nelse\nreturn color;\n}\n#if defined(NODE_COMBHSV_BL) || defined(NODE_SEPHSV_BL) || defined(NODE_HUE_SAT_BL) || defined(NODE_COLOR_CORRECTION_MX) || defined(NODE_COMPOSITE_LAYER_MX)\n#define HSV_NODES\n#endif\n#ifdef HSV_NODES\nvoid hsvToRGB(vec4 hsv, out vec4 outCol)\n{\nfloat i, f, p, q, t, h, s, v;\nvec3 rgb;\nh = hsv[0];\ns = hsv[1];\nv = hsv[2];\nif (s == 0.0)\nrgb = vec3(v, v, v);\nelse {\nif (h == 1.0)\nh = 0.0;\nh *= 6.0;\ni = floor(h);\nf = h - i;\nrgb = vec3(f, f, f);\np = v * (1.0 - s);\nq = v * (1.0 - (s * f));\nt = v * (1.0 - (s * (1.0 - f)));\nif (i == 0.0)\nrgb = vec3(v, t, p);\nelse if (i == 1.0)\nrgb = vec3(q, v, p);\nelse if (i == 2.0)\nrgb = vec3(p, v, t);\nelse if (i == 3.0)\nrgb = vec3(p, q, v);\nelse if (i == 4.0)\nrgb = vec3(t, p, v);\nelse\nrgb = vec3(v, p, q);\n}\noutCol = vec4(rgb, hsv.w);\n}\nvoid rgbToHSV(vec4 rgb, out vec4 outCol)\n{\nfloat cmax, cmin, h, s, v, cdelta;\nvec3 c;\ncmax = max(rgb[0], max(rgb[1], rgb[2]));\ncmin = min(rgb[0], min(rgb[1], rgb[2]));\ncdelta = cmax - cmin;\nv = cmax;\nif (cmax != 0.0)\ns = cdelta / cmax;\nelse {\ns = 0.0;\nh = 0.0;\n}\nif (s == 0.0)\nh = 0.0;\nelse {\nc = (vec3(cmax, cmax, cmax) - rgb.xyz) / cdelta;\nif (rgb.x == cmax) h = c[2] - c[1];\nelse if (rgb.y == cmax) h = 2.0 + c[0] - c[2];\nelse h = 4.0 + c[1] - c[0];\nh /= 6.0;\nif (h < 0.0)\nh += 1.0;\n}\noutCol = vec4(h, s, v, rgb.w);\n}\n#endif\nbool isPerspective(const mat4 projMatrix)\n{\nreturn (projMatrix[3][3] == 0.0);\n}\n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_AI_SKYDOME_LIGHT_MY)\nvec4 sampleEquirectangular(sampler2D map, vec3 reflectVec, mat3 uvTransform, int encoding)\n{\nreflectVec = normalize(reflectVec);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(reflectVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n#ifdef MT_MAYA\nsampleUV.x = atan(reflectVec.z, reflectVec.x) * RECIPROCAL_PI2 + 0.25;\n#else\nsampleUV.x = atan(reflectVec.x, reflectVec.z) * RECIPROCAL_PI2 + 0.5;\n#endif\nsampleUV.y *= -1.0;\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (reflectVec.x) / seamWidth) *\nclamp (1.0 - reflectVec.z / seamWidth, 0.0, 1.0);\nsampleUV = (uvTransform * vec3(sampleUV, 1.0)).xy;\nvec4 color = texture2D(map, sampleUV, seamBiasFactor * seam);\ncolor = nodeTexelToLinear(color, encoding);\nreturn color;\n}\n#endif\n#if defined(NODE_FRESNEL_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FALLOFF_MX) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL)\nfloat fresnelReflection(const vec3 dir, const vec3 normal, const float ior) {\nfloat cosTheta = clamp(abs(dot(dir, normal)), -1.0, 1.0);\nfloat gSquared = pow2(ior) + pow2(cosTheta) - 1.0;\nif (gSquared < 0.0) return 1.0;\nfloat g = sqrt(gSquared);\nreturn 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_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_GRADIENT_RAMP_MX)\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{\nif (abs(uOffset) < EPSILON && abs(vOffset) < EPSILON &&\n(abs(uTiling - 1.0)) < EPSILON && (abs(vTiling - 1.0)) < EPSILON &&\nabs(wAngle) < EPSILON)\nreturn mat3(1.0);\nfloat sx = uTiling;\nfloat sy = vTiling;\nfloat tx = -uOffset;\nfloat ty = -vOffset;\nfloat cx = uOffset + 0.5;\nfloat cy = vOffset + 0.5;\nfloat c = cos(-wAngle);\nfloat s = sin(-wAngle);\nreturn mat3(sx * c, -sy * s, 0.0,\nsx * 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_BL) || defined(NODE_TEX_WAVE_BL)\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) {\nreturn noiseModulo(((x * 34.0) + 1.0) * x);\n}\nvec4 taylorInvSqrt(vec4 r) {\nreturn 1.79284291400159 - 0.85373472095314 * r;\n}\nfloat noisePerlin(vec3 v) {\nconst vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\nconst vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\nvec3 i = floor(v + dot(v, C.yyy));\nvec3 x0 = v - i + dot(i, C.xxx);\nvec3 g = step(x0.yzx, x0.xyz);\nvec3 l = 1.0 - g;\nvec3 i1 = min(g.xyz, l.zxy);\nvec3 i2 = max(g.xyz, l.zxy);\nvec3 x1 = x0 - i1 + C.xxx;\nvec3 x2 = x0 - i2 + C.yyy;\nvec3 x3 = x0 - D.yyy;\ni = noiseModulo(i);\nvec4 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));\nfloat n_ = 0.142857142857;\nvec3 ns = n_ * D.wyz - D.xzx;\nvec4 j = p - 49.0 * floor(p * ns.z * ns.z);\nvec4 x_ = floor(j * ns.z);\nvec4 y_ = floor(j - 7.0 * x_);\nvec4 x = x_ * ns.x + ns.yyyy;\nvec4 y = y_ * ns.x + ns.yyyy;\nvec4 h = 1.0 - abs(x) - abs(y);\nvec4 b0 = vec4(x.xy, y.xy);\nvec4 b1 = vec4(x.zw, y.zw);\nvec4 s0 = floor(b0) * 2.0 + 1.0;\nvec4 s1 = floor(b1) * 2.0 + 1.0;\nvec4 sh = -step(h, vec4(0.0));\nvec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\nvec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\nvec3 p0 = vec3(a0.xy, h.x);\nvec3 p1 = vec3(a0.zw, h.y);\nvec3 p2 = vec3(a1.xy, h.z);\nvec3 p3 = vec3(a1.zw, h.w);\nvec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\np0 *= norm.x;\np1 *= norm.y;\np2 *= norm.z;\np3 *= norm.w;\nvec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\nm = m * m;\nreturn 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1),\ndot(p2, x2), dot(p3, x3)));\n}\nfloat noiseBlender(vec3 p) {\nreturn 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,\nfloat dispersionFactor) {\nfloat mixFac = mix(1.0, smoothstep(0.0, 1.0, octaveLenPerPixel) * falloffFactor,\ndispersionFactor);\nreturn mix(noiseBlender(p), NOISE_BLENDER_MEAN, mixFac);\n}\n#define MAX_OCTAVES_NUM 16\nfloat noiseTurbulence(vec3 p, float octaves, float octaveLenPerPixel,\nfloat falloffFactor, float dispersionFactor) {\nfloat fscale = 1.0;\nfloat amp = 1.0;\nfloat sum = 0.0;\noctaves = clamp(octaves, 0.0, 16.0);\nint octavesInt = int(octaves);\nfor (int i = 0; i <= MAX_OCTAVES_NUM; i++) {\n#if __VERSION__ == 300\nif (i <= octavesInt) {\nfloat t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nsum += t * amp;\namp *= 0.5;\nfscale *= 2.0;\noctaveLenPerPixel *= 2.0;\n} else {\ni = MAX_OCTAVES_NUM;\n}\n#else\nif (i > octavesInt) break;\nfloat t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nsum += t * amp;\namp *= 0.5;\nfscale *= 2.0;\noctaveLenPerPixel *= 2.0;\n#endif\n}\nfloat octavesFrac = fract(octaves);\nfloat octavesCoeff = pow(2.0, float(octavesInt));\nif (octavesFrac != 0.0) {\nfloat t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nfloat sum2 = sum + t * amp;\nsum *= octavesCoeff / (2.0 * octavesCoeff - 1.0);\nsum2 *= 2.0 * octavesCoeff / (4.0 * octavesCoeff - 1.0);\nreturn mix(sum, sum2, octavesFrac);\n} else {\nreturn sum * octavesCoeff / (2.0 * octavesCoeff - 1.0);\n}\n}\n#endif",node_material_gf_frag:"void node_material(\nvec3 normal, vec3 geometryNormal, vec4 tangent,\nvec4 baseColorFactor, vec4 baseColorTexture,\nfloat metallicFactor, float roughnessFactor, vec3 metallicRoughnessTexture,\nfloat normalmapScale, vec3 normalmapTexture, \nfloat occlusionStrength, float directLightOcclusionFactor, vec3 occlusionTexture,\nvec3 emissiveFactor, vec3 emissiveTexture, \nout vec4 outgoingLight) {\nNodeMaterial material;\nfloat metalness = metallicFactor * metallicRoughnessTexture.b;\nvec3 baseColor = baseColorTexture.rgb * baseColorFactor.rgb;\nmaterial.diffuseColor = baseColor * (1.0 - metalness);\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nfloat roughness = roughnessFactor * metallicRoughnessTexture.g;\nmaterial.specularRoughness = max(roughness, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nmaterial.specularColor = mix(vec3(DEFAULT_SPECULAR_COEFFICIENT), baseColor, metalness);\nif (normalmapScale > 0.0) {\nvec3 normalTex = normalmapTexture * 2.0 - 1.0;\n#ifdef MT_BLENDER\nnormalTex.y = -normalTex.y;\n#endif\nvec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\n\nnormal = mix(normal, normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal), normalmapScale);\n}\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#include \n#include \n#include \nfloat ambientOcclusion = occlusionStrength * occlusionTexture.r;\nif (ambientOcclusion < 1.0) {\nreflectedLight.indirectDiffuse *= ambientOcclusion;\nfloat dotNV = saturate(dot(geometry.normal, geometry.viewDir));\nfloat specularOcclusion = computeSpecularOcclusion(dotNV, ambientOcclusion, material.specularRoughness);\nreflectedLight.indirectSpecular *= specularOcclusion;\nreflectedLight.directDiffuse *= (1.0 + (ambientOcclusion - 1.0) * directLightOcclusionFactor);\nreflectedLight.directSpecular *= (1.0 + (specularOcclusion - 1.0) * directLightOcclusionFactor);\n}\nvec3 totalEmissiveRadiance = emissiveFactor * emissiveTexture;\nvec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\n+ reflectedLight.directSpecular + reflectedLight.indirectSpecular\n+ totalEmissiveRadiance;\nfloat alpha = baseColorFactor.a * baseColorTexture.a;\noutgoingLight = vec4(outColor3, alpha);\n}",node_rgb_gf_frag:"uniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_texture_gf_frag:"void node_texture(sampler2D map, vec2 uv, const mat3 uvTransform,\nconst int encoding, out vec3 color)\n{\nuv = (uvTransform * vec3(uv, 1.0)).xy;\ncolor = texture2D(map, uv).rgb;\ncolor = nodeTexelToLinear(vec4(color, 0.0), encoding).rgb;\n}\nvoid node_texture(sampler2D map, vec2 uv, const mat3 uvTransform,\nconst int encoding, out vec4 color)\n{\nuv = (uvTransform * vec3(uv, 1.0)).xy;\ncolor = texture2D(map, uv);\ncolor = nodeTexelToLinear(color, encoding);\n}",node_value_gf_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_add_shader_bl_frag:"void node_add_shader(vec4 color1, vec4 color2, out vec4 outColor) {\noutColor.rgb = color1.rgb + color2.rgb;\noutColor.a = clamp(color1.a + color2.a, 0.0, 1.0);\n}",node_ambient_occlusion_bl_frag:"void node_ambient_occlusion(vec4 color, float distance, vec3 normal,\nout vec4 outColor, out float outAO) {\noutColor = color;\noutAO = 1.0;\n}\nvoid node_ambient_occlusion(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_attribute_bl_frag:"void node_attribute(\nvec3 paramAttr,\nout vec4 outColor, out vec3 outVector, out float outFac)\n{\noutColor = vec4(paramAttr, 1.0);\noutVector = paramAttr;\noutFac = average(paramAttr);\n}",node_background_bl_frag:"void node_background(vec4 color, float strength, out vec4 outColor)\n{\noutColor = strength * color;\n}",node_bevel_bl_frag:"void node_bevel(float radius, vec3 normal, out vec3 outNormal) {\noutNormal = normal;\n}",node_blackbody_bl_frag:"void node_blackbody(float temp, out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_brightcontrast_bl_frag:"\nvoid node_brightcontrast(vec4 color, float bright, float contrast, out vec4 outColor)\n{\nfloat bminc = bright - contrast * 0.5;\noutColor.r = max((1.0 + contrast) * color.r + bminc, 0.0);\noutColor.g = max((1.0 + contrast) * color.g + bminc, 0.0);\noutColor.b = max((1.0 + contrast) * color.b + bminc, 0.0);\noutColor.a = color.a;\n}",node_bsdf_anisotropic_bl_frag:"void node_bsdf_anisotropic(\nvec4 color, float roughness, float anisotropy, float rotation, vec3 normal, vec3 tangent,\nout vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_diffuse_bl_frag:"\nvoid node_bsdf_diffuse(\nvec3 geometryNormal,\nvec4 color, float roughness, vec3 normal,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.diffuseColor = color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include \n#include \n#include \n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, 1.0);\n}",node_bsdf_glass_bl_frag:"void node_bsdf_glass(\nvec3 geometryNormal,\nvec4 color, float roughness, float ior, vec3 normal,\nout vec4 outColor) {\nnormal = swizzleUpY(normal);\nvec3 normalWorld = normal;\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.specularColor = vec3(1.0);\nmaterial.fresnelRefl90 = vec3(1.0);\nmaterial.specularRoughness = clamp(roughness, 0.0, 1.0);\nmaterial.refractionColor = vec3(1.0);\nmaterial.refractionIOR = ior;\nmaterial.refractionRoughness = pow2(roughness);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0),\nvec3(0.0), vec3(0.0));\n#define USE_REFRACTED_LIGHT\nvec3 refractedLight = vec3(0.0);\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include \n#include \n#include \n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\n#undef USE_REFRACTED_LIGHT\nvec3 viewWorld;\nif (isPerspective(projectionMatrix))\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nviewWorld = normalize(viewWorld);\nfloat fresnel = fresnelReflection(viewWorld, normalWorld, ior);\noutColor = vec4(color.rgb * mix(refractedLight, reflectedLight.directSpecular\n+ reflectedLight.indirectSpecular, fresnel), 1.0);\n}",node_bsdf_glossy_bl_frag:"\nvoid node_bsdf_glossy(\nvec3 geometryNormal,\nvec4 color, float roughness, vec3 normal,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nnormal = normalize((viewMatrix * vec4(normal.xyz, 0.0)).xyz);\nNodeMaterial material;\nmaterial.specularColor = vec3(1.0);\nmaterial.fresnelRefl90 = vec3(1.0);\nmaterial.specularRoughness = clamp(roughness, 0.0, 1.0);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include \n#include \n#include \n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\noutColor = vec4(color.rgb * (reflectedLight.directSpecular\n+ reflectedLight.indirectSpecular), 1.0);\n}",node_bsdf_hair_bl_frag:"void node_bsdf_hair(vec4 color, float offset, float roughnessU, float roughnessV, vec3 tangent, out vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_principled_bl_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) {\nfloat 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(\nvec3 geometryNormal,\nvec4 baseColor, float subsurface, vec3 subsurfaceRadius, vec4 subsurfaceColor,\nfloat metallic, float specular, float specularTint, float roughness,\nfloat anisotropic, float anisotropicRotation, float sheen, float sheenTint,\nfloat clearcoat, float clearcoatRoughness, float ior,\nfloat transmission, float transmissionRoughness, vec4 emission, float alpha,\nvec3 normal, vec3 clearcoatNormal, vec3 tangent,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nvec3 normalWorld = normal;\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmetallic = clamp(metallic, 0.0, 1.0);\nfloat dielectric = 1.0 - metallic;\ntransmission *= dielectric;\nmaterial.diffuseColor = baseColor.rgb * dielectric;\n#ifndef CLEARCOAT\nfloat dielReflCoeff = BLENDER_SPECULAR_COEFFICIENT;\n#else\nfloat dielReflCoeff = MAXIMUM_SPECULAR_COEFFICIENT;\nmaterial.clearcoat = saturate(clearcoat);\nmaterial.clearcoatRoughness = clamp(clearcoatRoughness, 0.0, 1.0);\n#endif\nvec3 dielRefl = dielReflCoeff * specular\n* mix(vec3(1.0), tintFromColor(baseColor.rgb), specularTint);\nmaterial.specularColor = mix(dielRefl, baseColor.rgb, metallic);\nmaterial.specularRoughness = clamp(roughness, 0.0, 1.0);\nvec3 viewWorld;\nif (isPerspective(projectionMatrix))\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nviewWorld = normalize(viewWorld);\nfloat fresnel = fresnelReflection(viewWorld, normalWorld, ior);\nvec3 fresnelColor = mix(vec3(1.0), baseColor.rgb, specularTint);\nmaterial.specularColor = mix(material.specularColor,\nfresnelBlend(ior, fresnel, fresnelColor) * fresnel, transmission);\nfloat isStrictDielectric = step(0.0, -length(vec4(subsurface, clearcoat,\ntransmission, float(metallic == 1.0))));\nmaterial.fresnelRefl90 = mix(vec3(1.0), material.specularColor,\n(1.0 - specular) * metallic * (1.0 - isStrictDielectric));\nmaterial.refractionColor = baseColor.rgb;\nmaterial.refractionIOR = ior;\nmaterial.refractionRoughness = pow2(roughness);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#ifdef CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\nclearcoatNormal = normalize(vec3(clearcoatNormal[0], clearcoatNormal[2], -clearcoatNormal[1]));\nclearcoatNormal = (viewMatrix * vec4(clearcoatNormal.xyz, 0.0)).xyz;\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define USE_REFRACTED_LIGHT\nvec3 refractedLight = vec3(0.0);\n#include \n#include \n#include \n#undef USE_REFRACTED_LIGHT\nvec3 outColor3 = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * (1.0 - transmission)\n+ reflectedLight.directSpecular + reflectedLight.indirectSpecular\n+ refractedLight * transmission * (1.0 - fresnel)\n+ emission.rgb;\noutColor = vec4(outColor3, alpha);\n}\nvoid node_bsdf_principled(\nvec3 geometryNormal,\nvec4 baseColor, float subsurface, vec3 subsurfaceRadius, vec4 subsurfaceColor,\nfloat metallic, float specular, float specularTint, float roughness,\nfloat anisotropic, float anisotropicRotation, float sheen, float sheenTint,\nfloat clearcoat, float clearcoatRoughness, float ior,\nfloat transmission, float transmissionRoughness,\nvec3 normal, vec3 clearcoatNormal, vec3 tangent,\nout vec4 outColor) {\nnode_bsdf_principled(geometryNormal, baseColor, subsurface, subsurfaceRadius,\nsubsurfaceColor, metallic, specular, specularTint, roughness,\nanisotropic, anisotropicRotation, sheen, sheenTint, clearcoat,\nclearcoatRoughness, ior, transmission, transmissionRoughness,\nvec4(0.0, 0.0, 0.0, 1.0), 1.0, normal, clearcoatNormal, tangent,\noutColor);\n}",node_bsdf_refraction_bl_frag:"#define BSDF_REFRACTION_GGX 0\n#define BSDF_REFRACTION_BECKMANN 1\n#define BSDF_REFRACTION_SHARP 2\nvoid node_bsdf_refraction(\nvec3 geometryNormal, const int distribution,\nvec4 color, float roughness, float ior, vec3 normal,\nout vec4 outColor) {\nnormal = swizzleUpY(normal);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.refractionColor = color.rgb;\nmaterial.refractionIOR = ior;\nif (distribution == BSDF_REFRACTION_SHARP) {\nmaterial.refractionRoughness = 0.0;\n} else {\nmaterial.refractionRoughness = pow2(roughness);\n}\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define USE_REFRACTED_LIGHT\nvec3 refractedLight = vec3(0.0);\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include \n#include \n#include \n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\n#undef USE_REFRACTED_LIGHT\noutColor = vec4(refractedLight, 1.0);\n}",node_bsdf_toon_bl_frag:"void node_bsdf_toon(\nvec4 color, float size, float smooth, vec3 normal, \nout vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_translucent_bl_frag:"void node_bsdf_translucent(vec4 color, vec3 normal, out vec4 outColor) {\nnormal = -vec3(normal[0], normal[2], -normal[1]);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.diffuseColor = color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#include \n#include \n#include \n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, 1.0);\n}",node_bsdf_transparent_bl_frag:"\nvoid node_bsdf_transparent(vec4 color, out vec4 outColor)\n{\nfloat alpha = saturate(1.0 - dot(color.rgb, vec3(0.333333)));\noutColor = vec4(0.0, 0.0, 0.0, alpha);\n}",node_bsdf_velvet_bl_frag:"void node_bsdf_velvet(vec4 color, float sigma, vec3 normal, out vec4 outColor)\n{\noutColor = color;\n}",node_bump_bl_frag:"\nvoid node_bump(\nconst int invert,\nfloat strength, float bumpDist, float height, float height_dx,\nfloat height_dy, vec3 normal,\nout vec3 outNormal) {\nvec3 position = swizzleUpZ(vWorldPosition);\nif (invert == 1)\nbumpDist *= -1.0;\nvec3 dPdx = dFdx(position);\nvec3 dPdy = dFdy(position);\nfloat dHdx = dFdx(height);\nfloat dHdy = dFdy(height);\nvec3 tanX = cross(dPdy, normal);\nvec3 tanY = cross(normal, dPdx);\nvec3 surfaceGrad = dHdx * tanX + dHdy * tanY;\nfloat dotPosTanX = dot(dPdx, tanX);\noutNormal = normalize(normal * abs(dotPosTanX) - surfaceGrad * bumpDist * sign(dotPosTanX));\noutNormal = normalize(mix(normal, outNormal, max(0.0, strength)));\n}\nvoid node_bump(\nconst int invert,\nfloat strength, float bumpDist, float height, vec3 normal,\nout vec3 outNormal) {\nnode_bump(invert, strength, bumpDist, height, 0.0, 0.0, normal, outNormal);\n}",node_camera_bl_frag:"\nvoid node_camera(\nvec3 viewPos, const int invCamZ,\nout vec3 outViewVector, out float outViewZDepth, out float outViewDistance)\n{\nviewPos = -viewPos;\nif (invCamZ == 1)\nviewPos.z = -viewPos.z;\noutViewVector = normalize(viewPos);\noutViewZDepth = abs(viewPos.z);\noutViewDistance = length(viewPos);\n}",node_clamp_bl_frag:"void node_clamp(float value, float minVal, float maxVal, out float result) {\nresult = clamp(value, minVal, maxVal);\n}",node_combhsv_bl_frag:"\nvoid node_combhsv(float h, float s, float v, out vec4 col)\n{\nhsvToRGB(vec4(h, s, v, 1.0), col);\n}",node_combrgb_bl_frag:"\nvoid node_combrgb(float r, float g, float b, out vec4 col)\n{\ncol = vec4(r, g, b, 1.0);\n}",node_combxyz_bl_frag:"void node_combxyz(float x, float y, float z, out vec3 outVector)\n{\noutVector = vec3(x, y, z);\n}",node_curve_rgb_bl_frag:"\nvoid node_curve_rgb(sampler2D curveData, float fac, vec4 col, out vec4 outCol)\n{\noutCol.r = texture2D(curveData, vec2(texture2D(curveData, vec2(col.r, 0.0)).a, 0.0)).r;\noutCol.g = texture2D(curveData, vec2(texture2D(curveData, vec2(col.g, 0.0)).a, 0.0)).g;\noutCol.b = texture2D(curveData, vec2(texture2D(curveData, vec2(col.b, 0.0)).a, 0.0)).b;\noutCol = mix(col, outCol, fac);\noutCol.a = col.a;\n}",node_curve_vec_bl_frag:"\nvoid node_curve_vec(sampler2D curveData, float fac, vec3 vec, out vec3 outVec)\n{\noutVec.x = texture2D(curveData, vec2((vec.x + 1.0) * 0.5, 0.0)).x;\noutVec.y = texture2D(curveData, vec2((vec.y + 1.0) * 0.5, 0.0)).y;\noutVec.z = texture2D(curveData, vec2((vec.z + 1.0) * 0.5, 0.0)).z;\noutVec = mix(vec, outVec * 2.0 - vec3(1.0), fac);\n}",node_displacement_bl_frag:"void node_displacement(float height, float midlevel, float scale, vec3 normal, out vec3 outDisplacement) {\noutDisplacement = vec3(0.0);\n}",node_eevee_specular_bl_frag:"void node_eevee_specular(\nvec4 baseColor, vec4 specular, float roughness, vec4 emissiveColor,\nfloat transparency, vec3 normal, float clearcoat, float clearcoatRoughness, \nvec3 clearcoatNormal, float ambientOcclusion,\nout vec4 outColor) {\noutColor = baseColor;\n}",node_emission_bl_frag:"\nvoid node_emission(vec4 color, float strength, out vec4 outColor)\n{\noutColor = vec4(strength * color.rgb, 1.0);\n}",node_fresnel_bl_frag:"void node_fresnel(vec3 viewPos, float IOR, vec3 normal, out float fac)\n{\nvec3 worldDir;\nif (isPerspective(projectionMatrix))\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n\nworldDir = normalize(swizzleUpZ(worldDir));\nfloat eta = max(IOR, 0.00001);\nfac = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\n}",node_gamma_bl_frag:"\nvoid node_gamma(vec4 col, float gamma, out vec4 outCol)\n{\noutCol = col;\nif (col.r > 0.0)\noutCol.r = powCompat(col.r, gamma);\nif (col.g > 0.0)\noutCol.g = powCompat(col.g, gamma);\nif (col.b > 0.0)\noutCol.b = powCompat(col.b, gamma);\n}",node_hair_info_bl_frag:"void node_hair_info(out float isStrand, out float intercept, out float thickness,\nout vec3 tangentNormal, out float random) {\nisStrand = 0.0;\nintercept = 0.0;\nthickness = 0.0;\ntangentNormal = vec3(0.0);\nrandom = 0.0;\n}\nvoid node_hair_info(\nout float isStrand, out float intercept, out float thickness, out vec3 tangentNormal)\n{\nisStrand = 0.0;\nintercept = 0.0;\nthickness = 0.0;\ntangentNormal = vec3(0.0);\n}",node_holdout_bl_frag:"void node_holdout(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_hue_sat_bl_frag:"\nvoid node_hue_sat(float hue, float sat, float value, float fac, vec4 col, out vec4 outCol)\n{\nvec4 hsv;\nrgbToHSV(col, hsv);\nhsv[0] += (hue - 0.5);\nif (hsv[0] > 1.0) hsv[0] -= 1.0; else if (hsv[0] < 0.0) hsv[0] += 1.0;\nhsv[1] *= sat;\nif (hsv[1] > 1.0) hsv[1] = 1.0; else if (hsv[1] < 0.0) hsv[1] = 0.0;\nhsv[2] *= value;\nif (hsv[2] > 1.0) hsv[2] = 1.0; else if (hsv[2] < 0.0) hsv[2] = 0.0;\nhsvToRGB(hsv, outCol);\noutCol = mix(col, outCol, fac);\n}",node_invert_bl_frag:"\nvoid node_invert(float fac, vec4 col, out vec4 outCol)\n{\noutCol.xyz = mix(col.xyz, vec3(1.0, 1.0, 1.0) - col.xyz, fac);\noutCol.w = col.w;\n}",node_layer_weight_bl_frag:"\nvoid node_layer_weight(vec3 viewPos, float blend, vec3 normal, out float fresnel, out float facing)\n{\nvec3 worldDir;\nif (isPerspective(projectionMatrix))\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n\nworldDir = normalize(swizzleUpZ(worldDir));\nfloat eta = max(1.0 - blend, EPSILON);\nfresnel = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? 1.0 / eta : eta);\nfacing = abs(dot(worldDir, normal));\nif (blend != 0.5) {\nblend = clamp(blend, 0.0, 1.0 - EPSILON);\nblend = (blend < 0.5) ? blend * 2.0 : 0.5 / (1.0 - blend);\nfacing = pow(facing, blend);\n}\nfacing = 1.0 - facing;\n}",node_light_falloff_bl_frag:"void node_light_falloff(\nfloat strength, float inSmooth,\nout float quadratic, out float linear, out float constant)\n{\nquadratic = 1.0;\nlinear = 1.0;\nconstant = 1.0;\n}",node_light_path_bl_frag:"void node_light_path(\nout float isCameraRay, out float isShadowRay, out float isDiffuseRay, \nout float isGlossyRay, out float isSingularRay, out float isReflectionRay,\nout float isTransmissionRay, out float rayLength, out float rayDepth, \nout float diffuseDepth, out float glossyDepth, out float transparentDepth, \nout float transmissionDepth)\n{\n#if LIGHT_PATH_IS_CAM_RAY\nisCameraRay = 1.0;\n#else\nisCameraRay = 0.0;\n#endif\nisShadowRay = 0.0;\nisDiffuseRay = 0.0;\nisGlossyRay = 0.0;\nisSingularRay = 0.0;\nisReflectionRay = 0.0;\nisTransmissionRay = 0.0;\nrayLength = 1.0;\nrayDepth = 1.0;\ndiffuseDepth = 1.0;\nglossyDepth = 1.0;\ntransparentDepth = 1.0; \ntransmissionDepth = 1.0;\n}",node_mapping_bl_frag:"\nvoid node_mapping(mat4 mat, vec3 minVec, vec3 maxVec, int useMin, int useMax, vec3 vec, out vec3 outVec)\n{\noutVec = (mat * vec4(vec, 1.0)).xyz;\nif (useMin == 1)\noutVec = max(outVec, minVec);\nif (useMax == 1)\noutVec = min(outVec, maxVec);\n}\nmat3 rotationMatrix(float angleX, float angleY, float angleZ) {\nfloat cx = cos(angleX);\nfloat sx = sin(angleX);\nfloat cy = cos(angleY);\nfloat sy = sin(angleY);\nfloat cz = cos(angleZ);\nfloat sz = sin(angleZ);\n\nmat3 mat;\nmat[0][0] = cy * cz;\nmat[0][1] = cy * sz;\nmat[0][2] = -sy;\n\nmat[1][0] = sy * sx * cz - cx * sz;\nmat[1][1] = sy * sx * sz + cx * cz;\nmat[1][2] = cy * sx;\n\nmat[2][0] = sy * cx * cz + sx * sz;\nmat[2][1] = sy * cx * sz - sx * cz;\nmat[2][2] = cy * cx;\n\nreturn 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{\nif (type == NODE_MAPPING_POINT)\noutVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale) + loc;\nelse if (type == NODE_MAPPING_TEXTURE)\noutVec = transposeMat3(rotationMatrix(rot.x, rot.y, rot.z)) * (vec - loc) / scale;\nelse if (type == NODE_MAPPING_VECTOR)\noutVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale);\nelse\noutVec = normalize(rotationMatrix(rot.x, rot.y, rot.z) * vec / scale);\n}",node_map_range_bl_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,\nfloat toMin, float toMax, float steps, out float result) {\nif (fromMax == fromMin) {\nresult = 0.0;\n} else {\nresult = (value - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin;\n}\nif (inClamp == 1) {\nresult = clamp(result, toMin, toMax);\n}\n}\nvoid node_map_range(const int interpolation, int inClamp, float value,\nfloat fromMin, float fromMax, float toMin, float toMax, out float result) {\nnode_map_range(NODE_MAP_RANGE_INTERP_LINEAR, inClamp, value, fromMin,\nfromMax, toMin, toMax, 0.0, result);\n}",node_math_bl_frag:"\nvoid node_math_add(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 + val2;\n}\nvoid node_math_subtract(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 - val2;\n}\nvoid node_math_multiply(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 * val2;\n}\nvoid node_math_divide(float val1, float val2, float val3, out float outVal)\n{\nif (val2 == 0.0)\noutVal = 0.0;\nelse\noutVal = val1 / val2;\n}\nvoid node_math_sine(float val, float val2, float val3, out float outVal)\n{\noutVal = sin(val);\n}\nvoid node_math_cosine(float val, float val2, float val3, out float outVal)\n{\noutVal = cos(val);\n}\nvoid node_math_tangent(float val, float val2, float val3, out float outVal)\n{\noutVal = tan(val);\n}\nvoid node_math_arcsine(float val, float val2, float val3, out float outVal)\n{\nif (val <= 1.0 && val >= -1.0)\noutVal = asin(val);\nelse\noutVal = 0.0;\n}\nvoid node_math_arccosine(float val, float val2, float val3, out float outVal)\n{\nif (val <= 1.0 && val >= -1.0)\noutVal = acos(val);\nelse\noutVal = 0.0;\n}\nvoid node_math_arctangent(float val, float val2, float val3, out float outVal)\n{\noutVal = atan(val);\n}\nvoid node_math_arctan2(float val, float val2, float val3, out float outVal)\n{\noutVal = atan(val, val2);\n}\nvoid node_math_power(float val1, float val2, float val3, out float outVal)\n{\nif (val1 >= 0.0)\noutVal = powCompat(val1, val2);\nelse {\nfloat val2_mod_1 = mod(abs(val2), 1.0);\nif (val2_mod_1 > 0.999 || val2_mod_1 < 0.001)\noutVal = powCompat(val1, floor(val2 + 0.5));\nelse\noutVal = 0.0;\n}\n}\nvoid node_math_logarithm(float val1, float val2, float val3, out float outVal)\n{\nif (val1 > 0.0 && val2 > 0.0)\noutVal = log2(val1) / log2(val2);\nelse\noutVal = 0.0;\n}\nvoid node_math_sqrt(float val1, float val2, float val3, out float outVal)\n{\noutVal = sqrt(val1);\n}\nvoid node_math_maximum(float val1, float val2, float val3, out float outVal)\n{\noutVal = max(val1, val2);\n}\nvoid node_math_minimum(float val1, float val2, float val3, out float outVal)\n{\noutVal = min(val1, val2);\n}\nvoid node_math_round(float val1, float val2, float val3, out float outVal)\n{\noutVal = floor(val1 + 0.5);\n}\nvoid node_math_floor(float val1, float val2, float val3, out float outVal)\n{\noutVal = floor(val1);\n}\nvoid node_math_ceil(float val1, float val2, float val3, out float outVal)\n{\noutVal = ceil(val1);\n}\nvoid node_math_fract(float val1, float val2, float val3, out float outVal)\n{\noutVal = fract(val1);\n}\nvoid node_math_less_than(float val1, float val2, float val3, out float outVal)\n{\nif (val1 < val2)\noutVal = 1.0;\nelse\noutVal = 0.0;\n}\nvoid node_math_greater_than(float val1, float val2, float val3, out float outVal)\n{\nif (val1 > val2)\noutVal = 1.0;\nelse\noutVal = 0.0;\n}\nvoid node_math_modulo(float val1, float val2, float val3, out float outVal)\n{\nif (val2 == 0.0)\noutVal = 0.0;\nelse\noutVal = mod(val1, val2);\noutVal = (val1 > 0.0) ? outVal : outVal - val2;\n}\nvoid node_math_absolute(float val1, float val2, float val3, out float outVal)\n{\noutVal = abs(val1);\n}\nvoid node_math_compare(float val1, float val2, float val3, out float outVal) {\noutVal = step(abs(val1 - val2), val3);\n}\nvoid node_math_cosh(float val1, float val2, float val3, out float outVal) {\noutVal = cosh(val1);\n}\nvoid node_math_degrees(float val1, float val2, float val3, out float outVal) {\noutVal = val1 / PI * 180.0;\n}\nvoid node_math_exponent(float val1, float val2, float val3, out float outVal) {\noutVal = exp(val1);\n}\nvoid node_math_inverse_sqrt(float val1, float val2, float val3, out float outVal) {\nif (val1 >= 0.0) {\noutVal = 1.0 / sqrt(val1);\n} else {\noutVal = 0.0;\n}\n}\nvoid node_math_multiply_add(float val1, float val2, float val3, out float outVal) {\noutVal = val1 * val2 + val3;\n}\nvoid node_math_pingpong(float val1, float val2, float val3, out float outVal) {\nif (val2 == 0.0) {\noutVal = 0.0;\n} else {\nfloat absVal2 = abs(val2);\nfloat rem = mod(val1, absVal2);\noutVal = 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) {\noutVal = val1 / 180.0 * PI;\n}\nvoid node_math_sign(float val1, float val2, float val3, out float outVal) {\noutVal = sign(val1);\n}\nvoid node_math_sinh(float val1, float val2, float val3, out float outVal) {\noutVal = sinh(val1);\n}\nvoid node_math_smooth_max(float val1, float val2, float val3, out float outVal) {\noutVal = smoothMax(val1, val2, val3);\n}\nvoid node_math_smooth_min(float val1, float val2, float val3, out float outVal) {\noutVal = smoothMin(val1, val2, val3);\n}\nvoid node_math_snap(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5 * sign(val2);\nfloat quot = val1 / val2;\noutVal = floor(quot) * val2;\n}\nvoid node_math_tanh(float val1, float val2, float val3, out float outVal) {\noutVal = tanh(val1);\n}\nvoid node_math_trunc(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5;\noutVal = trunc(val1);\n}\nvoid node_math_wrap(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5;\noutVal = mod(val1 - val3, val2 - val3) + val3;\n}\nvoid node_math_add(float val1, float val2, out float outVal) {\nnode_math_add(val1, val2, 0.0, outVal);\n}\nvoid node_math_subtract(float val1, float val2, out float outVal) {\nnode_math_subtract(val1, val2, 0.0, outVal);\n}\nvoid node_math_multiply(float val1, float val2, out float outVal) {\nnode_math_multiply(val1, val2, 0.0, outVal);\n}\nvoid node_math_divide(float val1, float val2, out float outVal) {\nnode_math_divide(val1, val2, 0.0, outVal);\n}\nvoid node_math_sine(float val1, float val2, out float outVal) {\nnode_math_sine(val1, val2, 0.0, outVal);\n}\nvoid node_math_cosine(float val1, float val2, out float outVal) {\nnode_math_cosine(val1, val2, 0.0, outVal);\n}\nvoid node_math_tangent(float val1, float val2, out float outVal) {\nnode_math_tangent(val1, val2, 0.0, outVal);\n}\nvoid node_math_arcsine(float val1, float val2, out float outVal) {\nnode_math_arcsine(val1, val2, 0.0, outVal);\n}\nvoid node_math_arccosine(float val1, float val2, out float outVal) {\nnode_math_arccosine(val1, val2, 0.0, outVal);\n}\nvoid node_math_arctangent(float val1, float val2, out float outVal) {\nnode_math_arctangent(val1, val2, 0.0, outVal);\n}\nvoid node_math_arctan2(float val1, float val2, out float outVal) {\nnode_math_arctan2(val1, val2, 0.0, outVal);\n}\nvoid node_math_power(float val1, float val2, out float outVal) {\nnode_math_power(val1, val2, 0.0, outVal);\n}\nvoid node_math_logarithm(float val1, float val2, out float outVal) {\nnode_math_logarithm(val1, val2, 0.0, outVal);\n}\nvoid node_math_sqrt(float val1, float val2, out float outVal) {\nnode_math_sqrt(val1, val2, 0.0, outVal);\n}\nvoid node_math_maximum(float val1, float val2, out float outVal) {\nnode_math_maximum(val1, val2, 0.0, outVal);\n}\nvoid node_math_minimum(float val1, float val2, out float outVal) {\nnode_math_minimum(val1, val2, 0.0, outVal);\n}\nvoid node_math_round(float val1, float val2, out float outVal) {\nnode_math_round(val1, val2, 0.0, outVal);\n}\nvoid node_math_floor(float val1, float val2, out float outVal) {\nnode_math_floor(val1, val2, 0.0, outVal);\n}\nvoid node_math_ceil(float val1, float val2, out float outVal) {\nnode_math_ceil(val1, val2, 0.0, outVal);\n}\nvoid node_math_fract(float val1, float val2, out float outVal) {\nnode_math_fract(val1, val2, 0.0, outVal);\n}\nvoid node_math_less_than(float val1, float val2, out float outVal) {\nnode_math_less_than(val1, val2, 0.0, outVal);\n}\nvoid node_math_greater_than(float val1, float val2, out float outVal) {\nnode_math_greater_than(val1, val2, 0.0, outVal);\n}\nvoid node_math_modulo(float val1, float val2, out float outVal) {\nnode_math_modulo(val1, val2, 0.0, outVal);\n}\nvoid node_math_absolute(float val1, float val2, out float outVal) {\nnode_math_absolute(val1, val2, 0.0, outVal);\n}",node_mix_rgb_bl_frag:"\nvoid node_mix_rgb_mix(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_add(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 + col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_multiply(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 * col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_screen(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = vec4(1.0) - (vec4(facm) + fac * (vec4(1.0) - col2)) * (vec4(1.0) - col1);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_overlay(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nif (outCol.r < 0.5)\noutCol.r *= facm + 2.0 * fac * col2.r;\nelse\noutCol.r = 1.0 - (facm + 2.0 * fac * (1.0 - col2.r)) * (1.0 - outCol.r);\nif (outCol.g < 0.5)\noutCol.g *= facm + 2.0 * fac * col2.g;\nelse\noutCol.g = 1.0 - (facm + 2.0 * fac * (1.0 - col2.g)) * (1.0 - outCol.g);\nif (outCol.b < 0.5)\noutCol.b *= facm + 2.0 * fac * col2.b;\nelse\noutCol.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{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 - col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_divide(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nif (col2.r != 0.0) outCol.r = facm * outCol.r + fac * outCol.r / col2.r;\nif (col2.g != 0.0) outCol.g = facm * outCol.g + fac * outCol.g / col2.g;\nif (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{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, abs(col1 - col2), fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_darken(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol.rgb = min(col1.rgb, col2.rgb * fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_lighten(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol.rgb = max(col1.rgb, col2.rgb * fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_dodge(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = col1;\nif (outCol.r != 0.0) {\nfloat tmp = 1.0 - fac * col2.r;\nif (tmp <= 0.0)\noutCol.r = 1.0;\nelse if ((tmp = outCol.r / tmp) > 1.0)\noutCol.r = 1.0;\nelse\noutCol.r = tmp;\n}\nif (outCol.g != 0.0) {\nfloat tmp = 1.0 - fac * col2.g;\nif (tmp <= 0.0)\noutCol.g = 1.0;\nelse if ((tmp = outCol.g / tmp) > 1.0)\noutCol.g = 1.0;\nelse\noutCol.g = tmp;\n}\nif (outCol.b != 0.0) {\nfloat tmp = 1.0 - fac * col2.b;\nif (tmp <= 0.0)\noutCol.b = 1.0;\nelse if ((tmp = outCol.b / tmp) > 1.0)\noutCol.b = 1.0;\nelse\noutCol.b = tmp;\n}\n}\nvoid node_mix_rgb_burn(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat tmp, facm = 1.0 - fac;\noutCol = col1;\ntmp = facm + fac * col2.r;\nif (tmp <= 0.0)\noutCol.r = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.r) / tmp)) < 0.0)\noutCol.r = 0.0;\nelse if (tmp > 1.0)\noutCol.r = 1.0;\nelse\noutCol.r = tmp;\ntmp = facm + fac * col2.g;\nif (tmp <= 0.0)\noutCol.g = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.g) / tmp)) < 0.0)\noutCol.g = 0.0;\nelse if (tmp > 1.0)\noutCol.g = 1.0;\nelse\noutCol.g = tmp;\ntmp = facm + fac * col2.b;\nif (tmp <= 0.0)\noutCol.b = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.b) / tmp)) < 0.0)\noutCol.b = 0.0;\nelse if (tmp > 1.0)\noutCol.b = 1.0;\nelse\noutCol.b = tmp;\n}\n#ifdef HSV_NODES\nvoid node_mix_rgb_hue(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2, tmp;\nrgbToHSV(col2, hsv2);\nif (hsv2.y != 0.0) {\nrgbToHSV(outCol, hsv);\nhsv.x = hsv2.x;\nhsvToRGB(hsv, tmp);\noutCol = mix(outCol, tmp, fac);\noutCol.a = col1.a;\n}\n}\nvoid node_mix_rgb_saturation(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2;\nrgbToHSV(outCol, hsv);\nif (hsv.y != 0.0) {\nrgbToHSV(col2, hsv2);\nhsv.y = facm * hsv.y + fac * hsv2.y;\nhsvToRGB(hsv, outCol);\n}\n}\nvoid node_mix_rgb_value(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\nvec4 hsv, hsv2;\nrgbToHSV(col1, hsv);\nrgbToHSV(col2, hsv2);\nhsv.z = facm * hsv.z + fac * hsv2.z;\nhsvToRGB(hsv, outCol);\n}\nvoid node_mix_rgb_color(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2, tmp;\nrgbToHSV(col2, hsv2);\nif (hsv2.y != 0.0) {\nrgbToHSV(outCol, hsv);\nhsv.x = hsv2.x;\nhsv.y = hsv2.y;\nhsvToRGB(hsv, tmp);\noutCol = mix(outCol, tmp, fac);\noutCol.a = col1.a;\n}\n}\n#endif\nvoid node_mix_rgb_soft_light(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\nvec4 one = vec4(1.0);\nvec4 scr = one - (one - col2) * (one - col1);\noutCol = 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{\nfac = clamp(fac, 0.0, 1.0);\noutCol = col1 + fac * (2.0 * (col2 - vec4(0.5)));\n}",node_mix_shader_bl_frag:"\nvoid node_mix_shader(int transpShaderNum,\nfloat fac, vec4 color1, vec4 color2, out vec4 outColor)\n{\nif (transpShaderNum == 0)\ncolor1.rgb = color2.rgb;\nelse if (transpShaderNum == 1)\ncolor2.rgb = color1.rgb;\noutColor = mix(color1, color2, fac);\n}",node_new_geometry_bl_frag:"void node_new_geometry(\nbool frontFacing, vec3 viewPos, vec3 viewNorm,\nout vec3 position, out vec3 normal, out vec3 tangent,\nout vec3 trueNormal, out vec3 incoming, out vec3 parametric,\nout float backfacing, out float pointiness, out float randomPerIsland)\n{\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nposition = swizzleUpZ(posWorld.xyz);\nvec4 viewDir = isOrtho(projectionMatrix) ? vec4(0.0, 0.0, -1.0, 0.0) : vec4(normalize(-viewPos), 0.0);\nviewDir = invViewMatrix * viewDir;\nvec3 incomingVec = -swizzleUpZ(viewDir.xyz);\n#if WORLD_NODES == 1\nnormal = incomingVec;\ntangent = vec3(0.0);\n#else\nvec3 norWorld = normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz;\nnormal = swizzleUpZ(norWorld);\nvec4 posLocal = invModelMatrix * posWorld;\nvec3 posLocalDelta = posLocal.xyz - boundingBoxMin;\nvec3 bbDelta = boundingBoxMax - boundingBoxMin;\nvec3 posOrco = vec3(\nbbDelta.x < 1e-5 ? -sign(posLocal.y) : posLocalDelta.x / bbDelta.x,\n0.0,\nbbDelta.z < 1e-5 ? sign(posLocal.y) : posLocalDelta.z / bbDelta.z\n);\nposOrco -= 0.5;\nvec3 tangWorld = (modelMatrix * vec4(posOrco.z, 0.0, -posOrco.x, 0.0)).xyz;\ntangWorld = cross(norWorld, normalize(cross(tangWorld, norWorld)));\ntangent = swizzleUpZ(tangWorld);\n#endif\ntrueNormal = normal;\nincoming = incomingVec;\nparametric = vec3(0.0);\nbackfacing = (frontFacing) ? 0.0 : 1.0;\n#if WORLD_NODES == 1\npointiness = 0.0;\n#else\npointiness = 0.5;\n#endif\nrandomPerIsland = 0.0;\n}\nvoid node_new_geometry(\nbool frontFacing, vec3 viewPos, vec3 viewNorm,\nout vec3 position, out vec3 normal, out vec3 tangent,\nout vec3 trueNormal, out vec3 incoming, out vec3 parametric,\nout float backfacing, out float pointiness) {\nfloat randomPerIsland;\nnode_new_geometry(frontFacing, viewPos, viewNorm, position, normal, tangent,\ntrueNormal, incoming, parametric, backfacing, pointiness, randomPerIsland);\n}",node_normal_bl_frag:"\nvoid node_normal(vec3 norParam, vec3 norIn, out vec3 norOut, out float dotOut)\n{\nnorOut = norParam;\ndotOut = dot(normalize(norIn), norParam);\n}",node_normal_map_bl_frag:"\nvoid node_normal_map(vec4 tangent, vec3 normal, float strength, vec4 normalColor, out vec3 normalOut)\n{\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\nnormalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\nnormalOut = mix(normal, normalOut, strength);\nnormalOut = normalize((invViewMatrix * vec4(normalOut, 0.0)).xyz);\nnormalOut = swizzleUpZ(normalOut);\n}",node_object_info_bl_frag:"\nvoid node_object_info(out vec3 location, out vec4 color, out float objIndex,\nout float matIndex, out float random) {\n#if WORLD_NODES == 1\nlocation = vec3(0.0);\ncolor = vec4(1.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.0;\n#else\nlocation = vec3(0.0);\ncolor = vec4(1.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 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\nlocation = vec3(0.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.0;\n#else\nlocation = vec3(0.0);\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.5;\n#endif\n}",node_output_lamp_bl_frag:"void node_output_lamp(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_output_material_bl_frag:"\nvoid node_output_material(vec4 surface, vec4 volume, float displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}\nvoid node_output_material(vec4 surface, vec4 volume, vec3 displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}",node_output_world_bl_frag:"void node_output_world(vec4 surface, vec4 volume, out vec4 outgoingLight)\n{\noutgoingLight = surface;\n}",node_particle_info_bl_frag:"\nvoid node_particle_info(out float index, out float random, out float age,\nout float lifeTime, out vec3 location, out float size, out vec3 velocity,\nout vec3 angularVelocity) {\n#if WORLD_NODES == 1\nindex = 0.0;\nrandom = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#else\nindex = 0.0;\nrandom = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#endif\n}\nvoid node_particle_info(out float index, out float age, out float lifeTime, out vec3 location,\nout float size, out vec3 velocity, out vec3 angularVelocity) {\n#if WORLD_NODES == 1\nindex = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#else\nindex = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#endif\n}",node_principled_volume_bl_frag:"void node_principled_volume(vec4 color, float colorAttribute, float density,\nfloat densityAttribute, float anisotropy, vec4 absorptionColor,\nfloat emissionStrength, vec4 emissionColor, float blackbodyIntensity,\nvec4 blackbodyTint, float temperature, float temperatureAttribute,\nout vec4 volume) {\nvolume = vec4(0.0);\n}",node_rgb_bl_frag:"\nuniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_rgbtobw_bl_frag:"\nvoid node_rgbtobw(vec4 color, out float outVal) {\noutVal = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722;\n}",node_script_bl_frag:"void node_script(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_sephsv_bl_frag:"\nvoid node_sephsv(vec4 col, out float h, out float s, out float v)\n{\nvec4 hsv;\nrgbToHSV(col, hsv);\nh = hsv[0];\ns = hsv[1];\nv = hsv[2];\n}",node_seprgb_bl_frag:"\nvoid node_seprgb(vec4 col, out float r, out float g, out float b)\n{\nr = col.r;\ng = col.g;\nb = col.b;\n}",node_sepxyz_bl_frag:"void node_sepxyz(vec3 vector, out float x, out float y, out float z)\n{\nx = vector.x;\ny = vector.y;\nz = vector.z;\n}",node_shadertorgb_bl_frag:"void node_shadertorgb(vec4 shader, out vec4 color, out float alpha) {\ncolor = vec4(shader.rgb, 1.0);\nalpha = shader.a;\n}",node_squeeze_bl_frag:"\nvoid node_squeeze(float val, float width, float center, out float outVal)\n{\noutVal = 1.0 / (1.0 + pow(2.71828183, -((val - center) * width)));\n}",node_subsurface_scattering_bl_frag:"void node_subsurface_scattering(\nvec4 color, float scale, vec3 radius, float sharpen, float textureBlur, vec3 normal,\nout vec4 outColor)\n{\noutColor = color;\n}",node_tangent_bl_frag:"void node_tangent(out vec3 outTangent)\n{\noutTangent = vec3(0.0);\n}",node_tex_brick_bl_frag:"void node_tex_brick(\nvec3 vector, vec4 color1, vec4 color2, vec4 mortar, float scale,\nfloat mortarSize, float mortarSmooth, float bias, float brickWidth,\nfloat rowHeight,\nout vec4 outColor, out float fac)\n{\noutColor = color1;\n}",node_tex_checker_bl_frag:"void node_tex_checker(vec3 vector, vec4 color1, vec4 color2, float scale, \nout vec4 outColor, out float outFac)\n{\nvec3 p = vector * scale;\np = (p + 0.00001) * 0.99999;\nfloat cx = floor(p.x);\nfloat cy = floor(p.y);\nfloat cz = floor(p.z);\nfloat result = sign(mod(cx + cy + cz, 2.0));\noutFac = max(result, 0.0);\noutColor = mix(color2, color1, outFac);\n}",node_tex_coord_bl_frag:"uniform mat4 nodeTexCoordObjectMatrices[NODE_TEX_COORD_NUM];\nvoid node_tex_coord(\nmat4 objectMat, vec3 viewPos, vec3 viewNorm, vec2 uv,\nout vec3 outGenerated, out vec3 outNormal, out vec3 outUV, out vec3 outObject,\nout vec3 outCamera, out vec3 outWindow, out vec3 outReflection)\n{\nvec4 view = vec4(-viewPos, 1.0);\nvec4 posWorld = invViewMatrix * view;\nvec3 loc = swizzleUpZ((invModelMatrix * posWorld).xyz);\n#if WORLD_NODES == 1\nloc = normalize(loc);\n#endif\n#if WORLD_NODES == 1\noutGenerated = loc;\n#else\nvec3 boxMin = vec3(boundingBoxMin.x, -boundingBoxMax.z, boundingBoxMin.y);\nvec3 boxMax = vec3(boundingBoxMax.x, -boundingBoxMin.z, boundingBoxMax.y);\nvec3 boxSize = boxMax - boxMin;\nif (abs(boxSize.x) < 0.001) {\noutGenerated.x = 0.5;\n} else {\noutGenerated.x = (loc.x - boxMin.x) / boxSize.x;\n}\nif (abs(boxSize.y) < 0.001) {\noutGenerated.y = 0.5;\n} else {\noutGenerated.y = (loc.y - boxMin.y) / boxSize.y;\n}\nif (abs(boxSize.z) < 0.001) {\noutGenerated.z = 0.5;\n} else {\noutGenerated.z = (loc.z - boxMin.z) / boxSize.z;\n}\n#endif\n#if WORLD_NODES == 1\noutNormal = -loc;\n#else\noutNormal = normalize(invModelMatrix * invViewMatrix * vec4(viewNorm, 0.0)).rgb;\noutNormal = swizzleUpZ(outNormal);\n#endif\n#if WORLD_NODES == 1\noutUV = vec3(0.0);\n#else\nuv.y = 1.0 - uv.y;\noutUV = vec3(uv, 0.0);\n#endif\n#if WORLD_NODES == 1\noutObject = loc;\n#else\noutObject = swizzleUpZ((objectMat * posWorld).xyz);\n#endif\noutCamera = vec3(view.xy, -view.z);\n#if WORLD_NODES == 1\noutWindow = vec3(0.0);\n#else\noutWindow = vec3(gl_FragCoord.xy / viewWidthHeight, 0.0);\n#endif\n#if WORLD_NODES == 1\noutReflection = -loc;\n#else\nvec4 reflection = (invViewMatrix * vec4(reflect(view.xyz, normalize(viewNorm)), 0.0));\noutReflection = normalize(swizzleUpZ(reflection.xyz));\n#endif\n}",node_tex_environment_bl_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) {\nvec2 uv;\nfloat bias;\nif (projection == TEX_PROJ_EQUIRECTANGULAR) {\nvec3 direction = swizzleUpY(vector);\nif (length(direction) == 0.0) {\ndirection = vec3(0.0, 1.0, 0.0);\n} else {\ndirection = normalize(direction);\n}\nuv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nuv.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\n#if WORLD_NODES == 1\nbias = -16.0;\n#else\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (direction.z) / seamWidth) *\nclamp (1.0 - direction.x / seamWidth, 0.0, 1.0);\nbias = seamBiasFactor * seam;\n#endif\n} else {\nvec3 normal = normalize(vector);\nnormal.y -= 1.0;\nnormal /= (2.0 * sqrt(max(-0.5 * normal.y, 0.0)));\nuv = clamp(0.5 * normal.xz + 0.5, 0.0, 1.0);\nbias = 0.0;\n}\nuv.y = 1.0 - uv.y;\noutColor = texture2D(tex, uv, bias);\noutColor = nodeTexelToLinear(outColor, encoding);\n}",node_tex_environment_none_bl_frag:"void node_tex_environment_none(vec3 vector, out vec4 outColor) {\noutColor = vec4(1.0, 0.0, 1.0, 1.0);\n}",node_tex_gradient_bl_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{\nfloat x, y, z, r;\nx = vector.x;\ny = vector.y;\nz = vector.z;\nif (type == TEX_GRAD_LINEAR) {\noutFac = x;\n} else if (type == TEX_GRAD_QUADRATIC) {\nr = max(x, 0.0);\noutFac = pow2(r);\n} else if (type == TEX_GRAD_EASING) {\nr = min(max(x, 0.0), 1.0);\noutFac = (3.0 * pow2(r) - 2.0 * pow3(r));\n} else if (type == TEX_GRAD_DIAGONAL) {\noutFac = (x + y) * 0.5;\n} else if (type == TEX_GRAD_RADIAL) {\noutFac = atan(y, x) / PI2 + 0.5;\n} else {\nr = max(0.99999 - sqrt(x * x + y * y + z * z), 0.0);\nif (type == TEX_GRAD_QUADRATIC_SPHERE) {\noutFac = pow2(r);\n} else if (type == TEX_GRAD_SPHERICAL) {\noutFac = r;\n}\n}\noutFac = clamp(outFac, 0.0, 1.0);\noutColor = vec4(outFac, outFac, outFac, 1.0);\n}",node_tex_ies_bl_frag:"void node_tex_ies(vec3 vector, float strength, out float fac) {\nfac = 0.0;\n}",node_tex_image_bl_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,\nconst int projection, const float projectionBlend, const bool clampToEdgeNoExtend,\nvec3 vector,\nout vec4 outColor, out float outAlpha) {\nif (projection == TEX_PROJ_FLAT) {\nvec2 uv = vector.xy;\nuv.y = 1.0 - uv.y;\nif (clampToEdgeNoExtend && (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)) {\noutColor = vec4(0.0);\noutAlpha = 0.0;\n} else {\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\n}\noutColor = nodeTexelToLinear(outColor, encoding);\n} else if (projection == TEX_PROJ_BOX) {\nvec3 norm = normalize(viewNorm * normalMatrix);\nvector = swizzleUpY(vector);\nvec2 uvX = vec2(-sign(norm.x) * vector.z, -vector.y);\nvec2 uvY = vec2(sign(norm.y) * vector.z, -vector.x);\nvec2 uvZ = vec2(sign(norm.z) * vector.x, -vector.y);\nvec4 colX = nodeTexelToLinear(texture2D(ima, uvX), encoding);\nvec4 colY = nodeTexelToLinear(texture2D(ima, uvY), encoding);\nvec4 colZ = nodeTexelToLinear(texture2D(ima, uvZ), encoding);\nvec3 barycentric = abs(norm);\nbarycentric /= barycentric.x + barycentric.y + barycentric.z;\nvec3 edgeShape = min(min(barycentric.yzx, barycentric.zxy),\n(projectionBlend - 1.0) / (projectionBlend - 3.0));\nvec3 edgeValue = (1.0 - projectionBlend) * (1.0 - edgeShape) / 2.0;\nvec3 weight = max((barycentric - edgeValue) / (1.0 - edgeValue), 0.0);\nweight /= (weight.x + weight.y + weight.z);\noutColor = weight.x * colX + weight.y * colY + weight.z * colZ;\noutAlpha = outColor.a;\n} else if (projection == TEX_PROJ_SPHERE) {\nvector = normalize(vector * 2.0 - 1.0);\nvector = swizzleUpY(vector);\nvec2 uv = vec2(atan(vector.x, vector.z) / PI2, acos(vector.y) / PI);\nuv.x = mod(uv.x, 1.0);\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\noutColor = nodeTexelToLinear(outColor, encoding);\n} else if (projection == TEX_PROJ_TUBE) {\nvector = vector * 2.0 - 1.0;\nvector = swizzleUpY(vector);\nvec2 uv = vec2(atan(vector.x, vector.z) / PI2, (1.0 - vector.y) / 2.0);\nuv.x = mod(uv.x, 1.0);\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\noutColor = nodeTexelToLinear(outColor, encoding);\n}\n}",node_tex_image_none_bl_frag:"void node_tex_image_none(vec3 vector, out vec4 color, out float alpha)\n{\ncolor = vec4(1.0, 0.0, 1.0, 1.0);\nalpha = 1.0;\n}",node_tex_magic_bl_frag:"void node_tex_magic(vec3 vector, float scale, float distortion,\nout vec4 outColor, out float outFac)\n{\noutColor = vec4(0.0);\noutFac = 0.0;\n}",node_tex_musgrave_bl_frag:"void node_tex_musgrave(vec3 vector, float w, float scale, float detail,\nfloat dimension, float lacunarity, float offset, float gain,\nout float outFac) {\noutFac = 0.0;\n}\nvoid node_tex_musgrave(\nvec3 vector, float scale, float detail, float dimension, float lacunarity,\nfloat offset, float gain,\nout vec4 outColor, out float outFac)\n{\noutColor = vec4(0.0);\noutFac = 0.0;\n}",node_tex_noise_bl_frag:"\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float w, float scale, float detail, float roughness,\nfloat distortion, out float outFac, out vec4 outColor) {\nvec3 p = vector * scale;\nvec3 dx = dFdx(p);\nvec3 dy = dFdy(p);\nfloat octaveLenPerPixel = (length(dx) + length(dy)) / 4.0;\nif (distortion != 0.0) {\nvec3 r, offset = vec3(13.5, 13.5, 13.5);\nr.x = noiseSmooth(p + offset, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\nr.y = noiseSmooth(p, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\nr.z = noiseSmooth(p - offset, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\np += r;\n}\noutFac = noiseTurbulence(p, detail, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nvec3 color = vec3(outFac,\nnoiseTurbulence(vec3(p.y, p.x, p.z), detail, octaveLenPerPixel,\nfalloffFactor, dispersionFactor),\nnoiseTurbulence(vec3(p.y, p.z, p.x), detail, octaveLenPerPixel,\nfalloffFactor, dispersionFactor)\n);\noutColor = vec4(color, 1.0);\n}\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float w, float scale, float detail, float distortion,\nout float outFac, out vec4 outColor) {\nnode_tex_noise(falloffFactor, dispersionFactor, vector, w, scale, detail,\n0.5, distortion, outFac, outColor);\n}\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float scale, float detail, float distortion,\nout vec4 outColor, out float outFac) {\nnode_tex_noise(falloffFactor, dispersionFactor, vector, 0.0, scale, detail,\ndistortion, outFac, outColor);\n}",node_tex_pointdensity_bl_frag:"void node_tex_pointdensity(\nvec3 vector,\nout vec4 outColor, out float outDensity)\n{\noutColor = vec4(0.0);\noutDensity = 0.0;\n}",node_tex_sky_bl_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, \nvec3 param3, vec3 param4, vec3 param5, vec3 param6, vec3 param7, \nvec3 param8, vec3 radiance, vec3 sunDirection, vec3 vectorIn, \nout vec4 outColor) {\nif (length(vectorIn) == 0.0) {\nvectorIn = vec3(0.0, 1.0, 0.0);\n} else {\nvectorIn = normalize(vectorIn);\n}\nvectorIn = swizzleUpY(vectorIn);\nsunDirection = swizzleUpY(sunDirection);\nfloat cosGamma = clamp(dot(vectorIn, sunDirection), -1.0, 1.0);\nfloat cosTheta = clamp(vectorIn.y, 0.0, 1.0);\nif (skyType == TEX_SKY_PREETHAM) {\nvec3 radInternal = (1.0 + param0 * exp(param1 / cosTheta)) * (\n1.0 + param2 * exp(param3 * acos(cosGamma)) \n+ param4 * pow(cosGamma, 2.0)\n);\nvec3 XYZ = xyY_to_XYZ(radInternal.y * radiance.y,\nradInternal.z * radiance.z, radInternal.x * radiance.x);\noutColor = vec4(max(xyz_to_sRGB(XYZ), 0.0), 1.0);\n} else if (skyType == TEX_SKY_HOSEK_WILKIE) {\nfloat cosGammaSq = pow(cosGamma, 2.0);\nvec3 chi = (1.0 + cosGammaSq) / pow(1.0 + pow(param8, vec3(2.0))\n- 2.0 * param8 * cosGamma, vec3(1.5));\nvec3 radInternal = (1.0 + param0 * exp(param1 / (cosTheta + 0.01))) * (\nparam2 + param3 * exp(param4 * acos(cosGamma)) \n+ param5 * cosGammaSq + param6 * chi + param7 * sqrt(cosTheta)\n);\noutColor = vec4(max(xyz_to_sRGB(radInternal * radiance), 0.0) * PI2/Km, 1.0);\n} else {\noutColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n}",node_tex_voronoi_bl_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 {\nvec3 point;\nvec3 randVec;\nvec3 toClosest;\nfloat dist;\n};\nfloat worleyLength(vec3 vec, int distance, float exponent) {\nif (distance == DISTANCE_EUCLIDEAN) {\nreturn length(vec);\n} else if (distance == DISTANCE_MANHATTAN) {\nreturn abs(vec.x) + abs(vec.y) + abs(vec.z);\n} else if (distance == DISTANCE_CHEBYCHEV) {\nreturn max(max(abs(vec.x), abs(vec.y)), abs(vec.z));\n} else if (distance == DISTANCE_MINKOWSKI) {\nreturn pow(pow(abs(vec.x), exponent)\n+ pow(abs(vec.y), exponent)\n+ pow(abs(vec.z), exponent), 1.0 / exponent);\n}\nreturn 0.0;\n}\nvoid worleyNoise(vec3 pos, int distance, float exponent, int feature,\nfloat smoothness, float randomness, out float outDist, out vec4 outColor,\nout vec3 outPosition, out float outW, out float outRadius) {\nconst highp float RAND_FIX_ZERO = 0.125;\nvec3 posI = floor(pos);\nvec3 posF = fract(pos);\nVoronoiGridData vgd[27];\n#pragma unroll_loop\nfor (int i = 0; i <= 2; i++) {\n#pragma unroll_loop\nfor (int j = 0; j <= 2; j++) {\n#pragma unroll_loop\nfor (int k = 0; k <= 2; k++) {\nvec3 point = vec3((i), (j), (k)) - 1.0;\nvec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\nvec3 toClosest = point + randomness * randVec - posF;\nconst int counter = (i) + (j) * 3 + (k) * 9;\nvgd[counter].point = point;\nvgd[counter].randVec = randVec;\nvgd[counter].toClosest = toClosest;\nvgd[counter].dist = worleyLength(toClosest, distance, exponent);\n}\n}\n}\nfloat f1 = 1e10;\nfloat f2 = 1e10;\nvec3 edgeToClosest = vec3(0.0);\nfloat distToEdge = 1e10;\nvec3 randColF1 = vec3(0.0);\nvec3 randColF2 = vec3(0.0);\nvec3 toClosestF1 = vec3(0.0);\nvec3 toClosestF2 = vec3(0.0);\nvec3 radPoint = vec3(0.0);\nvec3 radToClosest = vec3(0.0);\n#pragma unroll_loop\nfor (int i = 0; i < 27; i++) {\nif (feature == FEATURE_F1) {\nif (vgd[i].dist < f1) {\nf1 = vgd[i].dist;\nrandColF1 = vgd[i].randVec;\ntoClosestF1 = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_F2) {\nif (vgd[i].dist < f1) {\nf2 = f1;\nf1 = vgd[i].dist;\nrandColF2 = randColF1;\nrandColF1 = vgd[i].randVec;\ntoClosestF2 = toClosestF1;\ntoClosestF1 = vgd[i].toClosest;\n} else if (vgd[i].dist < f2) {\nf2 = vgd[i].dist;\nrandColF2 = vgd[i].randVec;\ntoClosestF2 = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_SMOOTH_F1) {\nf1 = smoothMin(f1, vgd[i].dist, smoothness);\n} else if (feature == FEATURE_DISTANCE_TO_EDGE) {\nfloat dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\nif (dist < f1) {\nf1 = dist;\nedgeToClosest = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_N_SPHERE_RADIUS) {\nfloat dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\nif (dist < f1) {\nf1 = dist;\nradPoint = vgd[i].point;\nradToClosest = vgd[i].toClosest;\n}\n}\n}\nif (feature == FEATURE_F1) {\noutDist = f1;\noutColor = vec4(randColF1, 1.0);\noutPosition = pos + toClosestF1;\n} else if (feature == FEATURE_F2) {\noutDist = f2;\noutColor = vec4(randColF2, 1.0);\noutPosition = pos + toClosestF2;\n} else if (feature == FEATURE_SMOOTH_F1) {\noutDist = f1;\nvec3 avgCol = vec3(0.0);\nvec3 avgOff = vec3(0.0);\nfloat sumWeightsCol = 0.0;\nfloat sumWeightsOff = 0.0;\n#pragma unroll_loop\nfor (int i = 0; i < 27; i++) {\nfloat smoothFac = getSmoothFactor(f1, vgd[i].dist, smoothness);\nfloat weightOff = smoothFac * smoothFac * smoothFac;\nfloat weightCol = weightOff * smoothFac;\navgCol += vgd[i].randVec * weightCol;\navgOff += vgd[i].toClosest * weightOff;\nsumWeightsCol += weightCol;\nsumWeightsOff += weightOff;\n}\noutColor = vec4(avgCol / sumWeightsCol, 1.0);\noutPosition = pos + avgOff / sumWeightsOff;\n} else if (feature == FEATURE_DISTANCE_TO_EDGE) {\n#pragma unroll_loop\nfor (int i = 0; i < 27; i++) {\nif (vgd[i].toClosest != edgeToClosest) {\nfloat dist = dot(0.5 * (edgeToClosest + vgd[i].toClosest),\nnormalize(vgd[i].toClosest - edgeToClosest));\ndistToEdge = min(distToEdge, dist);\n}\n}\noutDist = distToEdge;\n} else if (feature == FEATURE_N_SPHERE_RADIUS) {\nfloat diam = 1e10;\n#pragma unroll_loop\nfor (int i = 0; i <= 2; i++) {\n#pragma unroll_loop\nfor (int j = 0; j <= 2; j++) {\n#pragma unroll_loop\nfor (int k = 0; k <= 2; k++) {\nvec3 localPoint = vec3((i), (j), (k)) - 1.0;\nif (length(localPoint) > 0.0) {\nvec3 point = localPoint + radPoint;\nvec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\nvec3 toClosest = point + randomness * randVec - posF;\ndiam = min(diam, length(toClosest - radToClosest));\n}\n}\n}\n}\noutRadius = diam / 2.0;\n}\n}\n#define VORONOI_SMOOTH_COEFF 0.74\nvoid node_tex_voronoi(\nint distance, int feature,\nvec3 vector, float w, float scale, float smoothness, float exponent,\nfloat randomness,\nout float outDistance, out vec4 outColor, out vec3 outPosition,\nout float outW, out float outRadius) {\nvector = scale * (vector - 0.0001);\nsmoothness = clamp(smoothness, 1e-3, 1.0);\nsmoothness *= VORONOI_SMOOTH_COEFF;\nworleyNoise(vector, distance, exponent, feature, smoothness, randomness,\noutDistance, outColor, outPosition, outW, outRadius);\noutPosition /= 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 {\nvec4 closestDists;\nvec4 closestInds;\n};\nvoid updateVoronoiClosest(inout VoronoiClosest vf, vec3 newDistances,\nvec3 newIndices) {\n#pragma unroll_loop\nfor (int i = 0; i < 3; i++) {\nfloat currDist = newDistances[i];\nfloat currIdx = newIndices[i];\n#pragma unroll_loop\nfor (int j = 0; j < 4; j++) {\nif (currDist < vf.closestDists[j]) {\nfloat tmp = vf.closestDists[j];\nvf.closestDists[j] = currDist;\ncurrDist = tmp;\ntmp = vf.closestInds[j];\nvf.closestInds[j] = currIdx;\ncurrIdx = tmp;\n}\n}\n}\n}\nvec3 worleyPermute(vec3 x) {\nreturn mod((34.0 * x + 1.0) * x, 289.0);\n}\nvec3 worleyDist(vec3 x, vec3 y, vec3 z, int distance, float exponent) {\nif (distance == DISTANCE_EUCLIDEAN) {\nreturn x * x + y * y + z * z;\n} else if (distance == DISTANCE_MANHATTAN) {\nreturn abs(x) + abs(y) + abs(z);\n} else if (distance == DISTANCE_CHEBYCHEV) {\nreturn max(max(abs(x), abs(y)), abs(z));\n} else if (distance == DISTANCE_MINKOWSKI) {\nvec3 expVec = vec3(exponent);\nreturn pow(pow(abs(x), expVec)\n+ pow(abs(y), expVec)\n+ pow(abs(z), expVec), 1.0 / expVec);\n}\nreturn vec3(0.0);\n}\nVoronoiClosest worleyClosest(vec3 P, float jitter, int distance, float exponent) {\nfloat K = 0.142857142857;\nfloat Ko = 0.428571428571;\nfloat K2 = 0.020408163265306;\nfloat Kz = 0.166666666667;\nfloat Kzo = 0.416666666667;\nvec3 Pi = mod(floor(P), 289.0);\nvec3 Pf = fract(P) - 0.5;\nvec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\nvec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\nvec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\nvec3 p = worleyPermute(Pi.x + vec3(-1.0, 0.0, 1.0));\nvec3 p1 = worleyPermute(p + Pi.y - 1.0);\nvec3 p2 = worleyPermute(p + Pi.y);\nvec3 p3 = worleyPermute(p + Pi.y + 1.0);\nvec3 p11 = worleyPermute(p1 + Pi.z - 1.0);\nvec3 p12 = worleyPermute(p1 + Pi.z);\nvec3 p13 = worleyPermute(p1 + Pi.z + 1.0);\nvec3 p21 = worleyPermute(p2 + Pi.z - 1.0);\nvec3 p22 = worleyPermute(p2 + Pi.z);\nvec3 p23 = worleyPermute(p2 + Pi.z + 1.0);\nvec3 p31 = worleyPermute(p3 + Pi.z - 1.0);\nvec3 p32 = worleyPermute(p3 + Pi.z);\nvec3 p33 = worleyPermute(p3 + Pi.z + 1.0);\nvec3 ox11 = fract(p11*K) - Ko;\nvec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\nvec3 oz11 = floor(p11*K2)*Kz - Kzo;\nvec3 ox12 = fract(p12*K) - Ko;\nvec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\nvec3 oz12 = floor(p12*K2)*Kz - Kzo;\nvec3 ox13 = fract(p13*K) - Ko;\nvec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\nvec3 oz13 = floor(p13*K2)*Kz - Kzo;\nvec3 ox21 = fract(p21*K) - Ko;\nvec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\nvec3 oz21 = floor(p21*K2)*Kz - Kzo;\nvec3 ox22 = fract(p22*K) - Ko;\nvec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\nvec3 oz22 = floor(p22*K2)*Kz - Kzo;\nvec3 ox23 = fract(p23*K) - Ko;\nvec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\nvec3 oz23 = floor(p23*K2)*Kz - Kzo;\nvec3 ox31 = fract(p31*K) - Ko;\nvec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\nvec3 oz31 = floor(p31*K2)*Kz - Kzo;\nvec3 ox32 = fract(p32*K) - Ko;\nvec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\nvec3 oz32 = floor(p32*K2)*Kz - Kzo;\nvec3 ox33 = fract(p33*K) - Ko;\nvec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\nvec3 oz33 = floor(p33*K2)*Kz - Kzo;\nvec3 dx11 = Pfx + jitter*ox11;\nvec3 dy11 = Pfy.x + jitter*oy11;\nvec3 dz11 = Pfz.x + jitter*oz11;\nvec3 dx12 = Pfx + jitter*ox12;\nvec3 dy12 = Pfy.x + jitter*oy12;\nvec3 dz12 = Pfz.y + jitter*oz12;\nvec3 dx13 = Pfx + jitter*ox13;\nvec3 dy13 = Pfy.x + jitter*oy13;\nvec3 dz13 = Pfz.z + jitter*oz13;\nvec3 dx21 = Pfx + jitter*ox21;\nvec3 dy21 = Pfy.y + jitter*oy21;\nvec3 dz21 = Pfz.x + jitter*oz21;\nvec3 dx22 = Pfx + jitter*ox22;\nvec3 dy22 = Pfy.y + jitter*oy22;\nvec3 dz22 = Pfz.y + jitter*oz22;\nvec3 dx23 = Pfx + jitter*ox23;\nvec3 dy23 = Pfy.y + jitter*oy23;\nvec3 dz23 = Pfz.z + jitter*oz23;\nvec3 dx31 = Pfx + jitter*ox31;\nvec3 dy31 = Pfy.z + jitter*oy31;\nvec3 dz31 = Pfz.x + jitter*oz31;\nvec3 dx32 = Pfx + jitter*ox32;\nvec3 dy32 = Pfy.z + jitter*oy32;\nvec3 dz32 = Pfz.y + jitter*oz32;\nvec3 dx33 = Pfx + jitter*ox33;\nvec3 dy33 = Pfy.z + jitter*oy33;\nvec3 dz33 = Pfz.z + jitter*oz33;\nvec3 d11 = worleyDist(dx11, dy11, dz11, distance, exponent);\nvec3 d12 = worleyDist(dx12, dy12, dz12, distance, exponent);\nvec3 d13 = worleyDist(dx13, dy13, dz13, distance, exponent);\nvec3 d21 = worleyDist(dx21, dy21, dz21, distance, exponent);\nvec3 d22 = worleyDist(dx22, dy22, dz22, distance, exponent);\nvec3 d23 = worleyDist(dx23, dy23, dz23, distance, exponent);\nvec3 d31 = worleyDist(dx31, dy31, dz31, distance, exponent);\nvec3 d32 = worleyDist(dx32, dy32, dz32, distance, exponent);\nvec3 d33 = worleyDist(dx33, dy33, dz33, distance, exponent);\nVoronoiClosest vf = VoronoiClosest(vec4(1e10), vec4(0.0));\nupdateVoronoiClosest(vf, d11, p11);\nupdateVoronoiClosest(vf, d12, p12);\nupdateVoronoiClosest(vf, d13, p13);\nupdateVoronoiClosest(vf, d21, p21);\nupdateVoronoiClosest(vf, d22, p22);\nupdateVoronoiClosest(vf, d23, p23);\nupdateVoronoiClosest(vf, d31, p31);\nupdateVoronoiClosest(vf, d32, p32);\nupdateVoronoiClosest(vf, d33, p33);\nreturn vf;\n}\nvoid node_tex_voronoi(int coloring, int distance, int feature, vec3 vector,\nfloat scale, float exponent, out vec4 outColor, out float outFac) {\nvector = scale * (vector - 0.0001);\nVoronoiClosest vf = worleyClosest(vector, 1.0, distance, exponent);\nvec4 vorColorData;\nif (coloring == COLORING_INTENSITY) {\nvorColorData = vf.closestDists;\n} else if (coloring == COLORING_CELLS) {\nvorColorData = vf.closestInds;\n}\nfloat vorColorFac;\nif (feature == FEATURE_F1) {\nvorColorFac = vorColorData.x;\n} else if (feature == FEATURE_F2) {\nvorColorFac = vorColorData.y;\n} else if (feature == FEATURE_F3) {\nvorColorFac = vorColorData.z;\n} else if (feature == FEATURE_F4) {\nvorColorFac = vorColorData.w;\n} else if (feature == FEATURE_F2F1) {\nvorColorFac = vorColorData.y - vorColorData.x;\n}\nif (coloring == COLORING_INTENSITY) {\noutFac = vorColorFac;\noutColor = vec4(vec3(outFac), 1.0);\n} else if (coloring == COLORING_CELLS) {\nvorColorFac += 1e-3;\nfloat r = rand(vec2(vorColorFac / 289.0));\nfloat g = rand(vec2(vorColorFac / 23535.0));\nfloat b = rand(vec2(vorColorFac / 4353.0));\noutFac = (r + g + b) / 3.0;\noutColor = vec4(r, g, b, 1.0);\n}\n}",node_tex_wave_bl_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\n#define TEX_WAVE_PROFILE_TRI 2\n#define TEX_WAVE_BANDS_DIR_X 0\n#define TEX_WAVE_BANDS_DIR_Y 1\n#define TEX_WAVE_BANDS_DIR_Z 2\n#define TEX_WAVE_BANDS_DIR_DIAGONAL 3\n#define TEX_WAVE_RINGS_DIR_X 0\n#define TEX_WAVE_RINGS_DIR_Y 1\n#define TEX_WAVE_RINGS_DIR_Z 2\n#define TEX_WAVE_RINGS_DIR_SPHERICAL 3\nvoid node_tex_wave(\nint waveType, int waveProfile, int bandsDirection, int ringsDirection,\nvec3 vector, float scale, float distortion, float detail, float detailScale,\nfloat detailRoughness, float phaseOffset,\nout vec4 outColor, out float outFac) {\nvec3 coScaled = vector * scale;\nfloat waveFac;\nvec3 waveVec = coScaled;\nif (waveType == TEX_WAVE_TYPE_BANDS) {\nconst float BANDS_AXIS_SCALE = 2.0 / 3.0;\nif (bandsDirection == TEX_WAVE_BANDS_DIR_X) {\nwaveVec = waveVec.xxx * BANDS_AXIS_SCALE;\n} else if (bandsDirection == TEX_WAVE_BANDS_DIR_Y) {\nwaveVec = waveVec.yyy * BANDS_AXIS_SCALE;\n} else if (bandsDirection == TEX_WAVE_BANDS_DIR_Z) {\nwaveVec = waveVec.zzz * BANDS_AXIS_SCALE;\n} else if (bandsDirection == TEX_WAVE_BANDS_DIR_DIAGONAL) {\n}\nwaveFac = (waveVec.x + waveVec.y + waveVec.z) * 10.0;\n} else {\nif (ringsDirection == TEX_WAVE_RINGS_DIR_X) {\nwaveVec.x = 0.0;\n} else if (ringsDirection == TEX_WAVE_RINGS_DIR_Y) {\nwaveVec.y = 0.0;\n} else if (ringsDirection == TEX_WAVE_RINGS_DIR_Z) {\nwaveVec.z = 0.0;\n} else if (ringsDirection == TEX_WAVE_RINGS_DIR_SPHERICAL) {\n}\nwaveFac = length(waveVec) * 20.0;\n}\nif (distortion != 0.0) {\nwaveFac += distortion * noiseTurbulence(coScaled * detailScale, detail,\n0.0, 0.0, 1.0);\n}\nif (waveProfile == TEX_WAVE_PROFILE_SIN) {\nwaveFac = 0.5 + 0.5 * sin(waveFac - PI_HALF + phaseOffset);\n} else if (waveProfile == TEX_WAVE_PROFILE_SAW) {\nwaveFac = fract((waveFac + phaseOffset + 1e-4) / PI2);\n} else if (waveProfile == TEX_WAVE_PROFILE_TRI) {\nwaveFac = abs(2.0 * fract((waveFac + PI + phaseOffset) / PI2) - 1.0);\n}\noutColor = vec4(waveFac, waveFac, waveFac, 1.0);\noutFac = waveFac;\n}\nvoid node_tex_wave(int waveType, int waveProfile, int bandsDirection,\nint ringsDirection, vec3 vector, float scale, float distortion,\nfloat detail, float detailScale, out vec4 outColor, out float outFac) {\nfloat legacyOffset = 0.0;\nif (waveProfile == TEX_WAVE_PROFILE_SIN) {\nlegacyOffset = PI_HALF;\n}\nnode_tex_wave(waveType, waveProfile, bandsDirection, ringsDirection, vector,\nscale, distortion, detail, detailScale, 0.5, legacyOffset, outColor,\noutFac);\n}",node_tex_white_noise_bl_frag:"void node_tex_white_noise(vec3 vector, float w, out float outValue,\nout vec4 outColor) {\noutValue = 0.0;\noutColor = vec4(0.0);\n}\nvoid node_tex_white_noise(vec3 vector, float w, out float outValue) {\noutValue = 0.0;\n}",node_uvmap_bl_frag:"void node_uvmap(vec2 uv, out vec3 outUV) {\n#if WORLD_NODES == 1\noutUV = vec3(0.0);\n#else\nuv.y = 1.0 - uv.y;\noutUV = vec3(uv, 0.0);\n#endif\n}",node_valtorgb_bl_frag:"\nvoid node_valtorgb(sampler2D colormap, float fac, out vec4 colOut, out float alphaOut)\n{\ncolOut = texture2D(colormap, vec2(fac, 0.0));\nalphaOut = colOut.a;\n}",node_value_bl_frag:"\nuniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_vect_math_bl_frag:"void node_vect_math_add(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 + v2;\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 - v2;\n}\nvoid node_vect_math_multiply(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = v1 * v2;\n}\nvoid node_vect_math_divide(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec.x = v2.x == 0.0 ? 0.0 : v1.x / v2.x;\noutVec.y = v2.y == 0.0 ? 0.0 : v1.y / v2.y;\noutVec.z = v2.z == 0.0 ? 0.0 : v1.z / v2.z;\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = cross(v1, v2);\n}\nvoid node_vect_math_project(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nfloat d = dot(v2, v2);\noutVec = (d != 0.0) ? (dot(v1, v2) / d) * v2 : vec3(0.0);\n}\nvoid node_vect_math_reflect(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nif (v2 != vec3(0.0)) {\nv2 = normalize(v2);\n}\noutVec = reflect(v1, v2);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVal = dot(v1, v2);\n}\nvoid node_vect_math_distance(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVal = distance(v1, v2);\n}\nvoid node_vect_math_length(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVal = length(v1);\n}\nvoid node_vect_math_scale(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 * val;\n}\nvoid node_vect_math_normalize(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\nif (v1 != vec3(0.0)) {\nv1 = normalize(v1);\n}\noutVec = v1;\n}\nvoid node_vect_math_snap(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec.x = v2.x == 0.0 ? 0.0 : floor(v1.x / v2.x) * v2.x;\noutVec.y = v2.y == 0.0 ? 0.0 : floor(v1.y / v2.y) * v2.y;\noutVec.z = v2.z == 0.0 ? 0.0 : floor(v1.z / v2.z) * v2.z;\n}\nvoid node_vect_math_floor(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = floor(v1);\n}\nvoid node_vect_math_ceil(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = ceil(v1);\n}\nvoid node_vect_math_modulo(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nvec3 signProduct = sign(v1) * sign(v2);\nv1 += 1e-5 * signProduct;\noutVec.x = signProduct.x > 0.0 ? mod(v1.x, abs(v2.x)) : 0.0;\noutVec.y = signProduct.y > 0.0 ? mod(v1.y, abs(v2.y)) : 0.0;\noutVec.z = signProduct.z > 0.0 ? mod(v1.z, abs(v2.z)) : 0.0;\n}\nvoid node_vect_math_fraction(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = fract(v1);\n}\nvoid node_vect_math_absolute(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = abs(v1);\n}\nvoid node_vect_math_minimum(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = min(v1, v2);\n}\nvoid node_vect_math_maximum(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = max(v1, v2);\n}\nvoid node_vect_math_cosine(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = cos(v1);\n}\nvoid node_vect_math_sine(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = sin(v1);\n}\nvoid node_vect_math_tangent(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = tan(v1);\n}\nvoid node_vect_math_wrap(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nv1 += 1e-5;\noutVec.x = v2.x == v3.x ? v2.x : mod(v1.x - v3.x, v2.x - v3.x) + v3.x;\noutVec.y = v2.y == v3.y ? v2.y : mod(v1.y - v3.y, v2.y - v3.y) + v3.y;\noutVec.z = v2.z == v3.z ? v2.z : mod(v1.z - v3.z, v2.z - v3.z) + v3.z;\n}\nvoid node_vect_math_absolute(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_absolute(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_add(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_add(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_ceil(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_ceil(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_cross_product(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_distance(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_distance(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_divide(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_divide(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_dot_product(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_floor(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_floor(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_fraction(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_fraction(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_maximum(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_maximum(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_length(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_length(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_minimum(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_minimum(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_modulo(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_modulo(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_project(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_project(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_normalize(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_normalize(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_multiply(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_multiply(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_scale(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_scale(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_reflect(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_reflect(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_subtract(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_snap(vec3 v1, vec3 v2, float val, out vec3 outVec,\nout float outVal) {\nnode_vect_math_snap(v1, v2, vec3(0.0), val, outVec, outVal);\n}\nvoid node_vect_math_add(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = v1 + v2;\noutVal = (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{\noutVec = v1 - v2;\noutVal = (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{\noutVec = v1 + v2;\noutVal = length(outVec);\noutVec = normalize(outVec);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = vec3(0, 0, 0);\noutVal = dot(v1, v2);\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVec = cross(v1, v2);\noutVal = length(outVec);\noutVec /= outVal;\n}\nvoid node_vect_math_normalize(vec3 v, vec3 v2, out vec3 outVec, out float outVal)\n{\noutVal = length(v);\noutVec = normalize(v);\n}",node_vect_transform_bl_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{\nif (vecTransType == VEC_TRANS_NONE)\nvOut = vIn;\nelse {\nvec4 vec;\nif (vecTransType < VEC_TRANS_W_O_DIR)\nvec = vec4(vIn.xyz, 1.0);\nelse\nvec = vec4(vIn.xyz, 0.0);\nif (vecTransType == VEC_TRANS_W_O || vecTransType == VEC_TRANS_W_O_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = invModelMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_W_C || vecTransType == VEC_TRANS_W_C_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = viewMatrix * vec;\nif (invCamZ == 1)\nvec[2] = -vec[2];\n} else if (vecTransType == VEC_TRANS_O_W || vecTransType == VEC_TRANS_O_W_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = modelMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_O_C || vecTransType == VEC_TRANS_O_C_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = modelViewMatrix * vec;\nif (invCamZ == 1)\nvec[2] = -vec[2];\n} else if (vecTransType == VEC_TRANS_C_W || vecTransType == VEC_TRANS_C_W_DIR) {\nif (invCamZ == 1)\nvec[2] = -vec[2];\nvec = invViewMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_C_O || vecTransType == VEC_TRANS_C_O_DIR) {\nif (invCamZ == 1)\nvec[2] = -vec[2];\nvec = invModelMatrix * invViewMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n}\nvOut = vec.xyz;\n}\n}",node_vector_displacement_bl_frag:"void node_vector_displacement(vec4 vector, float midLevel, float scale,\nout vec3 displacement) {\ndisplacement = vec3(0.0);\n}",node_vector_rotate_bl_frag:"void node_vector_rotate(vec3 vector, vec3 center, vec3 axis, float angle,\nvec3 rotation, out vec3 outVector) {\noutVector = vec3(0.0);\n}",node_vertex_color_bl_frag:"void node_vertex_color(out vec4 color, out float alpha) {\ncolor = vec4(vec3(0.0), 1.0);\nalpha = 1.0;\n}",node_volume_absorption_bl_frag:"void node_volume_absorption(vec4 color, float density, out vec4 outColor)\n{\noutColor = color;\n}",node_volume_info_bl_frag:"void node_volume_info(out vec4 color, out float density, out float flame,\nout float temperature) {\ncolor = vec4(vec3(0.0), 1.0);\ndensity = 0.0;\nflame = 0.0;\ntemperature = 0.0;\n}",node_volume_scatter_bl_frag:"void node_volume_scatter(vec4 color, float density, float anisotropy, out vec4 outColor)\n{\noutColor = vec4(color);\n}",node_wavelength_bl_frag:"void node_wavelength(float wavelength, out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_wireframe_bl_frag:"void node_wireframe(float size, out float outFac)\n{\noutFac = 0.0;\n}",node_bitmap_none_mx_frag:"void node_bitmap_none(out vec4 color)\n{\ncolor = vec4(1.0);\n}",node_bitmap_env_mx_frag:"void node_bitmap_env(sampler2D envMap, int reflectMode, float IOR,\nconst int encoding, const int alphaAsMono, const int alphaAsRGB,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle, vec3 normal,\nout vec4 color, out float value)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec;\n#if WORLD_NODES\nreflectVec = normalize(cameraToVertex);\n#else\nif (reflectMode == MAX_ENV_COORDS_REFLECT)\nreflectVec = reflect(cameraToVertex, worldNormal);\nelse {\nfloat refrRatio = 1.0 / IOR;\nreflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n}\n#endif\nmat3 uvTransform = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle);\ncolor = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\nif (alphaAsMono == 1)\nvalue = color.a;\nelse\nvalue = average(color.rgb);\nif (alphaAsRGB == 1)\ncolor = vec4(color.a);\n}",node_bitmap_mx_frag:"void node_bitmap(sampler2D map, const vec2 uvIn, const int mapping, const int axis,\nconst ivec2 clampToEdgeNoExtend,\nconst int encoding, const int alphaAsMono, const int alphaAsRGB,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec4 color, out float value)\n{\nvec3 coordsIn;\nif (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n} else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\ncoordsIn = vec3(0.0);\n} else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\ncoordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n} else {\ncoordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n}\nif (axis == AXIS_XY)\ncoordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\nelse if (axis == AXIS_YZ)\ncoordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\nelse if (axis == AXIS_ZX)\ncoordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nvec2 uv = vec2(coordsOut.x, 1.0 - coordsOut.y);\nif ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n(clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\ncolor = vec4(0.0, 0.0, 0.0, 1.0);\n} else {\ncolor = texture2D(map, uv);\ncolor = nodeTexelToLinear(color, encoding);\n}\nif (alphaAsMono == 1)\nvalue = color.a;\nelse\nvalue = average(color.rgb);\nif (alphaAsRGB == 1)\ncolor = vec4(color.a);\n}",node_bump_mx_frag:"void node_bump(sampler2D bumpMap, const vec3 eyePos, const vec3 normal, const vec2 uv,\nout vec3 normalOut)\n{\nvec2 dSTdx = dFdx(uv);\nvec2 dSTdy = dFdy(uv);\nif (any(equal(dSTdx, vec2(0.0))) || any(equal(dSTdy, vec2(0.0)))) {\nnormalOut = normal;\n} else {\nconst float bumpScale = 1.0;\nvec3 vSigmaX = vec3(dFdx(eyePos.x), dFdx(eyePos.y), dFdx(eyePos.z));\nvec3 vSigmaY = vec3(dFdy(eyePos.x), dFdy(eyePos.y), dFdy(eyePos.z));\nvec3 vN = normal;\nvec3 R1 = cross(vSigmaY, vN);\nvec3 R2 = cross(vN, vSigmaX);\nfloat fDet = dot(vSigmaX, R1);\nfloat Hll = bumpScale * texture2D(bumpMap, uv).x;\nfloat dBx = bumpScale * texture2D(bumpMap, uv + dSTdx).x - Hll;\nfloat dBy = bumpScale * texture2D(bumpMap, uv + dSTdy).x - Hll;\nvec2 dHdxy = vec2(dBx, dBy);\nvec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\nnormalOut = normalize(abs(fDet) * normal - vGrad);\n}\n}",node_blend_mx_frag:"void node_blend(\nconst int useCurve, const float curveLower, const float curveUpper,\nconst vec4 color1, const vec4 color2, float mask,\nout vec4 color)\n{\nif (useCurve == 1)\nmask = smoothstep(curveLower, curveUpper, mask);\nelse\nmask = clamp(mask, 0.0, 1.0);\ncolor = mix(color1, color2, mask);\n}",node_color_correction_mx_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{\nif (type == REWIRE_RED)\nreturn color.r;\nelse if (type == REWIRE_GREEN)\nreturn color.g;\nelse if (type == REWIRE_BLUE)\nreturn color.b;\nelse if (type == REWIRE_ALPHA)\nreturn color.a;\nelse if (type == REWIRE_RED_INV)\nreturn 1.0-color.r;\nelse if (type == REWIRE_GREEN_INV)\nreturn 1.0-color.g;\nelse if (type == REWIRE_BLUE_INV)\nreturn 1.0-color.b;\nelse if (type == REWIRE_ALPHA_INV)\nreturn 1.0-color.a;\nelse if (type == REWIRE_MONOCHROME)\nreturn average(color.rgb);\nelse if (type == REWIRE_ONE)\nreturn 1.0;\nelse\nreturn 0.0;\n}\nvoid node_color_correction(const ivec4 rewire,\nconst vec4 color, const float hueShift, const float saturation,\nconst vec4 tint, const float tintStrength,\nconst float brightness, const float contrast,\nout vec4 outColor)\n{\nif (all(equal(rewire, ivec4(REWIRE_RED, REWIRE_GREEN, REWIRE_BLUE, REWIRE_ALPHA)))) {\noutColor = color;\n} else {\noutColor.r = rewireChannel(rewire.x, color);\noutColor.g = rewireChannel(rewire.y, color);\noutColor.b = rewireChannel(rewire.z, color);\noutColor.a = rewireChannel(rewire.w, color);\n}\nvec4 hsv;\nrgbToHSV(outColor, hsv);\nhsv[0] += hueShift / 360.0;\nif (hsv[0] > 1.0)\nhsv[0] -= 1.0;\nelse if (hsv[0] < 0.0)\nhsv[0] += 1.0;\nhsv[1] *= (saturation / 100.0 + 1.0);\nhsv[1] = saturate(hsv[1]);\nif (tintStrength > 0.0) {\nvec4 hsvTint;\nrgbToHSV(tint, hsvTint);\nhsv[0] = hsv[0] + (hsvTint[0] - hsv[0]) * tintStrength / 100.0;\n}\nhsvToRGB(hsv, outColor);\noutColor = (outColor - 0.5) * (contrast / 100.0 + 1.0) + 0.5 + brightness / 100.0;\noutColor = max(outColor, 0.0);\n}",node_color_map_mx_frag:"void node_color_map(const int reverseGamma,\nconst vec4 color, const float gamma, const float gain,\nout vec4 outColor)\n{\nfloat p = (reverseGamma == 1) ? gamma : 1.0 / gamma;\nfloat g = (reverseGamma == 1) ? (gain > EPSILON ? 1.0 / gain : 1.0) : gain;\noutColor = vec4(g * pow(abs(color.rgb), vec3(p)), color.a);\n}",node_composite_layer_mx_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) {\nif (blendMode == COMP_BLEND_NORMAL)\nreturn colorFG;\nelse if (blendMode == COMP_BLEND_AVERAGE)\nreturn (colorFG + colorBG) / 2.0;\nelse if (blendMode == COMP_BLEND_ADD)\nreturn colorBG + colorFG;\nelse if (blendMode == COMP_BLEND_SUBTRACT)\nreturn colorBG - colorFG;\nelse if (blendMode == COMP_BLEND_DARKEN)\nreturn min(colorFG, colorBG);\nelse if (blendMode == COMP_BLEND_MULTIPLY)\nreturn colorBG * colorFG;\nelse if (blendMode == COMP_BLEND_COLORBURN) {\nif (colorFG.r == 0.0 && colorFG.g == 0.0 && colorFG.b == 0.0)\nreturn vec4(0.0, 0.0, 0.0, 1.0);\nelse\nreturn max(1.0 - (1.0 - colorBG) / colorFG, 0.0);\n} else if (blendMode == COMP_BLEND_LINEARBURN)\nreturn max(colorFG + colorBG - 1.0, 0.0);\nelse if (blendMode == COMP_BLEND_LIGHTEN)\nreturn max(colorFG, colorBG);\nelse if (blendMode == COMP_BLEND_SCREEN)\nreturn colorFG + colorBG - colorFG * colorBG;\nelse if (blendMode == COMP_BLEND_COLORDODGE) {\nif (colorFG.r == 1.0 && colorFG.g == 1.0 && colorFG.b == 1.0)\nreturn vec4(1.0);\nelse\nreturn min(colorBG / (1.0 - colorFG), 1.0);\n} else if (blendMode == COMP_BLEND_LINEARDODGE)\nreturn min(colorFG + colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_SPOT)\nreturn min(2.0 * colorFG * colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_SPOTBLEND)\nreturn min(colorFG * colorBG + colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_OVERLAY) {\nif (colorBG.r <= 0.5 && colorBG.g <= 0.5 && colorBG.b <= 0.5)\nreturn saturate(2.0 * colorFG * colorBG);\nelse\nreturn saturate(1.0 - 2.0 * (1.0-colorFG) * (1.0-colorBG));\n} else if (blendMode == COMP_BLEND_SOFTLIGHT) {\nif (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\nreturn saturate(colorBG * (colorBG + 2.0 * colorFG * (1.0 - colorBG)));\nelse\nreturn saturate(colorBG + (2.0 * colorFG - 1.0) * (sqrt(colorBG) - colorBG));\n} else if (blendMode == COMP_BLEND_HARDLIGHT) {\nif (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\nreturn saturate(2.0 * colorFG * colorBG);\nelse\nreturn saturate(1.0 - 2.0*(1.0 - colorFG)*(1.0 - colorBG));\n} else if (blendMode == COMP_BLEND_PINLIGHT) {\nif (((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))))\nreturn colorFG;\nelse\nreturn colorBG;\n} else if (blendMode == COMP_BLEND_HARDMIX) {\nif (colorFG.r + colorBG.r <= 1.0 && colorFG.g + colorBG.g <= 1.0 && colorFG.b + colorBG.b <= 1.0)\nreturn vec4(0.0, 0.0, 0.0, 1.0);\nelse\nreturn vec4(1.0);\n} else if (blendMode == COMP_BLEND_DIFFERENCE)\nreturn abs(colorFG - colorBG);\nelse if (blendMode == COMP_BLEND_EXCLUSION)\nreturn colorFG + colorBG - 2.0 * colorFG * colorBG;\n}\nvec4 calcBlendingHSV(const vec4 colorBG, const vec4 colorFG, const int blendMode)\n{\nvec4 hsvBG, hsvFG;\nvec4 outColor;\nif (blendMode == COMP_BLEND_HUE) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvFG[0], hsvBG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_SATURATION) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvBG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_COLOR) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvFG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_VALUE) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvBG[0], hsvBG[1], hsvFG[2], 1.0), outColor);\n}\nreturn outColor;\n}\nvoid node_composite_layer(const int blendMode, const float opacity, \nconst vec4 colorBG, const vec4 colorFG, const vec4 mask,\nout vec4 outColor)\n{\nfloat fac = saturate(opacity * average(mask.rgb));\nif (blendMode < COMP_BLEND_HUE)\noutColor = calcBlending(colorBG, colorFG, blendMode);\nelse\noutColor = calcBlendingHSV(colorBG, colorFG, blendMode);\noutColor = mix(colorBG, outColor, fac);\n}",node_falloff_mx_frag:"void node_falloff(vec3 viewPos, float IOR,\nconst vec4 color1, const vec4 color2, vec3 normal, out vec4 color)\n{\nfloat fac;\n\nvec3 dir = normalize(viewPos);\nfloat eta = max(IOR, 0.00001);\nfac = fresnelReflection(dir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\ncolor = mix(color1, color2, fac);\n}",node_gradient_ramp_mx_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(\nsampler2D gradientData, int gradientType, vec2 uvIn, vec3 geometryNormal,\nvec3 viewPos, int mapping, int axis, ivec2 clampToEdgeNoExtend,\nvec4 sourceMap, float uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec4 outCol)\n{\nvec3 coordsIn;\nif (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n} else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\ncoordsIn = vec3(0.0);\n} else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\ncoordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-viewPos, 1.0)).xyz);\n} else {\ncoordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n}\nif (axis == AXIS_XY)\ncoordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\nelse if (axis == AXIS_YZ)\ncoordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\nelse if (axis == AXIS_ZX)\ncoordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nfloat coord = uvIn.x;\nuvIn = coordsOut.xy;\nif ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n(clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\noutCol = vec4(0.0, 0.0, 0.0, 1.0);\nreturn;\n}\nuvIn = fract(uvIn);\nif (gradientType == GRAD_TYPE_4_CORNER) {\ncoord = pow(uvIn.x, 2.0);\n} else if (gradientType == GRAD_TYPE_BOX) {\nvec2 boxUv = abs(uvIn - vec2(0.5)) * 2.0;\ncoord = max(boxUv.x, boxUv.y);\n} else if (gradientType == GRAD_TYPE_DIAGONAL) {\ncoord = abs(uvIn.x - uvIn.y) * sqrt(2.0);\n} else if (gradientType == GRAD_TYPE_LIGHTING) {\nIncidentLight directLight;\nGeometricContext geometry;\ngeometry.position = -viewPos;\nvec3 irr = vec3(0.0);\n#if (NUM_POINT_LIGHTS > 0)\n#pragma unroll_loop\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\ngetPointDirectLightIrradiance(pointLights[i], geometry, directLight);\nfloat dotNL = saturate(dot(geometryNormal, directLight.direction));\nirr += dotNL * directLight.color;\n}\n#endif\n#if (NUM_SPOT_LIGHTS > 0)\n#pragma unroll_loop\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\ngetSpotDirectLightIrradiance(spotLights[i], geometry, directLight);\nfloat dotNL = saturate(dot(geometryNormal, directLight.direction));\nirr += dotNL * directLight.color;\n}\n#endif\n#if (NUM_DIR_LIGHTS > 0)\n#pragma unroll_loop\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ngetDirectionalDirectLightIrradiance(directionalLights[i], geometry, directLight);\nfloat dotNL = saturate(dot(geometryNormal, directLight.direction));\nirr += dotNL * directLight.color;\n}\n#endif\n#if defined(PHYSICALLY_CORRECT_LIGHTS)\nirr /= PI;\n#endif\nvec3 ambIrr = getAmbientLightIrradiance(ambientLightColor);\n#if !defined(PHYSICALLY_CORRECT_LIGHTS)\nambIrr /= PI;\n#endif\nirr += ambIrr;\ncoord = (irr.x + irr.y + irr.z) / 3.0;\n} else if (gradientType == GRAD_TYPE_LINEAR) {\ncoord = uvIn.x;\n} else if (gradientType == GRAD_TYPE_MAPPED) {\ncoord = (sourceMap.x + sourceMap.y + sourceMap.z) / 3.0;\n} else if (gradientType == GRAD_TYPE_NORMAL) {\nfloat angle = acos(clamp(dot(geometryNormal, normalize(viewPos)), -1.0, 1.0));\nfloat k = 100.0;\ncoord = 1.0 - sin(pow2(k) - k * sqrt(pow2(k) - pow2(angle)));\n} else if (gradientType == GRAD_TYPE_PONG) {\nfloat y = min(uvIn.y, uvIn.x);\nfloat x = max(uvIn.y, uvIn.x);\ncoord = y / x;\n} else if (gradientType == GRAD_TYPE_RADIAL) {\ncoord = length(uvIn - vec2(0.5)) * 2.0;\n} else if (gradientType == GRAD_TYPE_SPIRAL) {\nvec2 uvSpiral = mat2(0.0, 1.0, -1.0, 0.0) * (uvIn - vec2(0.5));\ncoord = atan(uvSpiral.y, uvSpiral.x) / PI2 + 0.5;\n} else if (gradientType == GRAD_TYPE_SWEEP) {\ncoord = atan(uvIn.x, uvIn.y) / PI_HALF;\n} else if (gradientType == GRAD_TYPE_TARTAN) {\nvec2 uvTartan = abs(uvIn - vec2(0.5));\ncoord = 1.0 - min(uvTartan.x, uvTartan.y) * 2.0;\n}\noutCol = texture2D(gradientData, vec2(coord, 0.0));\n}",node_map_mx_frag:"\nvoid node_map(const vec4 colorIn, out vec4 color)\n{\ncolor = colorIn;\n}",node_mask_mx_frag:"void node_mask(const int maskInverted, \nconst vec4 color, vec4 mask,\nout vec4 outColor)\n{\nmask = (maskInverted == 1) ? vec4(vec3(1.0) - mask.rgb, mask.a) : mask;\noutColor = color * mask;\n}",node_material_mx_frag:"\nvoid node_material(\nfloat reflectionRatio, const float refractionRatio,\nconst int selfIllumColorOn,\nconst vec4 ambientColor, const vec4 diffuseColor, const vec4 specularColor,\nconst float glossiness, const float specularLevel, const vec4 selfIllum,\nconst float opacity, const vec4 filterColor, const vec3 normal,\nconst vec4 reflection, const vec4 refraction, const float displacement,\nout vec4 outColor)\n{\nvec3 diffuse, specular;\nNodeMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specularColor.rgb;\nmaterial.diffuseIntensity = 1.0;\nmaterial.specularHardness = 4.0 * exp2(glossiness * 10.0);\nmaterial.specularIntensity = specularLevel;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#include \n#include \n#include \ndiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nif (selfIllumColorOn == 1) {\ndiffuse += selfIllum.rgb;\n} else {\ndiffuse = mix(diffuse, material.diffuseColor, selfIllum[0]);\n}\nspecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\nfloat specularStrength = maxFromRGB(specular);\noutColor = vec4(saturate(diffuse + specular), 1.0);\nfloat alpha = opacity - saturate(maxFromRGB(specular)) * (opacity - 1.0);\noutColor += reflection * specularColor * reflectionRatio;\noutColor += refraction * refractionRatio;\nalpha += saturate(maxFromRGB(reflection.rgb) * maxFromRGB(specularColor.rgb)) * reflectionRatio;\nalpha += saturate(maxFromRGB(refraction.rgb)) * refractionRatio;\noutColor.a = alpha;\n}",node_mix_mx_frag:"void node_mix(const vec4 color1, const vec4 color2, const float amount, out vec4 color)\n{\ncolor = mix(color1, color2, clamp(amount, 0.0, 1.0));\n}",node_normal_bump_mx_frag:"void node_normal_bump(const vec4 tangent, const vec3 normal, ivec2 flip,\nvec4 normalColor, vec3 additionalBump, float normalMult, float addBumpMult,\nout vec3 normalOut)\n{\nif (flip[0] == 1)\nnormalColor.x = 1.0 - normalColor.x;\nif (flip[1] == 0)\nnormalColor.y = 1.0 - normalColor.y;\nvec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize(modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz, tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\nnormalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\nnormalOut = mix(normal, normalOut, normalMult);\nadditionalBump = mix(normal, additionalBump, addBumpMult);\nnormalOut = normalize(normalOut + additionalBump);\n}",node_output_map_mx_frag:"vec4 processOutputColor(vec4 color, const bool invert, const bool clampColor, const bool alphaFromRGB,\nconst float rgbLevel, const float rgbOffset, const float outputAmount)\n{\nvec3 color3 = color.rgb;\ncolor3 = clampColor ? saturate(color3) : color3;\ncolor3 = color3 * rgbLevel + vec3(rgbOffset);\ncolor3 = invert ? (vec3(1.0) - color3) : color3;\ncolor = outputAmount * vec4(color3, color.a);\ncolor.a = alphaFromRGB ? average(color.rgb) : color.a;\nreturn color;\n}\nvoid node_output_map(\nconst bool invert, const bool clampColor, const bool alphaFromRGB,\nconst vec4 color, const float rgbLevel, const float rgbOffset,\nconst float outputAmount, const float bumpAmount,\nout vec4 outColor)\n{\noutColor = processOutputColor(color, invert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}\nvoid node_output_map(\nconst bool invert, const bool clampColor, const bool alphaFromRGB, sampler2D colormap,\nvec4 color, const float rgbLevel, const float rgbOffset,\nconst float outputAmount, const float bumpAmount,\nout vec4 outColor)\n{\nfloat r = texture2D(colormap, vec2(color.r, 0.0)).r;\nfloat g = texture2D(colormap, vec2(color.g, 0.0)).g;\nfloat b = texture2D(colormap, vec2(color.b, 0.0)).b;\noutColor = processOutputColor(vec4(r, g, b, color.a),\ninvert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}",node_output_mx_frag:"void node_output(vec4 color, out vec4 outgoingLight)\n{\noutgoingLight = color;\n}",node_physical_mx_frag:"#define DEFAULT_REFLECTION_EDGE 1.0\n#define DEFAULT_REFLECTION_SLOPE 5.0\nvoid node_physical(\nvec3 geometryNormal, const float emitLuminance, const int useCustomReflCurve,\nconst float reflFacing, const float reflEdge, const float reflSlope,\nconst bool roughnessInv, const bool transRoughnessLock, const bool transRoughnessInv,\nconst bool thinWalled,\nconst float baseWeight, const vec4 baseColor, const float reflectivity,\nconst vec4 reflColor, const float roughness, const float metalness,\nconst float diffRoughness, const float anisotropy, const float anisoangle,\nconst float transparency, const vec4 transColor, const float transRoughness,\nconst float ior, const float scattering, const vec4 sssColor,\nconst float sssScale, const float emission, const vec4 emitColor,\nconst float coating, const vec4 coatColor, const float coatRoughness,\nconst vec3 normal, const vec3 clearcoatNormal, const float displacement,\nconst float cutout,\nout vec4 outColor)\n{\nNodeMaterial material;\nvec3 baseColorWeighted = baseWeight * baseColor.rgb;\nmaterial.diffuseColor = baseColorWeighted * (1.0 - transparency);\n#ifdef CLEARCOAT\nmaterial.clearcoat = saturate(coating);\nmaterial.clearcoatRoughness = clamp(coatRoughness, 0.0, 1.0);\n#endif\nfloat facing, edge, slope;\nif (useCustomReflCurve == 1) {\nfacing = reflFacing;\nedge = reflEdge;\nslope = reflSlope;\n} else {\nfacing = pow2((1.0 - ior) / (1.0 + ior));\nedge = DEFAULT_REFLECTION_EDGE;\nslope = DEFAULT_REFLECTION_SLOPE;\n}\nfloat cosTheta = saturate(dot(normal, normalize(vViewPosition)));\nfloat fresnelRefl = (facing + (edge - facing) * pow(1.0 - cosTheta, slope))\n* saturate(reflectivity + metalness);\nfloat kd = 1.0 - (metalness * (1.0 - fresnelRefl) + fresnelRefl);\nmaterial.specularColor = mix(metalness * baseColorWeighted, reflColor.rgb, fresnelRefl);\nmaterial.diffuseColor *= kd;\nmaterial.specularRoughness = clamp(roughnessInv ? (1.0 - roughness) : roughness, 0.0, 1.0);\nmaterial.refractionColor = pow(transparency * (1.0 - metalness) * transColor.rgb, vec3(2.0));\nmaterial.refractionIOR = ior;\nfloat tRough;\nif (transRoughnessLock) {\ntRough = roughnessInv ? 1.0 - roughness : roughness;\n} else {\ntRough = transRoughnessInv ? 1.0 - transRoughness : transRoughness;\n}\nmaterial.refractionRoughness = pow2(tRough);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.specularRoughness = calcCubeUVAdjustedRoughness(\nmaterial.specularRoughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#ifdef CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define USE_REFRACTED_LIGHT\nvec3 refractedLight = vec3(0.0);\n#include \n#include \n#include \n#undef USE_REFRACTED_LIGHT\nvec3 totalEmissiveRadiance = emitLuminance / LUMENS_PER_WATT * emission * emitColor.rgb;\nvec3 specular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\nvec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nspecular + totalEmissiveRadiance;\nfloat alpha = 1.0;\nif (thinWalled) {\nalpha = 1.0 - saturate(transparency) + maxFromRGB(specular) * saturate(transparency);\n} else {\noutColor3 += refractedLight;\n}\noutColor = vec4(outColor3, saturate(alpha));\n}",node_phy_sun_sky_env_mx_frag:"vec3 perezSky(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\nvec3 radiance, vec3 sunDirection, vec3 direction)\n{\nfloat cosGamma = clamp(dot(direction, sunDirection), -1.0, 1.0);\nfloat cosTheta = clamp(direction.y, 0.0, 1.0);\nvec3 radInternal = (1.0 + paramA * exp(paramB / cosTheta)) * (\n1.0 + paramC * exp(paramD * acos(cosGamma))\n+ paramE * pow(cosGamma, 2.0)\n);\nfloat ciex = radInternal.y * radiance.y;\nfloat ciey = radInternal.z * radiance.z;\nfloat cieY = clamp(radInternal.x * radiance.x, 0.0, 1000000.0);\nvec3 XYZ = xyY_to_XYZ(ciex, ciey, cieY);\nreturn 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{\nconst int horizSamples = GROUND_SKY_SAMPLES;\nconst int vertSamples = GROUND_SKY_SAMPLES / 2;\nvec3 result = vec3(0.0);\nfor (int horizSampleIdx = 0; horizSampleIdx < horizSamples; horizSampleIdx++) {\nfloat horizSample = float(horizSampleIdx) / float(horizSamples);\nfloat horizAngle = PI2 * horizSample;\nfor (int vertSampleIdx = 0; vertSampleIdx < vertSamples; vertSampleIdx++) {\nfloat vertSample = float(vertSampleIdx) / float(vertSamples);\nfloat y = 1.0 - vertSample;\nfloat x = sqrt(1.0 - y*y) * cos(horizAngle);\nfloat z = -sqrt(1.0 - y*y) * sin(horizAngle);\nvec3 direction = vec3(x, y, z);\nvec3 sampleColor = perezSky(paramA, paramB, paramC, paramD, paramE,\nradiance, sunDirection, direction);\n\nresult += direction.y * sampleColor;\n}\n}\nresult /= float(horizSamples * vertSamples);\nresult += (sunIlluminance * sunDirection.y) / PI;\nreturn result;\n}\nvoid node_phy_sun_sky_env(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\nvec3 radiance, vec3 sunDirection, vec3 sunIlluminance, vec3 sunLuminance, \nfloat globalIntensity, vec4 groundColor,\nout vec4 outColor) \n{\nvec3 dir = vWorldPosition;\nif (length(dir) == 0.0) {\ndir = vec3(0.0, 0.0, -1.0);\n} else {\ndir = normalize(dir);\n}\nif (dir.y < 0.0) {\noutColor = groundColor * vec4(groundSky(paramA, paramB, paramC, paramD, paramE, radiance, sunDirection, sunIlluminance), 1.0);\n} else {\noutColor = vec4(perezSky(paramA, paramB, paramC, paramD, paramE,\nradiance, sunDirection, dir), 1.0);\n}\noutColor = globalIntensity * outColor;\n}",node_reflect_refract_mx_frag:"void node_reflect_refract(sampler2D envMap,\nint reflectMode, const float IOR, const int encoding,\nvec3 normal, out vec4 color)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec;\nif (reflectMode == MAX_ENV_COORDS_REFLECT)\nreflectVec = reflect(cameraToVertex, worldNormal);\nelse {\nfloat refrRatio = 1.0 / IOR;\nreflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n}\nreflectVec = normalize(reflectVec);\ncolor = sampleEquirectangular(envMap, reflectVec, mat3(1.0), encoding);\n}",node_reflect_refract_color_mx_frag:"void node_reflect_refract_color(const vec4 colorIn, out vec4 color)\n{\ncolor = vec4(colorIn);\n}",node_rgb_multiply_mx_frag:"void node_rgb_multiply(const vec4 color1, const vec4 color2, out vec4 color)\n{\ncolor = color1 * color2;\n}",node_rgb_tint_mx_frag:"void node_rgb_tint(const vec4 color, const vec4 red, const vec4 green, const vec4 blue,\nout vec4 outColor)\n{\nmat3 tintMatrix = mat3(red.rgb, green.rgb, blue.rgb);\noutColor = vec4(tintMatrix * color.rgb, color.a);\n}",node_rgb_mx_frag:"uniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_shellac_mx_frag:"void node_shellac(const vec4 color1, const vec4 color2, const float amount,\nout vec4 color)\n{\ncolor = mix(color1, color2, clamp(amount, 0.0, 1.0));\n}",node_tex_environment_mx_frag:"\nvoid node_tex_environment(sampler2D tex, const int encoding, vec3 vector, out vec4 outColor) {\n\nvec3 direction = swizzleUpY(vector);\nif (length(direction) == 0.0) {\ndirection = vec3(0.0, 1.0, 0.0);\n} else {\ndirection = normalize(direction);\n}\nvec2 uv;\nuv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nuv.x = atan(direction.x, direction.z) * RECIPROCAL_PI2 + 0.5;\nuv.y *= -1.0;\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (direction.x) / seamWidth) *\nclamp (1.0 - direction.z / seamWidth, 0.0, 1.0);\noutColor = texture2D(tex, uv, seamBiasFactor * seam);\noutColor = nodeTexelToLinear(outColor, encoding);\n}",node_value_mx_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_vertex_color_mx_frag:"void node_vertex_color(vec3 color, out vec4 outColor)\n{\noutColor = vec4(color, 1.0);\n}",node_ai_skydome_light_my_frag:"void node_ai_skydome_light(sampler2D envMap, int encoding, vec3 normal,\nfloat intensity,\nout vec4 outgoingLight)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec = normalize(cameraToVertex);\nmat3 uvTransform = mat3(1.0);\nvec4 color = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\n#if LIGHT_PATH_IS_CAM_RAY\nintensity = 1.0;\n#endif\noutgoingLight = color * intensity;\n}",node_blend_colors_my_frag:"\nvoid node_blend_colors(float blender, vec4 color1, vec4 color2, out vec4 outColor)\n{\nblender = clamp(blender, 0.0, 1.0);\noutColor = mix(color1, color2, 1.0 - blender);\n}",node_light_path_my_frag:"void node_light_path(out float isCameraRay)\n{\n#if LIGHT_PATH_IS_CAM_RAY\nisCameraRay = 1.0;\n#else\nisCameraRay = 0.0;\n#endif\n}",node_output_my_frag:"void node_output(vec4 rgb, out vec4 outgoingLight)\n{\noutgoingLight = rgb;\n}",pp_plane_vert:"varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_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) {\nfloat mirrorFactor = 1.2 - factor;\nreturn mix(factor, mirrorFactor, bloomRadius);\n}\nvoid main() {\ngl_FragColor = bloomStrength * (\nlerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\nlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\nlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\nlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\nlerpBloomFactor(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() {\nvec4 texel = texture2D(tDiffuse, vUv);\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat v = dot(texel.xyz, luma);\nvec4 outputColor = vec4(defaultColor.rgb, defaultOpacity);\nfloat alpha = smoothstep(luminosityThreshold, luminosityThreshold + smoothWidth, v);\ngl_FragColor = mix(outputColor, texel, alpha);\ngl_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) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma)) / sigma;\n}\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nfloat fSigma = float(SIGMA);\nfloat weightSum = gaussianPdf(0.0, fSigma);\nvec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\nfor (int i = 1; i < KERNEL_RADIUS; i++) {\nfloat x = float(i);\nfloat w = gaussianPdf(x, fSigma);\nvec2 uvOffset = direction * invSize * x;\nvec3 sample1 = texture2D(colorTexture, vUv + uvOffset).rgb;\nvec3 sample2 = texture2D(colorTexture, vUv - uvOffset).rgb;\ndiffuseSum += (sample1 + sample2) * w;\nweightSum += 2.0 * w;\n}\ngl_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) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma;\n}\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nfloat weightSum = gaussianPdf(0.0, kernelRadius);\n#if LOG_SPACE == 1\nvec3 origDiffuse = texture2D(colorTexture, vUv).rgb;\nvec3 diffuseSum = vec3(weightSum);\n#else\nvec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\n#endif\nvec2 delta = direction * invSize * kernelRadius/float(MAX_SAMPLE_RADIUS);\nvec2 uvOffset = delta;\n#if OCTAHEDRAL_MAP == 1\nvec3 cubeDir = normalize(octUVToCubeVec(vUv, invSize));\nvec3 dirX = normalize(abs(cubeDir.y) < 0.99999 ? vec3(cubeDir.z, 0.0, -cubeDir.x)\n: vec3(0.0, -cubeDir.z, cubeDir.y));\nvec3 dirY = cross(cubeDir, dirX);\n#endif\n#pragma unroll_loop\nfor (int i = 1; i <= MAX_SAMPLE_RADIUS; i++) {\nfloat w = gaussianPdf(uvOffset.x, kernelRadius);\n#if OCTAHEDRAL_MAP == 1\nvec3 cubeOffset = uvOffset.x * dirX + uvOffset.y * dirY;\nvec2 uv1 = cubeVecToOctUV(cubeDir + cubeOffset, invSize);\nvec2 uv2 = cubeVecToOctUV(cubeDir - cubeOffset, invSize);\n#else\nvec2 uv1 = vUv + uvOffset;\nvec2 uv2 = vUv - uvOffset;\n#endif\nvec3 sample1 = texture2D(colorTexture, uv1).rgb;\nvec3 sample2 = texture2D(colorTexture, uv2).rgb;\n#if LOG_SPACE == 1\ndiffuseSum += (\nclamp(exp(sample1 - origDiffuse), 0.0, 1e38) +\nclamp(exp(sample2 - origDiffuse), 0.0, 1e38)\n) * w;\n#else\ndiffuseSum += ((sample1 + sample2) * w);\n#endif\nweightSum += 2.0 * w;\nuvOffset += delta;\n}\n#if LOG_SPACE == 1\ngl_FragColor = vec4(origDiffuse + log(diffuseSum/weightSum), 1.0);\n#else\ngl_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() {\nvec4 texel = texture2D(tDiffuse, vUv);\ntexel.rgb += brightness;\nif (contrast > 0.0)\ntexel.rgb = (texel.rgb - 0.5) / (1.0 - contrast) + 0.5;\nelse\ntexel.rgb = (texel.rgb - 0.5) * (1.0 + contrast) + 0.5;\ngl_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\nreturn unpackRGBAToDepth(texture2D(tDepth, screenPosition));\n#else\nreturn texture2D(tDepth, screenPosition).x;\n#endif\n}\nfloat getViewZ(const in float depth) {\n#if PERSPECTIVE_CAMERA == 1\nreturn perspectiveDepthToViewZ(depth, nearClip, farClip);\n#else\nreturn orthoDepthToViewZ(depth, nearClip, farClip);\n#endif\n}\nvec4 blurSample(vec2 uvOffset, vec4 centerCol, float viewZCenter) {\nfloat viewZ = -getViewZ(getDepth(vUv + uvOffset));\nfloat blurFactor = (viewZ >= viewZCenter) ? 1.0 : \nmin(depthLeakThreshold * abs((focus - viewZ) / aperture), 1.0);\nreturn mix(centerCol, texture2D(tColor, vUv + uvOffset), blurFactor);\n}\nvoid main() {\nvec2 aspectcorrect = vec2(1.0, aspect);\nfloat viewZ = -getViewZ(getDepth(vUv));\nfloat factor = abs(focus - viewZ);\n\nfloat dofblur = maxblur * min(factor / aperture, 1.0);\nfloat dofblur9 = dofblur * 0.9;\nfloat dofblur7 = dofblur * 0.7;\nfloat dofblur4 = dofblur * 0.4;\nvec4 centerCol = texture2D(tColor, vUv);\nvec4 col = centerCol;\ncol += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.15, 0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, 0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.40, 0.0 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, -0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, -0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, 0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, 0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, -0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.15, -0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\n\ncol += blurSample((vec2( 0.15, 0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, 0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, -0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, -0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, 0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, 0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, -0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2( 0.15, -0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\n\ncol += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.40, 0.0 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\n\ncol += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.4, 0.0 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ngl_FragColor = col / 41.0;\ngl_FragColor.a = centerCol.a;\n}",pp_copy_frag:"uniform sampler2D tDiffuse;\nuniform float opacity;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = (texture2D(tDiffuse, vUv));\n#if MAP_TEXELS == 1\ntexel = mapTexelToLinear(texel);\n#endif\ngl_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() {\ngl_FragColor = textureCube(tCube, octUVToCubeVec(gl_FragCoord.xy * texelSize,\ntexelSize));\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\nstruct 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\nstruct 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)\nFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }\n#else\nFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }\n#endif\n#if (FXAA_PC == 1)\nFxaaFloat4 FxaaPixelShader(\nFxaaFloat2 pos,\nFxaaFloat4 fxaaConsolePosPos,\nFxaaTex tex,\nFxaaTex fxaaConsole360TexExpBiasNegOne,\nFxaaTex fxaaConsole360TexExpBiasNegTwo,\nFxaaFloat2 fxaaQualityRcpFrame,\nFxaaFloat4 fxaaConsoleRcpFrameOpt,\nFxaaFloat4 fxaaConsoleRcpFrameOpt2,\nFxaaFloat4 fxaaConsole360RcpFrameOpt2,\nFxaaFloat fxaaQualitySubpix,\nFxaaFloat fxaaQualityEdgeThreshold,\nFxaaFloat fxaaQualityEdgeThresholdMin,\nFxaaFloat fxaaConsoleEdgeSharpness,\nFxaaFloat fxaaConsoleEdgeThreshold,\nFxaaFloat fxaaConsoleEdgeThresholdMin,\nFxaaFloat4 fxaaConsole360ConstDir\n) {\nFxaaFloat2 posM;\nposM.x = pos.x;\nposM.y = pos.y;\n#if (FXAA_GATHER4_ALPHA == 1)\n#if (FXAA_DISCARD == 0)\nFxaaFloat4 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)\nFxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);\nFxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));\n#else\nFxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);\nFxaaFloat4 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\nFxaaFloat4 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)\nFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(0.0, 1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0, 0.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(0.0,-1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));\n#else\nFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(0, 1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, 0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(0,-1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n#endif\n#endif\nFxaaFloat maxSM = max(lumaS, lumaM);\nFxaaFloat minSM = min(lumaS, lumaM);\nFxaaFloat maxESM = max(lumaE, maxSM);\nFxaaFloat minESM = min(lumaE, minSM);\nFxaaFloat maxWN = max(lumaN, lumaW);\nFxaaFloat minWN = min(lumaN, lumaW);\nFxaaFloat rangeMax = max(maxWN, maxESM);\nFxaaFloat rangeMin = min(minWN, minESM);\nFxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\nFxaaFloat range = rangeMax - rangeMin;\nFxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\nFxaaBool earlyExit = range < rangeMaxClamped;\nif(earlyExit)\n#if (FXAA_DISCARD == 1)\nreturn rgbyM;\n#else\nreturn rgbyM;\n#endif\n#if (FXAA_GATHER4_ALPHA == 0)\n#if (FXAA_GLSL_100 == 1)\nFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0, 1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0,-1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));\n#else\nFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, 1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1,-1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n#endif\n#else\nFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n#endif\nFxaaFloat lumaNS = lumaN + lumaS;\nFxaaFloat lumaWE = lumaW + lumaE;\nFxaaFloat subpixRcpRange = 1.0/range;\nFxaaFloat subpixNSWE = lumaNS + lumaWE;\nFxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\nFxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\nFxaaFloat lumaNESE = lumaNE + lumaSE;\nFxaaFloat lumaNWNE = lumaNW + lumaNE;\nFxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\nFxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\nFxaaFloat lumaNWSW = lumaNW + lumaSW;\nFxaaFloat lumaSWSE = lumaSW + lumaSE;\nFxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\nFxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\nFxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\nFxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\nFxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\nFxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\nFxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\nFxaaFloat lengthSign = fxaaQualityRcpFrame.x;\nFxaaBool horzSpan = edgeHorz >= edgeVert;\nFxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\nif(!horzSpan) lumaN = lumaW;\nif(!horzSpan) lumaS = lumaE;\nif(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\nFxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\nFxaaFloat gradientN = lumaN - lumaM;\nFxaaFloat gradientS = lumaS - lumaM;\nFxaaFloat lumaNN = lumaN + lumaM;\nFxaaFloat lumaSS = lumaS + lumaM;\nFxaaBool pairN = abs(gradientN) >= abs(gradientS);\nFxaaFloat gradient = max(abs(gradientN), abs(gradientS));\nif(pairN) lengthSign = -lengthSign;\nFxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\nFxaaFloat2 posB;\nposB.x = posM.x;\nposB.y = posM.y;\nFxaaFloat2 offNP;\noffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\noffNP.y = (horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\nif(!horzSpan) posB.x += lengthSign * 0.5;\nif(horzSpan) posB.y += lengthSign * 0.5;\nFxaaFloat2 posN;\nposN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\nposN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\nFxaaFloat2 posP;\nposP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\nposP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\nFxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\nFxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));\nFxaaFloat subpixE = subpixC * subpixC;\nFxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));\nif(!pairN) lumaNN = lumaSS;\nFxaaFloat gradientScaled = gradient * 1.0/4.0;\nFxaaFloat lumaMM = lumaM - lumaNN * 0.5;\nFxaaFloat subpixF = subpixD * subpixE;\nFxaaBool lumaMLTZero = lumaMM < 0.0;\nlumaEndN -= lumaNN * 0.5;\nlumaEndP -= lumaNN * 0.5;\nFxaaBool doneN = abs(lumaEndN) >= gradientScaled;\nFxaaBool doneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\nFxaaBool doneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n#if (FXAA_QUALITY_PS > 3)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n#if (FXAA_QUALITY_PS > 4)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n#if (FXAA_QUALITY_PS > 5)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n#if (FXAA_QUALITY_PS > 6)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n#if (FXAA_QUALITY_PS > 7)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n#if (FXAA_QUALITY_PS > 8)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n#if (FXAA_QUALITY_PS > 9)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n#if (FXAA_QUALITY_PS > 10)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n#if (FXAA_QUALITY_PS > 11)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n#if (FXAA_QUALITY_PS > 12)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\nif(!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}\nFxaaFloat dstN = posM.x - posN.x;\nFxaaFloat dstP = posP.x - posM.x;\nif(!horzSpan) dstN = posM.y - posN.y;\nif(!horzSpan) dstP = posP.y - posM.y;\nFxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\nFxaaFloat spanLength = (dstP + dstN);\nFxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\nFxaaFloat spanLengthRcp = 1.0/spanLength;\nFxaaBool directionN = dstN < dstP;\nFxaaFloat dst = min(dstN, dstP);\nFxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\nFxaaFloat subpixG = subpixF * subpixF;\nFxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\nFxaaFloat subpixH = subpixG * fxaaQualitySubpix;\nFxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\nFxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\nif(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\nif(horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n#if (FXAA_DISCARD == 1)\nreturn FxaaTexTop(tex, posM);\n#else\nreturn FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);\n#endif\n}\n#endif\nvoid main() {\ngl_FragColor = FxaaPixelShader(\nvUv,\nvec4(0.0),\ntDiffuse,\ntDiffuse,\ntDiffuse,\nresolution,\nvec4(0.0),\nvec4(0.0),\nvec4(0.0),\n0.75,\n0.166,\n0.0833,\n0.0,\n0.0,\n0.0,\nvec4(0.0)\n);\n\n}",pp_grayscale_frag:"uniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\nfloat bw = texel.r * 0.35 + texel.g * 0.45 + texel.b * 0.2;\ntexel = vec4(bw, bw, bw, texel.a);\ngl_FragColor = texel;\n}",pp_outline_edge_frag:"varying vec2 vUv;\nuniform sampler2D maskTexture;\nuniform vec2 texSize;\nuniform vec4 visibleEdgeColor;\nuniform vec4 hiddenEdgeColor;\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\nvec4 c1 = texture2D(maskTexture, vUv + uvOffset.xy);\nvec4 c2 = texture2D(maskTexture, vUv - uvOffset.xy);\nvec4 c3 = texture2D(maskTexture, vUv + uvOffset.yw);\nvec4 c4 = texture2D(maskTexture, vUv - uvOffset.yw);\nfloat diff1 = (c1.r - c2.r) * 0.5;\nfloat diff2 = (c3.r - c4.r) * 0.5;\nfloat d = length(vec2(diff1, diff2));\nfloat a1 = min(c1.g, c2.g);\nfloat a2 = min(c3.g, c4.g);\nfloat visibilityFactor = min(a1, a2);\nvec4 edgeColor = (1.0 - visibilityFactor > 0.001) ? visibleEdgeColor : hiddenEdgeColor;\ngl_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) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma;\n}\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nfloat weightSum = gaussianPdf(0.0, kernelRadius);\nvec4 diffuseSum = texture2D(colorTexture, vUv);\n#if defined(LOG_SPACE)\ndiffuseSum = exp(diffuseSum);\n#endif\ndiffuseSum *= weightSum;\nvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\nvec2 uvOffset = delta;\nfor (int i = 1; i <= MAX_RADIUS; i++) {\nfloat w = gaussianPdf(uvOffset.x, kernelRadius);\nvec4 sample1 = texture2D(colorTexture, vUv + uvOffset);\nvec4 sample2 = texture2D(colorTexture, vUv - uvOffset);\n#if defined(LOG_SPACE)\nsample1 = exp(sample1);\nsample2 = exp(sample2);\n#endif\ndiffuseSum += ((sample1 + sample2) * w);\nweightSum += (2.0 * w);\nuvOffset += delta;\n}\nvec4 finalCol = diffuseSum / weightSum;\n#if defined(LOG_SPACE)\nfinalCol = log(finalCol);\n#endif\ngl_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() {\nvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\nvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\nvec4 maskColor = texture2D(maskTexture, vUv);\nvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\nfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\nvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\nvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\nif (usePatternTexture)\nfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\nfloat maxChannel = max(finalColor.r, max(finalColor.g, finalColor.b));\nif (maxChannel != 0.0) {\nfinalColor.rgb /= maxChannel;\n}\ngl_FragColor = finalColor;\n}",pp_ssao_blur_frag:"uniform sampler2D tDiffuse;\nuniform vec2 resolution;\nvarying vec2 vUv;\nvoid main() {\nvec2 texelSize = (1.0 / resolution);\nfloat result = 0.0;\nfor (int i = - 2; i <= 2; i++) {\nfor (int j = - 2; j <= 2; j ++) {\nvec2 offset = (vec2(float(i), float(j))) * texelSize;\nresult += texture2D(tDiffuse, vUv + offset).r;\n}\n}\ngl_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\nfloat fragCoordZ = texture2D(tDepth, screenPosition).x;\nfloat viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\nreturn viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n#else\nreturn texture2D(depthSampler, coord).x;\n#endif\n}\nvoid main() {\nfloat depth = getLinearDepth(vUv);\ngl_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) {\nreturn texture2D(tDepth, screenPosition).x;\n}\nfloat getLinearDepth(const in vec2 screenPosition) {\n#if PERSPECTIVE_CAMERA == 1\nfloat fragCoordZ = texture2D(tDepth, screenPosition).x;\nfloat viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\nreturn viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n#else\nreturn texture2D(depthSampler, coord).x;\n#endif\n}\nfloat getViewZ(const in float depth) {\n#if PERSPECTIVE_CAMERA == 1\nreturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n#else\nreturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n#endif\n}\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ) {\nfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\nvec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\nclipPosition *= clipW;\nreturn (cameraInverseProjectionMatrix * clipPosition).xyz;\n}\nvec3 getViewNormal(const in vec2 screenPosition) {\nreturn unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n}\nvoid main() {\nfloat depth = getDepth(vUv);\nfloat viewZ = getViewZ(depth);\nvec3 viewPosition = getViewPosition(vUv, depth, viewZ);\nvec3 viewNormal = getViewNormal(vUv);\nvec2 noiseScale = vec2(resolution.x / 4.0, resolution.y / 4.0);\nvec3 random = texture2D(tNoise, vUv * noiseScale).xyz;\nvec3 tangent = normalize(random - viewNormal * dot(random, viewNormal));\nvec3 bitangent = cross(viewNormal, tangent);\nmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\nfloat occlusion = 0.0;\nfor (int i = 0; i < KERNEL_SIZE; i++) {\nvec3 sampleVector = kernelMatrix * kernel[i];\nvec3 samplePoint = viewPosition + (sampleVector * kernelRadius);\nvec4 samplePointNDC = cameraProjectionMatrix * vec4(samplePoint, 1.0);\nsamplePointNDC /= samplePointNDC.w;\nvec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5;\nfloat realDepth = getLinearDepth(samplePointUv);\nfloat sampleDepth = viewZToOrthographicDepth(samplePoint.z, cameraNear, cameraFar);\nfloat delta = sampleDepth - realDepth;\nif (delta > minDistance && delta < maxDistance) {\nocclusion += 1.0;\n}\n}\nocclusion = clamp(occlusion / float(KERNEL_SIZE), 0.0, 1.0);\ngl_FragColor = vec4(vec3(1.0 - occlusion), 1.0);\n}",pp_tonemap_frag:"uniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\nfloat alpha = clamp(texel.a, 0.0, 1.0);\ngl_FragColor = texel;\ngl_FragColor.rgb /= alpha;\n#include \ngl_FragColor = LinearTosRGB(gl_FragColor);\ngl_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() {\nvec4 c = vec4(color, opacity);\nif (useMap == 1.0) {\nc *= texture2D(map, vUV * repeat);\n}\nif (useAlphaMap == 1.0) {\nc.a *= texture2D(alphaMap, vUV * repeat).a;\n}\nif (c.a < alphaTest) {\ndiscard;\n}\ngl_FragColor = c;\ngl_FragColor.a *= step(vCounters, visibility);\ngl_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) {\nvec2 res = i.xy / i.w;\nres.x *= aspect;\nreturn res;\n}\nbool posEqual(vec2 pos0, vec2 pos1) {\nreturn length(pos0 - pos1) < EQ_EPS;\n}\nvoid main() {\nfloat aspect = resolution.x / resolution.y;\nvCounters = counters;\nvUV = uv;\nmat4 m = projectionMatrix * modelViewMatrix;\nvec4 finalPosition = m * vec4(position, 1.0);\nvec4 prevPos = m * vec4(previous, 1.0);\nvec4 nextPos = m * vec4(next, 1.0);\nvec2 currentP = fix(finalPosition, aspect);\nvec2 prevP = fix(prevPos, aspect);\nvec2 nextP = fix(nextPos, aspect);\nfloat w = lineWidth * width;\nif (sizeAttenuation == 0.0) {\nw *= finalPosition.w / resolution.x;\n}\nvec2 dir;\nif (posEqual(nextP, currentP)) {\ndir = normalize(currentP - prevP);\n} else if (posEqual(prevP, currentP)) {\ndir = normalize(nextP - currentP);\n} else {\nvec2 dir1 = normalize(currentP - prevP);\nvec2 dir2 = normalize(nextP - currentP);\ndir = normalize(dir1 + dir2);\n}\nvec2 offset = vec2(-dir.y, dir.x);\noffset.y *= aspect;\noffset *= w;\nfinalPosition.xy += offset * side;\ngl_Position = finalPosition;\n}"},ta={basic:{uniforms:Ni([Yi.common,Yi.specularmap,Yi.envmap,Yi.aomap,Yi.lightmap,Yi.fog]),vertexShader:ea.meshbasic_vert,fragmentShader:ea.meshbasic_frag},lambert:{uniforms:Ni([Yi.common,Yi.specularmap,Yi.envmap,Yi.aomap,Yi.lightmap,Yi.emissivemap,Yi.fog,Yi.lights,{emissive:{value:new Er(0)}}]),vertexShader:ea.meshlambert_vert,fragmentShader:ea.meshlambert_frag},phong:{uniforms:Ni([Yi.common,Yi.specularmap,Yi.envmap,Yi.aomap,Yi.lightmap,Yi.emissivemap,Yi.bumpmap,Yi.normalmap,Yi.displacementmap,Yi.fog,Yi.lights,{emissive:{value:new Er(0)},specular:{value:new Er(1118481)},shininess:{value:30}}]),vertexShader:ea.meshphong_vert,fragmentShader:ea.meshphong_frag},standard:{uniforms:Ni([Yi.common,Yi.envmap,Yi.aomap,Yi.lightmap,Yi.emissivemap,Yi.bumpmap,Yi.normalmap,Yi.displacementmap,Yi.roughnessmap,Yi.metalnessmap,Yi.fog,Yi.lights,{emissive:{value:new Er(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:ea.meshphysical_vert,fragmentShader:ea.meshphysical_frag},toon:{uniforms:Ni([Yi.common,Yi.specularmap,Yi.aomap,Yi.lightmap,Yi.emissivemap,Yi.bumpmap,Yi.normalmap,Yi.displacementmap,Yi.gradientmap,Yi.fog,Yi.lights,{emissive:{value:new Er(0)},specular:{value:new Er(1118481)},shininess:{value:30}}]),vertexShader:ea.meshtoon_vert,fragmentShader:ea.meshtoon_frag},matcap:{uniforms:Ni([Yi.common,Yi.bumpmap,Yi.normalmap,Yi.displacementmap,Yi.fog,{matcap:{value:null}}]),vertexShader:ea.meshmatcap_vert,fragmentShader:ea.meshmatcap_frag},points:{uniforms:Ni([Yi.points,Yi.fog]),vertexShader:ea.points_vert,fragmentShader:ea.points_frag},dashed:{uniforms:Ni([Yi.common,Yi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ea.linedashed_vert,fragmentShader:ea.linedashed_frag},depth:{uniforms:Ni([Yi.common,Yi.displacementmap,{slopeScaledBias:{value:0}}]),vertexShader:ea.depth_vert,fragmentShader:ea.depth_frag},normal:{uniforms:Ni([Yi.common,Yi.bumpmap,Yi.normalmap,Yi.displacementmap,{opacity:{value:1}}]),vertexShader:ea.normal_vert,fragmentShader:ea.normal_frag},sprite:{uniforms:Ni([Yi.sprite,Yi.fog]),vertexShader:ea.sprite_vert,fragmentShader:ea.sprite_frag},background:{uniforms:{uvTransform:{value:new Qt},t2D:{value:null}},vertexShader:ea.background_vert,fragmentShader:ea.background_frag},cube:{uniforms:Ni([Yi.envmap,{opacity:{value:1}}]),vertexShader:ea.cube_vert,fragmentShader:ea.cube_frag},equirect:{uniforms:{tEquirect:{value:null},invertU:{value:!1},offsetU:{value:0}},vertexShader:ea.equirect_vert,fragmentShader:ea.equirect_frag},distanceRGBA:{uniforms:Ni([Yi.common,Yi.displacementmap,{referencePosition:{value:new sn},nearDistance:{value:1},farDistance:{value:1e3},slopeScaledBias:{value:0}}]),vertexShader:ea.distanceRGBA_vert,fragmentShader:ea.distanceRGBA_frag},shadow:{uniforms:Ni([Yi.lights,Yi.fog,{color:{value:new Er(0)},opacity:{value:1}}]),vertexShader:ea.shadow_vert,fragmentShader:ea.shadow_frag},mask:{uniforms:Ni([Yi.common,Yi.displacementmap,Yi.mask]),vertexShader:ea.mask_vert,fragmentShader:ea.mask_frag},equicube:{uniforms:{tEquirect:{value:null},faceIndex:{value:0},invertU:{value:!1},offsetU:{value:0}},vertexShader:ea.equicube_vert,fragmentShader:ea.equicube_frag},node:{uniforms:Ni([Yi.common,Yi.displacementmap,Yi.envmap,Yi.fog,Yi.lights,Yi.ssr,Yi.node,{envMapIntensity:{value:1}}]),vertexShader:ea.meshnode_vert,fragmentShader:ea.meshnode_frag},cubeOctahedral:{uniforms:{tCube:{value:null},texelSize:{value:new Zt(.5,.5)}},vertexShader:ea.pp_plane_vert,fragmentShader:ea.pp_cube_octahedral_proj_frag}};function na(h,n,p,r){var f,m,v,g,_=new Er(0),y=0,x=null,b=0,w=null;function M(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return _},setClearColor:function(e,t){_.set(e),M(_,y=void 0!==t?t:1)},getClearAlpha:function(){return y},setClearAlpha:function(e){M(_,y=e)},dispose:function(){m&&(m.geometry.dispose(),m.material.dispose()),m=f=void 0,v&&(v.geometry.dispose(),v.material.dispose()),v=void 0,g&&(g.geometry.dispose(),g.material.dispose()),g=void 0},render:function(e,t,n,r){var i=t.background&&t.background.isSceneBackground,a=i?t.background.data:t.background,o=h.xr,s=o.getSession&&o.getSession();s&&"additive"===s.environmentBlendMode&&(a=null),null===a?M(_,y):a&&a.isColor&&(M(a,1),r=!0),(h.autoClear||r)&&h.clear(h.autoClearColor,h.autoClearDepth,h.autoClearStencil);var l=!!i&&t.background.useHDR;if(a&&(a.isCubeTexture||a.isWebGLCubeRenderTarget||a.mapping===We)){void 0===v&&((v=new Mi(new Di(1,1,1),new zi({type:"BackgroundCubeMaterial",uniforms:Oi.clone(ta.cube.uniforms),vertexShader:ta.cube.vertexShader,fragmentShader:ta.cube.fragmentShader,side:Pe,depthTest:!1,depthWrite:!1,fog:!1,polygonOffset:!0,useHDR:l}))).geometry.deleteAttribute("normal"),v.geometry.deleteAttribute("uv"),v.onBeforeRender=function(e,t,n){var r=n.far;this.matrixWorld.makeScale(r,r,r),this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(v.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),p.update(v));var c=a.isWebGLCubeRenderTarget?a.texture:a;v.material.uniforms.envMap.value=c,v.material.uniforms.flipEnvMap.value=c.isCubeTexture?-1:1,x===a&&b===c.version&&w===h.toneMapping||(v.material.needsUpdate=!0,x=a,b=c.version,w=h.toneMapping),e.unshift(v,v.geometry,v.material,0,0,null)}else if(a&&a.isTexture)if(a.mapping===ke){var u=!!i&&t.background.equirecInvertU,d=i?t.background.equirecOffsetU:0;void 0===g&&((g=new Mi(new Di(1,1,1),new zi({vertexShader:ta.equirect.vertexShader,fragmentShader:ta.equirect.fragmentShader,uniforms:ta.equirect.uniforms,side:Pe,depthTest:!1,depthWrite:!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)}),p.update(g),g.material.uniforms.invertU.value=u,g.material.uniforms.offsetU.value=d,g.material.uniforms.tEquirect.value=a,e.unshift(g,g.geometry,g.material,0,0,null)}else void 0===f&&(f=new Ki(-1,1,1,-1,0,1),m=new Mi(new $i(2,2),new Or({depthTest:!1,depthWrite:!1,fog:!1}))),p.update(m),m.material.map=a,h.renderBufferDirect(f,null,m.geometry,m.material,m,null)}}}function ra(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 ia(t,n,e){var r;function i(e){if("highp"===e){if(0",t[n]);return e}var wo=/^[ \t]*#include +<([\w\d./]+)>/gm;function Mo(e){return e.replace(wo,Ao)}function Ao(e,t){var n=ea[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Mo(n)}function So(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&&0Oo.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(_).multiplyScalar(y),A.position.setFromMatrixPosition(g.matrixWorld),A.position.applyMatrix4(m),L.identity(),P.copy(g.matrixWorld),P.premultiply(m),L.extractRotation(P),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,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(y),A.groundColor.copy(g.groundColor).multiplyScalar(y),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=Bo++)},state:E}}function Vo(){var t=new Uo,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 ko(){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 Vo,r.set(e,new WeakMap),r.get(e).set(t,n),e.addEventListener("dispose",i)):!1===r.get(e).has(t)?(n=new Vo,r.get(e).set(t,n)):n=r.get(e).get(t),n},dispose:function(){r=new WeakMap}}}function Go(e){Nr.call(this),this.type="MeshDepthMaterial",this.depthPacking=Rt,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 jo(e){Nr.call(this),this.type="MeshDistanceMaterial",this.distancePacking=It,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.referencePosition=new sn,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)}((Go.prototype=Object.create(Nr.prototype)).constructor=Go).prototype.isMeshDepthMaterial=!0,Go.prototype.copy=function(e){return Nr.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},((jo.prototype=Object.create(Nr.prototype)).constructor=jo).prototype.isMeshDistanceMaterial=!0,jo.prototype.copy=function(e){return Nr.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 Wo=.8,Xo=.2,Ho=.8,Yo=3;function qo(_,v,g){var y=new Hi,x=new mn,h=new mn,b=new Zt,w=new Zt(g.maxTextureSize,g.maxTextureSize),M=new sn,A=new sn,S=1,T=2,e=1+(S|T),E=new Array(e),C=new Array(e),P={},L={0:Pe,1:re,2:ie},R=[new sn(1,0,0),new sn(-1,0,0),new sn(0,1,0),new sn(0,-1,0),new sn(0,0,1),new sn(0,0,-1)],D=[new sn(0,1,0),new sn(0,1,0),new sn(0,0,1),new sn(0,0,-1),new sn(0,1,0),new sn(0,1,0)],c=[new en,new en,new en,new en,new en,new en],f=new er,p=[new sn,new sn,new sn,new sn,new sn,new sn,new sn,new sn],I=0,N=1,O=0,m=1,F=new Ki(-1,1,1,-1,0,10),B=new Mi(new $i(2,2)),z=new zi({type:"ShadowCubeOctahedral",defines:Object.assign({},ta.cubeOctahedral.defines),uniforms:Oi.clone(ta.cubeOctahedral.uniforms),vertexShader:ta.cubeOctahedral.vertexShader,fragmentShader:ta.cubeOctahedral.fragmentShader}),u={};var d={};function U(e,t,n,r,i,a,o){var s,l,c=B.material=o===O?((l=r)in u||((u[l]=new zi({type:"ShadowBlur",defines:Object.assign({},ta.blur.defines,{LOG_SPACE:1,OCTAHEDRAL_MAP:1}),uniforms:Oi.clone(ta.blur.uniforms),customPrepTokens:Object.assign({},ta.blur.customPrepTokens),vertexShader:ta.blur.vertexShader,fragmentShader:ta.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=l),u[l]):((s=r)in d||((d[s]=new zi({type:"ShadowBlur",defines:Object.assign({},ta.blur.defines,{LOG_SPACE:1}),uniforms:Oi.clone(ta.blur.uniforms),customPrepTokens:Object.assign({},ta.blur.customPrepTokens),vertexShader:ta.blur.vertexShader,fragmentShader:ta.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=s),d[s]);c.uniforms.direction.value.set(+(a===I),+(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(F,!1,B.geometry,c,B,null)}for(var t=0;t!==e;++t){var n=0!=(t&S),r=0!=(t&T),i=new Go({depthPacking:Dt,morphTargets:n,skinning:r});E[t]=i;var a=new jo({distancePacking:It,morphTargets:n,skinning:r});C[t]=a}var V=this;function k(e,t,n,r,i,a,o){var s=e.geometry,l=null,c=E,u=e.customDepthMaterial;if(!r&&V.type!==te||(c=C,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=Z,this.render=function(e,t,n){if(V.type==ee&&(V.type=Z,console.warn("v3d.WebGLShadowMap: disable unsupported VSM shadow maps")),!1!==V.enabled&&(!1!==V.autoUpdate||!1!==V.needsUpdate)&&0!==e.length){var r=_.getRenderTarget(),i=_.getActiveCubeFace(),a=_.getActiveMipmapLevel(),o=_.state;o.setBlending(ae),o.buffers.color.setClear(1,1,1,1),o.buffers.depth.setTest(!0),o.setScissorTest(!1);for(var s=0,l=e.length;sOo.OMNI_MAP_ANGLE)if(V.type===q||V.type===Z||V.type===$||V.type===ne)W(t,n,c);else{if(V.type!==te)continue;j(t,n,c)}else{if(!c.isSpotLight&&!c.isDirectionalLight)continue;if(V.type===q||V.type===Z||V.type===$||V.type===ne)H(t,n,c);else{if(V.type!==te)continue;X(t,n,c)}}else console.warn("v3d.WebGLShadowMap:",c,"has no shadow.")}V.needsUpdate=!1,_.setRenderTarget(r,i,a)}}}function Zo(u,n,e){var t,r,i=e.isWebGL2;var a=new function(){var t=!1,a=new en,n=null,o=new en(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?V:k)(2929)},setMask:function(e){n===e||t||(u.depthMask(e),n=e)},setFunc:function(e){if(r!==e){if(e)switch(e){case Ee:u.depthFunc(512);break;case Ce:u.depthFunc(519);break;case Le:u.depthFunc(513);break;case Re:u.depthFunc(515);break;case De:u.depthFunc(514);break;case Ie:u.depthFunc(518);break;case Ne:u.depthFunc(516);break;case Oe: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?V:k)(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,_=null,y=null,x=null,b=null,w=null,M=!1,A=null,S=null,T=null,E=null,C=null,P=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 I=null,N={},O=new en,F=new en;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?qt.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 qt.isPowerOfTwo(e.width)&&qt.isPowerOfTwo(e.height)}function E(e,t){return e.generateMipmaps&&t&&e.minFilter!==Ze&&e.minFilter!==Je}function C(e,t,n,r){y.generateMipmap(e),w.get(t).__maxMipLevel=Math.log(Math.max(n,r))*Math.LOG2E}function P(e,t,n){if(!1===S)return t;if(null!==e){if(void 0!==y[e])return y[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?x.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===Qe||e===Ke?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;y.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&&y.deleteTexture(n.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(var r=0;r<6;r++)y.deleteFramebuffer(t.__webglFramebuffer[r]),t.__webglDepthbuffer&&y.deleteRenderbuffer(t.__webglDepthbuffer[r]);else y.deleteFramebuffer(t.__webglFramebuffer),t.__webglDepthbuffer&&y.deleteRenderbuffer(t.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){y.deleteTexture(t.__webglColorTexture),y.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(ns.genWebGLErrorMessage());var t=document.getElementById("v3d_preloader_container");t&&(t.style.visibility="hidden")},checkIOS:function(){return(/iPad|iPhone|iPod/.test(navigator.platform)||"MacIntel"===navigator.platform&&1e.far||t.push({distance:s,point:ms.clone(),uv:Mr.getUV(ms,bs,ws,Ms,As,Ss,Ts,new Zt),face:null,object:this})}}else console.error('v3d.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.')},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return Nn.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}});var Ps=new sn,Ls=new sn;function Rs(){Nn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function Ds(e,t){e&&e.isGeometry&&console.error("v3d.SkinnedMesh no longer supports v3d.Geometry. Use v3d.BufferGeometry instead."),Mi.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new mn,this.bindMatrixInverse=new mn,this.normalizeSkinWeights()}Rs.prototype=Object.assign(Object.create(Nn.prototype),{constructor:Rs,isLOD:!0,copy:function(e){Nn.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 y=r.vertices,x=y.length;for(m=0;me.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 Zs=new sn,Qs=new sn;function Ks(e,t){qs.call(this,e,t),this.type="LineSegments"}function Js(e,t){qs.call(this,e,t),this.type="LineLoop"}function $s(e){Nr.call(this),this.type="PointsMaterial",this.color=new Er(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}Ks.prototype=Object.assign(Object.create(qs.prototype),{constructor:Ks,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 ol(e,t,n,r,i,a,o,s,l){$t.call(this,e,t,n,r,i,a,o,s,l),this.format=void 0!==o?o:st,this.minFilter=void 0!==a?a:Je,this.magFilter=void 0!==i?i:Je,this.generateMipmaps=!1}function sl(e,t,n,r,i,a,o,s,l,c,u,d){$t.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 ll(e,t,n,r,i,a,o,s,l){$t.call(this,e,t,n,r,i,a,o,s,l),this.needsUpdate=!0}function cl(e,t,n,r,i,a,o,s,l,c){if((c=void 0!==c?c:ct)!==ct&&c!==ut)throw new Error("DepthTexture format must be either v3d.DepthFormat or v3d.DepthStencilFormat");void 0===n&&c===ct&&(n=nt),void 0===n&&c===ut&&(n=ot),$t.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 ul(e){ai.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)}}),((sl.prototype=Object.create($t.prototype)).constructor=sl).prototype.isCompressedTexture=!0,((ll.prototype=Object.create($t.prototype)).constructor=ll).prototype.isCanvasTexture=!0,((cl.prototype=Object.create($t.prototype)).constructor=cl).prototype.isDepthTexture=!0,(ul.prototype=Object.create(ai.prototype)).constructor=ul,(dl.prototype=Object.create(Li.prototype)).constructor=dl,(hl.prototype=Object.create(ai.prototype)).constructor=hl,(pl.prototype=Object.create(Li.prototype)).constructor=pl,(fl.prototype=Object.create(ai.prototype)).constructor=fl,(ml.prototype=Object.create(Li.prototype)).constructor=ml,(vl.prototype=Object.create(fl.prototype)).constructor=vl,(gl.prototype=Object.create(Li.prototype)).constructor=gl,(_l.prototype=Object.create(fl.prototype)).constructor=_l,(yl.prototype=Object.create(Li.prototype)).constructor=yl,(xl.prototype=Object.create(fl.prototype)).constructor=xl,(bl.prototype=Object.create(Li.prototype)).constructor=bl,(wl.prototype=Object.create(fl.prototype)).constructor=wl,(Ml.prototype=Object.create(Li.prototype)).constructor=Ml,((Al.prototype=Object.create(ai.prototype)).constructor=Al).prototype.toJSON=function(){var e=ai.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e},(Sl.prototype=Object.create(Li.prototype)).constructor=Sl,(Tl.prototype=Object.create(ai.prototype)).constructor=Tl,(El.prototype=Object.create(Li.prototype)).constructor=El,(Cl.prototype=Object.create(ai.prototype)).constructor=Cl;var Pl=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=Ll(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=Ul(s,l,t,n,r),h=Ul(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&&kl(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=Gl(p.prev,p,p.next))return;if(p=p.prevZ,f!==e.prev&&f!==e.next&&kl(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&0<=Gl(f.prev,f,f.next))return;f=f.nextZ}for(;p&&p.z>=d;){if(p!==e.prev&&p!==e.next&&kl(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&0<=Gl(p.prev,p,p.next))return;p=p.prevZ}for(;f&&f.z<=h;){if(f!==e.prev&&f!==e.next&&kl(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&0<=Gl(f.prev,f,f.next))return;f=f.nextZ}return 1}}function Ol(e,t,n){var r=e;do{var i=r.prev,a=r.next.next;!jl(i,a)&&Wl(i,r,r.next,a)&&Xl(i,a)&&Xl(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),ql(r),ql(r.next),r=e=a),r=r.next}while(r!==e);return r}function Fl(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&&Wl(n,n.next,e,t))return 1;n=n.next}while(n!==e);return}(o,s)&&Xl(o,s)&&Xl(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=Hl(l,c);return l=Rl(l,l.next),u=Rl(u,u.next),Dl(l,t,n,r,i,a),void Dl(u,t,n,r,i,a)}c=c.next}l=l.next}while(l!==e)}function Bl(e,t){return e.x-t.x}function zl(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&&kl(an.x)&&Xl(r,e)&&(n=r,h=l),r=r.next;return n}(e,t)){var n=Hl(t,e);Rl(n,n.next)}}function Ul(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 Vl(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 Zt(r,i);a=Math.sqrt(g/2)}else{var _=!1;o>Number.EPSILON?l>Number.EPSILON&&(_=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(_=!0):Math.sign(s)===Math.sign(c)&&(_=!0),a=_?(r=-s,i=o,Math.sqrt(u)):(r=o,i=s,Math.sqrt(u/2))}return new Zt(r/a,i/a)}for(var F=[],B=0,z=S.length,U=z-1,V=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;n"+s+", please reexport your scene")}for(i=0;ia.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=vu.arraySlice(n,i,a),this.values=vu.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(qt.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(qt.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(Zu(o,s.x,l.x,c.x,u.x),Zu(o,s.y,l.y,c.y,u.y)),n},id.prototype.copy=function(e){Vu.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=Ql.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 dd).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,_=a.length;g<_;g++)o=i(d=(s=a[g]).getPoints()),(o=e?!o:o)?(!u&&f[v]&&v++,f[v]={s:new dd,p:d},f[v].s.curves=s.curves,u&&v++,m[v]=[]):m[v].push({h:s,p:d[0]});if(!f[0])return n(a);if(1n.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=qt.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=qt.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=bt,r.endingEnd=bt):(r.endingStart=e?this.zeroSlopeAtStart?bt:xt:wt,r.endingEnd=t?this.zeroSlopeAtEnd?bt:xt:wt)},_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}}),Ph.prototype=Object.assign(Object.create(o.prototype),{constructor:Ph,_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 mh(Th.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 Zt),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 Zt),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Ih.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 Oh=new sn,Fh=new sn;function Bh(e,t){this.start=void 0!==e?e:new sn,this.end=void 0!==t?t:new sn}function zh(e){Nn.call(this),this.material=e,this.render=function(){}}Object.assign(Bh.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 sn),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 sn),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 sn),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,t){Oh.subVectors(e,this.start),Fh.subVectors(this.end,this.start);var n=Fh.dot(Fh),r=Fh.dot(Oh)/n;return t&&(r=qt.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 sn),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)}}),((zh.prototype=Object.create(Nn.prototype)).constructor=zh).prototype.isImmediateRenderObject=!0;var Uh=new sn;function Vh(e,t){Nn.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;for(var n=new ai,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 Xr(r,3));var l=new Gs({fog:!1});this.cone=new Ks(n,l),this.add(this.cone),this.update()}((Vh.prototype=Object.create(Nn.prototype)).constructor=Vh).prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},Vh.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),Uh.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Uh),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var kh=new sn,Gh=new mn,jh=new mn;function Wh(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:Tp.clone(),object:e}}(e,e.material,t,n,yp,xp,bp,Sp);if(l){i&&(wp.fromBufferAttribute(i,a),Mp.fromBufferAttribute(i,o),Ap.fromBufferAttribute(i,s),l.uv=Mr.getUV(Sp,yp,xp,bp,wp,Mp,Ap,new Zt));var c=new sn;l.face=new Dr(a,o,s,Mr.getNormal(yp,xp,bp,c)),l.faceIndex=a}return l}function Cp(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=Ep(e,n,r,t.attributes.position,t.attributes.uv,s,l,c);return u?(u.faceIndex=i,a&&a.push(u),u):null}function Pp(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 Lp(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}();Dp.prototype.setFromBox=(Rp=new sn,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++){Rp.x=n.x*o+r.x*(1-o),Rp.y=n.y*s+r.y*(1-s),Rp.z=n.z*l+r.z*(1-l);var c=e.dot(Rp);i=Math.min(c,i),a=Math.max(c,a)}this.min=i,this.max=a});var Ip,Np,Op,Fp,Bp,zp,Up,Vp,kp,Gp,jp,Wp,Xp,Hp,Yp,qp,Zp,Qp,Kp,Jp,$p,ef,tf,nf=(Ip=new sn,Np=new sn,Op=new sn,function(e,t,n){var r=e.start,i=Ip,a=t.start,o=Np;Op.subVectors(r,a),Ip.subVectors(e.end,t.start),Np.subVectors(t.end,t.start);var s,l,c=Op.dot(o),u=o.dot(i),d=o.dot(o),h=Op.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}),rf=(Fp=new Zt,Bp=new sn,zp=new sn,function(e,t,n,r){nf(e,t,Fp);var i,a,o=Fp.x,s=Fp.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=Bp,c=zp;return e.closestPointToPoint(a,!0,Bp),t.closestPointToPoint(i,!0,zp),l.distanceToSquared(a)<=c.distanceToSquared(i)?(n.copy(l),void r.copy(a)):(n.copy(i),void r.copy(c))}),af=(Up=new sn,Vp=new sn,kp=new hr,Gp=new Bh,function(e,t){var n=e.radius,r=e.center,i=t.a,a=t.b,o=t.c;if(Gp.start=i,Gp.end=a,Gp.closestPointToPoint(r,!0,Up).distanceTo(r)<=n)return!0;if(Gp.start=i,Gp.end=o,Gp.closestPointToPoint(r,!0,Up).distanceTo(r)<=n)return!0;if(Gp.start=a,Gp.end=o,Gp.closestPointToPoint(r,!0,Up).distanceTo(r)<=n)return!0;var s=t.getPlane(kp);if(Math.abs(s.distanceToPoint(r))<=n){var l=s.projectPoint(r,Vp);if(t.containsPoint(l))return!0}return!1}),of=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 Uf,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 Uf,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 Uf,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}(),qf=function(){function r(e){var t,n=1t;)this._roots.pop();for(var n=0;n=this._roots.length){var r=new Yf(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}(),Zf=new lr,Qf=new mn,Kf=Mi.prototype.raycast;function Jf(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;try{Qf.getInverse(this.matrixWorld,!0)}catch(e){return}if(Zf.copy(e.ray).applyMatrix4(Qf),!0===e.firstHitOnly){var n=this.geometry.boundsTree.raycastFirst(this,e,Zf);n&&t.push(n)}else this.geometry.boundsTree.raycast(this,e,Zf,t)}else Kf.call(this,e,t)}function $f(e){return this.boundsTree=new jf(this,e),this.boundsTree}function em(){this.boundsTree=null}var tm,nm,rm,im,am,om,sm,lm,cm,um,dm,hm,pm,fm,mm,vm,gm,_m,ym,xm,bm,wm,Mm,Am,Sm,Tm,Em,Cm,Pm,Lm,Rm=["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","gradientMap","lightMap","map","metalnessMap","normalMap","roughnessMap","specularMap"],Dm={disposeTextures:function(t){if(Rm.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 Im(){this.name="",this.type="Constraint",this.mute=!1}function Nm(e){Im.call(this),this.type="TargetConstraint",this.target=e}function Om(e){Nm.call(this,e),this.type="ChildOfConstraint",this.offsetMatrix=new mn}function Fm(e){Nm.call(this,e),this.type="CopyLocationConstraint"}function Bm(e){Nm.call(this,e),this.type="CopyRotationConstraint"}function zm(e){Nm.call(this,e),this.type="CopyScaleConstraint"}function Um(e){Nm.call(this,e),this.type="FloorConstraint",this.floorLocation="Y",this.offset=0}function Vm(){Im.call(this),this.type="LimitLocationConstraint",this.min=(new sn).setScalar(-1/0),this.max=(new sn).setScalar(1/0)}function km(){Im.call(this),this.type="LimitRotationConstraint",this.axis="Y",this.min=0,this.max=2*Math.PI}function Gm(){Im.call(this),this.type="LimitScaleConstraint",this.min=(new sn).setScalar(-1/0),this.max=(new sn).setScalar(1/0)}function jm(e){Nm.call(this,e),this.type="LockedTrackConstraint",this.trackAxis="X",this.lockAxis="Y"}function Wm(e){Nm.call(this,e),this.type="TrackToConstraint",this.trackAxis="X",this.upAxis="Y"}Object.assign(Im.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)}}),Nm.prototype=Object.assign(Object.create(Im.prototype),{constructor:Nm,isTargetConstraint:!0,copy:function(e){Im.prototype.copy.call(this,e),this.target=e.target}}),Om.prototype=Object.assign(Object.create(Nm.prototype),{constructor:Om,isChildOfConstraint:!0,copy:function(e){Nm.prototype.copy.call(this,e),this.offsetMatrix.copy(e.offsetMatrix)},update:(tm=new mn,nm=(new rn).setFromAxisAngle(new sn(1,0,0),-Math.PI/2),function(e){Nm.prototype.update.call(this,e),this.mute||(tm.multiplyMatrices(this.target.matrixWorld,this.offsetMatrix),tm.decompose(e.position,e.quaternion,e.scale),e.isCamera&&e.quaternion.multiply(nm))})}),Fm.prototype=Object.assign(Object.create(Nm.prototype),{constructor:Fm,isCopyLocationConstraint:!0,update:(rm=new rn,im=new sn,function(e){Nm.prototype.update.call(this,e),this.mute||(this.target.matrixWorld.decompose(e.position,rm,im),e.parent&&e.parent.worldToLocal(e.position))})}),Bm.prototype=Object.assign(Object.create(Nm.prototype),{constructor:Bm,isCopyRotationConstraint:!0,update:(am=new sn,om=new rn,sm=new sn,lm=(new rn).setFromAxisAngle(new sn(1,0,0),-Math.PI/2),function(e){Nm.prototype.update.call(this,e),this.mute||(this.target.matrixWorld.decompose(am,e.quaternion,sm),e.parent&&(e.parent.matrixWorld.decompose(am,om,sm),e.quaternion.premultiply(om.inverse())),e.isCamera&&e.quaternion.multiply(lm))})}),zm.prototype=Object.assign(Object.create(Nm.prototype),{constructor:zm,isCopyScaleConstraint:!0,update:function(e){Nm.prototype.update.call(this,e),this.mute||e.scale.copy(this.target.scale)}}),Um.prototype=Object.assign(Object.create(Nm.prototype),{constructor:Um,isFloorConstraint:!0,copy:function(e){Nm.prototype.copy.call(this,e),this.floorLocation=e.floorLocation,this.offset=e.offset},update:function(e){if(Nm.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)}}}}),Vm.prototype=Object.assign(Object.create(Im.prototype),{constructor:Vm,isLimitLocationConstraint:!0,copy:function(e){Im.prototype.copy.call(this,e),this.min.copy(e.min),this.max.copy(e.max)},update:function(e){Im.prototype.update.call(this,e),this.mute||e.position.clamp(this.min,this.max)}}),km.prototype=Object.assign(Object.create(Im.prototype),{constructor:km,isLimitRotationConstraint:!0,copy:function(e){Im.prototype.copy.call(this,e),this.axis=e.axis,this.min=e.min,this.max=e.max},update:(cm=new _n,function(e){Im.prototype.update.call(this,e),this.mute||("X"==this.axis?(cm.setFromQuaternion(e.quaternion,"XYZ"),cm.x=this._clampAngle(cm.x,this.min,this.max)):"Y"==this.axis?(cm.setFromQuaternion(e.quaternion,"YZX"),cm.y=this._clampAngle(cm.y,this.min,this.max)):"Z"==this.axis&&(cm.setFromQuaternion(e.quaternion,"ZXY"),cm.z=this._clampAngle(cm.z,this.min,this.max)),e.quaternion.setFromEuler(cm))}),_clampAngle:function(e,t,n){return Math.abs(n-t)<2*Math.PI&&(e=qt.clampAngle(e,t,n)),e}}),Gm.prototype=Object.assign(Object.create(Im.prototype),{constructor:Gm,isLimitScaleConstraint:!0,copy:function(e){Im.prototype.copy.call(this,e),this.min.copy(e.min),this.max.copy(e.max)},update:function(e){Im.prototype.update.call(this,e),this.mute||e.scale.clamp(this.min,this.max)}}),jm.prototype=Object.assign(Object.create(Nm.prototype),{constructor:jm,isLockedTrackConstraint:!0,copy:function(e){Nm.prototype.copy.call(this,e),this.trackAxis=e.trackAxis,this.lockAxis=e.lockAxis},update:(um=new sn,dm=new sn,hm=new sn,pm=new sn,fm=new sn,mm=new hr,vm=new sn,gm=new sn,_m=new rn,ym=(new rn).setFromAxisAngle(new sn(1,0,0),-Math.PI/2),function(e){if(Nm.prototype.update.call(this,e),!this.mute&&(hm.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),pm.set("X"==this.lockAxis?1:0,"Y"==this.lockAxis?1:0,"Z"==this.lockAxis?1:0),1!=Math.abs(hm.dot(pm)))){um.setFromMatrixPosition(e.matrixWorld),dm.setFromMatrixPosition(this.target.matrixWorld),mm.setFromNormalAndCoplanarPoint(pm,um),mm.projectPoint(dm,fm).sub(um);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 sn,function(){if(O){var e=G.getElapsedTime()/k;if(e=qt.smootherstep(e,0,1),c.object.position.lerpVectors(B,U,e),c.object.lookAt(Y.lerpVectors(z,V,e)),1<=e){for(var t in O=!1,F(),g.set(0,0,0),_.set(0,0),A=M=0,P.set(0,0),L.set(0,0),f)f[t]=0;l.getDelta()}}else c.object.getLocalDirection(p),v.setFromVector3(p),v.theta+=g.theta*y,v.phi+=g.phi*y,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.lookAtLocal(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(-P.x),i.add(o.copy(c.object.up).setLength(P.y)),c.object.position.add(i),function(){var e=l.getDelta();for(var t in g.set(g.radius,_.y,_.x),_.x=c.enableDamping?qt.expAverage(_.x,0,e,x):0,_.y=c.enableDamping?qt.expAverage(_.y,0,e,x):0,g.set(g.radius,g.phi-_.y,g.theta-_.x),P.copy(L),L.x=c.enableDamping?qt.expAverage(L.x,0,e,D):0,L.y=c.enableDamping?qt.expAverage(L.y,0,e,D):0,P.sub(L),P.multiplyScalar(R),M=A,A=c.enableDamping?qt.expAverage(A,0,e,T):0,M-=A,M*=S,f){var n=t==Xm.A||t==Xm.LEFT_ARROW||t==Xm.D||t==Xm.RIGHT_ARROW,r=t==Xm.W||t==Xm.UP_ARROW||t==Xm.S||t==Xm.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]=qt.expAverage(f[t],0,e,i),o=s-f[t]}c.enabled&&(n&&!c.enablePan||r&&!c.enableZoom||(o*=60*e*a,t==Xm.A||t==Xm.LEFT_ARROW?P.x+=o:t==Xm.D||t==Xm.RIGHT_ARROW?P.x-=o:t==Xm.W||t==Xm.UP_ARROW?M+=o:t!=Xm.S&&t!=Xm.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 sn,u=new sn,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,_=new Qc,y=new Qc,x=1,b=new sn,w=!1,M={};M[Xm.W]=M[Xm.S]=M[Xm.A]=M[Xm.D]=M[Xm.UP_ARROW]=M[Xm.DOWN_ARROW]=M[Xm.LEFT_ARROW]=M[Xm.RIGHT_ARROW]=0;var A=new Hm(window);A.onKeyDown=function(e){e.keyCode in M&&(M[e.keyCode]=1)};var S=new Zt,T=new Zt,E=new Zt,C=new Zt,P=1,L=1,R=new Zt,D=new Zt,I=new Zt,N=new Zt,O=new Zt,F=new Zt,B=new Zt,z=1,U=1,V=1,k=new nh,G=new sn,j=new sn,W=new sn,X=new sn,H=0,Y=new nh;function q(){return Math.pow(.95,U)}function Z(e){y.theta-=e}function Q(e,t){T.set(e,t),C.add(T).sub(S),S.copy(T)}var K,J,$,ee,te=(K=new sn,function(e,t){K.setFromMatrixColumn(t,0),K.multiplyScalar(-e),b.add(K)}),ne=(J=new sn,function(e,t){J.setFromMatrixColumn(t,1),J.multiplyScalar(e),b.add(J)}),re=($=new sn,ee=new sn,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*qt.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?z/=e:d.object.isOrthographicCamera?(z/=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?z*=e:d.object.isOrthographicCamera?(z*=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;Q((n=e).clientX,n.clientY),P=d.rotateSpeed,L=d.rotateInertia;break;case m.DOLLY:if(!1===d.enableZoom)return;t=e,F.set(t.clientX,t.clientY),B.subVectors(F,O),0Math.abs(I.length())&&(0').concat("MADE WITH VERGE3D TRIAL",""),t.appendChild(r),setTimeout(function(){t.contains(r)&&890310108==qt.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,_){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),_=_||5;var y=new v3d.Vector3(1,0,0),n=new v3d.MeshLine;n.setGeometry([0,0,0,y.x,y.y,y.z]);var r=new v3d.MeshLineMaterial({color:t,lineWidth:e,sizeAttenuation:0}),x=new v3d.Mesh(n.geometry,r);x.name=v.name+"_LINE",v.add(x);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*_)/(e.width+2*_);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 tv(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}function nv(e){this._mesh=new Mi($m,e)}function rv(e,t,n,r,i){tv.call(this),this.strength=void 0!==t?t:1,this.radius=n,this.threshold=r,this.resolution=void 0!==e?new Zt(e.x,e.y):new Zt(256,256),i=i||{minFilter:Je,magFilter:Je,format:lt},this.clearColor=new Er(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 tn(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;x[0|n]=w[0|t],x[n+1|0]=w[t+1|0],x[n+2|0]=w[t+2|0],x[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(x[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(;x[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&&(x[(n=e+t|0)-1|0]=0,!(t>>>(x[0|e]=0)<3||(x[n+-2|0]=0,x[e+1|0]=0,x[n+-3|0]=0,t>>>(x[e+2|0]=0)<7||(x[n+-4|0]=0,t>>>(x[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,x[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,x[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=_[o+120>>1];n:if(r>>>0<(t=y(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)+(y(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=_[o>>1],(t=y(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+((y(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=_[(v=n=s)>>1],n=(t=y(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,x[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=_[o+504>>1];r:if((a=y(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=_[h+528>>1];i:{if(r>>>0<(i=y(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=_[u+600>>1],(n=y(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=_[h+552>>1],r>>>0<(a=y(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=_[h+576>>1],r>>>0<(n=y(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,P(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,P(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=_[o+984>>1],(n=y(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=_[s>>1],i>>>0<(t=y(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=_[(n=e)+1726>>1],o=1724+(n+(a=(t=i>>>0<(r=y(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=_[o>>1],(t=y(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=_[o>>1],(r=y(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=_[(n=1724+((a<<1)+e|0)|0)>>1],(t=y(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,x[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,x[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 C(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 P(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=_[t>>1],i=a>>>0<(r=y(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=_[t+2>>1],a>>>0<(r=y(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=_[o>>1],(r=y(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)-y(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-y(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,x[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 x[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(x[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(;x[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(x[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(;x[(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,x[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,_=0,y=0;o=b[e+36>>2]?b[e>>2]:(x[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,C(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=x[a+177|0])){l=6;break t}if(o=2,c=s=_=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,y=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|y,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],_=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]=_,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,C(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],x[a+40|0]=1,e<<3;x[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 Rv.Instance(new Rv.Module(t,n))})}}},RuntimeError:Error};Ev=[],"object"!=typeof Rv&&Pv("no native wasm support detected");var Dv=new Rv.Table({initial:1,maximum:1,element:"anyfunc"}),Iv=!1;function Nv(e,t){e||Kv("Assertion failed: "+t)}function Ov(e){var t=mv["_"+e];return Nv(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function Fv(e,t,n,r){var i={string:function(e){var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);t=dg(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,Vv,t,n)}return t},array:function(e){var t,n,r=dg(e.length);return t=e,n=r,Uv.set(t,n),r}};var a=Ov(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}(Vv,d,h):"":"boolean"===t?Boolean(u):u,0!==s&&hg(s),p}var Bv="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var zv,Uv,Vv,kv;var Gv,jv=mv.TOTAL_MEMORY||16777216;function Wv(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 _(1,"no header found");if(!(n=t.match(/^#\?(\S+)$/)))return _(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:_(3,"missing image size specifier"):_(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 _(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 _(3,"bad rgbe scanline format");for(c=0;c=2.0 are supported."));else{var c=o.asset.generator||"";if(-1\n\nvec3 getSample(float theta, vec3 axis) {\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 return bilinearCubeUV(envMap, sampleDirection, lodIdx);\n}\n\nvoid main() {\n vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n if (all(equal(axis, vec3(0.0))))\n axis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);\n axis = normalize(axis);\n gl_FragColor = vec4(0.0);\n gl_FragColor.rgb += weights[0] * getSample(0.0, axis);\n for (int i = 1; i < n; i++) {\n if (i >= samples)\n break;\n float theta = dTheta * float(i);\n gl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);\n gl_FragColor.rgb += weights[i] * getSample(theta, axis);\n }\n gl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n "),blending:ae,depthTest:!1,depthWrite:!1})).type="SphericalGaussianBlur",v_),b_=null,w_=null,M_=u_.map(function(e,t){for(var n=1/(d_(t)-1),r=-n/2,i=1+n/2,a=[r,r,i,r,i,i,r,r,i,i,r,i],o=new Float32Array(108),s=new Float32Array(72),l=new Float32Array(36),c=0;c<6;c++){var u=c%3*2/3-1,d=2\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 j_(e){return"".concat(e%1?e:"".concat(e,".0"))}function W_(e,t,n,r,i){tv.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 X_(e,t){var n=(this.sourceTexture=e).image.width,r=e.image.height,i={format:lt,magFilter:Je,minFilter:1008,type:t,generateMipmaps:!0,anisotropy:e.anisotropy,encoding:Mt,wrapS:e.wrapS,wrapT:e.wrapT};this.renderTarget=new tn(n,r,i),this.renderTarget.texture.name=e.name,this.renderTarget.texture.flipY=e.flipY,this.camera=new Ki(-1,1,1,-1,0,1),this.shader=new zi({type:"RGBEToFloat",uniforms:Oi.clone(ta.copy.uniforms),vertexShader:ta.copy.vertexShader,fragmentShader:ta.copy.fragmentShader,defines:{MAP_TEXELS:1}}),this.planeMesh=new Mi(new $i(2,2,0),this.shader),this.planeMesh.material.map=e,this.scene=new On,this.scene.add(this.planeMesh),this.scene.add(this.camera),this.shader.uniforms.tDiffuse.value=e,this.shader.uniforms.opacity.value=1}L_.prototype={constructor:L_,fromScene:function(e){var t=1