function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);nthis.length)&&(t=this.length),this.substring(t-e.length,t)===e}),Object.assign(a.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){var n,i;void 0!==this._listeners&&(void 0===(n=this._listeners[e])||-1!==(i=n.indexOf(t))&&n.splice(i,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),i=0,r=n.length;i>8&255]+Zt[e>>16&255]+Zt[e>>24&255]+"-"+Zt[255&t]+Zt[t>>8&255]+"-"+Zt[t>>16&15|64]+Zt[t>>24&255]+"-"+Zt[63&n|128]+Zt[n>>8&255]+"-"+Zt[n>>16&255]+Zt[n>>24&255]+Zt[255&i]+Zt[i>>8&255]+Zt[i>>16&255]+Zt[i>>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,i,r){return i+(e-t)*(r-i)/(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*Jt.DEG2RAD},radToDeg:function(e){return e*Jt.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,i,r){var o=Math.cos,a=Math.sin,s=o(n/2),l=a(n/2),c=o((t+i)/2),u=a((t+i)/2),d=o((t-i)/2),h=a((t-i)/2),f=o((i-t)/2),p=a((i-t)/2);"XYX"===r?e.set(s*u,l*d,l*h,s*c):"YZY"===r?e.set(l*h,s*u,l*d,s*c):"ZXZ"===r?e.set(l*d,l*h,s*u,s*c):"XZX"===r?e.set(s*u,l*p,l*f,s*c):"YXY"===r?e.set(l*f,s*u,l*p,s*c):"ZYZ"===r?e.set(l*p,l*f,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,i){var r=Math.exp(-n/i);return e*r+(1-r)*t},expAverageClamp:function(e,t,n,i,r){var o=this.expAverage(e,t,n,i);return Math.abs(e-t)Number.EPSILON&&(u=Math.sqrt(c),d=Math.atan2(u,s*l),h=Math.sin(h*d)/u,a=Math.sin(a*d)/u),m=m*h+x*(f=a*l),v=v*h+y*f,g=g*h+b*f,_=_*h+M*f,h===1-a&&(m*=p=1/Math.sqrt(m*m+v*v+g*g+_*_),v*=p,g*=p,_*=p)),e[t]=m,e[t+1]=v,e[t+2]=g,e[t+3]=_}}),Object.defineProperties(ln.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(ln.prototype,{isQuaternion:!0,set:function(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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,i=e._y,r=e._z,o=e.order,a=Math.cos,s=Math.sin,l=a(n/2),c=a(i/2),u=a(r/2),d=s(n/2),h=s(i/2),f=s(r/2);return"XYZ"===o?(this._x=d*c*u+l*h*f,this._y=l*h*u-d*c*f,this._z=l*c*f+d*h*u,this._w=l*c*u-d*h*f):"YXZ"===o?(this._x=d*c*u+l*h*f,this._y=l*h*u-d*c*f,this._z=l*c*f-d*h*u,this._w=l*c*u+d*h*f):"ZXY"===o?(this._x=d*c*u-l*h*f,this._y=l*h*u+d*c*f,this._z=l*c*f+d*h*u,this._w=l*c*u-d*h*f):"ZYX"===o?(this._x=d*c*u-l*h*f,this._y=l*h*u+d*c*f,this._z=l*c*f-d*h*u,this._w=l*c*u+d*h*f):"YZX"===o?(this._x=d*c*u+l*h*f,this._y=l*h*u+d*c*f,this._z=l*c*f-d*h*u,this._w=l*c*u-d*h*f):"XZY"===o&&(this._x=d*c*u-l*h*f,this._y=l*h*u-d*c*f,this._z=l*c*f+d*h*u,this._w=l*c*u+d*h*f),!1!==t&&this._onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,i=n[0],r=n[4],o=n[8],a=n[1],s=n[5],l=n[9],c=n[2],u=n[6],d=n[10],h=i+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(Jt.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var n=this.angleTo(e);if(0===n)return this;var i=Math.min(1,t/n);return this.slerp(e,i),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,i=e._y,r=e._z,o=e._w,a=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+o*a+i*l-r*s,this._y=i*c+o*s+r*a-n*l,this._z=r*c+o*l+n*s-i*a,this._w=o*c-n*a-i*s-r*l,this._onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,i=this._y,r=this._z,o=this._w,a=o*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),1<=a)return this._w=o,this._x=n,this._y=i,this._z=r,this;var s=1-a*a;if(s<=Number.EPSILON){var l=1-t;return this._w=l*o+t*this._w,this._x=l*n+t*this._x,this._y=l*i+t*this._y,this._z=l*r+t*this._z,this.normalize(),this._onChangeCallback(),this}var c=Math.sqrt(s),u=Math.atan2(c,a),d=Math.sin((1-t)*u)/c,h=Math.sin(t*u)/c;return this._w=o*d+this._w*h,this._x=n*d+this._x*h,this._y=i*d+this._y*h,this._z=r*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 cn=new dn,un=new ln;function dn(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}Object.assign(dn.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(un.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(un.setFromAxisAngle(e,t))},applyMatrix3:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this},applyNormalMatrix:function(e){return this.applyMatrix3(e).normalize()},applyMatrix4:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this},applyQuaternion:function(e){var t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,s=e.w,l=s*t+o*i-a*n,c=s*n+a*t-r*i,u=s*i+r*n-o*t,d=-r*t-o*n-a*i;return this.x=l*s+d*-r+c*-a-u*-o,this.y=c*s+d*-o+u*-r-l*-a,this.z=u*s+d*-a+l*-o-c*-r,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,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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,i=e.y,r=e.z,o=t.x,a=t.y,s=t.z;return this.x=i*s-r*a,this.y=r*o-n*s,this.z=n*a-i*o,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 cn.copy(this).projectOnVector(e),this.sub(cn)},reflect:function(e){return this.sub(cn.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(Jt.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,i=this.z-e.z;return t*t+n*n+i*i},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 i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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 hn=new dn,fn=new xn,pn=new dn(0,0,0),mn=new dn(1,1,1),vn=new dn,gn=new dn,_n=new dn;function xn(){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($n.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,i=1/0,r=-1/0,o=-1/0,a=-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 dn),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,Gn),Gn.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var t,n=0=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(Zn),Qn.subVectors(this.max,Zn),jn.subVectors(e.a,Zn),Wn.subVectors(e.b,Zn),Hn.subVectors(e.c,Zn),Xn.subVectors(Wn,jn),Yn.subVectors(Hn,Wn),qn.subVectors(jn,Hn);var t=[0,-Xn.z,Xn.y,0,-Yn.z,Yn.y,0,-qn.z,qn.y,Xn.z,0,-Xn.x,Yn.z,0,-Yn.x,qn.z,0,-qn.x,-Xn.y,Xn.x,0,-Yn.y,Yn.x,0,-qn.y,qn.x,0];return!!ei(t,jn,Wn,Hn,Qn)&&(!!ei(t=[1,0,0,0,1,0,0,0,1],jn,Wn,Hn,Qn)&&(Kn.crossVectors(Xn,Yn),ei(t=[Kn.x,Kn.y,Kn.z],jn,Wn,Hn,Qn)))},clampPoint:function(e,t){return void 0===t&&(console.warn("v3d.Box3: .clampPoint() target is now required"),t=new dn),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return Gn.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(Gn).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()||(zn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zn)),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 ti,ni,ii=new $n;function ri(e,t){this.center=void 0!==e?e:new dn,this.radius=void 0!==t?t:0}Object.assign(ri.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):ii.setFromPoints(e).getCenter(n);for(var i=0,r=0,o=e.length;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("v3d.Sphere: .getBoundingBox() target is now required"),e=new $n),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius},union:(ti=new dn,ni=new dn,function(e){var t=this.center,n=this.radius,i=e.center,r=e.radius;ti.subVectors(i,t);var o=ti.length();if(o+r<=n)return this;if(o+n<=r)return this.copy(e),this;var a=.5*(n+o+r);return ni.copy(ti).multiplyScalar((a-n)/o),ni.add(t),this.center.copy(ni),this.radius=a,this})});var oi=new dn,ai=new dn,si=new dn,li=new dn,ci=new dn,ui=new dn,di=new dn;function hi(e,t){this.origin=void 0!==e?e:new dn,this.direction=void 0!==t?t:new dn(0,0,-1)}Object.assign(hi.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 dn),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,oi)),this},closestPointToPoint:function(e,t){void 0===t&&(console.warn("v3d.Ray: .closestPointToPoint() target is now required"),t=new dn),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=oi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(oi.copy(this.direction).multiplyScalar(t).add(this.origin),oi.distanceToSquared(e))},distanceSqToSegment:function(e,t,n,i){ai.copy(e).add(t).multiplyScalar(.5),si.copy(t).sub(e).normalize(),li.copy(this.origin).sub(ai);var r,o,a,s,l,c=.5*e.distanceTo(t),u=-this.direction.dot(si),d=li.dot(this.direction),h=-li.dot(si),f=li.lengthSq(),p=Math.abs(1-u*u);return o=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){var i,r;return e=Jt.euclideanModulo(e,1),t=Jt.clamp(t,0,1),n=Jt.clamp(n,0,1),0===t?this.r=this.g=this.b=n:(r=2*n-(i=n<=.5?n*(1+t):n+t-n*t),this.r=Oi(r,i,e+1/3),this.g=Oi(r,i,e),this.b=Oi(r,i,e-1/3)),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 i,r=n[1],o=n[2];switch(r){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,e(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,e(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,l=parseInt(i[3],10)/100;return e(i[5]),this.setHSL(a,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 $i(e){return void 0!==e}function er(e,t,n){for(var i=0;in.far?null:{distance:c,point:Cr.clone(),object:e}}function Or(e,t,n,i,r,o,a,s,l,c,u,d){vr.fromBufferAttribute(r,c),gr.fromBufferAttribute(r,u),_r.fromBufferAttribute(r,d);var h=e.morphTargetInfluences;if(t.morphTargets&&o&&h){Mr.set(0,0,0),wr.set(0,0,0),Sr.set(0,0,0);for(var f=0,p=o.length;f"," #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")},r=new Hr({type:"CubemapFromEquirect",uniforms:zr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Re,blending:oe});r.uniforms.tEquirect.value=t;var o=new Pr(new Ur(5,5,5),r);n.add(o);var a=new qr(1,10,1);return a.renderTarget=this,a.renderTarget.texture.name="CubeCameraTexture",a.update(e,n),o.geometry.dispose(),o.material.dispose(),this},((Qr.prototype=Object.create(rn.prototype)).constructor=Qr).prototype.isDataTexture=!0;var Kr=new ri,Jr=new dn;function $r(e,t,n,i,r,o){this.planes=[void 0!==e?e:new vi,void 0!==t?t:new vi,void 0!==n?n:new vi,void 0!==i?i:new vi,void 0!==r?r:new vi,void 0!==o?o:new vi]}Object.assign($r.prototype,{set:function(e,t,n,i,r,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),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,i=n[0],r=n[1],o=n[2],a=n[3],s=n[4],l=n[5],c=n[6],u=n[7],d=n[8],h=n[9],f=n[10],p=n[11],m=n[12],v=n[13],g=n[14],_=n[15];return t[0].setComponents(a-i,u-s,p-d,_-m).normalize(),t[1].setComponents(a+i,u+s,p+d,_+m).normalize(),t[2].setComponents(a+r,u+l,p+h,_+v).normalize(),t[3].setComponents(a-r,u-l,p-h,_-v).normalize(),t[4].setComponents(a-o,u-c,p-f,_-g).normalize(),t[5].setComponents(a+o,u+c,p+f,_+g).normalize(),this},intersectsObject:function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Kr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Kr)},intersectsSprite:function(e){return Kr.center.set(0,0,0),Kr.radius=.7071067811865476,Kr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Kr)},intersectsSphere:function(e){for(var t=this.planes,n=e.center,i=-e.radius,r=0;r<6;r++){if(t[r].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}\nvec3 vec3RotateAxisAngle(vec3 vector, vec3 axis, float angle) {\nvec3 axisNorm = normalize(axis);\nfloat x = axisNorm.x, y = axisNorm.y, z = axisNorm.z;\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\nx * x * (1.0 - c) + c, x * y * (1.0 - c) + z * s, x * z * (1.0 - c) - y * s,\nx * y * (1.0 - c) - z * s, y * y * (1.0 - c) + c, y * z * (1.0 - c) + x * s,\nx * z * (1.0 - c) + y * s, y * z * (1.0 - c) - x * s, z * z * (1.0 - c) + c\n) * vector;\n}\nvec3 vec3RotateXAngle(vec3 vector, float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\n1.0, 0.0, 0.0,\n0.0, c, s,\n0.0, -s, c\n) * vector;\n}\nvec3 vec3RotateYAngle(vec3 vector, float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\nc, 0.0, -s,\n0.0, 1.0, 0.0,\ns, 0.0, c\n) * vector;\n}\nvec3 vec3RotateZAngle(vec3 vector, float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\nc, s, 0.0,\n-s, c, 0.0,\n0.0, 0.0, 1.0\n) * vector;\n}\nvec4 eulerToAxisAngle(vec3 euler) {\nfloat c1 = cos(euler.x / 2.0), c2 = cos(euler.y / 2.0), c3 = cos(euler.z / 2.0);\nfloat s1 = sin(euler.x / 2.0), s2 = sin(euler.y / 2.0), s3 = sin(euler.z / 2.0);\nvec4 axisAngle = vec4(\ns1 * c2 * c3 - c1 * s2 * s3,\nc1 * s2 * c3 + s1 * c2 * s3,\nc1 * c2 * s3 - s1 * s2 * c3,\n2.0 * acos(c1 * c2 * c3 + s1 * s2 * s3)\n);\naxisAngle.xyz = length(axisAngle.xyz) > 0.0 ? normalize(axisAngle.xyz) : vec3(1.0, 0.0, 0.0);\nreturn axisAngle;\n}\nfloat mat3GetDeterminant(mat3 mat) {\nreturn mat[0][0] * mat[1][1] * mat[2][2]\n+ mat[0][2] * mat[1][0] * mat[2][1]\n+ mat[0][1] * mat[1][2] * mat[2][0]\n- mat[0][2] * mat[1][1] * mat[2][0]\n- mat[0][0] * mat[1][2] * mat[2][1]\n- mat[0][1] * mat[1][0] * mat[2][2];\n}\nmat3 mat3GetInverseTransposed(mat3 mat) {\nfloat det = mat3GetDeterminant(mat);\nfloat a00 = (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) / det;\nfloat a01 = - (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) / det;\nfloat a02 = (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]) / det;\nfloat a10 = - (mat[0][1] * mat[2][2] - mat[0][2] * mat[2][1]) / det;\nfloat a11 = (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]) / det;\nfloat a12 = - (mat[0][0] * mat[2][1] - mat[0][1] * mat[2][0]) / det;\nfloat a20 = (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]) / det;\nfloat a21 = - (mat[0][0] * mat[1][2] - mat[0][2] * mat[1][0]) / det;\nfloat a22 = (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) / det;\nreturn mat3(\na00, a01, a02,\na10, a11, a12,\na20, a21, a22\n);\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}\nvec2 getUVPixels(vec3 direction, float lodIdx) {\nfloat face = getFace(direction);\nfloat faceSize = getLodTileSize(lodIdx);\nfloat filterLevel = getLodFilterLevel(lodIdx);\nvec2 uv = getUV(direction, face);\nuv = fixCubeUVSeams(uv, faceSize);\nuv *= (faceSize - 1.0);\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);\nreturn uv;\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float lodIdx) {\nfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\nvec2 uv = getUVPixels(direction, lodIdx);\nvec2 f = fract(uv);\nuv += 0.5 - f;\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}\nvec3 sampleCubeUV(sampler2D envMap, vec3 direction, float lodIdx) {\nfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\nvec2 uv = getUVPixels(direction, lodIdx);\nuv += 0.5;\nuv *= texelSize;\nreturn envMapTexelToLinear(texture2D(envMap, uv)).rgb;\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 = sampleCubeUV(envMap, sampleDir, lodIdxI);\nif (lodIdxF == 0.0) {\nreturn vec4(color0, 1.0);\n} else {\nvec3 color1 = sampleCubeUV(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;\nfloat shadowCameraNear;\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 vec3 iblIrradiance,\nconst in GeometricContext geometry, const in ToonMaterial material,\ninout 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 vec3 iblIrradiance,\nconst in GeometricContext geometry, const in BlinnPhongMaterial material,\ninout 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 vec3 iblIrradiance,\nconst in GeometricContext geometry, const in PhysicalMaterial material,\ninout 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) || defined(RE_DirectDiffuse) || defined(RE_DirectSpecular))\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\n#if defined(RE_Direct)\nRE_Direct(directLight, geometry, material, reflectedLight);\n#else\n#if defined(RE_DirectDiffuse)\nRE_DirectDiffuse(directLight, geometry, material, reflectedLight);\n#endif\n#if defined(RE_DirectSpecular)\nRE_DirectSpecular(directLight, geometry, material, reflectedLight);\n#endif\n#endif\n}\n#endif\n#if (NUM_SPOT_LIGHTS > 0) && (defined(RE_Direct) || defined(RE_DirectDiffuse) || defined(RE_DirectSpecular))\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\n#if defined(RE_Direct)\nRE_Direct(directLight, geometry, material, reflectedLight);\n#else\n#if defined(RE_DirectDiffuse)\nRE_DirectDiffuse(directLight, geometry, material, reflectedLight);\n#endif\n#if defined(RE_DirectSpecular)\nRE_DirectSpecular(directLight, geometry, material, reflectedLight);\n#endif\n#endif\n}\n#endif\n#if (NUM_DIR_LIGHTS > 0) && (defined(RE_Direct) || defined(RE_DirectDiffuse) || defined(RE_DirectSpecular))\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- directionalLight.direction * directionalLight.shadowCameraNear\n- geometry.position, 0.0)).xyz);\n#endif\ndirectLight.color *= all(bvec3(directLight.visible, receiveShadow,\nvViewPosition.z < directionalLight.maxDistance))\n? getDirShadow(directionalLight, directionalShadowMap[i],\nvDirectionalShadowCoord[i], distWorld) : 1.0;\n#endif\n#if defined(RE_Direct)\nRE_Direct(directLight, geometry, material, reflectedLight);\n#else\n#if defined(RE_DirectDiffuse)\nRE_DirectDiffuse(directLight, geometry, material, reflectedLight);\n#endif\n#if defined(RE_DirectSpecular)\nRE_DirectSpecular(directLight, geometry, material, reflectedLight);\n#endif\n#endif\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) || defined(RE_IndirectSpecular)\nvec3 iblIrradiance = vec3(0.0);\n#endif\n#if defined(RE_IndirectDiffuse)\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)\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)\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, iblIrradiance, 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)\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 BIAS_FRUSTUM_SCALE_COEFF 30.0\n#define ESM_SPOT_SINGLE_BLUR_COEFF 0.25\n#define PCF_POISSON_SPOT_OMNI_BLUR_COEFF 4.0\n#define PCF_POISSON_POINT_BLUR_COEFF 2.5\n#define PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF 0.5\n#define ESM_BIAS_COEFF 100.0\n#ifndef ESM_DISTANCE_SCALE\n#define ESM_DISTANCE_SCALE 1.0\n#endif\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}\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 texture2DShadowAvgCube(sampler2D depths, vec2 size, vec3 bd3D, float compare) {\nvec2 texelSize = vec2(1.0) / size;\nvec3 dirX = normalize(abs(bd3D.y) < 0.99999 ? vec3(bd3D.z, 0.0, -bd3D.x)\n: vec3(0.0, -bd3D.z, bd3D.y));\nvec3 dirY = cross(bd3D, dirX);\nfloat theta = PI_HALF * texelSize.y;\nvec3 sX = sin(theta) * dirX;\nvec3 sY = sin(theta) * dirY;\nfloat cosT = cos(theta);\nvec3 sampleVec[4];\nsampleVec[0] = bd3D;\nsampleVec[1] = bd3D * cosT + sY;\nsampleVec[2] = bd3D * cosT + sX;\nsampleVec[3] = sampleVec[2] * cosT + sY;\nfloat avg = 0.0;\nfor (int i = 0; i < 4; i++) {\navg += texture2DCompare(depths, cubeToUV(sampleVec[i], texelSize.y), compare);\n}\navg /= 4.0;\nreturn avg;\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_BILINEAR)\nshadowCoord.z += shadowBias;\nshadow = texture2DShadowLerp(shadowMap, shadowMapSize,\nshadowCoord.xy, shadowCoord.z);\n#elif 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;\nvec2 offsetVec[9];\noffsetVec[0] = vec2(dx0, dy0);\noffsetVec[1] = vec2(0.0, dy0);\noffsetVec[2] = vec2(dx1, dy0);\noffsetVec[3] = vec2(dx0, 0.0);\noffsetVec[4] = vec2(0.0);\noffsetVec[5] = vec2(dx1, 0.0);\noffsetVec[6] = vec2(dx0, dy1);\noffsetVec[7] = vec2(0.0, dy1);\noffsetVec[8] = vec2(dx1, dy1);\nshadow = 0.0;\nfor (int i = 0; i < 9; i++) {\nshadow += texture2DCompare(shadowMap, shadowCoord.xy + offsetVec[i], shadowCoord.z);\n}\nshadow /= 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;\nvec2 offsetVec[9];\noffsetVec[0] = vec2(dx0, dy0);\noffsetVec[1] = vec2(0.0, dy0);\noffsetVec[2] = vec2(dx1, dy0);\noffsetVec[3] = vec2(dx0, 0.0);\noffsetVec[4] = vec2(0.0);\noffsetVec[5] = vec2(dx1, 0.0);\noffsetVec[6] = vec2(dx0, dy1);\noffsetVec[7] = vec2(0.0, dy1);\noffsetVec[8] = vec2(dx1, dy1);\nshadow = 0.0;\nfor (int i = 0; i < 9; i++) {\nshadow += texture2DShadowLerp(shadowMap, shadowMapSize,\nshadowCoord.xy + offsetVec[i], shadowCoord.z);\n}\nshadow /= 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);\nvec2 sampleVec[16];\nsampleVec[0] = POISSON_DISK_0[0].xy;\nsampleVec[1] = POISSON_DISK_0[0].zw;\nsampleVec[2] = POISSON_DISK_0[1].xy;\nsampleVec[3] = POISSON_DISK_0[1].zw;\nsampleVec[4] = POISSON_DISK_0[2].xy;\nsampleVec[5] = POISSON_DISK_0[2].zw;\nsampleVec[6] = POISSON_DISK_0[3].xy;\nsampleVec[7] = POISSON_DISK_0[3].zw;\nsampleVec[8] = POISSON_DISK_1[0].xy;\nsampleVec[9] = POISSON_DISK_1[0].zw;\nsampleVec[10] = POISSON_DISK_1[1].xy;\nsampleVec[11] = POISSON_DISK_1[1].zw;\nsampleVec[12] = POISSON_DISK_1[2].xy;\nsampleVec[13] = POISSON_DISK_1[2].zw;\nsampleVec[14] = POISSON_DISK_1[3].xy;\nsampleVec[15] = POISSON_DISK_1[3].zw;\nshadow = 0.0;\nfor (int i = 0; i < 16; i++) {\nshadow += texture2DCompare(shadowMap, shadowCoord.xy\n+ sampleMat * sampleVec[i], shadowCoord.z);\n}\nshadow /= 16.0;\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap, shadowCoord.xy).x\n- length(distWorld) * ESM_DISTANCE_SCALE\n- ESM_BIAS_COEFF * shadowBias)));\n#else\nshadowCoord.z += shadowBias;\nshadow = texture2DCompare(shadowMap, shadowCoord.xy, shadowCoord.z);\n#endif\n}\nreturn shadow;\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) {\nfloat biasScaleCoeff = BIAS_FRUSTUM_SCALE_COEFF\n/ (shadowCameraFar - shadowCameraNear);\ndp += shadowBias * biasScaleCoeff;\nvec3 bd3D = normalize(lightToPosition);\nvec2 texelSize = 1.0 / shadowMapSize;\n#if defined(SHADOWMAP_TYPE_BILINEAR)\nshadow = texture2DShadowAvgCube(shadowMap, shadowMapSize, bd3D, dp);\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap,\ncubeVecToOctUV(bd3D, texelSize)).x\n- length(lightToPosition) * ESM_DISTANCE_SCALE\n- ESM_BIAS_COEFF * shadowBias)));\n#elif defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nvec2 offset = vec2(-1, 1) * shadowRadius * texelSize.y;\nvec3 offsetVec[9];\noffsetVec[0] = offset.xyy;\noffsetVec[1] = offset.yyy;\noffsetVec[2] = offset.xyx;\noffsetVec[3] = offset.yyx;\noffsetVec[4] = vec3(0.0);\noffsetVec[5] = offset.xxy;\noffsetVec[6] = offset.yxy;\noffsetVec[7] = offset.xxx;\noffsetVec[8] = offset.yxx;\nshadow = 0.0;\nfor (int i = 0; i < 9; i++) {\nshadow += texture2DCompare(shadowMap, cubeToUV(bd3D + offsetVec[i], texelSize.y), dp);\n}\nshadow /= 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);\nvec2 sampleVec[16];\nsampleVec[0] = POISSON_DISK_0[0].xy;\nsampleVec[1] = POISSON_DISK_0[0].zw;\nsampleVec[2] = POISSON_DISK_0[1].xy;\nsampleVec[3] = POISSON_DISK_0[1].zw;\nsampleVec[4] = POISSON_DISK_0[2].xy;\nsampleVec[5] = POISSON_DISK_0[2].zw;\nsampleVec[6] = POISSON_DISK_0[3].xy;\nsampleVec[7] = POISSON_DISK_0[3].zw;\nsampleVec[8] = POISSON_DISK_1[0].xy;\nsampleVec[9] = POISSON_DISK_1[0].zw;\nsampleVec[10] = POISSON_DISK_1[1].xy;\nsampleVec[11] = POISSON_DISK_1[1].zw;\nsampleVec[12] = POISSON_DISK_1[2].xy;\nsampleVec[13] = POISSON_DISK_1[2].zw;\nsampleVec[14] = POISSON_DISK_1[3].xy;\nsampleVec[15] = POISSON_DISK_1[3].zw;\nshadow = 0.0;\nfor (int i = 0; i < 16; i++) {\nshadow += texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * sampleVec[i], 0.0), texelSize.y), dp);\n}\nshadow /= 16.0;\n#else\nshadow = texture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp);\n#endif\n}\nreturn shadow;\n}\n#if NUM_DIR_LIGHT_SHADOWS > 0\nfloat getDirShadow(DirectionalLight light, sampler2D shadowMap,\nvec4 shadowCoord, float distWorld) {\nfloat shadowRadius = light.shadowRadius;\n#if defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowRadius *= PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF;\n#endif\nreturn getShadow(shadowMap, light.shadowMapSize, light.shadowBias,\nlight.expBias, shadowRadius, shadowCoord, distWorld);\n}\n#endif\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 *= 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 *= 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_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowRadius *= PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF;\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadowRadius *= ESM_SPOT_SINGLE_BLUR_COEFF;\n#endif\nshadowBias *= BIAS_FRUSTUM_SCALE_COEFF\n/ (light.shadowCameraFar - light.shadowCameraNear);\n#if defined(SHADOWMAP_TYPE_BASIC) || defined(SHADOWMAP_TYPE_BILINEAR) || defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT) || 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- directionalLight.direction * directionalLight.shadowCameraNear\n+ vViewPosition, 0.0)).xyz);\n#endif\nshadow *= all(bvec2(vViewPosition.z < directionalLight.maxDistance,\nreceiveShadow)) ? getDirShadow(directionalLight,\ndirectionalShadowMap[i], vDirectionalShadowCoord[i], distWorld)\n: 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-6), 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 \n#ifndef DISTANCE_SCALE\n#define DISTANCE_SCALE 1.0\n#endif\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\n#ifdef USE_SLOPE_SCALED_BIAS\nvec2 dxdy = abs(vec2(dFdx(dist), dFdy(dist)));\ndist += slopeScaledBias * max(dxdy.x, dxdy.y);\n#endif\ngl_FragColor = vec4(dist * DISTANCE_SCALE, 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(NODE_TANGENT_BL) || defined(NODE_BITMAP_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_NOISE_MX) || defined(NODE_SAMPLER_INFO_MY) || (defined(NODE_NORMAL) && defined(MT_BLENDER)) || defined(USE_OSL) || 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))\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) || (defined(NODE_NORMAL) && defined(MT_BLENDER)) || defined(USE_OSL)\nuniform mat4 projectionMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_TEX_COORD_BL) || defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_TANGENT_BL) || defined(NODE_BITMAP_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_NOISE_MX) || defined(NODE_SAMPLER_INFO_MY) || defined(USE_OSL)\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_BUMP_2D_MY) || defined(NODE_SAMPLER_INFO_MY)\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) || defined(NODE_TANGENT_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_DirectDiffuse_Node(const in IncidentLight directLight,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout 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));\nfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox(material.clearcoatRoughness, ccDotNL);\n#else\nfloat clearcoatDHR = 0.0;\n#endif\nreflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance\n* BRDF_Diffuse_Lambert(material.diffuseColor);\n#else\nreflectedLight.directDiffuse += irradiance * material.diffuseIntensity\n* BRDF_Diffuse_Lambert(material.diffuseColor);\n#endif\n}\nvoid RE_DirectSpecular_Node(const in IncidentLight directLight,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout 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);\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.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 vec3 iblIrradiance,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += (irradiance + iblIrradiance)\n* BRDF_Diffuse_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectSpecular_Node(const in vec3 radiance, const in vec3 irradiance,\nconst in vec3 clearcoatRadiance, const in GeometricContext geometry,\nconst in NodeMaterial material, inout ReflectedLight reflectedLight) {\n#ifdef PHYSICAL\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\n#endif\n}\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_RectArea RE_Direct_RectArea_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) || defined(USE_OSL)\n#define HSV_NODES\n#endif\n#if defined 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\n#endif\n#if defined(NODE_BITMAP_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_PLACE_2D_TEXTURE_MY)\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 c = cos(-wAngle);\nfloat s = sin(-wAngle);\n#if defined(NODE_PLACE_2D_TEXTURE_MY)\nfloat tx = uOffset;\nfloat ty = vOffset;\nfloat cx = 0.5;\nfloat cy = 0.5;\nreturn mat3(c*sx, s*sx, 0.0,\n-s*sy, c*sy, 0.0,\ns*(ty+sy-cy)+c*(tx-cx)+cx, -c*(ty+sy-cy)+s*(tx-cx)-cy+1.0, 1.0);\n#else\nfloat tx = -uOffset;\nfloat ty = -vOffset;\nfloat cx = uOffset + 0.5;\nfloat cy = vOffset + 0.5;\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#endif\n}\n#endif\n#if defined(NODE_NOISE_MX)\nmat4 calcXYZTransform(vec3 offset, vec3 tiling, vec3 angle) {\nmat4 rot = mat4(\ncos(angle.y)*cos(angle.z), cos(angle.x)*sin(angle.z)+sin(angle.x)*sin(angle.y)*cos(angle.z), sin(angle.x)*sin(angle.z)-cos(angle.x)*sin(angle.y)*cos(angle.z), 0.0,\n-cos(angle.y)*sin(angle.z), cos(angle.x)*cos(angle.z)-sin(angle.x)*sin(angle.y)*sin(angle.z), cos(angle.x)*sin(angle.y)*sin(angle.z)+sin(angle.x)*cos(angle.z), 0.0,\nsin(angle.y), -sin(angle.x)*cos(angle.y), cos(angle.x)*cos(angle.y), 0.0,\n0.0, 0.0, 0.0, 1.0\n);\nmat4 til = mat4(\ntiling.x, 0.0, 0.0, 0.0,\n0.0, tiling.y, 0.0, 0.0,\n0.0, 0.0, tiling.z, 0.0,\n0.0, 0.0, 0.0, 1.0\n);\nmat4 off = mat4(\n1.0, 0.0, 0.0, 0.0,\n0.0, 1.0, 0.0, 0.0,\n0.0, 0.0, 1.0, 0.0,\noffset.x, offset.y, offset.z, 1.0\n);\nreturn (til * rot * off);\n}\n#endif\n#if defined(NODE_TEX_NOISE_BL) || defined(NODE_TEX_WAVE_BL) || defined(NODE_NOISE_MX) || defined(USE_OSL)\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 taylorInvSqrt(float 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}\nvec4 permute(vec4 x) {\nreturn mod(((x*34.0)+1.0)*x, 289.0);\n}\nfloat permute(float x) {\nreturn floor(mod(((x*34.0)+1.0)*x, 289.0));\n}\nvec4 grad4(float j, vec4 ip) {\nconst vec4 ones = vec4(1.0, 1.0, 1.0, -1.0);\nvec4 p,s;\np.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0;\np.w = 1.5 - dot(abs(p.xyz), ones.xyz);\ns = vec4(lessThan(p, vec4(0.0)));\np.xyz = p.xyz + (s.xyz*2.0 - 1.0) * s.www; \nreturn p;\n}\nfloat snoise(vec4 v) {\nconst vec2 C = vec2(0.138196601125010504,\n0.309016994374947451);\nvec4 i = floor(v + dot(v, C.yyyy) );\nvec4 x0 = v - i + dot(i, C.xxxx);\nvec4 i0;\nvec3 isX = step( x0.yzw, x0.xxx );\nvec3 isYZ = step( x0.zww, x0.yyz );\ni0.x = isX.x + isX.y + isX.z;\ni0.yzw = 1.0 - isX;\ni0.y += isYZ.x + isYZ.y;\ni0.zw += 1.0 - isYZ.xy;\ni0.z += isYZ.z;\ni0.w += 1.0 - isYZ.z;\nvec4 i3 = clamp( i0, 0.0, 1.0 );\nvec4 i2 = clamp( i0-1.0, 0.0, 1.0 );\nvec4 i1 = clamp( i0-2.0, 0.0, 1.0 );\nvec4 x1 = x0 - i1 + 1.0 * C.xxxx;\nvec4 x2 = x0 - i2 + 2.0 * C.xxxx;\nvec4 x3 = x0 - i3 + 3.0 * C.xxxx;\nvec4 x4 = x0 - 1.0 + 4.0 * C.xxxx;\ni = mod(i, 289.0);\nfloat j0 = permute( permute( permute( permute(i.w) + i.z) + i.y) + i.x);\nvec4 j1 = permute( permute( permute( permute (\ni.w + vec4(i1.w, i2.w, i3.w, 1.0 ))\n+ i.z + vec4(i1.z, i2.z, i3.z, 1.0 ))\n+ i.y + vec4(i1.y, i2.y, i3.y, 1.0 ))\n+ i.x + vec4(i1.x, i2.x, i3.x, 1.0 ));\nvec4 ip = vec4(1.0/294.0, 1.0/49.0, 1.0/7.0, 0.0) ;\nvec4 p0 = grad4(j0, ip);\nvec4 p1 = grad4(j1.x, ip);\nvec4 p2 = grad4(j1.y, ip);\nvec4 p3 = grad4(j1.z, ip);\nvec4 p4 = grad4(j1.w, ip);\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;\np4 *= taylorInvSqrt(dot(p4,p4));\nvec3 m0 = max(0.6 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.0);\nvec2 m1 = max(0.6 - vec2(dot(x3,x3), dot(x4,x4) ), 0.0);\nm0 = m0 * m0;\nm1 = m1 * m1;\nreturn 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 )))\n+ dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ;\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\n#ifdef USE_OSL\n#define OSL_3DSMAX_HLSL 0\n#define OSL_ALPHA 1\n#define OSL_ANISOTROPIC 2\n#define OSL_AVERAGE 3\n#define OSL_BANDWIDTH 4\n#define OSL_BLACK 5\n#define OSL_CAMERA 6\n#define OSL_CEIL 7\n#define OSL_CELL 8\n#define OSL_CHANNELS 9\n#define OSL_COLOR 10\n#define OSL_COLOR_BURN 11\n#define OSL_COLOR_DODGE 12\n#define OSL_COMMON 13\n#define OSL_DARKEN 14\n#define OSL_DEFAULT 15\n#define OSL_DIFFERENCE 16\n#define OSL_DIRECTION 17\n#define OSL_DIVIDE 18\n#define OSL_DO_FILTER 19\n#define OSL_EMPTY 20\n#define OSL_EXCLUSION 21\n#define OSL_GABOR 22\n#define OSL_GBUFID 23\n#define OSL_HARD_LIGHT 24\n#define OSL_HARD_MIX 25\n#define OSL_HASH 26\n#define OSL_HSV 27\n#define OSL_HUE 28\n#define OSL_IMPULSES 29\n#define OSL_LIGHTEN 30\n#define OSL_LINEAR_BURN 31\n#define OSL_LINEAR_DODGE 32\n#define OSL_MIRRORBALL 33\n#define OSL_MTLID 34\n#define OSL_MULTIPLY 35\n#define OSL_NODEHANDLE 36\n#define OSL_NODENAME 37\n#define OSL_NORMAL 38\n#define OSL_OBJECT 39\n#define OSL_OSL_VERSION 40\n#define OSL_OVERLAY 41\n#define OSL_PALIFE 42\n#define OSL_PERIODIC 43\n#define OSL_PERLIN 44\n#define OSL_PIN_LIGHT 45\n#define OSL_RENDERER_NAME 46\n#define OSL_RESET_TO_DEFAULT_VALUES 47\n#define OSL_RESOLUTION 48\n#define OSL_RGB 49\n#define OSL_ROUND 50\n#define OSL_SATURATION 51\n#define OSL_SCREEN 52\n#define OSL_SHADER 53\n#define OSL_SOFT_LIGHT 54\n#define OSL_SPHERICAL 55\n#define OSL_SPOTLIGHT 56\n#define OSL_SPOTLIGHT_BLEND 57\n#define OSL_SUBTRACT 58\n#define OSL_TRUNC 59\n#define OSL_UPERLIN 60\n#define OSL_USIMPLEX 61\n#define OSL_USR_ 62\n#define OSL_VALUE 63\n#define OSL_W 64\n#define OSL_WIRECOLOR 65\n#define OSL_WORLD 66\n#define OSL_WRAP 67\n#define OSL_XY 68\n#define OSL_YZ 69\n#define OSL_ZX 70\n#define OSL_ADD_LAYER 0\n#define OSL_DELETE_LAYER 0\n#define OSL_ADD_INPUT 0\n#define OSL_DELETE_INPUT 0\nvoid oslGetAttribute(int name, out int value) {\nif (name == OSL_RENDERER_NAME)\nvalue = 8;\nelse\nvalue = 0;\n}\nvoid oslGetAttribute(int name, out float value) {\nvalue = 0.0;\n}\nvoid oslGetAttribute(int name, out vec3 vec) {\nvec = vec3(0.0, 0.0, 0.0);\n}\nvec3 oslHSV(float h, float s, float v) {\nvec4 outCol;\nhsvToRGB(vec4(h, s, v, 1.0), outCol);\nreturn outCol.rgb;\n}\nvec3 oslTexture(sampler2D image, float u, float v, int wrapModeFlag, int wrapMode, int alphaFlag, out float alpha) {\nvec4 colAlpha = texture2D(image, vec2(u, v));\nalpha = colAlpha.a;\nreturn colAlpha.rgb;\n}\nvec3 oslTexture(sampler2D image, float u, float v, int alphaFlag, out float alpha, int wrapModeFlag, int wrapMode) {\nreturn oslTexture(image, u, v, OSL_WRAP, OSL_DEFAULT, alphaFlag, alpha);\n}\nvec3 oslTexture(sampler2D image, float u, float v, int alphaFlag, out float alpha) {\nreturn oslTexture(image, u, v, OSL_WRAP, OSL_DEFAULT, alphaFlag, alpha);\n}\nvec3 oslTexture(sampler2D image, float u, float v) {\nfloat alpha;\nreturn oslTexture(image, u, v, OSL_WRAP, OSL_DEFAULT, OSL_ALPHA, alpha);\n}\nfloat oslCellNoise(vec3 vec) {\nreturn snoise(vec4(vec, 0.0));\n}\nvoid oslGetTextureInfo(int filename, int name, out int value) {\nvalue = 4;\n}\nfloat oslNoise(int type, vec3 vec, float phase) {\nreturn snoise(vec4(vec, phase));\n}\nvec3 oslNoise3D(int type, vec3 vec, float phase) {\nfloat x = snoise(vec4(vec, phase));\nfloat y = snoise(vec4(vec.y, vec.x, vec.z, phase));\nfloat z = snoise(vec4(vec.y, vec.z, vec.x, phase));\nreturn vec3(x, y, z);\n}\nfloat oslPow(float a, float b) {\nreturn pow(a, b);\n}\nvec3 oslPow(vec3 a, float b) {\nreturn pow(a, vec3(b));\n}\nbool oslRayType(int name) {\nif (name == OSL_CAMERA)\n#if LIGHT_PATH_IS_CAM_RAY\nreturn true;\n#else\nreturn false;\n#endif\nelse\nreturn false;\n}\nvec3 oslTransform(int space, vec4 vec) {\nvec = vec4(swizzleUpY(vec.xyz), vec.w);\nif (space == OSL_WORLD || space == OSL_SHADER) {\nvec = invViewMatrix * vec;\nreturn swizzleUpZ(vec.xyz);\n} else if (space == OSL_OBJECT) {\nvec = invModelMatrix * invViewMatrix * vec;\nreturn swizzleUpZ(vec.xyz);\n} else if (space == OSL_CAMERA) {\nreturn vec.xyz;\n} else {\n}\n}\nvec3 oslTransform(int space, vec3 vec) {\nreturn oslTransform(space, vec4(vec, 1.0));\n}\nvec3 oslTransformC(int fromSpace, int toSpace, vec3 vec) {\nvec4 outVec = vec4(vec, 1.0);\nif (fromSpace == OSL_HSV && toSpace == OSL_RGB)\nhsvToRGB(vec4(vec, 1.0), outVec);\nelse if (fromSpace == OSL_RGB && toSpace == OSL_HSV)\nrgbToHSV(vec4(vec, 1.0), outVec);\nreturn outVec.rgb;\n}\nvec3 oslTransformC(int toSpace, vec3 vec) {\nreturn oslTransformC(OSL_RGB, toSpace, vec);\n}\nvec3 oslRotate(vec3 vec, float angle, vec3 p0, vec3 p1) {\nvec3 axis = normalize(p1 - p0);\nfloat c = cos(angle);\nfloat s = sin(angle);\nfloat x = axis[0];\nfloat y = axis[1];\nfloat z = axis[2];\nmat4 mat = mat4(\nx * x + (1.0 - x * x) * c, x * y * (1.0 - c) + z * s, x * z * (1.0 - c) - y * s, 0.0,\nx * y * (1.0 - c) - z * s, y * y + (1.0 - y * y) * c, y * z * (1.0 - c) + x * s, 0.0,\nx * z * (1.0 - c) + y * s, y * z * (1.0 - c) - x * s, z * z + (1.0 - z * z) * c, 0.0,\n0.0, 0.0, 0.0, 1.0\n);\nreturn (mat * vec4((vec - p0), 1.0) + vec4(p0, 1.0)).xyz;\n}\nvec3 oslRotate(vec3 vec, float angle, vec3 axis) {\nreturn oslRotate(vec, angle, vec3(0.0), axis);\n}\nfloat oslLuminance(vec3 color) {\nreturn (abs(color.r) * 0.263 + abs(color.g) * 0.655 + abs(color.b) * 0.082);\n}\n#endif",node_normal_frag:"void node_normal(vec3 norParam, out vec3 norOut)\n{\n#ifdef MT_BLENDER\n#if WORLD_NODES == 1\nvec4 viewDir = isOrtho(projectionMatrix) ? vec4(0.0, 0.0, -1.0, 0.0) : vec4(normalize(-vViewPosition), 0.0);\nviewDir = invViewMatrix * viewDir;\nnorOut = -swizzleUpZ(viewDir.xyz);\n#else\nnorOut = normalize(invViewMatrix * vec4(norParam, 0.0)).xyz;\nnorOut = swizzleUpZ(norOut);\n#endif\n#else\nnorOut = norParam;\n#endif\n}",node_position_frag:"void node_position(vec3 posParam, out vec3 posOut)\n{\n#if defined(MT_BLENDER) || defined(MT_MAX)\nposOut = swizzleUpZ(-posParam);\n#else\nposOut = -posParam;\n#endif\n}",node_rgb_alpha_frag:"\nuniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb_alpha(vec4 color, out vec3 outColor, out float outAlpha)\n{\noutColor = color.rgb;\noutAlpha = color.a;\n}",node_value_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#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_IndirectDiffuse\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 = normalize(normal);\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));\nvec3 refractedLight = vec3(0.0);\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include \n#include \n#include \n#undef RE_DirectSpecular\n#undef RE_IndirectSpecular\n#undef RE_Refraction\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\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#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectSpecular\n#undef RE_IndirectSpecular\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));\nvec3 refractedLight = vec3(0.0);\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#undef RE_Refraction\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));\nvec3 refractedLight = vec3(0.0);\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#define RE_Refraction RE_Refraction_Node\n#include \n#include \n#include \n#undef RE_Refraction\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\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#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_IndirectDiffuse\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 = max(min(value, maxVal), minVal);\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] += (fract(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;\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);\nmat3 mat;\nmat[0][0] = cy * cz;\nmat[0][1] = cy * sz;\nmat[0][2] = -sy;\nmat[1][0] = sy * sx * cz - cx * sz;\nmat[1][1] = sy * sx * sz + cx * cz;\nmat[1][2] = cy * sx;\nmat[2][0] = sy * cx * cz + sx * sz;\nmat[2][1] = sy * cx * sz - sx * cz;\nmat[2][2] = cy * cx;\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 {\nmat3 rot = rotationMatrix(rot.x, rot.y, rot.z) * mat3(\nscale[0], 0.0, 0.0,\n0.0, scale[1], 0.0,\n0.0, 0.0, scale[2]\n);\noutVec = normalize(mat3GetInverseTransposed(rot) * vec);\n}\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:"#define TANGENT_AXIS_X 0\n#define TANGENT_AXIS_Y 1\n#define TANGENT_AXIS_Z 2\nvoid node_tangent(int axis, vec3 viewPos, vec3 viewNorm, out vec3 outTangent) {\noutTangent = vec3(0.0);\n#if WORLD_NODES == 0\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nvec3 norWorld = normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz;\nvec3 posLocal = (invModelMatrix * posWorld).xyz;\nvec3 posOrco = (posLocal - boundingBoxMin)\n/ (boundingBoxMax - boundingBoxMin) - 0.5;\nvec4 posOrcoPermuted;\nif (axis == TANGENT_AXIS_X) {\nposOrcoPermuted = vec4(0.0, -posOrco.z, posOrco.y, 0.0);\n} else if (axis == TANGENT_AXIS_Y) {\nposOrcoPermuted = vec4(-posOrco.y, posOrco.x, 0.0, 0.0);\n} else if (axis == TANGENT_AXIS_Z) {\nposOrcoPermuted = vec4(posOrco.z, 0.0, -posOrco.x, 0.0);\n}\nvec3 tangWorld = (modelMatrix * posOrcoPermuted).xyz;\ntangWorld = cross(norWorld, normalize(cross(tangWorld, norWorld)));\noutTangent = swizzleUpZ(tangWorld);\n#endif\n}\nvoid node_tangent(vec4 tangent, out vec3 outTangent) {\n#if WORLD_NODES == 0\noutTangent = normalize((modelMatrix * vec4(tangent.xyz, 0.0)).xyz);\noutTangent = swizzleUpZ(outTangent);\n#endif\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_axis_angle(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nif (length(axis) > 0.0) {\nvector -= center;\noutVector = vec3RotateAxisAngle(vector, axis, invert * angle);\noutVector += center;\n} else {\noutVector = vector;\n}\n}\nvoid node_vector_rotate_euler_xyz(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvec4 axisAngle = eulerToAxisAngle(rotation);\nvector -= center;\noutVector = vec3RotateAxisAngle(vector, axisAngle.xyz, invert * axisAngle.w);\noutVector += center;\n}\nvoid node_vector_rotate_x_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateXAngle(vector, invert * angle);\noutVector += center;\n}\nvoid node_vector_rotate_y_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateYAngle(vector, invert * angle);\noutVector += center;\n}\nvoid node_vector_rotate_z_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateZAngle(vector, invert * angle);\noutVector += center;\n}",node_vertex_color_bl_frag:"void node_vertex_color(vec4 color, out vec4 outColor, out float outAlpha) {\noutColor = color;\noutAlpha = color.a;\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#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\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_matte_shadow_mx_frag:"void node_matte_shadow(\nvec3 normal, bool receiveShadow, float shadowBrightness, vec3 color,\nout vec4 outColor) {\nfloat shadow = 1.0;\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = (isOrthographic) ? vec3(0, 0, 1) : normalize(vViewPosition);\nIncidentLight directLight;\n#if NUM_POINT_LIGHTS > 0\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)\nshadow *= all(bvec2(directLight.visible, receiveShadow)) ?\ngetPointShadow(pointLight, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n#endif\n}\n#endif\n#if NUM_SPOT_LIGHTS > 0\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\nshadow *= getSpotShadow(spotLight, spotShadowMap[i],\nvSpotShadowCoord[i], distWorld);\n} else if (spotLight.shadow == 2) {\nshadow *= getSpotOmniShadow(spotLight, spotShadowMap[i], vSpotShadowCoord[i]);\n}\n}\n#endif\n}\n#endif\n#if NUM_DIR_LIGHTS > 0\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- directionalLight.direction * directionalLight.shadowCameraNear\n- geometry.position, 0.0)).xyz);\n#endif\nshadow *= all(bvec3(directLight.visible, receiveShadow,\nvViewPosition.z < directionalLight.maxDistance))\n? getDirShadow(directionalLight, directionalShadowMap[i],\nvDirectionalShadowCoord[i], distWorld) : 1.0;\n#endif\n}\n#endif\noutColor = vec4(color, 1.0 - (shadowBrightness + (1.0 - shadowBrightness) * shadow));\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_noise_mx_frag:"#define NOISE_REGULAR 0\n#define NOISE_FRACTAL 1\n#define NOISE_TURBULENCE 2\nfloat noise(vec3 vec, const int noiseType, const float size, const float thresholdLow, const float thresholdHigh, const float levels, float phase) {\nvec /= size;\nfloat n = 0.0;\nif (noiseType == NOISE_REGULAR) {\nn = (1.0 + snoise(vec4(vec, phase))) * 0.5;\n} else if (noiseType == NOISE_FRACTAL) {\nfloat l, f = 1.0;\nfor (l = levels; l >= 1.0; l-=1.0) { \nn += snoise(vec4(vec * f, phase)) / f;\nf *= 2.0;\n}\nif (l > 0.0) \nn += l * snoise(vec4(vec * f, phase)) / f; \nn = 0.5 * (n + 1.0);\n} else {\nfloat l, f = 1.0;\nfloat ml = levels;\nfor (l = levels; l >= 1.0; l-=1.0, ml-=1.0) {\nn += abs(snoise(vec4(vec * f, phase))) / f;\nf *= 2.0f;\n}\nif (l > 0.0)\nn += l * abs(snoise(vec4(vec * f, phase))) / f;\n}\nreturn clamp(smoothstep(thresholdLow, thresholdHigh, n), 0.0, 1.0);\n}\nvoid node_noise(const vec2 uv, const int noiseType, const int coordType, \nconst vec3 color1, const vec3 color2, const float size,\nconst float thresholdLow, const float thresholdHigh, const float levels,\nconst float phase, const vec3 offset, const vec3 tiling, const vec3 angle,\nout vec4 color) {\nvec3 vec = (calcXYZTransform(offset, tiling, angle) * vec4(uv.x, 1.0 - uv.y, 1.0, 1.0)).xyz;\ncolor = vec4(mix(color1, color2, noise(vec, noiseType, size, thresholdLow, thresholdHigh, levels, phase)), 1.0);\n}\nvoid node_noise(const vec3 viewPos, const int noiseType, const int coordType,\nconst vec3 color1, const vec3 color2, const float size,\nconst float thresholdLow, const float thresholdHigh, const float levels,\nconst float phase, const vec3 offset, const vec3 tiling, const vec3 angle,\nout vec4 color) {\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nvec3 vec;\nif (coordType == 0)\nvec = (invModelMatrix * posWorld).xyz;\nelse\nvec = posWorld.xyz;\nvec = (calcXYZTransform(offset, tiling, angle) * vec4(swizzleUpZ(vec), 1.0)).xyz;\ncolor = vec4(mix(color1, color2, noise(vec, noiseType, size, thresholdLow, thresholdHigh, levels, phase)), 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));\nvec3 refractedLight = vec3(0.0);\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#undef RE_Refraction\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_osl_blackbody_mx_frag:"\nvoid node_osl_blackbody(float Input, float Min, float Max, int Normalize, float Intensity, out vec3 Col) {\nCol = vec3(0.0);\n}",node_osl_cameraprojector_mx_frag:"\nvoid node_osl_cameraprojector(int INode, vec3 Camera, vec3 Target, vec3 Right, float FOV, float OverScan, vec3 Aspect, vec3 Up, int Backface, int Filename, int AutoGamma, float ManualGamma, out vec3 UV, out vec3 Col, out float Alpha) {\nCol = 0.0;\nvec3 ToTarget = normalize(Target - Camera);\nif (dot(oslTransform(OSL_WORLD, N), ToTarget) > 0.0 && Backface == 0)\nreturn;\nvec3 ToRight = normalize(Right);\nvec3 ToTop = cross(ToRight, ToTarget);\nvec3 ToPoint = normalize(P - Camera);\nfloat dotTarget = dot(ToTarget, ToPoint);\nif (dotTarget > 0.0)\n{\nToPoint /= dotTarget;\nfloat aspect = Aspect[1] / Aspect[0];\nfloat x = dot(ToPoint, ToRight);\nfloat y = dot(ToPoint, ToTop) / aspect;\nfloat fov = FOV>M_PI?radians(FOV):FOV;\nfloat foo = 1.0 / tan(fov / 2);\nx = x * foo / (1.0 + OverScan / 100.0);\ny = y * foo / (1.0 + OverScan / 100.0);\nx = (x + 1) / 2;\ny = (y + 1) / 2;\nUV[0] = x;\nUV[1] = y;\nUV[2] = 0.0;\nif (UV[0] <= 1.0 && UV[1] <= 1.0 && UV[0] >= 0.0 && UV[1] >= 0.0)\n{\nAlpha = 1.0;\nCol = oslTexture(Filename, UV[0], 1.0-UV[1], OSL_ALPHA, Alpha);\nint channels;\noslGetTextureInfo(Filename, OSL_CHANNELS, channels);\nif (channels < 4)\n{\nAlpha = 1.0;\n}\nif (AutoGamma)\n{\nif (!false &&\n!false &&\n!false &&\n!false &&\n!false &&\n!false)\n{\nCol = oslPow(Col, 2.2);\n}\n}\nelse\n{\nif (ManualGamma != 1.0)\nCol = oslPow(Col, ManualGamma);\n}\n}\n}\n}",node_osl_candy_mx_frag:"\nvoid node_osl_candy(vec3 UVW, float Scale, float Radius, int RandomOverlap, float BumpAmount, float BumpShape, out vec3 Col, out float Fac, out float Bump, out float Dist, out float Rnd) {\nvec3 pnt = UVW / Scale;\nfloat pri = -1.0;\nfor (float x = -1.0; x <= 1.0; x++)\n{\nfor (float y = -1.0; y <= 1.0; y++)\n{\nfor(float z = -1.0; z <= 1.0; z++)\n{\nvec3 rndvec3 = floor(pnt) + vec3(x, y, z) + 0.001;\nvec3 dotcenter = rndvec3 + vec3(oslNoise(OSL_CELL, rndvec3, 1.0));\nfloat dist = distance(dotcenter, pnt);\nfloat priority = (oslNoise(OSL_CELL, rndvec3, 2.0));\nif (dist < Radius && priority > pri)\n{\npri = priority;\nCol = vec3(oslNoise(OSL_CELL, rndvec3, 3.0));\nDist = dist / Radius;\nBump = oslPow(sin((1.0 - Dist) * 1.58), BumpShape) * BumpAmount;\nFac = 1.0;\nRnd = priority;\nif (RandomOverlap == 0)\nreturn;\n}\n}\n}\n}\n}",node_osl_checker_mx_frag:"\nvoid node_osl_checker(vec3 UVW, float Scale, vec3 Color1, vec3 Color2, out vec3 Col) {\nvec3 p = UVW / Scale;\nint x = int(mod(p[0],2.0));\nint y = int(mod(p[1],2.0));\nint z = int(mod(p[2],2.0));\nif( ((x%2) ^ (y%2)) == (z%2) ){\nCol = Color1;\n} else {\nCol = Color2;\n}\n}",node_osl_color1of10_mx_frag:"\nvoid node_osl_color1of10(int Index, vec3 I0, vec3 I1, vec3 I2, vec3 I3, vec3 I4, vec3 I5, vec3 I6, vec3 I7, vec3 I8, vec3 I9, int StartIdx, int Mod, vec3 Outside, out vec3 Out) {\nint idx = Index - StartIdx;\nif (Mod == 1)\nidx = idx % Mod;\nif (idx < 0 || idx > 9)\n{\nOut = Outside;\n}\nelse\n{\nif (idx == 0) { Out = I0; } else\nif (idx == 1) { Out = I1; } else\nif (idx == 2) { Out = I2; } else\nif (idx == 3) { Out = I3; } else\nif (idx == 4) { Out = I4; } else\nif (idx == 5) { Out = I5; } else\nif (idx == 6) { Out = I6; } else\nif (idx == 7) { Out = I7; } else\nif (idx == 8) { Out = I8; } else\nif (idx == 9) { Out = I9; } else\nOut = Outside;\n}\n}",node_osl_color1of5_mx_frag:"\nvoid node_osl_color1of5(int Index, vec3 I0, vec3 I1, vec3 I2, vec3 I3, vec3 I4, int StartIdx, int Mod, vec3 Outside, out vec3 Out) {\nint idx = Index - StartIdx;\nif (Mod == 1)\nidx = idx % Mod;\nif (idx < 0 || idx > 4)\n{\nOut = Outside;\n}\nelse\n{\nif (idx == 0) { Out = I0; } else\nif (idx == 1) { Out = I1; } else\nif (idx == 2) { Out = I2; } else\nif (idx == 3) { Out = I3; } else\nif (idx == 4) { Out = I4; } else\nOut = Outside;\n}\n}",node_osl_color1ofn_mx_frag:"\nvoid node_osl_color1ofn(int Layers, int Add, int Delete, int Index, vec3 I0, vec3 I1, vec3 I2, vec3 I3, vec3 I4, int StartIdx, int Repeat, vec3 Outside, out vec3 Out) {\nint idx = Index - StartIdx;\nif (Repeat == 1)\nidx = idx % (Layers+1);\nif (idx < 0 || idx > Layers)\n{\nOut = Outside;\n}\nelse\n{\nif (idx == 0) { Out = I0; } else\nif (idx == 1) { Out = I1; } else\nif (idx == 2) { Out = I2; } else\nif (idx == 3) { Out = I3; } else\nif (idx == 4) { Out = I4; } else\nOut = Outside;\n}\n}",node_osl_coloradd_mx_frag:"\nvoid node_osl_coloradd(vec3 A, vec3 B, float A_Amount, float B_Amount, int Clamp, out vec3 Out) {\nOut = A*A_Amount + B*B_Amount;\nif (Clamp == 1)\nOut = clamp(Out, 0.0, 1.0);\n}",node_osl_colorclamp_mx_frag:"\nvoid node_osl_colorclamp(vec3 Input, vec3 Min, vec3 Max, out vec3 Out) {\nOut = clamp(Input, Min, Max);\n}",node_osl_colorcomp_mx_frag:"\nvoid node_osl_colorcomp(vec3 Input, out vec3 Out) {\nOut = 1.0 - Input;\n}",node_osl_colorcurves_mx_frag:"\nfloat interpolate(float Input, float position[], vec3 values[], int interpolation[], int c)\n{\nint l = arraylength(position);\nint last = l-1;\nif (Input < position[0])\nreturn values[0][c];\nint i;\nfor (i = 0; i < last; i++)\n{\nif (Input >= position[i] && Input < position[i+1])\nbreak;\n}\nif (i >= last)\nreturn values[last][c];\nint i0 = max(0, i-1);\nint i1 = i;\nint i2 = i+1;\nint i3 = min(last, i+2);\nfloat delta = position[i2] - position[i1];\nint interp = interpolation[i1];\nif (delta <= 0.0 || interp == 0)\nreturn values[i1][c];\nfloat along = (Input - position[i1]) / delta;\nif (interp == 1)\nreturn mix(values[i1][c], values[i2][c], along);\nif (interp == 2)\n{\nfloat M12 = 1.0;\nfloat M21 = -0.5;\nfloat M23 = 0.5;\nfloat M31 = 1.0;\nfloat M32 = -2.5;\nfloat M33 = 2.0;\nfloat M34 = -0.5;\nfloat M41 = -0.5;\nfloat M42 = 1.5;\nfloat M43 = -1.5;\nfloat M44 = 0.5;\nfloat v0 = values[i0][c];\nfloat v1 = values[i1][c];\nfloat v2 = values[i2][c];\nfloat v3 = values[i3][c];\nfloat c1 = M12 * v1;\nfloat c2 = M21 * v0 + M23 * v2;\nfloat c3 = M31 * v0 + M32 * v1 + M33 * v2 + M34 * v3;\nfloat c4 = M41 * v0 + M42 * v1 + M43 * v2 + M44 * v3;\nreturn ((c4 * along + c3) * along + c2) * along + c1;\n}\nif (interp == 3)\n{\nfloat i1_tangent = 0;\nfloat i2_tangent = 0;\nfloat i0_interval = position[i1] - position[i0];\nfloat i1_interval = position[i2] - position[i1];\nfloat i2_interval = position[i3] - position[i2];\nfloat i0_delta = (values[i1][c] - values[i0][c]) / i0_interval;\nfloat i1_delta = (values[i2][c] - values[i1][c]) / i1_interval;\nfloat i2_delta = (values[i3][c] - values[i2][c]) / i2_interval;\nif (i1 > 0 && (i1_delta * i0_delta) >= 0.0) {\ni1_tangent = 3.0 * (i0_interval + i1_interval)\n/ ((2.0 * i1_interval + i0_interval) / i0_delta\n+ (i1_interval + 2.0 * i0_interval) / i1_delta);\n}\nif (i2 < (last) && (i2_delta * i1_delta) >= 0.0) {\ni2_tangent = 3.0 * (i1_interval + i2_interval)\n/ ((2.0 * i2_interval + i1_interval) / i1_delta\n+ (i2_interval + 2.0 * i1_interval) / i2_delta);\n}\nfloat invint = 1.0 / i1_interval;\nfloat si = i1_delta;\nfloat ci = (3.0 * si - 2.0 * i1_tangent - i2_tangent) * invint;\nfloat di = (i1_tangent + i2_tangent - 2.0 * si) * invint * invint;\nfloat t = along * i1_interval;\nfloat t2 = t * t;\nfloat t3 = t * t2;\nreturn values[i1][c] + i1_tangent * t + ci * t2 + di * t3;\n}\nreturn mix(values[i1][c], values[i2][c], along);\n}\nvoid node_osl_colorcurves(int interpolation[], vec3 vec3s[], vec3(1, 0, 0)}, float position[], vec3 Input, out vec3 Out, out float R, out float G, out float B) {\nR = Out[0] = interpolate(Input[0], position, vec3s, interpolation, 0);\nG = Out[1] = interpolate(Input[1], position, vec3s, interpolation, 1);\nB = Out[2] = interpolate(Input[2], position, vec3s, interpolation, 2);\n}",node_osl_colordiv_mx_frag:"\nvoid node_osl_colordiv(vec3 A, vec3 B, int Clamp, out vec3 Out) {\nOut = A / B;\nif (Clamp == 1)\nclamp(Out, 0.0, 1.0);\n}",node_osl_colorjuggler_mx_frag:"\nvoid node_osl_colorjuggler(vec3 Input, float Ri, float Gi, float Bi, out vec3 Out, out float R, out float G, out float B) {\nOut = vec3(Ri,Gi,Bi);\nR = Out[0];\nG = Out[1];\nB = Out[2];\n}",node_osl_colorkey_mx_frag:"\nvoid node_osl_colorkey(vec3 Input, vec3 KeyColor, vec3 Mask, vec3 Fill, float Low, float High, float Gamma, vec3 UVW, float LowU, float HighU, float LowV, float HighV, out vec3 Col, out float Key) {\nfloat x = distance(oslPow(Input, Gamma), oslPow(KeyColor, Gamma));\nif (UVW[0] > LowU && UVW[0] < HighU &&\nUVW[1] > LowV && UVW[1] < HighV)\n{\nKey = smoothstep(Low, High, x) * oslLuminance(Mask);\nCol = Input * Key;\n}\nCol = mix(Fill, Input, Key);\n}",node_osl_colormax_mx_frag:"\nvoid node_osl_colormax(vec3 A, vec3 B, out vec3 Out) {\nOut = max(A, B);\n}",node_osl_colormin_mx_frag:"\nvoid node_osl_colormin(vec3 A, vec3 B, out vec3 Out) {\nOut = min(A, B);\n}",node_osl_colormul_mx_frag:"\nvoid node_osl_colormul(vec3 A, vec3 B, int Clamp, out vec3 Out) {\nOut = A * B;\nif (Clamp == 1)\nOut = clamp(Out, 0.0, 1.0);\n}",node_osl_colorspace_mx_frag:"\nvoid node_osl_colorspace(int FromSpace, int ToSpace, vec3 In, out vec3 Out) {\nOut = oslTransformC(FromSpace , ToSpace, In);\n}",node_osl_colorsub_mx_frag:"\nvoid node_osl_colorsub(vec3 A, vec3 B, float A_Amount, float B_Amount, int Clamp, out vec3 Out) {\nOut = A*A_Amount - B*B_Amount;\nif (Clamp == 1)\nOut = clamp(Out, 0.0, 1.0);\n}",node_osl_colortweak_mx_frag:"\nvoid node_osl_colortweak(vec3 Input, vec3 HSV, vec3 InputMin, vec3 InputMax, float MidTones, vec3 OutputMin, vec3 OutputMax, int Clamp, out vec3 Out) {\nvec3 col = (Input - InputMin) / InputMax;\nvec3 hsv = oslTransformC(OSL_RGB, OSL_HSV, col);\nhsv[0] += HSV[0];\nhsv[1] *= HSV[1];\nhsv[2] *= HSV[2];\ncol = oslTransformC(OSL_HSV, OSL_RGB, hsv);\nOut = mix(OutputMin, OutputMax, oslPow(col, 1.0/MidTones));\nif (Clamp == 1)\nOut = clamp(Out, 0.0, 1.0);\n}",node_osl_compare_mx_frag:"\nvoid node_osl_compare(float A, float B, float Thresh, vec3 Less, vec3 Equal, vec3 Greater, out vec3 Out, out float Float) {\nif (abs(A-B) <= Thresh)\nOut = Equal;\nelse if (A < B)\nOut = Less;\nelse\nOut = Greater;\nFloat = (Out[0]+Out[1]+Out[2])/3.0;\n}",node_osl_composite_mx_frag:"\nfloat PinLight (float b, float a){\nif ((a > 0.5 && a > b) || (a < 0.5 && a < b))\nreturn a;\nelse\nreturn b;\n}\nfloat HardMix (float b, float a){\nif ((a + b) <= 1.0)\nreturn 0.0;\nelse\nreturn 1.0;\n}\nfloat Difference (float b, float a){\nreturn abs(a - b);\n}\nvoid node_osl_composite(vec3 TopRGB, float TopA, vec3 BottomRGB, float BottomA, int BlendMode, int Premult, int Clamp, out vec3 Out, out float Alpha) {\nOut = BottomRGB * (1.0 - TopA);\nAlpha = BottomA * (1.0 - TopA);\nvec3 blended = vec3(0.0);\nif (BlendMode == OSL_NORMAL)\nblended = TopRGB;\nelse if (BlendMode == OSL_AVERAGE)\nblended = (BottomRGB+TopRGB)/2.0;\nelse if (BlendMode == OSL_DARKEN)\nblended = min(BottomRGB, TopRGB);\nelse if (BlendMode == OSL_MULTIPLY)\nblended = (BottomRGB * TopRGB);\nelse if (BlendMode == OSL_COLOR_BURN){\nif (TopRGB == vec3(0.0))\nblended = TopRGB;\nelse\nblended = max(1.0 - (1.0 - BottomRGB) / TopRGB, 0.0);\n}\nelse if (BlendMode == OSL_LINEAR_BURN)\nblended = max((BottomRGB + TopRGB - 1.0), vec3 (0.0));\nelse if (BlendMode == OSL_LIGHTEN)\nblended = max(BottomRGB, TopRGB);\nelse if (BlendMode == OSL_SCREEN)\nblended = TopRGB + BottomRGB - TopRGB * BottomRGB;\nelse if (BlendMode == OSL_COLOR_DODGE){\nif (TopRGB == vec3 (1.0))\nblended = vec3 (1.0);\nelse\nblended = min(BottomRGB / (1.0 - TopRGB), vec3 (1.0));\n}\nelse if (BlendMode == OSL_LINEAR_DODGE)\nblended = min((BottomRGB + TopRGB), vec3 (1.0));\nelse if (BlendMode == OSL_SPOTLIGHT)\nblended = min(2.0 * TopRGB * BottomRGB, 1.0);\nelse if (BlendMode == OSL_SPOTLIGHT_BLEND)\nblended = min(TopRGB * BottomRGB + BottomRGB, 1.0);\nelse if (BlendMode == OSL_OVERLAY){\nfloat BottomRGBl = oslLuminance(BottomRGB);\nif (BottomRGBl <= 0.5)\nblended = (2.0 * BottomRGB * TopRGB);\nelse\nblended = (1.0 - 2.0 * (1.0 - TopRGB) * (1.0 - BottomRGB));\n}\nelse if (BlendMode == OSL_SOFT_LIGHT){\nfloat TopRGBl = oslLuminance(TopRGB);\nif (TopRGBl <= 0.5)\nblended = BottomRGB * (BottomRGB + 2.0 * TopRGB * (1.0 - BottomRGB));\nelse\nblended = BottomRGB + (2.0 * TopRGB - 1.0) * (sqrt(BottomRGB) - BottomRGB);\n}\nelse if (BlendMode == OSL_HARD_LIGHT){\nfloat TopRGBl = oslLuminance(TopRGB);\nif (TopRGBl <= 0.5)\nblended = 2.0 * TopRGB * BottomRGB;\nelse\nblended = 1.0 - 2.0 * (1.0 - TopRGB) * (1.0 - BottomRGB);\n}\nelse if (BlendMode == OSL_PIN_LIGHT){\nblended[0] = PinLight (BottomRGB[0], TopRGB[0]);\nblended[1] = PinLight (BottomRGB[1], TopRGB[1]);\nblended[2] = PinLight (BottomRGB[2], TopRGB[2]);\n}\nelse if (BlendMode == OSL_HARD_MIX){\nblended[0] = HardMix (BottomRGB[0], TopRGB[0]);\nblended[1] = HardMix (BottomRGB[1], TopRGB[1]);\nblended[2] = HardMix (BottomRGB[2], TopRGB[2]);\n}\nelse if (BlendMode == OSL_DIFFERENCE){\nblended[0] = Difference (BottomRGB[0], TopRGB[0]);\nblended[1] = Difference (BottomRGB[1], TopRGB[1]);\nblended[2] = Difference (BottomRGB[2], TopRGB[2]);\n}\nelse if (BlendMode == OSL_EXCLUSION){\nblended = TopRGB + BottomRGB - 2.0 * TopRGB * BottomRGB;\n}\nelse if (BlendMode == OSL_SUBTRACT){\nblended = max(BottomRGB - TopRGB, 0.0);\n}\nelse if (BlendMode == OSL_DIVIDE){\nblended = BottomRGB / TopRGB;\n}\nelse if (BlendMode == OSL_HUE){\nvec3 hsvBottomRGB = oslTransformC(OSL_HSV, BottomRGB);\nvec3 hsvTopRGB = oslTransformC(OSL_HSV, TopRGB);\nblended = oslHSV(hsvTopRGB[0], hsvBottomRGB[1], hsvBottomRGB[2]);\n}\nelse if (BlendMode == OSL_SATURATION){\nvec3 hsvBottomRGB = oslTransformC(OSL_HSV, BottomRGB);\nvec3 hsvTopRGB = oslTransformC(OSL_HSV, TopRGB);\nblended = oslHSV(hsvBottomRGB[0], hsvTopRGB[1], hsvBottomRGB[2]);\n}\nelse if (BlendMode == OSL_COLOR){\nvec3 hsvBottomRGB = oslTransformC(OSL_HSV, BottomRGB);\nvec3 hsvTopRGB = oslTransformC(OSL_HSV, TopRGB);\nblended = oslHSV(hsvTopRGB[0], hsvTopRGB[1], hsvBottomRGB[2]);\n}\nelse if (BlendMode == OSL_VALUE){\nvec3 hsvBottomRGB = oslTransformC(OSL_HSV, BottomRGB);\nvec3 hsvTopRGB = oslTransformC(OSL_HSV, TopRGB);\nblended = oslHSV(hsvBottomRGB[0], hsvBottomRGB[1], hsvTopRGB[2]);\n}\nfloat topmul = bool(Premult)?1.0:TopA;\nOut += blended * topmul;\nAlpha += TopA;\nif (Clamp == 1)\nOut = clamp(Out, 0.0, 1.0);\n}",node_osl_degtorad_mx_frag:"\nvoid node_osl_degtorad(float Input, out float Out) {\nOut = radians(Input);\n}",node_osl_digits_mx_frag:"\nint inBit(vec3 pt, vec3 start, vec3 end)\n{\nif (pt[0] > start[0] && pt[0] < end[0] &&\npt[1] > start[1] && pt[1] < end[1])\nreturn 1;\nreturn 0;\n}\nint inDigit(vec3 inp, int digit, int dp, int ms)\n{\nvec3 pt = inp;\npt -= vec3(0.5, 0.2, 0.0);\npt *= 2.5;\npt += vec3(0.5, 0.2, 0.0);\nif (ms && inBit(pt, vec3(-0.9, 0.9, 0.0), vec3(-0.2, 1.1, 0.0)))\nreturn 1;\nif (pt[0] < -0.1 || pt[1] < -0.1 ||\npt[0] > 1.3 || pt[1] > 2.1)\nreturn -1;\nif (dp && inBit(pt, vec3(1.15, -0.1, 0.0), vec3(1.3, 0.1, 0)))\n{\nreturn 1;\n}\nif (inBit(pt, vec3(0.1,-0.1,0.0), vec3(0.9,0.1,0.0)))\n{\nif (digit == 2 || digit == 3 || digit == 5 || digit == 6 || digit == 8 || digit == 9 || digit == 0)\nreturn 1;\nelse\nreturn 0;\n}\nif (inBit(pt, vec3(0.1,0.9,0.0), vec3(0.9,1.1,0.0)))\n{\nif (digit == 2 || digit == 3 || digit == 4 || digit == 5 || digit == 6 || digit == 8 || digit == 9)\nreturn 1;\nelse\nreturn 0;\n}\nif (inBit(pt, vec3(0.1,1.9,0.0), vec3(0.9,2.1,0.0)))\n{\nif (digit == 2 || digit == 3 || digit == 5 || digit == 6 || digit == 7 || digit == 8 || digit == 9 || digit == 0)\nreturn 1;\nelse\nreturn 0;\n}\nif (inBit(pt, vec3(-0.1,0.1,0.0), vec3(0.1,0.9,0.0)))\n{\nif (digit == 2 || digit == 6 || digit == 8 || digit == 0)\nreturn 1;\nelse\nreturn 0;\n}\nif (inBit(pt, vec3(-0.1,1.1,0.0), vec3(0.1,1.9,0.0)))\n{\nif (digit == 4 || digit == 5 || digit == 6 || digit == 8 || digit == 9 || digit == 0)\nreturn 1;\nelse\nreturn 0;\n}\nif (inBit(pt, vec3(0.9,0.1,0.0), vec3(1.1,0.9,0.0)))\n{\nif (digit == 1 || digit == 3 || digit == 4 || digit == 5 || digit==6 || digit == 7 || digit == 8 || digit == 9 || digit == 0)\nreturn 1;\nelse\nreturn 0;\n}\nif (inBit(pt, vec3(0.9,1.1,0.0), vec3(1.1,1.9,0.0)))\n{\nif (digit == 1 || digit == 2 || digit == 3 || digit == 4 || digit == 7 || digit == 8 || digit == 9 || digit == 0)\nreturn 1;\nelse\nreturn 0;\n}\nreturn -1;\n}\nvoid node_osl_digits(vec3 UVW, float Number, int Digits, int Decimals, float Scale, vec3 BGColor, vec3 OnColor, vec3 OffColor, int UseOffColor, out vec3 Out, out float Fac, out float NumberOut) {\nint mult[9] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 };\nvec3 px = UVW / Scale;\nint number = int(Number * mult[Decimals]);\nint minus = 0;\nif (number < 0)\n{\nnumber = -number;\nminus = 1;\n}\nint digits = Digits;\nint leftOfDecimalPoint = (int(floor(log(abs(Number), 10.0)))) + 1;\nif (leftOfDecimalPoint <= 0)\nleftOfDecimalPoint = 1;\nint maxdigi = leftOfDecimalPoint + Decimals;\nif (maxdigi > digits)\ndigits = maxdigi;\nif (px[0] > 0 && px[0] < 1 && px[1] > 0 && px[1] < 1)\n{\npx -= vec3(0.9, 0.5, 0.0);\npx *= (digits * 0.8);\npx += vec3(0.9, 0.5, 0.0);\nfor (int i = 0; i < digits; i++)\n{\nint x = inDigit(px, int(number) % 10, Decimals == i, minus && i == digits-1);\nif (x == 0 && UseOffColor)\n{\nOut = OffColor;\nFac = 1.0;\n}\nif (x == 1)\n{\nOut = OnColor;\nFac = 1.0;\n}\nnumber /= 10;\npx += vec3(0.6,0.0,0.0);\n}\n}\n}",node_osl_environmentbackground_mx_frag:"\nvoid node_osl_environmentbackground(vec3 Background, vec3 Environment, out vec3 Out) {\nint renderer;\noslGetAttribute(OSL_RENDERER_NAME, renderer);\nif (renderer == OSL_3DSMAX_HLSL)\n{\nvec3 CP = oslTransform(OSL_CAMERA, vec3(0,0,0));\nif (CP == vec3(0.0))\nOut = Environment;\nelse\nOut = Background;\n}\nelse\n{\nif (oslRayType(OSL_CAMERA))\nOut= Background;\nelse\nOut = Environment;\n}\n}",node_osl_falloff_mx_frag:"\nvoid node_osl_falloff(vec3 Face, vec3 Away, int Coordspace, vec3 FalloffDirection, int Type, float Power, out vec3 Out, out float MixAmount) {\nvec3 normalDir = oslTransform(Coordspace, N);\nMixAmount = dot (normalDir, FalloffDirection);\nif (Power != 1.0)\nMixAmount = 1.0 - oslPow(1.0 - MixAmount, Power);\nif (Type == 1)\nMixAmount = (MixAmount + 1.0)/2.0;\nOut = mix(Away, Face, MixAmount);\n}",node_osl_float1of10_mx_frag:"\nvoid node_osl_float1of10(int Index, float I0, float I1, float I2, float I3, float I4, float I5, float I6, float I7, float I8, float I9, int StartIdx, int Mod, float Outside, out float Out) {\nint idx = Index - StartIdx;\nif (Mod == 1)\nidx = idx % Mod;\nif (idx < 0 || idx > 9)\n{\nOut = Outside;\n}\nelse\n{\nif (idx == 0) { Out = I0; } else\nif (idx == 1) { Out = I1; } else\nif (idx == 2) { Out = I2; } else\nif (idx == 3) { Out = I3; } else\nif (idx == 4) { Out = I4; } else\nif (idx == 5) { Out = I5; } else\nif (idx == 6) { Out = I6; } else\nif (idx == 7) { Out = I7; } else\nif (idx == 8) { Out = I8; } else\nif (idx == 9) { Out = I9; } else\nOut = Outside;\n}\n}",node_osl_float1of5_mx_frag:"\nvoid node_osl_float1of5(int Index, float I0, float I1, float I2, float I3, float I4, int StartIdx, int Mod, float Outside, out float Out) {\nint idx = Index - StartIdx;\nif (Mod == 1)\nidx = idx % Mod;\nif (idx < 0 || idx > 4)\n{\nOut = Outside;\n}\nelse\n{\nif (idx == 0) { Out = I0; } else\nif (idx == 1) { Out = I1; } else\nif (idx == 2) { Out = I2; } else\nif (idx == 3) { Out = I3; } else\nif (idx == 4) { Out = I4; } else\nOut = Outside;\n}\n}",node_osl_float1ofn_mx_frag:"\nvoid node_osl_float1ofn(int Layers, int Add, int Delete, int Index, float I0, float I1, float I2, float I3, float I4, int StartIdx, int Repeat, float Outside, out float Out) {\nint idx = Index - StartIdx;\nif (Repeat == 1)\nidx = idx % (Layers + 1);\nif (idx < 0 || idx > Layers)\n{\nOut = Outside;\n}\nelse\n{\nif (idx == 0) { Out = I0; } else\nif (idx == 1) { Out = I1; } else\nif (idx == 2) { Out = I2; } else\nif (idx == 3) { Out = I3; } else\nif (idx == 4) { Out = I4; } else\nOut = Outside;\n}\n}",node_osl_float2int_mx_frag:"\nvoid node_osl_float2int(float Input, int Mode, out int Out) {\nif (Mode == OSL_CEIL)\nOut = int(ceil(Input));\nelse\nif (Mode == OSL_ROUND)\nOut = int(round(Input));\nelse\nif (Mode == OSL_TRUNC)\nOut = int(trunc(Input));\nelse\nOut = int(floor(Input));\n}",node_osl_floatabs_mx_frag:"\nvoid node_osl_floatabs(float Input, out float Out) {\nOut = abs(Input);\n}",node_osl_floatacos_mx_frag:"\nvoid node_osl_floatacos(float Input, out float Out) {\nOut = acos(Input);\n}",node_osl_floatadd_mx_frag:"\nvoid node_osl_floatadd(float A, float B, out float Out) {\nOut = A + B;\n}",node_osl_floatangle_mx_frag:"\nvoid node_osl_floatangle(float X, float Y, out float Out) {\nOut = atan2(X, Y);\n}",node_osl_floatasin_mx_frag:"\nvoid node_osl_floatasin(float Input, out float Out) {\nOut = asin(Input);\n}",node_osl_floatatan_mx_frag:"\nvoid node_osl_floatatan(float Input, out float Out) {\nOut = atan(Input);\n}",node_osl_floatclamp_mx_frag:"\nvoid node_osl_floatclamp(float Input, float Min, float Max, out float Out) {\nOut = clamp(Input, Min, Max);\n}",node_osl_floatcomp_mx_frag:"\nvoid node_osl_floatcomp(float Input, out float Out) {\nOut = 1 - Input;\n}",node_osl_floatcos_mx_frag:"\nvoid node_osl_floatcos(float Input, out float Out) {\nOut = cos(Input);\n}",node_osl_floatcurves_mx_frag:"\nfloat interpolate(float Input, float position[], float values[], int interpolation[])\n{\nint l = arraylength(position);\nint last = l-1;\nif (Input < position[0])\nreturn values[0];\nint i;\nfor (i = 0; i < last; i++)\n{\nif (Input >= position[i] && Input < position[i+1])\nbreak;\n}\nif (i >= last)\nreturn values[last];\nint i0 = max(0, i-1);\nint i1 = i;\nint i2 = i+1;\nint i3 = min(last, i+2);\nfloat delta = position[i2] - position[i1];\nint interp = interpolation[i1];\nif (delta <= 0.0 || interp == 0)\nreturn values[i1];\nfloat along = (Input - position[i1]) / delta;\nif (interp == 1)\nreturn mix(values[i1], values[i2], along);\nif (interp == 2)\n{\nfloat M12 = 1.0;\nfloat M21 = -0.5;\nfloat M23 = 0.5;\nfloat M31 = 1.0;\nfloat M32 = -2.5;\nfloat M33 = 2.0;\nfloat M34 = -0.5;\nfloat M41 = -0.5;\nfloat M42 = 1.5;\nfloat M43 = -1.5;\nfloat M44 = 0.5;\nfloat v0 = values[i0];\nfloat v1 = values[i1];\nfloat v2 = values[i2];\nfloat v3 = values[i3];\nfloat c1 = M12 * v1;\nfloat c2 = M21 * v0 + M23 * v2;\nfloat c3 = M31 * v0 + M32 * v1 + M33 * v2 + M34 * v3;\nfloat c4 = M41 * v0 + M42 * v1 + M43 * v2 + M44 * v3;\nreturn ((c4 * along + c3) * along + c2) * along + c1;\n}\nif (interp == 3)\n{\nfloat i1_tangent = 0;\nfloat i2_tangent = 0;\nfloat i0_interval = position[i1] - position[i0];\nfloat i1_interval = position[i2] - position[i1];\nfloat i2_interval = position[i3] - position[i2];\nfloat i0_delta = (values[i1] - values[i0]) / i0_interval;\nfloat i1_delta = (values[i2] - values[i1]) / i1_interval;\nfloat i2_delta = (values[i3] - values[i2]) / i2_interval;\nif (i1 > 0 && (i1_delta * i0_delta) >= 0.0) {\ni1_tangent = 3.0 * (i0_interval + i1_interval)\n/ ((2.0 * i1_interval + i0_interval) / i0_delta\n+ (i1_interval + 2.0 * i0_interval) / i1_delta);\n}\nif (i2 < (last) && (i2_delta * i1_delta) >= 0.0) {\ni2_tangent = 3.0 * (i1_interval + i2_interval)\n/ ((2.0 * i2_interval + i1_interval) / i1_delta\n+ (i2_interval + 2.0 * i1_interval) / i2_delta);\n}\nfloat invint = 1.0 / i1_interval;\nfloat si = i1_delta;\nfloat ci = (3.0 * si - 2.0 * i1_tangent - i2_tangent) * invint;\nfloat di = (i1_tangent + i2_tangent - 2.0 * si) * invint * invint;\nfloat t = along * i1_interval;\nfloat t2 = t * t;\nfloat t3 = t * t2;\nreturn values[i1] + i1_tangent * t + ci * t2 + di * t3;\n}\nreturn mix(values[i1], values[i2], along);\n}\nvoid node_osl_floatcurves(int interpolation[], float values[], float position[], float Input, out float Out) {\nOut = interpolate(Input, position, values, interpolation);\n}",node_osl_floatdiv_mx_frag:"\nvoid node_osl_floatdiv(float A, float B, out float Out) {\nOut = A / B;\n}",node_osl_floatexp_mx_frag:"\nvoid node_osl_floatexp(float X, out float Out) {\nOut = exp(X);\n}",node_osl_floatinterpolate_mx_frag:"\nvoid node_osl_floatinterpolate(float Input, float Min, float Max, out float Out) {\nOut = mix(Min, Max, Input);\n}",node_osl_floatlog_mx_frag:"\nvoid node_osl_floatlog(float Input, out float Out) {\nOut = log(Input);\n}",node_osl_floatlogx_mx_frag:"\nvoid node_osl_floatlogx(float Input, float Base, out float Out) {\nOut = log(Input, Base);\n}",node_osl_floatmax_mx_frag:"\nvoid node_osl_floatmax(float A, float B, out float Out) {\nOut = max(A, B);\n}",node_osl_floatmin_mx_frag:"\nvoid node_osl_floatmin(float A, float B, out float Out) {\nOut = min(A, B);\n}",node_osl_floatmod_mx_frag:"\nvoid node_osl_floatmod(float A, float B, out float Out) {\nOut = fmod(A, B);\n}",node_osl_floatmul_mx_frag:"\nvoid node_osl_floatmul(float A, float B, out float Out) {\nOut = A * B;\n}",node_osl_floatnegate_mx_frag:"\nvoid node_osl_floatnegate(float Input, out float Out) {\nOut = -Input;\n}",node_osl_floatpow_mx_frag:"\nvoid node_osl_floatpow(float A, float B, out float Out) {\nOut = oslPow(A, B);\n}",node_osl_floatrange_mx_frag:"\nvoid node_osl_floatrange(float Input, int Clamp, float InStart, float InEnd, float OutStart, float OutEnd, float Curve, out float Out) {\nfloat fac = (Input - InStart) / (InEnd - InStart);\nOut = OutStart + oslPow(fac, 1.0 / Curve) * (OutEnd - OutStart);\nif (Clamp == 1)\n{\nif (OutStart < OutEnd)\nOut = clamp(Out, OutStart, OutEnd);\nelse\nOut = clamp(Out, OutEnd, OutStart);\n}\n}",node_osl_floatrecip_mx_frag:"\nvoid node_osl_floatrecip(float Input, out float Out) {\nOut = 1.0 / Input;\n}",node_osl_floatsin_mx_frag:"\nvoid node_osl_floatsin(float Input, out float Out) {\nOut = sin(Input);\n}",node_osl_floatsmoothstep_mx_frag:"\nvoid node_osl_floatsmoothstep(float Input, float Low, float High, out float Out) {\nOut = smoothstep(Low, High, Input);\n}",node_osl_floatsqrt_mx_frag:"\nvoid node_osl_floatsqrt(float Input, out float Out) {\nOut = sqrt(Input);\n}",node_osl_floatsub_mx_frag:"\nvoid node_osl_floatsub(float A, float B, out float Out) {\nOut = A - B;\n}",node_osl_floattan_mx_frag:"\nvoid node_osl_floattan(float Input, out float Out) {\nOut = tan(Input);\n}",node_osl_fourpointgradient_mx_frag:"\nvoid node_osl_fourpointgradient(vec3 UVW, vec3 TopLeft, vec3 TopRight, vec3 BottomLeft, vec3 BottomRight, float UCenter, float VCenter, out vec3 Out) {\nfloat x = oslPow(UVW[0], oslPow(50.0, UCenter - 0.5));\nfloat y = oslPow(UVW[1], oslPow(50.0, VCenter - 0.5));\nOut = mix(mix(BottomLeft, TopLeft, y),\nmix(BottomRight, TopRight, y), x);\n}",node_osl_gabornoise_mx_frag:"\nvoid node_osl_gabornoise(vec3 UVW, float Scale, float Bandwidth, float Impulses, int Unsigned, int Filter, int Anisotropic, vec3 Direction, out vec3 Col, out float R, out float G, out float B) {\nvec3 pnt = UVW / Scale;\nCol = oslNoise(OSL_GABOR, pnt, OSL_ANISOTROPIC, Anisotropic, OSL_DIRECTION, Direction,\nOSL_BANDWIDTH, Bandwidth, OSL_IMPULSES, Impulses, OSL_DO_FILTER, Filter );\nif (Unsigned)\nCol = (Col + 1.0) / 2.0;\nR = Col[0];\nG = Col[1];\nB = Col[2];\n}",node_osl_getattribute_mx_frag:"\nvoid node_osl_getattribute(int Attribute, int AddPrefix, vec3 ColDef, float FltDef, int IntDef, int StrDef, out vec3 Col, out float Flt, out int Int, out int Str) {\nCol = vec3(0.0);\nFlt = 0.0;\nInt = 0;\nStr = 0;\n}",node_osl_getcoordspace_mx_frag:"\nvoid node_osl_getcoordspace(vec3 Input, int Coordspace, out vec3 UVW) {\nUVW = oslTransform(Coordspace, Input);\n}",node_osl_getframe_mx_frag:"\nvoid node_osl_getframe(int In, int Offset, out int FrameNumber) {\nFrameNumber = In + Offset;\n}",node_osl_getmtlid_mx_frag:'\nvoid vec3ById(int id , out vec3 c)\n{\nint iPPermute[256] = {\n170, 85, 0, 43, 128, 213, 64, 149, 234, 191, 106, 21,\n180, 95, 10, 53, 138, 223, 74, 159, 244, 201, 116, 31,\n175, 90, 5, 48, 133, 218, 69, 154, 239, 196, 111, 26,\n185, 100, 15, 58, 143, 228, 79, 164, 249, 206, 121, 36,\n173, 88, 3, 46, 131, 216, 67, 152, 237, 194, 109, 24, 255,\n183, 98, 13, 56, 141, 226, 77, 162, 247, 204, 119, 34, 63,\n178, 93, 8, 51, 136, 221, 72, 157, 242, 199, 114, 29, 84,\n188, 103, 18, 61, 146, 231, 82, 167, 252, 209, 124, 39, 105,\n172, 87, 2, 45, 130, 215, 66, 151, 236, 193, 108, 23, 42,\n182, 97, 12, 55, 140, 225, 76, 161, 246, 203, 118, 33, 126,\n177, 92, 7, 50, 135, 220, 71, 156, 241, 198, 113, 28, 127,\n187, 102, 17, 60, 145, 230, 81, 166, 251, 208, 123, 38, 148,\n174, 89, 4, 47, 132, 217, 68, 153, 238, 195, 110, 25, 169,\n184, 99, 14, 57, 142, 227, 78, 163, 248, 205, 120, 35, 190,\n179, 94, 9, 52, 137, 222, 73, 158, 243, 200, 115, 30, 211,\n189, 104, 19, 62, 147, 232, 83, 168, 253, 210, 125, 40, 20,\n171, 86, 1, 44, 129, 214, 65, 150, 235, 192, 107, 22, 41,\n181, 96, 11, 54, 139, 224, 75, 160, 245, 202, 117, 32, 212,\n176, 91, 6, 49, 134, 219, 70, 155, 240, 197, 112, 27, 254,\n186, 101, 16, 59, 144, 229, 80, 165, 250, 207, 122, 37, 233 };\nfloat kMaxColor = 255.0;\nfloat h = (iPPermute[(id & 255)]) / kMaxColor;\nfloat s = 1 - ( id >> 8 ) / kMaxColor;\nc = vec3("hsv", h, s, 1.0);\n}\nvoid node_osl_getmtlid(out vec3 Col, out int Index) {\noslGetAttribute(OSL_MTLID, Index);\nvec3ById(Index, Col);\n}',node_osl_getnodeid_mx_frag:"\nvoid node_osl_getnodeid(out int Index) {\noslGetAttribute(OSL_NODEHANDLE, Index);\n}",node_osl_getnodename_mx_frag:"\nvoid node_osl_getnodename(out int Hash, out int Name) {\noslGetAttribute(OSL_NODENAME, Name);\nHash = hash(Name);\n}",node_osl_getobjectid_mx_frag:'\nvoid vec3ById(int id , out vec3 c)\n{\nint iPPermute[256] = {\n170, 85, 0, 43, 128, 213, 64, 149, 234, 191, 106, 21,\n180, 95, 10, 53, 138, 223, 74, 159, 244, 201, 116, 31,\n175, 90, 5, 48, 133, 218, 69, 154, 239, 196, 111, 26,\n185, 100, 15, 58, 143, 228, 79, 164, 249, 206, 121, 36,\n173, 88, 3, 46, 131, 216, 67, 152, 237, 194, 109, 24, 255,\n183, 98, 13, 56, 141, 226, 77, 162, 247, 204, 119, 34, 63,\n178, 93, 8, 51, 136, 221, 72, 157, 242, 199, 114, 29, 84,\n188, 103, 18, 61, 146, 231, 82, 167, 252, 209, 124, 39, 105,\n172, 87, 2, 45, 130, 215, 66, 151, 236, 193, 108, 23, 42,\n182, 97, 12, 55, 140, 225, 76, 161, 246, 203, 118, 33, 126,\n177, 92, 7, 50, 135, 220, 71, 156, 241, 198, 113, 28, 127,\n187, 102, 17, 60, 145, 230, 81, 166, 251, 208, 123, 38, 148,\n174, 89, 4, 47, 132, 217, 68, 153, 238, 195, 110, 25, 169,\n184, 99, 14, 57, 142, 227, 78, 163, 248, 205, 120, 35, 190,\n179, 94, 9, 52, 137, 222, 73, 158, 243, 200, 115, 30, 211,\n189, 104, 19, 62, 147, 232, 83, 168, 253, 210, 125, 40, 20,\n171, 86, 1, 44, 129, 214, 65, 150, 235, 192, 107, 22, 41,\n181, 96, 11, 54, 139, 224, 75, 160, 245, 202, 117, 32, 212,\n176, 91, 6, 49, 134, 219, 70, 155, 240, 197, 112, 27, 254,\n186, 101, 16, 59, 144, 229, 80, 165, 250, 207, 122, 37, 233 };\nfloat kMaxColor = 255.0;\nfloat h = (iPPermute[(id & 255)]) / kMaxColor;\nfloat s = 1 - ( id >> 8 ) / kMaxColor;\nc = vec3("hsv", h, s, 1.0);\n}\nvoid node_osl_getobjectid(out vec3 Col, out int Index) {\noslGetAttribute(OSL_GBUFID, Index);\nvec3ById(Index, Col);\n}',node_osl_getobjspace_mx_frag:"\nvoid node_osl_getobjspace(vec3 Input, out vec3 UVW) {\nUVW = oslTransform(OSL_OBJECT, Input);\n}",node_osl_getparticleage_mx_frag:"\nvoid node_osl_getparticleage(float Scale, out float Age) {\noslGetAttribute(OSL_PALIFE, Age);\nAge *= Scale;\n}",node_osl_gettime_mx_frag:"\nvoid node_osl_gettime(float In, float Offset, out float Out) {\nOut = In + Offset;\n}",node_osl_getuvw_mx_frag:"\nvoid node_osl_getuvw(vec2 uv, int uvSet, out vec3 uvw) {\nuvw = vec3(uv.x, 1.0 - uv.y, 0.0);\n}",node_osl_getwirecolor_mx_frag:"\nvoid node_osl_getwirecolor(out vec3 Col, out float R, out float G, out float B) {\noslGetAttribute(OSL_WIRECOLOR, Col);\nR = Col[0];\nG = Col[1];\nB = Col[2];\n}",node_osl_gradient2_mx_frag:"\nvoid node_osl_gradient2(vec3 Input, int Layers, int Add, int Delete, float Hardness, vec3 A_Col, float A_Pos, vec3 B_Col, float B_Pos, vec3 C_Col, float C_Pos, vec3 D_Col, float D_Pos, vec3 E_Col, float E_Pos, vec3 F_Col, float F_Pos, out vec3 Out) {\nOut = A_Col;\nfloat inValue = Input[0];\nif (inValue >= A_Pos && inValue < B_Pos) { float where = (inValue - A_Pos) / (B_Pos - A_Pos); where = smoothstep(Hardness, 1.0, where); Out = mix(A_Col, B_Col, where); }\nif (inValue >= B_Pos && inValue < C_Pos) { float where = (inValue - B_Pos) / (C_Pos - B_Pos); where = smoothstep(Hardness, 1.0, where); Out = mix(B_Col, C_Col, where); }\nif (inValue >= C_Pos && inValue < D_Pos) { float where = (inValue - C_Pos) / (D_Pos - C_Pos); where = smoothstep(Hardness, 1.0, where); Out = mix(C_Col, D_Col, where); }\nif (inValue >= D_Pos && inValue < E_Pos) { float where = (inValue - D_Pos) / (E_Pos - D_Pos); where = smoothstep(Hardness, 1.0, where); Out = mix(D_Col, E_Col, where); }\nif (inValue >= E_Pos && inValue < F_Pos) { float where = (inValue - E_Pos) / (F_Pos - E_Pos); where = smoothstep(Hardness, 1.0, where); Out = mix(E_Col, F_Col, where); }\n}",node_osl_greaterthan_mx_frag:"\nvoid node_osl_greaterthan(float A, float B, vec3 Greater, vec3 Else, out vec3 Out, out float Float) {\nif (A > B)\nOut = Greater;\nelse\nOut = Else;\nFloat = (Out[0]+Out[1]+Out[2])/3.0;\n}",node_osl_halftonedots_mx_frag:"\nvoid node_osl_halftonedots(vec3 UVW, vec3 Scale, float Angle, vec3 InputValue, int U_Input, float Fuzz, vec3 BlackDots, vec3 WhiteDots, out vec3 Out) {\nvec3 pos = oslRotate(UVW, radians(Angle), 0.0, vec3(0.0,0.0,1.0));\npos = vec3(pos[0] / Scale[0], pos[1] / Scale[1], 0.0);\nif (Scale[0] == 0.0)\npos[0] = 0.5;\nif (Scale[1] == 0.0)\npos[1] = 0.5;\nvec3 inputV = InputValue;\nif (U_Input)\ninputV += u;\npos = pos - floor(pos);\nfloat dist = 1.0 - (distance(vec3(0.5,0.5,0.0), pos) / (sqrt(2.0) / 2.5));\nvec3 factor = smoothstep(-Fuzz, 0.0, inputV - sqrt(max(0,dist)));\nOut = mix(BlackDots, WhiteDots, factor);\n}",node_osl_hdrienv_mx_frag:"\nvoid node_osl_hdrienv(int HDRI, float Rotation, int Flip, float TiltX, float TiltY, float Height, float Exposure, vec3 Tint, float Contrast, float Viewport, int GroundProjection, vec3 GroundCenter, float GroundRadius, int UseBackground, vec3 Background, float BackgroundMultiplier, vec3 AdditionalLight, float AdditionalLightMul, int Blur, float BlurAmount, int BlurSamples, int Clamp, float ClampStops, out vec3 Out) {\nif (UseBackground && oslRayType(OSL_CAMERA))\n{\nOut = Background * BackgroundMultiplier;\nreturn;\n}\nfloat power = Contrast;\nif (!false &&\n!false &&\n!false &&\n!false &&\n!false &&\n!false)\n{\npower *= 2.2;\n}\nfloat U = 0.0, V = 0.0;\nvec3 Direction = oslTransform(OSL_WORLD, I);\nvec3 OrgDir = Direction;\nvec3 CP = oslTransform(OSL_CAMERA, vec3(0,0,0));\nvec3 Position = oslTransform(OSL_WORLD, P);\nint HLSLBackend = 0;\nint renderer;\noslGetAttribute(OSL_RENDERER_NAME, renderer);\nif (renderer == OSL_3DSMAX_HLSL)\nHLSLBackend = 1;\nif (Position == 0.0)\nPosition = oslTransform(OSL_CAMERA, OSL_WORLD, vec3(0));\nint doBlur = Blur && BlurAmount > 0.0?oslRayType(OSL_CAMERA):0;\nint samples = doBlur?BlurSamples:1;\nfor (int i = 0; i < samples; i++)\n{\nif (doBlur)\nDirection = OrgDir + (oslNoise(OSL_HASH, I, i) - 0.5) * BlurAmount / 100.0;\nif (GroundProjection == 1 && Direction[2] < 0.0)\n{\nfloat t = (GroundCenter[2] - Position[2])/Direction[2];\nvec3 GP = Position + Direction * t;\nint doGround = 1;\nif (HLSLBackend)\n{\nif (distance(GP, CP) < 1e-4)\ndoGround = 0;\n}\nif (doGround)\n{\nvec3 TP = GroundCenter + vec3(0, 0, GroundRadius);\nDirection = normalize(GP-TP);\nif (Direction[2] > -0.1)\n{\nfloat fac = 1.0 - Direction[2] * -10.0;\nfac *= fac;\nDirection = mix(Direction, OrgDir, fac);\n}\n}\n}\nif (TiltX != 0.0)\nDirection = oslRotate(Direction, radians(TiltX), vec3(0.0), vec3(1,0,0));\nif (TiltY != 0.0)\nDirection = oslRotate(Direction, radians(TiltY), vec3(0.0), vec3(0,1,0));\nU = (Rotation / 360.0) + atan2(Direction[0],Direction[1]) / (M_PI * 2.0);\nV = 0.5 + (asin(Direction[2]) / M_PI);\nV -= Height * sqrt((1.0 - (Direction[2]*Direction[2])));\nOut += oslTexture(HDRI, Flip?-U:U, 1.0-V, OSL_WRAP, OSL_PERIODIC) * Tint;\n}\nOut /= samples;\nif (Clamp == 1)\nOut = clamp(Out, 0.0, oslPow(2.0, ClampStops));\nelse\n{\nif (Out[0] < 0.0) Out[0] = 0.0;\nif (Out[1] < 0.0) Out[1] = 0.0;\nif (Out[2] < 0.0) Out[2] = 0.0;\n}\nOut = oslPow(Out, power) * oslPow(2.0, Exposure);\nOut += AdditionalLight * AdditionalLightMul;\nif (HLSLBackend)\nOut *= Viewport;\n}",node_osl_hdrilights_mx_frag:'\nvoid node_osl_hdrilights(int Layers, int Add, int Delete, int LightOn1, vec3 helper", vec3 AdditionalLight, int VisibleToCamera, int Test, out vec3 Out) {\nOut = vec3(0.0);\n}',node_osl_idxrndcol_mx_frag:"\nvoid node_osl_idxrndcol(int Idx, int Seed, vec3 Min, vec3 Max, out vec3 Out) {\nfloat ratio = oslNoise(OSL_CELL, vec3(abs(Idx), abs(Seed), 10));\nOut = mix(Min, Max, ratio);\n}",node_osl_idxrndflt_mx_frag:"\nvoid node_osl_idxrndflt(int Idx, int Seed, float Min, float Max, out float Out) {\nfloat ratio = oslNoise(OSL_CELL, vec3(abs(Idx), abs(Seed), 11));\nOut = mix(Min, Max, ratio);\n}",node_osl_idxrndvec_mx_frag:"\nvoid node_osl_idxrndvec(int Idx, int Seed, vec3 Min, vec3 Max, out vec3 Out) {\nfloat ratio = oslNoise(OSL_CELL, vec3(abs(Idx), abs(Seed), 12));\nOut = mix(Min, Max, ratio);\n}",node_osl_interpolate_mx_frag:"\nvoid node_osl_interpolate(vec3 Input, vec3 Min, vec3 Max, out vec3 Out) {\nOut = mix(Min, Max, Input);\n}",node_osl_liftgammagain_mx_frag:"\nvoid node_osl_liftgammagain(vec3 Input, float Lift, float Gamma, float Gain, out vec3 Col) {\nCol = Lift + oslPow(Input, Gamma) * Gain;\n}",node_osl_mandelbrot_mx_frag:"\nvoid node_osl_mandelbrot(vec3 UVW, vec3 Center, float Scale, float ZImaginary, int Iterations, float ColorScale, float ColorPower, out vec3 Col, out float Fac) {\nvec3 pnt = (UVW - vec3(0.5,0.5,0)) / Scale - (Center + vec3(0,0.66,0));\nfloat cR = pnt[0];\nfloat cI = pnt[1];\nfloat zR = pnt[2];\nfloat zI = ZImaginary / Scale;\nint num = 0;\nfor (num = 0; num < Iterations; num++)\n{\nfloat zR2 = zR * zR;\nfloat zI2 = zI * zI;\nif (zR2+zI2 > 4.0)\nbreak;\nzI = 2 * zR * zI + cR;\nzR = zR2 - zI2 + cI;\n}\nFac = (float)(num * ColorScale)/ (float)Iterations;\nCol = wavelength_vec3(420 + oslPow(Fac, ColorPower) * 2000);\n}",node_osl_matcapuv_mx_frag:"\nvoid node_osl_matcapuv(vec3 N, out vec3 UVW) {\nvec3 cameraSpaceN = oslTransform(OSL_CAMERA, vec4(N, 0.0));\nUVW = cameraSpaceN *0.5 + 0.5;\n}",node_osl_noise3d_mx_frag:"\nvoid node_osl_noise3d(vec3 UVW, float Scale, int Type, int Octaves, float Lacunarity, float Gain, int StepFunction, float LowStep, float HiStep, int Normalize, float Amplitude, float Phase, out vec3 Out, out float X, out float Y, out float Z) {\n#if __VERSION__ == 100\n#define Octaves 4\n#endif\n\nvec3 pnt = UVW / Scale;\nfloat sum = 0.0;\nfloat curFreq = 1.0;\nfloat curAmp = Amplitude;\nfor (int i = 0; i < Octaves; i++)\n{\nvec3 ns = oslNoise3D(Type, pnt * curFreq, Phase + float(i));\nif (StepFunction == 1)\nns = smoothstep(LowStep, HiStep, ns);\nOut += ns * curAmp;\nsum += curAmp;\ncurFreq *= Lacunarity;\ncurAmp *= Gain;\n}\nif (Normalize == 1)\nOut /= sum / Amplitude;\nX = Out[0];\nY = Out[1];\nZ = Out[2];\n#if __VERSION__ == 100\n#undef Octaves\n#endif\n}",node_osl_noise_mx_frag:"\nvoid node_osl_noise(vec3 UVW, float Scale, int Type, int Octaves, float Lacunarity, float Gain, int StepFunction, float LowStep, float HiStep, int Normalize, float Amplitude, float Phase, out float Out) {\n#if __VERSION__ == 100\n#define Octaves 4\n#endif\n\nvec3 pnt = UVW / Scale;\nfloat sum = 0.0;\nfloat curFreq = 1.0;\nfloat curAmp = Amplitude;\nfor (int i = 0; i < Octaves; i++)\n{\nfloat ns = oslNoise(Type, pnt * curFreq, Phase + float(i));\nif (StepFunction == 1)\nns = smoothstep(LowStep, HiStep, ns);\nOut += ns * curAmp;\nsum += curAmp;\ncurFreq *= Lacunarity;\ncurAmp *= Gain;\n}\nif (Normalize == 1)\nOut /= sum / Amplitude;\n#if __VERSION__ == 100\n#undef Octaves\n#endif\n}",node_osl_normal_mx_frag:"\nvoid node_osl_normal(vec3 N, int Coordspace, out vec3 Out) {\nOut = oslTransform(Coordspace, vec4(N, 0.0));\n}",node_osl_objectprojector_mx_frag:"\nvoid node_osl_objectprojector(int INode, vec3 XAxis, vec3 YAxis, vec3 ZAxis, vec3 Position, vec3 Scale, int Projection, int Centered, int Backface, int Filename, int AutoGamma, float ManualGamma, out vec3 UV, out vec3 Col, out float Alpha) {\nvec3 pnt = oslTransform(OSL_WORLD, P) - Position;\nnormal nrm = oslTransform(OSL_WORLD, N);\nfloat xScale = length(XAxis); xScale *= xScale;\nfloat yScale = length(YAxis); yScale *= yScale;\nfloat zScale = length(ZAxis); zScale *= zScale;\nint front = 1;\nif (Projection == OSL_XY)\n{\nUV[0] = dot(pnt, XAxis) / xScale;\nUV[1] = dot(pnt, YAxis) / yScale;\nUV[2] = dot(pnt, ZAxis) / zScale;\nif (dot(ZAxis, nrm) < 0)\nfront = 0;\n}\nelse if (Projection == OSL_YZ)\n{\nUV[0] = dot(pnt, YAxis) / yScale;\nUV[1] = dot(pnt, ZAxis) / zScale;\nUV[2] = dot(pnt, XAxis) / xScale;\nif (dot(XAxis, nrm) < 0)\nfront = 0;\n}\nelse if (Projection == OSL_ZX)\n{\nUV[0] = dot(pnt, ZAxis) / zScale;\nUV[1] = dot(pnt, XAxis) / xScale;\nUV[2] = dot(pnt, YAxis) / yScale;\nif (dot(YAxis, nrm) < 0)\nfront = 0;\n}\nif (Backface == 1 || front == 1)\n{\nUV /= Scale;\nif (Centered)\nUV += vec3(0.5, 0.5, 0.0);\nif (UV[0] <= 1.0 && UV[1] <= 1.0 && UV[0] >= 0.0 && UV[1] >= 0.0)\n{\nAlpha = 1.0;\nCol = oslTexture(Filename, UV[0], 1.0-UV[1], OSL_ALPHA, Alpha);\nint channels;\noslGetTextureInfo(Filename, OSL_CHANNELS, channels);\nif (channels < 4)\n{\nAlpha = 1.0;\n}\nif (AutoGamma)\n{\nif (!false &&\n!false &&\n!false &&\n!false &&\n!false &&\n!false)\n{\nCol = oslPow(Col, 2.2);\n}\n}\nelse\n{\nif (ManualGamma != 1.0)\nCol = oslPow(Col, ManualGamma);\n}\n}\n}\n}",node_osl_oslbitmap2_mx_frag:"\nvoid node_osl_oslbitmap2(sampler2D Image, vec3 Pos, float Scale, int Filename, int Filename_UDIMList, int LoadUDIM, int UDIM, int WrapMode, int AutoGamma, float ManualGamma, out vec3 Col, out float R, out float G, out float B, out float A, out float Luminance, out float Average) {\nif (Filename == OSL_EMPTY)\nreturn;\nvec3 p = Pos / Scale;\nfloat ulookup = p[0];\nfloat vlookup = 1.0 - p[1];\nif (UDIM == 1)\n{\nfloat vfloor = floor(p[1]);\nfloat vfrac = p[1] - vfloor;\nvlookup = vfloor + (1.0 - vfrac);\n}\nCol = oslTexture(Image, ulookup, vlookup, OSL_WRAP, WrapMode, OSL_ALPHA, A);\nint channels;\noslGetTextureInfo(Filename, OSL_CHANNELS, channels);\nif (channels < 4)\n{\nA = 1.0;\nif (WrapMode == OSL_BLACK)\n{\nif (p[0] < 0.0 || p[0] > 1.0 ||\np[1] < 0.0 || p[1] > 1.0)\nA = 0.0;\n}\n}\nif (AutoGamma == 1)\n{\nif (!false &&\n!false &&\n!false &&\n!false &&\n!false &&\n!false)\n{\nCol = oslPow(Col, 2.2);\n}\n}\nelse\n{\nif (ManualGamma != 1.0)\nCol = oslPow(Col, ManualGamma);\n}\nR = Col[0];\nG = Col[1];\nB = Col[2];\nLuminance = oslLuminance(Col);\nAverage = (R + G + B) / 3.0;\n}",node_osl_oslbitmap_mx_frag:"\nvoid node_osl_oslbitmap(sampler2D Image, vec3 Pos, float Scale, int Filename, int UDIM, int WrapMode, int AutoGamma, float ManualGamma, out vec3 Col, out float R, out float G, out float B, out float A, out float Luminance, out float Average) {\nvec3 p = Pos / Scale;\nfloat ulookup = p[0];\nfloat vlookup = 1.0 - p[1];\nif (UDIM == 1)\n{\nfloat vfloor = floor(p[1]);\nfloat vfrac = p[1] - vfloor;\nvlookup = vfloor + (1.0 - vfrac);\n}\nCol = oslTexture(Image, ulookup, vlookup, OSL_WRAP, WrapMode, OSL_ALPHA, A);\nint channels;\noslGetTextureInfo(Filename, OSL_CHANNELS, channels);\nif (channels < 4)\n{\nA = 1.0;\nif (WrapMode == OSL_BLACK)\n{\nif (p[0] < 0.0 || p[0] > 1.0 ||\np[1] < 0.0 || p[1] > 1.0)\nA = 0.0;\n}\n}\nif (AutoGamma == 1)\n{\nif (!false &&\n!false &&\n!false &&\n!false &&\n!false &&\n!false)\n{\nCol = oslPow(Col, 2.2);\n}\n}\nelse\n{\nif (ManualGamma != 1.0)\nCol = oslPow(Col, ManualGamma);\n}\nR = Col[0];\nG = Col[1];\nB = Col[2];\nLuminance = oslLuminance(Col);\nAverage = (R + G + B) / 3.0;\n}",node_osl_radtodeg_mx_frag:"\nvoid node_osl_radtodeg(float Input, out float Out) {\nOut = 0.0;\n}",node_osl_randombitmaps2_mx_frag:'\nvec3 TextureFetch(int filename, vec3 lp, out float a)\n{\nif (!strlen(filename))\nreturn 0.0;\nvec3 rgb = oslTexture(filename, lp[0], 1.0-lp[1], "alpha", a, "wrap", "clamp");\nint channels = 3;\noslGetTextureInfo(filename, "channels", channels);\nif (channels <= 3)\na = 1.0;\nreturn rgb;\n}\nvoid node_osl_randombitmaps2(int Layers, int Add, int Delete, vec3 UVW, float Scale, vec3 Input, float InputAlpha, int Filename0, int Filename1, int Filename2, int Filename3, int Filename4, int NumFiles, int Seed, vec3 Probability, vec3 PosRandom, vec3 ScaleMin, vec3 ScaleMax, int UniformScale, float PixelScale, float RotMin, float RotMax, int RotSteps, vec3 HSVMin, vec3 HSVMax, float AlphaMin, float AlphaMax, float GammaMin, float GammaMax, int Clamp, int AutoGamma, float ManualGamma, int OverLap, out vec3 Out, out float Alpha) {\nint oslversion = 0;\noslGetAttribute(OSL_OSL_VERSION, oslversion);\nvec3 UVWs = UVW / Scale;\nint ix = int(floor(UVWs[0]));\nint iy = int(floor(UVWs[1]));\nfloat fx = UVWs[0] - ix;\nfloat fy = UVWs[1] - iy;\nfloat gamma = 1.0;\nif (AutoGamma)\n{\nif (!false &&\n!false &&\n!false &&\n!false &&\n!false &&\n!false)\n{\ngamma = 2.2;\n}\n}\nelse\n{\ngamma = ManualGamma;\n}\nOut = Input;\nAlpha = InputAlpha;\nint modValue = Layers+1;\nif (NumFiles > 0 && NumFiles <= Layers)\nmodValue = NumFiles;\nfor (int xx = -OverLap; xx <= OverLap; xx++)\n{\nfor(int yy = -OverLap; yy <= OverLap; yy++)\n{\nvec3 rndvec3 = vec3(ix + xx, iy + yy, Seed);\nif (oslversion >= 11000)\n{\nrndvec3[0] = rndvec3[0] < 0 ? rndvec3[0]-1: rndvec3[0];\nrndvec3[1] = rndvec3[1] < 0 ? rndvec3[1]-1: rndvec3[1];\nrndvec3[2] = rndvec3[2] < 0 ? rndvec3[2]-1: rndvec3[2];\n}\nvec3 pos = ((oslNoise(OSL_CELL, rndvec3, 0) - vec3(0.5,0.5,0.0)) * vec3(PosRandom[0], PosRandom[1], 1.0));\nvec3 lp = vec3(fx-xx, fy-yy, 0) - pos;\nfloat prob = Probability[0] + oslNoise(OSL_PERLIN, rndvec3 * Probability[2]) * Probability[1];\nif (pos[2] < prob)\n{\nvec3 scr = oslNoise(OSL_CELL, rndvec3, 1);\nint pic = int((float)oslNoise(OSL_CELL, rndvec3, 15) * 100) % modValue;\nfloat sx = 1.0, sy = 1.0;\nif (PixelScale > 0.0)\n{\nint res[2];\nif (pic == 0) oslGetTextureInfo(Filename0, OSL_RESOLUTION, res);\nelse if (pic == 1) oslGetTextureInfo(Filename1, OSL_RESOLUTION, res);\nelse if (pic == 2) oslGetTextureInfo(Filename2, OSL_RESOLUTION, res);\nelse if (pic == 3) oslGetTextureInfo(Filename3, OSL_RESOLUTION, res);\nelse if (pic == 4) oslGetTextureInfo(Filename4, OSL_RESOLUTION, res);\nsx = res[0] / PixelScale;\nsy = res[1] / PixelScale;\n}\nfloat scaleX = sx * mix(ScaleMin[0], ScaleMax[0], scr[0]);\nfloat scaleY = sy * mix(ScaleMin[1], ScaleMax[1], scr[UniformScale?0:1]);\nif (RotSteps > 1)\n{\nscr[2] = floor(scr[2] * RotSteps) / (RotSteps - 1);\n}\nfloat rot = mix(RotMin, RotMax, scr[2]);\nlp -= 0.5;\nlp = oslRotate(lp, radians(rot), vec3(0,0,0), vec3(0,0,1));\nlp /= vec3(scaleX, scaleY, 1.0);\nlp += 0.5;\nif (lp[0] >= 0.0 && lp[0] < 1.0 &&\nlp[1] >= 0.0 && lp[1] < 1.0)\n{\nvec3 rgb;\nfloat a = 1.0;\nif (pic == 0) rgb = TextureFetch(Filename0, lp, a);\nelse if (pic == 1) rgb = TextureFetch(Filename1, lp, a);\nelse if (pic == 2) rgb = TextureFetch(Filename2, lp, a);\nelse if (pic == 3) rgb = TextureFetch(Filename3, lp, a);\nelse if (pic == 4) rgb = TextureFetch(Filename4, lp, a);\nif (a > 0.0)\n{\nvec3 clr = oslNoise(OSL_CELL, rndvec3, 2);\nvec3 arr = oslNoise(OSL_CELL, rndvec3, 3);\nfloat gr = mix(GammaMin, GammaMax, arr[1]);\nif (gamma + gr != 1.0)\nrgb = oslPow(rgb, gamma + gr);\nvec3 hsvTweak = mix(HSVMin, HSVMax, clr);\nfloat ar = mix(AlphaMin, AlphaMax, arr[0]);\nvec3 hsv = oslTransformC(OSL_RGB, OSL_HSV, rgb);\nhsv[0] += hsvTweak[0];\nhsv[1] *= hsvTweak[1];\nhsv[2] *= hsvTweak[2];\nrgb = oslTransformC(OSL_HSV, OSL_RGB, hsv);\nrgb *= ar; a *= ar;\nif (Clamp == 1)\nrgb = clamp(rgb, 0.0, 1.0);\n}\nAlpha = 1.0 - ((1.0-Alpha)*(1.0-a));\nOut = Out * (1.0-a) + rgb;\n}\n}\n}\n}\n}',node_osl_randombitmaps_mx_frag:'\nvec3 TextureFetch(int filename, vec3 lp, out float a)\n{\nvec3 rgb = oslTexture(filename, lp[0], 1.0-lp[1], "alpha", a, "wrap", "clamp");\nint channels = 3;\noslGetTextureInfo(filename, "channels", channels);\nif (channels <= 3)\na = 1.0;\nreturn rgb;\n}\nvoid node_osl_randombitmaps(vec3 UVW, vec3 Input, float InputAlpha, int NumFiles, int Filename0, int Filename1, int Filename2, int Filename3, int Filename4, int Filename5, int Filename6, int Filename7, int Filename8, int Filename9, int Seed, vec3 Probability, vec3 PosRandom, vec3 ScaleMin, vec3 ScaleMax, int UniformScale, float PixelScale, float RotMin, float RotMax, int RotSteps, vec3 HSVMin, vec3 HSVMax, float AlphaMin, float AlphaMax, float GammaMin, float GammaMax, int Clamp, int AutoGamma, float ManualGamma, int OverLap, out vec3 Out, out float Alpha) {\nint oslversion = 0;\noslGetAttribute(OSL_OSL_VERSION, oslversion);\nint ix = int(floor(UVW[0]));\nint iy = int(floor(UVW[1]));\nfloat fx = UVW[0] - ix;\nfloat fy = UVW[1] - iy;\nfloat gamma = 1.0;\nif (AutoGamma)\n{\nif (!false &&\n!false &&\n!false &&\n!false &&\n!false &&\n!false)\n{\ngamma = 2.2;\n}\n}\nelse\n{\ngamma = ManualGamma;\n}\nOut = Input;\nAlpha = InputAlpha;\nfor (int xx = -OverLap; xx <= OverLap; xx++)\n{\nfor(int yy = -OverLap; yy <= OverLap; yy++)\n{\nvec3 rndvec3 = vec3(ix + xx, iy + yy, Seed);\nif (oslversion >= 11000)\n{\nrndvec3[0] = rndvec3[0] < 0 ? rndvec3[0]-1: rndvec3[0];\nrndvec3[1] = rndvec3[1] < 0 ? rndvec3[1]-1: rndvec3[1];\nrndvec3[2] = rndvec3[2] < 0 ? rndvec3[2]-1: rndvec3[2];\n}\nvec3 pos = ((oslNoise(OSL_CELL, rndvec3, 0) - vec3(0.5,0.5,0.0)) * vec3(PosRandom[0], PosRandom[1], 1.0));\nvec3 lp = vec3(fx-xx, fy-yy, 0) - pos;\nfloat prob = Probability[0] + oslNoise(OSL_PERLIN, rndvec3 * Probability[2]) * Probability[1];\nif (pos[2] < prob)\n{\nvec3 scr = oslNoise(OSL_CELL, rndvec3, 1);\nint pic = int((float)oslNoise(OSL_CELL, rndvec3, 15) * 100) % NumFiles;\nfloat sx = 1.0, sy = 1.0;\nif (PixelScale > 0.0)\n{\nint res[2];\nif (pic == 0) oslGetTextureInfo(Filename0, OSL_RESOLUTION, res);\nelse if (pic == 1) oslGetTextureInfo(Filename1, OSL_RESOLUTION, res);\nelse if (pic == 2) oslGetTextureInfo(Filename2, OSL_RESOLUTION, res);\nelse if (pic == 3) oslGetTextureInfo(Filename3, OSL_RESOLUTION, res);\nelse if (pic == 4) oslGetTextureInfo(Filename4, OSL_RESOLUTION, res);\nelse if (pic == 5) oslGetTextureInfo(Filename5, OSL_RESOLUTION, res);\nelse if (pic == 6) oslGetTextureInfo(Filename6, OSL_RESOLUTION, res);\nelse if (pic == 7) oslGetTextureInfo(Filename7, OSL_RESOLUTION, res);\nelse if (pic == 8) oslGetTextureInfo(Filename8, OSL_RESOLUTION, res);\nelse if (pic == 9) oslGetTextureInfo(Filename9, OSL_RESOLUTION, res);\nsx = res[0] / PixelScale;\nsy = res[1] / PixelScale;\n}\nfloat scaleX = sx * mix(ScaleMin[0], ScaleMax[0], scr[0]);\nfloat scaleY = sy * mix(ScaleMin[1], ScaleMax[1], scr[UniformScale?0:1]);\nif (RotSteps > 1)\n{\nscr[2] = floor(scr[2] * RotSteps) / (RotSteps - 1);\n}\nfloat rot = mix(RotMin, RotMax, scr[2]);\nlp -= 0.5;\nlp = oslRotate(lp, radians(rot), vec3(0,0,0), vec3(0,0,1));\nlp /= vec3(scaleX, scaleY, 1.0);\nlp += 0.5;\nif (lp[0] >= 0.0 && lp[0] < 1.0 &&\nlp[1] >= 0.0 && lp[1] < 1.0)\n{\nvec3 rgb;\nfloat a = 1.0;\nif (pic == 0) rgb = TextureFetch(Filename0, lp, a);\nelse if (pic == 1) rgb = TextureFetch(Filename1, lp, a);\nelse if (pic == 2) rgb = TextureFetch(Filename2, lp, a);\nelse if (pic == 3) rgb = TextureFetch(Filename3, lp, a);\nelse if (pic == 4) rgb = TextureFetch(Filename4, lp, a);\nelse if (pic == 5) rgb = TextureFetch(Filename5, lp, a);\nelse if (pic == 6) rgb = TextureFetch(Filename6, lp, a);\nelse if (pic == 7) rgb = TextureFetch(Filename7, lp, a);\nelse if (pic == 8) rgb = TextureFetch(Filename8, lp, a);\nelse if (pic == 9) rgb = TextureFetch(Filename9, lp, a);\nif (a > 0.0)\n{\nvec3 clr = oslNoise(OSL_CELL, rndvec3, 2);\nvec3 arr = oslNoise(OSL_CELL, rndvec3, 3);\nfloat gr = mix(GammaMin, GammaMax, arr[1]);\nif (gamma + gr != 1.0)\nrgb = oslPow(rgb, gamma + gr);\nvec3 hsvTweak = mix(HSVMin, HSVMax, clr);\nfloat ar = mix(AlphaMin, AlphaMax, arr[0]);\nvec3 hsv = oslTransformC(OSL_RGB, OSL_HSV, rgb);\nhsv[0] += hsvTweak[0];\nhsv[1] *= hsvTweak[1];\nhsv[2] *= hsvTweak[2];\nrgb = oslTransformC(OSL_HSV, OSL_RGB, hsv);\nrgb *= ar; a *= ar;\nif (Clamp == 1)\nrgb = clamp(rgb, 0.0, 1.0);\n}\nAlpha = 1.0 - ((1.0-Alpha)*(1.0-a));\nOut = Out * (1.0-a) + rgb;\n}\n}\n}\n}\n}',node_osl_randomindex_mx_frag:"\nvoid node_osl_randomindex(float InputNumber, vec3 InputColor, int Seed, int Min, int Max, out int Out) {\nfloat ratio = oslNoise(OSL_CELL, (vec3(InputNumber*InputColor[0], Seed*InputColor[1], 11*InputColor[2])));\nOut = int(floor(mix(Min, (Max + 0.99), ratio)));\n}",node_osl_rivets_mx_frag:"\nfloat edgeTweak(float gap, float width, float coord)\n{\nreturn smoothstep(gap, gap+width, coord);\n}\nvoid node_osl_rivets(vec3 UVW, float Scale, int U_Rivets, int V_Rivets, float RivetRadius, float Dirt, int Seed, vec3 PlateColor, vec3 RivetColor, vec3 DirtColor, vec3 SpaceColor, vec3 HoleColor, vec3 RivetCenter, vec3 RivetRandom, float RivetProbability, float HoleRadius, float HoleEdge, float BumpAmount, float BumpShape, float PlateGap, float PlateEdge, vec3 PlateWobble, vec3 WobbleScale, int RivetWobble, out vec3 Col, out float RivetFac, out float HoleFac, out float PlateFac, out float Dist, out float Bump, out int TileIdx, out int PlateIdx) {\nfloat RR = RivetRadius / 2.0;\nvec3 p = UVW / Scale;\nint plateIdx = int(p[0]) * 13 + int(p[1]) * 32 + 115 * Seed;\nvec3 modP = fmod(p, vec3(1));\nvec3 wob = oslNoise(OSL_PERLIN, modP / WobbleScale, plateIdx);\nmodP += (PlateWobble / 10.0) * wob;\nif (modP[0] < PlateGap || 1.0 - modP[0] < PlateGap ||\nmodP[1] < PlateGap || 1.0 - modP[1] < PlateGap)\n{\nCol = SpaceColor;\nPlateFac = 0.0;\nPlateIdx = 0;\n}\nelse\n{\nCol = PlateColor;\nPlateFac = 1.0 + PlateWobble[2] * wob[2] * 5.0;\nPlateFac *= edgeTweak(PlateGap, PlateEdge, modP[0]);\nPlateFac *= edgeTweak(PlateGap, PlateEdge, modP[1]);\nPlateFac *= edgeTweak(PlateGap, PlateEdge, 1.0 - modP[0]);\nPlateFac *= edgeTweak(PlateGap, PlateEdge, 1.0 - modP[1]);\nPlateIdx = plateIdx;\n}\nif (RivetWobble)\np += (PlateWobble / 10.0) * wob;\nfloat rivetu = p[0] * U_Rivets;\nfloat rivetv = p[1] * V_Rivets;\nint rcU = int(rivetu);\nint rcV = int(rivetv);\nTileIdx = rcU + rcV * 100 + 50 * Seed;\nrcU = rcU % U_Rivets;\nrcV = rcV % V_Rivets;\nif (rcU == 0 || rcV == 0 ||\nrcU == U_Rivets-1 || rcV == V_Rivets-1)\n{\nvec3 rnd = (oslNoise(OSL_CELL, TileIdx) - vec3(0.5,0.5,0));\nint doit = rnd[2] < RivetProbability;\nrnd[2] = 0;\nvec3 rp = vec3(fmod(rivetu, 1.0), fmod(rivetv, 1.0), 0);\nvec3 rc = RivetCenter + RivetRandom * rnd;\nfloat dist = distance(rp, rc);\nDist = dist / RR;\nif (dist < RR && doit)\n{\nBump = oslPow(sin((1.0 - Dist) * 1.5), BumpShape) * BumpAmount;\nCol = RivetColor;\nRivetFac = 1.0;\n}\nelse if (dist < RR + Dirt)\n{\nfloat da = smoothstep(0.0, 1.0, (dist - RR) / Dirt);\nCol = mix(DirtColor * Col, Col, da);\nif (dist < HoleRadius + HoleEdge)\n{\nPlateFac *= clamp((dist - HoleRadius) / HoleEdge, 0.0, 1.0);\nif (dist < HoleRadius)\n{\nCol = HoleColor;\nRivetFac = 1.0;\nHoleFac = 1.0;\n}\n}\n}\n}\nBump += PlateFac;\n}",node_osl_setcolor_mx_frag:"\nvoid node_osl_setcolor(vec3 In, out vec3 Out) {\nOut = In;\n}",node_osl_setfile_mx_frag:"\nvoid node_osl_setfile(int In, int DoPreview, out vec3 Preview, out int FileName) {\nFileName = In;\nif (DoPreview)\n{\nint res[2];\nif (oslGetTextureInfo(FileName, OSL_RESOLUTION, res))\n{\nfloat x = u, y = v;\nif (res[0] > res[1])\n{\ny = ((y - 0.5) * float(res[0]) / float(res[1])) + 0.5;\n}\nelse\n{\nx = ((x - 0.5) * float(res[1]) / float(res[0])) + 0.5;\n}\nPreview = oslTexture(FileName, x, 1-y);\nif (!false && !false &&\n!false && !false &&\n!false && !false)\n{\nPreview = oslPow(Preview, 2.2);\n}\n}\n}\n}",node_osl_setfloat_mx_frag:"\nvoid node_osl_setfloat(float In, out float Out) {\nOut = In;\n}",node_osl_setint_mx_frag:"\nvoid node_osl_setint(int In, out int Out) {\nOut = In;\n}",node_osl_setnumfile_mx_frag:"\nvoid node_osl_setnumfile(int In, int Number, int FrameCount, int Extension, int Replace, int DoPreview, out vec3 Preview, out int FileName) {\nPreview = vec3(0.0);\nFileName = 0;\n}",node_osl_setstring_mx_frag:"\nvoid node_osl_setstring(int In, out int Out) {\nOut = In;\n}",node_osl_setvector_mx_frag:"\nvoid node_osl_setvector(vec3 In, out vec3 Out) {\nOut = In;\n}",node_osl_simplegradient_mx_frag:"\nvoid node_osl_simplegradient(vec3 Input, float Hardness, vec3 A, float A_Value, vec3 B, float B_Value, vec3 C, float C_Value, vec3 D, float D_Value, vec3 E, float E_Value, vec3 F, float F_Value, out vec3 Out) {\nOut = F;\nfloat inValue = Input[0];\nif (inValue >= A_Value && inValue < B_Value) { float where = (inValue - A_Value) / (B_Value - A_Value); where = smoothstep(Hardness, 1.0, where); Out = mix(A, B, where); }\nif (inValue >= B_Value && inValue < C_Value) { float where = (inValue - B_Value) / (C_Value - B_Value); where = smoothstep(Hardness, 1.0, where); Out = mix(B, C, where); }\nif (inValue >= C_Value && inValue < D_Value) { float where = (inValue - C_Value) / (D_Value - C_Value); where = smoothstep(Hardness, 1.0, where); Out = mix(C, D, where); }\nif (inValue >= D_Value && inValue < E_Value) { float where = (inValue - D_Value) / (E_Value - D_Value); where = smoothstep(Hardness, 1.0, where); Out = mix(D, E, where); }\nif (inValue >= E_Value && inValue < F_Value) { float where = (inValue - E_Value) / (F_Value - E_Value); where = smoothstep(Hardness, 1.0, where); Out = mix(E, F, where); }\n}",node_osl_simpletiles_mx_frag:"\nint doRect(float loX, float hiX, float loY, float hiY, int Tile, int InIdx, float Radius,\nvec3 uvw, vec3 baseuvw, float GapWidth, vec3 Tiling, float Edge, out float Bump, out int Index\n)\n{\nfloat x = uvw[0] / Tiling[0], y = uvw[1] / Tiling[1];\nfloat lox = loX / Tiling[0];\nfloat hix = hiX / Tiling[0];\nfloat loy = loY / Tiling[1];\nfloat hiy = hiY / Tiling[1];\nif (x < lox + GapWidth ||\nx > hix - GapWidth ||\ny < loy + GapWidth ||\ny > hiy - GapWidth)\nreturn 0;\nfloat gwr = GapWidth + Radius;\nfloat lx = x - (lox + gwr);\nfloat ly = y - (loy + gwr);\nfloat hx = x - (hix - gwr);\nfloat hy = y - (hiy - gwr);\nvec3 dp = vec3(lx<0.0?lx:(hx>0.0?hx:0.0), ly<0.0?ly:(hy>0.0?hy:0.0), 0.0);\nfloat d = length(dp);\nif (d > Radius) return 0;\nif (Radius > Edge)\nBump = 1.0 - smoothstep(Radius-Edge, Radius+Edge, d);\nelse\n{\nfloat lx = x - (lox + GapWidth);\nfloat ly = y - (loy + GapWidth);\nfloat hx = x - (hix - GapWidth);\nfloat hy = y - (hiy - GapWidth);\nBump = smoothstep(-Edge, Edge, lx);\nBump *= smoothstep(-Edge, Edge, -hx);\nBump *= smoothstep(-Edge, Edge, ly);\nBump *= smoothstep(-Edge, Edge, -hy);\n}\nIndex = InIdx;\nreturn Tile;\n}\nvoid node_osl_simpletiles(vec3 UVW, float Scale, int TileMode, float U_Count, float V_Count, float TilingOffset, float GapWidth, float Radius, float Edge, float EdgeBump, float ColorBump, vec3 GapColor, vec3 TileColor1, vec3 TileColor2, vec3 TileColor3, out vec3 Col, out float Bump, out int Tile, out int TileIdx, out int Index) {\nint Overlap = 1;\nvec3 Tiling = vec3(U_Count, V_Count, 0.0);\nCol = GapColor;\nvec3 uvw = UVW * Tiling / Scale;\nfloat to = TilingOffset;\nfloat to2 = to*0.5;\nfloat Roundness = Radius / 10.0;\nvec3 fluvw = floor(uvw);\nvec3 fruvw = uvw - fluvw;\nfor (int xx = -Overlap; xx <= 0; xx++)\n{\nvec3 lookup = uvw - fluvw - vec3(float(xx),0,0);\nint HitIdx = 0;\nif (TileMode == 0)\n{\nif (Tile == 0)\nTile = doRect(0.0 ,1.0, 0.0, 0.5, 1, 1, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(to, to+1.0, 0.5, 1.0, 2, 2, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\n}\nif (TileMode == 1)\n{\nif (Tile == 0)\nTile = doRect(0.0 ,0.5, 0.0, 0.5, 1, 1, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.0, 0.5, 0.5, 1.0, 2, 2, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.5 ,1.0, 0.0, 0.5, 2, 3, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.5, 1.0, 0.5, 1.0, 1, 4, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\n}\nif (TileMode == 2)\n{\nif (Tile == 0)\nTile = doRect(0.0 ,1.0, 0.0, 0.5, 1, 1, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.0+to2, 0.5+to2, 0.5, 1.0, 2, 2, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.5+to2, 1.0+to2, 0.5, 1.0, 2, 3, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\n}\nif (TileMode == 3)\n{\nif (Tile == 0)\nTile = doRect(0.0 ,1.0, 0.0, 0.5, 1, 1, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.0+to, 0.5+to, 0.5, 0.75, 2, 2, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.5+to, 1.0+to, 0.5, 0.75, 2, 3, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.0+to2, 0.5+to2, 0.75, 1.0, 3, 4, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.5+to2, 1.0+to2, 0.75, 1.0, 3, 5, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\n}\nif (TileMode == 4)\n{\nif (Tile == 0)\nTile = doRect(0.0, 1.0-to2, 0.0, to2, 1, 1, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(to2, 1.0, 1.0-to2, 1.0, 1, 2, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(0.0, to2, to2, 1.0, 2, 3, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(1.0-to2, 1.0, 0.0, 1.0-to2, 2, 4, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\nif (Tile == 0)\nTile = doRect(to2, 1.0-to2, to2, 1.0-to2, 3, 5, Roundness, lookup,fluvw+vec3(float(xx),0,0),GapWidth*0.05,Tiling,Edge*0.1,Bump,HitIdx);\n}\nif (HitIdx > 0)\n{\nTileIdx = HitIdx;\nIndex = HitIdx + int(float(oslCellNoise(fluvw+vec3(float(xx),0,0))) * 1024.0);\n}\n}\nif (Tile == 1) Col = TileColor1;\nif (Tile == 2) Col = TileColor2;\nif (Tile == 3) Col = TileColor3;\nBump *= EdgeBump;\nBump += dot(vec3(0.3333), Col) * ColorBump;\n}",node_osl_smoothstepc_mx_frag:"\nvoid node_osl_smoothstepc(vec3 Input, vec3 Low, vec3 High, out vec3 Out) {\nOut = smoothstep(Low, High, Input);\n}",node_osl_specglostophysical_mx_frag:"\nvoid node_osl_specglostophysical(vec3 In, float Glossiness, int Fresnel, out float Reflectivity, out vec3 ReflColor, out float Roughness) {\nRoughness = 1.0 - Glossiness;\nReflectivity = max(max(In[0],In[1]),In[2]);\nif (Reflectivity > 0.0)\nReflColor = In / Reflectivity;\nif (Fresnel)\n{\nfloat fres = oslPow(1-abs(dot(I, N)),5.0) * Glossiness;\nReflectivity = mix(Reflectivity, 1.0, fres);\nReflColor = mix(ReflColor, 1.0, fres);\n}\n}",node_osl_sphericalprojector_mx_frag:"\nvoid node_osl_sphericalprojector(int INode, vec3 XAxis, vec3 YAxis, vec3 ZAxis, vec3 Position, int Backface, int Filename, int AutoGamma, float ManualGamma, out vec3 UV, out vec3 Col, out float Alpha) {\nvec3 pnt = oslTransform(OSL_WORLD, P) - Position;\nnormal nrm = oslTransform(OSL_WORLD, N);\nfloat xScale = length(XAxis); xScale *= xScale;\nfloat yScale = length(YAxis); yScale *= yScale;\nfloat zScale = length(ZAxis); zScale *= zScale;\nint front = 1;\nvec3 D = normalize(pnt);\nvec3 Direction = vec3(dot(D,XAxis), dot(D,YAxis), dot(D,ZAxis));\nUV[0] = atan2(Direction[0],Direction[1]) / (M_PI * 2.0);\nUV[1] = 0.5 + (asin(Direction[2]) / M_PI);\nUV[2] = 0.0;\nif (dot(Direction, nrm) > 0)\nfront = 0;\nif (Backface == 1 || front == 1)\n{\nAlpha = 1.0;\nCol = oslTexture(Filename, UV[0], 1.0-UV[1], OSL_ALPHA, Alpha, OSL_WRAP, OSL_PERIODIC);\nint channels;\noslGetTextureInfo(Filename, OSL_CHANNELS, channels);\nif (channels < 4)\n{\nAlpha = 1.0;\n}\nif (AutoGamma)\n{\nif (!false &&\n!false &&\n!false &&\n!false &&\n!false &&\n!false)\n{\nCol = oslPow(Col, 2.2);\n}\n}\nelse\n{\nif (ManualGamma != 1.0)\nCol = oslPow(Col, ManualGamma);\n}\n}\n}",node_osl_threads_mx_frag:"\nvoid node_osl_threads(float ThreadWidth, float EndV, float BaseLevel, float ThreadHeight, out vec3 Out) {\nOut = BaseLevel;\nif (v < EndV)\n{\nfloat foo = (v) / (EndV);\nfloat Revolutions = EndV / ThreadWidth;\nfloat taper = 1.0 - smoothstep(1.0 - 0.5 / Revolutions, 1.0, foo);\nfoo *= Revolutions;\nfoo -= u;\nOut = (sin(foo * M_2PI) + 1.0) * (ThreadHeight/2.0);\nOut = mix(BaseLevel, Out, taper);\n}\n}",node_osl_toonwidth_mx_frag:"\nvoid node_osl_toonwidth(vec3 ThickDirection, float Base, float Amt, out float Out) {\nvec3 camN = oslTransform(OSL_CAMERA, N);\nOut = Base + Amt * dot(ThickDirection, camN);\n}",node_osl_tritone_mx_frag:"\nvoid node_osl_tritone(vec3 Input, vec3 Highlights, vec3 Midtones, vec3 Shadows, float MidtoneLum, out vec3 Out) {\nvec3 below = clamp((Input / MidtoneLum), 0.0, 1.0);\nvec3 above = clamp((Input - MidtoneLum) / (1.0 - MidtoneLum), 0.0, 1.0);\nOut = mix(Shadows, mix(Midtones, Highlights, above), below);\n}",node_osl_uberbitmap2_mx_frag:"\nvoid node_osl_uberbitmap2(int UVSet, float Scale, vec3 Tiling, vec3 Offset, int RealWorld, float RealWidth, float RealHeight, float Rotate, vec3 RotCenter, vec3 RotAxis, int Filename, int Filename_UDIMList, int LoadUDIM, int UDIM, int WrapMode, int AutoGamma, float ManualGamma, out vec3 Col, out float R, out float G, out float B, out float A, out float Luminance, out float Average) {\nCol = vec3(0.0);\nR = 0.0;\nG = 0.0;\nB = 0.0;\nA = 0.0;\nLuminance = 0.0;\nAverage = 0.0;\n}",node_osl_uberbitmap_mx_frag:"\nvoid node_osl_uberbitmap(int UVSet, float Scale, vec3 Tiling, vec3 Offset, float Rotate, vec3 RotCenter, vec3 RotAxis, int Filename, int UDIM, int WrapMode, int AutoGamma, float ManualGamma, out vec3 Col, out float R, out float G, out float B, out float A, out float Luminance, out float Average) {\nCol = vec3(0.0);\nR = 0.0;\nG = 0.0;\nB = 0.0;\nA = 0.0;\nLuminance = 0.0;\nAverage = 0.0;\n}",node_osl_ubercolorcorrect_mx_frag:"\nfloat remap(vec3 In, int mapping)\n{\nif (mapping < 3)\nreturn In[mapping];\nif (mapping < 6)\nreturn 1.0 - In[mapping-3];\nif (mapping == 6) return oslLuminance(In);\nif (mapping == 7) return 1.0 - oslLuminance(In);\nif (mapping == 8) return 0.0;\nreturn 1.0;\n}\nvoid node_osl_ubercolorcorrect(vec3 Input, int Bypass, float Overall, int HueRange, vec3 AffectHue, float HueRangeWidth, float HueRangeSoftness, int ChannelMapping, int RedMapping, int GreenMapping, int BlueMapping, int BrightnessAdjustment, int Invert, float Brightness, float Contrast, float Lift, float Pivot, int InverseGamma, float Gamma, int ColorAdjustment, float HueShift, float Saturation, vec3 TintColor, float TintStrength, int OutputTint, vec3 Shadows, vec3 Midtones, vec3 Highlights, float MidtoneLum, int Clamp, float ClampLow, float ClampHi, int Reset, out vec3 Out, out float R, out float G, out float B) {\nfloat effect = Overall;\nOut = Input;\nif (Bypass == 0)\n{\nif (HueRange == 1)\n{\nvec3 hsv = oslTransformC(OSL_RGB, OSL_HSV, Input);\nvec3 hsv2 = oslTransformC(OSL_RGB, OSL_HSV, AffectHue);\nfloat huedifference = abs(hsv[0] - hsv2[0]);\nif (huedifference > 0.5)\nhuedifference = 1.0 - huedifference;\nfloat HRW = HueRangeWidth / 360.0 / 2.0;\nfloat HRS = HueRangeSoftness / 360.0;\nif (huedifference > HRW)\n{\nif (HRS > 0.0)\neffect *= smoothstep(0.0, 1.0, 1.0 - (huedifference - HRW) / HRS);\nelse\neffect = 0.0;\n}\n}\nif (ChannelMapping == 1)\n{\nOut[0] = remap(Input, RedMapping);\nOut[1] = remap(Input, GreenMapping);\nOut[2] = remap(Input, BlueMapping);\n}\nif (BrightnessAdjustment == 1)\n{\nif (Invert == 1) Out = 1.0 - Out;\nOut = Out * Brightness;\nOut = ((Out - Pivot) * Contrast) + Pivot;\nOut = Out + Lift;\nif (Gamma != 1.0)\nOut = oslPow(max(vec3(0.0), Out), bool(InverseGamma)?1.0/Gamma:Gamma);\n}\nif (ColorAdjustment == 1)\n{\nvec3 hsv = oslTransformC(OSL_RGB, OSL_HSV, Out);\nhsv[0] += HueShift;\nhsv[1] *= Saturation;\nOut = oslTransformC(OSL_HSV, OSL_RGB, hsv);\nOut = mix(Out, TintColor * hsv[2], TintStrength);\n}\nif (OutputTint == 1)\n{\nvec3 below = clamp((Out / MidtoneLum), 0.0, 1.0);\nvec3 above = clamp((Out - MidtoneLum) / (1.0 - MidtoneLum), 0.0, 1.0);\nOut = mix(Shadows, mix(Midtones, Highlights, above), below);\n}\nif (Clamp == 1)\nOut = clamp(Out, ClampLow, ClampHi);\nOut = mix(Input, Out, effect);\n}\nR = Out[0];\nG = Out[1];\nB = Out[2];\n}",node_osl_ubernoise_mx_frag:"\nfloat WorleyNoise(vec3 pnt, float phase, int mode, float power, float jitter, out vec3 closestvec3)\n{\nfloat closestdist = 1000;\nvec3 cellpnt = floor(pnt+0.5);\nvec3 offset = pnt - cellpnt;\nfor (int x = -1; x <= 1; x++)\n{\nfor (int y = -1; y <= 1; y++)\n{\nfor (int z = -1; z <= 1; z++)\n{\nvec3 base = cellpnt + vec3(x,y,z);\nfloat distort = oslCellNoise(base, phase) - 0.5;\nvec3 dist = pnt - (base + distort * jitter);\nfloat d = 0.0;\nif (mode == 0)\n{\nd = dot(dist, dist);\n}\nelse if (mode == 1)\n{\nd = abs(dist[0]) + abs(dist[1]) + abs(dist[2]);\n}\nelse if (mode == 2)\n{\nfloat x = abs(dist[0]);\nfloat y = abs(dist[1]);\nfloat z = abs(dist[2]);\nd = max(z,max(x,y));\n}\nelse if (mode == 3)\n{\nd = sqrt(abs(dist[0])) + sqrt(abs(dist[1])) + sqrt(abs(dist[2]));\n}\nelse if (mode == 4)\n{\nfloat x = dist[0]*dist[0];\nfloat y = dist[1]*dist[1];\nfloat z = dist[2]*dist[2];\nd = sqrt(x*x + y*y + z*z);\n}\nd = oslPow(d, power);\nif (d < closestdist)\n{\nclosestvec3 = base;\nclosestdist = d;\n}\n}\n}\n}\nreturn 1.0 - closestdist / 1.4142;\n}\nvoid node_osl_ubernoise(vec3 UVW, float Scale, int Type, float WorleyPower, float WorleyJitter, int Iterations, float Lacunarity, float Gain, int Mode, int LayerDistort, float LayerDistAmount, float LayerDistScale, float LayerDistRatio, int LayerStepFunction, float LayerLowStep, float LayerHiStep, int Normalize, float Amplitude, int OutputStepFunction, float OutputLowStep, float OutputHiStep, vec3 A, vec3 B, float Phase, out vec3 Color, out float Float, out vec3 CellRandomness, out vec3 CellCenter) {\nvec3 pnt = UVW / Scale;\nfloat sum = 0;\nfloat curFreq = 1.0;\nfloat curAmp = 1.0;\nfloat curPhase = Phase;\nfloat curDistFreq = LayerDistScale;\nfloat result = 0.0, lastResult = 1.0;\nvec3 cellvec3 = 0;\nif (Mode > 0)\n{\nsum = 1.0;\nresult = 1.0;\n}\nfor (int i = 0; i < Iterations; i++)\n{\nfloat ns = 0.0;\nvec3 noisePoint = pnt * curFreq;\nif (LayerDistort)\n{\nvec3 distort = oslNoise(OSL_PERLIN, pnt * curDistFreq, curPhase);\nnoisePoint += distort * LayerDistAmount;\ncurDistFreq *= LayerDistRatio;\n}\nif (Type == -1)\nns = oslNoise(OSL_USIMPLEX, noisePoint, curPhase + i);\nelse if (Type == 0)\nns = oslNoise(OSL_UPERLIN, noisePoint, curPhase + i);\nelse if (Type == 1)\nns = abs(oslNoise(OSL_PERLIN, noisePoint, curPhase + i));\nelse if (Type == 2)\nns = oslNoise(OSL_CELL, noisePoint, curPhase + i);\nelse\nns = WorleyNoise(noisePoint, curPhase + i, Type - 3, WorleyPower, WorleyJitter, cellvec3);\nif (LayerStepFunction)\nns = smoothstep(LayerLowStep, LayerHiStep, ns);\nif (Mode == 0)\n{\nresult += ns * curAmp;\nsum += curAmp;\n}\nelse if (Mode == 1)\n{\nresult += ns * curAmp * lastResult;\nsum += curAmp;\n}\nelse if (Mode == 2)\n{\nresult *= (ns * curAmp);\nsum *= (curAmp);\n}\nlastResult = ns;\ncurFreq *= Lacunarity;\ncurAmp *= Gain;\nif (i == 0)\n{\nCellCenter = cellvec3;\n}\n}\nif (Normalize == 1)\nresult /= sum / Amplitude;\nelse\nresult *= Amplitude;\nif (OutputStepFunction)\nresult = smoothstep(OutputLowStep, OutputHiStep, result);\nFloat = result;\nColor = mix(A, B, result);\nCellRandomness = oslNoise(CellCenter);\n}",node_osl_uvwenviron_mx_frag:"\nvoid node_osl_uvwenviron(vec3 Direction, int Mode, out vec3 UVW) {\nfloat U = 0.0, V = 0.0;\nif (Mode == OSL_SPHERICAL)\n{\nU = atan2(Direction[0],Direction[1]) / (M_PI * 2.0);\nV = 0.5 + (asin(Direction[2]) / M_PI);\n}\nif (Mode == OSL_MIRRORBALL)\n{\nvec3 camSpaceDir = oslTransform(OSL_COMMON, OSL_CAMERA, Direction);\nvec3 halfwayDir = normalize(vec3(0, 0, 1) + camSpaceDir);\nU = (halfwayDir[0] + 1.0) / 2.0;\nV = (halfwayDir[1] + 1.0) / 2.0;\n}\nUVW = vec3(U,V,0);\n}",node_osl_uvwrowoffset_mx_frag:"\nvoid node_osl_uvwrowoffset(vec3 Input, float Scale, vec3 Tiling, int RowCount, float Offset, float RandomOffset, out vec3 UVW) {\nUVW = Input * Tiling / Scale;\nint row = int(floor(UVW[1]));\nint modrow = row % RowCount;\nUVW[0] = UVW[0] + modrow * Offset + oslNoise(OSL_CELL, row) * RandomOffset;\n}",node_osl_uvwtransform_mx_frag:"\nvoid node_osl_uvwtransform(vec3 Input, float Scale, vec3 Tiling, vec3 Offset, int Wrap, int RealWorld, float RealWidth, float RealHeight, float Rotate, vec3 RotCenter, vec3 RotAxis, out vec3 UVW) {\nvec3 worldScale = vec3(1.0);\nif (RealWorld == 1)\nworldScale = vec3(RealWidth, RealHeight, 1.0);\nUVW = oslRotate(Input - Offset, radians(Rotate), RotCenter, RotCenter + RotAxis) * Tiling / worldScale / Scale;\nif (Wrap == 1)\nUVW -= floor(UVW);\n}",node_osl_vectoradd_mx_frag:"\nvoid node_osl_vectoradd(vec3 A, vec3 B, float A_Amount, float B_Amount, out vec3 Out) {\nOut = A*A_Amount + B*B_Amount;\n}",node_osl_vectorcross_mx_frag:"\nvoid node_osl_vectorcross(vec3 A, vec3 B, out vec3 Out) {\nOut = cross(A, B);\n}",node_osl_vectordist_mx_frag:"\nvoid node_osl_vectordist(vec3 A, vec3 B, out float Out) {\nOut = distance(A, B);\n}",node_osl_vectordiv_mx_frag:"\nvoid node_osl_vectordiv(vec3 A, vec3 B, out vec3 Out) {\nOut = A / B;\n}",node_osl_vectordot_mx_frag:"\nvoid node_osl_vectordot(vec3 A, vec3 B, out float Out) {\nOut = dot(A, B);\n}",node_osl_vectorinv_mx_frag:"\nvoid node_osl_vectorinv(vec3 Input, out vec3 Out) {\nOut = -Input;\n}",node_osl_vectorjuggler_mx_frag:"\nvoid node_osl_vectorjuggler(vec3 Input, float Xi, float Yi, float Zi, out vec3 Out, out float X, out float Y, out float Z) {\nOut = vec3(Xi,Yi,Zi);\nX = Out[0];\nY = Out[1];\nZ = Out[2];\n}",node_osl_vectorlength_mx_frag:"\nvoid node_osl_vectorlength(vec3 Input, out float Out) {\nOut = length(Input);\n}",node_osl_vectormax_mx_frag:"\nvoid node_osl_vectormax(vec3 A, vec3 B, out vec3 Out) {\nOut = max(A, B);\n}",node_osl_vectormin_mx_frag:"\nvoid node_osl_vectormin(vec3 A, vec3 B, out vec3 Out) {\nOut = min(A, B);\n}",node_osl_vectormul_mx_frag:"\nvoid node_osl_vectormul(vec3 A, vec3 B, out vec3 Out) {\nOut = A * B;\n}",node_osl_vectornorm_mx_frag:"\nvoid node_osl_vectornorm(vec3 Input, out vec3 Out) {\nOut = normalize(Input);\n}",node_osl_vectorsub_mx_frag:"\nvoid node_osl_vectorsub(vec3 A, vec3 B, float A_Amount, float B_Amount, out vec3 Out) {\nOut = A*A_Amount - B*B_Amount;\n}",node_osl_waveform_mx_frag:"\nvoid node_osl_waveform(int WaveShape, float MidPoint, float Amplitude, vec3 High, vec3 Low, int FrameNumber, float Period, float Phase, out vec3 Col, out float Wave) {\nfloat wavePos = (FrameNumber - Phase) / Period;\nfloat wavePosF = wavePos - floor(wavePos);\nfloat power = oslPow(10.0, (MidPoint - 0.5) * 2.0);\nif (WaveShape == 0 )\nWave = oslPow(sin(wavePos * M_2PI), power);\nelse if (WaveShape == 1 )\nWave = (oslPow(sin(wavePos * M_2PI) * 0.5 + 0.5, power));\nelse if (WaveShape == 2 )\nWave = wavePosF < MidPoint ? 1.0 : 0.0;\nelse if (WaveShape == 3 )\nWave = oslPow(wavePosF, power);\nelse if (WaveShape == 4 )\nWave = oslPow(1.0 - wavePosF, power);\nelse if (WaveShape == 5 )\nWave = wavePosF < MidPoint ? wavePosF / (MidPoint+0.001) : (1.0 - wavePosF) / (1.0 - MidPoint + 0.001);\nelse if (WaveShape == 6 )\nWave = (float)oslCellNoise(wavePos * 1.0) < MidPoint ? 1.0 : 0.0;\nCol = mix(Low, High, Wave);\nWave *= Amplitude;\n}",node_osl_wavelength_mx_frag:"\nvoid node_osl_wavelength(float Input, float Min, float Max, out vec3 Col) {\nCol = wavelength_vec3(mix(Min, Max, Input));\n}",node_osl_weave_mx_frag:"\nvoid node_osl_weave(vec3 UVW, float Scale, vec3 U_Color, vec3 V_Color, float Width, float Roundness, float RoundnessBump, float RoundShadow, float WeaveBump, float WeaveShadow, float Frizz, float FrizzBump, float FrizzScale, float Bendyness, float BendynessScale, float OpacityFade, int Seed, out vec3 Col, out float Bump, out int ThreadID, out float Opacity) {\nvec3 uvw = UVW / Scale;\nfloat frizz = oslNoise(OSL_PERLIN, uvw / FrizzScale) ;\nfloat w2 = Width + frizz * Frizz;\nfloat w = w2 * 0.5;\nint uf = int(floor(uvw[0]));\nint vf = int(floor(uvw[1]));\nfloat ubend = oslNoise(OSL_PERLIN, uvw[1] / BendynessScale + 13.0 * uf, Seed + 4) * Bendyness;\nfloat vbend = oslNoise(OSL_PERLIN, uvw[0] / BendynessScale + 23.0 * vf, Seed + 7) * Bendyness;\nfloat sx = uvw[0] - uf + ubend;\nfloat sy = uvw[1] - vf + vbend;\nint onU = (sy > 0.5 - w && sy < 0.5 + w);\nint onV = (sx > 0.5 - w && sx < 0.5 + w);\nfloat uu = (sy - (0.5 - w)) / w2;\nfloat vv = (sx - (0.5 - w)) / w2;\nint oddU = uf % 2;\nint oddV = vf % 2;\nif (onU == 0 && onV == 0) return;\nint U_on_top = (oddU ^ oddV) == 0;\nif (onU && onV)\n{\nonU = U_on_top;\nonV = onU == 0;\n}\nThreadID = 1 + int(((float)oslCellNoise(uf, Seed + 45) * onV + (float)oslCellNoise(vf, Seed + 32) * onU) * 1024.0) + onU;\nif (onU)\nCol = U_Color;\nelse\nCol = V_Color;\nfloat r = Roundness;\nfloat weave = (onU) ? sin((uvw[0] + oddV) * M_PI) : sin((uvw[1] + oddU + 1.0) * M_PI);\nfloat ubulge = sin(uu * M_PI);\nfloat vbulge = sin(vv * M_PI);\nfloat bulge = oslPow((onU ? ubulge : vbulge), r);\nOpacity = max(oslPow(ubulge, OpacityFade), oslPow(vbulge, OpacityFade));\nBump = 0.2 + weave * WeaveBump + bulge * RoundnessBump + frizz * FrizzBump;\nCol *= mix(1.0, bulge, RoundShadow);\nCol *= mix(1.0, weave, WeaveShadow);\n}",node_osl_wireframe_mx_frag:"\nvoid node_osl_wireframe(vec3 Tiling, float Width, vec3 Space, vec3 Wire, out vec3 Out) {\nOut = Space;\nfloat x = fmod(u * Tiling[0], 1.0);\nfloat y = fmod(v * Tiling[1], 1.0);\nif (x < filterwidth(x) * Width || y < filterwidth(y) * Width ||\n(1 - x) < filterwidth(x) * Width || (1 - y) < filterwidth(y) * Width)\nOut = Wire;\n}",node_ai_facing_ratio_my_frag:"void node_ai_facing_ratio(\nvec3 viewNorm,\nconst float bias, const float gain, const bool invert, const bool linear,\nout float outValue)\n{\noutValue = dot(normalize(viewNorm), normalize(vViewPosition));\n}",node_ai_flat_my_frag:"void node_ai_flat(vec3 color, out vec3 outColor)\n{\noutColor = color;\n}",node_ai_mix_shader_my_frag:"void node_ai_mix_shader(const int mode, \nconst float mixAmt, const vec3 shader1, const vec3 shader2,\nout vec3 color)\n{\nif (mode == 0)\ncolor = mix(shader1, shader2, clamp(mixAmt, 0.0, 1.0));\nelse\ncolor = shader1 + shader2;\n}",node_ai_normal_map_my_frag:"void node_ai_normal_map(\nvec4 tangentParam,\nvec3 inputVal, vec3 normal, float strength, vec3 tangent,\nout vec3 outValue) {\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = inputVal.xyz * 2.0 - 1.0;\nvec3 bitangent = tangentParam.w * cross(normal, tangent);\noutValue = normalize(normalTex.x * tangent + normalTex.y * bitangent + normalTex.z * normal);\noutValue = mix(normal, outValue, strength);\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_anim_curve_ta_my_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_anim_curve_ta(float val, out float outVal)\n{\noutVal = val;\n}",node_anim_curve_tu_my_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_anim_curve_tu(float val, out float outVal)\n{\noutVal = val;\n}",node_blend_colors_my_frag:"void node_blend_colors(float blender, vec3 color1, vec3 color2, out vec3 outColor)\n{\nblender = clamp(blender, 0.0, 1.0);\noutColor = mix(color1, color2, 1.0 - blender);\n}\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_blinn_my_frag:"void node_blinn(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float reflectivity, vec3 reflectedColor,\nfloat eccentricity, vec3 specularColor, float specularRollOff, float translucence,\nvec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color;\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.specularRoughness = max(eccentricity, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nmaterial.specularColor = specularColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nreflectedLight.directSpecular + reflectedLight.indirectSpecular + incandescence, alpha);\n}",node_bump_2d_my_frag:"void node_bump_2d(\nvec3 normal,\nfloat bumpDepth, float bumpValue,\nout vec3 outNormal) {\nvec3 position = vViewPosition;\nvec3 dPdx = dFdx(position);\nvec3 dPdy = dFdy(position);\nfloat dHdx = dFdx(bumpValue);\nfloat dHdy = dFdy(bumpValue);\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 * sign(dotPosTanX));\noutNormal = normalize(mix(normal, outNormal, max(0.0, bumpDepth)));\n}\nvoid node_bump_2d(\nvec3 normal, vec4 tangent,\nfloat bumpDepth, vec3 bumpValue,\nout vec3 outNormal) {\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = (bumpValue.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);\noutNormal = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\noutNormal = mix(normal, outNormal, bumpDepth);\n}",node_color_composite_my_frag:"void node_color_composite(int operation,\nvec3 colorA, float alphaA, vec3 colorB, float alphaB, float factor,\nout vec3 outColor, out float outAlpha)\n{\nif (factor <= 0.0) {\noutColor = colorA;\noutAlpha = alphaA;\nreturn;\n}\nif (operation == 0) {\noutColor[0] = colorA[0] + (colorB[0] * factor);\noutColor[1] = colorA[1] + (colorB[1] * factor);\noutColor[2] = colorA[2] + (colorB[2] * factor);\noutAlpha = alphaA + (alphaB * factor);\n} else if (operation == 1) {\noutColor[0] = colorA[0] + ((colorB[0] - 1.0) * factor);\noutColor[1] = colorA[1] + ((colorB[1] - 1.0) * factor);\noutColor[2] = colorA[2] + ((colorB[2] - 1.0) * factor);\noutAlpha = alphaA + ((alphaB - 1.0) * factor);\n} else if (operation == 2) {\nif (factor >= 1.0) {\noutColor = colorB;\noutAlpha = alphaB;\nreturn;\n}\noutColor[0] = mix(colorA[0], colorB[0], factor);\noutColor[1] = mix(colorA[1], colorB[1], factor);\noutColor[2] = mix(colorA[2], colorB[2], factor);\noutAlpha = mix(alphaA, alphaB, factor);\n} else if (operation == 3) {\noutColor[0] = colorA[0] * (colorB[0] * factor + (1.0 - factor));\noutColor[1] = colorA[1] * (colorB[1] * factor + (1.0 - factor));\noutColor[2] = colorA[2] * (colorB[2] * factor + (1.0 - factor));\noutAlpha = alphaA * (alphaB * factor + (1.0 - factor));\n} else if (operation == 4) {\noutColor[0] = 1.0 - ((1.0 - colorA[0]) * (1.0 - colorB[0] * factor));\noutColor[1] = 1.0 - ((1.0 - colorA[1]) * (1.0 - colorB[1] * factor));\noutColor[2] = 1.0 - ((1.0 - colorA[2]) * (1.0 - colorB[2] * factor));\noutAlpha = 1.0 - ((1.0 - alphaA) * (1.0 - alphaB * factor));\n} else if (operation == 5) {\noutColor[0] = colorB[0] > 0.5 ? (2.0 * colorA[0] * colorB[0] * factor) + colorA[0] * (1.0 - factor) :\n1.0 - ((1.0 - colorA[0]) * (1.0 - colorB[0] * factor)) * (2.0 - (1.0 - factor));\noutColor[1] = colorB[1] > 0.5 ? (2.0 * colorA[1] * colorB[1] * factor) + colorA[1] * (1.0 - factor) :\n1.0 - ((1.0 - colorA[1]) * (1.0 - colorB[1] * factor)) * (2.0 - (1.0 - factor));\noutColor[2] = colorB[2] > 0.5 ? (2.0 * colorA[2] * colorB[2] * factor) + colorA[2] * (1.0 - factor) :\n1.0 - ((1.0 - colorA[2]) * (1.0 - colorB[2] * factor)) * (2.0 - (1.0 - factor));\noutAlpha = alphaB > 0.5 ? (2.0 * alphaA * alphaB * factor) + alphaA * (1.0 - factor) :\n1.0 - ((1.0 - alphaA) * (1.0 - alphaB * factor)) * (2.0 - (1.0 - factor));\n} else if (operation == 6) {\noutColor[0] = abs(colorA[0] - (colorB[0] * factor));\noutColor[1] = abs(colorA[1] - (colorB[1] * factor));\noutColor[2] = abs(colorA[2] - (colorB[2] * factor));\noutAlpha = abs(alphaA - (alphaB * factor));\n} else if (operation == 7) {\noutColor[0] = clamp(mix(colorA[0], colorA[0] / max(1.0 - colorB[0], 0.00001), factor), colorA[0], colorB[0]);\noutColor[1] = clamp(mix(colorA[1], colorA[1] / max(1.0 - colorB[1], 0.00001), factor), colorA[1], colorB[1]);\noutColor[2] = clamp(mix(colorA[2], colorA[2] / max(1.0 - colorB[2], 0.00001), factor), colorA[2], colorB[2]);\noutAlpha = clamp(mix(alphaA, alphaA / max(1.0 - alphaB, 0.00001), factor), alphaA, alphaB);\n} else if (operation == 8) {\noutColor[0] = clamp(mix(colorA[0], 1.0 - (colorA[0] / max(1.0 - colorB[0], 0.00001)), factor), colorA[0], colorB[0]);\noutColor[1] = clamp(mix(colorA[1], 1.0 - (colorA[1] / max(1.0 - colorB[1], 0.00001)), factor), colorA[1], colorB[1]);\noutColor[2] = clamp(mix(colorA[2], 1.0 - (colorA[2] / max(1.0 - colorB[2], 0.00001)), factor), colorA[2], colorB[2]);\noutAlpha = clamp(mix(alphaA, 1.0 - (alphaA / max(1.0 - alphaB, 0.00001)), factor), alphaA, alphaB);\n}\n}",node_color_constant_my_frag:"void node_color_constant(vec3 inColor, float inAlpha, out vec3 outColor, out float outAlpha)\n{\noutColor = inColor;\noutAlpha = inAlpha;\n}",node_file_my_frag:"void node_file(sampler2D ima, const int encoding,\nvec2 uvCoord,\nout float outAlpha, out vec3 outColor, out vec2 outSize, out vec3 outTransparency) {\nvec2 uv = vec2(uvCoord.x, 1.0 - uvCoord.y);\nvec4 tex = texture2D(ima, uv);\noutColor = nodeTexelToLinear(tex, encoding).rgb;\noutAlpha = tex.a;\noutSize = vec2(0.0);\noutTransparency = vec3(1.0 - outAlpha, 1.0 - outAlpha, 1.0 - outAlpha);\n}",node_float_composite_my_frag:"void node_float_composite(int operation,\nfloat floatA, float floatB, float factor,\nout float outFloat)\n{\nif (factor <= 0.0) {\noutFloat = floatA;\nreturn;\n}\nif (operation == 0) {\noutFloat = floatA + (floatB * factor);\n} else if (operation == 1) {\noutFloat = floatA + ((floatB - 1.0) * factor);\n} else if (operation == 2) {\nif (factor >= 1.0) {\noutFloat = floatB;\nreturn;\n}\noutFloat = mix(floatA, floatB, factor);\n} else if (operation == 3) {\noutFloat = floatA * (floatB * factor + (1.0 - factor));\n} else if (operation == 4) {\noutFloat = 1.0 - ((1.0 - floatA) * (1.0 - floatB * factor));\n} else if (operation == 5) {\noutFloat = floatB > 0.5 ? (2.0 * floatA * floatB * factor) + floatA * (1.0 - factor) :\n1.0 - ((1.0 - floatA) * (1.0 - floatB * factor)) * (2.0 - (1.0 - factor));\n} else if (operation == 6) {\noutFloat = abs(floatA - (floatB * factor));\n} else if (operation == 7) {\noutFloat = clamp(mix(floatA, floatA / max(1.0 - floatB, 0.00001), factor), floatA, floatB);\n} else if (operation == 8) {\noutFloat = clamp(mix(floatA, 1.0 - (floatA / max(1.0 - floatB, 0.00001)), factor), floatA, floatB);\n}\n}",node_float_constant_my_frag:"void node_float_constant(float inFloat, out float outFloat)\n{\noutFloat = inFloat;\n}",node_lambert_my_frag:"\nvoid node_lambert(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float translucence, vec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * 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#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_IndirectDiffuse\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + incandescence, alpha);\n}",node_layered_texture_layer_my_frag:"#define LAYER_BLEND_MODE_NONE 0.0\n#define LAYER_BLEND_MODE_OVER 1.0\n#define LAYER_BLEND_MODE_IN 2.0\n#define LAYER_BLEND_MODE_OUT 3.0\n#define LAYER_BLEND_MODE_ADD 4.0\n#define LAYER_BLEND_MODE_SUBTRACT 5.0\n#define LAYER_BLEND_MODE_MULTIPLY 6.0\n#define LAYER_BLEND_MODE_DIFFERENCE 7.0\n#define LAYER_BLEND_MODE_LIGHTEN 8.0\n#define LAYER_BLEND_MODE_DARKEN 9.0\n#define LAYER_BLEND_MODE_SATURATE 10.0\n#define LAYER_BLEND_MODE_DESATURATE 11.0\n#define LAYER_BLEND_MODE_ILLUMINATE 12.0\nvoid node_layered_texture_layer(\nconst float alphaBG, const vec3 colorBG, \nconst vec3 color, const float alpha, const float blendMode, const bool isVisible,\nout float outAlpha, out vec3 outColor)\n{\noutAlpha = alphaBG;\noutColor = colorBG;\nif (!isVisible)\nreturn;\nif (blendMode == LAYER_BLEND_MODE_NONE) {\noutColor = color;\n} else if (blendMode == LAYER_BLEND_MODE_OVER) {\noutColor = mix(colorBG, color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_IN) {\noutColor = alpha * colorBG;\n} else if (blendMode == LAYER_BLEND_MODE_OUT) {\noutColor = (1.0 - alpha) * colorBG;\n} else if (blendMode == LAYER_BLEND_MODE_ADD) {\noutColor = mix(colorBG, colorBG + color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_SUBTRACT) {\noutColor = mix(colorBG, colorBG - color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_MULTIPLY) {\noutColor = mix(colorBG, colorBG * color, alpha);\n} else {\noutColor = mix(colorBG, color, alpha);\n}\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}",node_place_2d_texture_my_frag:"void node_place_2d_texture(const vec2 inUv,\nvec2 offset, vec2 repeatUv, float rotateUv,\nout vec2 outUv)\n{\noutUv = (calcUvTransform(offset.x, offset.y, repeatUv.x, repeatUv.y, rotateUv) * vec3(inUv, 1.0)).xy;\noutUv.y = 1.0 - outUv.y;\n}",node_phong_my_frag:"void node_phong(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float reflectivity, vec3 reflectedColor,\nfloat cosinePower, vec3 specularColor, float translucence, vec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color;\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nfloat roughness = sqrt(1.0 / (0.454 * cosinePower + 3.357));\nmaterial.specularRoughness = max(roughness, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nmaterial.specularColor = specularColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nreflectedLight.directSpecular + reflectedLight.indirectSpecular + incandescence, alpha);\n}",node_phong_e_my_frag:"void node_phong_e(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float reflectivity, vec3 reflectedColor,\nfloat highlightSize, float roughness, vec3 specularColor, float translucence, vec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color;\n#ifdef CLEARCOAT\n#undef CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.specularRoughness = max(roughness, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nmaterial.specularColor = specularColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nreflectedLight.directSpecular + reflectedLight.indirectSpecular + incandescence, alpha);\n}",node_ramp_my_frag:"void node_ramp(\nsampler2D rampData, int rampType,\nvec2 uvCoord,\nout float outAlpha, out vec3 outColor)\n{\nfloat coord;\nif (rampType == 0)\ncoord = uvCoord.y;\nelse if (rampType == 1)\ncoord = uvCoord.x;\nelse if (rampType == 2)\ncoord = abs(uvCoord.x + uvCoord.y) / 2.0;\nelse\ncoord = uvCoord.x;\nvec4 tex = texture2D(rampData, vec2(coord, 0.0));\noutAlpha = tex.w;\noutColor = tex.xyz;\n}",node_remap_hsv_my_frag:"void node_remap_hsv(vec3 color, out vec3 outColor)\n{\noutColor = color;\n}",node_sampler_info_my_frag:"void node_sampler_info(\nbool frontFacing, vec3 viewNorm, vec4 tangent, vec2 uv,\nout float facingRatio, out bool flippedNormal, out mat4 matrixEyeToWorld,\nout vec3 normalCamera, out vec2 pixelCenter, out vec3 pointCamera,\nout vec3 pointObj, out vec3 pointWorld,\nout vec3 tangentUCamera, out vec3 tangentVCamera, out vec2 uvCoord)\n{\nvec4 worldPos = invViewMatrix * vec4(-vViewPosition, 1.0);\nfacingRatio = dot(normalize(viewNorm), normalize(vViewPosition));\nflippedNormal = frontFacing;\nmatrixEyeToWorld = invViewMatrix;\nnormalCamera = viewNorm;\npixelCenter = vec2(1.0);\npointCamera = -vViewPosition;\npointObj = (invModelMatrix * worldPos).xyz;\npointWorld = worldPos.xyz;\ntangentUCamera = normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz);\ntangentVCamera = tangent.w * cross(viewNorm, tangentUCamera);\nuvCoord = vec2(uv.x, 1.0-uv.y);\n}",node_shading_engine_my_frag:"void node_shading_engine(vec4 surface, vec4 volume, vec3 displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}",node_standard_surface_my_frag:"#define DEFAULT_REFLECTION_EDGE 1.0\n#define DEFAULT_REFLECTION_SLOPE 5.0\nvoid node_standard_surface(\nvec3 geometryNormal, const bool thinWalled,\nconst float base, const vec3 baseColor, const float diffuseRoughness,\nconst float metalness, const float specular, const vec3 specularColor,\nconst float specularRoughness, const float trans, const vec3 transColor,\nconst float transDepth, const vec3 transScatter, const float transExtraRoughness,\nconst float subsurface, const vec3 subsurfaceColor, const vec3 subsurfaceRadius,\nconst float coat, const vec3 coatColor, const float coatRoughness,\nconst float sheen, const vec3 sheenColor, const float sheenRoughness,\nconst float emission, const vec3 emissionColor, const vec3 opacity,\nconst vec3 normal,\nout vec4 outColor, out vec3 outTransparency)\n{\nNodeMaterial material;\nvec3 baseColorWeighted = base * baseColor.rgb;\nmaterial.diffuseColor = baseColorWeighted * (1.0 - metalness);\n#ifdef CLEARCOAT\nmaterial.clearcoat = saturate(coat);\nmaterial.clearcoatRoughness = clamp(coatRoughness, 0.0, 1.0);\n#endif\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.specularRoughness = max(specularRoughness, 0.0525);\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min(material.specularRoughness, 1.0);\nvec3 dielRefl = DEFAULT_SPECULAR_COEFFICIENT * specular * specularColor;\nmaterial.specularColor = mix(dielRefl, baseColorWeighted, metalness);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\nvec3 totalEmissiveRadiance = emission * emissionColor;\nvec3 outSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\nvec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\noutSpecular + totalEmissiveRadiance;\nfloat alpha = average(opacity);\noutColor = vec4(outColor3, saturate(alpha));\noutTransparency = outColor3;\n}",node_surface_shader_my_frag:"void node_surface_shader(\nvec3 color, vec3 glowColor, vec3 matteOpacity, vec3 transparency,\nout vec3 outColor, out vec3 outGlowColor, out vec3 outMatteOpacity, out vec3 outTransparency)\n{\noutColor = color;\noutGlowColor = glowColor;\noutMatteOpacity = matteOpacity;\noutTransparency = transparency;\n}",node_unit_conversion_my_frag:"void node_unit_conversion(float conversionFactor, float inInput, out float outOutput)\n{\noutOutput = conversionFactor * inInput;\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}"},lo={basic:{uniforms:Gr([eo.common,eo.specularmap,eo.envmap,eo.aomap,eo.lightmap,eo.fog]),vertexShader:so.meshbasic_vert,fragmentShader:so.meshbasic_frag},lambert:{uniforms:Gr([eo.common,eo.specularmap,eo.envmap,eo.aomap,eo.lightmap,eo.emissivemap,eo.fog,eo.lights,{emissive:{value:new Ri(0)}}]),vertexShader:so.meshlambert_vert,fragmentShader:so.meshlambert_frag},phong:{uniforms:Gr([eo.common,eo.specularmap,eo.envmap,eo.aomap,eo.lightmap,eo.emissivemap,eo.bumpmap,eo.normalmap,eo.displacementmap,eo.fog,eo.lights,{emissive:{value:new Ri(0)},specular:{value:new Ri(1118481)},shininess:{value:30}}]),vertexShader:so.meshphong_vert,fragmentShader:so.meshphong_frag},standard:{uniforms:Gr([eo.common,eo.envmap,eo.aomap,eo.lightmap,eo.emissivemap,eo.bumpmap,eo.normalmap,eo.displacementmap,eo.roughnessmap,eo.metalnessmap,eo.fog,eo.lights,{emissive:{value:new Ri(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:so.meshphysical_vert,fragmentShader:so.meshphysical_frag},toon:{uniforms:Gr([eo.common,eo.specularmap,eo.aomap,eo.lightmap,eo.emissivemap,eo.bumpmap,eo.normalmap,eo.displacementmap,eo.gradientmap,eo.fog,eo.lights,{emissive:{value:new Ri(0)},specular:{value:new Ri(1118481)},shininess:{value:30}}]),vertexShader:so.meshtoon_vert,fragmentShader:so.meshtoon_frag},matcap:{uniforms:Gr([eo.common,eo.bumpmap,eo.normalmap,eo.displacementmap,eo.fog,{matcap:{value:null}}]),vertexShader:so.meshmatcap_vert,fragmentShader:so.meshmatcap_frag},points:{uniforms:Gr([eo.points,eo.fog]),vertexShader:so.points_vert,fragmentShader:so.points_frag},dashed:{uniforms:Gr([eo.common,eo.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:so.linedashed_vert,fragmentShader:so.linedashed_frag},depth:{uniforms:Gr([eo.common,eo.displacementmap,{slopeScaledBias:{value:0}}]),vertexShader:so.depth_vert,fragmentShader:so.depth_frag},normal:{uniforms:Gr([eo.common,eo.bumpmap,eo.normalmap,eo.displacementmap,{opacity:{value:1}}]),vertexShader:so.normal_vert,fragmentShader:so.normal_frag},sprite:{uniforms:Gr([eo.sprite,eo.fog]),vertexShader:so.sprite_vert,fragmentShader:so.sprite_frag},background:{uniforms:{uvTransform:{value:new en},t2D:{value:null}},vertexShader:so.background_vert,fragmentShader:so.background_frag},cube:{uniforms:Gr([eo.envmap,{opacity:{value:1}}]),vertexShader:so.cube_vert,fragmentShader:so.cube_frag},equirect:{uniforms:{tEquirect:{value:null},invertU:{value:!1},offsetU:{value:0}},vertexShader:so.equirect_vert,fragmentShader:so.equirect_frag},distanceRGBA:{uniforms:Gr([eo.common,eo.displacementmap,{referencePosition:{value:new dn},nearDistance:{value:1},farDistance:{value:1e3},slopeScaledBias:{value:0}}]),vertexShader:so.distanceRGBA_vert,fragmentShader:so.distanceRGBA_frag},shadow:{uniforms:Gr([eo.lights,eo.fog,{color:{value:new Ri(0)},opacity:{value:1}}]),vertexShader:so.shadow_vert,fragmentShader:so.shadow_frag},mask:{uniforms:Gr([eo.common,eo.displacementmap,eo.mask]),vertexShader:so.mask_vert,fragmentShader:so.mask_frag},equicube:{uniforms:{tEquirect:{value:null},faceIndex:{value:0},invertU:{value:!1},offsetU:{value:0}},vertexShader:so.equicube_vert,fragmentShader:so.equicube_frag},node:{uniforms:Gr([eo.common,eo.displacementmap,eo.envmap,eo.fog,eo.lights,eo.ssr,eo.node,{envMapIntensity:{value:1}}]),vertexShader:so.meshnode_vert,fragmentShader:so.meshnode_frag},cubeOctahedral:{uniforms:{tCube:{value:null},texelSize:{value:new $t(.5,.5)}},vertexShader:so.pp_plane_vert,fragmentShader:so.pp_cube_octahedral_proj_frag}};function co(h,n,f,i){var p,m,v,g,_=new Ri(0),x=0,y=null,b=0,M=null;function w(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,i)}return{getClearColor:function(){return _},setClearColor:function(e,t){_.set(e),w(_,x=void 0!==t?t:1)},getClearAlpha:function(){return x},setClearAlpha:function(e){w(_,x=e)},dispose:function(){m&&(m.geometry.dispose(),m.material.dispose()),m=p=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,i){var r=t.background&&t.background.isSceneBackground,o=r?t.background.data:t.background,a=h.xr,s=a.getSession&&a.getSession();s&&"additive"===s.environmentBlendMode&&(o=null),null===o?w(_,x):o&&o.isColor&&(w(o,1),i=!0),(h.autoClear||i)&&h.clear(h.autoClearColor,h.autoClearDepth,h.autoClearStencil);var l,c,u,d=!!r&&t.background.useHDR;o&&(o.isCubeTexture||o.isWebGLCubeRenderTarget||o.mapping===We)?(void 0===v&&((v=new Pr(new Ur(1,1,1),new Hr({type:"BackgroundCubeMaterial",uniforms:kr.clone(lo.cube.uniforms),vertexShader:lo.cube.vertexShader,fragmentShader:lo.cube.fragmentShader,side:Re,depthTest:!1,depthWrite:!1,fog:!1,polygonOffset:!0,useHDR:d}))).geometry.deleteAttribute("normal"),v.geometry.deleteAttribute("uv"),v.onBeforeRender=function(e,t,n){var i=n.far;this.matrixWorld.makeScale(i,i,i),this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(v.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),f.update(v)),l=o.isWebGLCubeRenderTarget?o.texture:o,v.material.uniforms.envMap.value=l,v.material.uniforms.flipEnvMap.value=l.isCubeTexture?-1:1,y===o&&b===l.version&&M===h.toneMapping||(v.material.needsUpdate=!0,y=o,b=l.version,M=h.toneMapping),e.unshift(v,v.geometry,v.material,0,0,null)):o&&o.isTexture&&(o.mapping===Ge?(c=!!r&&t.background.equirecInvertU,u=r?t.background.equirecOffsetU:0,void 0===g&&((g=new Pr(new Ur(1,1,1),new Hr({vertexShader:lo.equirect.vertexShader,fragmentShader:lo.equirect.fragmentShader,uniforms:lo.equirect.uniforms,side:Re,depthTest:!1,depthWrite:!1,polygonOffset:!0,useHDR:d}))).geometry.deleteAttribute("normal"),g.geometry.deleteAttribute("uv"),g.onBeforeRender=function(e,t,n){var i=n.far;this.matrixWorld.makeScale(i,i,i),this.matrixWorld.copyPosition(n.matrixWorld)}),f.update(g),g.material.uniforms.invertU.value=c,g.material.uniforms.offsetU.value=u,g.material.uniforms.tEquirect.value=o,e.unshift(g,g.geometry,g.material,0,0,null)):(void 0===p&&(p=new ro(-1,1,1,-1,0,1),m=new Pr(new ao(2,2),new Ui({depthTest:!1,depthWrite:!1,fog:!1}))),f.update(m),m.material.map=o,h.renderBufferDirect(p,null,m.geometry,m.material,m,null)))}}}function uo(a,s,l,e){var c,u=e.isWebGL2;this.setMode=function(e){c=e},this.render=function(e,t){a.drawArrays(c,e,t),l.update(t,c)},this.renderInstances=function(e,t,n,i){if(0!==i){var r,o;if(u)r=a,o="drawArraysInstanced";else if(o="drawArraysInstancedANGLE",null===(r=s.get("ANGLE_instanced_arrays")))return void console.error("v3d.WebGLBufferRenderer: using v3d.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");r[o](c,t,n,i),l.update(n,c,i)}}}function ho(t,n,e){var i;function r(e){if("highp"===e){if(0",t[n]);return e}var La=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ca(e){return e.replace(La,Pa)}function Pa(e,t){var n=so[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Ca(n)}function Ra(e){for(var t,n=new RegExp("#pragma unroll_loop[\\s]+?for \\(int (\\w+) \\= (\\d+)\\; (\\w+) <(=?) (\\w+)\\; (\\w+)\\+\\+\\) \\{"),i=new RegExp("\\{|\\}","g");t=n.exec(e);){for(var r,o,a=r=i.lastIndex=t.index+t[0].length,s=1;(o=i.exec(e))&&("{"==o[0]?s++:"}"==o[0]&&s--,r=o.index),o&&0 0\n attribute vec3 morphTarget0;\n #endif\n #if NUM_MORPH_TARGETS > 1\n attribute vec3 morphTarget1;\n #endif\n #if NUM_MORPH_TARGETS > 2\n attribute vec3 morphTarget2;\n #endif\n #if NUM_MORPH_TARGETS > 3\n attribute vec3 morphTarget3;\n #endif\n #if NUM_MORPH_TARGETS > 4\n attribute vec3 morphTarget4;\n #endif\n #if NUM_MORPH_TARGETS > 5\n attribute vec3 morphTarget5;\n #endif\n\n #ifdef USE_MORPHNORMALS\n #if NUM_MORPH_TARGETS > 0\n attribute vec3 morphNormal0;\n #endif\n #if NUM_MORPH_TARGETS > 1\n attribute vec3 morphNormal1;\n #endif\n #if NUM_MORPH_TARGETS > 2\n attribute vec3 morphNormal2;\n #endif\n #if NUM_MORPH_TARGETS > 3\n attribute vec3 morphNormal3;\n #endif\n #if NUM_MORPH_TARGETS > 4\n attribute vec3 morphNormal4;\n #endif\n #if NUM_MORPH_TARGETS > 5\n attribute vec3 morphNormal5;\n #endif\n #else\n #if NUM_MORPH_TARGETS > 6\n attribute vec3 morphTarget6;\n #endif\n #if NUM_MORPH_TARGETS > 7\n attribute vec3 morphTarget7;\n #endif\n #if NUM_MORPH_TARGETS > 8\n attribute vec3 morphTarget8;\n #endif\n #if NUM_MORPH_TARGETS > 9\n attribute vec3 morphTarget9;\n #endif\n #if NUM_MORPH_TARGETS > 10\n attribute vec3 morphTarget10;\n #endif\n #if NUM_MORPH_TARGETS > 11\n attribute vec3 morphTarget11;\n #endif\n #endif\n #endif\n\n #ifdef USE_SKINNING\n attribute vec4 skinIndex;\n attribute vec4 skinWeight;\n #endif\n "].filter(wa).join("\n"),c=[w,Oa(t),"#define SHADER_NAME "+t.shaderName,S,function(e){switch(e){case"blender":return"#define MT_BLENDER";case"max":return"#define MT_MAX";case"maya":return"#define MT_MAYA";default:return""}}(t.materialProfile),s.compatSettings.saturateSpecEnvBlenderApprox?"#define COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX":"",s.compatSettings.useSpecEnvBlenderApprox?"#define COMPAT_USE_SPEC_ENV_BLENDER_APPROX":"",t.alphaTest?"#define ALPHATEST "+t.alphaTest+(t.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+b,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+_:"",t.envMap?"#define "+x:"",t.envMap?"#define "+y:"",0!==t.envMapCubeUVTileSize?"#define cubeUV_maxTileSize ".concat(nr(t.envMapCubeUVTileSize)):"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.sheen?"#define USE_SHEEN":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+g:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"",t.physicallyCorrectLights?"#define UNITS_SCALE_FACTOR "+M:"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping===U||t.useHDR?"":"#define TONE_MAPPING",t.toneMapping===U||t.useHDR?"":so.tonemapping_pars_fragment,t.toneMapping===U||t.useHDR?"":function(e,t){var n;switch(t){case Ve:n="Linear";break;case z:n="Reinhard";break;case G:n="Uncharted2";break;case k:n="OptimizedCineon";break;case j:n="ACESFilmic";break;case Ue:n="LogarithmicMax";break;case ze:n="PhysicalMax";break;case W:n="FilmicBlender";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"(vec3 color) { return "+n+"ToneMapping(color); }"}("toneMapping",t.toneMapping),t.dithering?"#define DITHERING":"",t.outputEncoding||t.mapEncoding||t.matcapEncoding||t.envMapEncoding||t.emissiveMapEncoding||t.lightMapEncoding?so.encodings_pars_fragment:"",t.mapEncoding?Ma("mapTexelToLinear",t.mapEncoding):"",t.matcapEncoding?Ma("matcapTexelToLinear",t.matcapEncoding):"",t.envMapEncoding?Ma("envMapTexelToLinear",t.envMapEncoding):"",t.emissiveMapEncoding?Ma("emissiveMapTexelToLinear",t.emissiveMapEncoding):"",t.lightMapEncoding?Ma("lightMapTexelToLinear",t.lightMapEncoding):"",t.outputEncoding?(o="linearToOutputTexel",a=t.outputEncoding,u=ya(a),"vec4 "+o+"(vec4 value) { return LinearTo"+u[0]+u[1]+"; }"):"",t.depthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",t.distancePacking?"#define DISTANCE_PACKING "+t.distancePacking:"",t.useSlopeScaledBias?"#define USE_SLOPE_SCALED_BIAS":"","#define ESM_DISTANCE_SCALE ".concat(nr(t.esmDistanceScale)),"\n"].filter(wa).join("\n")),t.isMeshNodeMaterial&&(m=Ea(m,t.nodeChunks),v=Ea(v,t.nodeChunks)),m=Aa(m=Sa(m=Ca(m),t),t),t.customPrepTokens&&(m=Ta(m,t.customPrepTokens)),v=Aa(v=Sa(v=Ca(v),t),t),t.customPrepTokens&&(v=Ta(v,t.customPrepTokens)),m=Ra(m),v=Ra(v),t.isWebGL2&&!t.isRawShaderMaterial&&(d=!1,h=/^\s*#version\s+300\s+es\s*\n/,t.isShaderMaterial&&null!==m.match(h)&&null!==v.match(h)&&(d=!0,m=m.replace(h,""),v=v.replace(h,"")),l=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+l,c=["#version 300 es\n","#define varying in",d?"":"out highp vec4 pc_fragColor;",d?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+c,0Ga.OMNI_MAP_ANGLE?2:1:0,x.castShadow&&(g=x.shadow,_.shadowBias=g.bias,_.expBias=g.expBias,_.shadowRadius=g.radius,_.shadowMapSize=g.mapSize,E.spotShadowMap[c]=w,E.spotShadowMatrix[c]=x.shadow.matrix,p++,_.shadowCameraNear=g.camera.near,_.shadowCameraFar=g.camera.far),E.spot[c]=_,c++):x.isRectAreaLight?((_=T.get(x)).color.copy(y).multiplyScalar(b),_.position.setFromMatrixPosition(x.matrixWorld),_.position.applyMatrix4(m),P.identity(),C.copy(x.matrixWorld),C.premultiply(m),P.extractRotation(C),_.halfWidth.set(.5*x.width,0,0),_.halfHeight.set(0,.5*x.height,0),_.halfWidth.applyMatrix4(P),_.halfHeight.applyMatrix4(P),E.rectArea[u]=_,u++):x.isPointLight?((_=T.get(x)).position.setFromMatrixPosition(x.matrixWorld),_.position.applyMatrix4(m),_.color.copy(x.color).multiplyScalar(x.intensity),_.distance=x.distance,_.decay=x.decay,x.castShadow&&(g=x.shadow,_.shadowBias=g.bias,_.expBias=g.expBias,_.shadowRadius=g.radius,_.shadowMapSize=g.mapSize,_.shadowCameraNear=g.camera.near,_.shadowCameraFar=g.camera.far,E.pointShadowMap[l]=w,E.pointShadowMatrix[l]=x.shadow.matrix,f++),E.point[l]=_,l++):x.isHemisphereLight&&((_=T.get(x)).direction.setFromMatrixPosition(x.matrixWorld),_.direction.transformDirection(m),_.direction.normalize(),_.skyColor.copy(x.color).multiplyScalar(b),_.groundColor.copy(x.groundColor).multiplyScalar(b),E.hemi[d]=_,d++)}}E.ambient[0]=i,E.ambient[1]=r,E.ambient[2]=o;var A=E.hash;A.directionalLength===s&&A.pointLength===l&&A.spotLength===c&&A.rectAreaLength===u&&A.hemiLength===d&&A.numDirectionalShadows===h&&A.numPointShadows===f&&A.numSpotShadows===p||(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=f,E.spotShadowMap.length=p,E.directionalShadowMatrix.length=h,E.pointShadowMatrix.length=f,E.spotShadowMatrix.length=p,A.directionalLength=s,A.pointLength=l,A.spotLength=c,A.rectAreaLength=u,A.hemiLength=d,A.numDirectionalShadows=h,A.numPointShadows=f,A.numSpotShadows=p,E.version=ja++)},state:E}}function Xa(){var t=new Ha,n=[],i=[];return{init:function(){n.length=0,i.length=0},state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:function(e){t.setup(n,i,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)}}}function Ya(){var i=new WeakMap;function r(e){var t=e.target;t.removeEventListener("dispose",r),i.delete(t)}return{get:function(e,t){var n;return!1===i.has(e)?(n=new Xa,i.set(e,new WeakMap),i.get(e).set(t,n),e.addEventListener("dispose",r)):!1===i.get(e).has(t)?(n=new Xa,i.get(e).set(t,n)):n=i.get(e).get(t),n},dispose:function(){i=new WeakMap}}}function qa(e){Vi.call(this),this.type="MeshDepthMaterial",this.depthPacking=Dt,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}function Za(e){Vi.call(this),this.type="MeshDistanceMaterial",this.defines={DISTANCE_SCALE:"1.0"},this.distancePacking=Ft,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.referencePosition=new dn,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)}((qa.prototype=Object.create(Vi.prototype)).constructor=qa).prototype.isMeshDepthMaterial=!0,qa.prototype.copy=function(e){return Vi.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},((Za.prototype=Object.create(Vi.prototype)).constructor=Za).prototype.isMeshDistanceMaterial=!0,Za.prototype.copy=function(e){return Vi.prototype.copy.call(this,e),this.defines=Object.assign({},e.defines),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 Qa=.8,Ka=.2,Ja=.8,$a=50;function es(_,v,d){var g=new $r,h=new xn,f=new xn,p=new $t,m=new $t(d.maxTextureSize,d.maxTextureSize),x=new dn,y=new dn,b=1,M=2,e=1+(b|M),w=new Array(e),S=new Array(e),A={},T=new dn,E={0:Re,1:ie,2:re},L=[new dn(1,0,0),new dn(-1,0,0),new dn(0,1,0),new dn(0,-1,0),new dn(0,0,1),new dn(0,0,-1)],C=[new dn(0,1,0),new dn(0,1,0),new dn(0,0,1),new dn(0,0,-1),new dn(0,1,0),new dn(0,1,0)],u=[new on,new on,new on,new on,new on,new on],P=new ri,R=[new dn,new dn,new dn,new dn,new dn,new dn,new dn,new dn],c=new Pr(new ao(1,1,1,1));c.name="esmFarPlane",c.castShadow=!0,c.material.shadowSide=ie;var O=0,I=1,D=0,N=1,F=new ro(-1,1,1,-1,0,10),B=new Pr(new ao(2,2)),V=new Hr({type:"ShadowCubeOctahedral",defines:Object.assign({},lo.cubeOctahedral.defines),uniforms:kr.clone(lo.cubeOctahedral.uniforms),vertexShader:lo.cubeOctahedral.vertexShader,fragmentShader:lo.cubeOctahedral.fragmentShader}),U={};var z={};function G(e,t,n,i,r,o,a){var s,l,c=B.material=a===D?((l=i)in U||((U[l]=new Hr({type:"ShadowBlur",defines:Object.assign({},lo.blur.defines,{LOG_SPACE:1,OCTAHEDRAL_MAP:1}),uniforms:kr.clone(lo.blur.uniforms),customPrepTokens:Object.assign({},lo.blur.customPrepTokens),vertexShader:lo.blur.vertexShader,fragmentShader:lo.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=l),U[l]):((s=i)in z||((z[s]=new Hr({type:"ShadowBlur",defines:Object.assign({},lo.blur.defines,{LOG_SPACE:1}),uniforms:kr.clone(lo.blur.uniforms),customPrepTokens:Object.assign({},lo.blur.customPrepTokens),vertexShader:lo.blur.vertexShader,fragmentShader:lo.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=s),z[s]);c.uniforms.direction.value.set(+(o===O),+(o===I)),c.uniforms.colorTexture.value=t.texture,c.uniforms.texSize.value.set(t.width,t.height),c.uniforms.kernelRadius.value=r,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&b),i=0!=(t&M),r=new qa({depthPacking:Nt,morphTargets:n,skinning:i});w[t]=r;var o=new Za({distancePacking:Ft,morphTargets:n,skinning:i});S[t]=o}var k=this;function j(e,t,n,i,r,o,a){var s,l,c,u,d,h,f,p=e.geometry,m=null,v=w,g=e.customDepthMaterial;switch(!i&&k.type!==ee||(v=S,g=e.customDistanceMaterial),m=g||(s=!1,t.morphTargets&&(p&&p.isBufferGeometry?s=p.morphAttributes&&p.morphAttributes.position&&0>2&1,o>>1&1,s).multiplyScalar(2).subScalar(1).applyMatrix4(e.projectionMatrixInverse),1==s&&a.multiplyScalar(r)}i.setFromPoints(R),f.multiplyMatrices(t.camera.matrixWorldInverse,e.matrixWorld);var l=i.center.applyMatrix4(f),c=i.radius*=f.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,i}function X(e,t,n){var i,r,o,a,s,l;t.isPerspectiveCamera?(i=r=0,a=s=2*-(o=-.999*t.far)*Math.tan(Jt.degToRad(t.fov)/2),l=1):t.isOrthographicCamera&&(i=(t.right+t.left)/2,r=(t.top+t.bottom)/2,o=-.999*t.far,a=t.right-t.left,s=t.top-t.bottom,l=1),t.add(c),c.scale.set(a,s,l),c.position.set(i,r,o),c.updateMatrixWorld(),W(c,e,t,!0,n)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=q,this.esmDistanceScale=1,this.render=function(e,t,n){if(k.type==$&&(k.type=q,console.warn("v3d.WebGLShadowMap: disable unsupported VSM shadow maps")),!1!==k.enabled&&(!1!==k.autoUpdate||!1!==k.needsUpdate)&&0!==e.length){var i=_.getRenderTarget(),r=_.getActiveCubeFace(),o=_.getActiveMipmapLevel(),a=_.state;a.setBlending(oe),a.buffers.color.setClear(1,1,1,1),a.buffers.depth.setTest(!0),a.setScissorTest(!1);for(var s=0,l=e.length;sGa.OMNI_MAP_ANGLE)switch(k.type){case Y:case ne:case q:case Z:case te:!function(e,t,n){var i=n.shadow,r=i.camera,o=i.matrix,a=p.copy(i.mapSize);{var s;a.x*=4,a.y*=2,a.min(m),a.x/=4,a.y/=2,u[0].set(2*a.x,a.y,a.x,a.y),u[1].set(0,a.y,a.x,a.y),u[2].set(3*a.x,0,a.x,a.y),u[3].set(a.x,0,a.x,a.y),u[4].set(3*a.x,a.y,a.x,a.y),u[5].set(a.x,a.y,a.x,a.y),!n.isSpotLight||i.map&&i.map.width/i.map.height!=2&&(s=i.map,i.map=i._additionalMap2D,i._additionalMap2D=s)}null===i.map&&(i.map=new an(4*a.x,2*a.y,{minFilter:Ze,magFilter:Ze,format:lt,type:tt}),i.map.texture.name=n.name+".shadowMap");y.setFromMatrixPosition(n.matrixWorld),r.position.copy(y),n.isSpotLight&&(r.fov=90,r.updateProjectionMatrix());o.makeTranslation(-y.x,-y.y,-y.z),_.state.buffers.color.setClear(1,1,1,1),_.setRenderTarget(i.map),_.clear();for(var l=0;l<6;l++)_.state.viewport(u[l]),x.copy(r.position),x.add(L[l]),r.up.copy(C[l]),r.lookAt(x),r.updateMatrixWorld(),h.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),g.setFromProjectionMatrix(h),W(e,t,r,!0,n)}(t,n,c);break;case ee:!function(e,t,n){var i=n.shadow,r=i.camera,o=i.matrix,a=n.isPointLight?2:1,s=p.copy(i.mapSize).multiplyScalar(a).min(m).multiplyScalar(1/a);null===i._additionalMapCube&&(i._additionalMapCube=new Zr(s.x,{minFilter:Je,magFilter:Je,format:d.isWebGL2?dt:lt,type:ot}),i._additionalMapCube.texture.name=n.name+".shadowMap.tmpCube");null===i._additionalMap2D&&(i._additionalMap2D=new an(s.x*a,s.y*a,{minFilter:Je,magFilter:Je,format:d.isWebGL2?dt:lt,type:ot}),i._additionalMap2D.texture.name=n.name+".shadowMap.tmp2D");null===i.map&&(i.map=new an(s.x*a,s.y*a,{minFilter:Je,magFilter:Je,format:d.isWebGL2?dt:lt,type:ot}),i.map.texture.name=n.name+".shadowMap");y.setFromMatrixPosition(n.matrixWorld),r.position.copy(y),n.isSpotLight&&(r.fov=90,r.updateProjectionMatrix());o.makeTranslation(-y.x,-y.y,-y.z);for(var l=0;l<6;l++)x.copy(r.position),x.add(L[l]),r.up.copy(C[l]),2!==l&&3!==l&&r.up.multiplyScalar(-1),r.lookAt(x),r.updateMatrixWorld(),h.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),g.setFromProjectionMatrix(h),_.setRenderTarget(i._additionalMapCube,l),_.clearDepth(),X(t,r,n),W(e,t,r,!0,n);var c=Math.max(i.radius*a,.001),u=function(e){return Math.ceil(Ka*e)}(c);(function(e,t,n){var i=B.material=V;i.uniforms.tCube.value=t.texture,i.uniforms.texelSize.value.set(1/n.width,1/n.height),i.uniformsNeedUpdate=!0,e.setRenderTarget(n),e.clear(),e.updateGeometry(B),e.renderBufferDirect(F,!1,B.geometry,i,B,null)})(_,i._additionalMapCube,i.map),G(_,i.map,i._additionalMap2D,u,c,I,D),G(_,i._additionalMap2D,i.map,u,c,O,D)}(t,n,c);break;default:continue}else{if(!c.isSpotLight&&!c.isDirectionalLight)continue;switch(k.type){case Y:case ne:case q:case Z:case te:!function(e,t,n){var i=n.shadow,r=i.camera,o=i.matrix,a=p.copy(i.mapSize).min(m);{var s;n.isSpotLight&&i.map&&i.map.width!==i.map.height&&(s=i.map,i.map=i._additionalMap2D,i._additionalMap2D=s)}null===i.map&&(i.map=new an(a.x,a.y,{minFilter:Ze,magFilter:Ze,format:lt,type:tt}),i.map.texture.name=n.name+".shadowMap");i.isSpotLightShadow&&i.updateMatrices(n);{var l;y.setFromMatrixPosition(n.matrixWorld),r.position.copy(y),x.setFromMatrixPosition(n.target.matrixWorld),r.lookAt(x),r.updateMatrixWorld(),n.isDirectionalLight&&n.shadow.isDirectionalLightShadowCSM?(l=H(t,i,a,P),r.left=l.center.x-l.radius,r.right=l.center.x+l.radius,r.top=l.center.y+l.radius,r.bottom=l.center.y-l.radius,r.near=-l.center.z-l.radius,r.far=-l.center.z+l.radius,r.updateProjectionMatrix()):n.isSpotLight&&i.useMinFov90&&(r.fov=90,r.updateProjectionMatrix())}o.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),o.multiply(r.projectionMatrix),o.multiply(r.matrixWorldInverse),_.state.buffers.color.setClear(1,1,1,1),_.setRenderTarget(i.map),_.clear(),h.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),g.setFromProjectionMatrix(h),W(e,t,r,!1,n)}(t,n,c);break;case ee:!function(e,t,n){var i=n.shadow,r=i.camera,o=i.matrix,a=p.copy(i.mapSize).min(m);null===i._additionalMap2D&&(i._additionalMap2D=new an(a.x,a.y,{minFilter:Je,magFilter:Je,format:d.isWebGL2?dt:lt,type:ot}),i._additionalMap2D.texture.name=n.name+".shadowMap.tmp2D");null===i.map&&(i.map=new an(a.x,a.y,{minFilter:Je,magFilter:Je,format:d.isWebGL2?dt:lt,type:ot}),i.map.texture.name=n.name+".shadowMap");{var s,l;y.setFromMatrixPosition(n.matrixWorld),r.position.copy(y),x.setFromMatrixPosition(n.target.matrixWorld),r.lookAt(x),r.updateMatrixWorld(),n.isDirectionalLight?(n.shadow.isDirectionalLightShadowCSM&&(s=H(t,i,a,P),r.left=s.center.x-s.radius,r.right=s.center.x+s.radius,r.top=s.center.y+s.radius,r.bottom=s.center.y-s.radius,r.near=-s.center.z-s.radius,r.far=-s.center.z+s.radius,r.updateProjectionMatrix()),l=n.getWorldDirection(T),y.addScaledVector(l,r.near)):n.isSpotLight&&i.useMinFov90&&(r.fov=90,r.updateProjectionMatrix())}{var c;o.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),o.multiply(r.projectionMatrix),o.multiply(r.matrixWorldInverse),h.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),g.setFromProjectionMatrix(h),_.setRenderTarget(i.map),_.clearDepth(),X(t,r,n),W(e,t,r,!1,n),c=n.isDirectionalLight&&n.shadow.isDirectionalLightShadowCSM?function(e,t){return $a*e/t}(i.radius,(r.right-r.left)/2):n.isSpotLight?i.radius*Ja:i.radius}var u=function(e){return Math.ceil(Qa*e)}(c=Math.max(c,.001));G(_,i.map,i._additionalMap2D,u,c,O,N),G(_,i._additionalMap2D,i.map,u,c,I,N)}(t,n,c);break;default:continue}}else console.warn("v3d.WebGLShadowMap:",c,"has no shadow.")}k.needsUpdate=!1,_.setRenderTarget(i,r,o)}}}function ts(u,n,e){var t,i,r=e.isWebGL2;var o=new function(){var t=!1,o=new on,n=null,a=new on(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,i,r){!0===r&&(e*=i,t*=i,n*=i),o.set(e,t,n,i),!1===a.equals(o)&&(u.clearColor(e,t,n,i),a.copy(o))},reset:function(){t=!1,n=null,a.set(-1,0,0,0)}}},a=new function(){var t=!1,n=null,i=null,r=null;return{setTest:function(e){(e?z:G)(2929)},setMask:function(e){n===e||t||(u.depthMask(e),n=e)},setFunc:function(e){if(i!==e){if(e)switch(e){case Le:u.depthFunc(512);break;case Ce:u.depthFunc(519);break;case Oe:u.depthFunc(513);break;case Ie:u.depthFunc(515);break;case De:u.depthFunc(514);break;case Ne:u.depthFunc(518);break;case Fe:u.depthFunc(516);break;case Be:u.depthFunc(517);break;default:u.depthFunc(515)}else u.depthFunc(515);i=e}},setLocked:function(e){t=e},setClear:function(e){r!==e&&(u.clearDepth(e),r=e)},reset:function(){t=!1,r=i=n=null}}},s=new function(){var t=!1,n=null,i=null,r=null,o=null,a=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?z:G)(2960)},setMask:function(e){n===e||t||(u.stencilMask(e),n=e)},setFunc:function(e,t,n){i===e&&r===t&&o===n||(u.stencilFunc(e,t,n),i=e,r=t,o=n)},setOp:function(e,t,n){a===e&&s===t&&l===n||(u.stencilOp(e,t,n),a=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=a=o=r=i=n=null}}},l=u.getParameter(34921),c=new Uint8Array(l),d=new Uint8Array(l),h=new Uint8Array(l),f={},p=null,m=null,v=null,g=null,_=null,x=null,y=null,b=null,M=null,w=!1,S=null,A=null,T=null,E=null,L=null,C=u.getParameter(35661),P=!1,R=0,O=u.getParameter(7938);-1!==O.indexOf("WebGL")?(R=parseFloat(/^WebGL\ ([0-9])/.exec(O)[1]),P=1<=R):-1!==O.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(O)[1]),P=2<=R);var I=null,D={},N=new on,F=new on;function B(e,t,n){var i=new Uint8Array(4),r=u.createTexture();u.bindTexture(e,r),u.texParameteri(e,10241,9728),u.texParameteri(e,10240,9728);for(var o=0;oi||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){var o=t?Jt.floorPowerOfTwo:Math.floor,a=o(r*e.width),s=o(r*e.height);void 0===c&&(c=u(a,s));var l=n?u(a,s):c;return l.width=a,l.height=s,l.getContext("2d").drawImage(e,0,0,a,s),console.warn("v3d.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"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 Jt.isPowerOfTwo(e.width)&&Jt.isPowerOfTwo(e.height)}function E(e,t){return e.generateMipmaps&&t&&e.minFilter!==Ze&&e.minFilter!==Je}function L(e,t,n,i){x.generateMipmap(e),M.get(t).__maxMipLevel=Math.log(Math.max(n,i))*Math.LOG2E}function C(e,t,n){if(!1===A)return t;if(null!==e){if(void 0!==x[e])return x[e];console.warn("v3d.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}var i=t;return 6403===t&&(5126===n&&(i=33326),5131===n&&(i=33325),5121===n&&(i=33321)),6407===t&&(5126===n&&(i=34837),5131===n&&(i=34843),5121===n&&(i=32849)),6408===t&&(5126===n&&(i=34836),5131===n&&(i=34842),5121===n&&(i=32856)),33325===i||33326===i||34842===i||34836===i?y.get("EXT_color_buffer_float"):34843!==i&&34837!==i||console.warn("v3d.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),i}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=M.get(e);if(void 0===t.__webglInit)return;x.deleteTexture(t.__webglTexture),M.remove(e)}(t),t.isVideoTexture&&a.delete(t),S.memory.textures--,S.removeTextureSpec(t)}function P(e){var t=e.target;t.removeEventListener("dispose",P),function(e){var t=M.get(e),n=M.get(e.texture);if(!e)return;void 0!==n.__webglTexture&&x.deleteTexture(n.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(var i=0;i<6;i++)x.deleteFramebuffer(t.__webglFramebuffer[i]),t.__webglDepthbuffer&&x.deleteRenderbuffer(t.__webglDepthbuffer[i]);else x.deleteFramebuffer(t.__webglFramebuffer),t.__webglDepthbuffer&&x.deleteRenderbuffer(t.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){x.deleteTexture(t.__webglColorTexture),x.deleteTexture(t.__webglDepthStencilTexture),S.memory.textures-=2;for(var i=0,r=t.__webglViewFramebuffers.length;iu)return!1;for(var n=1,i=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(ls.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:a,point:ws.clone(),uv:Ei.getUV(ws,Cs,Ps,Rs,Os,Is,Ds,new $t),face:null,object:this}))):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 Vn.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}});var Bs=new dn,Vs=new dn;function Us(){Vn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function zs(e,t){e&&e.isGeometry&&console.error("v3d.SkinnedMesh no longer supports v3d.Geometry. Use v3d.BufferGeometry instead."),Pr.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new xn,this.bindMatrixInverse=new xn,this.normalizeSkinWeights()}Us.prototype=Object.assign(Object.create(Vn.prototype),{constructor:Us,isLOD:!0,copy:function(e){Vn.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,i=t.length;n=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(;ie.far||t.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}))}else for(m=0,v=f.length/3-1;me.far||t.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}))}}else if(i.isGeometry)for(var x,y=i.vertices,b=y.length,m=0;me.far||t.push({distance:x,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 il=new dn,rl=new dn;function ol(e,t){nl.call(this,e,t),this.type="LineSegments"}function al(e,t){nl.call(this,e,t),this.type="LineLoop"}function sl(e){Vi.call(this),this.type="PointsMaterial",this.color=new Ri(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}ol.prototype=Object.assign(Object.create(nl.prototype),{constructor:ol,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,n=[],i=0,r=t.count;ir.far)return;o.push({distance:c,distanceToRay:Math.sqrt(s),point:l,index:t,face:null,object:a})}}function pl(e,t,n,i,r,o,a,s,l){rn.call(this,e,t,n,i,r,o,a,s,l),this.format=void 0!==a?a:st,this.minFilter=void 0!==o?o:Je,this.magFilter=void 0!==r?r:Je,this.generateMipmaps=!1}function ml(e,t,n,i,r,o,a,s,l,c,u,d){rn.call(this,null,o,a,s,l,c,i,r,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function vl(e,t,n,i,r,o,a,s,l){rn.call(this,e,t,n,i,r,o,a,s,l),this.needsUpdate=!0}function gl(e,t,n,i,r,o,a,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=at),rn.call(this,null,i,r,o,a,s,c,n,l),this.image={width:e,height:t},this.magFilter=void 0!==a?a:Ze,this.minFilter=void 0!==s?s:Ze,this.flipY=!1,this.generateMipmaps=!1}function _l(e){hr.call(this),this.type="WireframeGeometry";var t,n,i,r,o,a,s=[],l=[0,0],c={},u=["a","b","c"];if(e&&e.isGeometry){for(var d=e.faces,h=0,f=d.length;h=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),((ml.prototype=Object.create(rn.prototype)).constructor=ml).prototype.isCompressedTexture=!0,((vl.prototype=Object.create(rn.prototype)).constructor=vl).prototype.isCanvasTexture=!0,((gl.prototype=Object.create(rn.prototype)).constructor=gl).prototype.isDepthTexture=!0,(_l.prototype=Object.create(hr.prototype)).constructor=_l,(xl.prototype=Object.create(Br.prototype)).constructor=xl,(yl.prototype=Object.create(hr.prototype)).constructor=yl,(bl.prototype=Object.create(Br.prototype)).constructor=bl,(Ml.prototype=Object.create(hr.prototype)).constructor=Ml,(wl.prototype=Object.create(Br.prototype)).constructor=wl,(Sl.prototype=Object.create(Ml.prototype)).constructor=Sl,(Al.prototype=Object.create(Br.prototype)).constructor=Al,(Tl.prototype=Object.create(Ml.prototype)).constructor=Tl,(El.prototype=Object.create(Br.prototype)).constructor=El,(Ll.prototype=Object.create(Ml.prototype)).constructor=Ll,(Cl.prototype=Object.create(Br.prototype)).constructor=Cl,(Pl.prototype=Object.create(Ml.prototype)).constructor=Pl,(Rl.prototype=Object.create(Br.prototype)).constructor=Rl,((Ol.prototype=Object.create(hr.prototype)).constructor=Ol).prototype.toJSON=function(){var e=hr.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e},(Il.prototype=Object.create(Br.prototype)).constructor=Il,(Dl.prototype=Object.create(hr.prototype)).constructor=Dl,(Nl.prototype=Object.create(Br.prototype)).constructor=Nl,(Fl.prototype=Object.create(hr.prototype)).constructor=Fl;var Bl=function(e,t,n){n=n||2;var i,r,o,a,s,l,c,u=t&&t.length,d=u?t[0]*n:e.length,h=Vl(e,0,d,n,!0),f=[];if(!h||h.next===h.prev)return f;if(u&&(h=function(e,t,n,i){var r,o,a,s,l,c=[];for(r=0,o=t.length;r=i.next.y&&i.next.y!==i.y){var s=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=r&&a=i.x&&i.x>=u&&r!==i.x&&jl(on.x)&&Yl(i,e)&&(n=i,h=l),i=i.next;return n}(e,t))&&Ul(n=ql(t,e),n.next)}}(c[r],n),n=Ul(n,n.next);return n}(e,t,h,n)),e.length>80*n){i=o=e[0],r=a=e[1];for(var p=n;po.x?r.x>a.x?r.x:a.x:o.x>a.x?o.x:a.x,u=r.y>o.y?r.y>a.y?r.y:a.y:o.y>a.y?o.y:a.y,d=kl(s,l,t,n,i),h=kl(c,u,t,n,i),f=e.prevZ,p=e.nextZ;for(;f&&f.z>=d&&p&&p.z<=h;){if(f!==e.prev&&f!==e.next&&jl(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&0<=Wl(f.prev,f,f.next))return!1;if(f=f.prevZ,p!==e.prev&&p!==e.next&&jl(r.x,r.y,o.x,o.y,a.x,a.y,p.x,p.y)&&0<=Wl(p.prev,p,p.next))return!1;p=p.nextZ}for(;f&&f.z>=d;){if(f!==e.prev&&f!==e.next&&jl(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&0<=Wl(f.prev,f,f.next))return!1;f=f.prevZ}for(;p&&p.z<=h;){if(p!==e.prev&&p!==e.next&&jl(r.x,r.y,o.x,o.y,a.x,a.y,p.x,p.y)&&0<=Wl(p.prev,p,p.next))return!1;p=p.nextZ}return!0}(e,i,r,o):function(e){var t=e.prev,n=e,i=e.next;if(0<=Wl(t,n,i))return!1;var r=e.next.next;for(;r!==e.prev;){if(jl(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&0<=Wl(r.prev,r,r.next))return!1;r=r.next}return!0}(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),Ql(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?zl(e=function(e,t,n){var i=e;do{var r=i.prev,o=i.next.next;!Hl(r,o)&&Xl(r,i,i.next,o)&&Yl(r,o)&&Yl(o,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(o.i/n),Ql(i),Ql(i.next),i=e=o),i=i.next}while(i!==e);return i}(e,t,n),t,n,i,r,o,2):2===a&&function(e,t,n,i,r,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&function(e,t){return e.next.i!==t.i&&e.prev.i!==t.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&&Xl(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&Yl(e,t)&&Yl(t,e)&&function(e,t){var n=e,i=!1,r=(e.x+t.x)/2,o=(e.y+t.y)/2;for(;n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next,n!==e;);return i}(e,t)}(a,s)){var l=ql(a,s);return a=Ul(a,a.next),l=Ul(l,l.next),zl(a,t,n,i,r,o),zl(l,t,n,i,r,o)}s=s.next}a=a.next}while(a!==e)}(e,t,n,i,r,o):zl(Ul(e),t,n,i,r,o,1);break}}}function Gl(e,t){return e.x-t.x}function kl(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function jl(e,t,n,i,r,o,a,s){return 0<=(r-a)*(t-s)-(e-a)*(o-s)&&0<=(e-a)*(i-s)-(n-a)*(t-s)&&0<=(n-a)*(o-s)-(r-a)*(i-s)}function Wl(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Hl(e,t){return e.x===t.x&&e.y===t.y}function Xl(e,t,n,i){return Hl(e,n)&&Hl(t,i)||Hl(e,i)&&Hl(n,t)||0Number.EPSILON){var u,d,h=Math.sqrt(l),f=Math.sqrt(a*a+s*s),p=t.x-o/h,m=t.y+r/h,v=((n.x-s/f-p)*s-(n.y+a/f-m)*a)/(r*s-o*a),g=(u=p+r*v-e.x)*u+(d=m+o*v-e.y)*d;if(g<=2)return new $t(u,d);i=Math.sqrt(g/2)}else{var _=!1;r>Number.EPSILON?a>Number.EPSILON&&(_=!0):r<-Number.EPSILON?a<-Number.EPSILON&&(_=!0):Math.sign(o)===Math.sign(s)&&(_=!0),i=_?(u=-o,d=r,Math.sqrt(l)):(u=r,d=o,Math.sqrt(l/2))}return new $t(u/i,d/i)}for(var F=[],B=0,V=A.length,U=V-1,z=B+1;B>>1;e "+i[r]+";"}}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]))},b.prototype.hasPathTo=function(e){return this.marked[e]},b.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()},b.prototype.distanceTo=function(e){return this.cost[e]},c.Dijkstra=b;function M(e,t){var n=e.V;this.s=t,this.marked=[],this.edgeTo=[],this.cost=[];for(var i=0;ithis.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 w(e,t){var n=e.V;this.s=t,this.marked=[],this.edgeTo=[],this.cost=[];for(var i=0;ithis.cost[t]+e.weight&&(this.cost[n]=this.cost[t]+e.weight,this.marked[n]=!0,this.edgeTo[n]=e)},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.TopologicalSortShortestPaths=w;function S(e,t,n){this.value=0,e.V;var i=Number.MAX_VALUE;for(this.marked=null,this.edgeTo=null,this.s=t,this.t=n;this.hasAugmentedPath(e);){for(var r=this.t;r!=this.s;r=this.edgeTo[r].from())i=Math.min(i,this.edgeTo[r].residualCapacityTo(r));for(r=this.t;r!=this.s;r=this.edgeTo[r].from())this.edgeTo[r].addResidualFlowTo(r,i);this.value+=i}}S.prototype.hasAugmentedPath=function(e){var t=e.V;this.marked=[],this.edgeTo=[];for(var n=0;n"+o+", please reexport your scene")}for(r=0;ro.tracks[s].times[0]&&(m=o.tracks[s].times[0]);for(s=0;st;)--a;return++a,0===o&&a===r||(a<=o&&(o=(a=Math.max(a,1))-1),n=this.getValueSize(),this.times=Tu.arraySlice(i,o,a),this.values=Tu.arraySlice(this.values,o*n,a*n)),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,i=this.values,r=n.length;0===r&&(console.error("v3d.KeyframeTrack: Track is empty.",this),e=!1);for(var o=null,a=0;a!==r;a++){var s=n[a];if("number"==typeof s&&isNaN(s)){console.error("v3d.KeyframeTrack: Time is not a valid number.",this,a,s),e=!1;break}if(null!==o&&sNumber.EPSILON&&(l.normalize(),i=Math.acos(Jt.clamp(o[u-1].dot(o[u]),-1,1)),a[u].applyMatrix4(c.makeRotationAxis(l,i))),s[u].crossVectors(o[u],a[u]);if(!0===t)for(i=Math.acos(Jt.clamp(a[0].dot(a[e]),-1,1)),i/=e,0i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(od(a,s.x,l.x,c.x,u.x),od(a,s.y,l.y,c.y,u.y)),n},pd.prototype.copy=function(e){Qu.prototype.copy.call(this,e),this.points=[];for(var t=0,n=e.points.length;t=t){var r=n[i]-t,o=this.curves[i],a=o.getLength(),s=0===a?0:1-r/a;return o.getPointAt(s)}i++}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,i=this.curves.length;nNumber.EPSILON){if(c<0&&(a=t[o],l=-l,s=t[r],c=-c),e.ys.y)continue;if(e.y===a.y){if(e.x===a.x)return 1}else{var u=c*(e.x-a.x)-l*(e.y-a.y);if(0==u)return 1;if(u<0)continue;i=!i}}else{if(e.y!==a.y)continue;if(s.x<=e.x&&e.x<=a.x||a.x<=e.x&&e.x<=s.x)return 1}}return i}(S.p,h[T].p)||(y!==T&&x.push({froms:y,tos:T,hole:w}),A?(A=!1,d[T].push(S)):_=!0);A&&d[y].push(S)}0t.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1)))),this._effectiveWeight=i},_updateTimeScale:function(e){var t,n=0;return this.paused||(n=this.timeScale,null!==(t=this._timeScaleInterpolant)&&(n*=t.evaluate(e)[0],e>t.parameterPositions[1]&&(this.stopWarping(),0===n?this.paused=!0:this.timeScale=n))),this._effectiveTimeScale=n},_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),i=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=Jt.clamp(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})),this.time;var r=2202===this.loop,o=this._loopIsPing(this._loopCount)?1:-1;this.time+=o*e;var a,s,l,c,u=this.timen,d=!1;return-1===this._loopCount&&(d=u,this._loopCount=d?-1:0,this._pingIsEven=!d,0<=e?this._setEndings(!0,0===this.repetitions,r):this._setEndings(0===this.repetitions,!0,r)),u&&(a=Math.floor((this.time-t)/i),this._loopCount+=Math.abs(a),(s=this.repetitions-this._loopCount)<=0?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=Jt.clamp(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})):(1==s?(l=e<0,this._setEndings(l,!l,r)):this._setEndings(!1,!1,r),(c=(this.time-t)%i)<0&&(c+=i),this.time=r?n-c:c+t,d||this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a}))),this.time},_setEndings:function(e,t,n){var i=this._interpolantSettings;n?(i.endingStart=St,i.endingEnd=St):(i.endingStart=e?this.zeroSlopeAtStart?St:wt:At,i.endingEnd=t?this.zeroSlopeAtEnd?St:wt:At)},_scheduleFading:function(e,t,n){var i=this._mixer,r=i.time,o=this._weightInterpolant;null===o&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=r,s[0]=t,a[1]=r+e,s[1]=n,this}}),Vh.prototype=Object.assign(Object.create(a.prototype),{constructor:Vh,_bindAction:function(e,t){var n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName,c=l[s];void 0===c&&(c={},l[s]=c);for(var u=0;u!==r;++u){var d=i[u],h=d.name;if(void 0!==(f=c[h]))o[u]=f;else{if(void 0!==(f=o[u])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,h));continue}var f,p=t&&t._propertyBindings[u].binding.parsedPath;++(f=new Sh(Nh.create(n,h,p),d.ValueTypeName,d.getValueSize())).referenceCount,this._addInactiveBinding(f,s,h),o[u]=f}a[u].resultBuffer=f.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){var t,n,i;null===e._cacheIndex&&(t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n],this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t));for(var r=e._propertyBindings,o=0,a=r.length;o!==a;++o){var s=r[o];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,i=t.length;n!==i;++n){var r=t[n];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}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 $t),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 $t),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return kh.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 Wh=new dn,Hh=new dn;function Xh(e,t){this.start=void 0!==e?e:new dn,this.end=void 0!==t?t:new dn}function Yh(e){Vn.call(this),this.material=e,this.render=function(){}}Object.assign(Xh.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 dn),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 dn),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 dn),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,t){Wh.subVectors(e,this.start),Hh.subVectors(this.end,this.start);var n=Hh.dot(Hh),i=Hh.dot(Wh)/n;return t&&(i=Jt.clamp(i,0,1)),i},closestPointToPoint:function(e,t,n){var i=this.closestPointToPointParameter(e,t);return void 0===n&&(console.warn("v3d.Line3: .closestPointToPoint() target is now required"),n=new dn),this.delta(n).multiplyScalar(i).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)}}),((Yh.prototype=Object.create(Vn.prototype)).constructor=Yh).prototype.isImmediateRenderObject=!0;var qh=new dn;function Zh(e,t){Vn.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;for(var n=new hr,i=[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],r=0,o=1;r<32;r++,o++){var a=r/32*Math.PI*2,s=o/32*Math.PI*2;i.push(Math.cos(a),Math.sin(a),1,Math.cos(s),Math.sin(s),1)}n.setAttribute("position",new Zi(i,3));var l=new Qs({fog:!1});this.cone=new ol(n,l),this.add(this.cone),this.update()}((Zh.prototype=Object.create(Vn.prototype)).constructor=Zh).prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},Zh.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),qh.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(qh),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var Qh=new dn,Kh=new xn,Jh=new xn;function $h(e){for(var t=function e(t){var n=[];t&&t.isBone&&n.push(t);for(var i=0;in.far?null:{distance:c,point:Ff.clone(),object:e}}(e,e.material,t,n,Cf,Pf,Rf,Nf);return c&&(r&&(Of.fromBufferAttribute(r,o),If.fromBufferAttribute(r,a),Df.fromBufferAttribute(r,s),c.uv=Ei.getUV(Nf,Cf,Pf,Rf,Of,If,Df,new $t)),l=new dn,c.face=new Fi(o,a,s,Ei.getNormal(Cf,Pf,Rf,l)),c.faceIndex=o),c}function Vf(e,t,n,i,r,o){var a=3*r,s=t.index.getX(a),l=t.index.getX(1+a),c=t.index.getX(2+a),u=Bf(e,n,i,t.attributes.position,t.attributes.uv,s,l,c);return u?(u.faceIndex=r,o&&o.push(u),u):null}function Uf(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 zf(e){for(var t=-1,n=-1/0,i=0;i<3;i++){var r=e[i+3]-e[i];ne.max||e.min>this.max}}]),e}();kf.prototype.setFromBox=(Gf=new dn,function(e,t){for(var n=t.min,i=t.max,r=1/0,o=-1/0,a=0;a<=1;a++)for(var s=0;s<=1;s++)for(var l=0;l<=1;l++){Gf.x=n.x*a+i.x*(1-a),Gf.y=n.y*s+i.y*(1-s),Gf.z=n.z*l+i.z*(1-l);var c=e.dot(Gf),r=Math.min(c,r),o=Math.max(c,o)}this.min=r,this.max=o});var jf,Wf,Hf,Xf,Yf,qf,Zf,Qf,Kf,Jf,$f,ep,tp,np,ip,rp,op,ap,sp,lp,cp,up,dp,hp=(jf=new dn,Wf=new dn,Hf=new dn,function(e,t,n){var i=e.start,r=jf,o=t.start,a=Wf;Hf.subVectors(i,o),jf.subVectors(e.end,t.start),Wf.subVectors(t.end,t.start);var s=Hf.dot(a),l=a.dot(r),c=a.dot(a),u=Hf.dot(r),d=r.dot(r)*c-l*l,h=0!=d?(s*l-u*c)/d:0,f=(s+h*l)/c;n.x=h,n.y=f}),fp=(Xf=new $t,Yf=new dn,qf=new dn,function(e,t,n,i){hp(e,t,Xf);var r=Xf.x,o=Xf.y;if(0<=r&&r<=1&&0<=o&&o<=1)return e.at(r,n),void t.at(o,i);if(0<=r&&r<=1)return o<0?t.at(0,i):t.at(1,i),void e.closestPointToPoint(i,!0,n);if(0<=o&&o<=1)return r<0?e.at(0,n):e.at(1,n),void t.closestPointToPoint(n,!0,i);var a=r<0?e.start:e.end,s=o<0?t.start:t.end,l=Yf,c=qf;return e.closestPointToPoint(s,!0,Yf),t.closestPointToPoint(a,!0,qf),l.distanceToSquared(s)<=c.distanceToSquared(a)?(n.copy(l),void i.copy(s)):(n.copy(a),void i.copy(c))}),pp=(Zf=new dn,Qf=new dn,Kf=new vi,Jf=new Xh,function(e,t){var n=e.radius,i=e.center,r=t.a,o=t.b,a=t.c;if(Jf.start=r,Jf.end=o,Jf.closestPointToPoint(i,!0,Zf).distanceTo(i)<=n)return!0;if(Jf.start=r,Jf.end=a,Jf.closestPointToPoint(i,!0,Zf).distanceTo(i)<=n)return!0;if(Jf.start=o,Jf.end=a,Jf.closestPointToPoint(i,!0,Zf).distanceTo(i)<=n)return!0;var s=t.getPlane(Kf);if(Math.abs(s.distanceToPoint(i))<=n){var l=s.projectPoint(i,Qf);if(t.containsPoint(l))return!0}return!1}),mp=function(){_inherits(o,Ei);var r=_createSuper(o);function o(){var e;_classCallCheck(this,o);for(var t=arguments.length,n=new Array(t),i=0;i=o;)r--;if(!(i=h.maxDepth&&(p=!0),n<=h.maxLeafTris||i>=h.maxDepth)return e.offset=t,e.count=n,e;var r=f.getOptimalSplit(e.boundingData,t,n,h.strategy);if(-1===r.axis)return e.offset=t,e.count=n,e;var o,a,s,l,c,u,d=f.partition(t,n,r);return d===t||d===t+n?(e.offset=t,e.count=n):(e.splitAxis=r.axis,s=d-(a=t),(o=e.left=new qp).boundingData=f.getBounds(a,s,new Float32Array(6)),m(o,a,s,i+1),c=d,u=n-s,(l=e.right=new qp).boundingData=f.getBounds(c,u,new Float32Array(6)),m(l,c,u,i+1)),e},i=[],r=this._getRootIndexRanges(e);if(1===r.length){var o=new qp,a=r[0];null!=e.boundingBox?o.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):o.boundingData=f.getBounds(a.offset,a.count,new Float32Array(6)),m(o,a.offset,a.count),i.push(o)}else for(var s=0;sa;)this.remove(this.children.pop())}}}]),o}(),om=function(){_inherits(r,Vn);var i=_createSuper(r);function r(e){var t,n=1t;)this._roots.pop();for(var n,i,r=0;r=this._roots.length?(n=new rm(this._mesh,this.depth,r),this.add(n),this._roots.push(n)):((i=this._roots[r]).depth=this.depth,i.update())}this.position.copy(this._mesh.position),this.rotation.copy(this._mesh.rotation),this.scale.copy(this._mesh.scale)}}]),r}(),am=new hi,sm=new xn,lm=Pr.prototype.raycast;function cm(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;try{sm.getInverse(this.matrixWorld,!0)}catch(e){return}var n;am.copy(e.ray).applyMatrix4(sm),!0===e.firstHitOnly?(n=this.geometry.boundsTree.raycastFirst(this,e,am))&&t.push(n):this.geometry.boundsTree.raycast(this,e,am,t)}else lm.call(this,e,t)}function um(e){return this.boundsTree=new em(this,e),this.boundsTree}function dm(){this.boundsTree=null}var hm,fm,pm,mm,vm,gm,_m,xm,ym,bm,Mm,wm,Sm,Am,Tm,Em,Lm,Cm,Pm,Rm,Om,Im,Dm,Nm,Fm,Bm,Vm,Um,zm,Gm,km=["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","gradientMap","lightMap","map","metalnessMap","normalMap","roughnessMap","specularMap"],jm={disposeTextures:function(t){if(km.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 Wm(){this.name="",this.type="Constraint",this.mute=!1}function Hm(e){Wm.call(this),this.type="TargetConstraint",this.target=e}function Xm(e){Hm.call(this,e),this.type="ChildOfConstraint",this.offsetMatrix=new xn}function Ym(e){Hm.call(this,e),this.type="CopyLocationConstraint"}function qm(e){Hm.call(this,e),this.type="CopyRotationConstraint"}function Zm(e){Hm.call(this,e),this.type="CopyScaleConstraint"}function Qm(e){Hm.call(this,e),this.type="FloorConstraint",this.floorLocation="Y",this.offset=0}function Km(){Wm.call(this),this.type="LimitLocationConstraint",this.min=(new dn).setScalar(-1/0),this.max=(new dn).setScalar(1/0)}function Jm(){Wm.call(this),this.type="LimitRotationConstraint",this.axis="Y",this.min=0,this.max=2*Math.PI}function $m(){Wm.call(this),this.type="LimitScaleConstraint",this.min=(new dn).setScalar(-1/0),this.max=(new dn).setScalar(1/0)}function ev(e){Hm.call(this,e),this.type="LockedTrackConstraint",this.trackAxis="X",this.lockAxis="Y"}function tv(e){Hm.call(this,e),this.type="TrackToConstraint",this.trackAxis="X",this.upAxis="Y"}Object.assign(Wm.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)}}),Hm.prototype=Object.assign(Object.create(Wm.prototype),{constructor:Hm,isTargetConstraint:!0,copy:function(e){Wm.prototype.copy.call(this,e),this.target=e.target}}),Xm.prototype=Object.assign(Object.create(Hm.prototype),{constructor:Xm,isChildOfConstraint:!0,copy:function(e){Hm.prototype.copy.call(this,e),this.offsetMatrix.copy(e.offsetMatrix)},update:(hm=new xn,fm=(new ln).setFromAxisAngle(new dn(1,0,0),-Math.PI/2),function(e){Hm.prototype.update.call(this,e),this.mute||(hm.multiplyMatrices(this.target.matrixWorld,this.offsetMatrix),hm.decompose(e.position,e.quaternion,e.scale),e.isCamera&&e.quaternion.multiply(fm))})}),Ym.prototype=Object.assign(Object.create(Hm.prototype),{constructor:Ym,isCopyLocationConstraint:!0,update:(pm=new ln,mm=new dn,function(e){Hm.prototype.update.call(this,e),this.mute||(this.target.matrixWorld.decompose(e.position,pm,mm),e.parent&&e.parent.worldToLocal(e.position))})}),qm.prototype=Object.assign(Object.create(Hm.prototype),{constructor:qm,isCopyRotationConstraint:!0,update:(vm=new dn,gm=new ln,_m=new dn,xm=(new ln).setFromAxisAngle(new dn(1,0,0),-Math.PI/2),function(e){Hm.prototype.update.call(this,e),this.mute||(this.target.matrixWorld.decompose(vm,e.quaternion,_m),e.parent&&(e.parent.matrixWorld.decompose(vm,gm,_m),e.quaternion.premultiply(gm.inverse())),e.isCamera&&e.quaternion.multiply(xm))})}),Zm.prototype=Object.assign(Object.create(Hm.prototype),{constructor:Zm,isCopyScaleConstraint:!0,update:function(e){Hm.prototype.update.call(this,e),this.mute||e.scale.copy(this.target.scale)}}),Qm.prototype=Object.assign(Object.create(Hm.prototype),{constructor:Qm,isFloorConstraint:!0,copy:function(e){Hm.prototype.copy.call(this,e),this.floorLocation=e.floorLocation,this.offset=e.offset},update:function(e){if(Hm.prototype.update.call(this,e),!this.mute){var t=e.position,n=this.target.position,i=this.offset;switch(this.floorLocation){case"X":t.x=Math.max(t.x,n.x+i);break;case"Y":t.y=Math.max(t.y,n.y+i);break;case"Z":t.z=Math.max(t.z,n.z+i);break;case"-X":t.x=Math.min(t.x,n.x+i);break;case"-Y":t.y=Math.min(t.y,n.y+i);break;case"-Z":t.z=Math.min(t.z,n.z+i)}}}}),Km.prototype=Object.assign(Object.create(Wm.prototype),{constructor:Km,isLimitLocationConstraint:!0,copy:function(e){Wm.prototype.copy.call(this,e),this.min.copy(e.min),this.max.copy(e.max)},update:function(e){Wm.prototype.update.call(this,e),this.mute||e.position.clamp(this.min,this.max)}}),Jm.prototype=Object.assign(Object.create(Wm.prototype),{constructor:Jm,isLimitRotationConstraint:!0,copy:function(e){Wm.prototype.copy.call(this,e),this.axis=e.axis,this.min=e.min,this.max=e.max},update:(ym=new Mn,function(e){Wm.prototype.update.call(this,e),this.mute||("X"==this.axis?(ym.setFromQuaternion(e.quaternion,"XYZ"),ym.x=this._clampAngle(ym.x,this.min,this.max)):"Y"==this.axis?(ym.setFromQuaternion(e.quaternion,"YZX"),ym.y=this._clampAngle(ym.y,this.min,this.max)):"Z"==this.axis&&(ym.setFromQuaternion(e.quaternion,"ZXY"),ym.z=this._clampAngle(ym.z,this.min,this.max)),e.quaternion.setFromEuler(ym))}),_clampAngle:function(e,t,n){return Math.abs(n-t)<2*Math.PI&&(e=Jt.clampAngle(e,t,n)),e}}),$m.prototype=Object.assign(Object.create(Wm.prototype),{constructor:$m,isLimitScaleConstraint:!0,copy:function(e){Wm.prototype.copy.call(this,e),this.min.copy(e.min),this.max.copy(e.max)},update:function(e){Wm.prototype.update.call(this,e),this.mute||e.scale.clamp(this.min,this.max)}}),ev.prototype=Object.assign(Object.create(Hm.prototype),{constructor:ev,isLockedTrackConstraint:!0,copy:function(e){Hm.prototype.copy.call(this,e),this.trackAxis=e.trackAxis,this.lockAxis=e.lockAxis},update:(bm=new dn,Mm=new dn,wm=new dn,Sm=new dn,Am=new dn,Tm=new vi,Em=new dn,Lm=new dn,Cm=new ln,Pm=(new ln).setFromAxisAngle(new dn(1,0,0),-Math.PI/2),function(e){var t;Hm.prototype.update.call(this,e),this.mute||(wm.set("X"==this.trackAxis?1:"-X"==this.trackAxis?-1:0,"Y"==this.trackAxis?1:"-Y"==this.trackAxis?-1:0,"Z"==this.trackAxis?1:"-Z"==this.trackAxis?-1:0),Sm.set("X"==this.lockAxis?1:0,"Y"==this.lockAxis?1:0,"Z"==this.lockAxis?1:0),1!=Math.abs(wm.dot(Sm))&&(bm.setFromMatrixPosition(e.matrixWorld),Mm.setFromMatrixPosition(this.target.matrixWorld),Tm.setFromNormalAndCoplanarPoint(Sm,bm),Tm.projectPoint(Mm,Am).sub(bm),t=0Math.PI&&(n=t+Math.sign(t-n)*(2*Math.PI-i)),this.sphericalFrom.theta=t,this.sphericalTo.theta=n),this}),start:function(e){this.active=!0,this.duration=e,this.clock.start()},update:(nv=new dn,iv=new dn,function(){var e,t,n,i=0Math.abs(s)&&(w+=r,S=l.zoomSpeedTouch,A=l.zoomInertiaTouch),l.enablePan&&Math.abs(r)<=Math.abs(s)&&(C.add(a),P=l.panSpeedTouch,R=l.panInertiaTouch)}}}function K(e){if(!1!==l.enabled){switch(e.touches.length){case 0:d=o.NONE;break;case 1:if(!1===l.enableRotate)return;d=o.TOUCH_ROTATE,b.copy(W(e.touches[0].pageX,e.touches[0].pageY).negate()),y.copy(b)}l.dispatchEvent(B)}}function J(e){!1!==l.enabled&&e.preventDefault()}this.update=function(){D.active?D.update(function(e,t,n){if(l.object.position.copy(t),l.object.lookAt(n),1<=e){for(var i in v.set(0,0,0),g.set(0,0),w=M=0,L.set(0,0),C.set(0,0),f)f[i]=0;c.getDelta()}}):(l.object.getLocalDirection(h),m.setFromVector3(h),m.theta+=v.theta*_,m.phi+=v.phi*_,m.theta=Math.max(l.minAzimuthAngle,Math.min(l.maxAzimuthAngle,m.theta)),m.phi=Math.max(l.minPolarAngle,Math.min(l.maxPolarAngle,m.phi)),m.makeSafe(),h.setFromSpherical(m),n.copy(h).add(l.object.position),l.object.lookAtLocal(n),l.object.isPerspectiveCamera?l.object.position.addScaledVector(h,M):l.object.isOrthographicCamera&&(l.object.zoom*=1+.15*M,l.object.updateProjectionMatrix()),i.copy(h).cross(l.object.up).setLength(-L.x),i.add(r.copy(l.object.up).setLength(L.y)),l.object.position.add(i),function(){var e=c.getDelta();for(var t in v.set(v.radius,g.y,g.x),g.x=l.enableDamping?Jt.expAverageClamp(g.x,0,e,x,.001):0,g.y=l.enableDamping?Jt.expAverageClamp(g.y,0,e,x,.001):0,v.set(v.radius,v.phi-g.y,v.theta-g.x),L.copy(C),C.x=l.enableDamping?Jt.expAverageClamp(C.x,0,e,R,.001):0,C.y=l.enableDamping?Jt.expAverageClamp(C.y,0,e,R,.001):0,L.sub(C),L.multiplyScalar(P),M=w,w=l.enableDamping?Jt.expAverageClamp(w,0,e,A,.001):0,M-=w,M*=S,f){var n,i,r=t==ov.A||t==ov.LEFT_ARROW||t==ov.D||t==ov.RIGHT_ARROW,o=t==ov.W||t==ov.UP_ARROW||t==ov.S||t==ov.DOWN_ARROW,a=r?l.panInertia:l.zoomInertia,s=r?l.panSpeedKey:l.zoomSpeedKey;i=p.isKeyDown[t]?f[t]=1:(n=f[t],f[t]=Jt.expAverageClamp(f[t],0,e,a,.001),n-f[t]),l.enabled&&(r&&!l.enablePan||o&&!l.enableZoom||(i*=60*e*s,t==ov.A||t==ov.LEFT_ARROW?L.x+=i:t==ov.D||t==ov.RIGHT_ARROW?L.x-=i:t==ov.W||t==ov.UP_ARROW?M+=i:t!=ov.S&&t!=ov.DOWN_ARROW||(M-=i)))}}());var e=!1;1e-6g||8*(1-c.dot(h.object.quaternion))>g)||(h.dispatchEvent(f),l.copy(h.object.position),c.copy(h.object.quaternion),M=!1))}),this.dispose=function(){h.domElement.removeEventListener("contextmenu",ce,!1),h.domElement.removeEventListener("mousedown",ne,!1),h.domElement.removeEventListener("wheel",oe,!1),h.domElement.removeEventListener("touchstart",ae,!1),h.domElement.removeEventListener("touchend",le,!1),h.domElement.removeEventListener("touchmove",se,!1),document.removeEventListener("mousemove",ie,!1),document.removeEventListener("mouseup",re,!1),document.removeEventListener("mouseleave",re,!1),S.dispose()},this.tween=(u=new dn,d=new dn,function(e,t,n,i,r){h.targetObj.updateWorldMatrix(!0,!1),d.setFromMatrixPosition(h.targetObj.matrixWorld),h.object.parent&&(e=u.copy(e),h.object.parent.worldToLocal(e)),e.manhattanDistanceTo(h.object.position)<1e-5&&t.manhattanDistanceTo(d)<1e-5||k.setup({posFrom:h.object.position,targetFrom:d,posTo:e,targetTo:t,finishCb:i,movementType:r}).start(n)});var h=this,f={type:"change"},p={type:"start"},r={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 Jc,x=new Jc,y=1,b=new dn,M=!1,w={};w[ov.W]=w[ov.S]=w[ov.A]=w[ov.D]=w[ov.UP_ARROW]=w[ov.DOWN_ARROW]=w[ov.LEFT_ARROW]=w[ov.RIGHT_ARROW]=0;var S=new av(window);S.onKeyDown=function(e){e.keyCode in w&&(w[e.keyCode]=1)};var A=new $t,T=new $t,E=new $t,L=new $t,C=1,P=1,R=new $t,O=new $t,I=new $t,D=new $t,N=new $t,F=new $t,B=new $t,V=1,U=1,z=1,G=new dh,k=new sv;function j(){return Math.pow(.95,U)}function W(e){x.theta-=e}function H(e,t){T.set(e,t),L.add(T).sub(A),A.copy(T)}var X,Y,q,Z,Q=(X=new dn,function(e,t){X.setFromMatrixColumn(t,0),X.multiplyScalar(-e),b.add(X)}),K=(Y=new dn,function(e,t){Y.setFromMatrixColumn(t,1),Y.multiplyScalar(e),b.add(Y)}),J=(q=new dn,Z=new dn,function(e,t){var n,i,r=h.domElement===document?h.domElement.body:h.domElement,o=r.clientWidth,a=r.clientHeight;o&&a&&(h.object.isPerspectiveCamera?(h.targetObj.updateWorldMatrix(!0,!1),Z.setFromMatrixPosition(h.targetObj.matrixWorld),n=h.object.position,q.copy(n).sub(Z),i=q.length(),i*=Math.tan(h.object.fov/2*Jt.DEG2RAD),Q(2*e*i/a,h.object.matrix),K(2*t*i/a,h.object.matrix)):h.object.isOrthographicCamera?(Q(e*(h.object.right-h.object.left)/h.object.zoom/o,h.object.matrix),K(t*(h.object.top-h.object.bottom)/h.object.zoom/a,h.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),h.enablePan=!1))});function $(e){h.object.isPerspectiveCamera?V/=e:h.object.isOrthographicCamera?(V/=e,M=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),h.enableZoom=!1)}function ee(e){h.object.isPerspectiveCamera?V*=e:h.object.isOrthographicCamera?(V*=e,M=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),h.enableZoom=!1)}function te(e){var t,n;t=e.clientX,n=e.clientY,O.set(t,n),D.add(O).sub(R),R.copy(O)}function ne(e){if(!1!==h.enabled){switch(e.preventDefault(),e.button){case h.mouseButtons.ROTATE:if(!1===h.enableRotate)return;n=e,A.set(n.clientX,n.clientY),v=m.ROTATE;break;case h.mouseButtons.ZOOM:case h.mouseButtons.PAN:if(!1===h.enablePan)return;t=e,R.set(t.clientX,t.clientY),v=m.PAN}var t,n;v!==m.NONE&&(document.addEventListener("mousemove",ie,!1),document.addEventListener("mouseup",re,!1),document.addEventListener("mouseleave",re,!1),h.dispatchEvent(p))}}function ie(e){var t,n;if(!1!==h.enabled)switch(e.preventDefault(),v){case m.ROTATE:if(!1===h.enableRotate)return;H((n=e).clientX,n.clientY),C=h.rotateSpeed,P=h.rotateInertia;break;case m.DOLLY:if(!1===h.enableZoom)return;t=e,F.set(t.clientX,t.clientY),B.subVectors(F,N),0Math.abs(I.length())&&(0').concat("MADE WITH VERGE3D TRIAL",""),i.appendChild(n),setTimeout(function(){i.contains(n)&&890310108==Jt.hashString(n.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 Ri(1,0,.2),_=_||5;var x=new dn(1,0,0),n=new Av;n.setGeometry([0,0,0,x.x,x.y,x.z]);var i=new Rv({color:t,lineWidth:e,sizeAttenuation:0}),y=new Pr(n.geometry,i);y.name=v.name+"_LINE",v.add(y);var b=new dn,M=new dn,w=new ln;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,i=v.getWorldPosition(b);i.project(m.camera);var r,o,a=(i.x+1)/2*m.getWidth(),s=(1-i.y)/2*m.getHeight(),l=(n-s)/(t-a),c=(e.height+2*_)/(e.width+2*_);Math.abs(l)>c?r=((o=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))},printPerformanceInfo:function(m,v){v=v||1;var g=m.renderer.info,_=g.autoReset;g.autoReset=!1,g.reset();for(var x=m.frame,e=0;et.type?1:e.width!=t.width?t.width-e.width:t.height-e.height});for(c=0;c>4,n=(15&r)<<4|(o=s.indexOf(e.charAt(c++)))>>2,i=(3&o)<<6|(a=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(t),64!==o&&(l+=String.fromCharCode(n)),64!==a&&(l+=String.fromCharCode(i)),c>>0)o(0|e,0|t,0|n);else{i=e+n|0;e:if(3&(e^t))if(i>>>0<4)n=e;else if((r=i-4|0)>>>0>>0)n=e;else for(n=e;y[0|n]=M[0|t],y[n+1|0]=M[t+1|0],y[n+2|0]=M[t+2|0],y[n+3|0]=M[t+3|0],t=t+4|0,(n=n+4|0)>>>0<=r>>>0;);else{t:if((0|n)<1)n=e;else if(3&e)for(n=e;;){if(y[0|n]=M[0|t],t=t+1|0,i>>>0<=(n=n+1|0)>>>0)break t;if(!(3&n))break}else n=e;if(!((e=-4&i)>>>0<64||(r=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<=r>>>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(;y[0|n]=M[0|t],t=t+1|0,(0|i)!=(0|(n=n+1|0)););}}function T(e,t,n){if(n^=-1,t)for(;n=b[1056+((M[0|e]^255&n)<<2)>>2]^n>>>8,e=e+1|0,t=t+-1|0;);return-1^n}function a(e){var t=0;e&&(t=b[e+1200>>2],b[t+60>>2]&&E(b[t+24>>2]),E(t),E(e))}function f(e){var t;return(0|(e=(t=b[263312])+(e+3&-4)|0))<=-1||!(e>>>0<=(n.byteLength/65536|0)<<16>>>0||r(0|e))?(b[263185]=48,-1):(b[263312]=e,t)}function E(e){var t=0,n=0,i=0,r=0,o=0,a=0,s=0;e:if(e){o=(i=e+-8|0)+(e=-8&(n=b[e+-4>>2]))|0;t:if(!(1&n)){if(!(3&n))break e;if((i=i-(n=b[i>>2])|0)>>>0>2])))return b[263188]=e,b[o+4>>2]=-2&n,b[i+4>>2]=1|e,b[e+i>>2]=e,0}else{if(n>>>0<=255){if(r=b[i+8>>2],n=n>>>3|0,(0|(t=b[i+12>>2]))==(0|r)){b[263186]=b[263186]&m(n);break t}b[r+12>>2]=t,b[t+8>>2]=r;break t}if(s=b[i+24>>2],(0|i)==(0|(n=b[i+12>>2])))if((t=b[(r=i+20|0)>>2])||(t=b[(r=i+16|0)>>2])){for(;a=r,(t=b[(r=(n=t)+20|0)>>2])||(r=n+16|0,t=b[n+16>>2]););b[a>>2]=0}else n=0;else t=b[i+8>>2],b[t+12>>2]=n,b[n+8>>2]=t;if(!s)break t;r=b[i+28>>2];n:{if(b[(t=1053048+(r<<2)|0)>>2]==(0|i)){if(b[t>>2]=n)break n;b[263187]=b[263187]&m(r);break t}if(!(b[s+(b[s+16>>2]==(0|i)?16:20)>>2]=n))break t}if(b[n+24>>2]=s,(t=b[i+16>>2])&&(b[n+16>>2]=t,b[t+24>>2]=n),!(t=b[i+20>>2]))break t;b[n+20>>2]=t,b[t+24>>2]=n}}if(!(o>>>0<=i>>>0)&&1&(n=b[o+4>>2])){t:{if(!(2&n)){if(b[263192]==(0|o)){if(b[263192]=i,e=b[263189]+e|0,b[263189]=e,b[i+4>>2]=1|e,b[263191]!=(0|i))break e;return b[263188]=0,b[263191]=0}if(b[263191]==(0|o))return b[263191]=i,e=b[263188]+e|0,b[263188]=e,b[i+4>>2]=1|e,b[e+i>>2]=e,0;e=(-8&n)+e|0;n:if(n>>>0<=255){if(n=n>>>3|0,(0|(t=b[o+8>>2]))==(0|(r=b[o+12>>2]))){b[263186]=b[263186]&m(n);break n}b[t+12>>2]=r,b[r+8>>2]=t}else{if(s=b[o+24>>2],(0|o)==(0|(n=b[o+12>>2])))if((t=b[(r=o+20|0)>>2])||(t=b[(r=o+16|0)>>2])){for(;a=r,(t=b[(r=(n=t)+20|0)>>2])||(r=n+16|0,t=b[n+16>>2]););b[a>>2]=0}else n=0;else t=b[o+8>>2],b[t+12>>2]=n,b[n+8>>2]=t;if(s){r=b[o+28>>2];i:{if(b[(t=1053048+(r<<2)|0)>>2]==(0|o)){if(b[t>>2]=n)break i;b[263187]=b[263187]&m(r);break n}if(!(b[s+(b[s+16>>2]==(0|o)?16:20)>>2]=n))break n}b[n+24>>2]=s,(t=b[o+16>>2])&&(b[n+16>>2]=t,b[t+24>>2]=n),(t=b[o+20>>2])&&(b[n+20>>2]=t,b[t+24>>2]=n)}}if(b[i+4>>2]=1|e,b[e+i>>2]=e,b[263191]!=(0|i))break t;return b[263188]=e,0}b[o+4>>2]=-2&n,b[i+4>>2]=1|e,b[e+i>>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]=i,b[e+12>>2]=i,b[i+12>>2]=n,b[i+8>>2]=e,0;b[i+16>>2]=0,t=b[i+20>>2]=0,(r=e>>>8|0)&&(t=31,16777215>>0||(t=r,t<<=r=r+1048320>>>16&8,t=28+((t=((t<<=s=t+520192>>>16&4)<<(a=t+245760>>>16&2)>>>15|0)-(a|r|s)|0)<<1|e>>>t+21&1)|0)),a=1053048+((b[(n=i)+28>>2]=t)<<2)|0;t:{n:{if((r=b[263187])&(n=1<>>1|0)|0),n=b[a>>2];;){if((-8&b[(t=n)+4>>2])==(0|e))break n;if(n=r>>>29|0,r<<=1,!(n=b[16+(a=t+(4&n)|0)>>2]))break}b[a+16>>2]=i,b[i+24>>2]=t}else b[263187]=n|r,b[a>>2]=i,b[i+24>>2]=a;b[i+12>>2]=i,b[i+8>>2]=i;break t}e=b[t+8>>2],b[e+12>>2]=i,b[t+8>>2]=i,b[i+24>>2]=0,b[i+12>>2]=t,b[i+8>>2]=e}if(e=b[263194]+-1|0,!(b[263194]=e)){for(i=1053200;i=(e=b[i>>2])+8|0,e;);b[263194]=-1}}}}function L(e,t){var n=0;if(t&&(y[(n=e+t|0)-1|0]=0,!(t>>>(y[0|e]=0)<3||(y[n+-2|0]=0,y[e+1|0]=0,y[n+-3|0]=0,t>>>(y[e+2|0]=0)<7||(y[n+-4|0]=0,t>>>(y[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 C(e){var t,n=0,i=0,r=0,o=0,a=0,s=0,l=0,c=0,u=0,d=0;h=t=h-16|0;e:{t:{n:{i:{r:{o:{a:{s:{l:{c:{u:{if(e>>>0<=244){if(3&(n=(a=b[263186])>>>(e=(s=e>>>0<11?16:e+11&-8)>>>3|0)|0)){e=(n=b[1052792+(o=(i=e+(1&(-1^n))|0)<<3)>>2])+8|0,(0|(r=b[n+8>>2]))!=(0|(o=o+1052784|0))?(b[r+12>>2]=o,b[o+8>>2]=r):b[263186]=m(i)&a,i<<=3,b[n+4>>2]=3|i,b[4+(n=n+i|0)>>2]=1|b[n+4>>2];break e}if(s>>>0<=(c=b[263188])>>>0)break u;if(n){i=n=(e=(0-(e=(0-(i=2<>>12&16,i|=n=(e=e>>>n|0)>>>5&8,i|=n=(e=e>>>n|0)>>>2&4,n=b[1052792+(r=(i=((i|=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|(r=r+1052784|0))?(b[e+12>>2]=r,b[r+8>>2]=e):(a=m(i)&a,b[263186]=a),e=n+8|0,b[n+4>>2]=3|s,o=(i<<=3)-s|0,b[4+(l=n+s|0)>>2]=1|o,b[n+i>>2]=o,c&&(n=1052784+((i=c>>>3|0)<<3)|0,r=b[263191],i=(i=1<>2]:(b[263186]=i|a,n),b[n+8>>2]=r,b[i+12>>2]=r,b[r+12>>2]=n,b[r+8>>2]=i),b[263191]=l,b[263188]=o;break e}if(!(d=b[263187]))break u;for(i=n=(e=(d&0-d)-1|0)>>>12&16,i|=n=(e=e>>>n|0)>>>5&8,i|=n=(e=e>>>n|0)>>>2&4,n=b[1053048+(((i|=n=(e=e>>>n|0)>>>1&2)|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)<<2)>>2],r=(-8&b[n+4>>2])-s|0,i=n;e=(e=b[i+16>>2])||b[i+20>>2];)r=(i=(o=(-8&b[e+4>>2])-s|0)>>>0>>0)?o:r,n=i?e:n,i=e;if(u=b[n+24>>2],(0|(o=b[n+12>>2]))!=(0|n)){e=b[n+8>>2],b[e+12>>2]=o,b[o+8>>2]=e;break t}if(!(e=b[(i=n+20|0)>>2])){if(!(e=b[n+16>>2]))break c;i=n+16|0}for(;l=i,(e=b[(i=(o=e)+20|0)>>2])||(i=o+16|0,e=b[o+16>>2]););b[l>>2]=0;break t}if(s=-1,!(4294967231>>0)&&(s=-8&(n=e+11|0),c=b[263187])){i=0-s|0,(n=n>>>8|(a=0))&&(a=31,16777215>>0||(a=28+((e=((a=(n<<=r=n+1048320>>>16&8)<<(e=n+520192>>>16&4))<<(n=a+245760>>>16&2)>>>15|0)-(n|e|r)|0)<<1|s>>>e+21&1)|0));d:{h:{if(r=b[1053048+(a<<2)>>2])for(n=s<<(31==(0|a)?0:25-(a>>>1|0)|0),e=0;;){if(!(i>>>0<=(l=(-8&b[r+4>>2])-s|0)>>>0||(o=r,i=l))){i=0,e=r;break h}if(l=b[r+20>>2],r=b[16+((n>>>29&4)+r|0)>>2],e=l&&(0|l)!=(0|r)?l:e,n<<=0!=(0|r),!r)break}else e=0;if(!(e|o)){if(!(e=(0-(e=2<>>12&16,r|=n=(e=e>>>n|0)>>>5&8,r|=n=(e=e>>>n|0)>>>2&4,e=b[1053048+(((r|=n=(e=e>>>n|0)>>>1&2)|(n=(e=e>>>n|0)>>>1&1))+(e>>>n|0)<<2)>>2]}if(!e)break d}for(;i=(n=(r=(-8&b[e+4>>2])-s|0)>>>0>>0)?r:i,o=n?e:o,e=(n=b[e+16>>2])||b[e+20>>2];);}if(!(!o|i>>>0>=b[263188]-s>>>0)){if(l=b[o+24>>2],(0|o)!=(0|(n=b[o+12>>2]))){e=b[o+8>>2],b[e+12>>2]=n,b[n+8>>2]=e;break n}if(!(e=b[(r=o+20|0)>>2])){if(!(e=b[o+16>>2]))break l;r=o+16|0}for(;a=r,(e=b[(r=(n=e)+20|0)>>2])||(r=n+16|0,e=b[n+16>>2]););b[a>>2]=0;break n}}}if(s>>>0<=(n=b[263188])>>>0){e=b[263191],16<=(i=n-s|0)>>>0?(b[263188]=i,r=e+s|0,b[263191]=r,b[r+4>>2]=1|i,b[e+n>>2]=i,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<(r=b[263189])>>>0){n=r-s|0,b[263189]=n,i=(e=b[263192])+s|0,b[263192]=i,b[i+4>>2]=1|n,b[e+4>>2]=3|s,e=e+8|0;break e}if((i=(a=(i=o=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])+i|0)>>>0<=c>>>0|n>>>0>>0)break e;if(4&M[1053188])break o;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=f(0))))break a;if(a=i,(r=(e=b[263305])+-1|0)&n&&(a=(i-n|0)+(n+r&0-e)|0),a>>>0<=s>>>0|2147483646>>0)break a;if((e=b[263296])&&(l=(r=b[263294])+a|0)>>>0<=r>>>0|e>>>0>>0)break a;if((0|n)!=(0|(e=f(a))))break u;break r}if(2147483646<(a=l&a-r)>>>0)break a;if((0|(n=f(a)))==(b[e>>2]+b[e+4>>2]|0))break s;e=n}if(!(s+48>>>0<=a>>>0|2147483646>>0|-1==(0|(n=e)))){if(2147483646<(e=(e=b[263306])+(o-a|0)&0-e)>>>0)break r;if(-1!=(0|f(e))){a=e+a|0;break r}f(0-a|0);break a}if(-1!=(0|n))break r;break a}o=0;break t}n=0;break n}if(-1!=(0|n))break r}b[263297]=4|b[263297]}if(2147483646>>0)break i;if(n=f(i),(e=f(0))>>>0<=n>>>0|-1==(0|n)|-1==(0|e))break i;if((a=e-n|0)>>>0<=s+40>>>0)break i}e=b[263294]+a|0,(b[263294]=e)>>>0>w[263295]&&(b[263295]=e);r:{o:{a:{if(i=b[263192]){for(e=1053192;;){if(((r=b[e>>2])+(o=b[e+4>>2])|0)==(0|n))break a;if(!(e=b[e+8>>2]))break}break o}for((e=b[263190])>>>0<=n>>>0&&e||(b[263190]=n),e=0,b[263299]=a,b[263298]=n,b[263194]=-1,b[263195]=b[263304],b[263301]=0;r=1052784+(i=e<<3)|0,b[i+1052792>>2]=r,b[i+1052796>>2]=r,32!=(0|(e=e+1|0)););r=(e=a+-40|0)-(i=n+8&7?-8-n&7:0)|0,b[263189]=r,i=n+i|0,b[263192]=i,b[i+4>>2]=1|r,b[4+(e+n|0)>>2]=40,b[263193]=b[263308];break r}if(!(8&M[e+12|0]|n>>>0<=i>>>0|i>>>0>>0)){b[e+4>>2]=o+a,n=(e=i+8&7?-8-i&7:0)+i|0,b[263192]=n,e=(r=b[263189]+a|0)-e|0,b[263189]=e,b[n+4>>2]=1|e,b[4+(i+r|0)>>2]=40,b[263193]=b[263308];break r}}n>>>0<(o=b[263190])>>>0&&(b[263190]=n,o=0),r=n+a|0,e=1053192;o:{a:{s:{l:{c:{u:{for(;(0|r)!=b[e>>2];)if(!(e=b[e+8>>2]))break u;if(!(8&M[e+12|0]))break c}for(e=1053192;;){if((r=b[e>>2])>>>0<=i>>>0&&i>>>0<(o=r+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]+a,b[4+(u=(n+8&7?-8-n&7:0)+n|0)>>2]=3|s,e=((n=r+(r+8&7?-8-r&7:0)|0)-u|0)-s|0,l=s+u|0,(0|n)==(0|i)){b[263192]=l,e=b[263189]+e|0,b[263189]=e,b[l+4>>2]=1|e;break a}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 a}if(1==(3&(i=b[n+4>>2]))){d=-8&i;c:if(i>>>0<=255){if(o=i>>>3|0,i=b[n+8>>2],(0|(r=b[n+12>>2]))==(0|i)){b[263186]=b[263186]&m(o);break c}b[i+12>>2]=r,b[r+8>>2]=i}else{if(c=b[n+24>>2],(0|(a=b[n+12>>2]))==(0|n))if((s=b[(r=n+20|0)>>2])||(s=b[(r=n+16|0)>>2])){for(;i=r,(s=b[(r=(a=s)+20|0)>>2])||(r=a+16|0,s=b[a+16>>2]););b[i>>2]=0}else a=0;else i=b[n+8>>2],b[i+12>>2]=a,b[a+8>>2]=i;if(c){i=b[n+28>>2];u:{if(b[(r=1053048+(i<<2)|0)>>2]==(0|n)){if(b[r>>2]=a)break u;b[263187]=b[263187]&m(i);break c}if(!(b[c+(b[c+16>>2]==(0|n)?16:20)>>2]=a))break c}b[a+24>>2]=c,(i=b[n+16>>2])&&(b[a+16>>2]=i,b[i+24>>2]=a),(i=b[n+20>>2])&&(b[a+20>>2]=i,b[i+24>>2]=a)}}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=(i=b[263186])&(n=1<>2]:(b[263186]=n|i,e),b[e+8>>2]=l,b[n+12>>2]=l,b[l+12>>2]=e,b[l+8>>2]=n;break a}if((r=e>>>8|(n=0))&&(n=31,16777215>>0||(n=28+((n=((s=(r<<=o=r+1048320>>>16&8)<<(n=r+520192>>>16&4))<<(r=s+245760>>>16&2)>>>15|0)-(r|n|o)|0)<<1|e>>>n+21&1)|0)),b[(i=l)+28>>2]=n,b[l+16>>2]=0,i=1053048+(n<<2)|(b[l+20>>2]=0),(r=b[263187])&(o=1<>>1|0)|0),n=b[i>>2];;){if((-8&b[(i=n)+4>>2])==(0|e))break s;if(n=r>>>29|0,r<<=1,!(n=b[16+(o=(4&n)+i|0)>>2]))break}b[o+16>>2]=l}else b[263187]=r|o,b[i>>2]=l;b[l+24>>2]=i,b[l+12>>2]=l,b[l+8>>2]=l;break a}for(l=(e=a+-40|0)-(r=n+8&7?-8-n&7:0)|0,b[263189]=l,r=n+r|0,b[263192]=r,b[r+4>>2]=1|l,b[4+(e+n|0)>>2]=40,b[263193]=b[263308],b[(r=(e=(o+(o+-39&7?39-o&7:0)|0)-47|0)>>>0>>0?i:e)+4>>2]=27,e=b[263301],b[r+16>>2]=b[263300],b[r+20>>2]=e,e=b[263299],b[r+8>>2]=b[263298],b[r+12>>2]=e,b[263300]=r+8,b[263299]=a,b[263298]=n,e=r+24|(b[263301]=0);b[e+4>>2]=7,n=e+8|0,e=e+4|0,n>>>0>>0;);if((0|i)==(0|r))break r;if(b[r+4>>2]=-2&b[r+4>>2],o=r-i|0,b[i+4>>2]=1|o,(b[r>>2]=o)>>>0<=255){e=1052784+((n=o>>>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;break r}if(b[i+16>>2]=0,e=b[i+20>>2]=0,(r=o>>>8|0)&&(e=31,16777215>>0||(e=28+((e=((l=(r<<=a=r+1048320>>>16&8)<<(e=r+520192>>>16&4))<<(r=l+245760>>>16&2)>>>15|0)-(r|e|a)|0)<<1|o>>>e+21&1)|0)),n=1053048+((b[(n=i)+28>>2]=e)<<2)|0,(r=b[263187])&(a=1<>>1|0)|0),n=b[n>>2];;){if((0|o)==(-8&b[(r=n)+4>>2]))break o;if(n=e>>>29|0,e<<=1,!(n=b[16+(a=r+(4&n)|0)>>2]))break}b[a+16>>2]=i,b[i+24>>2]=r}else b[263187]=r|a,b[n>>2]=i,b[i+24>>2]=n;b[i+12>>2]=i,b[i+8>>2]=i;break r}e=b[i+8>>2],b[e+12>>2]=l,b[i+8>>2]=l,b[l+24>>2]=0,b[l+12>>2]=i,b[l+8>>2]=e}e=u+8|0;break e}e=b[r+8>>2],b[e+12>>2]=i,b[r+8>>2]=i,b[i+24>>2]=0,b[i+12>>2]=r,b[i+8>>2]=e}if(!((e=b[263189])>>>0<=s>>>0)){n=e-s|0,b[263189]=n,i=(e=b[263192])+s|0,b[263192]=i,b[i+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[o+28>>2];i:{if(b[(r=1053048+(e<<2)|0)>>2]==(0|o)){if(b[r>>2]=n)break i;c=m(e)&c,b[263187]=c;break n}if(!(b[l+(b[l+16>>2]==(0|o)?16:20)>>2]=n))break n}b[n+24>>2]=l,(e=b[o+16>>2])&&(b[n+16>>2]=e,b[e+24>>2]=n),(e=b[o+20>>2])&&(b[n+20>>2]=e,b[e+24>>2]=n)}n:if(i>>>0<=15)e=i+s|0,b[o+4>>2]=3|e,b[4+(e=e+o|0)>>2]=1|b[e+4>>2];else if(b[o+4>>2]=3|s,b[4+(r=o+s|0)>>2]=1|i,(b[i+r>>2]=i)>>>0<=255)e=1052784+((n=i>>>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;else{(s=i>>>8|(e=0))&&(e=31,16777215>>0||(e=28+((e=((l=(s<<=a=s+1048320>>>16&8)<<(e=s+520192>>>16&4))<<(s=l+245760>>>16&2)>>>15|0)-(s|e|a)|0)<<1|i>>>e+21&1)|0)),b[(n=r)+28>>2]=e,b[r+16>>2]=0,n=1053048+(e<<2)|(b[r+20>>2]=0);i:{if((s=1<>>1|0)|0),s=b[n>>2];;){if((-8&b[(n=s)+4>>2])==(0|i))break i;if(s=e>>>29|0,e<<=1,!(s=b[16+(a=(4&s)+n|0)>>2]))break}b[a+16>>2]=r}else b[263187]=s|c,b[n>>2]=r;b[r+24>>2]=n,b[r+12>>2]=r,b[r+8>>2]=r;break n}e=b[n+8>>2],b[e+12>>2]=r,b[n+8>>2]=r,b[r+24>>2]=0,b[r+12>>2]=n,b[r+8>>2]=e}e=o+8|0;break e}t:if(u){e=b[n+28>>2];n:{if(b[(i=1053048+(e<<2)|0)>>2]==(0|n)){if(b[i>>2]=o)break n;b[263187]=m(e)&d;break t}if(!(b[u+(b[u+16>>2]==(0|n)?16:20)>>2]=o))break t}b[o+24>>2]=u,(e=b[n+16>>2])&&(b[o+16>>2]=e,b[e+24>>2]=o),(e=b[n+20>>2])&&(b[o+20>>2]=e,b[e+24>>2]=o)}r>>>0<=15?(e=r+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|r,b[r+s>>2]=r,c&&(e=1052784+((i=c>>>3|0)<<3)|0,o=b[263191],i=(i=1<>2]:(b[263186]=i|a,e),b[e+8>>2]=o,b[i+12>>2]=o,b[o+12>>2]=e,b[o+8>>2]=i),b[263191]=s,b[263188]=r),e=n+8|0}return h=16+t|0,e}function p(e){var t=0,n=0,i=0,r=0,o=0,a=0,s=0,l=0,c=0,u=0,d=0,h=0,f=0,p=0,m=0,v=0;if(!((n=b[e+40>>2])>>>0<=(c=b[e+32>>2])>>>0)&&(t=b[e+104>>2])&&(o=b[e+84>>2],!(w[e+36>>2]<=o>>>0|w[e+48>>2]<=o>>>0))){if(a=(n=n-c|0)>>>0>>0?n:t,b[e+104>>2]=t-a,t=(-1^o)+c|0,t=c>>>0<=o>>>0?b[e+44>>2]+t|0:t,o=b[e+24>>2],n=M[t+o|0],b[e+32>>2]=c+1,y[o+c|0]=n,i=a+-1|0)for(;t=(0|(n=t+1|0))==b[e+44>>2]?0:n,a=b[e+24>>2],o=M[t+a|0],n=b[e+32>>2],b[e+32>>2]=n+1,y[n+a|0]=o,i=i+-1|0;);c=b[e+32>>2],w[e+36>>2]>=c>>>0||(b[e+36>>2]=c)}e:{t:if(!(c>>>0>=w[e+40>>2]))for(f=e+1756|0,p=e+2784|0,m=e+84|0;;){if((o=b[e+16>>2])>>>0>w[e+20>>2])break t;a=u=(((d=b[e+100>>2])<<5)+e|0)+((s=b[e+116>>2]&c)<<1)|0,16777216<=(r=b[e>>2])>>>0?i=b[e+4>>2]:(r<<=8,b[e>>2]=r,n=o+1|0,b[e+16>>2]=n,i=M[b[e+12>>2]+o|0]|b[e+4>>2]<<8,b[e+4>>2]=i,o=n),n=_[a+120>>1];n:if(i>>>0<(t=x(n,r>>>11|0))>>>0){b[e>>2]=t,g[a+120>>1]=n+(2048-n>>>5|0),r=c+-1|0,r=c?r:b[e+44>>2]+r|0,s=b[e+108>>2],n=(b[e+112>>2]&c)<>2])&&(u=M[b[e+24>>2]+r|0]),h=n+(u>>>8-s|0)|0,r=1;i:{if(d>>>0<=6)for(;;)if(a=3812+((r<<=1)+(x(h,1536)+e|0)|0)|0,16777215>>0?n=t:(n=t<<8,b[e>>2]=n,t=o+1|0,b[e+16>>2]=t,i=M[b[e+12>>2]+o|0]|i<<8,b[e+4>>2]=i,o=t),s=_[a>>1],(t=x(s,n>>>11|0))>>>0<=i>>>0?(i=i-t|0,b[e+4>>2]=i,t=n-t|0,b[e>>2]=t,g[a>>1]=s-(s>>>5|0),r|=1):(b[e>>2]=t,g[a>>1]=s+(2048-s>>>5|0)),!(r>>>0<256))break i;for(r=(-1^(n=b[e+84>>2]))+c|0,r=c>>>0<=n>>>0?b[e+44>>2]+r|0:r,a=a?M[b[e+24>>2]+r|0]:0,r=1,l=256;d=l&(a<<=1),s=3812+((x(h,1536)+e|0)+((d+l|0)+r<<1)|0)|0,16777215>>0?u=t:(u=t<<8,b[e>>2]=u,n=o+1|0,b[e+16>>2]=n,i=M[b[e+12>>2]+o|0]|i<<8,b[e+4>>2]=i,o=n),s=_[(v=n=s)>>1],n=(t=x(s,u>>>11|0))>>>0<=i>>>0?(i=i-t|0,b[e+4>>2]=i,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,(r=r<<1|u)>>>0<256;);}if(b[e+32>>2]=c+1,y[b[e+24>>2]+c|0]=r,c=b[e+32>>2],w[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{i=i-t|0,b[e+4>>2]=i,t=r-t|0,b[e>>2]=t,g[a+120>>1]=n-(n>>>5|0),a=h=(d<<1)+e|0,16777215>>0?n=o:(t<<=8,b[e>>2]=t,n=o+1|0,b[e+16>>2]=n,i=M[b[e+12>>2]+o|0]|i<<8,b[e+4>>2]=i),d=_[a+504>>1];i:if((o=x(d,t>>>11|0))>>>0<=i>>>0){i=i-o|0,b[e+4>>2]=i,t=t-o|0,b[e>>2]=t,g[a+504>>1]=d-(d>>>5|0),16777215>>0?a=n:(t<<=8,b[e>>2]=t,a=n+1|0,b[e+16>>2]=a,i=M[b[e+12>>2]+n|0]|i<<8,b[e+4>>2]=i),n=_[h+528>>1];r:{if(i>>>0<(r=x(n,t>>>11|0))>>>0){if(b[e>>2]=r,g[h+528>>1]=n+(2048-n>>>5|0),r>>>0<=16777215&&(r<<=8,b[e>>2]=r,b[e+16>>2]=a+1,i=M[b[e+12>>2]+a|0]|i<<8,b[e+4>>2]=i),t=_[u+600>>1],(n=x(t,r>>>11|0))>>>0<=i>>>0){b[e+4>>2]=i-n,b[e>>2]=r-n,g[u+600>>1]=t-(t>>>5|0);break r}b[e>>2]=n,g[u+600>>1]=t+(2048-t>>>5|0),b[e+104>>2]=1,b[e+100>>2]=w[e+100>>2]<7?9:11;break i}i=i-r|0,b[e+4>>2]=i,t=t-r|0,b[e>>2]=t,g[h+528>>1]=n-(n>>>5|0),16777215>>0?n=a:(t<<=8,b[e>>2]=t,n=a+1|0,b[e+16>>2]=n,i=M[b[e+12>>2]+a|0]|i<<8,b[e+4>>2]=i),a=_[h+552>>1],i>>>0<(o=x(a,t>>>11|0))>>>0?(b[e>>2]=o,g[h+552>>1]=a+(2048-a>>>5|0),t=b[e+88>>2]):(i=i-o|0,b[e+4>>2]=i,t=t-o|0,b[e>>2]=t,g[h+552>>1]=a-(a>>>5|0),t>>>0<=16777215&&(t<<=8,b[e>>2]=t,b[e+16>>2]=n+1,i=M[b[e+12>>2]+n|0]|i<<8,b[e+4>>2]=i),o=_[h+576>>1],i>>>0<(n=x(o,t>>>11|0))>>>0?(b[e>>2]=n,g[h+576>>1]=o+(2048-o>>>5|0),t=b[e+92>>2]):(b[e+4>>2]=i-n,b[e>>2]=t-n,g[h+576>>1]=o-(o>>>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]=w[e+100>>2]<7?8:11,R(e,p,s)}else{for(b[e>>2]=o,g[a+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]=w[e+100>>2]<7?7:10,R(e,f,s),o=(n=b[e+104>>2])>>>0<6?n+-2|0:3,t=b[e>>2],i=1;a=(i<<=1)+((o<<7)+e|0)|0,16777216<=t>>>0?r=b[e+4>>2]:(t<<=8,b[e>>2]=t,n=b[e+16>>2],b[e+16>>2]=n+1,r=M[n+b[e+12>>2]|0]|b[e+4>>2]<<8,b[e+4>>2]=r),s=_[a+984>>1],(n=x(s,t>>>11|0))>>>0<=r>>>0?(r=r-n|0,b[e+4>>2]=r,t=t-n|0,b[e>>2]=t,g[a+984>>1]=s-(s>>>5|0),i|=1):(b[e>>2]=n,g[a+984>>1]=s+(2048-s>>>5|0),t=n),i>>>0<64;);if((o=i+-64|0)>>>0<=3)b[e+84>>2]=o;else if(l=1&o|2,b[e+84>>2]=l,n=o>>>1|0,o>>>0<=13)for(u=l<<(a=n+-1|0),o=1538+((((b[e+84>>2]=u)<<(l=1))+m|0)+(0-i<<1)|0)|0,i=0;s=o+(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,r=M[t+b[e+12>>2]|0]|r<<8,b[e+4>>2]=r),d=_[s>>1],r>>>0<(t=x(d,n>>>11|0))>>>0?(b[e>>2]=t,g[s>>1]=d+(2048-d>>>5|0)):(r=r-t|0,b[e+4>>2]=r,t=n-t|0,b[e>>2]=t,g[s>>1]=d-(d>>>5|0),u=(1<>2]=u,l|=1),(i=i+1|0)>>>0>>0;);else{for(o=n+-5|0;16777215>>0?i=t:(i=t<<8,b[e>>2]=i,n=b[e+16>>2],b[e+16>>2]=n+1,r=M[n+b[e+12>>2]|0]|r<<8,b[e+4>>2]=r),t=i>>>1|0,l=(n=(a=r-(b[e>>2]=t)|0)>>31)+(l<<1|1)|0,b[e+84>>2]=l,r=a+(t&n)|0,b[e+4>>2]=r,o=o+-1|0;);l<<=4,b[e+84>>2]=l,i>>>0<=33554431&&(t<<=8,b[e>>2]=t,n=b[e+16>>2],b[e+16>>2]=n+1,r=M[n+b[e+12>>2]|0]|r<<8,b[e+4>>2]=r),o=_[(n=e)+1726>>1],a=1724+(n+(o=(t=r>>>0<(i=x(o,t>>>11|0))>>>0?(b[e>>2]=i,g[e+1726>>1]=o+(2048-o>>>5|0),2):(r=r-i|0,b[e+4>>2]=r,i=t-i|0,b[e>>2]=i,l|=1,b[e+84>>2]=l,g[e+1726>>1]=o-(o>>>5|0),3))<<1)|0)|0,i>>>0<=16777215&&(i<<=8,b[e>>2]=i,n=b[e+16>>2],b[e+16>>2]=n+1,r=M[n+b[e+12>>2]|0]|r<<8,b[e+4>>2]=r),n=_[a>>1],(t=x(n,i>>>11|0))>>>0<=r>>>0?(r=r-t|0,b[e+4>>2]=r,t=i-t|0,b[e>>2]=t,g[a>>1]=n-(n>>>5|0),l=l+2|0,b[e+84>>2]=l,o|=1):(b[e>>2]=t,g[a>>1]=n+(2048-n>>>5|0)),a=1724+((o<<=1)+e|0)|0,t>>>0<=16777215&&(t<<=8,b[e>>2]=t,n=b[e+16>>2],b[e+16>>2]=n+1,r=M[n+b[e+12>>2]|0]|r<<8,b[e+4>>2]=r),n=_[a>>1],(i=x(n,t>>>11|0))>>>0<=r>>>0?(r=r-i|0,b[e+4>>2]=r,i=t-i|0,b[e>>2]=i,g[a>>1]=n-(n>>>5|0),l=l+4|0,b[e+84>>2]=l,o|=1):(b[e>>2]=i,g[a>>1]=n+(2048-n>>>5|0)),i>>>0<=16777215&&(i<<=8,b[e>>2]=i,n=b[e+16>>2],b[e+16>>2]=n+1,r=M[n+b[e+12>>2]|0]|r<<8,b[e+4>>2]=r),o=_[(n=1724+((o<<1)+e|0)|0)>>1],(t=x(o,i>>>11|0))>>>0<=r>>>0?(b[e+4>>2]=r-t,b[e>>2]=i-t,g[n>>1]=o-(o>>>5|0),b[e+84>>2]=l+8):(b[e>>2]=t,g[n>>1]=o+(2048-o>>>5|0))}}if(t=0,o=b[e+84>>2],w[e+36>>2]<=o>>>0|w[e+48>>2]<=o>>>0)break e;if(s=b[e+32>>2],a=(n=b[e+40>>2]-s|0)>>>0<(t=b[e+104>>2])>>>0?n:t,b[e+104>>2]=t-a,t=s+(-1^o)|0,t=s>>>0<=o>>>0?b[e+44>>2]+t|0:t,o=b[e+24>>2],n=M[t+o|0],b[e+32>>2]=s+1,y[o+s|0]=n,r=a+-1|0)for(;t=(0|(n=t+1|0))==b[e+44>>2]?0:n,a=b[e+24>>2],o=M[t+a|0],n=b[e+32>>2],b[e+32>>2]=n+1,y[n+a|0]=o,r=r+-1|0;);c=b[e+32>>2],w[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]=M[n+b[e+12>>2]|0]|b[e+4>>2]<<8)}return t}function P(e,t,n){var i=0,r=0,o=0;e:if(n){for(;(0|(i=M[0|e]))==(0|(r=M[0|t]));)if(t=t+1|0,e=e+1|0,!(n=n+-1|0))break e;o=i-r|0}return o}function R(e,t,n){var i=0,r=0,o=0,a=0,s=0,l=0,c=0;for(16777216<=(a=b[e>>2])>>>0?o=b[e+4>>2]:(a<<=8,b[e>>2]=a,r=b[e+16>>2],b[e+16>>2]=r+1,o=M[r+b[e+12>>2]|0]|b[e+4>>2]<<8,b[e+4>>2]=o),r=_[t>>1],r=o>>>0<(i=x(r,a>>>11|0))>>>0?(b[e>>2]=i,g[t>>1]=r+(2048-r>>>5|0),c=4+((n<<4)+t|0)|0,l=2,8):(o=o-i|0,b[e+4>>2]=o,a=a-i|0,b[e>>2]=a,g[t>>1]=r-(r>>>5|0),a>>>0<=16777215&&(a<<=8,b[e>>2]=a,r=b[e+16>>2],b[e+16>>2]=r+1,o=M[r+b[e+12>>2]|0]|o<<8,b[e+4>>2]=o),r=_[t+2>>1],o>>>0<(i=x(r,a>>>11|0))>>>0?(b[e>>2]=i,g[t+2>>1]=r+(2048-r>>>5|0),c=260+((n<<4)+t|0)|0,l=10,8):(o=o-i|0,b[e+4>>2]=o,i=a-i|0,b[e>>2]=i,g[t+2>>1]=r-(r>>>5|0),c=t+516|0,l=18,256)),b[e+104>>2]=l,t=1;a=c+(t<<=1)|0,16777215>>0?n=i:(n=i<<8,b[e>>2]=n,i=b[e+16>>2],b[e+16>>2]=i+1,o=M[i+b[e+12>>2]|0]|o<<8,b[e+4>>2]=o),s=_[a>>1],(i=x(s,n>>>11|0))>>>0<=o>>>0?(o=o-i|0,b[e+4>>2]=o,i=n-i|0,b[e>>2]=i,g[a>>1]=s-(s>>>5|0),t|=1):(b[e>>2]=i,g[a>>1]=(2048-s>>>5|0)+s),t>>>0>>0;);b[e+104>>2]=(t-r|0)+l}function O(e){for(var t=0,n=0,i=0,r=0,o=0,a=0,s=0,l=0,c=0,u=e+28392|0,d=e+28388|0;;){t=b[e+64>>2];e:{t:{n:{i:{r:{o:{a:{s:{l:{c:{u:{d:{h:{f:{p:{if(n=b[132105],(i=b[132106])>>>0<=n>>>0){if(7==(0|t))break p;return 0}if(8>>0)continue;switch(t-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 p;case 7:break o;case 5:break s;default:break f}}t=b[e+76>>2];break a}if(o=1,b[132105]=n+1,!(t=M[b[132104]+n|0]))break r;if(!(1!=(0|t)&&t>>>0<=223)){g[e+80>>1]=256,b[e+60>>2]||(i=b[132108],b[e+24>>2]=i+b[132107],b[e+44>>2]=b[132109]-i),b[e+28>>2]=0,b[e+32>>2]=0,b[e+36>>2]=0,b[e+40>>2]=0;break n}if(!M[e+80|0])break n;return 7}b[132105]=n+1,t=M[b[132104]+n|0],b[e+64>>2]=2,b[e+72>>2]=b[e+72>>2]+(t<<8);continue}b[132105]=n+1,t=M[b[132104]+n|0],b[e+64>>2]=3,b[e+72>>2]=1+(t+b[e+72>>2]|0);continue}b[132105]=n+1,t=M[b[132104]+n|0],b[e+64>>2]=4,b[e+76>>2]=t<<8;continue}b[132105]=n+1,t=M[b[132104]+n|0],b[e+64>>2]=b[e+68>>2],b[e+76>>2]=1+(t+b[e+76>>2]|0);continue}if(b[132105]=n+1,o=7,224<(t=M[b[132104]+n|0])>>>0)break r;if(i=e,r=t>>>(n=0)<45?0:(t=(t=t+-45|0)-x(r=((255&t)>>>0)/45|0,45)|0,r+1|0),b[i+116>>2]=-1<>>0&&(n=1+(i=((255&(t=t+-9|0))>>>0)/9|0)|0,t=t-x(i,9)|0),b[e+112>>2]=n,t&=255,4<(b[e+108>>2]=t)+n>>>0)break r;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+((t<<1)+e|0)>>1]=1024,14134!=(0|(t=t+1|0)););b[e+64>>2]=6,b[e+8>>2]=5,b[e>>2]=-1,b[e+4>>2]=0}if((o=b[e+76>>2])>>>0<5)return 7;if(n=b[e+8>>2])for(t=b[132105],r=b[132106];;){if((0|t)==(0|r))return 0;if(a=b[e+4>>2],i=t+1|0,b[132105]=i,t=M[b[132104]+t|0],n=n+-1|0,b[e+8>>2]=n,b[e+4>>2]=t|a<<8,t=i,!n)break}b[e+64>>2]=7,t=o+-5|0,b[e+76>>2]=t}i=b[e+32>>2],n=(n=b[132109]-b[132108]|0)>>>0<(o=b[e+72>>2])>>>0?n:o,o=b[e+44>>2],b[e+40>>2]=n>>>0>>0?i+n|0:o,n=(r=b[132106])-(i=b[132105])|0,o=b[e+28388>>2];a:{if(!t||o){if(A(4+(o+d|0)|0,r=b[132104]+i|0,t=n>>>0<(t=(t=t-o|0)>>>0<(i=42-o|0)>>>0?t:i)>>>0?n:t),(0|(i=(n=b[e+28388>>2])+t|0))!=b[e+76>>2]){if(i>>>0<=20){b[e+28388>>2]=i,b[132105]=t+b[132105];break a}i=i+-21|0}else L(4+(t+(n+d|0)|0)|0,63-i|0),i=t+b[e+28388>>2]|0;if(b[e+16>>2]=0,b[e+12>>2]=u,b[e+20>>2]=i,o=7,!p(e))break r;if(i=b[e+16>>2],(n=b[e+28388>>2])+t>>>0>>0)break r;if(t=b[e+76>>2]-i|0,b[e+76>>2]=t,i>>>0>>0){t=n-i|0,function(e,t,n){var i=0,r=0;s:if((0|e)!=(0|t)){if(!(e>>>0>>0&&t>>>0<(r=e+n|0)>>>0))return A(e,t,n);if(i=3&(e^t),e>>>0>>0){if(!i){if(3&e)for(;;){if(!n)break s;if(y[0|e]=M[0|t],t=t+1|0,n=n+-1|0,!(3&(e=e+1|0)))break}if(!(n>>>0<=3)){for(i=n;b[e>>2]=b[t>>2],t=t+4|0,e=e+4|0,3<(i=i+-4|0)>>>0;);n&=3}}if(n)for(;y[0|e]=M[0|t],e=e+1|0,t=t+1|0,n=n+-1|0;);}else{if(!i){if(3&r)for(;;){if(!n)break s;if(y[0|(i=(n=n+-1|0)+e|0)]=M[t+n|0],!(3&i))break}if(!(n>>>0<=3))for(;b[(n=n+-4|0)+e>>2]=b[t+n>>2],3>>0;);}if(!n)break s;for(;y[(n=n+-1|0)+e|0]=M[t+n|0],n;);}}}(u,4+(i+d|0)|0,b[e+28388>>2]=t);break a}i=b[132105]+(i-n|0)|0,b[132105]=i,b[e+28388>>2]=0,n=(r=b[132106])-i|0}if(21<=n>>>0){if(o=b[132104],b[e+16>>2]=i,b[e+12>>2]=o,b[e+20>>2]=n>>>0>>0?r+-21|0:t+i|0,o=7,!p(e))break r;if((t=b[e+76>>2])>>>0<(n=(i=b[e+16>>2])-b[132105]|0)>>>0)break r;if(t=t-n|0,b[e+76>>2]=t,b[132105]=i,20<(n=b[132106]-i|0)>>>0)break a}t=t>>>0>>0?t:n,A(u,b[132104]+i|0,t),b[e+28388>>2]=t,b[132105]=t+b[132105]}if(n=(t=b[e+32>>2])-(o=b[e+28>>2])|0,b[(i=e)+60>>2]&&((0|t)==b[e+44>>2]&&(b[e+32>>2]=0),A(b[132107]+b[132108]|0,o+b[e+24>>2]|0,n),t=b[e+32>>2]),b[i+28>>2]=t,t=n+b[132108]|0,b[132108]=t,i=b[e+72>>2]-n|0,!(b[e+72>>2]=i)){if(o=7,b[e+4>>2]|(b[e+76>>2]|b[e+104>>2]))break r;b[e+64>>2]=0;break t}if(((o=0)|t)==b[132109])break r;if(b[132105]!=b[132106]|w[e+28388>>2]>=w[e+76>>2])continue;break r}if(!(r=b[e+76>>2]))break i;if(!(i>>>(o=0)<=n>>>0))for(;;){if((t=b[132109])>>>0<=(a=b[132108])>>>0)break r;if(c=r,s=b[e+32>>2],r=r>>>0<(t=(l=b[e+44>>2]-s|0)>>>0<(t=(i=i-n|0)>>>0<(t=t-a|0)>>>0?i:t)>>>0?l:t)>>>0?r:t,b[e+76>>2]=c-r,A(b[e+24>>2]+s|0,b[132104]+n|0,r),t=r+b[e+32>>2]|0,b[e+32>>2]=t,w[e+36>>2]>>0&&(b[e+36>>2]=t),b[(i=e)+60>>2]&&((0|t)==b[e+44>>2]&&(b[e+32>>2]=0),A(b[132107]+b[132108]|0,b[132104]+b[132105]|0,r),t=b[e+32>>2]),b[i+28>>2]=t,b[132108]=r+b[132108],n=r+b[132105]|0,b[132105]=n,!(r=b[e+76>>2]))break i;if(!(n>>>0<(i=b[132106])>>>0))break}}return o}b[e+64>>2]=0;continue}if(-1>24)break e;if(b[e+64>>2]=1,b[e+72>>2]=t<<16&2031616,192<=t>>>0){b[e+68>>2]=5,y[e+81|0]=0;continue}if(M[e+81|0])return 7;if(b[e+68>>2]=6,t>>>0<160)continue;for(b[e+84>>2]=0,t=b[e+88>>2]=0,b[e+100>>2]=0,b[e+92>>2]=0,b[e+96>>2]=0;g[120+((t<<1)+e|0)>>1]=1024,14134!=(0|(t=t+1|0)););}b[e+8>>2]=5,b[e>>2]=-1,b[e+4>>2]=0;continue}if(!(t>>>0<=2))break;b[e+64>>2]=3,b[e+68>>2]=8}return 7}function s(){var e,t,n=0;if(e=C(1208)){if(b[e+36>>2]=2,n=(t=C(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 y[e+40|0]=0,b[e>>2]=0,b[e+4>>2]=0,b[e+24>>2]=0,L(e+72|(b[e+28>>2]=0),100),b[e+172>>2]=12,e;E(e)}return 0}function l(e){var t,n,i=0,r=0,o=0,a=0,s=0,l=0,c=0,u=0,d=0,h=0,f=0,p=0,m=0,v=0,g=0,r=b[e+36>>2]?b[e>>2]:(y[e+40|0]=0,b[e>>2]=0,b[e+4>>2]=0,b[e+24>>2]=0,L(e+72|(b[e+28>>2]=0),100),b[e+172>>2]=12,0),_=b[132108],x=b[132105];b[e+16>>2]=x,t=e+96|0,p=(i=e)+182|0,n=i+176|0,c=i+168|0;e:{t:{n:{i:{r:{for(;;)if(!(9>>0)){e=c;o:{a:{s:{l:{c:{u:switch(r-1|0){case 1:l=b[132106],r=b[132104],a=b[i+172>>2],o=b[i+168>>2];break c;default:if(o=b[132105],r=b[132106]-o|0,s=b[i+168>>2],r=r>>>0<(l=b[i+172>>2]-s|0)>>>0?r:l,A(8+(s+c|0)|0,o+b[132104]|0,r),b[132105]=r+b[132105],a=0,r=r+b[i+168>>2]|0,o=b[i+172>>2],b[i+168>>2]=(0|o)==(0|r)?0:r,(0|r)!=(0|o))break e;if(b[i>>2]=1,P(n,1024,6)){a=5;break e}if((0|T(p,2,0))!=(M[i+184|0]|M[i+185|0]<<8|(M[i+186|0]<<16|M[i+187|0]<<24))){a=7;break e}if(a=6,M[0|p])break e;if(r=M[i+183|0],15<(b[i+32>>2]=r)>>>0)break e;if(a=2,!(1<>>0)break e;break;case 4:break a;case 3:break s;case 2:break l;case 0:break u;case 8:break n;case 7:break i;case 6:break r;case 5:break o}if((0|(l=b[132106]))==(0|(o=b[132105]))){a=0;break e}if(r=b[132104],!(s=M[o+r|0])){b[132105]=o+1,b[i+16>>2]=o,r=6,b[i>>2]=6;continue}b[i+168>>2]=0,a=4+(s<<(b[i>>2]=2))|0,b[i+172>>2]=a,b[i+64>>2]=a,o=0}if(s=l,A(8+(e+o|0)|0,r+(l=b[132105])|0,s=(s=s-l|0)>>>0<(a=a-o|0)>>>0?s:a),b[132105]=s+b[132105],a=0,e=s+b[i+168>>2]|0,r=b[i+172>>2],b[i+168>>2]=(0|r)==(0|e)?0:e,(0|e)!=(0|r))break e;if(e=e+-4|0,r=T(n,b[i+172>>2]=e,0),d=b[i+172>>2],(0|r)!=(M[176+(e=d+i|0)|0]|M[e+177|0]<<8|(M[e+178|0]<<16|M[e+179|0]<<24))){a=7;break e}if(b[i+168>>2]=2,63&(m=y[i+177|0])){a=6;break e}if(r=2,s=o=v=u=-1,64&m){for((l=b[i+4>>2])||(b[i+8>>2]=0,b[i+12>>2]=0);;){if(d>>>0<=r>>>0){a=7;break e}h=M[8+(r+c|0)|0],r=r+1|0,b[i+168>>2]=r,g=b[(e=i)+12>>2],f=127&h,a=31&(o=l),o=32<=(63&o)>>>0?(s=f<>>32-a,f<>2],s=a=s|g,b[e+8>>2]=o,b[e+12>>2]=s;c:{if(!(128&h)){if(h|!l)break c;a=7;break e}if(l=l+(a=7)|0,63!=(0|(b[i+4>>2]=l)))continue;break e}break}b[i+4>>2]=0}if(b[i+48>>2]=o,b[i+52>>2]=s,(0|m)<=-1){for((l=b[i+4>>2])||(b[i+8>>2]=0,b[i+12>>2]=0);;){if(d>>>0<=r>>>0){a=7;break e}h=M[8+(r+c|0)|0],r=r+1|0,b[i+168>>2]=r,f=b[(e=i)+12>>2],u=127&h,a=31&(o=l),u=(o=32<=(63&o)>>>0?(s=u<>>32-a,u<>2],v=o=s|f,b[e+8>>2]=u,b[e+12>>2]=o;c:{if(!(128&h)){if(h|!l)break c;a=7;break e}if(l=l+(a=7)|0,63!=(0|(b[i+4>>2]=l)))continue;break e}break}b[i+4>>2]=0}if(b[i+56>>2]=u,b[i+60>>2]=v,d-r>>>0<2){a=7;break e}if(o=r+1|0,b[i+168>>2]=o,33!=M[8+(r+c|0)|0]){a=6;break e}if(e=r+2|0,b[i+168>>2]=e,1!=M[8+(o+c|0)|0]){a=6;break e}if(a=7,(0|e)==(0|d))break e;if(b[i+168>>2]=r+3,a=function(e,t){var n=0,i=0;n=6;c:if(!(39>>0)){if(t=(1&t|2)<<11+(t>>>1|0),b[e+48>>2]=t,i=b[e+60>>2]){if(n=4,t>>>0>w[e+52>>2])break c;if(b[e+44>>2]=t,!(2!=(0|i)|w[e+56>>2]>=t>>>0||(E(b[e+24>>2]),t=C(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,y[e+80|0]=1,b[e+104>>2]=0,n=0}return n}(b[i+1200>>2],M[8+(e+c|0)|0]))break e;r=b[i+168>>2],o=b[i+172>>2];c:{for(;;){if(o>>>0<=r>>>0)break c;if(e=r+1|0,s=r+c|0,r=b[i+168>>2]=e,M[s+8|0])break}a=6;break e}b[i+168>>2]=0,b[i+80>>2]=0,b[i+84>>2]=0,b[i+72>>2]=0,b[i+76>>2]=0,b[i>>2]=3}if(b[i+16>>2]=b[132105],b[i+20>>2]=b[132108],a=O(b[i+1200>>2]),e=b[(r=i)+76>>2],(s=(o=b[132105]-b[i+16>>2]|0)+b[i+72>>2]|0)>>>0>>0&&(e=e+1|0),l=s,o=e,b[r+72>>2]=s,b[r+76>>2]=e,e=b[i+84>>2],d=b[i+20>>2],(h=(s=u=b[132108]-d|0)+b[i+80>>2]|0)>>>0>>0&&(e=e+1|0),s=e,b[r+80>>2]=h,b[r+84>>2]=e,(0|(e=b[i+52>>2]))==(0|o)&l>>>0>w[i+48>>2]|e>>>0>>0){a=7;break e}if((0|(e=b[i+60>>2]))==(0|s)&h>>>0>w[i+56>>2]|e>>>0>>0){a=7;break e}l:if(!(3<(r=b[i+32>>2]+-1|0)>>>0)){e=i;c:{u:switch(r-1|0){default:r=T(d+b[132107]|0,u,b[i+24>>2]),o=0;break c;case 0:case 1:break l;case 2:}r=function(e,t,n,i){var r=0;if(n^=-1,i^=-1,t)for(;r=2080+((M[0|e]^255&n)<<3)|0,n=b[r>>2]^((255&i)<<24|n>>>8),i=b[r+4>>2]^i>>>8,e=e+1|0,t=t+-1|0;);return S=-1^i,-1^n}(d+b[132107]|0,u,b[i+24>>2],b[i+28>>2]),o=S}b[e+24>>2]=r,b[e+28>>2]=o}if(1!=(0|a))break e;if(r=e=b[i+52>>2],!(-1==(0|(o=b[i+48>>2]))&-1==(0|r)|b[i+72>>2]==(0|o)&b[i+76>>2]==(0|r))){a=7;break e}if(e=b[i+80>>2],r=b[i+84>>2],s=l=b[i+60>>2],-1==(0|(o=b[i+56>>2]))&-1==(0|s))o=e,s=r;else if(a=7,(0|e)!=(0|o)|(0|r)!=(0|s))break e;s=s+b[i+108>>2]|0,(r=o+b[i+104>>2]|0)>>>0>>0&&(s=s+1|0),b[i+104>>2]=r,b[i+108>>2]=s,s=b[i+100>>2],e=b[i+76>>2],(l=(o=b[i+64>>2])+b[i+72>>2]|0)>>>0>>0&&(e=e+1|0),e=e+s|0,e=(o=l+b[i+96>>2]|0)>>>0>>0?e+1|0:e,(o=(s=o)+M[b[i+32>>2]+1040|0]|0)>>>0>>0&&(e=e+1|0),b[i+96>>2]=o,b[i+100>>2]=e,b[i+112>>2]=T(t,24,b[i+112>>2]),b[i>>2]=4,r=b[i+92>>2],(o=b[i+88>>2]+1|0)>>>0<1&&(r=r+1|0),b[i+88>>2]=o,b[i+92>>2]=r}if(s=b[i+76>>2],3&(o=b[i+72>>2]))for(r=b[132105],l=b[132106];;){if((0|r)==(0|l)){a=0;break e}if(e=r+1|0,b[132105]=e,M[b[132104]+r|0]){a=7;break e}if((o=o+1|0)>>>0<1&&(s=s+1|0),b[i+72>>2]=o,b[i+76>>2]=s,r=e,!(3&o))break}b[i>>2]=5}a:{s:if(!(3<(r=(e=b[i+32>>2])+-1|0)>>>0)){l:switch(r-1|0){default:for(r=b[132105],a=b[132106];;){if((0|r)==(0|a)){a=0;break e}if(l=b[i+24>>2],o=b[i+28>>2],e=b[i+4>>2],s=r+1|0,b[132105]=s,u=M[b[132104]+r|0],d=l,r=o,l=31&e,(0|u)!=(255&(32<=(63&e)>>>0?r>>>l|0:((1<>>l))){a=7;break e}if(e=e+8|0,r=s,!((b[i+4>>2]=e)>>>0<32))break}b[i+24>>2]=0,b[i+28>>2]=0;break a;case 0:case 1:break s;case 2:}for(r=b[132105],a=b[132106];;){if((0|r)==(0|a)){a=0;break e}if(l=b[i+24>>2],o=b[i+28>>2],e=b[i+4>>2],s=r+1|0,b[132105]=s,u=M[b[132104]+r|0],d=l,r=o,l=31&e,(0|u)!=(255&(32<=(63&e)>>>0?r>>>l|0:((1<>>l))){a=7;break e}if(e=e+8|0,r=s,!((b[i+4>>2]=e)>>>0<64))break}b[i+24>>2]=0,b[i+28>>2]=0;break a}if(r=b[i+4>>2],!((e=M[e+1040|0])>>>0<=r>>>0))for(a=b[132105],o=b[132106];;){if((0|a)==(0|o)){a=0;break e}if(a=a+1|0,b[132105]=a,r=r+1|0,(0|e)==(0|(b[i+4>>2]=r)))break}}b[i+4>>2]=0,r=1,b[i>>2]=1;continue}break}for(h=i+144|0;;){f=b[132106],u=b[132104],(e=b[i+4>>2])||(b[i+8>>2]=0,b[i+12>>2]=0),r=b[132105];o:{for(;;){if(f>>>0<=r>>>0)a=0;else if(c=M[r+u|0],r=r+1|0,b[132105]=r,p=b[(l=i)+12>>2],d=127&c,a=31&e,o=32<=(63&e)>>>0?(s=d<>>32-a,d<>2],s=a=s|p,b[l+8>>2]=o,b[l+12>>2]=s,128&c){if(e=e+(a=7)|0,63!=(0|(b[i+4>>2]=e)))continue}else{if(c|!e)break o;a=7}break}e=b[i+132>>2],(c=(s=(o=r)-(r=b[i+16>>2])|0)+b[i+128>>2]|0)>>>0>>0&&(e=e+1|0),b[i+128>>2]=c,b[i+132>>2]=e,b[i+24>>2]=T(r+u|0,s,b[i+24>>2]),b[i+28>>2]=0;break e}b[i+4>>2]=0;o:{if((e=b[i+120>>2])>>>0<=2){a:switch(e-1|0){default:if(b[i+136>>2]=o,b[i+140>>2]=s,(0|o)!=b[i+88>>2]|(0|s)!=b[i+92>>2]){a=7;break e}b[i+120>>2]=1;break o;case 1:e=s+b[i+156>>2]|0,(s=o+b[i+152>>2]|0)>>>0>>0&&(e=e+1|0),b[i+152>>2]=s,b[i+156>>2]=e,b[i+160>>2]=T(h,24,b[i+160>>2]),b[i+120>>2]=1,s=b[i+140>>2]+-1|0,(r=b[i+136>>2]+-1|0)>>>0<4294967295&&(s=s+1|0),o=r,b[i+136>>2]=r,b[i+140>>2]=s;break o;case 0:}b[i+120>>2]=2,e=s+b[i+148>>2]|0,(s=o+b[i+144>>2]|0)>>>0>>0&&(e=e+1|0),b[i+144>>2]=s,b[i+148>>2]=e}o=b[i+136>>2],s=b[i+140>>2]}if(!(o|s))break}b[i>>2]=7}o=b[i+132>>2],d=((r=b[132105])+(((s=b[i+16>>2])-r|0)-(c=b[i+128>>2])&3)|0)-s|0;r:{for(;;){if(e=o,(a=(l=u=r-s|0)+c|0)>>>0>>0&&(e=e+1|0),!(3&(l=a)))break r;if(a=b[132104],b[132106]==(0|r)){b[i+128>>2]=l,b[i+132>>2]=e,b[i+24>>2]=T(a+s|0,u,b[i+24>>2]),a=b[i+28>>2]=0;break e}if(e=r+1|0,l=r+a|0,r=b[132105]=e,M[0|l])break}a=7;break e}if(r=b[132104],b[i+128>>2]=l,b[i+132>>2]=e,b[i+24>>2]=T(r+s|0,d,b[i+24>>2]),a=7,P(t,i+144|(b[i+28>>2]=0),24))break e;b[i>>2]=8}for(r=b[132105],a=b[132106];;){if((0|r)==(0|a)){a=0;break e}if(c=b[i+24>>2],s=b[i+28>>2],o=b[i+4>>2],e=r+1|0,b[132105]=e,l=b[132104],u=M[l+r|0],d=c,r=s,c=31&o,(0|u)!=(255&(32<=(63&o)>>>0?r>>>c|0:((1<>>c))){a=7;break e}if(o=o+8|0,r=e,!((b[i+4>>2]=o)>>>0<32))break}b[i+172>>2]=12,b[i+24>>2]=0,b[i+28>>2]=0,b[i>>2]=9,b[i+4>>2]=0,r=12;break t}e=b[132105],l=b[132104],a=b[132106],r=b[i+172>>2]}o=a-e|0,A(176+(i+(s=b[i+168>>2])|0)|0,e+l|0,r=o>>>0<(r=r-s|0)>>>0?o:r),b[132105]=r+b[132105],a=0,e=r+b[i+168>>2]|0,r=b[i+172>>2],b[i+168>>2]=(0|r)==(0|e)?0:e,(0|e)==(0|r)&&(a=7,23129==(M[i+186|0]|M[i+187|0]<<8)&&(0|T(i+180|0,6,0))==(M[i+176|0]|M[i+177|0]<<8|(M[i+178|0]<<16|M[i+179|0]<<24))&&(e=(r=b[i+132>>2])>>>2|0,M[i+184|0]|(M[i+180|0]|M[i+181|0]<<8|(M[i+182|0]<<16|M[i+183|0]<<24))!=((3&r)<<30|b[i+128>>2]>>>2)|e||(a=b[i+32>>2]==M[i+185|0]?1:7)))}e:{if(!b[i+36>>2]){if(a){if(i=1==(0|a),e=a,a=1,i)break e}else e=b[132105]==b[132106]?7:8;return b[132108]=_,b[132105]=x,e}if(!(b[132105]!=(0|x)|a|b[132108]!=(0|_)))return e=M[i+40|0],y[i+40|0]=1,e<<3;y[i+40|0]=0}return a}function m(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,i=0,r=0,o=0,a=0,s=0,l=0;t=(e=a)>>>1|0,n=1&(e=(1&e)<<31|s>>>1),t^=0-(0<(o=1&s)>>>0)&-915646571,o=e^(r=0-o&-679014590),e=t>>>1|0,e^=0-(0>>0)&-915646571,n=(t=(1&t)<<31|o>>>1)^(i=0-n&-679014590),i=e>>>1|0,n=1&(e=(1&e)<<31|n>>>1),r=0-(t&=1)&-679014590,t=i^0-(0>>0)&-915646571,i=e^r,e=t>>>1|0,i=0-n&-679014590^(t=(1&t)<<31|i>>>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|i>>>1)^(r=0-t&-679014590))>>>1,e=(n=0-(0<(i=1&n)>>>0)&-915646571^e>>>1)>>>1|0,i=1&(n=(1&n)<<31|(i=t^(o=0-i&-679014590))>>>1),n^=0-(t&=1)&-679014590,t=(e^=0-(0>>0)&-915646571)>>>1|0,b[(r=2080+(l<<3)|0)>>2]=0-i&-679014590^((1&e)<<31|n>>>1),b[r+4>>2]=t^0-(0>>0)&-915646571,l=l+1|0,e=a,(a=s+1|0)>>>0<1&&(e=e+1|0),256!=(0|(s=a))|(a=e););}(),e=s(),0|(e=(b[263184]=e)?0:(a(0),1))},decompress:function(){var e,t=0;e:{if((e=l(b[263184]))>>>0<=8){t:switch(e-1|0){case 0:return a(b[263184]),0;case 2:return a(b[263184]),1;case 3:return a(b[263184]),2;case 4:return a(b[263184]),4;case 5:return a(b[263184]),5;case 6:case 7:break t;default:break e}return a(b[263184]),6}a(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|i()}}}({Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array,NaN:NaN,Infinity:1/0,Math:Math},n,i.buffer))}},instantiate:function(t,n){return{then:function(e){e({instance:new lg.Instance(new lg.Module(t,n))})}}},RuntimeError:Error},cg=[];"object"!=typeof lg&&ag("no native wasm support detected");var ug=new lg.Table({initial:1,maximum:1,element:"anyfunc"}),dg=!1;function hg(e,t){e||Rg("Assertion failed: "+t)}function fg(e){var t=qv["_"+e];return hg(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function pg(e,t,n,i){var r={string:function(e){var t,n=0;return null!=e&&0!==e&&(t=1+(e.length<<2),n=Hg(t),function(e,t,n,i){if(0>6,t[n++]=128|63&l}else if(l<=65535){if(o<=n+2)break;t[n++]=224|l>>12,t[n++]=128|l>>6&63,t[n++]=128|63&l}else{if(o<=n+3)break;t[n++]=240|l>>18,t[n++]=128|l>>12&63,t[n++]=128|l>>6&63,t[n++]=128|63&l}}t[n]=0}}(e,_g,n,t)),n},array:function(e){var t,n,i=Hg(e.length);return t=e,n=i,gg.set(t,n),i}};var o=fg(e),a=[],s=0;if(i)for(var l=0;l>10,56320|1023&l))):o+=String.fromCharCode((31&c)<<6|a)):o+=String.fromCharCode(c)}return o}(_g,d,h):"":"boolean"===t?Boolean(u):u,0!==s&&Xg(s),f}var mg="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var vg,gg,_g,xg;var yg,bg=qv.TOTAL_MEMORY||16777216;function Mg(e){for(;0>4,n=(15&r)<<4|(o=s.indexOf(e.charAt(c++)))>>2,i=(3&o)<<6|(a=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(t),64!==o&&(l+=String.fromCharCode(n)),64!==a&&(l+=String.fromCharCode(i)),c>16&32768,i=t>>12&2047,r=t>>23&255;return r<103?n:142>114-r)+(i>>113-r&1):(n|=r-112<<10|i>>1,n+=1&i)}var n=new Uint8Array(e);n.pos=0;var i,r,c,u,d,h,f=function(e){var t,n,i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,a=/^\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(i))&&(s.gamma=parseFloat(n[1],10)),(n=t.match(r))&&(s.exposure=parseFloat(n[1],10)),(n=t.match(o))&&(s.valid|=2,s.format=n[1]),(n=t.match(a))&&(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!==f){var p=f.width,m=f.height,v=function(e,t,n){var i,r,o,a,s,l,c,u,d,h,f,p,m,v=t,g=n;if(v<8||32767e.byteLength)return _(1);if(m[0]=e[o++],m[1]=e[o++],m[2]=e[o++],m[3]=e[o++],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.")):(-1<(r=c.asset.generator||"").indexOf("Verge3D")&&"ALL"!=Wt&&[["Blender","BLENDER"],["3ds Max","MAX"],["Maya","MAYA"]].forEach(function(e){var t=e[0],n=e[1];-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:oe,depthTest:!1,depthWrite:!1})).type="SphericalGaussianBlur",$_(z_=l)}function K_(e,t){var n={magFilter:Je,minFilter:Je,generateMipmaps:!1,type:e?e.type:tt,format:e?e.format:A,encoding:e?e.encoding:Ct,depthBuffer:!1,stencilBuffer:!1};Object.assign(n,t);var i=ex(n);return i.depthBuffer=!e,W_=ex(n),i}function J_(e){W_.dispose(),H_.setRenderTarget(X_),e.scissorTest=!1,e.setSize(e.width,e.height)}function $_(e){var t=new Un;t.add(new Pr(j_[0],e)),H_.compile(t,U_)}function ex(e){var t=N_(0),n=new an(3*t,3*t,e);return n.texture.mapping=We,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function tx(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function nx(e){var t=H_.autoClear;H_.autoClear=!1;for(var n=1;n\n\n vec4 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\n vec4 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\n vec4 envMapTexelToLinear(vec4 color) {\n return inputTexelToLinear(color);\n }\n\n#endif\n "}function cx(e,t,n,i,r){this._domElement=e,this._keyCode=t,this._callback=n,this._repeats=i,this._period=r,this._timer=0,this._counter=0,this._keydownCb=function(e){e.keyCode==this._keyCode&&(this._timer||(this._timer=window.setTimeout(function(){this._counter=0,this._timer=null}.bind(this),1e3*r)),++this._counter>=i&&(this._timer&&(window.clearTimeout(this._timer),this._timer=null),this._counter=0,this._callback()))}.bind(this),this._domElement.addEventListener("keydown",this._keydownCb,!1)}function ux(e){this.data=void 0!==e?e:null,this.equirecInvertU=!1,this.equirecOffsetU=0,this.useHDR=!1}Q_.prototype={constructor:Q_,fromScene:function(e){var t=1