@threepipe/webgi-plugins 0.5.0 → 0.5.2
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/README.md +9 -3
- package/dist/index.js +15 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +461 -228
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/buffer/VelocityBufferPlugin.d.ts.map +1 -1
- package/dist/plugins/extras/AdvancedGroundPlugin.d.ts +2 -1
- package/dist/plugins/extras/AdvancedGroundPlugin.d.ts.map +1 -1
- package/dist/plugins/extras/WatchHandsPlugin.d.ts +27 -0
- package/dist/plugins/extras/WatchHandsPlugin.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +3 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/postprocessing/OutlinePlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/SSGIPlugin.d.ts +1 -0
- package/dist/plugins/postprocessing/SSGIPlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/SSReflectionPlugin.d.ts +5 -0
- package/dist/plugins/postprocessing/SSReflectionPlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/TemporalAAPlugin.d.ts.map +1 -1
- package/dist/utils/shaders.d.ts +9 -0
- package/dist/utils/shaders.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @threepipe/webgi-plugins v0.5.
|
|
3
|
+
* @threepipe/webgi-plugins v0.5.2
|
|
4
4
|
* Copyright 2022-2025 repalash <palash@shaders.app> (https://repalash.com)
|
|
5
|
-
* SEE LICENSE IN LICENSE
|
|
5
|
+
* SEE LICENSE IN LICENSE
|
|
6
6
|
*/
|
|
7
7
|
var _a, _b;
|
|
8
|
-
import { PipelinePassPlugin, GBufferPlugin, ProgressivePlugin, generateUiConfig, uiToggle, uiConfig, ExtendedShaderPass, Vector2, Matrix4, CopyShader, getOrCall, serialize, uniform, uiVector, matDefineBool, UnsignedByteType, shaderReplaceString, LinearSRGBColorSpace, GBufferRenderPass, Color, ShaderMaterial, NoBlending, Matrix3, DoubleSide, uiImage, uiFolderContainer, uiConfigMaterialExtension, updateBit, Vector4, HalfFloatType, AdditiveBlending, uiSlider, onChange, onChange2, Vector3, PickingPlugin, now, FrameFadePlugin, shaderUtils, ExtendedShaderMaterial, RGBAFormat, NearestFilter, bindToValue, AViewerPluginSync, updateMaterialDefines, glsl,
|
|
8
|
+
import { ShaderChunk, PipelinePassPlugin, GBufferPlugin, ProgressivePlugin, generateUiConfig, uiToggle, uiConfig, ExtendedShaderPass, Vector2, Matrix4, CopyShader, getOrCall, serialize, uniform, uiVector, matDefineBool, UnsignedByteType, shaderReplaceString, LinearSRGBColorSpace, GBufferRenderPass, Color, ShaderMaterial, NoBlending, Matrix3, DoubleSide, uiImage, uiFolderContainer, uiConfigMaterialExtension, updateBit, Vector4, HalfFloatType, AdditiveBlending, uiSlider, onChange, onChange2, Vector3, PickingPlugin, now, FrameFadePlugin, shaderUtils, ExtendedShaderMaterial, RGBAFormat, NearestFilter, bindToValue, AViewerPluginSync, updateMaterialDefines, glsl, BaseGroundPlugin, matDefine, SSAAPlugin, getTexelDecoding, AScreenPassExtensionPlugin, animateTarget, RenderPass, uiColor, makeSamplerUi, SRGBColorSpace, Mesh2, Plane, PerspectiveCamera, MathUtils, DirectionalLight2, copyObject3DUserData, Serialization, ThreeSerialization, ShadowMaterial, SimpleEventDispatcher, BasicShadowMap, ShaderMaterial2, NoColorSpace, Layers, LinearFilter, LinearMipmapLinearFilter, PCFShadowMap, PCFSoftShadowMap, VSMShadowMap, uiDropdown, uiInput, uiButton } from "threepipe";
|
|
9
9
|
const VelocityBufferUnpack = "#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";
|
|
10
10
|
const ssVelocityVert = "#ifdef USE_ALPHAMAP\n#define USE_UV\n#endif\n#include <uv_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;void main(){\n#include <uv_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);\n#ifdef USE_INSTANCING\nmvPosition=instanceMatrix*mvPosition;\n#endif\nvWorldPosition=(modelMatrix*mvPosition).xyz;vWorldPositionPrevious=(modelMatrixPrevious*mvPosition).xyz;mvPosition=modelViewMatrix*mvPosition;gl_Position=projectionMatrix*mvPosition;\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n}";
|
|
11
11
|
const ssVelocityFrag = "varying vec3 vWorldPosition;varying vec3 vWorldPositionPrevious;uniform mat4 currentProjectionViewMatrix;uniform mat4 lastProjectionViewMatrix;vec2 computeScreenSpaceVelocity2(){vec4 currentPositionClip=currentProjectionViewMatrix*vec4(vWorldPosition,1.0);vec4 prevPositionClip=lastProjectionViewMatrix*vec4(vWorldPositionPrevious,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(){vec2 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.);}";
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const 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);}";
|
|
13
|
+
const 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;}";
|
|
14
|
+
const 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;vec3 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));vec4 corners=2.0*(tr+bl+br+tl)-2.0*mc;mc+=(mc-(corners*0.166667))*2.718282*0.3;mc=max(vec4(0.0),mc);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);previousColor=clip_aabb(cmin,cmax,previousColor);float 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#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}";
|
|
15
|
+
const 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.);}";
|
|
16
|
+
const ssrtao = "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.));}";
|
|
17
|
+
const shadersUtils2 = {
|
|
18
|
+
computeScreenSpaceVelocity,
|
|
19
|
+
getWorldPositionFromViewZ,
|
|
20
|
+
temporalAA: temporalaa,
|
|
21
|
+
ssReflection: ssreflection,
|
|
22
|
+
calculateGI: ssrtao,
|
|
23
|
+
["__inited"]: false
|
|
24
|
+
};
|
|
25
|
+
function getShaders() {
|
|
26
|
+
if (!shadersUtils2.__inited) {
|
|
27
|
+
shadersUtils2.__inited = true;
|
|
28
|
+
Object.assign(ShaderChunk, shadersUtils2);
|
|
29
|
+
}
|
|
30
|
+
return shadersUtils2;
|
|
31
|
+
}
|
|
32
|
+
var __defProp$f = Object.defineProperty;
|
|
33
|
+
var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
|
|
34
|
+
var __decorateClass$f = (decorators, target, key, kind) => {
|
|
35
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
|
|
17
36
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
18
37
|
if (decorator = decorators[i2])
|
|
19
38
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
20
|
-
if (kind && result) __defProp$
|
|
39
|
+
if (kind && result) __defProp$f(target, key, result);
|
|
21
40
|
return result;
|
|
22
41
|
};
|
|
23
42
|
const passId$4 = "taa";
|
|
@@ -144,10 +163,10 @@ const _TemporalAAPlugin = class _TemporalAAPlugin extends PipelinePassPlugin {
|
|
|
144
163
|
_TemporalAAPlugin.PluginType = "TAA";
|
|
145
164
|
_TemporalAAPlugin.OldPluginType = "TemporalAAPlugin";
|
|
146
165
|
let TemporalAAPlugin = _TemporalAAPlugin;
|
|
147
|
-
__decorateClass$
|
|
166
|
+
__decorateClass$f([
|
|
148
167
|
uiToggle("Stable Noise (Total frame count)")
|
|
149
168
|
], TemporalAAPlugin.prototype, "stableNoise", 1);
|
|
150
|
-
__decorateClass$
|
|
169
|
+
__decorateClass$f([
|
|
151
170
|
uiConfig()
|
|
152
171
|
], TemporalAAPlugin.prototype, "_pass", 2);
|
|
153
172
|
class TemporalAAPluginPass extends ExtendedShaderPass {
|
|
@@ -155,7 +174,7 @@ class TemporalAAPluginPass extends ExtendedShaderPass {
|
|
|
155
174
|
var _a2;
|
|
156
175
|
super({
|
|
157
176
|
vertexShader: CopyShader.vertexShader,
|
|
158
|
-
fragmentShader:
|
|
177
|
+
fragmentShader: getShaders().temporalAA,
|
|
159
178
|
uniforms: {
|
|
160
179
|
currentRT: { value: null },
|
|
161
180
|
previousRT: { value: null },
|
|
@@ -226,23 +245,23 @@ class TemporalAAPluginPass extends ExtendedShaderPass {
|
|
|
226
245
|
this.onSizeUpdate();
|
|
227
246
|
}
|
|
228
247
|
}
|
|
229
|
-
__decorateClass$
|
|
248
|
+
__decorateClass$f([
|
|
230
249
|
serialize(),
|
|
231
250
|
uniform(),
|
|
232
251
|
uiVector("Feedback", void 0, 1e-4)
|
|
233
252
|
], TemporalAAPluginPass.prototype, "feedBack", 2);
|
|
234
|
-
__decorateClass$
|
|
253
|
+
__decorateClass$f([
|
|
235
254
|
uiToggle(),
|
|
236
255
|
matDefineBool("DEBUG_VELOCITY", void 0, false, void 0, true)
|
|
237
256
|
], TemporalAAPluginPass.prototype, "debugVelocity", 2);
|
|
238
|
-
var __defProp$
|
|
239
|
-
var __getOwnPropDesc$
|
|
240
|
-
var __decorateClass$
|
|
241
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
257
|
+
var __defProp$e = Object.defineProperty;
|
|
258
|
+
var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
|
|
259
|
+
var __decorateClass$e = (decorators, target, key, kind) => {
|
|
260
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
|
|
242
261
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
243
262
|
if (decorator = decorators[i2])
|
|
244
263
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
245
|
-
if (kind && result) __defProp$
|
|
264
|
+
if (kind && result) __defProp$e(target, key, result);
|
|
246
265
|
return result;
|
|
247
266
|
};
|
|
248
267
|
let VelocityBufferPlugin = class extends PipelinePassPlugin {
|
|
@@ -341,18 +360,17 @@ let VelocityBufferPlugin = class extends PipelinePassPlugin {
|
|
|
341
360
|
return pass;
|
|
342
361
|
}
|
|
343
362
|
onAdded(viewer) {
|
|
344
|
-
var _a2;
|
|
345
363
|
super.onAdded(viewer);
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
364
|
+
viewer.forPlugin(TemporalAAPlugin, (taa) => {
|
|
365
|
+
var _a2;
|
|
366
|
+
this._attachToTaa && ((_a2 = taa.pass) == null ? void 0 : _a2.material.registerMaterialExtensions([this.unpackExtension]));
|
|
367
|
+
}, (taa) => {
|
|
368
|
+
var _a2, _b2;
|
|
369
|
+
(_b2 = (_a2 = taa.pass) == null ? void 0 : _a2.material) == null ? void 0 : _b2.unregisterMaterialExtensions([this.unpackExtension]);
|
|
370
|
+
});
|
|
351
371
|
}
|
|
352
372
|
onRemove(viewer) {
|
|
353
|
-
var _a2, _b2;
|
|
354
373
|
this._disposeTarget();
|
|
355
|
-
if (this._attachToTaa) (_b2 = (_a2 = viewer.getPlugin(TemporalAAPlugin)) == null ? void 0 : _a2.pass) == null ? void 0 : _b2.material.unregisterMaterialExtensions([this.unpackExtension]);
|
|
356
374
|
return super.onRemove(viewer);
|
|
357
375
|
}
|
|
358
376
|
setDirty() {
|
|
@@ -373,13 +391,10 @@ let VelocityBufferPlugin = class extends PipelinePassPlugin {
|
|
|
373
391
|
};
|
|
374
392
|
VelocityBufferPlugin.PluginType = "VelocityBuffer";
|
|
375
393
|
VelocityBufferPlugin.OldPluginType = "VelocityBufferPlugin";
|
|
376
|
-
__decorateClass$
|
|
377
|
-
uiImage(
|
|
378
|
-
"Velocity Buffer"
|
|
379
|
-
/* {readOnly: true}*/
|
|
380
|
-
)
|
|
394
|
+
__decorateClass$e([
|
|
395
|
+
uiImage("Velocity Buffer", { readOnly: true })
|
|
381
396
|
], VelocityBufferPlugin.prototype, "texture", 2);
|
|
382
|
-
VelocityBufferPlugin = __decorateClass$
|
|
397
|
+
VelocityBufferPlugin = __decorateClass$e([
|
|
383
398
|
uiFolderContainer("Velocity Buffer Plugin (for TAA)")
|
|
384
399
|
], VelocityBufferPlugin);
|
|
385
400
|
class SSVelocityMaterial extends ShaderMaterial {
|
|
@@ -434,14 +449,14 @@ class SSVelocityMaterial extends ShaderMaterial {
|
|
|
434
449
|
}
|
|
435
450
|
}
|
|
436
451
|
const hdrBloom = "#include <packing>\nuniform float intensity;uniform float opacity;uniform vec2 tDiffuseSize;varying vec2 vUv;uniform float weight;\n#if PASS_STEP == 0\nuniform vec4 prefilter;vec4 Prefilter(vec4 c){\n#ifdef HAS_GBUFFER\n#if !BACKGROUND_BLOOM\nif(getDepth(vUv)>0.999){return vec4(0.0);}\n#endif\n#endif\nfloat brightness=max(c.r,max(c.g,c.b));float soft=brightness+prefilter.x*(prefilter.y-1.);soft=clamp(soft,0.,prefilter.z);soft=soft*soft*prefilter.w;float contribution=max(soft,brightness-prefilter.x);contribution/=max(brightness,0.001);return vec4(c.rgb*contribution,c.a);}\n#endif\nvec4 Sample(vec2 uv){return min(vec4(MAX_INTENSITY,MAX_INTENSITY,MAX_INTENSITY,1.),tDiffuseTexelToLinear(texture2D(tDiffuse,uv)));}vec4 SampleBox(vec2 uv,float delta){vec4 o=vec2(-delta,delta).xxyy/tDiffuseSize.xyxy;vec4 s=Sample(uv+o.xy)+Sample(uv+o.zy)+Sample(uv+o.xw)+Sample(uv+o.zw);return s*0.25;}int getBloomBit(in int number){\n#ifdef WebGL2Context\nreturn(number/4)% 2;\n#else\nreturn int(mod(floor(float(number)/4.),2.));\n#endif\n}void main(){\n#if PASS_STEP == 0\n#ifdef GBUFFER_HAS_FLAGS\nint doBloom=getBloomBit(getGBufferFlags(vUv).a);\n#else\nint doBloom=1;\n#endif\ngl_FragColor=float(doBloom)*weight*Prefilter(SampleBox(vUv,1.));gl_FragColor.a=1.;\n#elif PASS_STEP == 1\ngl_FragColor=weight*(SampleBox(vUv,1.));gl_FragColor.a=1.;\n#elif PASS_STEP == 2\ngl_FragColor=(SampleBox(vUv,0.5));gl_FragColor.a=1.;\n#elif PASS_STEP == 3\nvec4 texel=tSourceTexelToLinear(texture2D(tSource,vUv));vec4 bloom=intensity*SampleBox(vUv,0.5).rgba;float brightness=max(bloom.r,max(bloom.g,bloom.b));texel.rgb+=bloom.rgb;texel.a=min(1.,texel.a+brightness);gl_FragColor=texel;\n#elif PASS_STEP == 4\nvec4 texel=vec4(0.);texel.rgb+=intensity*SampleBox(vUv,0.5).rgb;texel.a=1.;gl_FragColor=texel;\n#endif\n#include <colorspace_fragment>\n}";
|
|
437
|
-
var __defProp$
|
|
438
|
-
var __getOwnPropDesc$
|
|
439
|
-
var __decorateClass$
|
|
440
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
452
|
+
var __defProp$d = Object.defineProperty;
|
|
453
|
+
var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
|
|
454
|
+
var __decorateClass$d = (decorators, target, key, kind) => {
|
|
455
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
|
|
441
456
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
442
457
|
if (decorator = decorators[i2])
|
|
443
458
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
444
|
-
if (kind && result) __defProp$
|
|
459
|
+
if (kind && result) __defProp$d(target, key, result);
|
|
445
460
|
return result;
|
|
446
461
|
};
|
|
447
462
|
const passId$3 = "bloom";
|
|
@@ -543,7 +558,7 @@ const _BloomPlugin = (_a = class extends PipelinePassPlugin {
|
|
|
543
558
|
return config;
|
|
544
559
|
}
|
|
545
560
|
}, _a.PluginType = "Bloom", _a.OldPluginType = "BloomPlugin", _a);
|
|
546
|
-
__decorateClass$
|
|
561
|
+
__decorateClass$d([
|
|
547
562
|
uiConfig()
|
|
548
563
|
], _BloomPlugin.prototype, "_pass", 2);
|
|
549
564
|
let BloomPlugin = _BloomPlugin;
|
|
@@ -691,48 +706,48 @@ let BloomPluginPass = class extends ExtendedShaderPass {
|
|
|
691
706
|
if (setDirty !== false) this.setDirty();
|
|
692
707
|
}
|
|
693
708
|
};
|
|
694
|
-
__decorateClass$
|
|
709
|
+
__decorateClass$d([
|
|
695
710
|
uniform()
|
|
696
711
|
], BloomPluginPass.prototype, "prefilter", 2);
|
|
697
|
-
__decorateClass$
|
|
712
|
+
__decorateClass$d([
|
|
698
713
|
uiSlider("Threshold", [0, 2]),
|
|
699
714
|
onChange(BloomPluginPass.prototype._thresholdsUpdated),
|
|
700
715
|
serialize()
|
|
701
716
|
], BloomPluginPass.prototype, "threshold", 2);
|
|
702
|
-
__decorateClass$
|
|
717
|
+
__decorateClass$d([
|
|
703
718
|
uiSlider("Soft Threshold", [0, 1]),
|
|
704
719
|
onChange(BloomPluginPass.prototype._thresholdsUpdated),
|
|
705
720
|
serialize()
|
|
706
721
|
], BloomPluginPass.prototype, "softThreshold", 2);
|
|
707
|
-
__decorateClass$
|
|
722
|
+
__decorateClass$d([
|
|
708
723
|
uiSlider("Intensity", [0, 3]),
|
|
709
724
|
serialize(),
|
|
710
725
|
uniform()
|
|
711
726
|
], BloomPluginPass.prototype, "intensity", 2);
|
|
712
|
-
__decorateClass$
|
|
727
|
+
__decorateClass$d([
|
|
713
728
|
uiToggle("Background Bloom"),
|
|
714
729
|
serialize(),
|
|
715
730
|
matDefineBool("BACKGROUND_BLOOM")
|
|
716
731
|
], BloomPluginPass.prototype, "backgroundBloom", 2);
|
|
717
|
-
__decorateClass$
|
|
732
|
+
__decorateClass$d([
|
|
718
733
|
uiSlider("Iterations", [2, 7], 1),
|
|
719
734
|
onChange2(BloomPluginPass.prototype._updateWeights),
|
|
720
735
|
serialize()
|
|
721
736
|
], BloomPluginPass.prototype, "bloomIterations", 2);
|
|
722
|
-
__decorateClass$
|
|
737
|
+
__decorateClass$d([
|
|
723
738
|
uiSlider("Radius", [0, 1], 0.01),
|
|
724
739
|
onChange2(BloomPluginPass.prototype._updateWeights),
|
|
725
740
|
serialize()
|
|
726
741
|
], BloomPluginPass.prototype, "radius", 2);
|
|
727
|
-
__decorateClass$
|
|
742
|
+
__decorateClass$d([
|
|
728
743
|
uiSlider("Power", [0.2, 10], 0.01),
|
|
729
744
|
onChange2(BloomPluginPass.prototype._updateWeights),
|
|
730
745
|
serialize()
|
|
731
746
|
], BloomPluginPass.prototype, "power", 2);
|
|
732
|
-
__decorateClass$
|
|
747
|
+
__decorateClass$d([
|
|
733
748
|
uiToggle("Debug")
|
|
734
749
|
], BloomPluginPass.prototype, "bloomDebug", 2);
|
|
735
|
-
BloomPluginPass = __decorateClass$
|
|
750
|
+
BloomPluginPass = __decorateClass$d([
|
|
736
751
|
uiFolderContainer("Bloom Pass")
|
|
737
752
|
], BloomPluginPass);
|
|
738
753
|
const dofCombine = "#include <common>\n#include <packing>\nvarying vec2 vUv;uniform vec2 cocTextureSize;uniform vec2 nearFarBlurScale;uniform vec2 cameraNearFar;uniform vec2 focalDepthRange;uniform vec2 crossCenter;uniform float crossRadius;uniform float crossAlpha;uniform vec3 crossColor;float smoothBoundary(float d,float smooothFactor){smooothFactor*=0.5;float value=smoothstep(-smooothFactor,smooothFactor,d);return value;}float circle(vec2 p,float r){return min((length(p)-r),-(length(p)-r-0.01));}float computeCoc(){float depth=getDepth(vUv);if(depth>1.0-0.01)return max(nearFarBlurScale.x,nearFarBlurScale.y);depth=mix(cameraNearFar.x,cameraNearFar.y,depth);float coc=(depth-focalDepthRange.x)/focalDepthRange.y;coc=clamp(coc,-1.,1.);return(coc>0.0 ? coc*nearFarBlurScale.y : coc*nearFarBlurScale.x);}void main(){vec4 blur=blurTextureTexelToLinear(texture2D(blurTexture,vUv));float scale=0.5;blur+=blurTextureTexelToLinear(texture2D(blurTexture,vUv+scale*vec2(1.0,1.0)/cocTextureSize));blur+=blurTextureTexelToLinear(texture2D(blurTexture,vUv+scale*vec2(-1.0,1.0)/cocTextureSize));blur+=blurTextureTexelToLinear(texture2D(blurTexture,vUv+scale*vec2(-1.0,-1.0)/cocTextureSize));blur+=blurTextureTexelToLinear(texture2D(blurTexture,vUv+scale*vec2(1.0,-1.0)/cocTextureSize));blur/=5.0;vec2 uvNearest=(floor(vUv*cocTextureSize)+0.5)/cocTextureSize;float coc=abs(min(2.*cocTextureTexelToLinear(texture2D(cocTexture,uvNearest)).a-1.,computeCoc()));float cocLower=0.005;float cocHigher=0.3;vec4 outColor=vec4(mix(colorTextureTexelToLinear(texture2D(colorTexture,vUv)).rgb,blur.rgb,smoothstep(cocLower,cocHigher,coc)),1.0);vec2 d=vUv-crossCenter;if(length(d)>crossRadius+0.05){float dist=circle(d,crossRadius);gl_FragColor=outColor;}else{d.x*=cocTextureSize.x/cocTextureSize.y;float dist=circle(d,crossRadius);dist=smoothBoundary(dist,2.*fwidth(dist));vec4 color=outColor;vec3 dofCircleColor=mix(crossColor,color.rgb,1.-crossAlpha);gl_FragColor=vec4(mix(color.rgb,dofCircleColor,dist),color.a);}\n#include <colorspace_fragment>\n}";
|
|
@@ -740,14 +755,14 @@ const dofPoissonBox = "#include <randomHelpers>\n#include <common>\nvarying vec2
|
|
|
740
755
|
const poissonDiskSamples$1 = "vec2 poisson_disk_samples[16];void setPds(){poisson_disk_samples[0]=vec2(-0.399691779231,0.728591545584);poisson_disk_samples[1]=vec2(-0.48622557676,-0.84016533712);poisson_disk_samples[2]=vec2(0.770309468987,-0.24906070432);poisson_disk_samples[3]=vec2(0.556596796154,0.820359876432);poisson_disk_samples[4]=vec2(-0.933902004071,0.0600539051593);poisson_disk_samples[5]=vec2(0.330144964342,0.207477293384);poisson_disk_samples[6]=vec2(0.289013230975,-0.686749271417);poisson_disk_samples[7]=vec2(-0.0832470893559,-0.187351643125);poisson_disk_samples[8]=vec2(-0.296314525615,0.254474834305);poisson_disk_samples[9]=vec2(-0.850977666059,0.484642744689);poisson_disk_samples[10]=vec2(0.829287915319,0.2345063545);poisson_disk_samples[11]=vec2(-0.773042143899,-0.543741521254);poisson_disk_samples[12]=vec2(0.0561133030864,0.928419742597);poisson_disk_samples[13]=vec2(-0.205799249508,-0.562072714492);poisson_disk_samples[14]=vec2(-0.526991665882,-0.193690188118);poisson_disk_samples[15]=vec2(-0.051789270667,-0.935374050821);}";
|
|
741
756
|
const dofComputeCoC = "#include <common>\n#include <packing>\nvarying vec2 vUv;uniform vec2 nearFarBlurScale;uniform vec2 cameraNearFar;uniform vec2 focalDepthRange;float computeCoc(){float depth=getDepth(vUv);if(depth==1.0)return max(nearFarBlurScale.x,nearFarBlurScale.y);depth=mix(cameraNearFar.x,cameraNearFar.y,depth);float coc=(depth-focalDepthRange.x)/focalDepthRange.y;coc=clamp(coc,-1.,1.);return(coc>0.0 ? coc*nearFarBlurScale.y : coc*nearFarBlurScale.x);}void main(){gl_FragColor=vec4(colorTextureTexelToLinear(texture2D(colorTexture,vUv)).rgb,0.5*computeCoc()+0.5);\n#include <colorspace_fragment>\n}";
|
|
742
757
|
const dofExpandCoC = "#include <common>\n#include <gbuffer_unpack>\nvarying vec2 vUv;uniform vec2 colorTextureSize;uniform vec2 direction;uniform vec2 nearFarBlurScale;const float MAXIMUM_BLUR_SIZE=4.0;float expandNear(const in vec2 offset,const in bool isBackground){float coc=0.0;vec2 sampleOffsets=MAXIMUM_BLUR_SIZE*offset/5.0;float coc0=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv)).a-1.;float coc1=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv-5.0*sampleOffsets)).a-1.;float coc2=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv-4.0*sampleOffsets)).a-1.;float coc3=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv-3.0*sampleOffsets)).a-1.;float coc4=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv-2.0*sampleOffsets)).a-1.;float coc5=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv-1.0*sampleOffsets)).a-1.;float coc6=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv+1.0*sampleOffsets)).a-1.;float coc7=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv+2.0*sampleOffsets)).a-1.;float coc8=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv+3.0*sampleOffsets)).a-1.;float coc9=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv+4.0*sampleOffsets)).a-1.;float coc10=2.*colorTextureTexelToLinear(texture2D(colorTexture,vUv+5.0*sampleOffsets)).a-1.;if(isBackground){coc=abs(coc0)*0.095474+(abs(coc1)+abs(coc10))*0.084264+(abs(coc2)+abs(coc9))*0.088139+(abs(coc3)+abs(coc8))*0.091276+(abs(coc4)+abs(coc7))*0.093585+(abs(coc5)+abs(coc6))*0.094998;}else{coc=min(coc0,0.0);coc=min(coc1*0.3,coc);coc=min(coc2*0.5,coc);coc=min(coc3*0.75,coc);coc=min(coc4*0.8,coc);coc=min(coc5*0.95,coc);coc=min(coc6*0.95,coc);coc=min(coc7*0.8,coc);coc=min(coc8*0.75,coc);coc=min(coc9*0.5,coc);coc=min(coc10*0.3,coc);if(abs(coc0)>abs(coc))coc=coc0;}return coc;}void main(){vec2 offset=2.*direction/colorTextureSize;bool isBackground=getDepth(vUv)>1.0-0.001;float coc=expandNear(offset,isBackground);gl_FragColor=vec4(colorTextureTexelToLinear(texture2D(colorTexture,vUv)).rgb,0.5*coc+0.5);\n#include <colorspace_fragment>\n}";
|
|
743
|
-
var __defProp$
|
|
744
|
-
var __getOwnPropDesc$
|
|
745
|
-
var __decorateClass$
|
|
746
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
758
|
+
var __defProp$c = Object.defineProperty;
|
|
759
|
+
var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
|
|
760
|
+
var __decorateClass$c = (decorators, target, key, kind) => {
|
|
761
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
|
|
747
762
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
748
763
|
if (decorator = decorators[i2])
|
|
749
764
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
750
|
-
if (kind && result) __defProp$
|
|
765
|
+
if (kind && result) __defProp$c(target, key, result);
|
|
751
766
|
return result;
|
|
752
767
|
};
|
|
753
768
|
const passId$2 = "depthOfField";
|
|
@@ -960,14 +975,14 @@ const _DepthOfFieldPlugin = class _DepthOfFieldPlugin extends PipelinePassPlugin
|
|
|
960
975
|
_DepthOfFieldPlugin.PluginType = "DepthOfField";
|
|
961
976
|
_DepthOfFieldPlugin.OldPluginType = "DepthOfFieldPlugin";
|
|
962
977
|
let DepthOfFieldPlugin = _DepthOfFieldPlugin;
|
|
963
|
-
__decorateClass$
|
|
978
|
+
__decorateClass$c([
|
|
964
979
|
serialize(),
|
|
965
980
|
uiToggle()
|
|
966
981
|
], DepthOfFieldPlugin.prototype, "enableEdit", 2);
|
|
967
|
-
__decorateClass$
|
|
982
|
+
__decorateClass$c([
|
|
968
983
|
serialize("focalPoint")
|
|
969
984
|
], DepthOfFieldPlugin.prototype, "_focalPointHit", 2);
|
|
970
|
-
__decorateClass$
|
|
985
|
+
__decorateClass$c([
|
|
971
986
|
serialize()
|
|
972
987
|
], DepthOfFieldPlugin.prototype, "crossFadeTime", 2);
|
|
973
988
|
const dofBlurMaterialPoisson = new ExtendedShaderMaterial({
|
|
@@ -1082,50 +1097,50 @@ let DepthOfFieldPluginPass = class extends ExtendedShaderPass {
|
|
|
1082
1097
|
renderManager.releaseTempTarget(renderTargetBlurTemp);
|
|
1083
1098
|
}
|
|
1084
1099
|
};
|
|
1085
|
-
__decorateClass$
|
|
1100
|
+
__decorateClass$c([
|
|
1086
1101
|
bindToValue({ obj: "focalDepthRange", key: "y" }),
|
|
1087
1102
|
uiSlider("Depth Range", [0.25, 3])
|
|
1088
1103
|
], DepthOfFieldPluginPass.prototype, "depthRange", 2);
|
|
1089
|
-
__decorateClass$
|
|
1104
|
+
__decorateClass$c([
|
|
1090
1105
|
bindToValue({ obj: "nearFarBlurScale", key: "x" }),
|
|
1091
1106
|
uiSlider("Near Blur Scale", [0, 1])
|
|
1092
1107
|
], DepthOfFieldPluginPass.prototype, "nearBlurScale", 2);
|
|
1093
|
-
__decorateClass$
|
|
1108
|
+
__decorateClass$c([
|
|
1094
1109
|
bindToValue({ obj: "nearFarBlurScale", key: "y" }),
|
|
1095
1110
|
uiSlider("Far Blur Scale", [0, 1])
|
|
1096
1111
|
], DepthOfFieldPluginPass.prototype, "farBlurScale", 2);
|
|
1097
|
-
__decorateClass$
|
|
1112
|
+
__decorateClass$c([
|
|
1098
1113
|
serialize(),
|
|
1099
1114
|
uniform()
|
|
1100
1115
|
], DepthOfFieldPluginPass.prototype, "nearFarBlurScale", 2);
|
|
1101
|
-
__decorateClass$
|
|
1116
|
+
__decorateClass$c([
|
|
1102
1117
|
serialize(),
|
|
1103
1118
|
uniform()
|
|
1104
1119
|
], DepthOfFieldPluginPass.prototype, "focalDepthRange", 2);
|
|
1105
|
-
__decorateClass$
|
|
1120
|
+
__decorateClass$c([
|
|
1106
1121
|
uniform()
|
|
1107
1122
|
], DepthOfFieldPluginPass.prototype, "crossCenter", 2);
|
|
1108
|
-
__decorateClass$
|
|
1123
|
+
__decorateClass$c([
|
|
1109
1124
|
uniform()
|
|
1110
1125
|
], DepthOfFieldPluginPass.prototype, "crossRadius", 2);
|
|
1111
|
-
__decorateClass$
|
|
1126
|
+
__decorateClass$c([
|
|
1112
1127
|
uniform()
|
|
1113
1128
|
], DepthOfFieldPluginPass.prototype, "crossAlpha", 2);
|
|
1114
|
-
__decorateClass$
|
|
1129
|
+
__decorateClass$c([
|
|
1115
1130
|
uniform()
|
|
1116
1131
|
], DepthOfFieldPluginPass.prototype, "crossColor", 2);
|
|
1117
|
-
DepthOfFieldPluginPass = __decorateClass$
|
|
1132
|
+
DepthOfFieldPluginPass = __decorateClass$c([
|
|
1118
1133
|
uiFolderContainer("DepthOfField Pass")
|
|
1119
1134
|
], DepthOfFieldPluginPass);
|
|
1120
1135
|
const ssrtShader = "#ifndef SSRT_PARS_SNIP\n#define SSRT_PARS_SNIP\n#define pow2(a) a*a\nfloat getDepth2(const in vec2 uv,const in float lod){float viewDepth=getDepth(uv);return depthToViewZ(viewDepth);}\n#define LOD_DEPTH 1.0\n#define LOD_COLOR 5.0\nvoid _traceRay(in vec4 ray_origin,in vec4 ray_dir,in float tolerance,inout vec3 state,in int loopMax,in float iStepCount){vec4 sample_uv;float d,hit;float dLod=0.;\n#pragma unroll_loop_start\nfor(int i=0;i<8;i++){if(UNROLLED_LOOP_INDEX<loopMax){sample_uv=ray_origin+ray_dir*state.y;d=getDepth2(sample_uv.xy,dLod);d=sample_uv.z/sample_uv.w-d;if(abs(d+tolerance)<tolerance){hit=clamp(state.x/(state.x-d),0.,1.)-1.;hit=(state.y+hit*iStepCount);state.z=min(state.z,hit);}state.x=d;state.y+=1.*iStepCount;}}\n#pragma unroll_loop_end\n}vec3 traceRay(in vec3 ray_origin_view,in vec3 ray_dir_view,in float tolerance,inout vec3 state,in int _STEP_COUNT){vec4 sample_uv;vec4 ray_origin=viewToScreen3(ray_origin_view);vec3 ray_end_view=ray_origin_view+ray_dir_view;vec4 ray_dir=viewToScreen3(ray_end_view);vec2 clamp_end=clamp(ray_dir.xy,vec2(0.),vec2(1.));vec2 correction=abs(ray_dir.xy-clamp_end);correction=(step(0.01,correction)*correction/(abs(clamp_end-ray_origin.xy)+0.01))+1.;correction.x=1./min(max(correction.y,correction.x),10.);ray_dir=ray_dir-ray_origin;ray_dir.xyw*=correction.x;float iStepCount=1./float(_STEP_COUNT);tolerance*=0.125;_traceRay(ray_origin,ray_dir,tolerance,state,_STEP_COUNT,iStepCount);if(_STEP_COUNT>8&&state.z>0.98)_traceRay(ray_origin,ray_dir,tolerance,state,_STEP_COUNT-8,iStepCount);if(_STEP_COUNT>15&&state.z>0.98)_traceRay(ray_origin,ray_dir,tolerance,state,_STEP_COUNT-16,iStepCount);if(_STEP_COUNT>23&&state.z>0.98)_traceRay(ray_origin,ray_dir,tolerance,state,_STEP_COUNT-16,iStepCount);sample_uv=ray_origin+ray_dir*state.z;sample_uv.z/=sample_uv.w;state.z=state.z<0.999 ? state.z : 9999999.;return sample_uv.xyz;}/**for ray clippinga=ray_originb=ray_endc=clamp(b)x=c.y-a.yy=b.y-c.y(c.y-a.y)/(b.y-c.y)=m/(l-m)m/(l-m)=km=kl-kmm=kl/(1+k)((c-a)/(b-c))/(1+(c-a)/(b-c))x/(y*(1+x/y))x/(y+x)1/(y/x+1)x/(y+yx)1/(y/x+y)ray scale=k/(1+k)1/(1/k+1)=1/((b-c)/(c-a)+1)**/\n#endif\n";
|
|
1121
|
-
var __defProp$
|
|
1122
|
-
var __getOwnPropDesc$
|
|
1123
|
-
var __decorateClass$
|
|
1124
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1136
|
+
var __defProp$b = Object.defineProperty;
|
|
1137
|
+
var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
|
|
1138
|
+
var __decorateClass$b = (decorators, target, key, kind) => {
|
|
1139
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
|
|
1125
1140
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
1126
1141
|
if (decorator = decorators[i2])
|
|
1127
1142
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1128
|
-
if (kind && result) __defProp$
|
|
1143
|
+
if (kind && result) __defProp$b(target, key, result);
|
|
1129
1144
|
return result;
|
|
1130
1145
|
};
|
|
1131
1146
|
let SSContactShadowsPlugin = class extends AViewerPluginSync {
|
|
@@ -1338,51 +1353,50 @@ let SSContactShadowsPlugin = class extends AViewerPluginSync {
|
|
|
1338
1353
|
};
|
|
1339
1354
|
SSContactShadowsPlugin.PluginType = "SSContactShadows";
|
|
1340
1355
|
SSContactShadowsPlugin.OldPluginType = "SSContactShadowsPlugin";
|
|
1341
|
-
__decorateClass$
|
|
1356
|
+
__decorateClass$b([
|
|
1342
1357
|
uiToggle("Enabled"),
|
|
1343
1358
|
serialize(),
|
|
1344
1359
|
onChange(SSContactShadowsPlugin.prototype.setDirty)
|
|
1345
1360
|
], SSContactShadowsPlugin.prototype, "enabled", 2);
|
|
1346
|
-
__decorateClass$
|
|
1361
|
+
__decorateClass$b([
|
|
1347
1362
|
uniform({ propKey: "sscsRadius", onChange: SSContactShadowsPlugin.prototype.setDirty }),
|
|
1348
1363
|
uiSlider("Radius", [1e-4, 0.1], 1e-4),
|
|
1349
1364
|
serialize()
|
|
1350
1365
|
], SSContactShadowsPlugin.prototype, "radius", 2);
|
|
1351
|
-
__decorateClass$
|
|
1366
|
+
__decorateClass$b([
|
|
1352
1367
|
uniform({ propKey: "sscsIntensity", onChange: SSContactShadowsPlugin.prototype.setDirty }),
|
|
1353
1368
|
uiSlider("Intensity", [1e-4, 1], 1e-4),
|
|
1354
1369
|
serialize()
|
|
1355
1370
|
], SSContactShadowsPlugin.prototype, "intensity", 2);
|
|
1356
|
-
__decorateClass$
|
|
1371
|
+
__decorateClass$b([
|
|
1357
1372
|
uniform({ propKey: "sscsTolerance", onChange: SSContactShadowsPlugin.prototype.setDirty }),
|
|
1358
1373
|
uiSlider("Tolerance", [0.1, 5]),
|
|
1359
1374
|
serialize()
|
|
1360
1375
|
], SSContactShadowsPlugin.prototype, "tolerance", 2);
|
|
1361
|
-
__decorateClass$
|
|
1376
|
+
__decorateClass$b([
|
|
1362
1377
|
matDefine("SSCS_DEBUG", void 0, true, SSContactShadowsPlugin.prototype.setDirty),
|
|
1363
1378
|
uiToggle("Debug only SSCS"),
|
|
1364
1379
|
serialize()
|
|
1365
1380
|
], SSContactShadowsPlugin.prototype, "onlySSCSDebug", 2);
|
|
1366
|
-
__decorateClass$
|
|
1381
|
+
__decorateClass$b([
|
|
1367
1382
|
matDefine("SSCS_STEP_COUNT", void 0, true, SSContactShadowsPlugin.prototype.setDirty),
|
|
1368
1383
|
uiSlider("Step count", [1, 8], 1),
|
|
1369
1384
|
serialize()
|
|
1370
1385
|
], SSContactShadowsPlugin.prototype, "stepCount", 2);
|
|
1371
|
-
SSContactShadowsPlugin = __decorateClass$
|
|
1386
|
+
SSContactShadowsPlugin = __decorateClass$b([
|
|
1372
1387
|
uiFolderContainer("SS Contact Shadows")
|
|
1373
1388
|
], SSContactShadowsPlugin);
|
|
1374
1389
|
const samplePointHelpers = "#define PI 3.141592653589793\nmat3 GetTangentBasis(vec3 TangentZ){vec3 up=vec3(0.0,0.0,1.0);vec3 TangentX=normalize(cross(dot(TangentZ,up)<0.8 ? up : vec3(1.0,0.0,0.0),TangentZ));vec3 TangentY=cross(TangentZ,TangentX);return mat3(TangentX,TangentY,TangentZ);}vec4 CosineSampleHemisphere(vec2 E){float Phi=2.*PI*E.x;float CosTheta=sqrt(E.y);float SinTheta=sqrt(1.-CosTheta*CosTheta);vec3 H;H.x=SinTheta*cos(Phi);H.y=SinTheta*sin(Phi);H.z=CosTheta;float PDF=CosTheta*(1.0/PI);return vec4(H,PDF);}vec4 UniformSampleHemisphere(vec2 E){float Phi=2.*PI*E.x;float CosTheta=E.y;float SinTheta=sqrt(1.-CosTheta*CosTheta);vec3 H;H.x=SinTheta*cos(Phi);H.y=SinTheta*sin(Phi);H.z=CosTheta;float PDF=1.0/(2.*PI);return vec4(H,PDF);}vec2 UniformSampleDiskConcentric(vec2 E){vec2 p=2.*E-1.;float Radius;float Phi;if(abs(p.x)>abs(p.y)){Radius=p.x;Phi=(PI/4.)*(p.y/p.x);}else{Radius=p.y;Phi=(PI/2.)-(PI/4.)*(p.x/p.y);}return vec2(Radius*cos(Phi),Radius*sin(Phi));}vec2 UniformSampleDiskConcentricApprox(vec2 E){vec2 sf=E*sqrt(2.0)-sqrt(0.5);vec2 sq=sf*sf;float root=sqrt(2.0*max(sq.x,sq.y)-min(sq.x,sq.y));if(sq.x>sq.y){sf.x=sf.x>0. ? root :-root;}else{sf.y=sf.y>0. ? root :-root;}return sf;}";
|
|
1375
|
-
const
|
|
1376
|
-
const ssreflPatch = "\n#if defined(SSREFL_ENABLED) && SSREFL_ENABLED > 0\nvec3 screenPos=viewToScreen(geometryPosition);vec4 ssrColor=vec4(0,0,0,0);float alphaModifier=1.0-clamp(material.roughness*.3,0.,1.);alphaModifier*=ssrIntensity;\n#if defined(SSR_MASK_FRONT_RAYS) && SSR_MASK_FRONT_RAYS > 0\nalphaModifier*=clamp(-4.0*dot(geometryViewDir,normal)+(4.0+ssrMaskFrontFactor),0.0,1.0);\n#endif\n#ifdef USE_TRANSMISSION\nalphaModifier*=1.-transmission;\n#endif\nfloat vignette=1.;if(true){float fadeStrength=0.1;float dist=max(0.,min(min(1.-screenPos.x,1.-screenPos.y),min(screenPos.x,screenPos.y)));float fade=dist*dist/(fadeStrength+0.001);fade=clamp(fade,0.0,1.0);fade=pow(fade,0.3);vignette=fade;}alphaModifier*=vignette;vec3 specularColor=EnvironmentBRDF(geometryNormal,geometryViewDir,material.specularColor.rgb,material.specularF90,material.roughness);if(length(specularColor.rgb)*alphaModifier>0.01&&roughnessFactor<0.9){\n#if defined(SSR_INLINE) && SSR_INLINE > 0\nvec3 scPos=vec3(screenPos.xy,geometryPosition.z);vec4 scol=vec4(0,0,0,0);\n#pragma unroll_loop_start\nfor(int i=0;i<8;i++){if(SSR_RAY_COUNT>UNROLLED_LOOP_INDEX){scol=calculateSSR(float(UNROLLED_LOOP_INDEX),scPos,geometryNormal,UNROLLED_LOOP_INDEX%3==0?1.:UNROLLED_LOOP_INDEX%3==1?0.5:1.5,material.roughness);\n#ifdef SSR_RAY_BLEND_MAX\nssrColor=max(ssrColor,scol);\n#else\nssrColor+=scol;\n#endif\n}}\n#pragma unroll_loop_end\n#ifndef SSR_RAY_BLEND_MAX\nssrColor*=ssrColor.a>0.001 ? 1.0/ssrColor.a : 1.0;\n#endif\n#else\nssrColor=tSSReflMapTexelToLinear(texture2D(tSSReflMap,screenPos.xy));\n#endif\n}ssrColor.rgb*=ssrBoost;ssrColor.a*=alphaModifier;ssrColor.rgb=pow(max(vec3(0.),ssrColor.rgb),vec3(ssrPower));ssrColor.a=min(ssrColor.a,1.0);\n#if defined(SSR_NON_PHYSICAL) && SSR_NON_PHYSICAL > 0\ndiffuseColor.a=max(ssrColor.a,diffuseColor.a*diffuseColor.a);reflectedLight.indirectSpecular=mix(reflectedLight.indirectSpecular,saturate(diffuseColor.rgb*ssrColor.rgb),1.0);reflectedLight.indirectDiffuse=diffuseColor.rgb*(1.0-ssrColor.a);reflectedLight.directDiffuse=vec3(0.0);reflectedLight.directSpecular=vec3(0.0);\n#else\nreflectedLight.indirectSpecular=mix(reflectedLight.indirectSpecular,(specularColor.rgb*ssrColor.rgb),ssrColor.a);\n#endif\n#endif\n";
|
|
1390
|
+
const ssreflPatch = "\n#if defined(SSREFL_ENABLED) && SSREFL_ENABLED > 0\nvec3 screenPos=viewToScreen(geometryPosition);\n#if SSREFL_ENABLED == 2\nif(screenPos.x>ssrSplitX){\n#endif\nvec4 ssrColor=vec4(0,0,0,0);float alphaModifier=1.0-clamp(material.roughness*.3,0.,1.);alphaModifier*=ssrIntensity;\n#if defined(SSR_MASK_FRONT_RAYS) && SSR_MASK_FRONT_RAYS > 0\nalphaModifier*=clamp(-4.0*dot(geometryViewDir,normal)+(4.0+ssrMaskFrontFactor),0.0,1.0);\n#endif\n#ifdef USE_TRANSMISSION\nalphaModifier*=1.-transmission;\n#endif\nfloat vignette=1.;if(true){float fadeStrength=0.1;float dist=max(0.,min(min(1.-screenPos.x,1.-screenPos.y),min(screenPos.x,screenPos.y)));float fade=dist*dist/(fadeStrength+0.001);fade=clamp(fade,0.0,1.0);fade=pow(fade,0.3);vignette=fade;}alphaModifier*=vignette;vec3 specularColor=EnvironmentBRDF(geometryNormal,geometryViewDir,material.specularColor.rgb,material.specularF90,material.roughness);if(length(specularColor.rgb)*alphaModifier>0.01&&roughnessFactor<0.9){\n#if defined(SSR_INLINE) && SSR_INLINE > 0\nvec3 scPos=vec3(screenPos.xy,geometryPosition.z);vec4 scol=vec4(0,0,0,0);\n#pragma unroll_loop_start\nfor(int i=0;i<8;i++){if(SSR_RAY_COUNT>UNROLLED_LOOP_INDEX){scol=calculateSSR(float(UNROLLED_LOOP_INDEX),scPos,geometryNormal,UNROLLED_LOOP_INDEX%3==0?1.:UNROLLED_LOOP_INDEX%3==1?0.5:1.5,material.roughness);\n#ifdef SSR_RAY_BLEND_MAX\nssrColor=max(ssrColor,scol);\n#else\nssrColor+=scol;\n#endif\n}}\n#pragma unroll_loop_end\n#ifndef SSR_RAY_BLEND_MAX\nssrColor*=ssrColor.a>0.001 ? 1.0/ssrColor.a : 1.0;\n#endif\n#else\nssrColor=tSSReflMapTexelToLinear(texture2D(tSSReflMap,screenPos.xy));\n#endif\n}ssrColor.rgb*=ssrBoost;ssrColor.a*=alphaModifier;ssrColor.rgb=pow(max(vec3(0.),ssrColor.rgb),vec3(ssrPower));ssrColor.a=min(ssrColor.a,1.0);\n#if defined(SSR_NON_PHYSICAL) && SSR_NON_PHYSICAL > 0\ndiffuseColor.a=max(ssrColor.a,diffuseColor.a*diffuseColor.a);reflectedLight.indirectSpecular=mix(reflectedLight.indirectSpecular,saturate(diffuseColor.rgb*ssrColor.rgb),1.0);reflectedLight.indirectDiffuse=diffuseColor.rgb*(1.0-ssrColor.a);reflectedLight.directDiffuse=vec3(0.0);reflectedLight.directSpecular=vec3(0.0);\n#else\nreflectedLight.indirectSpecular=mix(reflectedLight.indirectSpecular,(specularColor.rgb*ssrColor.rgb),ssrColor.a);\n#endif\n#if SSREFL_ENABLED == 2\n}\n#endif\n#endif\n";
|
|
1377
1391
|
const ssrShaderMain = "void main(){vec4 texel=tDiffuseTexelToLinear(texture2D(tDiffuse,vUv));vec4 lastAO=tLastThisTexelToLinear(texture2D(tLastThis,vUv));float depth;vec3 normal;getDepthNormal(vUv,depth,normal);if(depth>=0.999){discard;}float viewZ=depthToViewZ(depth);vec3 screenPos=vec3(vUv.x,vUv.y,viewZ);vec3 viewPos=screenToView3(screenPos.xy,screenPos.z);viewPos.z=viewZ/viewPos.z;vec4 ao=vec4(0.);ao+=calculateSSR(8.,screenPos,normal,1.,0.1);ao.rgb=min(vec3(3.),ao.rgb);ao.rgb=max(vec3(0.),ao.rgb);if(currentFrameCount<2.){gl_FragColor=ao;return;}if(ao.a<0.01){gl_FragColor.rgb=lastAO.rgb;gl_FragColor.a=(((lastAO.a)*currentFrameCount)/(currentFrameCount+1.));}else{gl_FragColor=((ao+(lastAO)*currentFrameCount)/(currentFrameCount+1.));}\n#include <colorspace_fragment>\n}";
|
|
1378
|
-
var __defProp$
|
|
1379
|
-
var __getOwnPropDesc$
|
|
1380
|
-
var __decorateClass$
|
|
1381
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1392
|
+
var __defProp$a = Object.defineProperty;
|
|
1393
|
+
var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
|
|
1394
|
+
var __decorateClass$a = (decorators, target, key, kind) => {
|
|
1395
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
|
|
1382
1396
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
1383
1397
|
if (decorator = decorators[i2])
|
|
1384
1398
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1385
|
-
if (kind && result) __defProp$
|
|
1399
|
+
if (kind && result) __defProp$a(target, key, result);
|
|
1386
1400
|
return result;
|
|
1387
1401
|
};
|
|
1388
1402
|
const passId$1 = "ssrefl";
|
|
@@ -1403,6 +1417,20 @@ let SSReflectionPlugin = class extends PipelinePassPlugin {
|
|
|
1403
1417
|
if (this._gbufferUnpackExtension) this._pass.setGBufferUnpackExtension(this._gbufferUnpackExtension);
|
|
1404
1418
|
else this._viewer.console.warn("SSReflectionPlugin: GBuffer unpack extension removed");
|
|
1405
1419
|
};
|
|
1420
|
+
this._viewerListeners = {
|
|
1421
|
+
preRender: () => {
|
|
1422
|
+
if (!this._viewer || this.isDisabled()) return;
|
|
1423
|
+
if (!this._pass) return;
|
|
1424
|
+
const renderCamera = this._viewer.scene.renderCamera;
|
|
1425
|
+
this._pass.uniforms.currentProjectionViewMatrix.value.multiplyMatrices(renderCamera.projectionMatrix, renderCamera.matrixWorldInverse);
|
|
1426
|
+
this._pass.uniforms.inverseViewMatrix.value.copy(renderCamera.matrixWorld);
|
|
1427
|
+
},
|
|
1428
|
+
postRender: () => {
|
|
1429
|
+
if (!this._viewer || this.isDisabled()) return;
|
|
1430
|
+
if (!this._pass) return;
|
|
1431
|
+
this._pass.uniforms.lastProjectionViewMatrix.value.copy(this._pass.uniforms.currentProjectionViewMatrix.value);
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1406
1434
|
this.enabled = enabled;
|
|
1407
1435
|
this.bufferType = bufferType;
|
|
1408
1436
|
this.sizeMultiplier = sizeMultiplier;
|
|
@@ -1446,6 +1474,13 @@ let SSReflectionPlugin = class extends PipelinePassPlugin {
|
|
|
1446
1474
|
if (viewer.getPlugin("Ground") || viewer.getPlugin("BaseGroundPlugin")) console.error("GroundPlugin must be added after SSReflectionPlugin");
|
|
1447
1475
|
this._gbufferUnpackExtensionChanged();
|
|
1448
1476
|
viewer.renderManager.addEventListener("gbufferUnpackExtensionChanged", this._gbufferUnpackExtensionChanged);
|
|
1477
|
+
viewer.forPlugin(VelocityBufferPlugin, (vbp) => {
|
|
1478
|
+
var _a2;
|
|
1479
|
+
(_a2 = this._pass) == null ? void 0 : _a2.material.registerMaterialExtensions([vbp.unpackExtension]);
|
|
1480
|
+
}, (vbp) => {
|
|
1481
|
+
var _a2, _b2;
|
|
1482
|
+
(_b2 = (_a2 = this._pass) == null ? void 0 : _a2.material) == null ? void 0 : _b2.unregisterMaterialExtensions([vbp.unpackExtension]);
|
|
1483
|
+
});
|
|
1449
1484
|
}
|
|
1450
1485
|
onRemove(viewer) {
|
|
1451
1486
|
this._disposeTarget();
|
|
@@ -1481,16 +1516,13 @@ let SSReflectionPlugin = class extends PipelinePassPlugin {
|
|
|
1481
1516
|
};
|
|
1482
1517
|
SSReflectionPlugin.PluginType = "SSReflectionPlugin";
|
|
1483
1518
|
SSReflectionPlugin.OldPluginType = "SSReflection";
|
|
1484
|
-
__decorateClass$
|
|
1485
|
-
uiImage(
|
|
1486
|
-
"SSReflection Buffer"
|
|
1487
|
-
/* {readOnly: true}*/
|
|
1488
|
-
)
|
|
1519
|
+
__decorateClass$a([
|
|
1520
|
+
uiImage("SSReflection Buffer", { readOnly: true, hideOnEmpty: true })
|
|
1489
1521
|
], SSReflectionPlugin.prototype, "texture", 2);
|
|
1490
|
-
__decorateClass$
|
|
1522
|
+
__decorateClass$a([
|
|
1491
1523
|
uiConfig()
|
|
1492
1524
|
], SSReflectionPlugin.prototype, "_pass", 2);
|
|
1493
|
-
SSReflectionPlugin = __decorateClass$
|
|
1525
|
+
SSReflectionPlugin = __decorateClass$a([
|
|
1494
1526
|
uiFolderContainer("SSReflection Plugin")
|
|
1495
1527
|
], SSReflectionPlugin);
|
|
1496
1528
|
let SSReflectionPluginPass = class extends ExtendedShaderPass {
|
|
@@ -1537,8 +1569,14 @@ let SSReflectionPluginPass = class extends ExtendedShaderPass {
|
|
|
1537
1569
|
maskFrontFactor: { value: -0.1 },
|
|
1538
1570
|
tolerance: { value: 0 },
|
|
1539
1571
|
ssrRoughnessFactor: { value: 1 },
|
|
1540
|
-
sceneBoundingRadius: { value: 0 }
|
|
1572
|
+
sceneBoundingRadius: { value: 0 },
|
|
1541
1573
|
// todo do same in SSAO
|
|
1574
|
+
// reprojection/velocity
|
|
1575
|
+
currentProjectionViewMatrix: { value: new Matrix4() },
|
|
1576
|
+
lastProjectionViewMatrix: { value: new Matrix4() },
|
|
1577
|
+
inverseViewMatrix: { value: new Matrix4() },
|
|
1578
|
+
// split mode
|
|
1579
|
+
ssrSplitX: { value: 0.5 }
|
|
1542
1580
|
},
|
|
1543
1581
|
vertexShader: shaderUtils.defaultVertex,
|
|
1544
1582
|
fragmentShader: `
|
|
@@ -1553,7 +1591,7 @@ ${samplePointHelpers}
|
|
|
1553
1591
|
|
|
1554
1592
|
${ssrtShader}
|
|
1555
1593
|
|
|
1556
|
-
${
|
|
1594
|
+
${getShaders().ssReflection}
|
|
1557
1595
|
|
|
1558
1596
|
${ssrShaderMain}
|
|
1559
1597
|
`
|
|
@@ -1576,6 +1614,7 @@ ${ssrShaderMain}
|
|
|
1576
1614
|
this.lowQualityFrames = 0;
|
|
1577
1615
|
this.maskFrontRays = true;
|
|
1578
1616
|
this.maskFrontFactor = -0.2;
|
|
1617
|
+
this.split = 0;
|
|
1579
1618
|
this.materialExtension = {
|
|
1580
1619
|
extraUniforms: {
|
|
1581
1620
|
tSSReflMap: () => {
|
|
@@ -1620,7 +1659,7 @@ ${ssrShaderMain}
|
|
|
1620
1659
|
},
|
|
1621
1660
|
onObjectRender: (_object, material, renderer) => {
|
|
1622
1661
|
var _a2, _b2, _c;
|
|
1623
|
-
let x = this.enabled && renderer.userData.screenSpaceRendering !== false && !((_a2 = material.userData) == null ? void 0 : _a2.pluginsDisabled) && !((_b2 = material.userData) == null ? void 0 : _b2.ssreflDisabled) ? 1 : 0;
|
|
1662
|
+
let x = this.enabled && renderer.userData.screenSpaceRendering !== false && !((_a2 = material.userData) == null ? void 0 : _a2.pluginsDisabled) && !((_b2 = material.userData) == null ? void 0 : _b2.ssreflDisabled) ? this.split > 0 ? 2 : 1 : 0;
|
|
1624
1663
|
if (material.defines.SSREFL_ENABLED !== x) {
|
|
1625
1664
|
material.defines.SSREFL_ENABLED = x;
|
|
1626
1665
|
material.needsUpdate = true;
|
|
@@ -1649,7 +1688,7 @@ ${ssrShaderMain}
|
|
|
1649
1688
|
#include <randomHelpers>
|
|
1650
1689
|
${samplePointHelpers}
|
|
1651
1690
|
${ssrtShader}
|
|
1652
|
-
${
|
|
1691
|
+
${getShaders().ssReflection}
|
|
1653
1692
|
`}
|
|
1654
1693
|
#include <simpleCameraHelpers>
|
|
1655
1694
|
#endif
|
|
@@ -1681,7 +1720,12 @@ ${ssrShader}
|
|
|
1681
1720
|
projection: this.material.uniforms.projection,
|
|
1682
1721
|
cameraPositionWorld: this.material.uniforms.cameraPositionWorld,
|
|
1683
1722
|
cameraNearFar: this.material.uniforms.cameraNearFar,
|
|
1684
|
-
sceneBoundingRadius: this.material.uniforms.sceneBoundingRadius
|
|
1723
|
+
sceneBoundingRadius: this.material.uniforms.sceneBoundingRadius,
|
|
1724
|
+
// reprojection
|
|
1725
|
+
currentProjectionViewMatrix: this.material.uniforms.currentProjectionViewMatrix,
|
|
1726
|
+
lastProjectionViewMatrix: this.material.uniforms.lastProjectionViewMatrix,
|
|
1727
|
+
inverseViewMatrix: this.material.uniforms.inverseViewMatrix,
|
|
1728
|
+
ssrSplitX: this.material.uniforms.ssrSplitX
|
|
1685
1729
|
});
|
|
1686
1730
|
}
|
|
1687
1731
|
}
|
|
@@ -1769,85 +1813,90 @@ ${ssrShader}
|
|
|
1769
1813
|
Object.assign(this.materialExtension.extraDefines, this._gbufferUnpackExtension.extraDefines);
|
|
1770
1814
|
}
|
|
1771
1815
|
};
|
|
1772
|
-
__decorateClass$
|
|
1816
|
+
__decorateClass$a([
|
|
1773
1817
|
uiSlider("Intensity", [0, 4]),
|
|
1774
1818
|
serialize(),
|
|
1775
1819
|
uniform()
|
|
1776
1820
|
], SSReflectionPluginPass.prototype, "intensity", 2);
|
|
1777
|
-
__decorateClass$
|
|
1821
|
+
__decorateClass$a([
|
|
1778
1822
|
uiVector("Boost"),
|
|
1779
1823
|
serialize(),
|
|
1780
1824
|
uniform()
|
|
1781
1825
|
], SSReflectionPluginPass.prototype, "boost", 2);
|
|
1782
|
-
__decorateClass$
|
|
1826
|
+
__decorateClass$a([
|
|
1783
1827
|
uiSlider("Object Radius", [0.01, 2]),
|
|
1784
1828
|
serialize(),
|
|
1785
1829
|
uniform()
|
|
1786
1830
|
], SSReflectionPluginPass.prototype, "objectRadius", 2);
|
|
1787
|
-
__decorateClass$
|
|
1831
|
+
__decorateClass$a([
|
|
1788
1832
|
uiToggle("Auto radius"),
|
|
1789
1833
|
serialize(),
|
|
1790
1834
|
uniform()
|
|
1791
1835
|
], SSReflectionPluginPass.prototype, "autoRadius", 2);
|
|
1792
|
-
__decorateClass$
|
|
1836
|
+
__decorateClass$a([
|
|
1793
1837
|
uiSlider("Power", [0, 3]),
|
|
1794
1838
|
serialize(),
|
|
1795
1839
|
uniform()
|
|
1796
1840
|
], SSReflectionPluginPass.prototype, "power", 2);
|
|
1797
|
-
__decorateClass$
|
|
1841
|
+
__decorateClass$a([
|
|
1798
1842
|
uiSlider("Tolerance", [0.1, 5]),
|
|
1799
1843
|
serialize(),
|
|
1800
1844
|
uniform()
|
|
1801
1845
|
], SSReflectionPluginPass.prototype, "tolerance", 2);
|
|
1802
|
-
__decorateClass$
|
|
1846
|
+
__decorateClass$a([
|
|
1803
1847
|
uiSlider("Roughness Factor", [0.1, 1.25]),
|
|
1804
1848
|
serialize(),
|
|
1805
1849
|
uniform({ propKey: "ssrRoughnessFactor" })
|
|
1806
1850
|
], SSReflectionPluginPass.prototype, "roughnessFactor", 2);
|
|
1807
|
-
__decorateClass$
|
|
1808
|
-
uiSlider("Step count", [1, 32], 1),
|
|
1851
|
+
__decorateClass$a([
|
|
1852
|
+
uiSlider("Step count", [1, 32], 1, { tags: ["performance"] }),
|
|
1809
1853
|
serialize(),
|
|
1810
1854
|
matDefine("SSR_STEP_COUNT", void 0, void 0, SSReflectionPluginPass.prototype.setDirty)
|
|
1811
1855
|
], SSReflectionPluginPass.prototype, "stepCount", 2);
|
|
1812
|
-
__decorateClass$
|
|
1813
|
-
uiSlider("Ray count", [1, 8], 1),
|
|
1856
|
+
__decorateClass$a([
|
|
1857
|
+
uiSlider("Ray count", [1, 8], 1, { tags: ["performance"] }),
|
|
1814
1858
|
serialize(),
|
|
1815
1859
|
matDefine("SSR_RAY_COUNT", void 0, void 0, SSReflectionPluginPass.prototype.setDirty)
|
|
1816
1860
|
], SSReflectionPluginPass.prototype, "rayCount", 2);
|
|
1817
|
-
__decorateClass$
|
|
1861
|
+
__decorateClass$a([
|
|
1818
1862
|
uiToggle("Ray Blend MAX"),
|
|
1819
1863
|
serialize(),
|
|
1820
1864
|
matDefineBool("SSR_RAY_BLEND_MAX", void 0, void 0, SSReflectionPluginPass.prototype.setDirty, true)
|
|
1821
1865
|
], SSReflectionPluginPass.prototype, "rayBlendMax", 2);
|
|
1822
|
-
__decorateClass$
|
|
1866
|
+
__decorateClass$a([
|
|
1823
1867
|
uiSlider("Low Quality Frames", [0, 4], 1),
|
|
1824
1868
|
serialize(),
|
|
1825
1869
|
matDefine("SSR_LOW_QUALITY_FRAMES", void 0, void 0, SSReflectionPluginPass.prototype.setDirty)
|
|
1826
1870
|
], SSReflectionPluginPass.prototype, "lowQualityFrames", 2);
|
|
1827
|
-
__decorateClass$
|
|
1871
|
+
__decorateClass$a([
|
|
1828
1872
|
uiToggle("Ignore front rays"),
|
|
1829
1873
|
serialize(),
|
|
1830
1874
|
matDefineBool("SSR_MASK_FRONT_RAYS", void 0, void 0, SSReflectionPluginPass.prototype.setDirty)
|
|
1831
1875
|
], SSReflectionPluginPass.prototype, "maskFrontRays", 2);
|
|
1832
|
-
__decorateClass$
|
|
1876
|
+
__decorateClass$a([
|
|
1833
1877
|
uiSlider("Mask front rays factor", [-1, 1], 0.01, (that) => ({ hidden: () => !that.maskFrontRays })),
|
|
1834
1878
|
serialize(),
|
|
1835
1879
|
uniform()
|
|
1836
1880
|
], SSReflectionPluginPass.prototype, "maskFrontFactor", 2);
|
|
1837
|
-
|
|
1881
|
+
__decorateClass$a([
|
|
1882
|
+
uiSlider("Split", [0, 1], 0.01, { tags: ["debug"] }),
|
|
1883
|
+
serialize(),
|
|
1884
|
+
uniform({ propKey: "ssrSplitX", onChange: SSReflectionPluginPass.prototype.setDirty })
|
|
1885
|
+
], SSReflectionPluginPass.prototype, "split", 2);
|
|
1886
|
+
SSReflectionPluginPass = __decorateClass$a([
|
|
1838
1887
|
uiFolderContainer("SSReflection Pass")
|
|
1839
1888
|
], SSReflectionPluginPass);
|
|
1840
1889
|
const outlineShader = "uniform sampler2D outlineBuffer;uniform vec2 tDiffuseSize;uniform vec3 outlineColor;uniform float outlineThickness;uniform float outlineIntensity;uniform float highlightTransparency;uniform bool enableHighlight;uniform float dpr;float isSelected(vec2 uv){return 1.-texture2D(outlineBuffer,uv).b;}vec4 outline(in vec4 color){vec2 invSize=1.0/tDiffuseSize;\n#if DEBUG_OUTLINE > 0\ncolor=vec4(0.,0.,0.,1.);\n#endif\nvec3 finalColor=color.rgb;float c=isSelected(vUv);if(c>0.){vec4 uvOffset=1.5*dpr*outlineThickness*vec4(1.0,0.0,-1.0,1.0)*vec4(invSize,invSize);float c1=isSelected(vUv+uvOffset.xy);float c2=isSelected(vUv-uvOffset.xy);float c3=isSelected(vUv+uvOffset.yw);float c4=isSelected(vUv-uvOffset.yw);float diff1=(c1-c2)*0.5;float diff2=(c3-c4)*0.5;float d=length(vec2(diff1,diff2));vec4 highlightColor=enableHighlight ? vec4(c*outlineColor,(1.-highlightTransparency)*c): vec4(0.);vec4 edgeColor=vec4(outlineColor,1.)*vec4(d);float gbufferDepth=getDepth(vUv);float outlineDepth=unpack16(texture2D(outlineBuffer,vUv).xy);outlineDepth*=outlineDepth;outlineDepth-=0.005;if(gbufferDepth<outlineDepth){highlightColor.rgb=highlightColor.rgb*0.3;edgeColor.rgb=edgeColor.rgb*0.5;}vec4 outColor=edgeColor+highlightColor*(1.-d);finalColor=mix(color.rgb,outlineIntensity*outColor.rgb,outColor.a);}else{finalColor.rgb=color.rgb;}return vec4(finalColor.rgb,color.a);}";
|
|
1841
1890
|
const outlineDepthVertex = "#ifdef USE_ALPHAMAP\n#define USE_UV\n#endif\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec3 vViewPosition;void main(){\n#include <skinbase_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition=-mvPosition.xyz;}";
|
|
1842
1891
|
const outlineDepthFrag = "uniform vec2 cameraNearFar;varying vec3 vViewPosition;vec2 pack16(float value){float sMax=65535.0;int v=int(clamp(value,0.0,1.0)*sMax+0.5);int digit0=v/256;int digit1=v-digit0*256;return vec2(float(digit0)/255.0,float(digit1)/255.0);}float linstep(float edge0,float edge1,float value){return clamp((value-edge0)/(edge1-edge0),0.0,1.0);}void main(){float linearZ=linstep(-cameraNearFar.x,-cameraNearFar.y,-vViewPosition.z);vec2 packedZ=pack16(pow(max(0.,linearZ),0.5));gl_FragColor=vec4(packedZ.x,packedZ.y,0.,0.);}";
|
|
1843
|
-
var __defProp$
|
|
1844
|
-
var __getOwnPropDesc$
|
|
1845
|
-
var __decorateClass$
|
|
1846
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1892
|
+
var __defProp$9 = Object.defineProperty;
|
|
1893
|
+
var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
|
|
1894
|
+
var __decorateClass$9 = (decorators, target, key, kind) => {
|
|
1895
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
|
|
1847
1896
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
1848
1897
|
if (decorator = decorators[i2])
|
|
1849
1898
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1850
|
-
if (kind && result) __defProp$
|
|
1899
|
+
if (kind && result) __defProp$9(target, key, result);
|
|
1851
1900
|
return result;
|
|
1852
1901
|
};
|
|
1853
1902
|
let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
@@ -1928,14 +1977,16 @@ let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
|
1928
1977
|
setDirty() {
|
|
1929
1978
|
super.setDirty();
|
|
1930
1979
|
if (!this._viewer) return;
|
|
1931
|
-
const picking = this._viewer.getPlugin(PickingPlugin);
|
|
1932
1980
|
const enabled = !this.isDisabled();
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
this._pickingWidgetDisabled
|
|
1981
|
+
const picking = this._viewer.getPlugin(PickingPlugin);
|
|
1982
|
+
if (picking) {
|
|
1983
|
+
if (enabled && picking.widgetEnabled) {
|
|
1984
|
+
picking.widgetEnabled = false;
|
|
1985
|
+
this._pickingWidgetDisabled = true;
|
|
1986
|
+
} else if (!enabled && this._pickingWidgetDisabled) {
|
|
1987
|
+
picking.widgetEnabled = true;
|
|
1988
|
+
this._pickingWidgetDisabled = false;
|
|
1989
|
+
}
|
|
1939
1990
|
}
|
|
1940
1991
|
this._viewer.setDirty();
|
|
1941
1992
|
}
|
|
@@ -2057,64 +2108,61 @@ let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
|
2057
2108
|
};
|
|
2058
2109
|
OutlinePlugin.PluginType = "OutlinePlugin";
|
|
2059
2110
|
OutlinePlugin.OldPluginType = "Outline";
|
|
2060
|
-
__decorateClass$
|
|
2111
|
+
__decorateClass$9([
|
|
2061
2112
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2062
2113
|
uiToggle("Enable"),
|
|
2063
2114
|
serialize()
|
|
2064
2115
|
], OutlinePlugin.prototype, "enabled", 2);
|
|
2065
|
-
__decorateClass$
|
|
2116
|
+
__decorateClass$9([
|
|
2066
2117
|
uiToggle("Highlight"),
|
|
2067
2118
|
uniform({ propKey: "enableHighlight" }),
|
|
2068
2119
|
serialize()
|
|
2069
2120
|
], OutlinePlugin.prototype, "enableHighlight", 2);
|
|
2070
|
-
__decorateClass$
|
|
2121
|
+
__decorateClass$9([
|
|
2071
2122
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2072
2123
|
uiToggle("DynamicSelection"),
|
|
2073
2124
|
serialize()
|
|
2074
2125
|
], OutlinePlugin.prototype, "enableDynamicSelection", 2);
|
|
2075
|
-
__decorateClass$
|
|
2126
|
+
__decorateClass$9([
|
|
2076
2127
|
uiSlider("Intensity", [0, 4], 1e-3),
|
|
2077
2128
|
uniform({ propKey: "outlineIntensity" }),
|
|
2078
2129
|
serialize("outlineIntensity")
|
|
2079
2130
|
], OutlinePlugin.prototype, "intensity", 2);
|
|
2080
|
-
__decorateClass$
|
|
2131
|
+
__decorateClass$9([
|
|
2081
2132
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2082
2133
|
uiSlider("Transparency", [0, 1], 0.01),
|
|
2083
2134
|
serialize()
|
|
2084
2135
|
], OutlinePlugin.prototype, "highlightTransparency", 2);
|
|
2085
|
-
__decorateClass$
|
|
2136
|
+
__decorateClass$9([
|
|
2086
2137
|
uiColor("Color"),
|
|
2087
2138
|
uniform({ propKey: "outlineColor" }),
|
|
2088
2139
|
serialize("outlineColor")
|
|
2089
2140
|
], OutlinePlugin.prototype, "color", 2);
|
|
2090
|
-
__decorateClass$
|
|
2141
|
+
__decorateClass$9([
|
|
2091
2142
|
uiSlider("Thickness", [0, 10], 0.01),
|
|
2092
2143
|
uniform({ propKey: "outlineThickness" }),
|
|
2093
2144
|
serialize("outlineThickness")
|
|
2094
2145
|
], OutlinePlugin.prototype, "thickness", 2);
|
|
2095
|
-
__decorateClass$
|
|
2146
|
+
__decorateClass$9([
|
|
2096
2147
|
uiToggle("Debug"),
|
|
2097
2148
|
matDefineBool("DEBUG_OUTLINE", void 0, true)
|
|
2098
2149
|
], OutlinePlugin.prototype, "debugOutline", 2);
|
|
2099
|
-
__decorateClass$
|
|
2150
|
+
__decorateClass$9([
|
|
2100
2151
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2101
2152
|
uiToggle("Highlight Selected Materials")
|
|
2102
2153
|
], OutlinePlugin.prototype, "highlightSelectedMaterials", 2);
|
|
2103
|
-
__decorateClass$
|
|
2154
|
+
__decorateClass$9([
|
|
2104
2155
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2105
2156
|
uiToggle("Highlight Materials (same name)")
|
|
2106
2157
|
], OutlinePlugin.prototype, "highlightMaterialSameNames", 2);
|
|
2107
|
-
__decorateClass$
|
|
2158
|
+
__decorateClass$9([
|
|
2108
2159
|
uniform({ propKey: "highlightTransparency" })
|
|
2109
2160
|
], OutlinePlugin.prototype, "transparency", 2);
|
|
2110
|
-
__decorateClass$
|
|
2161
|
+
__decorateClass$9([
|
|
2111
2162
|
uniform({ propKey: "outlineBuffer" }),
|
|
2112
|
-
uiImage(
|
|
2113
|
-
"Outline Buffer"
|
|
2114
|
-
/* {readOnly: true}*/
|
|
2115
|
-
)
|
|
2163
|
+
uiImage("Outline Buffer", { readOnly: true })
|
|
2116
2164
|
], OutlinePlugin.prototype, "texture", 2);
|
|
2117
|
-
OutlinePlugin = __decorateClass$
|
|
2165
|
+
OutlinePlugin = __decorateClass$9([
|
|
2118
2166
|
uiFolderContainer("Outline")
|
|
2119
2167
|
], OutlinePlugin);
|
|
2120
2168
|
let OutlineRenderPass = class extends RenderPass {
|
|
@@ -2206,22 +2254,21 @@ let OutlineRenderPass = class extends RenderPass {
|
|
|
2206
2254
|
camera.updateShaderProperties(this.overrideMaterial);
|
|
2207
2255
|
}
|
|
2208
2256
|
};
|
|
2209
|
-
__decorateClass$
|
|
2257
|
+
__decorateClass$9([
|
|
2210
2258
|
uiToggle("Enabled")
|
|
2211
2259
|
], OutlineRenderPass.prototype, "enabled", 2);
|
|
2212
|
-
OutlineRenderPass = __decorateClass$
|
|
2260
|
+
OutlineRenderPass = __decorateClass$9([
|
|
2213
2261
|
uiFolderContainer((c) => c.passId + " Render Pass")
|
|
2214
2262
|
], OutlineRenderPass);
|
|
2215
|
-
const ssgiPatch = "\n#if defined(SSRTAO_ENABLED) && SSRTAO_ENABLED > 0\nvec4 ssgi=tSSGIMapTexelToLinear(texture2D(tSSGIMap,
|
|
2216
|
-
const ssrtaoShader = "uniform float sceneBoundingRadius;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;vec3 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\nvec3 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.));}";
|
|
2263
|
+
const ssgiPatch = "\n#if defined(SSRTAO_ENABLED) && SSRTAO_ENABLED > 0\nvec3 screenPos_gi=viewToScreen(vViewPosition.xyz);\n#if SSRTAO_ENABLED == 2\nif(screenPos_gi.x>ssrtaoSplitX){\n#endif\nvec4 ssgi=tSSGIMapTexelToLinear(texture2D(tSSGIMap,screenPos_gi.xy));float ambientOcclusion=1.-ssgi.a;ambientOcclusion=max(0.,ambientOcclusion);ambientOcclusion=pow(ambientOcclusion,ssaoPower);ambientOcclusion=min(1.,ambientOcclusion);reflectedLight.indirectDiffuse*=ambientOcclusion;\n#if defined(SSGI_ENABLED) && SSGI_ENABLED > 0\nvec3 ssgiColor=ssgi.rgb*ssgiIntensity;reflectedLight.indirectDiffuse+=ssgiColor*(material.diffuseColor.rgb);\n#endif\n#if defined( USE_ENVMAP )\nfloat dotNV=saturate(dot(geometryNormal,geometryViewDir));float specularOcclusion=saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*material.roughness-1.0))-1.0+ambientOcclusion);reflectedLight.indirectSpecular*=specularOcclusion;\n#if defined(SSGI_ENABLED) && SSGI_ENABLED > 0\n#if !defined(SSR_ENABLED) || SSR_ENABLED < 1\nreflectedLight.indirectSpecular+=ssgiColor*material.specularColor;\n#endif\n#endif\n#endif\n#if SSRTAO_ENABLED == 2\n}\n#endif\n#endif\n";
|
|
2217
2264
|
const ssaoBilateral = "uniform vec2 tDiffuseSize;uniform vec2 bilDirection;varying vec2 vUv;uniform bool smoothEnabled;uniform float edgeSharpness;vec4 bilaterialAO(){vec4 color=clamp((texture2D(tDiffuse,vUv.xy)).B_SRC_ACCESSOR,0.,5.);if(!smoothEnabled)return color;float depth;vec3 normal;getDepthNormal(vUv.xy,depth,normal);float gaussianWeights[4];gaussianWeights[0]=0.153170;gaussianWeights[1]=0.144893;gaussianWeights[2]=0.122649;gaussianWeights[3]=0.092902;float Z=gaussianWeights[0]+0.03;vec4 final_colour=Z*color;vec2 nuv;vec4 cc;float dp;vec3 nor;vec2 direction=bilDirection/tDiffuseSize.xy;\n#pragma unroll_loop_start\nfor(int i=0;i<6;i++){direction*=-1.;nuv=vUv+2.*direction*float(UNROLLED_LOOP_INDEX/2+1);getDepthNormal(nuv,dp,nor);if(dp<0.999){float normalCloseness=dot(normal,nor);normalCloseness*=normalCloseness;float normalError=(1.0-normalCloseness)*8.;float normalWeight=max((1.0-normalError*edgeSharpness),0.00);float depthWeight=max(0.0,1.0-edgeSharpness*4000.*abs(depth-dp));float kernelWeight=gaussianWeights[UNROLLED_LOOP_INDEX/2]+0.03;float bilateralWeight=kernelWeight*depthWeight*normalWeight;Z+=bilateralWeight;cc=clamp((texture2D(tDiffuse,nuv)).B_SRC_ACCESSOR,0.,5.);final_colour+=bilateralWeight*cc;}}\n#pragma unroll_loop_end\nfinal_colour/=Z;return final_colour;}void main(){vec4 ao=clamp(bilaterialAO(),vec4(0.),vec4(1.));gl_FragColor=ao;}";
|
|
2218
|
-
var __defProp$
|
|
2219
|
-
var __decorateClass$
|
|
2265
|
+
var __defProp$8 = Object.defineProperty;
|
|
2266
|
+
var __decorateClass$8 = (decorators, target, key, kind) => {
|
|
2220
2267
|
var result = void 0;
|
|
2221
2268
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
2222
2269
|
if (decorator = decorators[i2])
|
|
2223
2270
|
result = decorator(target, key, result) || result;
|
|
2224
|
-
if (result) __defProp$
|
|
2271
|
+
if (result) __defProp$8(target, key, result);
|
|
2225
2272
|
return result;
|
|
2226
2273
|
};
|
|
2227
2274
|
class BilateralFilterPass extends ExtendedShaderPass {
|
|
@@ -2266,22 +2313,22 @@ class BilateralFilterPass extends ExtendedShaderPass {
|
|
|
2266
2313
|
super.render(renderer, target, writeBuffer, deltaTime, maskActive);
|
|
2267
2314
|
}
|
|
2268
2315
|
}
|
|
2269
|
-
__decorateClass$
|
|
2316
|
+
__decorateClass$8([
|
|
2270
2317
|
serialize(),
|
|
2271
2318
|
uniform()
|
|
2272
2319
|
], BilateralFilterPass.prototype, "smoothEnabled");
|
|
2273
|
-
__decorateClass$
|
|
2320
|
+
__decorateClass$8([
|
|
2274
2321
|
serialize(),
|
|
2275
2322
|
uniform()
|
|
2276
2323
|
], BilateralFilterPass.prototype, "edgeSharpness");
|
|
2277
|
-
var __defProp$
|
|
2278
|
-
var __getOwnPropDesc$
|
|
2279
|
-
var __decorateClass$
|
|
2280
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
2324
|
+
var __defProp$7 = Object.defineProperty;
|
|
2325
|
+
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
2326
|
+
var __decorateClass$7 = (decorators, target, key, kind) => {
|
|
2327
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
|
|
2281
2328
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
2282
2329
|
if (decorator = decorators[i2])
|
|
2283
2330
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
2284
|
-
if (kind && result) __defProp$
|
|
2331
|
+
if (kind && result) __defProp$7(target, key, result);
|
|
2285
2332
|
return result;
|
|
2286
2333
|
};
|
|
2287
2334
|
const passId = "ssrtgi";
|
|
@@ -2343,6 +2390,13 @@ let SSGIPlugin = class extends PipelinePassPlugin {
|
|
|
2343
2390
|
if (viewer.getPlugin("Ground") || viewer.getPlugin("BaseGroundPlugin")) console.error("GroundPlugin must be added after SSGIPlugin");
|
|
2344
2391
|
this._gbufferUnpackExtensionChanged();
|
|
2345
2392
|
viewer.renderManager.addEventListener("gbufferUnpackExtensionChanged", this._gbufferUnpackExtensionChanged);
|
|
2393
|
+
viewer.forPlugin(VelocityBufferPlugin, (vbp) => {
|
|
2394
|
+
var _a2;
|
|
2395
|
+
(_a2 = this._pass) == null ? void 0 : _a2.material.registerMaterialExtensions([vbp.unpackExtension]);
|
|
2396
|
+
}, (vbp) => {
|
|
2397
|
+
var _a2, _b2;
|
|
2398
|
+
(_b2 = (_a2 = this._pass) == null ? void 0 : _a2.material) == null ? void 0 : _b2.unregisterMaterialExtensions([vbp.unpackExtension]);
|
|
2399
|
+
});
|
|
2346
2400
|
}
|
|
2347
2401
|
onRemove(viewer) {
|
|
2348
2402
|
this._disposeTarget();
|
|
@@ -2384,16 +2438,13 @@ let SSGIPlugin = class extends PipelinePassPlugin {
|
|
|
2384
2438
|
};
|
|
2385
2439
|
SSGIPlugin.PluginType = "SSGIPlugin";
|
|
2386
2440
|
SSGIPlugin.OldPluginType = "SSGI";
|
|
2387
|
-
__decorateClass$
|
|
2388
|
-
uiImage(
|
|
2389
|
-
"SSGI Buffer"
|
|
2390
|
-
/* {readOnly: true}*/
|
|
2391
|
-
)
|
|
2441
|
+
__decorateClass$7([
|
|
2442
|
+
uiImage("SSGI Buffer", { readOnly: true })
|
|
2392
2443
|
], SSGIPlugin.prototype, "texture", 2);
|
|
2393
|
-
__decorateClass$
|
|
2444
|
+
__decorateClass$7([
|
|
2394
2445
|
uiConfig()
|
|
2395
2446
|
], SSGIPlugin.prototype, "_pass", 2);
|
|
2396
|
-
SSGIPlugin = __decorateClass$
|
|
2447
|
+
SSGIPlugin = __decorateClass$7([
|
|
2397
2448
|
uiFolderContainer("SSGI Plugin")
|
|
2398
2449
|
], SSGIPlugin);
|
|
2399
2450
|
let SSGIPluginPass = class extends ExtendedShaderPass {
|
|
@@ -2442,8 +2493,14 @@ let SSGIPluginPass = class extends ExtendedShaderPass {
|
|
|
2442
2493
|
// maskFrontFactor: {value: -0.1},
|
|
2443
2494
|
tolerance: { value: 0 },
|
|
2444
2495
|
// ssrtaoRoughnessFactor: {value: 1},
|
|
2445
|
-
sceneBoundingRadius: { value: 0 }
|
|
2496
|
+
sceneBoundingRadius: { value: 0 },
|
|
2446
2497
|
// todo do same in SSAO
|
|
2498
|
+
// reprojection/velocity
|
|
2499
|
+
currentProjectionViewMatrix: { value: new Matrix4() },
|
|
2500
|
+
lastProjectionViewMatrix: { value: new Matrix4() },
|
|
2501
|
+
inverseViewMatrix: { value: new Matrix4() },
|
|
2502
|
+
// split mode
|
|
2503
|
+
ssrtaoSplitX: { value: 0.5 }
|
|
2447
2504
|
},
|
|
2448
2505
|
vertexShader: shaderUtils.defaultVertex,
|
|
2449
2506
|
fragmentShader: `
|
|
@@ -2458,7 +2515,7 @@ ${samplePointHelpers}
|
|
|
2458
2515
|
|
|
2459
2516
|
${ssrtShader}
|
|
2460
2517
|
|
|
2461
|
-
${
|
|
2518
|
+
${getShaders().calculateGI}
|
|
2462
2519
|
`
|
|
2463
2520
|
}, "tDiffuse", "tLastThis", "tLastFrame");
|
|
2464
2521
|
this.target = target;
|
|
@@ -2477,6 +2534,7 @@ ${ssrtaoShader}
|
|
|
2477
2534
|
this.stepCount = 8;
|
|
2478
2535
|
this.smoothEnabled = true;
|
|
2479
2536
|
this.renderWithCamera = true;
|
|
2537
|
+
this.split = 0;
|
|
2480
2538
|
this.materialExtension = {
|
|
2481
2539
|
// todo set priority wrt ssr etc
|
|
2482
2540
|
extraUniforms: {
|
|
@@ -2485,7 +2543,8 @@ ${ssrtaoShader}
|
|
|
2485
2543
|
return { value: ((_a2 = getOrCall(this.target)) == null ? void 0 : _a2.texture) ?? null };
|
|
2486
2544
|
},
|
|
2487
2545
|
ssaoPower: this.material.uniforms.power,
|
|
2488
|
-
ssgiIntensity: this.material.uniforms.intensity
|
|
2546
|
+
ssgiIntensity: this.material.uniforms.intensity,
|
|
2547
|
+
ssrtaoSplitX: this.material.uniforms.ssrtaoSplitX
|
|
2489
2548
|
// ssrMaskFrontFactor: this.material.uniforms.maskFrontFactor,
|
|
2490
2549
|
},
|
|
2491
2550
|
extraDefines: {
|
|
@@ -2519,7 +2578,7 @@ ${ssrtaoShader}
|
|
|
2519
2578
|
},
|
|
2520
2579
|
onObjectRender: (_object, material, renderer) => {
|
|
2521
2580
|
var _a2, _b2, _c;
|
|
2522
|
-
let x = this.enabled && (this.renderWithCamera || renderer.renderManager.frameCount > 1) && renderer.userData.screenSpaceRendering !== false && !((_a2 = material.userData) == null ? void 0 : _a2.pluginsDisabled) && !((_b2 = material.userData) == null ? void 0 : _b2.ssrtaoDisabled) && !((_c = material.userData) == null ? void 0 : _c.ssaoDisabled) ? 1 : 0;
|
|
2581
|
+
let x = this.enabled && (this.renderWithCamera || renderer.renderManager.frameCount > 1) && renderer.userData.screenSpaceRendering !== false && !((_a2 = material.userData) == null ? void 0 : _a2.pluginsDisabled) && !((_b2 = material.userData) == null ? void 0 : _b2.ssrtaoDisabled) && !((_c = material.userData) == null ? void 0 : _c.ssaoDisabled) ? this.split > 0 ? 2 : 1 : 0;
|
|
2523
2582
|
if (material.defines.SSRTAO_ENABLED !== x) {
|
|
2524
2583
|
material.defines.SSRTAO_ENABLED = x;
|
|
2525
2584
|
material.needsUpdate = true;
|
|
@@ -2532,6 +2591,9 @@ ${ssrtaoShader}
|
|
|
2532
2591
|
uniform float ssaoPower;
|
|
2533
2592
|
uniform float ssgiIntensity;
|
|
2534
2593
|
uniform sampler2D tSSGIMap;
|
|
2594
|
+
#if defined(SSRTAO_ENABLED) && SSRTAO_ENABLED == 2
|
|
2595
|
+
uniform float ssrtaoSplitX;
|
|
2596
|
+
#endif
|
|
2535
2597
|
${getTexelDecoding("tSSGIMap", (_a2 = getOrCall(this.target)) == null ? void 0 : _a2.texture.colorSpace)}
|
|
2536
2598
|
${/*tLastFrame not requried in material extension
|
|
2537
2599
|
// uniform sampler2D tLastFrame;
|
|
@@ -2581,10 +2643,13 @@ ${ssrtaoShader}
|
|
|
2581
2643
|
if (this.smoothEnabled) {
|
|
2582
2644
|
this.bilateralPass.render(renderer, writeBuffer, readBuffer, deltaTime, maskActive);
|
|
2583
2645
|
}
|
|
2646
|
+
this.uniforms.lastProjectionViewMatrix.value.copy(this.uniforms.currentProjectionViewMatrix.value);
|
|
2584
2647
|
}
|
|
2585
2648
|
beforeRender(scene, camera, renderManager) {
|
|
2586
2649
|
if (!this.enabled) return;
|
|
2587
2650
|
this.updateShaderProperties([scene, camera, renderManager]);
|
|
2651
|
+
this.uniforms.currentProjectionViewMatrix.value.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
2652
|
+
this.uniforms.inverseViewMatrix.value.copy(camera.matrixWorld);
|
|
2588
2653
|
}
|
|
2589
2654
|
/**
|
|
2590
2655
|
* Returns a uiConfig to toggle SSGI on a material.
|
|
@@ -2651,79 +2716,84 @@ ${ssrtaoShader}
|
|
|
2651
2716
|
super.setDirty();
|
|
2652
2717
|
}
|
|
2653
2718
|
};
|
|
2654
|
-
__decorateClass$
|
|
2719
|
+
__decorateClass$7([
|
|
2655
2720
|
serialize()
|
|
2656
2721
|
], SSGIPluginPass.prototype, "bilateralPass", 2);
|
|
2657
|
-
__decorateClass$
|
|
2722
|
+
__decorateClass$7([
|
|
2658
2723
|
uiToggle("GI Enabled"),
|
|
2659
2724
|
serialize(),
|
|
2660
2725
|
matDefineBool("SSGI_ENABLED", void 0, void 0, SSGIPluginPass.prototype.setDirty, false)
|
|
2661
2726
|
], SSGIPluginPass.prototype, "giEnabled", 2);
|
|
2662
|
-
__decorateClass$
|
|
2727
|
+
__decorateClass$7([
|
|
2663
2728
|
uiSlider("Intensity", [0, 4]),
|
|
2664
2729
|
serialize(),
|
|
2665
2730
|
uniform()
|
|
2666
2731
|
], SSGIPluginPass.prototype, "intensity", 2);
|
|
2667
|
-
__decorateClass$
|
|
2732
|
+
__decorateClass$7([
|
|
2668
2733
|
uiSlider("Power", [0, 3]),
|
|
2669
2734
|
serialize(),
|
|
2670
2735
|
uniform()
|
|
2671
2736
|
], SSGIPluginPass.prototype, "power", 2);
|
|
2672
|
-
__decorateClass$
|
|
2737
|
+
__decorateClass$7([
|
|
2673
2738
|
uiToggle("Auto radius"),
|
|
2674
2739
|
serialize(),
|
|
2675
2740
|
uniform()
|
|
2676
2741
|
], SSGIPluginPass.prototype, "autoRadius", 2);
|
|
2677
|
-
__decorateClass$
|
|
2742
|
+
__decorateClass$7([
|
|
2678
2743
|
uiSlider("Object Radius", [0.01, 10]),
|
|
2679
2744
|
serialize(),
|
|
2680
2745
|
uniform()
|
|
2681
2746
|
], SSGIPluginPass.prototype, "objectRadius", 2);
|
|
2682
|
-
__decorateClass$
|
|
2747
|
+
__decorateClass$7([
|
|
2683
2748
|
uiSlider("Tolerance", [0.1, 5]),
|
|
2684
2749
|
serialize(),
|
|
2685
2750
|
uniform()
|
|
2686
2751
|
], SSGIPluginPass.prototype, "tolerance", 2);
|
|
2687
|
-
__decorateClass$
|
|
2752
|
+
__decorateClass$7([
|
|
2688
2753
|
uiSlider("Bias", [-0.3, 0.3]),
|
|
2689
2754
|
serialize(),
|
|
2690
2755
|
uniform()
|
|
2691
2756
|
], SSGIPluginPass.prototype, "bias", 2);
|
|
2692
|
-
__decorateClass$
|
|
2757
|
+
__decorateClass$7([
|
|
2693
2758
|
uiSlider("Falloff", [1e-4, 4]),
|
|
2694
2759
|
serialize(),
|
|
2695
2760
|
uniform()
|
|
2696
2761
|
], SSGIPluginPass.prototype, "falloff", 2);
|
|
2697
|
-
__decorateClass$
|
|
2698
|
-
uiSlider("Ray Count", [1, 5], 1),
|
|
2762
|
+
__decorateClass$7([
|
|
2763
|
+
uiSlider("Ray Count", [1, 5], 1, { tags: ["performance"] }),
|
|
2699
2764
|
serialize(),
|
|
2700
2765
|
uniform()
|
|
2701
2766
|
], SSGIPluginPass.prototype, "rayCount", 2);
|
|
2702
|
-
__decorateClass$
|
|
2703
|
-
uiSlider("Step count", [1, 16], 1),
|
|
2767
|
+
__decorateClass$7([
|
|
2768
|
+
uiSlider("Step count", [1, 16], 1, { tags: ["performance"] }),
|
|
2704
2769
|
serialize(),
|
|
2705
2770
|
matDefine("RTAO_STEP_COUNT", void 0, void 0, SSGIPluginPass.prototype.setDirty)
|
|
2706
2771
|
], SSGIPluginPass.prototype, "stepCount", 2);
|
|
2707
|
-
__decorateClass$
|
|
2772
|
+
__decorateClass$7([
|
|
2708
2773
|
uiToggle("Smooth Enabled"),
|
|
2709
2774
|
serialize()
|
|
2710
2775
|
], SSGIPluginPass.prototype, "smoothEnabled", 2);
|
|
2711
|
-
__decorateClass$
|
|
2776
|
+
__decorateClass$7([
|
|
2712
2777
|
uiToggle("Render with Camera")
|
|
2713
2778
|
], SSGIPluginPass.prototype, "renderWithCamera", 2);
|
|
2714
|
-
|
|
2779
|
+
__decorateClass$7([
|
|
2780
|
+
uiSlider("Split", [0, 1], 0.01, { tags: ["debug"] }),
|
|
2781
|
+
serialize(),
|
|
2782
|
+
uniform({ propKey: "ssrtaoSplitX", onChange: SSGIPluginPass.prototype.setDirty })
|
|
2783
|
+
], SSGIPluginPass.prototype, "split", 2);
|
|
2784
|
+
SSGIPluginPass = __decorateClass$7([
|
|
2715
2785
|
uiFolderContainer("SSGI Pass")
|
|
2716
2786
|
], SSGIPluginPass);
|
|
2717
2787
|
const anisotropyBsdf = "uniform float anisotropyFactor;uniform float anisotropyNoise;\n#if ANISOTROPY_TEX_MODE == 0\nuniform float anisotropyDirection;\n#else\nuniform sampler2D anisotropyDirectionMap;varying vec2 vAnisotropy2MapUv;\n#endif\nconst float MIN_ROUGHNESS=0.05;vec3 indirectAnisotropyBentNormal(const in vec3 normal,const in vec3 viewDir,const in float roughness,const in vec3 anisotropicT,const in vec3 anisotropicB){vec3 aDirection=anisotropyFactor>=0.0 ? anisotropicB : anisotropicT;vec3 aTangent=cross(aDirection,viewDir);vec3 aNormal=cross(aTangent,aDirection);float bendFactor=abs(anisotropyFactor)*saturate(5.0*max(roughness,MIN_ROUGHNESS));return normalize(mix(normal,aNormal,bendFactor));}vec3 BRDF_GGX_Anisotropy(const in vec3 lightDir,const in vec3 viewDir,const in vec3 normal,const in vec3 f0,const in float f90,const in float roughness,const in vec3 anisotropicT,const in vec3 anisotropicB){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));float dotTV=dot(anisotropicT,viewDir);float dotBV=dot(anisotropicB,viewDir);float dotTL=dot(anisotropicT,lightDir);float dotBL=dot(anisotropicB,lightDir);float dotTH=dot(anisotropicT,halfDir);float dotBH=dot(anisotropicB,halfDir);float aspect=sqrt(1.0-min(1.-MIN_ROUGHNESS,abs(anisotropyFactor)*0.9));if(anisotropyFactor>0.0)aspect=1.0/aspect;float at=roughness*aspect;float ab=roughness/aspect;vec3 F=F_Schlick(f0,f90,dotVH);float V=V_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);return F*(V*D);}";
|
|
2718
2788
|
const anisotropyTBN = "float rnd=(random2(vUv.xy,frameCount)-0.5)*anisotropyNoise*material.roughness;\n#if ANISOTROPY_TEX_MODE < 2\n#if ANISOTROPY_TEX_MODE == 0\nfloat rot=saturate(anisotropyDirection);\n#else\nfloat rot=(anisotropyDirectionMapTexelToLinear(texture2D(anisotropyDirectionMap,vAnisotropy2MapUv)).r);\n#endif\nrot=rot*2.*PI+rnd;vec2 rot2=vec2(sin(rot),cos(rot));\n#else\nvec2 rot2=(anisotropyDirectionMapTexelToLinear(texture2D(anisotropyDirectionMap,vAnisotropy2MapUv)).rg*2.-1.)+vec2(rnd,rnd);rot2=normalize(rot2);const float anisoSpecMultiplier=0.25;float matSpecAniso=(length(material.specularColor.rgb))*2.*PI;rot2=mix(rot2,vec2(sin(matSpecAniso),cos(matSpecAniso)),anisoSpecMultiplier);rot2=normalize(rot2);\n#endif\nvec3 anisotropicT=(tbn[0]*rot2.x+tbn[1]*rot2.y);anisotropicT=normalize(anisotropicT-normal*dot(anisotropicT,normal));vec3 anisotropicB=normalize(cross(normal,anisotropicT));";
|
|
2719
|
-
var __defProp$
|
|
2720
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2721
|
-
var __decorateClass$
|
|
2722
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
2789
|
+
var __defProp$6 = Object.defineProperty;
|
|
2790
|
+
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
2791
|
+
var __decorateClass$6 = (decorators, target, key, kind) => {
|
|
2792
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
|
|
2723
2793
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
2724
2794
|
if (decorator = decorators[i2])
|
|
2725
2795
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
2726
|
-
if (kind && result) __defProp$
|
|
2796
|
+
if (kind && result) __defProp$6(target, key, result);
|
|
2727
2797
|
return result;
|
|
2728
2798
|
};
|
|
2729
2799
|
let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
@@ -3053,11 +3123,11 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
3053
3123
|
};
|
|
3054
3124
|
AnisotropyPlugin.PluginType = "AnisotropyPlugin";
|
|
3055
3125
|
AnisotropyPlugin.ANISOTROPY_GLTF_EXTENSION = "WEBGI_materials_anisotropy";
|
|
3056
|
-
__decorateClass$
|
|
3126
|
+
__decorateClass$6([
|
|
3057
3127
|
uiToggle("Enabled", (that) => ({ onChange: that.setDirty })),
|
|
3058
3128
|
serialize()
|
|
3059
3129
|
], AnisotropyPlugin.prototype, "enabled", 2);
|
|
3060
|
-
AnisotropyPlugin = __decorateClass$
|
|
3130
|
+
AnisotropyPlugin = __decorateClass$6([
|
|
3061
3131
|
uiFolderContainer("Anisotropy (MatExt)")
|
|
3062
3132
|
], AnisotropyPlugin);
|
|
3063
3133
|
class GLTFMaterialsAnisotropyExtensionImport {
|
|
@@ -3136,13 +3206,13 @@ const anisotropyGLTFExtension = {
|
|
|
3136
3206
|
};
|
|
3137
3207
|
const poissonDiskSamples = "vec2 poisson_disk_samples[16];void setPds(){poisson_disk_samples[0]=vec2(-0.399691779231,0.728591545584);poisson_disk_samples[1]=vec2(-0.48622557676,-0.84016533712);poisson_disk_samples[2]=vec2(0.770309468987,-0.24906070432);poisson_disk_samples[3]=vec2(0.556596796154,0.820359876432);poisson_disk_samples[4]=vec2(-0.933902004071,0.0600539051593);poisson_disk_samples[5]=vec2(0.330144964342,0.207477293384);poisson_disk_samples[6]=vec2(0.289013230975,-0.686749271417);poisson_disk_samples[7]=vec2(-0.0832470893559,-0.187351643125);poisson_disk_samples[8]=vec2(-0.296314525615,0.254474834305);poisson_disk_samples[9]=vec2(-0.850977666059,0.484642744689);poisson_disk_samples[10]=vec2(0.829287915319,0.2345063545);poisson_disk_samples[11]=vec2(-0.773042143899,-0.543741521254);poisson_disk_samples[12]=vec2(0.0561133030864,0.928419742597);poisson_disk_samples[13]=vec2(-0.205799249508,-0.562072714492);poisson_disk_samples[14]=vec2(-0.526991665882,-0.193690188118);poisson_disk_samples[15]=vec2(-0.051789270667,-0.935374050821);}";
|
|
3138
3208
|
const reflectorSample = "\n#include <randomHelpers>\n#ifndef D_sceneBoundingRadius\n#define D_sceneBoundingRadius\nuniform float sceneBoundingRadius;\n#endif\n#ifndef D_frameCount\n#define D_frameCount\nuniform float frameCount;\n#endif\nvarying vec4 vRefUv;uniform sampler2D tRefDiffuse;uniform vec2 tRefDiffuseSize;float getSpecularMIPLevel(const in float roughness,const in float maxMIPLevel){float sigma=PI*roughness*roughness/(1.0+roughness);float desiredMIPLevel=maxMIPLevel+log2(sigma);return clamp(desiredMIPLevel,0.0,maxMIPLevel);}vec4 getReflectionColor(const in float roughness,const in float depthModifier){float mip=getSpecularMIPLevel(roughness+depthModifier,4.0);vec4 color=texture2D(tRefDiffuse,vRefUv.xy/vRefUv.w,mip);float blurDist=saturate(2.0/(1.+pow(abs(vViewPosition.z),0.25)))*roughness*64.*color.a;float rnd=PI2*interleavedGradientNoise(vUv.xy,frameCount);vec4 rotationMatrix=vec4(cos(rnd),-sin(rnd),0.,0.);rotationMatrix.z=-rotationMatrix.y;rotationMatrix.w=rotationMatrix.x;vec3 colorSum=color.rgb*color.a;float weightSum=0.001+color.a;vec2 ofs;setPds();\n#pragma unroll_loop_start\nfor(int i=0;i<16;i++){ofs=poisson_disk_samples[UNROLLED_LOOP_INDEX];ofs=vec2(dot(ofs,rotationMatrix.xy),dot(ofs,rotationMatrix.zw));ofs=vRefUv.xy+vRefUv.w*blurDist*ofs/tRefDiffuseSize.xy;color=texture2D(tRefDiffuse,ofs/vRefUv.w,mip);colorSum+=color.rgb*color.a;weightSum+=color.a;}\n#pragma unroll_loop_end\nreturn vec4(colorSum/weightSum,1.0);}";
|
|
3139
|
-
var __defProp$
|
|
3140
|
-
var __decorateClass$
|
|
3209
|
+
var __defProp$5 = Object.defineProperty;
|
|
3210
|
+
var __decorateClass$5 = (decorators, target, key, kind) => {
|
|
3141
3211
|
var result = void 0;
|
|
3142
3212
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
3143
3213
|
if (decorator = decorators[i2])
|
|
3144
3214
|
result = decorator(target, key, result) || result;
|
|
3145
|
-
if (result) __defProp$
|
|
3215
|
+
if (result) __defProp$5(target, key, result);
|
|
3146
3216
|
return result;
|
|
3147
3217
|
};
|
|
3148
3218
|
const _Reflector2 = class _Reflector22 extends Mesh2 {
|
|
@@ -3360,10 +3430,10 @@ const _Reflector2 = class _Reflector22 extends Mesh2 {
|
|
|
3360
3430
|
return this._renderTarget;
|
|
3361
3431
|
}
|
|
3362
3432
|
};
|
|
3363
|
-
__decorateClass$
|
|
3433
|
+
__decorateClass$5([
|
|
3364
3434
|
onChange(_Reflector2.prototype._updateExtension)
|
|
3365
3435
|
], _Reflector2.prototype, "enabled");
|
|
3366
|
-
__decorateClass$
|
|
3436
|
+
__decorateClass$5([
|
|
3367
3437
|
onChange(_Reflector2.prototype._updateExtension)
|
|
3368
3438
|
], _Reflector2.prototype, "reflectorModePhysical");
|
|
3369
3439
|
let Reflector2 = _Reflector2;
|
|
@@ -3437,13 +3507,13 @@ class a {
|
|
|
3437
3507
|
return { next: () => Math.random() };
|
|
3438
3508
|
}
|
|
3439
3509
|
}
|
|
3440
|
-
var __defProp$
|
|
3441
|
-
var __decorateClass$
|
|
3510
|
+
var __defProp$4 = Object.defineProperty;
|
|
3511
|
+
var __decorateClass$4 = (decorators, target, key, kind) => {
|
|
3442
3512
|
var result = void 0;
|
|
3443
3513
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
3444
3514
|
if (decorator = decorators[i2])
|
|
3445
3515
|
result = decorator(target, key, result) || result;
|
|
3446
|
-
if (result) __defProp$
|
|
3516
|
+
if (result) __defProp$4(target, key, result);
|
|
3447
3517
|
return result;
|
|
3448
3518
|
};
|
|
3449
3519
|
class RandomizedDirectionalLight extends DirectionalLight2 {
|
|
@@ -3598,10 +3668,10 @@ class RandomizedDirectionalLight extends DirectionalLight2 {
|
|
|
3598
3668
|
// this.updateMatrixWorld()
|
|
3599
3669
|
// }
|
|
3600
3670
|
}
|
|
3601
|
-
__decorateClass$
|
|
3671
|
+
__decorateClass$4([
|
|
3602
3672
|
serialize("shadowParams")
|
|
3603
3673
|
], RandomizedDirectionalLight.prototype, "_shadowParams");
|
|
3604
|
-
__decorateClass$
|
|
3674
|
+
__decorateClass$4([
|
|
3605
3675
|
serialize("randomParams")
|
|
3606
3676
|
], RandomizedDirectionalLight.prototype, "_randomParams");
|
|
3607
3677
|
function getSample(rand, dir, extent) {
|
|
@@ -3614,13 +3684,13 @@ function getSample(rand, dir, extent) {
|
|
|
3614
3684
|
const oneminus = Math.sqrt(1 - r2.y * r2.y);
|
|
3615
3685
|
return o1.multiplyScalar(Math.cos(r2.x) * oneminus).add(o2.multiplyScalar(Math.sin(r2.x) * oneminus)).add(dir.multiplyScalar(r2.y));
|
|
3616
3686
|
}
|
|
3617
|
-
var __defProp$
|
|
3618
|
-
var __decorateClass$
|
|
3687
|
+
var __defProp$3 = Object.defineProperty;
|
|
3688
|
+
var __decorateClass$3 = (decorators, target, key, kind) => {
|
|
3619
3689
|
var result = void 0;
|
|
3620
3690
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
3621
3691
|
if (decorator = decorators[i2])
|
|
3622
3692
|
result = decorator(target, key, result) || result;
|
|
3623
|
-
if (result) __defProp$
|
|
3693
|
+
if (result) __defProp$3(target, key, result);
|
|
3624
3694
|
return result;
|
|
3625
3695
|
};
|
|
3626
3696
|
class FSShadowMaterial extends ShadowMaterial {
|
|
@@ -3680,17 +3750,17 @@ gl_FragColor = packDepthToRGBA(mix(last, shadow, opacity));
|
|
|
3680
3750
|
this.dispatchEvent({ ...options, type: "materialUpdate" });
|
|
3681
3751
|
}
|
|
3682
3752
|
}
|
|
3683
|
-
__decorateClass$
|
|
3753
|
+
__decorateClass$3([
|
|
3684
3754
|
uniform({ propKey: "tLastThis" })
|
|
3685
3755
|
], FSShadowMaterial.prototype, "lastFrameTexture");
|
|
3686
3756
|
const seperableShadowBlur = "#include <packing>\nuniform sampler2D colorTexture;uniform vec2 size;uniform vec2 direction;uniform float step;varying vec2 vUv;void main(){float sum=0.0;vec2 uvDelta=step*direction/size;sum+=unpackRGBAToDepth(texture2D(colorTexture,vUv-1.*uvDelta))*0.3333;sum+=unpackRGBAToDepth(texture2D(colorTexture,vec2(vUv.x,vUv.y)))*0.3333;sum+=unpackRGBAToDepth(texture2D(colorTexture,vUv+1.*uvDelta))*0.3333;gl_FragColor=packDepthToRGBA(sum);}";
|
|
3687
|
-
var __defProp$
|
|
3688
|
-
var __decorateClass$
|
|
3757
|
+
var __defProp$2 = Object.defineProperty;
|
|
3758
|
+
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
3689
3759
|
var result = void 0;
|
|
3690
3760
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
3691
3761
|
if (decorator = decorators[i2])
|
|
3692
3762
|
result = decorator(target, key, result) || result;
|
|
3693
|
-
if (result) __defProp$
|
|
3763
|
+
if (result) __defProp$2(target, key, result);
|
|
3694
3764
|
return result;
|
|
3695
3765
|
};
|
|
3696
3766
|
const _ShadowMapBaker = class _ShadowMapBaker2 extends SimpleEventDispatcher {
|
|
@@ -4081,44 +4151,44 @@ const _ShadowMapBaker = class _ShadowMapBaker2 extends SimpleEventDispatcher {
|
|
|
4081
4151
|
// this._viewer.renderManager.renderModel(mesh, this._viewer.scene.activeCamera!)
|
|
4082
4152
|
// }
|
|
4083
4153
|
};
|
|
4084
|
-
__decorateClass$
|
|
4154
|
+
__decorateClass$2([
|
|
4085
4155
|
serialize("randomizedLight")
|
|
4086
4156
|
], _ShadowMapBaker.prototype, "_light");
|
|
4087
|
-
__decorateClass$
|
|
4157
|
+
__decorateClass$2([
|
|
4088
4158
|
onChange(_ShadowMapBaker.prototype.reset),
|
|
4089
4159
|
serialize()
|
|
4090
4160
|
], _ShadowMapBaker.prototype, "maxFrameNumber");
|
|
4091
|
-
__decorateClass$
|
|
4161
|
+
__decorateClass$2([
|
|
4092
4162
|
onChange(_ShadowMapBaker.prototype.reset),
|
|
4093
4163
|
serialize()
|
|
4094
4164
|
], _ShadowMapBaker.prototype, "smoothShadow");
|
|
4095
|
-
__decorateClass$
|
|
4165
|
+
__decorateClass$2([
|
|
4096
4166
|
serialize(),
|
|
4097
4167
|
onChange(_ShadowMapBaker.prototype.reset)
|
|
4098
4168
|
], _ShadowMapBaker.prototype, "shadowMapType");
|
|
4099
|
-
__decorateClass$
|
|
4169
|
+
__decorateClass$2([
|
|
4100
4170
|
onChange(_ShadowMapBaker.prototype._groundMapModeChanged),
|
|
4101
4171
|
serialize()
|
|
4102
4172
|
], _ShadowMapBaker.prototype, "groundMapMode");
|
|
4103
|
-
__decorateClass$
|
|
4173
|
+
__decorateClass$2([
|
|
4104
4174
|
serialize(),
|
|
4105
4175
|
onChange(_ShadowMapBaker.prototype._alphaVignetteChanged)
|
|
4106
4176
|
], _ShadowMapBaker.prototype, "alphaVignette");
|
|
4107
|
-
__decorateClass$
|
|
4177
|
+
__decorateClass$2([
|
|
4108
4178
|
serialize(),
|
|
4109
4179
|
onChange(_ShadowMapBaker.prototype._alphaVignetteChanged)
|
|
4110
4180
|
], _ShadowMapBaker.prototype, "alphaVignetteAxis");
|
|
4111
|
-
__decorateClass$
|
|
4181
|
+
__decorateClass$2([
|
|
4112
4182
|
serialize()
|
|
4113
4183
|
], _ShadowMapBaker.prototype, "maxBakeCount");
|
|
4114
4184
|
let ShadowMapBaker = _ShadowMapBaker;
|
|
4115
|
-
var __defProp = Object.defineProperty;
|
|
4116
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4185
|
+
var __defProp$1 = Object.defineProperty;
|
|
4186
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
4117
4187
|
var result = void 0;
|
|
4118
4188
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
4119
4189
|
if (decorator = decorators[i2])
|
|
4120
4190
|
result = decorator(target, key, result) || result;
|
|
4121
|
-
if (result) __defProp(target, key, result);
|
|
4191
|
+
if (result) __defProp$1(target, key, result);
|
|
4122
4192
|
return result;
|
|
4123
4193
|
};
|
|
4124
4194
|
const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
@@ -4248,6 +4318,7 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4248
4318
|
super.refresh();
|
|
4249
4319
|
}
|
|
4250
4320
|
_refreshTransform() {
|
|
4321
|
+
if (!super._refreshTransform()) return false;
|
|
4251
4322
|
if (this.autoFrustumSize) {
|
|
4252
4323
|
const baker = this.shadowBaker;
|
|
4253
4324
|
if (baker) {
|
|
@@ -4259,7 +4330,7 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4259
4330
|
}
|
|
4260
4331
|
}
|
|
4261
4332
|
}
|
|
4262
|
-
|
|
4333
|
+
return true;
|
|
4263
4334
|
}
|
|
4264
4335
|
// see BaseGroundPlugin
|
|
4265
4336
|
fromJSON(data, meta) {
|
|
@@ -4300,7 +4371,7 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4300
4371
|
{
|
|
4301
4372
|
label: "Alpha Vignette",
|
|
4302
4373
|
type: "checkbox",
|
|
4303
|
-
hidden: () => !this._material || this._material.transmission < 1e-4 && !this._material.transparent,
|
|
4374
|
+
hidden: () => !this._material || (this._material.transmission || 0) < 1e-4 && !this._material.transparent,
|
|
4304
4375
|
property: () => [this._shadowBaker, "alphaVignette"],
|
|
4305
4376
|
limitedUi: true,
|
|
4306
4377
|
onChange: () => {
|
|
@@ -4313,7 +4384,7 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4313
4384
|
type: "dropdown",
|
|
4314
4385
|
hidden: () => {
|
|
4315
4386
|
var _a3;
|
|
4316
|
-
return !((_a3 = this._shadowBaker) == null ? void 0 : _a3.alphaVignette) || !this._material || this._material.transmission < 1e-4 && !this._material.transparent;
|
|
4387
|
+
return !((_a3 = this._shadowBaker) == null ? void 0 : _a3.alphaVignette) || !this._material || (this._material.transmission || 0) < 1e-4 && !this._material.transparent;
|
|
4317
4388
|
},
|
|
4318
4389
|
property: () => [this._shadowBaker, "alphaVignetteAxis"],
|
|
4319
4390
|
children: ["x", "y", "xy"].map((v) => ({ label: v, value: v })),
|
|
@@ -4448,30 +4519,190 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4448
4519
|
];
|
|
4449
4520
|
}
|
|
4450
4521
|
}, _b.PluginType = "AdvancedGroundPlugin", _b);
|
|
4451
|
-
__decorateClass([
|
|
4522
|
+
__decorateClass$1([
|
|
4452
4523
|
onChange(_AdvancedGroundPlugin.prototype._refresh3),
|
|
4453
4524
|
uiToggle("Baked Shadows"),
|
|
4454
4525
|
serialize()
|
|
4455
4526
|
], _AdvancedGroundPlugin.prototype, "bakedShadows");
|
|
4456
|
-
__decorateClass([
|
|
4527
|
+
__decorateClass$1([
|
|
4457
4528
|
onChange(_AdvancedGroundPlugin.prototype._refresh3),
|
|
4458
4529
|
uiToggle("Planar Reflections"),
|
|
4459
4530
|
serialize()
|
|
4460
4531
|
], _AdvancedGroundPlugin.prototype, "groundReflection");
|
|
4461
|
-
__decorateClass([
|
|
4532
|
+
__decorateClass$1([
|
|
4462
4533
|
onChange(_AdvancedGroundPlugin.prototype._refresh3),
|
|
4463
4534
|
uiToggle("Physical Reflections"),
|
|
4464
4535
|
serialize()
|
|
4465
4536
|
], _AdvancedGroundPlugin.prototype, "physicalReflections");
|
|
4466
|
-
__decorateClass([
|
|
4537
|
+
__decorateClass$1([
|
|
4467
4538
|
onChange(_AdvancedGroundPlugin.prototype._refresh3),
|
|
4468
4539
|
uiToggle("Auto Shadow Frustum Size"),
|
|
4469
4540
|
serialize()
|
|
4470
4541
|
], _AdvancedGroundPlugin.prototype, "autoFrustumSize");
|
|
4471
|
-
__decorateClass([
|
|
4542
|
+
__decorateClass$1([
|
|
4472
4543
|
serialize("shadowBaker")
|
|
4473
4544
|
], _AdvancedGroundPlugin.prototype, "_shadowBaker");
|
|
4545
|
+
__decorateClass$1([
|
|
4546
|
+
bindToValue({ key: "groundReflection" })
|
|
4547
|
+
], _AdvancedGroundPlugin.prototype, "planarReflections");
|
|
4474
4548
|
let AdvancedGroundPlugin = _AdvancedGroundPlugin;
|
|
4549
|
+
var __defProp = Object.defineProperty;
|
|
4550
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4551
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4552
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
4553
|
+
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
4554
|
+
if (decorator = decorators[i2])
|
|
4555
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
4556
|
+
if (kind && result) __defProp(target, key, result);
|
|
4557
|
+
return result;
|
|
4558
|
+
};
|
|
4559
|
+
let WatchHandsPlugin = class extends AViewerPluginSync {
|
|
4560
|
+
constructor() {
|
|
4561
|
+
super(...arguments);
|
|
4562
|
+
this.enabled = true;
|
|
4563
|
+
this.dependencies = [];
|
|
4564
|
+
this.axis = "y";
|
|
4565
|
+
this.invertAxis = false;
|
|
4566
|
+
this.analog = true;
|
|
4567
|
+
this.hourOffset = 0;
|
|
4568
|
+
this.minuteOffset = 0;
|
|
4569
|
+
this.secondOffset = 0;
|
|
4570
|
+
this.hour = ".*hour.*";
|
|
4571
|
+
this.minute = ".*minute.*";
|
|
4572
|
+
this.second = ".*second.*";
|
|
4573
|
+
this.regex = true;
|
|
4574
|
+
this.hands = [];
|
|
4575
|
+
this._lastEnabled = true;
|
|
4576
|
+
this._preFrame = () => {
|
|
4577
|
+
var _a2, _b2, _c, _d;
|
|
4578
|
+
if (!this.enabled) {
|
|
4579
|
+
if (this._lastEnabled) {
|
|
4580
|
+
this._lastEnabled = false;
|
|
4581
|
+
if (!this.hands.length) return;
|
|
4582
|
+
for (const h of this.hands) {
|
|
4583
|
+
h.object.rotation.fromArray(h.object.userData.initRotation);
|
|
4584
|
+
h.object.updateMatrixWorld();
|
|
4585
|
+
}
|
|
4586
|
+
(_a2 = this._viewer) == null ? void 0 : _a2.renderManager.resetShadows();
|
|
4587
|
+
(_b2 = this._viewer) == null ? void 0 : _b2.setDirty();
|
|
4588
|
+
}
|
|
4589
|
+
return;
|
|
4590
|
+
}
|
|
4591
|
+
this._lastEnabled = true;
|
|
4592
|
+
if (!this.hands.length) return;
|
|
4593
|
+
const time = /* @__PURE__ */ new Date();
|
|
4594
|
+
const invert = this.invertAxis ? -1 : 1;
|
|
4595
|
+
const secondHandRotation = invert * (time.getSeconds() + (this.analog ? time.getMilliseconds() / 1e3 : 0) - this.secondOffset) * (Math.PI * 2) / 60;
|
|
4596
|
+
const minuteHandRotation = invert * (time.getMinutes() - this.minuteOffset) * (Math.PI * 2) / 60 + secondHandRotation / 60;
|
|
4597
|
+
const hourHandRotation = invert * (time.getHours() - this.hourOffset) * (Math.PI * 2) / 12 + minuteHandRotation / 12;
|
|
4598
|
+
if (this.hands.find((h) => h.type === "second" && Math.abs(secondHandRotation - h.object.rotation[this.axis]) > 1e-3)) {
|
|
4599
|
+
for (const hand of this.hands) {
|
|
4600
|
+
if (hand.type === "second") {
|
|
4601
|
+
hand.object.rotation[this.axis] = secondHandRotation;
|
|
4602
|
+
}
|
|
4603
|
+
if (hand.type === "minute") {
|
|
4604
|
+
hand.object.rotation[this.axis] = minuteHandRotation;
|
|
4605
|
+
}
|
|
4606
|
+
if (hand.type === "hour") {
|
|
4607
|
+
hand.object.rotation[this.axis] = hourHandRotation;
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4610
|
+
(_c = this._viewer) == null ? void 0 : _c.renderManager.resetShadows();
|
|
4611
|
+
(_d = this._viewer) == null ? void 0 : _d.setDirty();
|
|
4612
|
+
}
|
|
4613
|
+
};
|
|
4614
|
+
this._addSceneObject = async (e2) => {
|
|
4615
|
+
if (!e2.object) return;
|
|
4616
|
+
this.refresh();
|
|
4617
|
+
};
|
|
4618
|
+
}
|
|
4619
|
+
onAdded(viewer) {
|
|
4620
|
+
super.onAdded(viewer);
|
|
4621
|
+
viewer.scene.addEventListener("addSceneObject", this._addSceneObject);
|
|
4622
|
+
viewer.addEventListener("preFrame", this._preFrame);
|
|
4623
|
+
}
|
|
4624
|
+
onRemove(viewer) {
|
|
4625
|
+
viewer.scene.removeEventListener("addSceneObject", this._addSceneObject);
|
|
4626
|
+
viewer.removeEventListener("preFrame", this._preFrame);
|
|
4627
|
+
super.onRemove(viewer);
|
|
4628
|
+
}
|
|
4629
|
+
refresh() {
|
|
4630
|
+
var _a2;
|
|
4631
|
+
this.hands = [];
|
|
4632
|
+
(_a2 = this._viewer) == null ? void 0 : _a2.scene.modelRoot.traverse((o) => {
|
|
4633
|
+
let isChild = false;
|
|
4634
|
+
o.traverseAncestors((oa) => {
|
|
4635
|
+
if (isChild) return;
|
|
4636
|
+
if (this.hands.find((h) => h.object === oa)) isChild = true;
|
|
4637
|
+
});
|
|
4638
|
+
if (isChild) return;
|
|
4639
|
+
if (o.name.match(this.regex ? new RegExp(this.hour) : this.hour)) {
|
|
4640
|
+
if (!o.userData.initRotation) o.userData.initRotation = o.rotation.toArray();
|
|
4641
|
+
this.hands.push({ type: "hour", object: o });
|
|
4642
|
+
}
|
|
4643
|
+
if (o.name.match(this.regex ? new RegExp(this.minute) : this.minute)) {
|
|
4644
|
+
if (!o.userData.initRotation) o.userData.initRotation = o.rotation.toArray();
|
|
4645
|
+
this.hands.push({ type: "minute", object: o });
|
|
4646
|
+
}
|
|
4647
|
+
if (o.name.match(this.regex ? new RegExp(this.second) : this.second)) {
|
|
4648
|
+
if (!o.userData.initRotation) o.userData.initRotation = o.rotation.toArray();
|
|
4649
|
+
this.hands.push({ type: "second", object: o });
|
|
4650
|
+
}
|
|
4651
|
+
});
|
|
4652
|
+
}
|
|
4653
|
+
};
|
|
4654
|
+
WatchHandsPlugin.PluginType = "WatchHandsPlugin";
|
|
4655
|
+
__decorateClass([
|
|
4656
|
+
uiToggle(),
|
|
4657
|
+
serialize()
|
|
4658
|
+
], WatchHandsPlugin.prototype, "enabled", 2);
|
|
4659
|
+
__decorateClass([
|
|
4660
|
+
uiDropdown(void 0, ["x", "y", "z"].map((label) => ({ label }))),
|
|
4661
|
+
serialize()
|
|
4662
|
+
], WatchHandsPlugin.prototype, "axis", 2);
|
|
4663
|
+
__decorateClass([
|
|
4664
|
+
uiToggle(),
|
|
4665
|
+
serialize()
|
|
4666
|
+
], WatchHandsPlugin.prototype, "invertAxis", 2);
|
|
4667
|
+
__decorateClass([
|
|
4668
|
+
uiToggle(),
|
|
4669
|
+
serialize()
|
|
4670
|
+
], WatchHandsPlugin.prototype, "analog", 2);
|
|
4671
|
+
__decorateClass([
|
|
4672
|
+
uiSlider(void 0, [0, 12], 1e-3),
|
|
4673
|
+
serialize()
|
|
4674
|
+
], WatchHandsPlugin.prototype, "hourOffset", 2);
|
|
4675
|
+
__decorateClass([
|
|
4676
|
+
uiSlider(void 0, [0, 60], 1e-3),
|
|
4677
|
+
serialize()
|
|
4678
|
+
], WatchHandsPlugin.prototype, "minuteOffset", 2);
|
|
4679
|
+
__decorateClass([
|
|
4680
|
+
uiSlider(void 0, [0, 60], 1e-3),
|
|
4681
|
+
serialize()
|
|
4682
|
+
], WatchHandsPlugin.prototype, "secondOffset", 2);
|
|
4683
|
+
__decorateClass([
|
|
4684
|
+
uiInput(),
|
|
4685
|
+
serialize()
|
|
4686
|
+
], WatchHandsPlugin.prototype, "hour", 2);
|
|
4687
|
+
__decorateClass([
|
|
4688
|
+
uiInput(),
|
|
4689
|
+
serialize()
|
|
4690
|
+
], WatchHandsPlugin.prototype, "minute", 2);
|
|
4691
|
+
__decorateClass([
|
|
4692
|
+
uiInput(),
|
|
4693
|
+
serialize()
|
|
4694
|
+
], WatchHandsPlugin.prototype, "second", 2);
|
|
4695
|
+
__decorateClass([
|
|
4696
|
+
uiToggle(),
|
|
4697
|
+
onChange("refresh"),
|
|
4698
|
+
serialize()
|
|
4699
|
+
], WatchHandsPlugin.prototype, "regex", 2);
|
|
4700
|
+
__decorateClass([
|
|
4701
|
+
uiButton()
|
|
4702
|
+
], WatchHandsPlugin.prototype, "refresh", 1);
|
|
4703
|
+
WatchHandsPlugin = __decorateClass([
|
|
4704
|
+
uiFolderContainer("Watch Hands Time")
|
|
4705
|
+
], WatchHandsPlugin);
|
|
4475
4706
|
const webgiPlugins = [
|
|
4476
4707
|
TemporalAAPlugin,
|
|
4477
4708
|
VelocityBufferPlugin,
|
|
@@ -4482,7 +4713,8 @@ const webgiPlugins = [
|
|
|
4482
4713
|
OutlinePlugin,
|
|
4483
4714
|
SSGIPlugin,
|
|
4484
4715
|
AnisotropyPlugin,
|
|
4485
|
-
AdvancedGroundPlugin
|
|
4716
|
+
AdvancedGroundPlugin,
|
|
4717
|
+
WatchHandsPlugin
|
|
4486
4718
|
];
|
|
4487
4719
|
export {
|
|
4488
4720
|
AdvancedGroundPlugin,
|
|
@@ -4502,6 +4734,7 @@ export {
|
|
|
4502
4734
|
TemporalAAPlugin,
|
|
4503
4735
|
TemporalAAPluginPass,
|
|
4504
4736
|
VelocityBufferPlugin,
|
|
4737
|
+
WatchHandsPlugin,
|
|
4505
4738
|
anisotropyGLTFExtension,
|
|
4506
4739
|
webgiPlugins
|
|
4507
4740
|
};
|