1997 lines
459 KiB
JavaScript
1997 lines
459 KiB
JavaScript
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).skinview3d={})}(this,function(e){"use strict";let t,i;let r={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},a={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},n="srgb",s="srgb-linear",o="display-p3",l="300 es";class h{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let i=this._listeners,r=i[e];if(void 0!==r){let e=r.indexOf(t);-1!==e&&r.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners,i=t[e.type];if(void 0!==i){e.target=this;let t=i.slice(0);for(let i=0,r=t.length;i<r;i++)t[i].call(this,e);e.target=null}}}let c=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],u=Math.PI/180,d=180/Math.PI;function p(){let e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0,a=c[255&e]+c[e>>8&255]+c[e>>16&255]+c[e>>24&255]+"-"+c[255&t]+c[t>>8&255]+"-"+c[t>>16&15|64]+c[t>>24&255]+"-"+c[63&i|128]+c[i>>8&255]+"-"+c[i>>16&255]+c[i>>24&255]+c[255&r]+c[r>>8&255]+c[r>>16&255]+c[r>>24&255];return a.toLowerCase()}function f(e,t,i){return Math.max(t,Math.min(i,e))}function m(e){return(e&e-1)==0&&0!==e}function g(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function v(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("Invalid component type.")}}function _(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw Error("Invalid component type.")}}class x{constructor(e=0,t=0){x.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return thi
|
||
|
#include <begin_vertex>
|
||
|
#include <project_vertex>
|
||
|
}`,fragmentShader:`uniform sampler2D tEquirect;varying vec3 vWorldDirection;
|
||
|
#include <common>
|
||
|
void main(){vec3 direction=normalize(vWorldDirection);vec2 sampleUV=equirectUv(direction);gl_FragColor=texture2D(tEquirect,sampleUV);}`},r=new tO(5,5,5),a=new tH({name:"CubemapFromEquirect",uniforms:tz(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});a.uniforms.tEquirect.value=t;let n=new tI(r,a),s=t.minFilter;1008===t.minFilter&&(t.minFilter=1006);let o=new tW(1,10,this);return o.update(e,n),t.minFilter=s,n.geometry.dispose(),n.material.dispose(),this}clear(e,t,i,r){let a=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(a)}}let tX=new W,tY=new W,tZ=new y;class tK{constructor(e=new W(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=tX.subVectors(i,t).cross(tY.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta(tX),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/r;return a<0||a>1?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||tZ.getNormalMatrix(e),r=this.coplanarPoint(tX).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}let tJ=new eu,tQ=new W;class t${constructor(e=new tK,t=new tK,i=new tK,r=new tK,a=new tK,n=new tK){this.planes=[e,t,i,r,a,n]}set(e,t,i,r,a,n){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(i),s[3].copy(r),s[4].copy(a),s[5].copy(n),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=2e3){let i=this.planes,r=e.elements,a=r[0],n=r[1],s=r[2],o=r[3],l=r[4],h=r[5],c=r[6],u=r[7],d=r[8],p=r[9],f=r[10],m=r[11],g=r[12],v=r[13],_=r[14],x=r[15];if(i[0].setComponents(o-a,u-l,m-d,x-g).normalize(),i[1].setComponents(o+a,u+l,m+d,x+g).normalize(),i[2].setComponents(o+n,u+h,m+p,x+v).normalize(),i[3].setComponents(o-n,u-h,m-p,x-v).normalize(),i[4].setComponents(o-s,u-c,m-f,x-_).normalize(),2e3===t)i[5].setComponents(o+s,u+c,m+f,x+_).normalize();else if(2001===t)i[5].setComponents(s,c,f,_).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),tJ.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),tJ.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(tJ)}intersectsSprite(e){return tJ.center.set(0,0,0),tJ.radius=.7071067811865476,tJ.applyMatrix4(e.matrixWorld),this.intersectsSphere(tJ)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let e=0;e<6;e++){let a=t[e].distanceToPoint(i);if(a<r)return!1}return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(tQ.x=r.normal.x>0?e.max.x:e.min.
|
||
|
if(diffuseColor.a<getAlphaHashThreshold(vPosition))discard;
|
||
|
#endif`,t4=`#ifdef USE_ALPHAHASH
|
||
|
const float ALPHA_HASH_SCALE=0.05;float hash2D(vec2 value){return fract(1.0e4*sin(17.0*value.x+0.1*value.y)*(0.1+abs(sin(13.0*value.y+value.x))));}float hash3D(vec3 value){return hash2D(vec2(hash2D(value.xy),value.z));}float getAlphaHashThreshold(vec3 position){float maxDeriv=max(length(dFdx(position.xyz)),length(dFdy(position.xyz)));float pixScale=1.0/(ALPHA_HASH_SCALE*maxDeriv);vec2 pixScales=vec2(exp2(floor(log2(pixScale))),exp2(ceil(log2(pixScale))));vec2 alpha=vec2(hash3D(floor(pixScales.x*position.xyz)),hash3D(floor(pixScales.y*position.xyz)));float lerpFactor=fract(log2(pixScale));float x=(1.0-lerpFactor)*alpha.x+lerpFactor*alpha.y;float a=min(lerpFactor,1.0-lerpFactor);vec3 cases=vec3(x*x/(2.0*a*(1.0-a)),(x-0.5*a)/(1.0-a),1.0-((1.0-x)*(1.0-x)/(2.0*a*(1.0-a))));float threshold=(x<(1.0-a))?((x<a)?cases.x:cases.y):cases.z;return clamp(threshold,1.0e-6,1.0);}
|
||
|
#endif`,t5=`#ifdef USE_ALPHAMAP
|
||
|
diffuseColor.a*=texture2D(alphaMap,vAlphaMapUv).g;
|
||
|
#endif`,t6=`#ifdef USE_ALPHAMAP
|
||
|
uniform sampler2D alphaMap;
|
||
|
#endif`,t8=`#ifdef USE_ALPHATEST
|
||
|
if(diffuseColor.a<alphaTest)discard;
|
||
|
#endif`,t7=`#ifdef USE_ALPHATEST
|
||
|
uniform float alphaTest;
|
||
|
#endif`,t9=`#ifdef USE_AOMAP
|
||
|
float ambientOcclusion=(texture2D(aoMap,vAoMapUv).r-1.0)*aoMapIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;
|
||
|
#if defined(USE_ENVMAP)&&defined(STANDARD)
|
||
|
float dotNV=saturate(dot(geometry.normal,geometry.viewDir));reflectedLight.indirectSpecular*=computeSpecularOcclusion(dotNV,ambientOcclusion,material.roughness);
|
||
|
#endif
|
||
|
#endif`,ie=`#ifdef USE_AOMAP
|
||
|
uniform sampler2D aoMap;uniform float aoMapIntensity;
|
||
|
#endif`,it=`vec3 transformed=vec3(position);
|
||
|
#ifdef USE_ALPHAHASH
|
||
|
vPosition=vec3(position);
|
||
|
#endif`,ii=`vec3 objectNormal=vec3(normal);
|
||
|
#ifdef USE_TANGENT
|
||
|
vec3 objectTangent=vec3(tangent.xyz);
|
||
|
#endif`,ir=`#ifdef USE_IRIDESCENCE
|
||
|
const mat3 XYZ_TO_REC709=mat3(3.2404542,-0.9692660,0.0556434,-1.5371385,1.8760108,-0.2040259,-0.4985314,0.0415560,1.0572252);vec3 Fresnel0ToIor(vec3 fresnel0){vec3 sqrtF0=sqrt(fresnel0);return(vec3(1.0)+sqrtF0)/(vec3(1.0)-sqrtF0);}vec3 IorToFresnel0(vec3 transmittedIor,float incidentIor){return pow2((transmittedIor-vec3(incidentIor))/(transmittedIor+vec3(incidentIor)));}float IorToFresnel0(float transmittedIor,float incidentIor){return pow2((transmittedIor-incidentIor)/(transmittedIor+incidentIor));}vec3 evalSensitivity(float OPD,vec3 shift){float phase=2.0*PI*OPD*1.0e-9;vec3 val=vec3(5.4856e-13,4.4201e-13,5.2481e-13);vec3 pos=vec3(1.6810e+06,1.7953e+06,2.2084e+06);vec3 var=vec3(4.3278e+09,9.3046e+09,6.6121e+09);vec3 xyz=val*sqrt(2.0*PI*var)*cos(pos*phase+shift)*exp(-pow2(phase)*var);xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*pow2(phase));xyz/=1.0685e-7;vec3 rgb=XYZ_TO_REC709*xyz;return rgb;}vec3 evalIridescence(float outsideIOR,float eta2,float cosTheta1,float thinFilmThickness,vec3 baseF0){vec3 I;float iridescenceIOR=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));float sinTheta2Sq=pow2(outsideIOR/iridescenceIOR)*(1.0-pow2(cosTheta1));float cosTheta2Sq=1.0-sinTheta2Sq;if(cosTheta2Sq<0.0){return vec3(1.0);}float cosTheta2=sqrt(cosTheta2Sq);float R0=IorToFresnel0(iridescenceIOR,outsideIOR);float R12=F_Schlick(R0,1.0,cosTheta1);float T121=1.0-R12;float phi12=0.0;if(iridescenceIOR<outsideIOR)phi12=PI;float phi21=PI-phi12;vec3 baseIOR=Fresnel0ToIor(clamp(baseF0,0.0,0.9999));vec3 R1=IorToFresnel0(baseIOR,iridescenceIOR);vec3 R23=F_Schlick(R1,1.0,cosTheta2);vec3 phi23=vec3(0.0);if(baseIOR[0]<iridescenceIOR)phi23[0]=PI;if(baseIOR[1]<iridescenceIOR)phi23[1]=PI;if(baseIOR[2]<iridescenceIOR)phi23[2]=PI;float OPD=2.0*iridescenceIOR*thinFilmThickness*cosTheta2;vec3 phi=vec3(phi21)+phi23;vec3 R123=clamp(R12*R23,1e-5,0.9999);vec3 r123=sqrt(R123);vec3 Rs=pow2(T121)*R23/(vec3(1.0)-R123);vec3 C0=R12+Rs;I=C0;vec3 Cm=Rs-T121;for(int m=1;m<=2;++m){Cm*=r123;vec3 Sm=2.0*evalSensitivity(float(m)*OPD,float(m)*phi);I+=Cm*Sm;}return max(I,vec3(0.0));}
|
||
|
#endif`,ia=`#ifdef USE_BUMPMAP
|
||
|
uniform sampler2D bumpMap;uniform float bumpScale;vec2 dHdxy_fwd(){vec2 dSTdx=dFdx(vBumpMapUv);vec2 dSTdy=dFdy(vBumpMapUv);float Hll=bumpScale*texture2D(bumpMap,vBumpMapUv).x;float dBx=bumpScale*texture2D(bumpMap,vBumpMapUv+dSTdx).x-Hll;float dBy=bumpScale*texture2D(bumpMap,vBumpMapUv+dSTdy).x-Hll;return vec2(dBx,dBy);}vec3 perturbNormalArb(vec3 surf_pos,vec3 surf_norm,vec2 dHdxy,float faceDirection){vec3 vSigmaX=dFdx(surf_pos.xyz);vec3 vSigmaY=dFdy(surf_pos.xyz);vec3 vN=surf_norm;vec3 R1=cross(vSigmaY,vN);vec3 R2=cross(vN,vSigmaX);float fDet=dot(vSigmaX,R1)*faceDirection;vec3 vGrad=sign(fDet)*(dHdxy.x*R1+dHdxy.y*R2);return normalize(abs(fDet)*surf_norm-vGrad);}
|
||
|
#endif`,is=`#if NUM_CLIPPING_PLANES>0
|
||
|
vec4 plane;
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<UNION_CLIPPING_PLANES;i++){plane=clippingPlanes[i];if(dot(vClipPosition,plane.xyz)>plane.w)discard;}
|
||
|
#pragma unroll_loop_end
|
||
|
#if UNION_CLIPPING_PLANES<NUM_CLIPPING_PLANES
|
||
|
bool clipped=true;
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=UNION_CLIPPING_PLANES;i<NUM_CLIPPING_PLANES;i++){plane=clippingPlanes[i];clipped=(dot(vClipPosition,plane.xyz)>plane.w)&&clipped;}
|
||
|
#pragma unroll_loop_end
|
||
|
if(clipped)discard;
|
||
|
#endif
|
||
|
#endif`,io=`#if NUM_CLIPPING_PLANES>0
|
||
|
varying vec3 vClipPosition;uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];
|
||
|
#endif`,il=`#if NUM_CLIPPING_PLANES>0
|
||
|
varying vec3 vClipPosition;
|
||
|
#endif`,ih=`#if NUM_CLIPPING_PLANES>0
|
||
|
vClipPosition=-mvPosition.xyz;
|
||
|
#endif`,ic=`#if defined(USE_COLOR_ALPHA)
|
||
|
diffuseColor*=vColor;
|
||
|
#elif defined(USE_COLOR)
|
||
|
diffuseColor.rgb*=vColor;
|
||
|
#endif`,iu=`#if defined(USE_COLOR_ALPHA)
|
||
|
varying vec4 vColor;
|
||
|
#elif defined(USE_COLOR)
|
||
|
varying vec3 vColor;
|
||
|
#endif`,id=`#if defined(USE_COLOR_ALPHA)
|
||
|
varying vec4 vColor;
|
||
|
#elif defined(USE_COLOR)||defined(USE_INSTANCING_COLOR)
|
||
|
varying vec3 vColor;
|
||
|
#endif`,ip=`#if defined(USE_COLOR_ALPHA)
|
||
|
vColor=vec4(1.0);
|
||
|
#elif defined(USE_COLOR)||defined(USE_INSTANCING_COLOR)
|
||
|
vColor=vec3(1.0);
|
||
|
#endif
|
||
|
#ifdef USE_COLOR
|
||
|
vColor*=color;
|
||
|
#endif
|
||
|
#ifdef USE_INSTANCING_COLOR
|
||
|
vColor.xyz*=instanceColor.xyz;
|
||
|
#endif`,im=`#define PI 3.141592653589793
|
||
|
#define PI2 6.283185307179586
|
||
|
#define PI_HALF 1.5707963267948966
|
||
|
#define RECIPROCAL_PI 0.3183098861837907
|
||
|
#define RECIPROCAL_PI2 0.15915494309189535
|
||
|
#define EPSILON 1e-6
|
||
|
#ifndef saturate
|
||
|
#define saturate(a)clamp(a,0.0,1.0)
|
||
|
#endif
|
||
|
#define whiteComplement(a)(1.0-saturate(a))
|
||
|
float pow2(const in float x){return x*x;}vec3 pow2(const in vec3 x){return x*x;}float pow3(const in float x){return x*x*x;}float pow4(const in float x){float x2=x*x;return x2*x2;}float max3(const in vec3 v){return max(max(v.x,v.y),v.z);}float average(const in vec3 v){return dot(v,vec3(0.3333333));}highp float rand(const in vec2 uv){const highp float a=12.9898,b=78.233,c=43758.5453;highp float dt=dot(uv.xy,vec2(a,b)),sn=mod(dt,PI);return fract(sin(sn)*c);}
|
||
|
#ifdef HIGH_PRECISION
|
||
|
float precisionSafeLength(vec3 v){return length(v);}
|
||
|
#else
|
||
|
float precisionSafeLength(vec3 v){float maxComponent=max3(abs(v));return length(v/maxComponent)*maxComponent;}
|
||
|
#endif
|
||
|
struct IncidentLight{vec3 color;vec3 direction;bool visible;};struct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct GeometricContext{vec3 position;vec3 normal;vec3 viewDir;
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
vec3 clearcoatNormal;
|
||
|
#endif
|
||
|
};
|
||
|
#ifdef USE_ALPHAHASH
|
||
|
varying vec3 vPosition;
|
||
|
#endif
|
||
|
vec3 transformDirection(in vec3 dir,in mat4 matrix){return normalize((matrix*vec4(dir,0.0)).xyz);}vec3 inverseTransformDirection(in vec3 dir,in mat4 matrix){return normalize((vec4(dir,0.0)*matrix).xyz);}mat3 transposeMat3(const in mat3 m){mat3 tmp;tmp[0]=vec3(m[0].x,m[1].x,m[2].x);tmp[1]=vec3(m[0].y,m[1].y,m[2].y);tmp[2]=vec3(m[0].z,m[1].z,m[2].z);return tmp;}float luminance(const in vec3 rgb){const vec3 weights=vec3(0.2126729,0.7151522,0.0721750);return dot(weights,rgb);}bool isPerspectiveMatrix(mat4 m){return m[2][3]==-1.0;}vec2 equirectUv(in vec3 dir){float u=atan(dir.z,dir.x)*RECIPROCAL_PI2+0.5;float v=asin(clamp(dir.y,-1.0,1.0))*RECIPROCAL_PI+0.5;return vec2(u,v);}vec3 BRDF_Lambert(const in vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}vec3 F_Schlick(const in vec3 f0,const in float f90,const in float dotVH){float fresnel=exp2((-5.55473*dotVH-6.98316)*dotVH);return f0*(1.0-fresnel)+(f90*fresnel);}float F_Schlick(const in float f0,const in float f90,const in float dotVH){float fresnel=exp2((-5.55473*dotVH-6.98316)*dotVH);return f0*(1.0-fresnel)+(f90*fresnel);}`,ig=`#ifdef ENVMAP_TYPE_CUBE_UV
|
||
|
#define cubeUV_minMipLevel 4.0
|
||
|
#define cubeUV_minTileSize 16.0
|
||
|
float getFace(vec3 direction){vec3 absDirection=abs(direction);float face=-1.0;if(absDirection.x>absDirection.z){if(absDirection.x>absDirection.y)face=direction.x>0.0?0.0:3.0;else face=direction.y>0.0?1.0:4.0;}else{if(absDirection.z>absDirection.y)face=direction.z>0.0?2.0:5.0;else face=direction.y>0.0?1.0:4.0;}return face;}vec2 getUV(vec3 direction,float face){vec2 uv;if(face==0.0){uv=vec2(direction.z,direction.y)/abs(direction.x);}else if(face==1.0){uv=vec2(-direction.x,-direction.z)/abs(direction.y);}else if(face==2.0){uv=vec2(-direction.x,direction.y)/abs(direction.z);}else if(face==3.0){uv=vec2(-direction.z,direction.y)/abs(direction.x);}else if(face==4.0){uv=vec2(-direction.x,direction.z)/abs(direction.y);}else{uv=vec2(direction.x,direction.y)/abs(direction.z);}return 0.5*(uv+1.0);}vec3 bilinearCubeUV(sampler2D envMap,vec3 direction,float mipInt){float face=getFace(direction);float filterInt=max(cubeUV_minMipLevel-mipInt,0.0);mipInt=max(mipInt,cubeUV_minMipLevel);float faceSize=exp2(mipInt);highp vec2 uv=getUV(direction,face)*(faceSize-2.0)+1.0;if(face>2.0){uv.y+=faceSize;face-=3.0;}uv.x+=face*faceSize;uv.x+=filterInt*3.0*cubeUV_minTileSize;uv.y+=4.0*(exp2(CUBEUV_MAX_MIP)-faceSize);uv.x*=CUBEUV_TEXEL_WIDTH;uv.y*=CUBEUV_TEXEL_HEIGHT;
|
||
|
#ifdef texture2DGradEXT
|
||
|
return texture2DGradEXT(envMap,uv,vec2(0.0),vec2(0.0)).rgb;
|
||
|
#else
|
||
|
return texture2D(envMap,uv).rgb;
|
||
|
#endif
|
||
|
}
|
||
|
#define cubeUV_r0 1.0
|
||
|
#define cubeUV_v0 0.339
|
||
|
#define cubeUV_m0-2.0
|
||
|
#define cubeUV_r1 0.8
|
||
|
#define cubeUV_v1 0.276
|
||
|
#define cubeUV_m1-1.0
|
||
|
#define cubeUV_r4 0.4
|
||
|
#define cubeUV_v4 0.046
|
||
|
#define cubeUV_m4 2.0
|
||
|
#define cubeUV_r5 0.305
|
||
|
#define cubeUV_v5 0.016
|
||
|
#define cubeUV_m5 3.0
|
||
|
#define cubeUV_r6 0.21
|
||
|
#define cubeUV_v6 0.0038
|
||
|
#define cubeUV_m6 4.0
|
||
|
float roughnessToMip(float roughness){float mip=0.0;if(roughness>=cubeUV_r1){mip=(cubeUV_r0-roughness)*(cubeUV_m1-cubeUV_m0)/(cubeUV_r0-cubeUV_r1)+cubeUV_m0;}else if(roughness>=cubeUV_r4){mip=(cubeUV_r1-roughness)*(cubeUV_m4-cubeUV_m1)/(cubeUV_r1-cubeUV_r4)+cubeUV_m1;}else if(roughness>=cubeUV_r5){mip=(cubeUV_r4-roughness)*(cubeUV_m5-cubeUV_m4)/(cubeUV_r4-cubeUV_r5)+cubeUV_m4;}else if(roughness>=cubeUV_r6){mip=(cubeUV_r5-roughness)*(cubeUV_m6-cubeUV_m5)/(cubeUV_r5-cubeUV_r6)+cubeUV_m5;}else{mip=-2.0*log2(1.16*roughness);}return mip;}vec4 textureCubeUV(sampler2D envMap,vec3 sampleDir,float roughness){float mip=clamp(roughnessToMip(roughness),cubeUV_m0,CUBEUV_MAX_MIP);float mipF=fract(mip);float mipInt=floor(mip);vec3 color0=bilinearCubeUV(envMap,sampleDir,mipInt);if(mipF==0.0){return vec4(color0,1.0);}else{vec3 color1=bilinearCubeUV(envMap,sampleDir,mipInt+1.0);return vec4(mix(color0,color1,mipF),1.0);}}
|
||
|
#endif`,iv=`vec3 transformedNormal=objectNormal;
|
||
|
#ifdef USE_INSTANCING
|
||
|
mat3 m=mat3(instanceMatrix);transformedNormal/=vec3(dot(m[0],m[0]),dot(m[1],m[1]),dot(m[2],m[2]));transformedNormal=m*transformedNormal;
|
||
|
#endif
|
||
|
transformedNormal=normalMatrix*transformedNormal;
|
||
|
#ifdef FLIP_SIDED
|
||
|
transformedNormal=-transformedNormal;
|
||
|
#endif
|
||
|
#ifdef USE_TANGENT
|
||
|
vec3 transformedTangent=(modelViewMatrix*vec4(objectTangent,0.0)).xyz;
|
||
|
#ifdef FLIP_SIDED
|
||
|
transformedTangent=-transformedTangent;
|
||
|
#endif
|
||
|
#endif`,i_=`#ifdef USE_DISPLACEMENTMAP
|
||
|
uniform sampler2D displacementMap;uniform float displacementScale;uniform float displacementBias;
|
||
|
#endif`,ix=`#ifdef USE_DISPLACEMENTMAP
|
||
|
transformed+=normalize(objectNormal)*(texture2D(displacementMap,vDisplacementMapUv).x*displacementScale+displacementBias);
|
||
|
#endif`,iy=`#ifdef USE_EMISSIVEMAP
|
||
|
vec4 emissiveColor=texture2D(emissiveMap,vEmissiveMapUv);totalEmissiveRadiance*=emissiveColor.rgb;
|
||
|
#endif`,iM=`#ifdef USE_EMISSIVEMAP
|
||
|
uniform sampler2D emissiveMap;
|
||
|
#endif`,iS=`#ifdef USE_ENVMAP
|
||
|
#ifdef ENV_WORLDPOS
|
||
|
vec3 cameraToFrag;if(isOrthographic){cameraToFrag=normalize(vec3(-viewMatrix[0][2],-viewMatrix[1][2],-viewMatrix[2][2]));}else{cameraToFrag=normalize(vWorldPosition-cameraPosition);}vec3 worldNormal=inverseTransformDirection(normal,viewMatrix);
|
||
|
#ifdef ENVMAP_MODE_REFLECTION
|
||
|
vec3 reflectVec=reflect(cameraToFrag,worldNormal);
|
||
|
#else
|
||
|
vec3 reflectVec=refract(cameraToFrag,worldNormal,refractionRatio);
|
||
|
#endif
|
||
|
#else
|
||
|
vec3 reflectVec=vReflect;
|
||
|
#endif
|
||
|
#ifdef ENVMAP_TYPE_CUBE
|
||
|
vec4 envColor=textureCube(envMap,vec3(flipEnvMap*reflectVec.x,reflectVec.yz));
|
||
|
#else
|
||
|
vec4 envColor=vec4(0.0);
|
||
|
#endif
|
||
|
#ifdef ENVMAP_BLENDING_MULTIPLY
|
||
|
outgoingLight=mix(outgoingLight,outgoingLight*envColor.xyz,specularStrength*reflectivity);
|
||
|
#elif defined(ENVMAP_BLENDING_MIX)
|
||
|
outgoingLight=mix(outgoingLight,envColor.xyz,specularStrength*reflectivity);
|
||
|
#elif defined(ENVMAP_BLENDING_ADD)
|
||
|
outgoingLight+=envColor.xyz*specularStrength*reflectivity;
|
||
|
#endif
|
||
|
#endif`,ib=`#ifdef USE_ENVMAP
|
||
|
uniform float envMapIntensity;uniform float flipEnvMap;
|
||
|
#ifdef ENVMAP_TYPE_CUBE
|
||
|
uniform samplerCube envMap;
|
||
|
#else
|
||
|
uniform sampler2D envMap;
|
||
|
#endif
|
||
|
#endif`,iw=`#ifdef USE_ENVMAP
|
||
|
uniform float reflectivity;
|
||
|
#if defined(USE_BUMPMAP)||defined(USE_NORMALMAP)||defined(PHONG)||defined(LAMBERT)
|
||
|
#define ENV_WORLDPOS
|
||
|
#endif
|
||
|
#ifdef ENV_WORLDPOS
|
||
|
varying vec3 vWorldPosition;uniform float refractionRatio;
|
||
|
#else
|
||
|
varying vec3 vReflect;
|
||
|
#endif
|
||
|
#endif`,iT=`#ifdef USE_ENVMAP
|
||
|
#if defined(USE_BUMPMAP)||defined(USE_NORMALMAP)||defined(PHONG)||defined(LAMBERT)
|
||
|
#define ENV_WORLDPOS
|
||
|
#endif
|
||
|
#ifdef ENV_WORLDPOS
|
||
|
varying vec3 vWorldPosition;
|
||
|
#else
|
||
|
varying vec3 vReflect;uniform float refractionRatio;
|
||
|
#endif
|
||
|
#endif`,iE=`#ifdef USE_ENVMAP
|
||
|
#ifdef ENV_WORLDPOS
|
||
|
vWorldPosition=worldPosition.xyz;
|
||
|
#else
|
||
|
vec3 cameraToVertex;if(isOrthographic){cameraToVertex=normalize(vec3(-viewMatrix[0][2],-viewMatrix[1][2],-viewMatrix[2][2]));}else{cameraToVertex=normalize(worldPosition.xyz-cameraPosition);}vec3 worldNormal=inverseTransformDirection(transformedNormal,viewMatrix);
|
||
|
#ifdef ENVMAP_MODE_REFLECTION
|
||
|
vReflect=reflect(cameraToVertex,worldNormal);
|
||
|
#else
|
||
|
vReflect=refract(cameraToVertex,worldNormal,refractionRatio);
|
||
|
#endif
|
||
|
#endif
|
||
|
#endif`,iA=`#ifdef USE_FOG
|
||
|
vFogDepth=-mvPosition.z;
|
||
|
#endif`,iC=`#ifdef USE_FOG
|
||
|
varying float vFogDepth;
|
||
|
#endif`,iL=`#ifdef USE_FOG
|
||
|
#ifdef FOG_EXP2
|
||
|
float fogFactor=1.0-exp(-fogDensity*fogDensity*vFogDepth*vFogDepth);
|
||
|
#else
|
||
|
float fogFactor=smoothstep(fogNear,fogFar,vFogDepth);
|
||
|
#endif
|
||
|
gl_FragColor.rgb=mix(gl_FragColor.rgb,fogColor,fogFactor);
|
||
|
#endif`,iP=`#ifdef USE_FOG
|
||
|
uniform vec3 fogColor;varying float vFogDepth;
|
||
|
#ifdef FOG_EXP2
|
||
|
uniform float fogDensity;
|
||
|
#else
|
||
|
uniform float fogNear;uniform float fogFar;
|
||
|
#endif
|
||
|
#endif`,iR=`#ifdef USE_GRADIENTMAP
|
||
|
uniform sampler2D gradientMap;
|
||
|
#endif
|
||
|
vec3 getGradientIrradiance(vec3 normal,vec3 lightDirection){float dotNL=dot(normal,lightDirection);vec2 coord=vec2(dotNL*0.5+0.5,0.0);
|
||
|
#ifdef USE_GRADIENTMAP
|
||
|
return vec3(texture2D(gradientMap,coord).r);
|
||
|
#else
|
||
|
vec2 fw=fwidth(coord)*0.5;return mix(vec3(0.7),vec3(1.0),smoothstep(0.7-fw.x,0.7+fw.x,coord.x));
|
||
|
#endif
|
||
|
}`,iD=`#ifdef USE_LIGHTMAP
|
||
|
vec4 lightMapTexel=texture2D(lightMap,vLightMapUv);vec3 lightMapIrradiance=lightMapTexel.rgb*lightMapIntensity;reflectedLight.indirectDiffuse+=lightMapIrradiance;
|
||
|
#endif`,iU=`#ifdef USE_LIGHTMAP
|
||
|
uniform sampler2D lightMap;uniform float lightMapIntensity;
|
||
|
#endif`,iI=`varying vec3 vViewPosition;struct LambertMaterial{vec3 diffuseColor;float specularStrength;};void RE_Direct_Lambert(const in IncidentLight directLight,const in GeometricContext geometry,const in LambertMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color;reflectedLight.directDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Lambert(const in vec3 irradiance,const in GeometricContext geometry,const in LambertMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}
|
||
|
#define RE_Direct RE_Direct_Lambert
|
||
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,iN=`uniform bool receiveShadow;uniform vec3 ambientLightColor;uniform vec3 lightProbe[9];vec3 shGetIrradianceAt(in vec3 normal,in vec3 shCoefficients[9]){float x=normal.x,y=normal.y,z=normal.z;vec3 result=shCoefficients[0]*0.886227;result+=shCoefficients[1]*2.0*0.511664*y;result+=shCoefficients[2]*2.0*0.511664*z;result+=shCoefficients[3]*2.0*0.511664*x;result+=shCoefficients[4]*2.0*0.429043*x*y;result+=shCoefficients[5]*2.0*0.429043*y*z;result+=shCoefficients[6]*(0.743125*z*z-0.247708);result+=shCoefficients[7]*2.0*0.429043*x*z;result+=shCoefficients[8]*0.429043*(x*x-y*y);return result;}vec3 getLightProbeIrradiance(const in vec3 lightProbe[9],const in vec3 normal){vec3 worldNormal=inverseTransformDirection(normal,viewMatrix);vec3 irradiance=shGetIrradianceAt(worldNormal,lightProbe);return irradiance;}vec3 getAmbientLightIrradiance(const in vec3 ambientLightColor){vec3 irradiance=ambientLightColor;return irradiance;}float getDistanceAttenuation(const in float lightDistance,const in float cutoffDistance,const in float decayExponent){
|
||
|
#if defined(LEGACY_LIGHTS)
|
||
|
if(cutoffDistance>0.0&&decayExponent>0.0){return pow(saturate(-lightDistance/cutoffDistance+1.0),decayExponent);}return 1.0;
|
||
|
#else
|
||
|
float distanceFalloff=1.0/max(pow(lightDistance,decayExponent),0.01);if(cutoffDistance>0.0){distanceFalloff*=pow2(saturate(1.0-pow4(lightDistance/cutoffDistance)));}return distanceFalloff;
|
||
|
#endif
|
||
|
}float getSpotAttenuation(const in float coneCosine,const in float penumbraCosine,const in float angleCosine){return smoothstep(coneCosine,penumbraCosine,angleCosine);}
|
||
|
#if NUM_DIR_LIGHTS>0
|
||
|
struct DirectionalLight{vec3 direction;vec3 color;};uniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];void getDirectionalLightInfo(const in DirectionalLight directionalLight,const in GeometricContext geometry,out IncidentLight light){light.color=directionalLight.color;light.direction=directionalLight.direction;light.visible=true;}
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHTS>0
|
||
|
struct PointLight{vec3 position;vec3 color;float distance;float decay;};uniform PointLight pointLights[NUM_POINT_LIGHTS];void getPointLightInfo(const in PointLight pointLight,const in GeometricContext geometry,out IncidentLight light){vec3 lVector=pointLight.position-geometry.position;light.direction=normalize(lVector);float lightDistance=length(lVector);light.color=pointLight.color;light.color*=getDistanceAttenuation(lightDistance,pointLight.distance,pointLight.decay);light.visible=(light.color!=vec3(0.0));}
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHTS>0
|
||
|
struct SpotLight{vec3 position;vec3 direction;vec3 color;float distance;float decay;float coneCos;float penumbraCos;};uniform SpotLight spotLights[NUM_SPOT_LIGHTS];void getSpotLightInfo(const in SpotLight spotLight,const in GeometricContext geometry,out IncidentLight light){vec3 lVector=spotLight.position-geometry.position;light.direction=normalize(lVector);float angleCos=dot(light.direction,spotLight.direction);float spotAttenuation=getSpotAttenuation(spotLight.coneCos,spotLight.penumbraCos,angleCos);if(spotAttenuation>0.0){float lightDistance=length(lVector);light.color=spotLight.color*spotAttenuation;light.color*=getDistanceAttenuation(lightDistance,spotLight.distance,spotLight.decay);light.visible=(light.color!=vec3(0.0));}else{light.color=vec3(0.0);light.visible=false;}}
|
||
|
#endif
|
||
|
#if NUM_RECT_AREA_LIGHTS>0
|
||
|
struct RectAreaLight{vec3 color;vec3 position;vec3 halfWidth;vec3 halfHeight;};uniform sampler2D ltc_1;uniform sampler2D ltc_2;uniform RectAreaLight rectAreaLights[NUM_RECT_AREA_LIGHTS];
|
||
|
#endif
|
||
|
#if NUM_HEMI_LIGHTS>0
|
||
|
struct HemisphereLight{vec3 direction;vec3 skyColor;vec3 groundColor;};uniform HemisphereLight hemisphereLights[NUM_HEMI_LIGHTS];vec3 getHemisphereLightIrradiance(const in HemisphereLight hemiLight,const in vec3 normal){float dotNL=dot(normal,hemiLight.direction);float hemiDiffuseWeight=0.5*dotNL+0.5;vec3 irradiance=mix(hemiLight.groundColor,hemiLight.skyColor,hemiDiffuseWeight);return irradiance;}
|
||
|
#endif`,iO=`#ifdef USE_ENVMAP
|
||
|
vec3 getIBLIrradiance(const in vec3 normal){
|
||
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
|
vec3 worldNormal=inverseTransformDirection(normal,viewMatrix);vec4 envMapColor=textureCubeUV(envMap,worldNormal,1.0);return PI*envMapColor.rgb*envMapIntensity;
|
||
|
#else
|
||
|
return vec3(0.0);
|
||
|
#endif
|
||
|
}vec3 getIBLRadiance(const in vec3 viewDir,const in vec3 normal,const in float roughness){
|
||
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
|
vec3 reflectVec=reflect(-viewDir,normal);reflectVec=normalize(mix(reflectVec,normal,roughness*roughness));reflectVec=inverseTransformDirection(reflectVec,viewMatrix);vec4 envMapColor=textureCubeUV(envMap,reflectVec,roughness);return envMapColor.rgb*envMapIntensity;
|
||
|
#else
|
||
|
return vec3(0.0);
|
||
|
#endif
|
||
|
}
|
||
|
#ifdef USE_ANISOTROPY
|
||
|
vec3 getIBLAnisotropyRadiance(const in vec3 viewDir,const in vec3 normal,const in float roughness,const in vec3 bitangent,const in float anisotropy){
|
||
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
||
|
vec3 bentNormal=cross(bitangent,viewDir);bentNormal=normalize(cross(bentNormal,bitangent));bentNormal=normalize(mix(bentNormal,normal,pow2(pow2(1.0-anisotropy*(1.0-roughness)))));return getIBLRadiance(viewDir,bentNormal,roughness);
|
||
|
#else
|
||
|
return vec3(0.0);
|
||
|
#endif
|
||
|
}
|
||
|
#endif
|
||
|
#endif`,iz=`varying vec3 vViewPosition;struct ToonMaterial{vec3 diffuseColor;};void RE_Direct_Toon(const in IncidentLight directLight,const in GeometricContext geometry,const in ToonMaterial material,inout ReflectedLight reflectedLight){vec3 irradiance=getGradientIrradiance(geometry.normal,directLight.direction)*directLight.color;reflectedLight.directDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Toon(const in vec3 irradiance,const in GeometricContext geometry,const in ToonMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}
|
||
|
#define RE_Direct RE_Direct_Toon
|
||
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,iF=`varying vec3 vViewPosition;struct BlinnPhongMaterial{vec3 diffuseColor;vec3 specularColor;float specularShininess;float specularStrength;};void RE_Direct_BlinnPhong(const in IncidentLight directLight,const in GeometricContext geometry,const in BlinnPhongMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color;reflectedLight.directDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);reflectedLight.directSpecular+=irradiance*BRDF_BlinnPhong(directLight.direction,geometry.viewDir,geometry.normal,material.specularColor,material.specularShininess)*material.specularStrength;}void RE_IndirectDiffuse_BlinnPhong(const in vec3 irradiance,const in GeometricContext geometry,const in BlinnPhongMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}
|
||
|
#define RE_Direct RE_Direct_BlinnPhong
|
||
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ik=`PhysicalMaterial material;material.diffuseColor=diffuseColor.rgb*(1.0-metalnessFactor);vec3 dxy=max(abs(dFdx(geometryNormal)),abs(dFdy(geometryNormal)));float geometryRoughness=max(max(dxy.x,dxy.y),dxy.z);material.roughness=max(roughnessFactor,0.0525);material.roughness+=geometryRoughness;material.roughness=min(material.roughness,1.0);
|
||
|
#ifdef IOR
|
||
|
material.ior=ior;
|
||
|
#ifdef USE_SPECULAR
|
||
|
float specularIntensityFactor=specularIntensity;vec3 specularColorFactor=specularColor;
|
||
|
#ifdef USE_SPECULAR_COLORMAP
|
||
|
specularColorFactor*=texture2D(specularColorMap,vSpecularColorMapUv).rgb;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
|
specularIntensityFactor*=texture2D(specularIntensityMap,vSpecularIntensityMapUv).a;
|
||
|
#endif
|
||
|
material.specularF90=mix(specularIntensityFactor,1.0,metalnessFactor);
|
||
|
#else
|
||
|
float specularIntensityFactor=1.0;vec3 specularColorFactor=vec3(1.0);material.specularF90=1.0;
|
||
|
#endif
|
||
|
material.specularColor=mix(min(pow2((material.ior-1.0)/(material.ior+1.0))*specularColorFactor,vec3(1.0))*specularIntensityFactor,diffuseColor.rgb,metalnessFactor);
|
||
|
#else
|
||
|
material.specularColor=mix(vec3(0.04),diffuseColor.rgb,metalnessFactor);material.specularF90=1.0;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
material.clearcoat=clearcoat;material.clearcoatRoughness=clearcoatRoughness;material.clearcoatF0=vec3(0.04);material.clearcoatF90=1.0;
|
||
|
#ifdef USE_CLEARCOATMAP
|
||
|
material.clearcoat*=texture2D(clearcoatMap,vClearcoatMapUv).x;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
|
material.clearcoatRoughness*=texture2D(clearcoatRoughnessMap,vClearcoatRoughnessMapUv).y;
|
||
|
#endif
|
||
|
material.clearcoat=saturate(material.clearcoat);material.clearcoatRoughness=max(material.clearcoatRoughness,0.0525);material.clearcoatRoughness+=geometryRoughness;material.clearcoatRoughness=min(material.clearcoatRoughness,1.0);
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCE
|
||
|
material.iridescence=iridescence;material.iridescenceIOR=iridescenceIOR;
|
||
|
#ifdef USE_IRIDESCENCEMAP
|
||
|
material.iridescence*=texture2D(iridescenceMap,vIridescenceMapUv).r;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
|
material.iridescenceThickness=(iridescenceThicknessMaximum-iridescenceThicknessMinimum)*texture2D(iridescenceThicknessMap,vIridescenceThicknessMapUv).g+iridescenceThicknessMinimum;
|
||
|
#else
|
||
|
material.iridescenceThickness=iridescenceThicknessMaximum;
|
||
|
#endif
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN
|
||
|
material.sheenColor=sheenColor;
|
||
|
#ifdef USE_SHEEN_COLORMAP
|
||
|
material.sheenColor*=texture2D(sheenColorMap,vSheenColorMapUv).rgb;
|
||
|
#endif
|
||
|
material.sheenRoughness=clamp(sheenRoughness,0.07,1.0);
|
||
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
|
material.sheenRoughness*=texture2D(sheenRoughnessMap,vSheenRoughnessMapUv).a;
|
||
|
#endif
|
||
|
#endif
|
||
|
#ifdef USE_ANISOTROPY
|
||
|
#ifdef USE_ANISOTROPYMAP
|
||
|
mat2 anisotropyMat=mat2(anisotropyVector.x,anisotropyVector.y,-anisotropyVector.y,anisotropyVector.x);vec3 anisotropyPolar=texture2D(anisotropyMap,vAnisotropyMapUv).rgb;vec2 anisotropyV=anisotropyMat*normalize(2.0*anisotropyPolar.rg-vec2(1.0))*anisotropyPolar.b;
|
||
|
#else
|
||
|
vec2 anisotropyV=anisotropyVector;
|
||
|
#endif
|
||
|
material.anisotropy=length(anisotropyV);anisotropyV/=material.anisotropy;material.anisotropy=saturate(material.anisotropy);material.alphaT=mix(pow2(material.roughness),1.0,pow2(material.anisotropy));material.anisotropyT=tbn[0]*anisotropyV.x-tbn[1]*anisotropyV.y;material.anisotropyB=tbn[1]*anisotropyV.x+tbn[0]*anisotropyV.y;
|
||
|
#endif`,iB=`struct PhysicalMaterial{vec3 diffuseColor;float roughness;vec3 specularColor;float specularF90;
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
float clearcoat;float clearcoatRoughness;vec3 clearcoatF0;float clearcoatF90;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCE
|
||
|
float iridescence;float iridescenceIOR;float iridescenceThickness;vec3 iridescenceFresnel;vec3 iridescenceF0;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN
|
||
|
vec3 sheenColor;float sheenRoughness;
|
||
|
#endif
|
||
|
#ifdef IOR
|
||
|
float ior;
|
||
|
#endif
|
||
|
#ifdef USE_TRANSMISSION
|
||
|
float transmission;float transmissionAlpha;float thickness;float attenuationDistance;vec3 attenuationColor;
|
||
|
#endif
|
||
|
#ifdef USE_ANISOTROPY
|
||
|
float anisotropy;float alphaT;vec3 anisotropyT;vec3 anisotropyB;
|
||
|
#endif
|
||
|
};vec3 clearcoatSpecular=vec3(0.0);vec3 sheenSpecular=vec3(0.0);vec3 Schlick_to_F0(const in vec3 f,const in float f90,const in float dotVH){float x=clamp(1.0-dotVH,0.0,1.0);float x2=x*x;float x5=clamp(x*x2*x2,0.0,0.9999);return(f-vec3(f90)*x5)/(1.0-x5);}float V_GGX_SmithCorrelated(const in float alpha,const in float dotNL,const in float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(const in float alpha,const in float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}
|
||
|
#ifdef USE_ANISOTROPY
|
||
|
float V_GGX_SmithCorrelated_Anisotropic(const in float alphaT,const in float alphaB,const in float dotTV,const in float dotBV,const in float dotTL,const in float dotBL,const in float dotNV,const in float dotNL){float gv=dotNL*length(vec3(alphaT*dotTV,alphaB*dotBV,dotNV));float gl=dotNV*length(vec3(alphaT*dotTL,alphaB*dotBL,dotNL));float v=0.5/(gv+gl);return saturate(v);}float D_GGX_Anisotropic(const in float alphaT,const in float alphaB,const in float dotNH,const in float dotTH,const in float dotBH){float a2=alphaT*alphaB;highp vec3 v=vec3(alphaB*dotTH,alphaT*dotBH,a2*dotNH);highp float v2=dot(v,v);float w2=a2/v2;return RECIPROCAL_PI*a2*pow2(w2);}
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
vec3 BRDF_GGX_Clearcoat(const in vec3 lightDir,const in vec3 viewDir,const in vec3 normal,const in PhysicalMaterial material){vec3 f0=material.clearcoatF0;float f90=material.clearcoatF90;float roughness=material.clearcoatRoughness;float alpha=pow2(roughness);vec3 halfDir=normalize(lightDir+viewDir);float dotNL=saturate(dot(normal,lightDir));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotVH=saturate(dot(viewDir,halfDir));vec3 F=F_Schlick(f0,f90,dotVH);float V=V_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(V*D);}
|
||
|
#endif
|
||
|
vec3 BRDF_GGX(const in vec3 lightDir,const in vec3 viewDir,const in vec3 normal,const in PhysicalMaterial material){vec3 f0=material.specularColor;float f90=material.specularF90;float roughness=material.roughness;float alpha=pow2(roughness);vec3 halfDir=normalize(lightDir+viewDir);float dotNL=saturate(dot(normal,lightDir));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotVH=saturate(dot(viewDir,halfDir));vec3 F=F_Schlick(f0,f90,dotVH);
|
||
|
#ifdef USE_IRIDESCENCE
|
||
|
F=mix(F,material.iridescenceFresnel,material.iridescence);
|
||
|
#endif
|
||
|
#ifdef USE_ANISOTROPY
|
||
|
float dotTL=dot(material.anisotropyT,lightDir);float dotTV=dot(material.anisotropyT,viewDir);float dotTH=dot(material.anisotropyT,halfDir);float dotBL=dot(material.anisotropyB,lightDir);float dotBV=dot(material.anisotropyB,viewDir);float dotBH=dot(material.anisotropyB,halfDir);float V=V_GGX_SmithCorrelated_Anisotropic(material.alphaT,alpha,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);float D=D_GGX_Anisotropic(material.alphaT,alpha,dotNH,dotTH,dotBH);
|
||
|
#else
|
||
|
float V=V_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);
|
||
|
#endif
|
||
|
return F*(V*D);}vec2 LTC_Uv(const in vec3 N,const in vec3 V,const in float roughness){const float LUT_SIZE=64.0;const float LUT_SCALE=(LUT_SIZE-1.0)/LUT_SIZE;const float LUT_BIAS=0.5/LUT_SIZE;float dotNV=saturate(dot(N,V));vec2 uv=vec2(roughness,sqrt(1.0-dotNV));uv=uv*LUT_SCALE+LUT_BIAS;return uv;}float LTC_ClippedSphereFormFactor(const in vec3 f){float l=length(f);return max((l*l+f.z)/(l+1.0),0.0);}vec3 LTC_EdgeVectorFormFactor(const in vec3 v1,const in vec3 v2){float x=dot(v1,v2);float y=abs(x);float a=0.8543985+(0.4965155+0.0145206*y)*y;float b=3.4175940+(4.1616724+y)*y;float v=a/b;float theta_sintheta=(x>0.0)?v:0.5*inversesqrt(max(1.0-x*x,1e-7))-v;return cross(v1,v2)*theta_sintheta;}vec3 LTC_Evaluate(const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[4]){vec3 v1=rectCoords[1]-rectCoords[0];vec3 v2=rectCoords[3]-rectCoords[0];vec3 lightNormal=cross(v1,v2);if(dot(lightNormal,P-rectCoords[0])<0.0)return vec3(0.0);vec3 T1,T2;T1=normalize(V-N*dot(V,N));T2=-cross(N,T1);mat3 mat=mInv*transposeMat3(mat3(T1,T2,N));vec3 coords[4];coords[0]=mat*(rectCoords[0]-P);coords[1]=mat*(rectCoords[1]-P);coords[2]=mat*(rectCoords[2]-P);coords[3]=mat*(rectCoords[3]-P);coords[0]=normalize(coords[0]);coords[1]=normalize(coords[1]);coords[2]=normalize(coords[2]);coords[3]=normalize(coords[3]);vec3 vectorFormFactor=vec3(0.0);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[0],coords[1]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[1],coords[2]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[2],coords[3]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[3],coords[0]);float result=LTC_ClippedSphereFormFactor(vectorFormFactor);return vec3(result);}
|
||
|
#if defined(USE_SHEEN)
|
||
|
float D_Charlie(float roughness,float dotNH){float alpha=pow2(roughness);float invAlpha=1.0/alpha;float cos2h=dotNH*dotNH;float sin2h=max(1.0-cos2h,0.0078125);return(2.0+invAlpha)*pow(sin2h,invAlpha*0.5)/(2.0*PI);}float V_Neubelt(float dotNV,float dotNL){return saturate(1.0/(4.0*(dotNL+dotNV-dotNL*dotNV)));}vec3 BRDF_Sheen(const in vec3 lightDir,const in vec3 viewDir,const in vec3 normal,vec3 sheenColor,const in float sheenRoughness){vec3 halfDir=normalize(lightDir+viewDir);float dotNL=saturate(dot(normal,lightDir));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float D=D_Charlie(sheenRoughness,dotNH);float V=V_Neubelt(dotNV,dotNL);return sheenColor*(D*V);}
|
||
|
#endif
|
||
|
float IBLSheenBRDF(const in vec3 normal,const in vec3 viewDir,const in float roughness){float dotNV=saturate(dot(normal,viewDir));float r2=roughness*roughness;float a=roughness<0.25?-339.2*r2+161.4*roughness-25.9:-8.48*r2+14.3*roughness-9.95;float b=roughness<0.25?44.0*r2-23.7*roughness+3.26:1.97*r2-3.27*roughness+0.72;float DG=exp(a*dotNV+b)+(roughness<0.25?0.0:0.1*(roughness-0.25));return saturate(DG*RECIPROCAL_PI);}vec2 DFGApprox(const in vec3 normal,const in vec3 viewDir,const in float roughness){float dotNV=saturate(dot(normal,viewDir));const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 fab=vec2(-1.04,1.04)*a004+r.zw;return fab;}vec3 EnvironmentBRDF(const in vec3 normal,const in vec3 viewDir,const in vec3 specularColor,const in float specularF90,const in float roughness){vec2 fab=DFGApprox(normal,viewDir,roughness);return specularColor*fab.x+specularF90*fab.y;}
|
||
|
#ifdef USE_IRIDESCENCE
|
||
|
void computeMultiscatteringIridescence(const in vec3 normal,const in vec3 viewDir,const in vec3 specularColor,const in float specularF90,const in float iridescence,const in vec3 iridescenceF0,const in float roughness,inout vec3 singleScatter,inout vec3 multiScatter){
|
||
|
#else
|
||
|
void computeMultiscattering(const in vec3 normal,const in vec3 viewDir,const in vec3 specularColor,const in float specularF90,const in float roughness,inout vec3 singleScatter,inout vec3 multiScatter){
|
||
|
#endif
|
||
|
vec2 fab=DFGApprox(normal,viewDir,roughness);
|
||
|
#ifdef USE_IRIDESCENCE
|
||
|
vec3 Fr=mix(specularColor,iridescenceF0,iridescence);
|
||
|
#else
|
||
|
vec3 Fr=specularColor;
|
||
|
#endif
|
||
|
vec3 FssEss=Fr*fab.x+specularF90*fab.y;float Ess=fab.x+fab.y;float Ems=1.0-Ess;vec3 Favg=Fr+(1.0-Fr)*0.047619;vec3 Fms=FssEss*Favg/(1.0-Ems*Favg);singleScatter+=FssEss;multiScatter+=Fms*Ems;}
|
||
|
#if NUM_RECT_AREA_LIGHTS>0
|
||
|
void RE_Direct_RectArea_Physical(const in RectAreaLight rectAreaLight,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){vec3 normal=geometry.normal;vec3 viewDir=geometry.viewDir;vec3 position=geometry.position;vec3 lightPos=rectAreaLight.position;vec3 halfWidth=rectAreaLight.halfWidth;vec3 halfHeight=rectAreaLight.halfHeight;vec3 lightColor=rectAreaLight.color;float roughness=material.roughness;vec3 rectCoords[4];rectCoords[0]=lightPos+halfWidth-halfHeight;rectCoords[1]=lightPos-halfWidth-halfHeight;rectCoords[2]=lightPos-halfWidth+halfHeight;rectCoords[3]=lightPos+halfWidth+halfHeight;vec2 uv=LTC_Uv(normal,viewDir,roughness);vec4 t1=texture2D(ltc_1,uv);vec4 t2=texture2D(ltc_2,uv);mat3 mInv=mat3(vec3(t1.x,0,t1.y),vec3(0,1,0),vec3(t1.z,0,t1.w));vec3 fresnel=(material.specularColor*t2.x+(vec3(1.0)-material.specularColor)*t2.y);reflectedLight.directSpecular+=lightColor*fresnel*LTC_Evaluate(normal,viewDir,position,mInv,rectCoords);reflectedLight.directDiffuse+=lightColor*material.diffuseColor*LTC_Evaluate(normal,viewDir,position,mat3(1.0),rectCoords);}
|
||
|
#endif
|
||
|
void RE_Direct_Physical(const in IncidentLight directLight,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color;
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
float dotNLcc=saturate(dot(geometry.clearcoatNormal,directLight.direction));vec3 ccIrradiance=dotNLcc*directLight.color;clearcoatSpecular+=ccIrradiance*BRDF_GGX_Clearcoat(directLight.direction,geometry.viewDir,geometry.clearcoatNormal,material);
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN
|
||
|
sheenSpecular+=irradiance*BRDF_Sheen(directLight.direction,geometry.viewDir,geometry.normal,material.sheenColor,material.sheenRoughness);
|
||
|
#endif
|
||
|
reflectedLight.directSpecular+=irradiance*BRDF_GGX(directLight.direction,geometry.viewDir,geometry.normal,material);reflectedLight.directDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Physical(const in vec3 irradiance,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}void 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){
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
clearcoatSpecular+=clearcoatRadiance*EnvironmentBRDF(geometry.clearcoatNormal,geometry.viewDir,material.clearcoatF0,material.clearcoatF90,material.clearcoatRoughness);
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN
|
||
|
sheenSpecular+=irradiance*material.sheenColor*IBLSheenBRDF(geometry.normal,geometry.viewDir,material.sheenRoughness);
|
||
|
#endif
|
||
|
vec3 singleScattering=vec3(0.0);vec3 multiScattering=vec3(0.0);vec3 cosineWeightedIrradiance=irradiance*RECIPROCAL_PI;
|
||
|
#ifdef USE_IRIDESCENCE
|
||
|
computeMultiscatteringIridescence(geometry.normal,geometry.viewDir,material.specularColor,material.specularF90,material.iridescence,material.iridescenceFresnel,material.roughness,singleScattering,multiScattering);
|
||
|
#else
|
||
|
computeMultiscattering(geometry.normal,geometry.viewDir,material.specularColor,material.specularF90,material.roughness,singleScattering,multiScattering);
|
||
|
#endif
|
||
|
vec3 totalScattering=singleScattering+multiScattering;vec3 diffuse=material.diffuseColor*(1.0-max(max(totalScattering.r,totalScattering.g),totalScattering.b));reflectedLight.indirectSpecular+=radiance*singleScattering;reflectedLight.indirectSpecular+=multiScattering*cosineWeightedIrradiance;reflectedLight.indirectDiffuse+=diffuse*cosineWeightedIrradiance;}
|
||
|
#define RE_Direct RE_Direct_Physical
|
||
|
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
||
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
||
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
||
|
float computeSpecularOcclusion(const in float dotNV,const in float ambientOcclusion,const in float roughness){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}`,iH=`GeometricContext geometry;geometry.position=-vViewPosition;geometry.normal=normal;geometry.viewDir=(isOrthographic)?vec3(0,0,1):normalize(vViewPosition);
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
geometry.clearcoatNormal=clearcoatNormal;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCE
|
||
|
float dotNVi=saturate(dot(normal,geometry.viewDir));if(material.iridescenceThickness==0.0){material.iridescence=0.0;}else{material.iridescence=saturate(material.iridescence);}if(material.iridescence>0.0){material.iridescenceFresnel=evalIridescence(1.0,material.iridescenceIOR,dotNVi,material.iridescenceThickness,material.specularColor);material.iridescenceF0=Schlick_to_F0(material.iridescenceFresnel,1.0,dotNVi);}
|
||
|
#endif
|
||
|
IncidentLight directLight;
|
||
|
#if (NUM_POINT_LIGHTS>0)&&defined(RE_Direct)
|
||
|
PointLight pointLight;
|
||
|
#if defined(USE_SHADOWMAP)&&NUM_POINT_LIGHT_SHADOWS>0
|
||
|
PointLightShadow pointLightShadow;
|
||
|
#endif
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_POINT_LIGHTS;i++){pointLight=pointLights[i];getPointLightInfo(pointLight,geometry,directLight);
|
||
|
#if defined(USE_SHADOWMAP)&&(UNROLLED_LOOP_INDEX<NUM_POINT_LIGHT_SHADOWS)
|
||
|
pointLightShadow=pointLightShadows[i];directLight.color*=(directLight.visible&&receiveShadow)?getPointShadow(pointShadowMap[i],pointLightShadow.shadowMapSize,pointLightShadow.shadowBias,pointLightShadow.shadowRadius,vPointShadowCoord[i],pointLightShadow.shadowCameraNear,pointLightShadow.shadowCameraFar):1.0;
|
||
|
#endif
|
||
|
RE_Direct(directLight,geometry,material,reflectedLight);}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#if (NUM_SPOT_LIGHTS>0)&&defined(RE_Direct)
|
||
|
SpotLight spotLight;vec4 spotColor;vec3 spotLightCoord;bool inSpotLightMap;
|
||
|
#if defined(USE_SHADOWMAP)&&NUM_SPOT_LIGHT_SHADOWS>0
|
||
|
SpotLightShadow spotLightShadow;
|
||
|
#endif
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_SPOT_LIGHTS;i++){spotLight=spotLights[i];getSpotLightInfo(spotLight,geometry,directLight);
|
||
|
#if (UNROLLED_LOOP_INDEX<NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS)
|
||
|
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
||
|
#elif (UNROLLED_LOOP_INDEX<NUM_SPOT_LIGHT_SHADOWS)
|
||
|
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
||
|
#else
|
||
|
#define SPOT_LIGHT_MAP_INDEX(UNROLLED_LOOP_INDEX-NUM_SPOT_LIGHT_SHADOWS+NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS)
|
||
|
#endif
|
||
|
#if (SPOT_LIGHT_MAP_INDEX<NUM_SPOT_LIGHT_MAPS)
|
||
|
spotLightCoord=vSpotLightCoord[i].xyz/vSpotLightCoord[i].w;inSpotLightMap=all(lessThan(abs(spotLightCoord*2.-1.),vec3(1.0)));spotColor=texture2D(spotLightMap[SPOT_LIGHT_MAP_INDEX],spotLightCoord.xy);directLight.color=inSpotLightMap?directLight.color*spotColor.rgb:directLight.color;
|
||
|
#endif
|
||
|
#undef SPOT_LIGHT_MAP_INDEX
|
||
|
#if defined(USE_SHADOWMAP)&&(UNROLLED_LOOP_INDEX<NUM_SPOT_LIGHT_SHADOWS)
|
||
|
spotLightShadow=spotLightShadows[i];directLight.color*=(directLight.visible&&receiveShadow)?getShadow(spotShadowMap[i],spotLightShadow.shadowMapSize,spotLightShadow.shadowBias,spotLightShadow.shadowRadius,vSpotLightCoord[i]):1.0;
|
||
|
#endif
|
||
|
RE_Direct(directLight,geometry,material,reflectedLight);}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#if (NUM_DIR_LIGHTS>0)&&defined(RE_Direct)
|
||
|
DirectionalLight directionalLight;
|
||
|
#if defined(USE_SHADOWMAP)&&NUM_DIR_LIGHT_SHADOWS>0
|
||
|
DirectionalLightShadow directionalLightShadow;
|
||
|
#endif
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_DIR_LIGHTS;i++){directionalLight=directionalLights[i];getDirectionalLightInfo(directionalLight,geometry,directLight);
|
||
|
#if defined(USE_SHADOWMAP)&&(UNROLLED_LOOP_INDEX<NUM_DIR_LIGHT_SHADOWS)
|
||
|
directionalLightShadow=directionalLightShadows[i];directLight.color*=(directLight.visible&&receiveShadow)?getShadow(directionalShadowMap[i],directionalLightShadow.shadowMapSize,directionalLightShadow.shadowBias,directionalLightShadow.shadowRadius,vDirectionalShadowCoord[i]):1.0;
|
||
|
#endif
|
||
|
RE_Direct(directLight,geometry,material,reflectedLight);}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#if (NUM_RECT_AREA_LIGHTS>0)&&defined(RE_Direct_RectArea)
|
||
|
RectAreaLight rectAreaLight;
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_RECT_AREA_LIGHTS;i++){rectAreaLight=rectAreaLights[i];RE_Direct_RectArea(rectAreaLight,geometry,material,reflectedLight);}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#if defined(RE_IndirectDiffuse)
|
||
|
vec3 iblIrradiance=vec3(0.0);vec3 irradiance=getAmbientLightIrradiance(ambientLightColor);irradiance+=getLightProbeIrradiance(lightProbe,geometry.normal);
|
||
|
#if (NUM_HEMI_LIGHTS>0)
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_HEMI_LIGHTS;i++){irradiance+=getHemisphereLightIrradiance(hemisphereLights[i],geometry.normal);}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#endif
|
||
|
#if defined(RE_IndirectSpecular)
|
||
|
vec3 radiance=vec3(0.0);vec3 clearcoatRadiance=vec3(0.0);
|
||
|
#endif`,iV=`#if defined(RE_IndirectDiffuse)
|
||
|
#ifdef USE_LIGHTMAP
|
||
|
vec4 lightMapTexel=texture2D(lightMap,vLightMapUv);vec3 lightMapIrradiance=lightMapTexel.rgb*lightMapIntensity;irradiance+=lightMapIrradiance;
|
||
|
#endif
|
||
|
#if defined(USE_ENVMAP)&&defined(STANDARD)&&defined(ENVMAP_TYPE_CUBE_UV)
|
||
|
iblIrradiance+=getIBLIrradiance(geometry.normal);
|
||
|
#endif
|
||
|
#endif
|
||
|
#if defined(USE_ENVMAP)&&defined(RE_IndirectSpecular)
|
||
|
#ifdef USE_ANISOTROPY
|
||
|
radiance+=getIBLAnisotropyRadiance(geometry.viewDir,geometry.normal,material.roughness,material.anisotropyB,material.anisotropy);
|
||
|
#else
|
||
|
radiance+=getIBLRadiance(geometry.viewDir,geometry.normal,material.roughness);
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
clearcoatRadiance+=getIBLRadiance(geometry.viewDir,geometry.clearcoatNormal,material.clearcoatRoughness);
|
||
|
#endif
|
||
|
#endif`,iG=`#if defined(RE_IndirectDiffuse)
|
||
|
RE_IndirectDiffuse(irradiance,geometry,material,reflectedLight);
|
||
|
#endif
|
||
|
#if defined(RE_IndirectSpecular)
|
||
|
RE_IndirectSpecular(radiance,iblIrradiance,clearcoatRadiance,geometry,material,reflectedLight);
|
||
|
#endif`,iW=`#if defined(USE_LOGDEPTHBUF)&&defined(USE_LOGDEPTHBUF_EXT)
|
||
|
gl_FragDepthEXT=vIsPerspective==0.0?gl_FragCoord.z:log2(vFragDepth)*logDepthBufFC*0.5;
|
||
|
#endif`,ij=`#if defined(USE_LOGDEPTHBUF)&&defined(USE_LOGDEPTHBUF_EXT)
|
||
|
uniform float logDepthBufFC;varying float vFragDepth;varying float vIsPerspective;
|
||
|
#endif`,iq=`#ifdef USE_LOGDEPTHBUF
|
||
|
#ifdef USE_LOGDEPTHBUF_EXT
|
||
|
varying float vFragDepth;varying float vIsPerspective;
|
||
|
#else
|
||
|
uniform float logDepthBufFC;
|
||
|
#endif
|
||
|
#endif`,iX=`#ifdef USE_LOGDEPTHBUF
|
||
|
#ifdef USE_LOGDEPTHBUF_EXT
|
||
|
vFragDepth=1.0+gl_Position.w;vIsPerspective=float(isPerspectiveMatrix(projectionMatrix));
|
||
|
#else
|
||
|
if(isPerspectiveMatrix(projectionMatrix)){gl_Position.z=log2(max(EPSILON,gl_Position.w+1.0))*logDepthBufFC-1.0;gl_Position.z*=gl_Position.w;}
|
||
|
#endif
|
||
|
#endif`,iY=`#ifdef USE_MAP
|
||
|
vec4 sampledDiffuseColor=texture2D(map,vMapUv);
|
||
|
#ifdef DECODE_VIDEO_TEXTURE
|
||
|
sampledDiffuseColor=vec4(mix(pow(sampledDiffuseColor.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),sampledDiffuseColor.rgb*0.0773993808,vec3(lessThanEqual(sampledDiffuseColor.rgb,vec3(0.04045)))),sampledDiffuseColor.w);
|
||
|
#endif
|
||
|
diffuseColor*=sampledDiffuseColor;
|
||
|
#endif`,iZ=`#ifdef USE_MAP
|
||
|
uniform sampler2D map;
|
||
|
#endif`,iK=`#if defined(USE_MAP)||defined(USE_ALPHAMAP)
|
||
|
#if defined(USE_POINTS_UV)
|
||
|
vec2 uv=vUv;
|
||
|
#else
|
||
|
vec2 uv=(uvTransform*vec3(gl_PointCoord.x,1.0-gl_PointCoord.y,1)).xy;
|
||
|
#endif
|
||
|
#endif
|
||
|
#ifdef USE_MAP
|
||
|
diffuseColor*=texture2D(map,uv);
|
||
|
#endif
|
||
|
#ifdef USE_ALPHAMAP
|
||
|
diffuseColor.a*=texture2D(alphaMap,uv).g;
|
||
|
#endif`,iJ=`#if defined(USE_POINTS_UV)
|
||
|
varying vec2 vUv;
|
||
|
#else
|
||
|
#if defined(USE_MAP)||defined(USE_ALPHAMAP)
|
||
|
uniform mat3 uvTransform;
|
||
|
#endif
|
||
|
#endif
|
||
|
#ifdef USE_MAP
|
||
|
uniform sampler2D map;
|
||
|
#endif
|
||
|
#ifdef USE_ALPHAMAP
|
||
|
uniform sampler2D alphaMap;
|
||
|
#endif`,iQ=`float metalnessFactor=metalness;
|
||
|
#ifdef USE_METALNESSMAP
|
||
|
vec4 texelMetalness=texture2D(metalnessMap,vMetalnessMapUv);metalnessFactor*=texelMetalness.b;
|
||
|
#endif`,i$=`#ifdef USE_METALNESSMAP
|
||
|
uniform sampler2D metalnessMap;
|
||
|
#endif`,i0=`#if defined(USE_MORPHCOLORS)&&defined(MORPHTARGETS_TEXTURE)
|
||
|
vColor*=morphTargetBaseInfluence;for(int i=0;i<MORPHTARGETS_COUNT;i++){
|
||
|
#if defined(USE_COLOR_ALPHA)
|
||
|
if(morphTargetInfluences[i]!=0.0)vColor+=getMorph(gl_VertexID,i,2)*morphTargetInfluences[i];
|
||
|
#elif defined(USE_COLOR)
|
||
|
if(morphTargetInfluences[i]!=0.0)vColor+=getMorph(gl_VertexID,i,2).rgb*morphTargetInfluences[i];
|
||
|
#endif
|
||
|
}
|
||
|
#endif`,i1=`#ifdef USE_MORPHNORMALS
|
||
|
objectNormal*=morphTargetBaseInfluence;
|
||
|
#ifdef MORPHTARGETS_TEXTURE
|
||
|
for(int i=0;i<MORPHTARGETS_COUNT;i++){if(morphTargetInfluences[i]!=0.0)objectNormal+=getMorph(gl_VertexID,i,1).xyz*morphTargetInfluences[i];}
|
||
|
#else
|
||
|
objectNormal+=morphNormal0*morphTargetInfluences[0];objectNormal+=morphNormal1*morphTargetInfluences[1];objectNormal+=morphNormal2*morphTargetInfluences[2];objectNormal+=morphNormal3*morphTargetInfluences[3];
|
||
|
#endif
|
||
|
#endif`,i3=`#ifdef USE_MORPHTARGETS
|
||
|
uniform float morphTargetBaseInfluence;
|
||
|
#ifdef MORPHTARGETS_TEXTURE
|
||
|
uniform float morphTargetInfluences[MORPHTARGETS_COUNT];uniform sampler2DArray morphTargetsTexture;uniform ivec2 morphTargetsTextureSize;vec4 getMorph(const in int vertexIndex,const in int morphTargetIndex,const in int offset){int texelIndex=vertexIndex*MORPHTARGETS_TEXTURE_STRIDE+offset;int y=texelIndex/morphTargetsTextureSize.x;int x=texelIndex-y*morphTargetsTextureSize.x;ivec3 morphUV=ivec3(x,y,morphTargetIndex);return texelFetch(morphTargetsTexture,morphUV,0);}
|
||
|
#else
|
||
|
#ifndef USE_MORPHNORMALS
|
||
|
uniform float morphTargetInfluences[8];
|
||
|
#else
|
||
|
uniform float morphTargetInfluences[4];
|
||
|
#endif
|
||
|
#endif
|
||
|
#endif`,i2=`#ifdef USE_MORPHTARGETS
|
||
|
transformed*=morphTargetBaseInfluence;
|
||
|
#ifdef MORPHTARGETS_TEXTURE
|
||
|
for(int i=0;i<MORPHTARGETS_COUNT;i++){if(morphTargetInfluences[i]!=0.0)transformed+=getMorph(gl_VertexID,i,0).xyz*morphTargetInfluences[i];}
|
||
|
#else
|
||
|
transformed+=morphTarget0*morphTargetInfluences[0];transformed+=morphTarget1*morphTargetInfluences[1];transformed+=morphTarget2*morphTargetInfluences[2];transformed+=morphTarget3*morphTargetInfluences[3];
|
||
|
#ifndef USE_MORPHNORMALS
|
||
|
transformed+=morphTarget4*morphTargetInfluences[4];transformed+=morphTarget5*morphTargetInfluences[5];transformed+=morphTarget6*morphTargetInfluences[6];transformed+=morphTarget7*morphTargetInfluences[7];
|
||
|
#endif
|
||
|
#endif
|
||
|
#endif`,i4=`float faceDirection=gl_FrontFacing?1.0:-1.0;
|
||
|
#ifdef FLAT_SHADED
|
||
|
vec3 fdx=dFdx(vViewPosition);vec3 fdy=dFdy(vViewPosition);vec3 normal=normalize(cross(fdx,fdy));
|
||
|
#else
|
||
|
vec3 normal=normalize(vNormal);
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
normal*=faceDirection;
|
||
|
#endif
|
||
|
#endif
|
||
|
#if defined(USE_NORMALMAP_TANGENTSPACE)||defined(USE_CLEARCOAT_NORMALMAP)||defined(USE_ANISOTROPY)
|
||
|
#ifdef USE_TANGENT
|
||
|
mat3 tbn=mat3(normalize(vTangent),normalize(vBitangent),normal);
|
||
|
#else
|
||
|
mat3 tbn=getTangentFrame(-vViewPosition,normal,
|
||
|
#if defined(USE_NORMALMAP)
|
||
|
vNormalMapUv
|
||
|
#elif defined(USE_CLEARCOAT_NORMALMAP)
|
||
|
vClearcoatNormalMapUv
|
||
|
#else
|
||
|
vUv
|
||
|
#endif
|
||
|
);
|
||
|
#endif
|
||
|
#if defined(DOUBLE_SIDED)&&!defined(FLAT_SHADED)
|
||
|
tbn[0]*=faceDirection;tbn[1]*=faceDirection;
|
||
|
#endif
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
|
#ifdef USE_TANGENT
|
||
|
mat3 tbn2=mat3(normalize(vTangent),normalize(vBitangent),normal);
|
||
|
#else
|
||
|
mat3 tbn2=getTangentFrame(-vViewPosition,normal,vClearcoatNormalMapUv);
|
||
|
#endif
|
||
|
#if defined(DOUBLE_SIDED)&&!defined(FLAT_SHADED)
|
||
|
tbn2[0]*=faceDirection;tbn2[1]*=faceDirection;
|
||
|
#endif
|
||
|
#endif
|
||
|
vec3 geometryNormal=normal;`,i5=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
||
|
normal=texture2D(normalMap,vNormalMapUv).xyz*2.0-1.0;
|
||
|
#ifdef FLIP_SIDED
|
||
|
normal=-normal;
|
||
|
#endif
|
||
|
#ifdef DOUBLE_SIDED
|
||
|
normal=normal*faceDirection;
|
||
|
#endif
|
||
|
normal=normalize(normalMatrix*normal);
|
||
|
#elif defined(USE_NORMALMAP_TANGENTSPACE)
|
||
|
vec3 mapN=texture2D(normalMap,vNormalMapUv).xyz*2.0-1.0;mapN.xy*=normalScale;normal=normalize(tbn*mapN);
|
||
|
#elif defined(USE_BUMPMAP)
|
||
|
normal=perturbNormalArb(-vViewPosition,normal,dHdxy_fwd(),faceDirection);
|
||
|
#endif`,i6=`#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#ifdef USE_TANGENT
|
||
|
varying vec3 vTangent;varying vec3 vBitangent;
|
||
|
#endif
|
||
|
#endif`,i8=`#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#ifdef USE_TANGENT
|
||
|
varying vec3 vTangent;varying vec3 vBitangent;
|
||
|
#endif
|
||
|
#endif`,i7=`#ifndef FLAT_SHADED
|
||
|
vNormal=normalize(transformedNormal);
|
||
|
#ifdef USE_TANGENT
|
||
|
vTangent=normalize(transformedTangent);vBitangent=normalize(cross(vNormal,vTangent)*tangent.w);
|
||
|
#endif
|
||
|
#endif`,i9=`#ifdef USE_NORMALMAP
|
||
|
uniform sampler2D normalMap;uniform vec2 normalScale;
|
||
|
#endif
|
||
|
#ifdef USE_NORMALMAP_OBJECTSPACE
|
||
|
uniform mat3 normalMatrix;
|
||
|
#endif
|
||
|
#if !defined(USE_TANGENT)&&(defined(USE_NORMALMAP_TANGENTSPACE)||defined(USE_CLEARCOAT_NORMALMAP)||defined(USE_ANISOTROPY))
|
||
|
mat3 getTangentFrame(vec3 eye_pos,vec3 surf_norm,vec2 uv){vec3 q0=dFdx(eye_pos.xyz);vec3 q1=dFdy(eye_pos.xyz);vec2 st0=dFdx(uv.st);vec2 st1=dFdy(uv.st);vec3 N=surf_norm;vec3 q1perp=cross(q1,N);vec3 q0perp=cross(N,q0);vec3 T=q1perp*st0.x+q0perp*st1.x;vec3 B=q1perp*st0.y+q0perp*st1.y;float det=max(dot(T,T),dot(B,B));float scale=(det==0.0)?0.0:inversesqrt(det);return mat3(T*scale,B*scale,N);}
|
||
|
#endif`,re=`#ifdef USE_CLEARCOAT
|
||
|
vec3 clearcoatNormal=geometryNormal;
|
||
|
#endif`,rt=`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
|
vec3 clearcoatMapN=texture2D(clearcoatNormalMap,vClearcoatNormalMapUv).xyz*2.0-1.0;clearcoatMapN.xy*=clearcoatNormalScale;clearcoatNormal=normalize(tbn2*clearcoatMapN);
|
||
|
#endif`,ri=`#ifdef USE_CLEARCOATMAP
|
||
|
uniform sampler2D clearcoatMap;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
|
uniform sampler2D clearcoatNormalMap;uniform vec2 clearcoatNormalScale;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
|
uniform sampler2D clearcoatRoughnessMap;
|
||
|
#endif`,rr=`#ifdef USE_IRIDESCENCEMAP
|
||
|
uniform sampler2D iridescenceMap;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
|
uniform sampler2D iridescenceThicknessMap;
|
||
|
#endif`,ra=`#ifdef OPAQUE
|
||
|
diffuseColor.a=1.0;
|
||
|
#endif
|
||
|
#ifdef USE_TRANSMISSION
|
||
|
diffuseColor.a*=material.transmissionAlpha;
|
||
|
#endif
|
||
|
gl_FragColor=vec4(outgoingLight,diffuseColor.a);`,rn=`#ifdef PREMULTIPLIED_ALPHA
|
||
|
gl_FragColor.rgb*=gl_FragColor.a;
|
||
|
#endif`,rs=`vec4 mvPosition=vec4(transformed,1.0);
|
||
|
#ifdef USE_INSTANCING
|
||
|
mvPosition=instanceMatrix*mvPosition;
|
||
|
#endif
|
||
|
mvPosition=modelViewMatrix*mvPosition;gl_Position=projectionMatrix*mvPosition;`,ro=`#ifdef DITHERING
|
||
|
gl_FragColor.rgb=dithering(gl_FragColor.rgb);
|
||
|
#endif`,rl=`#ifdef DITHERING
|
||
|
vec3 dithering(vec3 color){float grid_position=rand(gl_FragCoord.xy);vec3 dither_shift_RGB=vec3(0.25/255.0,-0.25/255.0,0.25/255.0);dither_shift_RGB=mix(2.0*dither_shift_RGB,-2.0*dither_shift_RGB,grid_position);return color+dither_shift_RGB;}
|
||
|
#endif`,rh=`float roughnessFactor=roughness;
|
||
|
#ifdef USE_ROUGHNESSMAP
|
||
|
vec4 texelRoughness=texture2D(roughnessMap,vRoughnessMapUv);roughnessFactor*=texelRoughness.g;
|
||
|
#endif`,rc=`#ifdef USE_ROUGHNESSMAP
|
||
|
uniform sampler2D roughnessMap;
|
||
|
#endif`,ru=`#if NUM_SPOT_LIGHT_COORDS>0
|
||
|
varying vec4 vSpotLightCoord[NUM_SPOT_LIGHT_COORDS];
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHT_MAPS>0
|
||
|
uniform sampler2D spotLightMap[NUM_SPOT_LIGHT_MAPS];
|
||
|
#endif
|
||
|
#ifdef USE_SHADOWMAP
|
||
|
#if NUM_DIR_LIGHT_SHADOWS>0
|
||
|
uniform sampler2D directionalShadowMap[NUM_DIR_LIGHT_SHADOWS];varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];struct DirectionalLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHT_SHADOWS>0
|
||
|
uniform sampler2D spotShadowMap[NUM_SPOT_LIGHT_SHADOWS];struct SpotLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHT_SHADOWS>0
|
||
|
uniform sampler2D pointShadowMap[NUM_POINT_LIGHT_SHADOWS];varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];struct PointLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;float shadowCameraNear;float shadowCameraFar;};uniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];
|
||
|
#endif
|
||
|
float texture2DCompare(sampler2D depths,vec2 uv,float compare){return step(compare,unpackRGBAToDepth(texture2D(depths,uv)));}vec2 texture2DDistribution(sampler2D shadow,vec2 uv){return unpackRGBATo2Half(texture2D(shadow,uv));}float VSMShadow(sampler2D shadow,vec2 uv,float compare){float occlusion=1.0;vec2 distribution=texture2DDistribution(shadow,uv);float hard_shadow=step(compare,distribution.x);if(hard_shadow!=1.0){float distance=compare-distribution.x;float variance=max(0.00000,distribution.y*distribution.y);float softness_probability=variance/(variance+distance*distance);softness_probability=clamp((softness_probability-0.3)/(0.95-0.3),0.0,1.0);occlusion=clamp(max(hard_shadow,softness_probability),0.0,1.0);}return occlusion;}float getShadow(sampler2D shadowMap,vec2 shadowMapSize,float shadowBias,float shadowRadius,vec4 shadowCoord){float shadow=1.0;shadowCoord.xyz/=shadowCoord.w;shadowCoord.z+=shadowBias;bool inFrustum=shadowCoord.x>=0.0&&shadowCoord.x<=1.0&&shadowCoord.y>=0.0&&shadowCoord.y<=1.0;bool frustumTest=inFrustum&&shadowCoord.z<=1.0;if(frustumTest){
|
||
|
#if defined(SHADOWMAP_TYPE_PCF)
|
||
|
vec2 texelSize=vec2(1.0)/shadowMapSize;float dx0=-texelSize.x*shadowRadius;float dy0=-texelSize.y*shadowRadius;float dx1=+texelSize.x*shadowRadius;float dy1=+texelSize.y*shadowRadius;float dx2=dx0/2.0;float dy2=dy0/2.0;float dx3=dx1/2.0;float dy3=dy1/2.0;shadow=(texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy,shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,dy1),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy1),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,dy1),shadowCoord.z))*(1.0/17.0);
|
||
|
#elif defined(SHADOWMAP_TYPE_PCF_SOFT)
|
||
|
vec2 texelSize=vec2(1.0)/shadowMapSize;float dx=texelSize.x;float dy=texelSize.y;vec2 uv=shadowCoord.xy;vec2 f=fract(uv*shadowMapSize+0.5);uv-=f*texelSize;shadow=(texture2DCompare(shadowMap,uv,shadowCoord.z)+texture2DCompare(shadowMap,uv+vec2(dx,0.0),shadowCoord.z)+texture2DCompare(shadowMap,uv+vec2(0.0,dy),shadowCoord.z)+texture2DCompare(shadowMap,uv+texelSize,shadowCoord.z)+mix(texture2DCompare(shadowMap,uv+vec2(-dx,0.0),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,0.0),shadowCoord.z),f.x)+mix(texture2DCompare(shadowMap,uv+vec2(-dx,dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,dy),shadowCoord.z),f.x)+mix(texture2DCompare(shadowMap,uv+vec2(0.0,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(0.0,2.0*dy),shadowCoord.z),f.y)+mix(texture2DCompare(shadowMap,uv+vec2(dx,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(dx,2.0*dy),shadowCoord.z),f.y)+mix(mix(texture2DCompare(shadowMap,uv+vec2(-dx,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,-dy),shadowCoord.z),f.x),mix(texture2DCompare(shadowMap,uv+vec2(-dx,2.0*dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,2.0*dy),shadowCoord.z),f.x),f.y))*(1.0/9.0);
|
||
|
#elif defined(SHADOWMAP_TYPE_VSM)
|
||
|
shadow=VSMShadow(shadowMap,shadowCoord.xy,shadowCoord.z);
|
||
|
#else
|
||
|
shadow=texture2DCompare(shadowMap,shadowCoord.xy,shadowCoord.z);
|
||
|
#endif
|
||
|
}return shadow;}vec2 cubeToUV(vec3 v,float texelSizeY){vec3 absV=abs(v);float scaleToCube=1.0/max(absV.x,max(absV.y,absV.z));absV*=scaleToCube;v*=scaleToCube*(1.0-2.0*texelSizeY);vec2 planar=v.xy;float almostATexel=1.5*texelSizeY;float almostOne=1.0-almostATexel;if(absV.z>=almostOne){if(v.z>0.0)planar.x=4.0-v.x;}else if(absV.x>=almostOne){float signX=sign(v.x);planar.x=v.z*signX+2.0*signX;}else if(absV.y>=almostOne){float signY=sign(v.y);planar.x=v.x+2.0*signY+2.0;planar.y=v.z*signY-2.0;}return vec2(0.125,0.25)*planar+vec2(0.375,0.75);}float getPointShadow(sampler2D shadowMap,vec2 shadowMapSize,float shadowBias,float shadowRadius,vec4 shadowCoord,float shadowCameraNear,float shadowCameraFar){vec2 texelSize=vec2(1.0)/(shadowMapSize*vec2(4.0,2.0));vec3 lightToPosition=shadowCoord.xyz;float dp=(length(lightToPosition)-shadowCameraNear)/(shadowCameraFar-shadowCameraNear);dp+=shadowBias;vec3 bd3D=normalize(lightToPosition);
|
||
|
#if defined(SHADOWMAP_TYPE_PCF)||defined(SHADOWMAP_TYPE_PCF_SOFT)||defined(SHADOWMAP_TYPE_VSM)
|
||
|
vec2 offset=vec2(-1,1)*shadowRadius*texelSize.y;return(texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xyy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yyy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xyx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yyx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xxy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yxy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xxx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yxx,texelSize.y),dp))*(1.0/9.0);
|
||
|
#else
|
||
|
return texture2DCompare(shadowMap,cubeToUV(bd3D,texelSize.y),dp);
|
||
|
#endif
|
||
|
}
|
||
|
#endif`,rd=`#if NUM_SPOT_LIGHT_COORDS>0
|
||
|
uniform mat4 spotLightMatrix[NUM_SPOT_LIGHT_COORDS];varying vec4 vSpotLightCoord[NUM_SPOT_LIGHT_COORDS];
|
||
|
#endif
|
||
|
#ifdef USE_SHADOWMAP
|
||
|
#if NUM_DIR_LIGHT_SHADOWS>0
|
||
|
uniform mat4 directionalShadowMatrix[NUM_DIR_LIGHT_SHADOWS];varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];struct DirectionalLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHT_SHADOWS>0
|
||
|
struct SpotLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHT_SHADOWS>0
|
||
|
uniform mat4 pointShadowMatrix[NUM_POINT_LIGHT_SHADOWS];varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];struct PointLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;float shadowCameraNear;float shadowCameraFar;};uniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];
|
||
|
#endif
|
||
|
#endif`,rp=`#if (defined(USE_SHADOWMAP)&&(NUM_DIR_LIGHT_SHADOWS>0||NUM_POINT_LIGHT_SHADOWS>0))||(NUM_SPOT_LIGHT_COORDS>0)
|
||
|
vec3 shadowWorldNormal=inverseTransformDirection(transformedNormal,viewMatrix);vec4 shadowWorldPosition;
|
||
|
#endif
|
||
|
#if defined(USE_SHADOWMAP)
|
||
|
#if NUM_DIR_LIGHT_SHADOWS>0
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_DIR_LIGHT_SHADOWS;i++){shadowWorldPosition=worldPosition+vec4(shadowWorldNormal*directionalLightShadows[i].shadowNormalBias,0);vDirectionalShadowCoord[i]=directionalShadowMatrix[i]*shadowWorldPosition;}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHT_SHADOWS>0
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_POINT_LIGHT_SHADOWS;i++){shadowWorldPosition=worldPosition+vec4(shadowWorldNormal*pointLightShadows[i].shadowNormalBias,0);vPointShadowCoord[i]=pointShadowMatrix[i]*shadowWorldPosition;}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHT_COORDS>0
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_SPOT_LIGHT_COORDS;i++){shadowWorldPosition=worldPosition;
|
||
|
#if (defined(USE_SHADOWMAP)&&UNROLLED_LOOP_INDEX<NUM_SPOT_LIGHT_SHADOWS)
|
||
|
shadowWorldPosition.xyz+=shadowWorldNormal*spotLightShadows[i].shadowNormalBias;
|
||
|
#endif
|
||
|
vSpotLightCoord[i]=spotLightMatrix[i]*shadowWorldPosition;}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif`,rf=`float getShadowMask(){float shadow=1.0;
|
||
|
#ifdef USE_SHADOWMAP
|
||
|
#if NUM_DIR_LIGHT_SHADOWS>0
|
||
|
DirectionalLightShadow directionalLight;
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_DIR_LIGHT_SHADOWS;i++){directionalLight=directionalLightShadows[i];shadow*=receiveShadow?getShadow(directionalShadowMap[i],directionalLight.shadowMapSize,directionalLight.shadowBias,directionalLight.shadowRadius,vDirectionalShadowCoord[i]):1.0;}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#if NUM_SPOT_LIGHT_SHADOWS>0
|
||
|
SpotLightShadow spotLight;
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_SPOT_LIGHT_SHADOWS;i++){spotLight=spotLightShadows[i];shadow*=receiveShadow?getShadow(spotShadowMap[i],spotLight.shadowMapSize,spotLight.shadowBias,spotLight.shadowRadius,vSpotLightCoord[i]):1.0;}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#if NUM_POINT_LIGHT_SHADOWS>0
|
||
|
PointLightShadow pointLight;
|
||
|
#pragma unroll_loop_start
|
||
|
for(int i=0;i<NUM_POINT_LIGHT_SHADOWS;i++){pointLight=pointLightShadows[i];shadow*=receiveShadow?getPointShadow(pointShadowMap[i],pointLight.shadowMapSize,pointLight.shadowBias,pointLight.shadowRadius,vPointShadowCoord[i],pointLight.shadowCameraNear,pointLight.shadowCameraFar):1.0;}
|
||
|
#pragma unroll_loop_end
|
||
|
#endif
|
||
|
#endif
|
||
|
return shadow;}`,rm=`#ifdef USE_SKINNING
|
||
|
mat4 boneMatX=getBoneMatrix(skinIndex.x);mat4 boneMatY=getBoneMatrix(skinIndex.y);mat4 boneMatZ=getBoneMatrix(skinIndex.z);mat4 boneMatW=getBoneMatrix(skinIndex.w);
|
||
|
#endif`,rg=`#ifdef USE_SKINNING
|
||
|
uniform mat4 bindMatrix;uniform mat4 bindMatrixInverse;uniform highp sampler2D boneTexture;uniform int boneTextureSize;mat4 getBoneMatrix(const in float i){float j=i*4.0;float x=mod(j,float(boneTextureSize));float y=floor(j/float(boneTextureSize));float dx=1.0/float(boneTextureSize);float dy=1.0/float(boneTextureSize);y=dy*(y+0.5);vec4 v1=texture2D(boneTexture,vec2(dx*(x+0.5),y));vec4 v2=texture2D(boneTexture,vec2(dx*(x+1.5),y));vec4 v3=texture2D(boneTexture,vec2(dx*(x+2.5),y));vec4 v4=texture2D(boneTexture,vec2(dx*(x+3.5),y));mat4 bone=mat4(v1,v2,v3,v4);return bone;}
|
||
|
#endif`,rv=`#ifdef USE_SKINNING
|
||
|
vec4 skinVertex=bindMatrix*vec4(transformed,1.0);vec4 skinned=vec4(0.0);skinned+=boneMatX*skinVertex*skinWeight.x;skinned+=boneMatY*skinVertex*skinWeight.y;skinned+=boneMatZ*skinVertex*skinWeight.z;skinned+=boneMatW*skinVertex*skinWeight.w;transformed=(bindMatrixInverse*skinned).xyz;
|
||
|
#endif`,r_=`#ifdef USE_SKINNING
|
||
|
mat4 skinMatrix=mat4(0.0);skinMatrix+=skinWeight.x*boneMatX;skinMatrix+=skinWeight.y*boneMatY;skinMatrix+=skinWeight.z*boneMatZ;skinMatrix+=skinWeight.w*boneMatW;skinMatrix=bindMatrixInverse*skinMatrix*bindMatrix;objectNormal=vec4(skinMatrix*vec4(objectNormal,0.0)).xyz;
|
||
|
#ifdef USE_TANGENT
|
||
|
objectTangent=vec4(skinMatrix*vec4(objectTangent,0.0)).xyz;
|
||
|
#endif
|
||
|
#endif`,rx=`float specularStrength;
|
||
|
#ifdef USE_SPECULARMAP
|
||
|
vec4 texelSpecular=texture2D(specularMap,vSpecularMapUv);specularStrength=texelSpecular.r;
|
||
|
#else
|
||
|
specularStrength=1.0;
|
||
|
#endif`,ry=`#ifdef USE_SPECULARMAP
|
||
|
uniform sampler2D specularMap;
|
||
|
#endif`,rM=`#if defined(TONE_MAPPING)
|
||
|
gl_FragColor.rgb=toneMapping(gl_FragColor.rgb);
|
||
|
#endif`,rS=`#ifndef saturate
|
||
|
#define saturate(a)clamp(a,0.0,1.0)
|
||
|
#endif
|
||
|
uniform float toneMappingExposure;vec3 LinearToneMapping(vec3 color){return saturate(toneMappingExposure*color);}vec3 ReinhardToneMapping(vec3 color){color*=toneMappingExposure;return saturate(color/(vec3(1.0)+color));}vec3 OptimizedCineonToneMapping(vec3 color){color*=toneMappingExposure;color=max(vec3(0.0),color-0.004);return pow((color*(6.2*color+0.5))/(color*(6.2*color+1.7)+0.06),vec3(2.2));}vec3 RRTAndODTFit(vec3 v){vec3 a=v*(v+0.0245786)-0.000090537;vec3 b=v*(0.983729*v+0.4329510)+0.238081;return a/b;}vec3 ACESFilmicToneMapping(vec3 color){const mat3 ACESInputMat=mat3(vec3(0.59719,0.07600,0.02840),vec3(0.35458,0.90834,0.13383),vec3(0.04823,0.01566,0.83777));const mat3 ACESOutputMat=mat3(vec3(1.60475,-0.10208,-0.00327),vec3(-0.53108,1.10813,-0.07276),vec3(-0.07367,-0.00605,1.07602));color*=toneMappingExposure/0.6;color=ACESInputMat*color;color=RRTAndODTFit(color);color=ACESOutputMat*color;return saturate(color);}vec3 CustomToneMapping(vec3 color){return color;}`,rb=`#ifdef USE_TRANSMISSION
|
||
|
material.transmission=transmission;material.transmissionAlpha=1.0;material.thickness=thickness;material.attenuationDistance=attenuationDistance;material.attenuationColor=attenuationColor;
|
||
|
#ifdef USE_TRANSMISSIONMAP
|
||
|
material.transmission*=texture2D(transmissionMap,vTransmissionMapUv).r;
|
||
|
#endif
|
||
|
#ifdef USE_THICKNESSMAP
|
||
|
material.thickness*=texture2D(thicknessMap,vThicknessMapUv).g;
|
||
|
#endif
|
||
|
vec3 pos=vWorldPosition;vec3 v=normalize(cameraPosition-pos);vec3 n=inverseTransformDirection(normal,viewMatrix);vec4 transmitted=getIBLVolumeRefraction(n,v,material.roughness,material.diffuseColor,material.specularColor,material.specularF90,pos,modelMatrix,viewMatrix,projectionMatrix,material.ior,material.thickness,material.attenuationColor,material.attenuationDistance);material.transmissionAlpha=mix(material.transmissionAlpha,transmitted.a,material.transmission);totalDiffuse=mix(totalDiffuse,transmitted.rgb,material.transmission);
|
||
|
#endif`,rw=`#ifdef USE_TRANSMISSION
|
||
|
uniform float transmission;uniform float thickness;uniform float attenuationDistance;uniform vec3 attenuationColor;
|
||
|
#ifdef USE_TRANSMISSIONMAP
|
||
|
uniform sampler2D transmissionMap;
|
||
|
#endif
|
||
|
#ifdef USE_THICKNESSMAP
|
||
|
uniform sampler2D thicknessMap;
|
||
|
#endif
|
||
|
uniform vec2 transmissionSamplerSize;uniform sampler2D transmissionSamplerMap;uniform mat4 modelMatrix;uniform mat4 projectionMatrix;varying vec3 vWorldPosition;float w0(float a){return(1.0/6.0)*(a*(a*(-a+3.0)-3.0)+1.0);}float w1(float a){return(1.0/6.0)*(a*a*(3.0*a-6.0)+4.0);}float w2(float a){return(1.0/6.0)*(a*(a*(-3.0*a+3.0)+3.0)+1.0);}float w3(float a){return(1.0/6.0)*(a*a*a);}float g0(float a){return w0(a)+w1(a);}float g1(float a){return w2(a)+w3(a);}float h0(float a){return-1.0+w1(a)/(w0(a)+w1(a));}float h1(float a){return 1.0+w3(a)/(w2(a)+w3(a));}vec4 bicubic(sampler2D tex,vec2 uv,vec4 texelSize,float lod){uv=uv*texelSize.zw+0.5;vec2 iuv=floor(uv);vec2 fuv=fract(uv);float g0x=g0(fuv.x);float g1x=g1(fuv.x);float h0x=h0(fuv.x);float h1x=h1(fuv.x);float h0y=h0(fuv.y);float h1y=h1(fuv.y);vec2 p0=(vec2(iuv.x+h0x,iuv.y+h0y)-0.5)*texelSize.xy;vec2 p1=(vec2(iuv.x+h1x,iuv.y+h0y)-0.5)*texelSize.xy;vec2 p2=(vec2(iuv.x+h0x,iuv.y+h1y)-0.5)*texelSize.xy;vec2 p3=(vec2(iuv.x+h1x,iuv.y+h1y)-0.5)*texelSize.xy;return g0(fuv.y)*(g0x*textureLod(tex,p0,lod)+g1x*textureLod(tex,p1,lod))+g1(fuv.y)*(g0x*textureLod(tex,p2,lod)+g1x*textureLod(tex,p3,lod));}vec4 textureBicubic(sampler2D sampler,vec2 uv,float lod){vec2 fLodSize=vec2(textureSize(sampler,int(lod)));vec2 cLodSize=vec2(textureSize(sampler,int(lod+1.0)));vec2 fLodSizeInv=1.0/fLodSize;vec2 cLodSizeInv=1.0/cLodSize;vec4 fSample=bicubic(sampler,uv,vec4(fLodSizeInv,fLodSize),floor(lod));vec4 cSample=bicubic(sampler,uv,vec4(cLodSizeInv,cLodSize),ceil(lod));return mix(fSample,cSample,fract(lod));}vec3 getVolumeTransmissionRay(const in vec3 n,const in vec3 v,const in float thickness,const in float ior,const in mat4 modelMatrix){vec3 refractionVector=refract(-v,normalize(n),1.0/ior);vec3 modelScale;modelScale.x=length(vec3(modelMatrix[0].xyz));modelScale.y=length(vec3(modelMatrix[1].xyz));modelScale.z=length(vec3(modelMatrix[2].xyz));return normalize(refractionVector)*thickness*modelScale;}float applyIorToRoughness(const in float roughness,const in float ior){return roughness*clamp(ior*2.0-2.0,0.0,1.0);}vec4 getTransmissionSample(const in vec2 fragCoord,const in float roughness,const in float ior){float lod=log2(transmissionSamplerSize.x)*applyIorToRoughness(roughness,ior);return textureBicubic(transmissionSamplerMap,fragCoord.xy,lod);}vec3 volumeAttenuation(const in float transmissionDistance,const in vec3 attenuationColor,const in float attenuationDistance){if(isinf(attenuationDistance)){return vec3(1.0);}else{vec3 attenuationCoefficient=-log(attenuationColor)/attenuationDistance;vec3 transmittance=exp(-attenuationCoefficient*transmissionDistance);return transmittance;}}vec4 getIBLVolumeRefraction(const in vec3 n,const in vec3 v,const in float roughness,const in vec3 diffuseColor,const in vec3 specularColor,const in float specularF90,const in vec3 position,const in mat4 modelMatrix,const in mat4 viewMatrix,const in mat4 projMatrix,const in float ior,const in float thickness,const in vec3 attenuationColor,const in float attenuationDistance){vec3 transmissionRay=getVolumeTransmissionRay(n,v,thickness,ior,modelMatrix);vec3 refractedRayExit=position+transmissionRay;vec4 ndcPos=projMatrix*viewMatrix*vec4(refractedRayExit,1.0);vec2 refractionCoords=ndcPos.xy/ndcPos.w;refractionCoords+=1.0;refractionCoords/=2.0;vec4 transmittedLight=getTransmissionSample(refractionCoords,roughness,ior);vec3 transmittance=diffuseColor*volumeAttenuation(length(transmissionRay),attenuationColor,attenuationDistance);vec3 attenuatedColor=transmittance*transmittedLight.rgb;vec3 F=EnvironmentBRDF(n,v,specularColor,specularF90,roughness);float transmittanceFactor=(transmittance.r+transmittance.g+transmittance.b)/3.0;return vec4((1.0-F)*attenuatedColor,1.0-(1.0-transmittedLight.a)*transmittanceFactor);}
|
||
|
#endif`,rT=`#if defined(USE_UV)||defined(USE_ANISOTROPY)
|
||
|
varying vec2 vUv;
|
||
|
#endif
|
||
|
#ifdef USE_MAP
|
||
|
varying vec2 vMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_ALPHAMAP
|
||
|
varying vec2 vAlphaMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_LIGHTMAP
|
||
|
varying vec2 vLightMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_AOMAP
|
||
|
varying vec2 vAoMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_BUMPMAP
|
||
|
varying vec2 vBumpMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_NORMALMAP
|
||
|
varying vec2 vNormalMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_EMISSIVEMAP
|
||
|
varying vec2 vEmissiveMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_METALNESSMAP
|
||
|
varying vec2 vMetalnessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_ROUGHNESSMAP
|
||
|
varying vec2 vRoughnessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_ANISOTROPYMAP
|
||
|
varying vec2 vAnisotropyMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOATMAP
|
||
|
varying vec2 vClearcoatMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
|
varying vec2 vClearcoatNormalMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
|
varying vec2 vClearcoatRoughnessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCEMAP
|
||
|
varying vec2 vIridescenceMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
|
varying vec2 vIridescenceThicknessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN_COLORMAP
|
||
|
varying vec2 vSheenColorMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
|
varying vec2 vSheenRoughnessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULARMAP
|
||
|
varying vec2 vSpecularMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULAR_COLORMAP
|
||
|
varying vec2 vSpecularColorMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
|
varying vec2 vSpecularIntensityMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_TRANSMISSIONMAP
|
||
|
uniform mat3 transmissionMapTransform;varying vec2 vTransmissionMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_THICKNESSMAP
|
||
|
uniform mat3 thicknessMapTransform;varying vec2 vThicknessMapUv;
|
||
|
#endif`,rE=`#if defined(USE_UV)||defined(USE_ANISOTROPY)
|
||
|
varying vec2 vUv;
|
||
|
#endif
|
||
|
#ifdef USE_MAP
|
||
|
uniform mat3 mapTransform;varying vec2 vMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_ALPHAMAP
|
||
|
uniform mat3 alphaMapTransform;varying vec2 vAlphaMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_LIGHTMAP
|
||
|
uniform mat3 lightMapTransform;varying vec2 vLightMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_AOMAP
|
||
|
uniform mat3 aoMapTransform;varying vec2 vAoMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_BUMPMAP
|
||
|
uniform mat3 bumpMapTransform;varying vec2 vBumpMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_NORMALMAP
|
||
|
uniform mat3 normalMapTransform;varying vec2 vNormalMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_DISPLACEMENTMAP
|
||
|
uniform mat3 displacementMapTransform;varying vec2 vDisplacementMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_EMISSIVEMAP
|
||
|
uniform mat3 emissiveMapTransform;varying vec2 vEmissiveMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_METALNESSMAP
|
||
|
uniform mat3 metalnessMapTransform;varying vec2 vMetalnessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_ROUGHNESSMAP
|
||
|
uniform mat3 roughnessMapTransform;varying vec2 vRoughnessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_ANISOTROPYMAP
|
||
|
uniform mat3 anisotropyMapTransform;varying vec2 vAnisotropyMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOATMAP
|
||
|
uniform mat3 clearcoatMapTransform;varying vec2 vClearcoatMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
|
uniform mat3 clearcoatNormalMapTransform;varying vec2 vClearcoatNormalMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
|
uniform mat3 clearcoatRoughnessMapTransform;varying vec2 vClearcoatRoughnessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN_COLORMAP
|
||
|
uniform mat3 sheenColorMapTransform;varying vec2 vSheenColorMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
|
uniform mat3 sheenRoughnessMapTransform;varying vec2 vSheenRoughnessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCEMAP
|
||
|
uniform mat3 iridescenceMapTransform;varying vec2 vIridescenceMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
|
uniform mat3 iridescenceThicknessMapTransform;varying vec2 vIridescenceThicknessMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULARMAP
|
||
|
uniform mat3 specularMapTransform;varying vec2 vSpecularMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULAR_COLORMAP
|
||
|
uniform mat3 specularColorMapTransform;varying vec2 vSpecularColorMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
|
uniform mat3 specularIntensityMapTransform;varying vec2 vSpecularIntensityMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_TRANSMISSIONMAP
|
||
|
uniform mat3 transmissionMapTransform;varying vec2 vTransmissionMapUv;
|
||
|
#endif
|
||
|
#ifdef USE_THICKNESSMAP
|
||
|
uniform mat3 thicknessMapTransform;varying vec2 vThicknessMapUv;
|
||
|
#endif`,rA=`#if defined(USE_UV)||defined(USE_ANISOTROPY)
|
||
|
vUv=vec3(uv,1).xy;
|
||
|
#endif
|
||
|
#ifdef USE_MAP
|
||
|
vMapUv=(mapTransform*vec3(MAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_ALPHAMAP
|
||
|
vAlphaMapUv=(alphaMapTransform*vec3(ALPHAMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_LIGHTMAP
|
||
|
vLightMapUv=(lightMapTransform*vec3(LIGHTMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_AOMAP
|
||
|
vAoMapUv=(aoMapTransform*vec3(AOMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_BUMPMAP
|
||
|
vBumpMapUv=(bumpMapTransform*vec3(BUMPMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_NORMALMAP
|
||
|
vNormalMapUv=(normalMapTransform*vec3(NORMALMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_DISPLACEMENTMAP
|
||
|
vDisplacementMapUv=(displacementMapTransform*vec3(DISPLACEMENTMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_EMISSIVEMAP
|
||
|
vEmissiveMapUv=(emissiveMapTransform*vec3(EMISSIVEMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_METALNESSMAP
|
||
|
vMetalnessMapUv=(metalnessMapTransform*vec3(METALNESSMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_ROUGHNESSMAP
|
||
|
vRoughnessMapUv=(roughnessMapTransform*vec3(ROUGHNESSMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_ANISOTROPYMAP
|
||
|
vAnisotropyMapUv=(anisotropyMapTransform*vec3(ANISOTROPYMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOATMAP
|
||
|
vClearcoatMapUv=(clearcoatMapTransform*vec3(CLEARCOATMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
||
|
vClearcoatNormalMapUv=(clearcoatNormalMapTransform*vec3(CLEARCOAT_NORMALMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||
|
vClearcoatRoughnessMapUv=(clearcoatRoughnessMapTransform*vec3(CLEARCOAT_ROUGHNESSMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCEMAP
|
||
|
vIridescenceMapUv=(iridescenceMapTransform*vec3(IRIDESCENCEMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
|
vIridescenceThicknessMapUv=(iridescenceThicknessMapTransform*vec3(IRIDESCENCE_THICKNESSMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN_COLORMAP
|
||
|
vSheenColorMapUv=(sheenColorMapTransform*vec3(SHEEN_COLORMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
|
vSheenRoughnessMapUv=(sheenRoughnessMapTransform*vec3(SHEEN_ROUGHNESSMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULARMAP
|
||
|
vSpecularMapUv=(specularMapTransform*vec3(SPECULARMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULAR_COLORMAP
|
||
|
vSpecularColorMapUv=(specularColorMapTransform*vec3(SPECULAR_COLORMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
|
vSpecularIntensityMapUv=(specularIntensityMapTransform*vec3(SPECULAR_INTENSITYMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_TRANSMISSIONMAP
|
||
|
vTransmissionMapUv=(transmissionMapTransform*vec3(TRANSMISSIONMAP_UV,1)).xy;
|
||
|
#endif
|
||
|
#ifdef USE_THICKNESSMAP
|
||
|
vThicknessMapUv=(thicknessMapTransform*vec3(THICKNESSMAP_UV,1)).xy;
|
||
|
#endif`,rC=`#if defined(USE_ENVMAP)||defined(DISTANCE)||defined(USE_SHADOWMAP)||defined(USE_TRANSMISSION)||NUM_SPOT_LIGHT_COORDS>0
|
||
|
vec4 worldPosition=vec4(transformed,1.0);
|
||
|
#ifdef USE_INSTANCING
|
||
|
worldPosition=instanceMatrix*worldPosition;
|
||
|
#endif
|
||
|
worldPosition=modelMatrix*worldPosition;
|
||
|
#endif`;let rL=`uniform sampler2D t2D;uniform float backgroundIntensity;varying vec2 vUv;void main(){vec4 texColor=texture2D(t2D,vUv);
|
||
|
#ifdef DECODE_VIDEO_TEXTURE
|
||
|
texColor=vec4(mix(pow(texColor.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),texColor.rgb*0.0773993808,vec3(lessThanEqual(texColor.rgb,vec3(0.04045)))),texColor.w);
|
||
|
#endif
|
||
|
texColor.rgb*=backgroundIntensity;gl_FragColor=texColor;
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
}`,rP=`varying vec3 vWorldDirection;
|
||
|
#include <common>
|
||
|
void main(){vWorldDirection=transformDirection(position,modelMatrix);
|
||
|
#include <begin_vertex>
|
||
|
#include <project_vertex>
|
||
|
gl_Position.z=gl_Position.w;}`,rR=`#ifdef ENVMAP_TYPE_CUBE
|
||
|
uniform samplerCube envMap;
|
||
|
#elif defined(ENVMAP_TYPE_CUBE_UV)
|
||
|
uniform sampler2D envMap;
|
||
|
#endif
|
||
|
uniform float flipEnvMap;uniform float backgroundBlurriness;uniform float backgroundIntensity;varying vec3 vWorldDirection;
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
void main(){
|
||
|
#ifdef ENVMAP_TYPE_CUBE
|
||
|
vec4 texColor=textureCube(envMap,vec3(flipEnvMap*vWorldDirection.x,vWorldDirection.yz));
|
||
|
#elif defined(ENVMAP_TYPE_CUBE_UV)
|
||
|
vec4 texColor=textureCubeUV(envMap,vWorldDirection,backgroundBlurriness);
|
||
|
#else
|
||
|
vec4 texColor=vec4(0.0,0.0,0.0,1.0);
|
||
|
#endif
|
||
|
texColor.rgb*=backgroundIntensity;gl_FragColor=texColor;
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
}`,rD=`varying vec3 vWorldDirection;
|
||
|
#include <common>
|
||
|
void main(){vWorldDirection=transformDirection(position,modelMatrix);
|
||
|
#include <begin_vertex>
|
||
|
#include <project_vertex>
|
||
|
gl_Position.z=gl_Position.w;}`,rU=`uniform samplerCube tCube;uniform float tFlip;uniform float opacity;varying vec3 vWorldDirection;void main(){vec4 texColor=textureCube(tCube,vec3(tFlip*vWorldDirection.x,vWorldDirection.yz));gl_FragColor=texColor;gl_FragColor.a*=opacity;
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
}`,rI=`#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
varying vec2 vHighPrecisionZW;void main(){
|
||
|
#include <uv_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#ifdef USE_DISPLACEMENTMAP
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vHighPrecisionZW=gl_Position.zw;}`,rN=`#if DEPTH_PACKING==3200
|
||
|
uniform float opacity;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
varying vec2 vHighPrecisionZW;void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor=vec4(1.0);
|
||
|
#if DEPTH_PACKING==3200
|
||
|
diffuseColor.a=opacity;
|
||
|
#endif
|
||
|
#include <map_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
#include <logdepthbuf_fragment>
|
||
|
float fragCoordZ=0.5*vHighPrecisionZW[0]/vHighPrecisionZW[1]+0.5;
|
||
|
#if DEPTH_PACKING==3200
|
||
|
gl_FragColor=vec4(vec3(1.0-fragCoordZ),opacity);
|
||
|
#elif DEPTH_PACKING==3201
|
||
|
gl_FragColor=packDepthToRGBA(fragCoordZ);
|
||
|
#endif
|
||
|
}`,rO=`#define DISTANCE
|
||
|
varying vec3 vWorldPosition;
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){
|
||
|
#include <uv_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#ifdef USE_DISPLACEMENTMAP
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <worldpos_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vWorldPosition=worldPosition.xyz;}`,rz=`#define DISTANCE
|
||
|
uniform vec3 referencePosition;uniform float nearDistance;uniform float farDistance;varying vec3 vWorldPosition;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor=vec4(1.0);
|
||
|
#include <map_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
float dist=length(vWorldPosition-referencePosition);dist=(dist-nearDistance)/(farDistance-nearDistance);dist=saturate(dist);gl_FragColor=packDepthToRGBA(dist);}`,rF=`varying vec3 vWorldDirection;
|
||
|
#include <common>
|
||
|
void main(){vWorldDirection=transformDirection(position,modelMatrix);
|
||
|
#include <begin_vertex>
|
||
|
#include <project_vertex>
|
||
|
}`,rk=`uniform sampler2D tEquirect;varying vec3 vWorldDirection;
|
||
|
#include <common>
|
||
|
void main(){vec3 direction=normalize(vWorldDirection);vec2 sampleUV=equirectUv(direction);gl_FragColor=texture2D(tEquirect,sampleUV);
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
}`,rB=`uniform float scale;attribute float lineDistance;varying float vLineDistance;
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){vLineDistance=scale*lineDistance;
|
||
|
#include <uv_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <morphcolor_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,rH=`uniform vec3 diffuse;uniform float opacity;uniform float dashSize;uniform float totalSize;varying float vLineDistance;
|
||
|
#include <common>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
if(mod(vLineDistance,totalSize)>dashSize){discard;}vec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity);
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
outgoingLight=diffuseColor.rgb;
|
||
|
#include <opaque_fragment>
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
}`,rV=`#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <envmap_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){
|
||
|
#include <uv_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <morphcolor_vertex>
|
||
|
#if defined(USE_ENVMAP)||defined(USE_SKINNING)
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#endif
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <worldpos_vertex>
|
||
|
#include <envmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,rG=`uniform vec3 diffuse;uniform float opacity;
|
||
|
#ifndef FLAT_SHADED
|
||
|
varying vec3 vNormal;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <envmap_common_pars_fragment>
|
||
|
#include <envmap_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <specularmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor=vec4(diffuse,opacity);
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
#include <specularmap_fragment>
|
||
|
ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));
|
||
|
#ifdef USE_LIGHTMAP
|
||
|
vec4 lightMapTexel=texture2D(lightMap,vLightMapUv);reflectedLight.indirectDiffuse+=lightMapTexel.rgb*lightMapIntensity*RECIPROCAL_PI;
|
||
|
#else
|
||
|
reflectedLight.indirectDiffuse+=vec3(1.0);
|
||
|
#endif
|
||
|
#include <aomap_fragment>
|
||
|
reflectedLight.indirectDiffuse*=diffuseColor.rgb;vec3 outgoingLight=reflectedLight.indirectDiffuse;
|
||
|
#include <envmap_fragment>
|
||
|
#include <opaque_fragment>
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,rW=`#define LAMBERT
|
||
|
varying vec3 vViewPosition;
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <envmap_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <normal_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){
|
||
|
#include <uv_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <morphcolor_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#include <normal_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vViewPosition=-mvPosition.xyz;
|
||
|
#include <worldpos_vertex>
|
||
|
#include <envmap_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,rj=`#define LAMBERT
|
||
|
uniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <emissivemap_pars_fragment>
|
||
|
#include <envmap_common_pars_fragment>
|
||
|
#include <envmap_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <bsdfs>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <normal_pars_fragment>
|
||
|
#include <lights_lambert_pars_fragment>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <specularmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
#include <specularmap_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
#include <emissivemap_fragment>
|
||
|
#include <lights_lambert_fragment>
|
||
|
#include <lights_fragment_begin>
|
||
|
#include <lights_fragment_maps>
|
||
|
#include <lights_fragment_end>
|
||
|
#include <aomap_fragment>
|
||
|
vec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+totalEmissiveRadiance;
|
||
|
#include <envmap_fragment>
|
||
|
#include <opaque_fragment>
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,rq=`#define MATCAP
|
||
|
varying vec3 vViewPosition;
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <normal_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){
|
||
|
#include <uv_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <morphcolor_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#include <normal_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <fog_vertex>
|
||
|
vViewPosition=-mvPosition.xyz;}`,rX=`#define MATCAP
|
||
|
uniform vec3 diffuse;uniform float opacity;uniform sampler2D matcap;varying vec3 vViewPosition;
|
||
|
#include <common>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <normal_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor=vec4(diffuse,opacity);
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
vec3 viewDir=normalize(vViewPosition);vec3 x=normalize(vec3(viewDir.z,0.0,-viewDir.x));vec3 y=cross(viewDir,x);vec2 uv=vec2(dot(x,normal),dot(y,normal))*0.495+0.5;
|
||
|
#ifdef USE_MATCAP
|
||
|
vec4 matcapColor=texture2D(matcap,uv);
|
||
|
#else
|
||
|
vec4 matcapColor=vec4(vec3(mix(0.2,0.8,uv.y)),1.0);
|
||
|
#endif
|
||
|
vec3 outgoingLight=diffuseColor.rgb*matcapColor.rgb;
|
||
|
#include <opaque_fragment>
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,rY=`#define NORMAL
|
||
|
#if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(USE_NORMALMAP_TANGENTSPACE)
|
||
|
varying vec3 vViewPosition;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <normal_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){
|
||
|
#include <uv_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#include <normal_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(USE_NORMALMAP_TANGENTSPACE)
|
||
|
vViewPosition=-mvPosition.xyz;
|
||
|
#endif
|
||
|
}`,rZ=`#define NORMAL
|
||
|
uniform float opacity;
|
||
|
#if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(USE_NORMALMAP_TANGENTSPACE)
|
||
|
varying vec3 vViewPosition;
|
||
|
#endif
|
||
|
#include <packing>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <normal_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
gl_FragColor=vec4(packNormalToRGB(normal),opacity);
|
||
|
#ifdef OPAQUE
|
||
|
gl_FragColor.a=1.0;
|
||
|
#endif
|
||
|
}`,rK=`#define PHONG
|
||
|
varying vec3 vViewPosition;
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <envmap_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <normal_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){
|
||
|
#include <uv_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <morphcolor_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#include <normal_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vViewPosition=-mvPosition.xyz;
|
||
|
#include <worldpos_vertex>
|
||
|
#include <envmap_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,rJ=`#define PHONG
|
||
|
uniform vec3 diffuse;uniform vec3 emissive;uniform vec3 specular;uniform float shininess;uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <emissivemap_pars_fragment>
|
||
|
#include <envmap_common_pars_fragment>
|
||
|
#include <envmap_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <bsdfs>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <normal_pars_fragment>
|
||
|
#include <lights_phong_pars_fragment>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <specularmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
#include <specularmap_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
#include <emissivemap_fragment>
|
||
|
#include <lights_phong_fragment>
|
||
|
#include <lights_fragment_begin>
|
||
|
#include <lights_fragment_maps>
|
||
|
#include <lights_fragment_end>
|
||
|
#include <aomap_fragment>
|
||
|
vec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+totalEmissiveRadiance;
|
||
|
#include <envmap_fragment>
|
||
|
#include <opaque_fragment>
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,rQ=`#define STANDARD
|
||
|
varying vec3 vViewPosition;
|
||
|
#ifdef USE_TRANSMISSION
|
||
|
varying vec3 vWorldPosition;
|
||
|
#endif
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <normal_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){
|
||
|
#include <uv_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <morphcolor_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#include <normal_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vViewPosition=-mvPosition.xyz;
|
||
|
#include <worldpos_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
#ifdef USE_TRANSMISSION
|
||
|
vWorldPosition=worldPosition.xyz;
|
||
|
#endif
|
||
|
}`,r$=`#define STANDARD
|
||
|
#ifdef PHYSICAL
|
||
|
#define IOR
|
||
|
#define USE_SPECULAR
|
||
|
#endif
|
||
|
uniform vec3 diffuse;uniform vec3 emissive;uniform float roughness;uniform float metalness;uniform float opacity;
|
||
|
#ifdef IOR
|
||
|
uniform float ior;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULAR
|
||
|
uniform float specularIntensity;uniform vec3 specularColor;
|
||
|
#ifdef USE_SPECULAR_COLORMAP
|
||
|
uniform sampler2D specularColorMap;
|
||
|
#endif
|
||
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
||
|
uniform sampler2D specularIntensityMap;
|
||
|
#endif
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
uniform float clearcoat;uniform float clearcoatRoughness;
|
||
|
#endif
|
||
|
#ifdef USE_IRIDESCENCE
|
||
|
uniform float iridescence;uniform float iridescenceIOR;uniform float iridescenceThicknessMinimum;uniform float iridescenceThicknessMaximum;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN
|
||
|
uniform vec3 sheenColor;uniform float sheenRoughness;
|
||
|
#ifdef USE_SHEEN_COLORMAP
|
||
|
uniform sampler2D sheenColorMap;
|
||
|
#endif
|
||
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
||
|
uniform sampler2D sheenRoughnessMap;
|
||
|
#endif
|
||
|
#endif
|
||
|
#ifdef USE_ANISOTROPY
|
||
|
uniform vec2 anisotropyVector;
|
||
|
#ifdef USE_ANISOTROPYMAP
|
||
|
uniform sampler2D anisotropyMap;
|
||
|
#endif
|
||
|
#endif
|
||
|
varying vec3 vViewPosition;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <emissivemap_pars_fragment>
|
||
|
#include <iridescence_fragment>
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
#include <envmap_common_pars_fragment>
|
||
|
#include <envmap_physical_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <normal_pars_fragment>
|
||
|
#include <lights_physical_pars_fragment>
|
||
|
#include <transmission_pars_fragment>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <clearcoat_pars_fragment>
|
||
|
#include <iridescence_pars_fragment>
|
||
|
#include <roughnessmap_pars_fragment>
|
||
|
#include <metalnessmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
#include <roughnessmap_fragment>
|
||
|
#include <metalnessmap_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
#include <clearcoat_normal_fragment_begin>
|
||
|
#include <clearcoat_normal_fragment_maps>
|
||
|
#include <emissivemap_fragment>
|
||
|
#include <lights_physical_fragment>
|
||
|
#include <lights_fragment_begin>
|
||
|
#include <lights_fragment_maps>
|
||
|
#include <lights_fragment_end>
|
||
|
#include <aomap_fragment>
|
||
|
vec3 totalDiffuse=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse;vec3 totalSpecular=reflectedLight.directSpecular+reflectedLight.indirectSpecular;
|
||
|
#include <transmission_fragment>
|
||
|
vec3 outgoingLight=totalDiffuse+totalSpecular+totalEmissiveRadiance;
|
||
|
#ifdef USE_SHEEN
|
||
|
float sheenEnergyComp=1.0-0.157*max3(material.sheenColor);outgoingLight=outgoingLight*sheenEnergyComp+sheenSpecular;
|
||
|
#endif
|
||
|
#ifdef USE_CLEARCOAT
|
||
|
float dotNVcc=saturate(dot(geometry.clearcoatNormal,geometry.viewDir));vec3 Fcc=F_Schlick(material.clearcoatF0,material.clearcoatF90,dotNVcc);outgoingLight=outgoingLight*(1.0-material.clearcoat*Fcc)+clearcoatSpecular*material.clearcoat;
|
||
|
#endif
|
||
|
#include <opaque_fragment>
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,r0=`#define TOON
|
||
|
varying vec3 vViewPosition;
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <displacementmap_pars_vertex>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <normal_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){
|
||
|
#include <uv_vertex>
|
||
|
#include <color_vertex>
|
||
|
#include <morphcolor_vertex>
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#include <normal_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <displacementmap_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
vViewPosition=-mvPosition.xyz;
|
||
|
#include <worldpos_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,r1=`#define TOON
|
||
|
uniform vec3 diffuse;uniform vec3 emissive;uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <dithering_pars_fragment>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <aomap_pars_fragment>
|
||
|
#include <lightmap_pars_fragment>
|
||
|
#include <emissivemap_pars_fragment>
|
||
|
#include <gradientmap_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <bsdfs>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <normal_pars_fragment>
|
||
|
#include <lights_toon_pars_fragment>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <bumpmap_pars_fragment>
|
||
|
#include <normalmap_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive;
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
#include <normal_fragment_begin>
|
||
|
#include <normal_fragment_maps>
|
||
|
#include <emissivemap_fragment>
|
||
|
#include <lights_toon_fragment>
|
||
|
#include <lights_fragment_begin>
|
||
|
#include <lights_fragment_maps>
|
||
|
#include <lights_fragment_end>
|
||
|
#include <aomap_fragment>
|
||
|
vec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+totalEmissiveRadiance;
|
||
|
#include <opaque_fragment>
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
#include <dithering_fragment>
|
||
|
}`,r3=`uniform float size;uniform float scale;
|
||
|
#include <common>
|
||
|
#include <color_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
#ifdef USE_POINTS_UV
|
||
|
varying vec2 vUv;uniform mat3 uvTransform;
|
||
|
#endif
|
||
|
void main(){
|
||
|
#ifdef USE_POINTS_UV
|
||
|
vUv=(uvTransform*vec3(uv,1)).xy;
|
||
|
#endif
|
||
|
#include <color_vertex>
|
||
|
#include <morphcolor_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <project_vertex>
|
||
|
gl_PointSize=size;
|
||
|
#ifdef USE_SIZEATTENUATION
|
||
|
bool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)gl_PointSize*=(scale/-mvPosition.z);
|
||
|
#endif
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <worldpos_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,r2=`uniform vec3 diffuse;uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <color_pars_fragment>
|
||
|
#include <map_particle_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity);
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_particle_fragment>
|
||
|
#include <color_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
outgoingLight=diffuseColor.rgb;
|
||
|
#include <opaque_fragment>
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
#include <premultiplied_alpha_fragment>
|
||
|
}`,r4=`#include <common>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <morphtarget_pars_vertex>
|
||
|
#include <skinning_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <shadowmap_pars_vertex>
|
||
|
void main(){
|
||
|
#include <beginnormal_vertex>
|
||
|
#include <morphnormal_vertex>
|
||
|
#include <skinbase_vertex>
|
||
|
#include <skinnormal_vertex>
|
||
|
#include <defaultnormal_vertex>
|
||
|
#include <begin_vertex>
|
||
|
#include <morphtarget_vertex>
|
||
|
#include <skinning_vertex>
|
||
|
#include <project_vertex>
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <worldpos_vertex>
|
||
|
#include <shadowmap_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,r5=`uniform vec3 color;uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <packing>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <bsdfs>
|
||
|
#include <lights_pars_begin>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <shadowmap_pars_fragment>
|
||
|
#include <shadowmask_pars_fragment>
|
||
|
void main(){
|
||
|
#include <logdepthbuf_fragment>
|
||
|
gl_FragColor=vec4(color,opacity*(1.0-getShadowMask()));
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
}`,r6=`uniform float rotation;uniform vec2 center;
|
||
|
#include <common>
|
||
|
#include <uv_pars_vertex>
|
||
|
#include <fog_pars_vertex>
|
||
|
#include <logdepthbuf_pars_vertex>
|
||
|
#include <clipping_planes_pars_vertex>
|
||
|
void main(){
|
||
|
#include <uv_vertex>
|
||
|
vec4 mvPosition=modelViewMatrix*vec4(0.0,0.0,0.0,1.0);vec2 scale;scale.x=length(vec3(modelMatrix[0].x,modelMatrix[0].y,modelMatrix[0].z));scale.y=length(vec3(modelMatrix[1].x,modelMatrix[1].y,modelMatrix[1].z));
|
||
|
#ifndef USE_SIZEATTENUATION
|
||
|
bool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)scale*=-mvPosition.z;
|
||
|
#endif
|
||
|
vec2 alignedPosition=(position.xy-(center-vec2(0.5)))*scale;vec2 rotatedPosition;rotatedPosition.x=cos(rotation)*alignedPosition.x-sin(rotation)*alignedPosition.y;rotatedPosition.y=sin(rotation)*alignedPosition.x+cos(rotation)*alignedPosition.y;mvPosition.xy+=rotatedPosition;gl_Position=projectionMatrix*mvPosition;
|
||
|
#include <logdepthbuf_vertex>
|
||
|
#include <clipping_planes_vertex>
|
||
|
#include <fog_vertex>
|
||
|
}`,r8=`uniform vec3 diffuse;uniform float opacity;
|
||
|
#include <common>
|
||
|
#include <uv_pars_fragment>
|
||
|
#include <map_pars_fragment>
|
||
|
#include <alphamap_pars_fragment>
|
||
|
#include <alphatest_pars_fragment>
|
||
|
#include <alphahash_pars_fragment>
|
||
|
#include <fog_pars_fragment>
|
||
|
#include <logdepthbuf_pars_fragment>
|
||
|
#include <clipping_planes_pars_fragment>
|
||
|
void main(){
|
||
|
#include <clipping_planes_fragment>
|
||
|
vec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity);
|
||
|
#include <logdepthbuf_fragment>
|
||
|
#include <map_fragment>
|
||
|
#include <alphamap_fragment>
|
||
|
#include <alphatest_fragment>
|
||
|
#include <alphahash_fragment>
|
||
|
outgoingLight=diffuseColor.rgb;
|
||
|
#include <opaque_fragment>
|
||
|
#include <tonemapping_fragment>
|
||
|
#include <colorspace_fragment>
|
||
|
#include <fog_fragment>
|
||
|
}`,r7={alphahash_fragment:t2,alphahash_pars_fragment:t4,alphamap_fragment:t5,alphamap_pars_fragment:t6,alphatest_fragment:t8,alphatest_pars_fragment:t7,aomap_fragment:t9,aomap_pars_fragment:ie,begin_vertex:it,beginnormal_vertex:ii,bsdfs:"float G_BlinnPhong_Implicit(){return 0.25;}float D_BlinnPhong(const in float shininess,const in float dotNH){return RECIPROCAL_PI*(shininess*0.5+1.0)*pow(dotNH,shininess);}vec3 BRDF_BlinnPhong(const in vec3 lightDir,const in vec3 viewDir,const in vec3 normal,const in vec3 specularColor,const in float shininess){vec3 halfDir=normalize(lightDir+viewDir);float dotNH=saturate(dot(normal,halfDir));float dotVH=saturate(dot(viewDir,halfDir));vec3 F=F_Schlick(specularColor,1.0,dotVH);float G=G_BlinnPhong_Implicit();float D=D_BlinnPhong(shininess,dotNH);return F*(G*D);}",iridescence_fragment:ir,bumpmap_pars_fragment:ia,clipping_planes_fragment:is,clipping_planes_pars_fragment:io,clipping_planes_pars_vertex:il,clipping_planes_vertex:ih,color_fragment:ic,color_pars_fragment:iu,color_pars_vertex:id,color_vertex:ip,common:im,cube_uv_reflection_fragment:ig,defaultnormal_vertex:iv,displacementmap_pars_vertex:i_,displacementmap_vertex:ix,emissivemap_fragment:iy,emissivemap_pars_fragment:iM,colorspace_fragment:"gl_FragColor=linearToOutputTexel(gl_FragColor);",colorspace_pars_fragment:"vec4 LinearToLinear(in vec4 value){return value;}vec4 LinearTosRGB(in vec4 value){return vec4(mix(pow(value.rgb,vec3(0.41666))*1.055-vec3(0.055),value.rgb*12.92,vec3(lessThanEqual(value.rgb,vec3(0.0031308)))),value.a);}",envmap_fragment:iS,envmap_common_pars_fragment:ib,envmap_pars_fragment:iw,envmap_pars_vertex:iT,envmap_physical_pars_fragment:iO,envmap_vertex:iE,fog_vertex:iA,fog_pars_vertex:iC,fog_fragment:iL,fog_pars_fragment:iP,gradientmap_pars_fragment:iR,lightmap_fragment:iD,lightmap_pars_fragment:iU,lights_lambert_fragment:"LambertMaterial material;material.diffuseColor=diffuseColor.rgb;material.specularStrength=specularStrength;",lights_lambert_pars_fragment:iI,lights_pars_begin:iN,lights_toon_fragment:"ToonMaterial material;material.diffuseColor=diffuseColor.rgb;",lights_toon_pars_fragment:iz,lights_phong_fragment:"BlinnPhongMaterial material;material.diffuseColor=diffuseColor.rgb;material.specularColor=specular;material.specularShininess=shininess;material.specularStrength=specularStrength;",lights_phong_pars_fragment:iF,lights_physical_fragment:ik,lights_physical_pars_fragment:iB,lights_fragment_begin:iH,lights_fragment_maps:iV,lights_fragment_end:iG,logdepthbuf_fragment:iW,logdepthbuf_pars_fragment:ij,logdepthbuf_pars_vertex:iq,logdepthbuf_vertex:iX,map_fragment:iY,map_pars_fragment:iZ,map_particle_fragment:iK,map_particle_pars_fragment:iJ,metalnessmap_fragment:iQ,metalnessmap_pars_fragment:i$,morphcolor_vertex:i0,morphnormal_vertex:i1,morphtarget_pars_vertex:i3,morphtarget_vertex:i2,normal_fragment_begin:i4,normal_fragment_maps:i5,normal_pars_fragment:i6,normal_pars_vertex:i8,normal_vertex:i7,normalmap_pars_fragment:i9,clearcoat_normal_fragment_begin:re,clearcoat_normal_fragment_maps:rt,clearcoat_pars_fragment:ri,iridescence_pars_fragment:rr,opaque_fragment:ra,packing:"vec3 packNormalToRGB(const in vec3 normal){return normalize(normal)*0.5+0.5;}vec3 unpackRGBToNormal(const in vec3 rgb){return 2.0*rgb.xyz-1.0;}const float PackUpscale=256./255.;const float UnpackDownscale=255./256.;const vec3 PackFactors=vec3(256.*256.*256.,256.*256.,256.);const vec4 UnpackFactors=UnpackDownscale/vec4(PackFactors,1.);const float ShiftRight8=1./256.;vec4 packDepthToRGBA(const in float v){vec4 r=vec4(fract(v*PackFactors),v);r.yzw-=r.xyz*ShiftRight8;return r*PackUpscale;}float unpackRGBAToDepth(const in vec4 v){return dot(v,UnpackFactors);}vec2 packDepthToRG(in highp float v){return packDepthToRGBA(v).yx;}float unpackRGToDepth(const in highp vec2 v){return unpackRGBAToDepth(vec4(v.xy,0.0,0.0));}vec4 pack2HalfToRGBA(vec2 v){vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}vec2 unpackRGBATo2Half(vec4 v){return vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));}float viewZToOrthographicDept
|
||
|
#define ENVMAP_TYPE_CUBE_UV
|
||
|
#include <cube_uv_reflection_fragment>
|
||
|
vec3 getSample(float theta,vec3 axis){float cosTheta=cos(theta);vec3 sampleDirection=vOutputDirection*cosTheta+cross(axis,vOutputDirection)*sin(theta)+axis*dot(axis,vOutputDirection)*(1.0-cosTheta);return bilinearCubeUV(envMap,sampleDirection,mipInt);}void main(){vec3 axis=latitudinal?poleAxis:cross(poleAxis,vOutputDirection);if(all(equal(axis,vec3(0.0)))){axis=vec3(vOutputDirection.z,0.0,-vOutputDirection.x);}axis=normalize(axis);gl_FragColor=vec4(0.0,0.0,0.0,1.0);gl_FragColor.rgb+=weights[0]*getSample(0.0,axis);for(int i=1;i<n;i++){if(i>=samples){break;}float theta=dTheta*float(i);gl_FragColor.rgb+=weights[i]*getSample(-1.0*theta,axis);gl_FragColor.rgb+=weights[i]*getSample(theta,axis);}}`,blending:0,depthTest:!1,depthWrite:!1});return n}(r,e,t)}return r}_compileMaterial(e){let t=new tI(this._lodPlanes[0],e);this._renderer.compile(t,ac)}_sceneToCubeUV(e,t,i,r){let a=new tG(90,1,t,i),n=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,h=o.toneMapping;o.getClearColor(au),o.toneMapping=0,o.autoClear=!1;let c=new ti({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new tI(new tO,c),d=!1,p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,d=!0):(c.color.copy(au),d=!0);for(let t=0;t<6;t++){let i=t%3;0===i?(a.up.set(0,n[t],0),a.lookAt(s[t],0,0)):1===i?(a.up.set(0,0,n[t]),a.lookAt(0,s[t],0)):(a.up.set(0,n[t],0),a.lookAt(0,0,s[t]));let l=this._cubeSize;a_(r,i*l,t>2?l:0,l,l),o.setRenderTarget(r),d&&o.render(u,a),o.render(e,a)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=h,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let i=this._renderer,r=301===e.mapping||302===e.mapping;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=ay()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=ax());let a=r?this._cubemapMaterial:this._equirectMaterial,n=new tI(this._lodPlanes[0],a),s=a.uniforms;s.envMap.value=e;let o=this._cubeSize;a_(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(n,ac)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){let i=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),r=am[(t-1)%am.length];this._blur(e,t-1,t,i,r)}t.autoClear=i}_blur(e,t,i,r,a){let n=this._pingPongRenderTarget;this._halfBlur(e,n,t,i,r,"latitudinal",a),this._halfBlur(n,e,i,i,r,"longitudinal",a)}_halfBlur(e,t,i,r,a,n,s){let o=this._renderer,l=this._blurMaterial;"latitudinal"!==n&&"longitudinal"!==n&&console.error("blur direction must be either latitudinal or longitudinal!");let h=new tI(this._lodPlanes[r],l),c=l.uniforms,u=this._sizeLods[i]-1,d=isFinite(a)?Math.PI/(2*u):2*Math.PI/39,p=a/d,f=isFinite(a)?1+Math.floor(3*p):20;f>20&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);let m=[],g=0;for(let e=0;e<20;++e){let t=e/p,i=Math.exp(-t*t/2);m.push(i),0===e?g+=i:e<f&&(g+=2*i)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;c.envMap.value=e.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===n,s&&(c.poleAxis.value=s);let{_lodMax:v}=this;c.dTheta.value=d,c.mipInt.value=v-i;let _=this._sizeLods[r],x=4*(this._cubeSize-_);a_(t,3*_*(r>v-4?r-v+4:0),x,3*_,2*_),o.setRenderTarget(t),o.render(h,ac)}}function av(e,t,i){let r=new H(e,t,i);return r.texture.mapping=306,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function a_(e,t,i,r,a){e.viewport.set(t,i,r,a),e.scissor.set(t,i,r,a)}function ax(){return new tH({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:aM(),fragmentShader:`precision mediump float;precision mediump int;varying vec3 vOutputDirection;uniform sampler2D envMap;
|
||
|
#include <common>
|
||
|
void main(){vec3 outputDirection=normalize(vOutputDirection);vec2 uv=equirectUv(outputDirection);gl_FragColor=vec4(texture2D(envMap,uv).rgb,1.0);}`,blending:0,depthTest:!1,depthWrite:!1})}function ay(){return new tH({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:aM(),fragmentShader:"precision mediump float;precision mediump int;uniform float flipEnvMap;varying vec3 vOutputDirection;uniform samplerCube envMap;void main(){gl_FragColor=textureCube(envMap,vec3(flipEnvMap*vOutputDirection.x,vOutputDirection.yz));}",blending:0,depthTest:!1,depthWrite:!1})}function aM(){return"precision mediump float;precision mediump int;attribute float faceIndex;varying vec3 vOutputDirection;vec3 getDirection(vec2 uv,float face){uv=2.0*uv-1.0;vec3 direction=vec3(uv,1.0);if(face==0.0){direction=direction.zyx;}else if(face==1.0){direction=direction.xzy;direction.xz*=-1.0;}else if(face==2.0){direction.x*=-1.0;}else if(face==3.0){direction=direction.zyx;direction.xz*=-1.0;}else if(face==4.0){direction=direction.xzy;direction.xy*=-1.0;}else if(face==5.0){direction.z*=-1.0;}return direction;}void main(){vOutputDirection=getDirection(uv,faceIndex);gl_Position=vec4(position,1.0);}"}function aS(e){let t=new WeakMap,i=null;function r(e){let i=e.target;i.removeEventListener("dispose",r);let a=t.get(i);void 0!==a&&(t.delete(i),a.dispose())}return{get:function(a){if(a&&a.isTexture){let n=a.mapping,s=303===n||304===n,o=301===n||302===n;if(s||o){if(a.isRenderTargetTexture&&!0===a.needsPMREMUpdate){a.needsPMREMUpdate=!1;let r=t.get(a);return null===i&&(i=new ag(e)),r=s?i.fromEquirectangular(a,r):i.fromCubemap(a,r),t.set(a,r),r.texture}if(t.has(a))return t.get(a).texture;{let n=a.image;if(!(s&&n&&n.height>0||o&&n&&function(e){let t=0;for(let i=0;i<6;i++)void 0!==e[i]&&t++;return 6===t}(n)))return null;{null===i&&(i=new ag(e));let n=s?i.fromEquirectangular(a):i.fromCubemap(a);return t.set(a,n),a.addEventListener("dispose",r),n.texture}}}}return a},dispose:function(){t=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function ab(e){let t={};function i(i){let r;if(void 0!==t[i])return t[i];switch(i){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(i)}return t[i]=r,r}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get:function(e){let t=i(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function aw(e,t,i,r){let a={},n=new WeakMap;function s(e){let o=e.target;for(let e in null!==o.index&&t.remove(o.index),o.attributes)t.remove(o.attributes[e]);for(let e in o.morphAttributes){let i=o.morphAttributes[e];for(let e=0,r=i.length;e<r;e++)t.remove(i[e])}o.removeEventListener("dispose",s),delete a[o.id];let l=n.get(o);l&&(t.remove(l),n.delete(o)),r.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(e){let i=[],r=e.index,a=e.attributes.position,s=0;if(null!==r){let e=r.array;s=r.version;for(let t=0,r=e.length;t<r;t+=3){let r=e[t+0],a=e[t+1],n=e[t+2];i.push(r,a,a,n,n
|
||
|
#include <packing>
|
||
|
void main(){const float samples=float(VSM_SAMPLES);float mean=0.0;float squared_mean=0.0;float uvStride=samples<=1.0?0.0:2.0/(samples-1.0);float uvStart=samples<=1.0?0.0:-1.0;for(float i=0.0;i<samples;i++){float uvOffset=uvStart+i*uvStride;
|
||
|
#ifdef HORIZONTAL_PASS
|
||
|
vec2 distribution=unpackRGBATo2Half(texture2D(shadow_pass,(gl_FragCoord.xy+vec2(uvOffset,0.0)*radius)/resolution));mean+=distribution.x;squared_mean+=distribution.y*distribution.y+distribution.x*distribution.x;
|
||
|
#else
|
||
|
float depth=unpackRGBAToDepth(texture2D(shadow_pass,(gl_FragCoord.xy+vec2(0.0,uvOffset)*radius)/resolution));mean+=depth;squared_mean+=depth*depth;
|
||
|
#endif
|
||
|
}mean=mean/samples;squared_mean=squared_mean/samples;float std_dev=sqrt(squared_mean-mean*mean);gl_FragColor=pack2HalfToRGBA(vec2(mean,std_dev));}`;function n2(e,t,i){let r=new t$,a=new x,n=new x,s=new k,o=new n0({depthPacking:3201}),l=new n1,h={},c=i.maxTextureSize,u={0:1,1:0,2:2},d=new tH({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new x},radius:{value:4}},vertexShader:"void main(){gl_Position=vec4(position,1.0);}",fragmentShader:n3}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new tg;f.setAttribute("position",new tn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new tI(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function _(t,i,r,a){let n=null,s=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)n=s;else if(n=!0===r.isPointLight?l:o,e.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){let e=n.uuid,t=i.uuid,r=h[e];void 0===r&&(r={},h[e]=r);let a=r[t];void 0===a&&(a=n.clone(),r[t]=a),n=a}if(n.visible=i.visible,n.wireframe=i.wireframe,3===a?n.side=null!==i.shadowSide?i.shadowSide:i.side:n.side=null!==i.shadowSide?i.shadowSide:u[i.side],n.alphaMap=i.alphaMap,n.alphaTest=i.alphaTest,n.map=i.map,n.clipShadows=i.clipShadows,n.clippingPlanes=i.clippingPlanes,n.clipIntersection=i.clipIntersection,n.displacementMap=i.displacementMap,n.displacementScale=i.displacementScale,n.displacementBias=i.displacementBias,n.wireframeLinewidth=i.wireframeLinewidth,n.linewidth=i.linewidth,!0===r.isPointLight&&!0===n.isMeshDistanceMaterial){let t=e.properties.get(n);t.light=r}return n}this.render=function(i,o,l){if(!1===g.enabled||!1===g.autoUpdate&&!1===g.needsUpdate||0===i.length)return;let h=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),x=e.state;x.setBlending(0),x.buffers.color.setClear(1,1,1,1),x.buffers.depth.setTest(!0),x.setScissorTest(!1);let y=3!==v&&3===this.type,M=3===v&&3!==this.type;for(let h=0,u=i.length;h<u;h++){let u=i[h],f=u.shadow;if(void 0===f){console.warn("THREE.WebGLShadowMap:",u,"has no shadow.");continue}if(!1===f.autoUpdate&&!1===f.needsUpdate)continue;a.copy(f.mapSize);let g=f.getFrameExtents();if(a.multiply(g),n.copy(f.mapSize),(a.x>c||a.y>c)&&(a.x>c&&(n.x=Math.floor(c/g.x),a.x=n.x*g.x,f.mapSize.x=n.x),a.y>c&&(n.y=Math.floor(c/g.y),a.y=n.y*g.y,f.mapSize.y=n.y)),null===f.map||!0===y||!0===M){let e=3!==this.type?{minFilter:1003,magFilter:1003}:{};null!==f.map&&f.map.dispose(),f.map=new H(a.x,a.y,e),f.map.texture.name=u.name+".shadowMap",f.camera.updateProjectionMatrix()}e.setRenderTarget(f.map),e.clear();let v=f.getViewportCount();for(let i=0;i<v;i++){let a=f.getViewport(i);s.set(n.x*a.x,n.y*a.y,n.x*a.z,n.y*a.w),x.viewport(s),f.updateMatrices(u,i),r=f.getFrustum(),function i(a,n,s,o,l){if(!1===a.visible)return;let h=a.layers.test(n.layers);if(h&&(a.isMesh||a.isLine||a.isPoints)&&(a.castShadow||a.receiveShadow&&3===l)&&(!a.frustumCulled||r.intersectsObject(a))){a.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,a.matrixWorld);let i=t.update(a),r=a.material;if(Array.isArray(r)){let t=i.groups;for(let n=0,h=t.length;n<h;n++){let h=t[n],c=r[h.materialIndex];if(c&&c.visible){let t=_(a,c,o,l);e.renderBufferDirect(s,null,i,t,a,h)}}}else if(r.visible){let t=_(a,r,o,l);e.renderBufferDirect(s,null,i,t,a,null)}}let c=a.children;for(let e=0,t=c.length;e<t;e++)i(c[e],n,s,o,l)}(o,l,f.camera,u,this.type)}!0!==f.isPointLightShadow&&3===this.type&&function(i,r){let n=t.update(m);d.defines.VSM_SAMPLES!==i.blurSamples&&(d.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new H(a.x,a.y)),d.uniforms.shadow_pass.value=i.map.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,e.setRenderTarget(i.mapPass),e.clear(),e.renderBufferDirect(r,null,n,d,m,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize
|
||
|
#ifndef FXAA_DISCARD
|
||
|
#define FXAA_DISCARD 0
|
||
|
#endif
|
||
|
#define FxaaTexTop(t,p)texture2D(t,p,-100.0)
|
||
|
#define FxaaTexOff(t,p,o,r)texture2D(t,p+(o*r),-100.0)
|
||
|
#define NUM_SAMPLES 5
|
||
|
float contrast(vec4 a,vec4 b){vec4 diff=abs(a-b);return max(max(max(diff.r,diff.g),diff.b),diff.a);}vec4 FxaaPixelShader(vec2 posM,sampler2D tex,vec2 fxaaQualityRcpFrame,float fxaaQualityEdgeThreshold,float fxaaQualityinvEdgeThreshold){vec4 rgbaM=FxaaTexTop(tex,posM);vec4 rgbaS=FxaaTexOff(tex,posM,vec2(0.0,1.0),fxaaQualityRcpFrame.xy);vec4 rgbaE=FxaaTexOff(tex,posM,vec2(1.0,0.0),fxaaQualityRcpFrame.xy);vec4 rgbaN=FxaaTexOff(tex,posM,vec2(0.0,-1.0),fxaaQualityRcpFrame.xy);vec4 rgbaW=FxaaTexOff(tex,posM,vec2(-1.0,0.0),fxaaQualityRcpFrame.xy);bool earlyExit=max(max(max(contrast(rgbaM,rgbaN),contrast(rgbaM,rgbaS)),contrast(rgbaM,rgbaE)),contrast(rgbaM,rgbaW))<fxaaQualityEdgeThreshold;
|
||
|
#if (FXAA_DISCARD==1)
|
||
|
if(earlyExit)FxaaDiscard;
|
||
|
#else
|
||
|
if(earlyExit)return rgbaM;
|
||
|
#endif
|
||
|
float contrastN=contrast(rgbaM,rgbaN);float contrastS=contrast(rgbaM,rgbaS);float contrastE=contrast(rgbaM,rgbaE);float contrastW=contrast(rgbaM,rgbaW);float relativeVContrast=(contrastN+contrastS)-(contrastE+contrastW);relativeVContrast*=fxaaQualityinvEdgeThreshold;bool horzSpan=relativeVContrast>0.;if(abs(relativeVContrast)<.3){vec2 dirToEdge;dirToEdge.x=contrastE>contrastW?1.:-1.;dirToEdge.y=contrastS>contrastN?1.:-1.;vec4 rgbaAlongH=FxaaTexOff(tex,posM,vec2(dirToEdge.x,-dirToEdge.y),fxaaQualityRcpFrame.xy);float matchAlongH=contrast(rgbaM,rgbaAlongH);vec4 rgbaAlongV=FxaaTexOff(tex,posM,vec2(-dirToEdge.x,dirToEdge.y),fxaaQualityRcpFrame.xy);float matchAlongV=contrast(rgbaM,rgbaAlongV);relativeVContrast=matchAlongV-matchAlongH;relativeVContrast*=fxaaQualityinvEdgeThreshold;if(abs(relativeVContrast)<.3){return mix(rgbaM,(rgbaN+rgbaS+rgbaE+rgbaW)*.25,.4);}horzSpan=relativeVContrast>0.;}if(!horzSpan)rgbaN=rgbaW;if(!horzSpan)rgbaS=rgbaE;bool pairN=contrast(rgbaM,rgbaN)>contrast(rgbaM,rgbaS);if(!pairN)rgbaN=rgbaS;vec2 offNP;offNP.x=(!horzSpan)?0.0:fxaaQualityRcpFrame.x;offNP.y=(horzSpan)?0.0:fxaaQualityRcpFrame.y;bool doneN=false;bool doneP=false;float nDist=0.;float pDist=0.;vec2 posN=posM;vec2 posP=posM;int iterationsUsed=0;int iterationsUsedN=0;int iterationsUsedP=0;for(int i=0;i<NUM_SAMPLES;i++){iterationsUsed=i;float increment=float(i+1);if(!doneN){nDist+=increment;posN=posM+offNP*nDist;vec4 rgbaEndN=FxaaTexTop(tex,posN.xy);doneN=contrast(rgbaEndN,rgbaM)>contrast(rgbaEndN,rgbaN);iterationsUsedN=i;}if(!doneP){pDist+=increment;posP=posM-offNP*pDist;vec4 rgbaEndP=FxaaTexTop(tex,posP.xy);doneP=contrast(rgbaEndP,rgbaM)>contrast(rgbaEndP,rgbaN);iterationsUsedP=i;}if(doneN||doneP)break;}if(!doneP&&!doneN)return rgbaM;float dist=min(doneN?float(iterationsUsedN)/float(NUM_SAMPLES-1):1.,doneP?float(iterationsUsedP)/float(NUM_SAMPLES-1):1.);dist=pow(dist,.5);dist=1.-dist;return mix(rgbaM,rgbaN,dist*.5);}void main(){const float edgeDetectionQuality=.2;const float invEdgeDetectionQuality=1./edgeDetectionQuality;gl_FragColor=FxaaPixelShader(vUv,tDiffuse,resolution,edgeDetectionQuality,invEdgeDetectionQuality);}`};function ou(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class od extends sb{async loadAndPaint(){await document.fonts.load(this.font,this.text),this.paint()}paint(){let e=document.createElement("canvas"),t=e.getContext("2d");t.font=this.font;let i=t.measureText(this.text);e.width=this.margin[3]+i.actualBoundingBoxLeft+i.actualBoundingBoxRight+this.margin[1],e.height=this.margin[0]+i.actualBoundingBoxAscent+i.actualBoundingBoxDescent+this.margin[2],(t=e.getContext("2d")).font=this.font,t.fillStyle=this.backgroundStyle,t.fillRect(0,0,e.width,e.height),t.fillStyle=this.textStyle,t.fillText(this.text,this.margin[3]+i.actualBoundingBoxLeft,this.margin[0]+i.actualBoundingBoxAscent);let r=new sT(e);r.magFilter=1003,r.minFilter=1003,this.textMaterial.map=r,this.textMaterial.needsUpdate=!0,this.scale.x=e.width/e.height*this.height,this.scale.y=this.height}constructor(e="",t={}){let i=new sc({transparent:!0,alphaTest:1e-5});super(i),ou(this,"painted",void 0),ou(this,"text",void 0),ou(this,"font",void 0),ou(this,"margin",void 0),ou(this,"textStyle",void 0),ou(this,"backgroundStyle",void 0),ou(this,"height",void 0),ou(this,"textMaterial",void 0),this.textMaterial=i,this.text=e,this.font=void 0===t.font?"48px Minecraft":t.font,this.margin=void 0===t.margin?[5,10,5,10]:t.margin,this.textStyle=void 0===t.textStyle?"white":t.textStyle,this.backgroundStyle=void 0===t.backgroundStyle?"rgba(0,0,0,.25)":t.backgroundStyle,this.height=void 0===t.height?4:t.height;let r=void 0===t.repaintAfterLoaded||t.repaintAfterLoaded;r&&!document.fonts.check(this.font,this.text)?(this.paint(),this.painted=this.loadAndPaint()):(this.paint(),this.painted=Promise.resolve())}}function op(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function of(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writabl
|