@threepipe/webgi-plugins 0.8.0 → 0.9.0-r172.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/LICENSE +190 -141
- package/README.md +2 -17
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/index.js +184 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +185 -43
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/buffer/VelocityBufferPlugin.d.ts +23 -0
- package/dist/plugins/buffer/VelocityBufferPlugin.d.ts.map +1 -1
- package/dist/plugins/extras/AnisotropyPlugin.d.ts +1 -1
- package/dist/plugins/extras/AnisotropyPlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/OutlinePlugin.d.ts +3 -0
- package/dist/plugins/postprocessing/OutlinePlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/TemporalAAPlugin.d.ts +14 -0
- package/dist/plugins/postprocessing/TemporalAAPlugin.d.ts.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AdvancedGroundPlugin.html +64 -64
- package/docs/classes/AnisotropyPlugin.html +32 -32
- package/docs/classes/BloomPlugin.html +36 -36
- package/docs/classes/BloomPluginPass.html +28 -28
- package/docs/classes/DepthOfFieldPlugin.html +40 -40
- package/docs/classes/DepthOfFieldPluginPass.html +31 -31
- package/docs/classes/OutlinePlugin.html +64 -64
- package/docs/classes/OutlineRenderPass.html +18 -18
- package/docs/classes/SSContactShadowsPlugin.html +35 -35
- package/docs/classes/SSGIPlugin.html +40 -40
- package/docs/classes/SSGIPluginPass.html +38 -38
- package/docs/classes/SSReflectionPlugin.html +41 -41
- package/docs/classes/SSReflectionPluginPass.html +39 -39
- package/docs/classes/SSVelocityMaterial.html +22 -7
- package/docs/classes/TemporalAAPlugin.html +34 -34
- package/docs/classes/TemporalAAPluginPass.html +68 -28
- package/docs/classes/VelocityBufferPlugin.html +62 -42
- package/docs/classes/WatchHandsPlugin.html +39 -39
- package/docs/types/OutlinePluginPass.html +1 -1
- package/docs/types/OutlinePluginTarget.html +1 -1
- package/docs/types/SSGIPluginTarget.html +1 -1
- package/docs/types/SSReflectionPluginTarget.html +1 -1
- package/docs/types/VelocityBufferPluginPass.html +1 -1
- package/docs/types/VelocityBufferPluginTarget.html +1 -1
- package/docs/variables/anisotropyGLTFExtension.html +3 -3
- package/docs/variables/webgiPlugins.html +1 -1
- package/package.json +6 -3
- package/src/plugins/buffer/VelocityBufferPlugin.ts +119 -8
- package/src/plugins/buffer/shaders/VelocityBufferPlugin.mat.frag.glsl +9 -1
- package/src/plugins/buffer/shaders/VelocityBufferPlugin.mat.vert.glsl +14 -1
- package/src/plugins/extras/AnisotropyPlugin.ts +2 -2
- package/src/plugins/postprocessing/OutlinePlugin.ts +53 -38
- package/src/plugins/postprocessing/SSContactShadowsPlugin.ts +1 -1
- package/src/plugins/postprocessing/TemporalAAPlugin.ts +42 -0
- package/src/utils/shaders/temporalaa.glsl +9 -0
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @threepipe/webgi-plugins v0.
|
|
3
|
+
* @threepipe/webgi-plugins v0.9.0-r172.1
|
|
4
4
|
* Copyright 2023-2026 repalash <palash@shaders.app> (https://repalash.com)
|
|
5
|
-
*
|
|
5
|
+
* Apache-2.0 License
|
|
6
6
|
* See ./dependencies.txt for any bundled third-party dependencies and licenses.
|
|
7
7
|
*/
|
|
8
8
|
(function(global, factory) {
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
// src/plugins/buffer/shaders/VelocityBufferPlugin.unpack.glsl
|
|
13
13
|
var VelocityBufferPlugin_unpack_default = "#if defined(HAS_VELOCITY_BUFFER)\nuniform sampler2D tVelocity;vec2 getVelocity(const in vec2 uv){vec2 screenSpaceVelocity=texture2D(tVelocity,uv).xy*2.0-1.0;return sign(screenSpaceVelocity)*pow(abs(screenSpaceVelocity),vec2(4.));}\n#endif\n";
|
|
14
14
|
// src/plugins/buffer/shaders/VelocityBufferPlugin.mat.vert.glsl
|
|
15
|
-
var VelocityBufferPlugin_mat_vert_default = "#ifdef USE_ALPHAMAP\n#define USE_UV\n#endif\n#include <uv_pars_vertex>\n#include <batching_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec3 vWorldPosition;varying vec3 vWorldPositionPrevious;uniform mat4 modelMatrixPrevious;
|
|
15
|
+
var VelocityBufferPlugin_mat_vert_default = "#ifdef USE_ALPHAMAP\n#define USE_UV\n#endif\n#include <uv_pars_vertex>\n#include <batching_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec3 vWorldPosition;varying vec3 vWorldPositionPrevious;uniform mat4 modelMatrixPrevious;\n#ifdef USE_INSTANCING\nuniform sampler2D instanceMatrixPrevious;uniform bool hasInstanceMatrixPrevious;mat4 getInstanceMatrixPrevious(){int x=(gl_InstanceID % 1024)*4,y=gl_InstanceID/1024;return mat4(texelFetch(instanceMatrixPrevious,ivec2(x,y),0),texelFetch(instanceMatrixPrevious,ivec2(x+1,y),0),texelFetch(instanceMatrixPrevious,ivec2(x+2,y),0),texelFetch(instanceMatrixPrevious,ivec2(x+3,y),0));}\n#endif\nvoid main(){\n#include <uv_vertex>\n#include <batching_vertex>\n#include <skinbase_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\nvec4 mvPosition=vec4(transformed,1.0);vec4 previousPosition=mvPosition;\n#ifdef USE_INSTANCING\npreviousPosition=hasInstanceMatrixPrevious ? getInstanceMatrixPrevious()*mvPosition : instanceMatrix*mvPosition;mvPosition=instanceMatrix*mvPosition;\n#endif\nvWorldPosition=(modelMatrix*mvPosition).xyz;vWorldPositionPrevious=(modelMatrixPrevious*previousPosition).xyz;mvPosition=modelViewMatrix*mvPosition;gl_Position=projectionMatrix*mvPosition;\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n}";
|
|
16
16
|
// src/plugins/buffer/shaders/VelocityBufferPlugin.mat.frag.glsl
|
|
17
|
-
var VelocityBufferPlugin_mat_frag_default = "#ifdef USE_ALPHAMAP\n#define USE_UV\n#include <packing>\nuniform sampler2D alphaMap;uniform float alphaTest;\n#endif\n#include <uv_pars_fragment>\nvarying vec3 vWorldPosition;varying vec3 vWorldPositionPrevious;uniform mat4 currentProjectionViewMatrix;uniform mat4 lastProjectionViewMatrix
|
|
17
|
+
var VelocityBufferPlugin_mat_frag_default = "#ifdef USE_ALPHAMAP\n#define USE_UV\n#include <packing>\nuniform sampler2D alphaMap;uniform float alphaTest;\n#endif\n#include <uv_pars_fragment>\nvarying vec3 vWorldPosition;varying vec3 vWorldPositionPrevious;uniform mat4 currentProjectionViewMatrix;uniform mat4 lastProjectionViewMatrix;\n#ifdef VELOCITY_SPLIT\nuniform float velocitySplitX;\n#endif\nvec2 computeScreenSpaceVelocity2(){vec4 currentPositionClip=currentProjectionViewMatrix*vec4(vWorldPosition,1.0);vec3 previousWorld=vWorldPositionPrevious;\n#ifdef VELOCITY_SPLIT\nif(currentPositionClip.x/currentPositionClip.w*0.5+0.5<velocitySplitX)previousWorld=vWorldPosition;\n#endif\nvec4 prevPositionClip=lastProjectionViewMatrix*vec4(previousWorld,1.0);vec2 currentPositionNDC=currentPositionClip.xy/currentPositionClip.w;vec2 prevPositionNDC=prevPositionClip.xy/prevPositionClip.w;if(prevPositionNDC.x>=1.0||prevPositionNDC.x<=-1.0||prevPositionNDC.x>=1.0||prevPositionNDC.y<=-1.0){return vec2(0.0);}return 0.5*(currentPositionNDC-prevPositionNDC);}void main(){\n#ifdef USE_ALPHAMAP\nfloat alphaMapValue=\n#ifdef ALPHA_I_RGBA_PACKING\n1.-unpackRGBAToDepth(texture2D(alphaMap,vAlphaMapUv));\n#else\ntexture2D(alphaMap,vAlphaMapUv).g;\n#endif\nif(alphaMapValue<alphaTest)discard;\n#endif\nvec2 velocity=clamp(computeScreenSpaceVelocity2(),-1.0,1.0);velocity=sign(velocity)*pow(abs(velocity),vec2(1./4.));velocity=velocity*0.5+0.5;gl_FragColor=vec4(velocity.x,velocity.y,1.,1.);}";
|
|
18
18
|
// src/utils/shaders.ts
|
|
19
19
|
var shadersUtils2 = {
|
|
20
20
|
computeScreenSpaceVelocity: "uniform mat4 lastProjectionViewMatrix;uniform mat4 currentProjectionViewMatrix;vec2 computeScreenSpaceVelocity(const in vec3 worldPosition){vec4 currentPositionClip=currentProjectionViewMatrix*vec4(worldPosition,1.0);vec4 prevPositionClip=lastProjectionViewMatrix*vec4(worldPosition,1.0);vec2 currentPositionNDC=currentPositionClip.xy/currentPositionClip.w;vec2 prevPositionNDC=prevPositionClip.xy/prevPositionClip.w;if(prevPositionNDC.x>=1.0||prevPositionNDC.x<=-1.0||prevPositionNDC.x>=1.0||prevPositionNDC.y<=-1.0){return vec2(0.0);}return 0.5*(currentPositionNDC-prevPositionNDC);}",
|
|
21
21
|
getWorldPositionFromViewZ: "uniform mat4 inverseViewMatrix;vec3 getWorldPositionFromViewZ(const in vec2 uv,const in float viewDepth){vec2 uv_=2.*uv-1.;float xe=-(uv_.x+projection[2][0])*viewDepth/projection[0][0];float ye=-(uv_.y+projection[2][1])*viewDepth/projection[1][1];return(inverseViewMatrix*vec4(xe,ye,viewDepth,1.)).xyz;}",
|
|
22
|
-
temporalAA: "#include <common>\n#include <gbuffer_unpack>\n#ifdef HAS_VELOCITY_BUFFER\n#pragma <velocity_unpack>\n#else\n#define HAS_VELOCITY_BUFFER 0\n#endif\n#include <cameraHelpers>\nvarying vec2 vUv;uniform vec2 previousRTSize;uniform vec2 jitterSample;uniform vec2 feedBack;uniform bool firstFrame
|
|
22
|
+
temporalAA: "#include <common>\n#include <gbuffer_unpack>\n#ifdef HAS_VELOCITY_BUFFER\n#pragma <velocity_unpack>\n#else\n#define HAS_VELOCITY_BUFFER 0\n#endif\n#include <cameraHelpers>\nvarying vec2 vUv;uniform vec2 previousRTSize;uniform vec2 jitterSample;uniform vec2 feedBack;uniform bool firstFrame;\n#ifdef TAA_SPLIT\nuniform float taaSplitX;\n#endif\nvec3 find_closest_fragment_3x3(const in vec2 uv){const vec3 offset=vec3(-1.0,1.0,0.0);vec2 texelSize=1.0/previousRTSize;vec3 dtr=vec3(1,1,getDepth(uv+offset.yy*texelSize));vec3 dtc=vec3(0,1,getDepth(uv+offset.zy*texelSize));vec3 dtl=vec3(-1,1,getDepth(uv+offset.xy*texelSize));vec3 dml=vec3(-1,0,getDepth(uv+offset.xz*texelSize));vec3 dmc=vec3(0,0,getDepth(uv));vec3 dmr=vec3(1,0,getDepth(uv+offset.yz*texelSize));vec3 dbl=vec3(-1,-1,getDepth(uv+offset.xx*texelSize));vec3 dbc=vec3(0,-1,getDepth(uv+offset.zx*texelSize));vec3 dbr=vec3(1,-1,getDepth(uv+offset.yx*texelSize));vec3 dmin=dtl;if(dmin.z>dtc.z)dmin=dtc;if(dmin.z>dtr.z)dmin=dtr;if(dmin.z>dml.z)dmin=dml;if(dmin.z>dmc.z)dmin=dmc;if(dmin.z>dmr.z)dmin=dmr;if(dmin.z>dbl.z)dmin=dbl;if(dmin.z>dbc.z)dmin=dbc;if(dmin.z>dbr.z)dmin=dbr;return vec3(uv+texelSize.xy*dmin.xy,dmin.z);}vec3 find_closest_fragment_5tap(const in vec2 uv){vec2 texelSize=1.0/previousRTSize;vec2 offset=vec2(1.0,-1.0);vec3 dtl=vec3(-1,1,getDepth(uv+offset.yx*texelSize));vec3 dtr=vec3(1,1,getDepth(uv+offset.xx*texelSize));vec3 dmc=vec3(0,0,getDepth(uv));vec3 dbl=vec3(-1,-1,getDepth(uv+offset.yy*texelSize));vec3 dbr=vec3(1,-1,getDepth(uv+offset.xy*texelSize));vec3 dmin=dtl;if(dmin.z>dtr.z)dmin=dtr;if(dmin.z>dmc.z)dmin=dmc;if(dmin.z>dbl.z)dmin=dbl;if(dmin.z>dbr.z)dmin=dbr;return vec3(uv+dmin.xy*texelSize,dmin.z);}vec4 clip_aabb(const in vec4 aabb_min,const in vec4 aabb_max,vec4 p){const float FLT_EPS=1e-8;vec4 p_clip=0.5*(aabb_max+aabb_min);vec4 e_clip=0.5*(aabb_max-aabb_min)+FLT_EPS;vec4 v_clip=p-p_clip;vec4 v_unit=abs(v_clip/e_clip);float ma_unit=max(v_unit.x,max(v_unit.y,v_unit.z));if(ma_unit>1.0)return p_clip+v_clip/ma_unit;else return p;}\n#if HAS_VELOCITY_BUFFER == 0 || defined(DEBUG_VELOCITY)\n#include <computeScreenSpaceVelocity>\n#include <getWorldPositionFromViewZ>\n#endif\nvec4 currentRTTexelToLinear1(vec4 a){if(isinf(a.x)||isinf(a.y)||isinf(a.z)||isinf(a.w)){return vec4(1.);}return currentRTTexelToLinear(a);}vec4 computeTAA(const in vec2 uv,const in vec2 screenSpaceVelocity,const in float feedbackScale){vec2 uvUnJitter=uv;vec4 currentColor=currentRTTexelToLinear(texture2D(currentRT,uvUnJitter));vec4 previousColor=previousRTTexelToLinear(texture2D(previousRT,uv-screenSpaceVelocity));const vec3 offset=vec3(1.,-1.,0.);vec2 texelSize=1./previousRTSize;float texelSpeed=length(screenSpaceVelocity);vec4 tl=currentRTTexelToLinear1(texture2D(currentRT,uvUnJitter+offset.yx*texelSize));vec4 tc=currentRTTexelToLinear1(texture2D(currentRT,uvUnJitter+offset.zx*texelSize));vec4 tr=currentRTTexelToLinear1(texture2D(currentRT,uvUnJitter+offset.xx*texelSize));vec4 ml=currentRTTexelToLinear1(texture2D(currentRT,uvUnJitter+offset.yz*texelSize));vec4 mc=currentColor;vec4 mr=currentRTTexelToLinear1(texture2D(currentRT,uvUnJitter+offset.xz*texelSize));vec4 bl=currentRTTexelToLinear1(texture2D(currentRT,uvUnJitter+offset.yy*texelSize));vec4 bc=currentRTTexelToLinear1(texture2D(currentRT,uvUnJitter+offset.zy*texelSize));vec4 br=currentRTTexelToLinear1(texture2D(currentRT,uvUnJitter+offset.xy*texelSize));mc=max(vec4(0.0),mc+0.2718*(4.0*mc-(tl+tr+bl+br)));vec4 min5=min(tc,min(ml,min(mc,min(mr,bc))));vec4 max5=max(tc,max(ml,max(mc,max(mr,bc))));vec4 cmin=min(min5,min(tl,min(tr,min(bl,br))));vec4 cmax=max(min5,max(tl,max(tr,max(bl,br))));;cmin=0.5*(cmin+min5);cmax=0.5*(cmax+max5);\n#ifndef TAA_NO_CLAMP\npreviousColor=clip_aabb(cmin,cmax,previousColor);\n#endif\nfloat lum0=luminance(currentColor.rgb);float lum1=luminance(previousColor.rgb);float unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedBack.x,feedBack.y,unbiased_weight_sqr);return mix(currentColor,previousColor,clamp(k_feedback*feedbackScale,0.,1.));}void main(){\n#if HAS_VELOCITY_BUFFER == 0\n#if QUALITY == 1\nvec3 c_frag=find_closest_fragment_3x3(vUv);\n#else\nvec3 c_frag=find_closest_fragment_5tap(vUv);\n#endif\n#else\nvec3 c_frag=vec3(vUv,0.);\n#endif\nbool bg=firstFrame;\n#ifdef TAA_SPLIT\nbg=bg||vUv.x<taaSplitX;\n#endif\n#if BACKGROUND_TAA\nfloat d=c_frag.z;float edgef=min(1.,max(0.,1.-(d*100.-99.)));\n#else\nbg=bg||c_frag.z>0.999;\n#endif\nif(bg){gl_FragColor=currentRTTexelToLinear1(texture2D(currentRT,vUv));}else{\n#if HAS_VELOCITY_BUFFER == 0\nfloat sampleViewZ=mix(-cameraNearFar.x,-cameraNearFar.y,c_frag.z);vec3 worldPosition=getWorldPositionFromViewZ(c_frag.xy,sampleViewZ);vec2 screenSpaceVelocity=computeScreenSpaceVelocity(worldPosition);\n#else\nvec2 screenSpaceVelocity=getVelocity(c_frag.xy);\n#endif\n#if BACKGROUND_TAA\ngl_FragColor=computeTAA(vUv,screenSpaceVelocity*edgef,edgef);\n#else\ngl_FragColor=computeTAA(vUv,screenSpaceVelocity,1.);\n#endif\n}\n#include <colorspace_fragment>\n#ifdef DEBUG_VELOCITY\nfloat sampleViewZ=mix(-cameraNearFar.x,-cameraNearFar.y,c_frag.z);vec3 worldPosition=getWorldPositionFromViewZ(c_frag.xy,sampleViewZ);vec2 screenSpaceVelocity=computeScreenSpaceVelocity(worldPosition);gl_FragColor=vec4(10.*length(screenSpaceVelocity),0.,0.,1.);\n#endif\n}",
|
|
23
23
|
ssReflection: "uniform float currentFrameCount;\n#ifndef D_frameCount\n#define D_frameCount\nuniform float frameCount;\n#endif\nuniform float objectRadius;uniform float radius;uniform float tolerance;uniform float ssrRoughnessFactor;uniform bool autoRadius;\n#ifndef D_sceneBoundingRadius\n#define D_sceneBoundingRadius\nuniform float sceneBoundingRadius;\n#endif\n#if SSREFL_ENABLED == 2\nuniform float ssrSplitX;\n#endif\n#ifdef HAS_VELOCITY_BUFFER\n#pragma <velocity_unpack>\n#else\n#define HAS_VELOCITY_BUFFER 0\n#endif\n#if HAS_VELOCITY_BUFFER == 0\n#include <computeScreenSpaceVelocity>\n#include <getWorldPositionFromViewZ>\n#endif\nvec3 ComputeReflectionL(vec3 N,vec2 E,vec3 V,float rough){float rough4=rough*rough*rough*rough;float phi=2.0*PI*E.x;float cos_theta=pow(max(E.y,0.000001),rough4/(2.0-rough4));float sin_theta=sqrt(max(0.,1.0-cos_theta*cos_theta));vec3 half_vec=vec3(sin_theta*cos(phi),sin_theta*sin(phi),cos_theta);vec3 tangentX=normalize(cross(abs(N.z)<0.999 ? vec3(0.0,0.0,1.0): vec3(1.0,0.0,0.0),N));vec3 tangentY=cross(N,tangentX);half_vec=half_vec.x*tangentX+half_vec.y*tangentY+half_vec.z*N;vec3 ray_dir=(2.0*dot(V,half_vec))*half_vec-V;return ray_dir;}vec2 GetRandomE(float seed){vec2 rand_e;rand_e.x=interleavedGradientNoise(gl_FragCoord.xy,frameCount*34.+seed);rand_e.y=fract(rand_e.x*38.65435);rand_e.y=mix(rand_e.y,1.0,0.7);return rand_e;}vec4 calculateSSR(in float seed,in vec3 screenPos,in vec3 normal,in float radiusFactor,in float roughness){vec3 viewPos=screenToView3(screenPos.xy,screenPos.z);normal=normalize(normal);vec2 E=GetRandomE(seed);vec3 L=ComputeReflectionL(normal,E,-normalize(viewPos),roughness*ssrRoughnessFactor);L=normalize(L);float cameraDist=length(cameraPositionWorld);float rayLen=objectRadius*sceneBoundingRadius;rayLen=autoRadius ?min(max(mix(max(0.0,(cameraDist+rayLen)+viewPos.z),max(0.0,-viewPos.z-max(0.0,cameraDist-rayLen)),L.z*0.5+0.5),rayLen*0.1),rayLen*5.):rayLen;rayLen*=radiusFactor;float r=interleavedGradientNoise(gl_FragCoord.xy,frameCount+seed);rayLen=max(rayLen,0.001);int steps=SSR_STEP_COUNT/(currentFrameCount<float(SSR_LOW_QUALITY_FRAMES)? 2 : 1);vec3 state=vec3(0.,(r+0.5)/float(steps),2.);viewPos+=normal*max(-0.0001*viewPos.z,0.001);vec3 screenHitP=traceRay(viewPos,L*rayLen,tolerance*rayLen,state,steps);if(state.z<0.99){if(currentFrameCount<1.){\n#if HAS_VELOCITY_BUFFER == 0\nvec3 worldPosition=getWorldPositionFromViewZ(screenHitP.xy,screenHitP.z);vec2 screenSpaceVelocity=computeScreenSpaceVelocity(worldPosition);\n#else\nvec2 screenSpaceVelocity=getVelocity(screenHitP.xy);\n#endif\nscreenHitP.xy-=screenSpaceVelocity;}vec3 hitColor=(tLastFrameTexelToLinear(texture2D(tLastFrame,screenHitP.xy))).rgb;float ssrWeight=1.;return vec4(hitColor*ssrWeight,1.);}return vec4(0.);}",
|
|
24
24
|
calculateGI: "uniform float currentFrameCount;uniform float intensity;uniform float objectRadius;uniform float rayCount;uniform float power;uniform float bias;uniform float falloff;uniform float tolerance;uniform bool autoRadius;uniform vec2 screenSize;\n#ifndef D_sceneBoundingRadius\n#define D_sceneBoundingRadius\nuniform float sceneBoundingRadius;\n#endif\n#ifdef HAS_VELOCITY_BUFFER\n#pragma <velocity_unpack>\n#else\n#define HAS_VELOCITY_BUFFER 0\n#endif\n#if HAS_VELOCITY_BUFFER == 0\n#include <computeScreenSpaceVelocity>\n#include <getWorldPositionFromViewZ>\n#endif\nvec3 ComputeUniformL(vec3 N,vec2 E){vec3 L;L.xy=E;L.z=interleavedGradientNoise(gl_FragCoord.xy,currentFrameCount*5.);L=L*2.-1.;return L;}vec2 GetRandomE(float seed){vec2 rand_e;rand_e.x=random3(vec3(gl_FragCoord.xy,currentFrameCount+seed));rand_e.y=random3(vec3(gl_FragCoord.yx,rand_e.x+(currentFrameCount)*7.));return rand_e;}float saturate2(float v,float mx){return max(0.,min(mx,v));}vec4 calculateGI(in float seed,in vec3 screenPos,in vec3 normal,in float radiusFactor){vec3 viewPos=screenToView3(screenPos.xy,screenPos.z);normal=normalize(normal);vec2 E=GetRandomE(seed);vec3 L=ComputeUniformL(normal,E);L=normalize(L);L*=sign(dot(L,normal));float cameraDist=length(cameraPositionWorld);float rayLen=objectRadius*sceneBoundingRadius;rayLen=autoRadius ?min(max(mix(max(0.0,(cameraDist+rayLen)+viewPos.z),max(0.0,-viewPos.z-max(0.0,cameraDist-rayLen)),L.z*0.5+0.5),rayLen*0.1),rayLen*5.):rayLen;rayLen*=radiusFactor;float r=interleavedGradientNoise(gl_FragCoord.xy,currentFrameCount*14.+seed)+0.05;rayLen=max(rayLen,0.001);vec3 state=vec3(1.,(r+0.5)/float(RTAO_STEP_COUNT),2.);viewPos+=normal*max(-0.01*viewPos.z,0.001);vec3 screenHitP=traceRay(viewPos,L*rayLen,tolerance*rayLen,state,RTAO_STEP_COUNT);vec3 viewHitP=screenToView3(screenHitP.xy,screenHitP.z);vec3 LRes=viewHitP-viewPos;if(state.z>1.)LRes=vec3(9999999.);float dist=length(LRes)*falloff;float EPS=0.01;float zBias=(viewPos.z)*bias;float ao=(max(dot(normal,L)+zBias,0.))/(dist*dist+EPS);\n#if defined(SSGI_ENABLED) && SSGI_ENABLED > 0\nif(currentFrameCount<1.){\n#if HAS_VELOCITY_BUFFER == 0\nvec3 worldPosition=getWorldPositionFromViewZ(screenHitP.xy,screenHitP.z);vec2 screenSpaceVelocity=computeScreenSpaceVelocity(worldPosition);\n#else\nvec2 screenSpaceVelocity=getVelocity(screenHitP.xy);\n#endif\nscreenHitP.xy-=screenSpaceVelocity;}vec3 hitColor=tLastFrameTexelToLinear(texture2D(tLastFrame,screenHitP.xy)).rgb;vec3 hitNormal=getViewNormal(screenHitP.xy);float giWeight=1.;giWeight=saturate2(giWeight/(dist+EPS),1.);giWeight*=saturate2((dot(normal,L)),1.0);giWeight*=saturate2((dot(hitNormal,-L)),1.0);return vec4(hitColor*giWeight,ao);\n#endif\nreturn vec4(0,0,0,ao);}float normpdf(in float x,in float sigma){return exp(-0.5*x*x/(sigma*sigma));}vec4 getLastThis(sampler2D tex,float depth,vec3 normal){vec2 direction=vec2(1,1);vec4 color=clamp(tLastThisTexelToLinear(texture2D(tex,vUv.xy)),0.,5.);return color;}void main(){float depth;vec3 normal;getDepthNormal(vUv,depth,normal);if(depth>0.99){discard;gl_FragColor=getLastThis(tLastThis,depth,normal);return;}float viewZ=depthToViewZ(depth);vec3 screenPos=vec3(vUv.x,vUv.y,viewZ);vec4 gi=vec4(0.);gi+=calculateGI(8.,screenPos,normal,1.);if(rayCount>1.5)gi=max(gi,calculateGI(2.,screenPos,normal,0.4));if(rayCount>2.5)gi=max(gi,calculateGI(3.,screenPos,normal,1.5));if(rayCount>3.5)gi=max(gi,calculateGI(1.,screenPos,normal,0.6));if(rayCount>4.5)gi=max(gi,calculateGI(3.,screenPos,normal,1.));gi.a=min(1.,gi.a);gi.a=max(0.,gi.a);gi.rgb=min(vec3(3.),gi.rgb);gi.rgb=max(vec3(0.),gi.rgb);if(currentFrameCount<3.){gl_FragColor=gi;return;}gl_FragColor=(texture2D(tLastThis,vUv));gl_FragColor=((gi+(gl_FragColor)*currentFrameCount)/(currentFrameCount+1.));}",
|
|
25
25
|
["__inited"]: false
|
|
@@ -138,7 +138,8 @@
|
|
|
138
138
|
projection: { value: new threepipe.Matrix4() },
|
|
139
139
|
inverseViewMatrix: { value: new threepipe.Matrix4() },
|
|
140
140
|
jitterSample: { value: new threepipe.Vector2() },
|
|
141
|
-
firstFrame: { value: true }
|
|
141
|
+
firstFrame: { value: true },
|
|
142
|
+
taaSplitX: { value: 0 }
|
|
142
143
|
},
|
|
143
144
|
defines: {
|
|
144
145
|
["QUALITY"]: 1,
|
|
@@ -152,6 +153,8 @@
|
|
|
152
153
|
this.taaEnabled = true;
|
|
153
154
|
this.feedBack = new threepipe.Vector2(.88, .97);
|
|
154
155
|
this.debugVelocity = false;
|
|
156
|
+
this.split = 0;
|
|
157
|
+
this.clamp = true;
|
|
155
158
|
this.uiConfig = {
|
|
156
159
|
type: "folder",
|
|
157
160
|
label: "Temporal AA Pass",
|
|
@@ -193,6 +196,25 @@
|
|
|
193
196
|
super.setSize(width, height);
|
|
194
197
|
this.onSizeUpdate();
|
|
195
198
|
}
|
|
199
|
+
_clampChanged() {
|
|
200
|
+
const off = !this.clamp;
|
|
201
|
+
if (!!this.material.defines.TAA_NO_CLAMP !== off) {
|
|
202
|
+
if (off) this.material.defines.TAA_NO_CLAMP = 1;
|
|
203
|
+
else delete this.material.defines.TAA_NO_CLAMP;
|
|
204
|
+
this.material.needsUpdate = true;
|
|
205
|
+
}
|
|
206
|
+
this.setDirty();
|
|
207
|
+
}
|
|
208
|
+
_splitChanged() {
|
|
209
|
+
const on = this.split > 0;
|
|
210
|
+
this.uniforms.taaSplitX.value = this.split;
|
|
211
|
+
if (!!this.material.defines.TAA_SPLIT !== on) {
|
|
212
|
+
if (on) this.material.defines.TAA_SPLIT = 1;
|
|
213
|
+
else delete this.material.defines.TAA_SPLIT;
|
|
214
|
+
this.material.needsUpdate = true;
|
|
215
|
+
}
|
|
216
|
+
this.setDirty();
|
|
217
|
+
}
|
|
196
218
|
};
|
|
197
219
|
__decorate([
|
|
198
220
|
(0, threepipe.serialize)(),
|
|
@@ -200,6 +222,16 @@
|
|
|
200
222
|
(0, threepipe.uiVector)("Feedback", void 0, 1e-4)
|
|
201
223
|
], TemporalAAPluginPass.prototype, "feedBack", void 0);
|
|
202
224
|
__decorate([(0, threepipe.uiToggle)(), (0, threepipe.matDefineBool)("DEBUG_VELOCITY", void 0, false, void 0, true)], TemporalAAPluginPass.prototype, "debugVelocity", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
(0, threepipe.uiSlider)("Split", [0, 1], .01, { tags: ["debug"] }),
|
|
227
|
+
(0, threepipe.onChange)(TemporalAAPluginPass.prototype._splitChanged),
|
|
228
|
+
(0, threepipe.serialize)()
|
|
229
|
+
], TemporalAAPluginPass.prototype, "split", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
(0, threepipe.uiToggle)("Clamp history", { tags: ["debug"] }),
|
|
232
|
+
(0, threepipe.onChange)(TemporalAAPluginPass.prototype._clampChanged),
|
|
233
|
+
(0, threepipe.serialize)()
|
|
234
|
+
], TemporalAAPluginPass.prototype, "clamp", void 0);
|
|
203
235
|
// src/plugins/buffer/VelocityBufferPlugin.ts
|
|
204
236
|
var _VelocityBufferPlugin;
|
|
205
237
|
var VelocityBufferPlugin = class VelocityBufferPlugin extends threepipe.PipelinePassPlugin {
|
|
@@ -212,6 +244,16 @@
|
|
|
212
244
|
static {
|
|
213
245
|
this.OldPluginType = "VelocityBufferPlugin";
|
|
214
246
|
}
|
|
247
|
+
_splitChanged() {
|
|
248
|
+
const m = this.material, on = this.split > 0;
|
|
249
|
+
m.uniforms.velocitySplitX.value = this.split;
|
|
250
|
+
if (!!m.defines.VELOCITY_SPLIT !== on) {
|
|
251
|
+
if (on) m.defines.VELOCITY_SPLIT = 1;
|
|
252
|
+
else delete m.defines.VELOCITY_SPLIT;
|
|
253
|
+
m.needsUpdate = true;
|
|
254
|
+
}
|
|
255
|
+
if (this._viewer) this.setDirty();
|
|
256
|
+
}
|
|
215
257
|
_createTarget(recreate = true) {
|
|
216
258
|
if (!this._viewer) return;
|
|
217
259
|
if (recreate) this._disposeTarget();
|
|
@@ -271,6 +313,7 @@
|
|
|
271
313
|
super();
|
|
272
314
|
this.passId = "velocityBuffer";
|
|
273
315
|
this.material = new SSVelocityMaterial();
|
|
316
|
+
this.split = 0;
|
|
274
317
|
this.unpackExtension = {
|
|
275
318
|
shaderExtender: (shader) => {
|
|
276
319
|
if (this.isDisabled()) return;
|
|
@@ -296,6 +339,7 @@
|
|
|
296
339
|
}
|
|
297
340
|
onRemove(viewer) {
|
|
298
341
|
this._disposeTarget();
|
|
342
|
+
this.material.dispose();
|
|
299
343
|
return super.onRemove(viewer);
|
|
300
344
|
}
|
|
301
345
|
setDirty() {
|
|
@@ -314,6 +358,11 @@
|
|
|
314
358
|
}
|
|
315
359
|
};
|
|
316
360
|
__decorate([(0, threepipe.uiImage)("Velocity Buffer", { readOnly: true })], VelocityBufferPlugin.prototype, "texture", void 0);
|
|
361
|
+
__decorate([
|
|
362
|
+
(0, threepipe.uiSlider)("Split", [0, 1], .01, { tags: ["debug"] }),
|
|
363
|
+
(0, threepipe.onChange)(VelocityBufferPlugin.prototype._splitChanged),
|
|
364
|
+
(0, threepipe.serialize)()
|
|
365
|
+
], VelocityBufferPlugin.prototype, "split", void 0);
|
|
317
366
|
VelocityBufferPlugin = _VelocityBufferPlugin = __decorate([(0, threepipe.uiFolderContainer)("Velocity Buffer Plugin (for TAA)")], VelocityBufferPlugin);
|
|
318
367
|
var SSVelocityMaterial = class extends threepipe.ShaderMaterial {
|
|
319
368
|
constructor() {
|
|
@@ -326,19 +375,101 @@
|
|
|
326
375
|
alphaTest: { value: null },
|
|
327
376
|
alphaMapTransform: { value: /* @__PURE__*/ new threepipe.Matrix3() },
|
|
328
377
|
currentProjectionViewMatrix: { value: new threepipe.Matrix4() },
|
|
329
|
-
lastProjectionViewMatrix: { value: new threepipe.Matrix4() }
|
|
378
|
+
lastProjectionViewMatrix: { value: new threepipe.Matrix4() },
|
|
379
|
+
velocitySplitX: { value: 0 }
|
|
330
380
|
},
|
|
331
381
|
blending: threepipe.NoBlending
|
|
332
382
|
});
|
|
333
|
-
this.extraUniformsToUpload = {
|
|
383
|
+
this.extraUniformsToUpload = {
|
|
384
|
+
modelMatrixPrevious: { value: new threepipe.Matrix4().identity() },
|
|
385
|
+
instanceMatrixPrevious: { value: null },
|
|
386
|
+
hasInstanceMatrixPrevious: { value: false }
|
|
387
|
+
};
|
|
334
388
|
this._previousWorldMatrices = {};
|
|
389
|
+
this._previousInstanceMatrices = {};
|
|
390
|
+
this._meshListeners = /* @__PURE__ */ new Map();
|
|
391
|
+
}
|
|
392
|
+
_instancePrevious(object, frame) {
|
|
393
|
+
const capacity = object.instanceMatrix.count;
|
|
394
|
+
let e = this._previousInstanceMatrices[object.uuid];
|
|
395
|
+
if (!e || e.capacity !== capacity) {
|
|
396
|
+
if (e) e.textures.forEach((t) => t.dispose());
|
|
397
|
+
else if (object.addEventListener) {
|
|
398
|
+
const o = object;
|
|
399
|
+
const listener = () => {
|
|
400
|
+
const d = this._previousInstanceMatrices[object.uuid];
|
|
401
|
+
if (d) d.textures.forEach((t) => t.dispose());
|
|
402
|
+
delete this._previousInstanceMatrices[object.uuid];
|
|
403
|
+
delete this._previousWorldMatrices[object.uuid];
|
|
404
|
+
this._meshListeners.delete(object.uuid);
|
|
405
|
+
o.removeEventListener("dispose", listener);
|
|
406
|
+
};
|
|
407
|
+
o.addEventListener("dispose", listener);
|
|
408
|
+
this._meshListeners.set(object.uuid, {
|
|
409
|
+
object: o,
|
|
410
|
+
listener
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
const width = 4 * Math.min(capacity, 1024), height = Math.ceil(capacity / 1024);
|
|
414
|
+
const data = [new Float32Array(width * height * 4), new Float32Array(width * height * 4)];
|
|
415
|
+
const make = (i) => {
|
|
416
|
+
const t = new threepipe.DataTexture(data[i], width, height, threepipe.RGBAFormat, threepipe.FloatType);
|
|
417
|
+
t.minFilter = t.magFilter = threepipe.NearestFilter;
|
|
418
|
+
t.generateMipmaps = false;
|
|
419
|
+
t.name = "instanceMatrixPrevious";
|
|
420
|
+
return t;
|
|
421
|
+
};
|
|
422
|
+
e = this._previousInstanceMatrices[object.uuid] = {
|
|
423
|
+
textures: [make(0), make(1)],
|
|
424
|
+
data: [data[0], data[1]],
|
|
425
|
+
read: 0,
|
|
426
|
+
valid: false,
|
|
427
|
+
capacity,
|
|
428
|
+
frame: -1,
|
|
429
|
+
readNow: null
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
if (e.frame !== frame) {
|
|
433
|
+
e.frame = frame;
|
|
434
|
+
e.readNow = e.valid ? e.textures[e.read] : null;
|
|
435
|
+
const w = 1 - e.read;
|
|
436
|
+
e.data[w].set(object.instanceMatrix.array);
|
|
437
|
+
e.textures[w].needsUpdate = true;
|
|
438
|
+
e.read = 1 - e.read;
|
|
439
|
+
e.valid = true;
|
|
440
|
+
}
|
|
441
|
+
const u = this.extraUniformsToUpload;
|
|
442
|
+
u.instanceMatrixPrevious.value = e.readNow;
|
|
443
|
+
u.hasInstanceMatrixPrevious.value = !!e.readNow;
|
|
444
|
+
}
|
|
445
|
+
dispose() {
|
|
446
|
+
for (const e of Object.values(this._previousInstanceMatrices)) e.textures.forEach((t) => t.dispose());
|
|
447
|
+
for (const { object, listener } of this._meshListeners.values()) object.removeEventListener("dispose", listener);
|
|
448
|
+
this._meshListeners.clear();
|
|
449
|
+
this._previousInstanceMatrices = {};
|
|
450
|
+
this._previousWorldMatrices = {};
|
|
451
|
+
super.dispose();
|
|
335
452
|
}
|
|
336
453
|
onBeforeRender(_r, _s, _c, _geometry, object, group) {
|
|
337
454
|
super.onBeforeRender(_r, _s, _c, _geometry, object, group);
|
|
338
|
-
const
|
|
339
|
-
this.
|
|
340
|
-
if (
|
|
341
|
-
|
|
455
|
+
const frame = _r.info.render.frame;
|
|
456
|
+
let world = this._previousWorldMatrices[object.uuid];
|
|
457
|
+
if (!world) world = this._previousWorldMatrices[object.uuid] = {
|
|
458
|
+
previous: object.matrixWorld.clone(),
|
|
459
|
+
current: object.matrixWorld.clone(),
|
|
460
|
+
frame
|
|
461
|
+
};
|
|
462
|
+
else if (world.frame !== frame) {
|
|
463
|
+
world.previous.copy(world.current);
|
|
464
|
+
world.current.copy(object.matrixWorld);
|
|
465
|
+
world.frame = frame;
|
|
466
|
+
}
|
|
467
|
+
this.extraUniformsToUpload.modelMatrixPrevious.value.copy(world.previous);
|
|
468
|
+
if (object.isInstancedMesh) this._instancePrevious(object, frame);
|
|
469
|
+
else {
|
|
470
|
+
this.extraUniformsToUpload.instanceMatrixPrevious.value = null;
|
|
471
|
+
this.extraUniformsToUpload.hasInstanceMatrixPrevious.value = false;
|
|
472
|
+
}
|
|
342
473
|
let mat = object.material;
|
|
343
474
|
if (Array.isArray(mat)) mat = mat[0];
|
|
344
475
|
this.uniforms.alphaMap.value = mat?.alphaMap ?? null;
|
|
@@ -1588,6 +1719,31 @@ ${getShaders().ssReflection}
|
|
|
1588
1719
|
};
|
|
1589
1720
|
this._shaderPatch = "diffuseColor = outline(diffuseColor);";
|
|
1590
1721
|
this.dependencies = [threepipe.PickingPlugin, threepipe.GBufferPlugin];
|
|
1722
|
+
this._onSelectedObjectChanged = () => {
|
|
1723
|
+
if (this._animationCallBack) return;
|
|
1724
|
+
if (this._pickingPlugin?.getSelectedObject()) {
|
|
1725
|
+
if (this.enableDynamicSelection) {
|
|
1726
|
+
this.transparency = 1;
|
|
1727
|
+
this._animationCallBack = this._startTransparencyAnimation(1, this.highlightTransparency, 400);
|
|
1728
|
+
} else this.transparency = this.highlightTransparency;
|
|
1729
|
+
} else this.transparency = 1;
|
|
1730
|
+
};
|
|
1731
|
+
this._onMouseMove = (e) => {
|
|
1732
|
+
if (!this.mouseInOutAnimationEnabled) return;
|
|
1733
|
+
if (!this.enableHighlight) return;
|
|
1734
|
+
const selectedObject = this._pickingPlugin?.getSelectedObject();
|
|
1735
|
+
if (selectedObject && this.enableDynamicSelection) {
|
|
1736
|
+
if (e.target !== this._viewer?.canvas) {
|
|
1737
|
+
if (!this._animationCallBack && this._state === "in") {
|
|
1738
|
+
this._animationCallBack = this._startTransparencyAnimation(this.highlightTransparency, 1, 600);
|
|
1739
|
+
this._state = "out";
|
|
1740
|
+
}
|
|
1741
|
+
} else if (!this._animationCallBack && this._state === "out") {
|
|
1742
|
+
this._animationCallBack = this._startTransparencyAnimation(1, this.highlightTransparency, 600);
|
|
1743
|
+
this._state = "in";
|
|
1744
|
+
}
|
|
1745
|
+
} else this.transparency = selectedObject ? this.highlightTransparency : 1;
|
|
1746
|
+
};
|
|
1591
1747
|
this._pickingWidgetDisabled = false;
|
|
1592
1748
|
this.material = new threepipe.ShaderMaterial({
|
|
1593
1749
|
uniforms: { "cameraNearFar": { value: new threepipe.Vector2(.1, 100) } },
|
|
@@ -1622,6 +1778,7 @@ ${getShaders().ssReflection}
|
|
|
1622
1778
|
}
|
|
1623
1779
|
setDirty() {
|
|
1624
1780
|
super.setDirty();
|
|
1781
|
+
if (this._pass) this._pass.enabled = !this.isDisabled();
|
|
1625
1782
|
if (!this._viewer) return;
|
|
1626
1783
|
const picking = this._viewer.getPlugin(threepipe.PickingPlugin);
|
|
1627
1784
|
let enabled = !this.isDisabled();
|
|
@@ -1644,38 +1801,23 @@ ${getShaders().ssReflection}
|
|
|
1644
1801
|
super.onAdded(viewer);
|
|
1645
1802
|
this.setDirty();
|
|
1646
1803
|
this._pass = this._createPass();
|
|
1804
|
+
this._pass.enabled = !this.isDisabled();
|
|
1647
1805
|
this._pass.onDirty?.push(viewer.setDirty);
|
|
1648
1806
|
viewer.renderManager.registerPass(this._pass);
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
} else this.transparency = 1;
|
|
1658
|
-
}
|
|
1659
|
-
});
|
|
1660
|
-
document.addEventListener("mousemove", (e) => {
|
|
1661
|
-
if (!this) return;
|
|
1662
|
-
if (!this.mouseInOutAnimationEnabled) return;
|
|
1663
|
-
if (!this.enableHighlight) return;
|
|
1664
|
-
const selectedObject = pickingPlugin?.getSelectedObject();
|
|
1665
|
-
if (selectedObject && this.enableDynamicSelection) {
|
|
1666
|
-
if (e.target !== viewer.canvas) {
|
|
1667
|
-
if (!this._animationCallBack && this._state === "in") {
|
|
1668
|
-
this._animationCallBack = this._startTransparencyAnimation(this.highlightTransparency, 1, 600);
|
|
1669
|
-
this._state = "out";
|
|
1670
|
-
}
|
|
1671
|
-
} else if (!this._animationCallBack && this._state === "out") {
|
|
1672
|
-
this._animationCallBack = this._startTransparencyAnimation(1, this.highlightTransparency, 600);
|
|
1673
|
-
this._state = "in";
|
|
1674
|
-
}
|
|
1675
|
-
} else this.transparency = selectedObject ? this.highlightTransparency : 1;
|
|
1676
|
-
});
|
|
1807
|
+
viewer.forPlugin(threepipe.PickingPlugin, (p) => {
|
|
1808
|
+
this._pickingPlugin = p;
|
|
1809
|
+
p.addEventListener("selectedObjectChanged", this._onSelectedObjectChanged);
|
|
1810
|
+
}, (p) => {
|
|
1811
|
+
p.removeEventListener("selectedObjectChanged", this._onSelectedObjectChanged);
|
|
1812
|
+
this._pickingPlugin = void 0;
|
|
1813
|
+
}, this);
|
|
1814
|
+
document.addEventListener("mousemove", this._onMouseMove, { passive: true });
|
|
1677
1815
|
}
|
|
1678
1816
|
onRemove(viewer) {
|
|
1817
|
+
document.removeEventListener("mousemove", this._onMouseMove);
|
|
1818
|
+
this._pickingPlugin?.removeEventListener("selectedObjectChanged", this._onSelectedObjectChanged);
|
|
1819
|
+
this._pickingPlugin = void 0;
|
|
1820
|
+
this._animationCallBack = void 0;
|
|
1679
1821
|
this._disposeTarget();
|
|
1680
1822
|
if (this._pass) {
|
|
1681
1823
|
viewer.renderManager.unregisterPass(this._pass);
|
|
@@ -2566,7 +2708,7 @@ ${getShaders().calculateGI}
|
|
|
2566
2708
|
return null;
|
|
2567
2709
|
}
|
|
2568
2710
|
};
|
|
2569
|
-
var glTFMaterialsAnisotropyExtensionExport = (w) => ({
|
|
2711
|
+
var glTFMaterialsAnisotropyExtensionExport = (w) => ({ writeMaterialAsync: async (material, materialDef) => {
|
|
2570
2712
|
if (!material.isMeshStandardMaterial || !material.userData._isAnisotropic) return;
|
|
2571
2713
|
if ((material.userData._anisotropyFactor || 0) < .001) return;
|
|
2572
2714
|
materialDef.extensions = materialDef.extensions || {};
|
|
@@ -2575,7 +2717,7 @@ ${getShaders().calculateGI}
|
|
|
2575
2717
|
extensionDef.anisotropyNoiseFactor = material.userData._anisotropyNoise || 0;
|
|
2576
2718
|
extensionDef.anisotropyDirectionMode = material.userData._anisotropyDirectionMode || "CONSTANT";
|
|
2577
2719
|
if (w.checkEmptyMap(material.userData._anisotropyDirectionMap) && extensionDef.anisotropyDirectionMode !== "CONSTANT") {
|
|
2578
|
-
const anisotropyDirectionMapDef = { index: w.
|
|
2720
|
+
const anisotropyDirectionMapDef = { index: await w.processTextureAsync(material.userData._anisotropyDirectionMap) };
|
|
2579
2721
|
w.applyTextureTransform(anisotropyDirectionMapDef, material.userData._anisotropyDirectionMap);
|
|
2580
2722
|
extensionDef.anisotropyDirection = anisotropyDirectionMapDef;
|
|
2581
2723
|
} else {
|