@threepipe/webgi-plugins 0.5.1 → 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 +14 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +452 -211
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/buffer/VelocityBufferPlugin.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
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,10 +391,10 @@ let VelocityBufferPlugin = class extends PipelinePassPlugin {
|
|
|
373
391
|
};
|
|
374
392
|
VelocityBufferPlugin.PluginType = "VelocityBuffer";
|
|
375
393
|
VelocityBufferPlugin.OldPluginType = "VelocityBufferPlugin";
|
|
376
|
-
__decorateClass$
|
|
394
|
+
__decorateClass$e([
|
|
377
395
|
uiImage("Velocity Buffer", { readOnly: true })
|
|
378
396
|
], VelocityBufferPlugin.prototype, "texture", 2);
|
|
379
|
-
VelocityBufferPlugin = __decorateClass$
|
|
397
|
+
VelocityBufferPlugin = __decorateClass$e([
|
|
380
398
|
uiFolderContainer("Velocity Buffer Plugin (for TAA)")
|
|
381
399
|
], VelocityBufferPlugin);
|
|
382
400
|
class SSVelocityMaterial extends ShaderMaterial {
|
|
@@ -431,14 +449,14 @@ class SSVelocityMaterial extends ShaderMaterial {
|
|
|
431
449
|
}
|
|
432
450
|
}
|
|
433
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}";
|
|
434
|
-
var __defProp$
|
|
435
|
-
var __getOwnPropDesc$
|
|
436
|
-
var __decorateClass$
|
|
437
|
-
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;
|
|
438
456
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
439
457
|
if (decorator = decorators[i2])
|
|
440
458
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
441
|
-
if (kind && result) __defProp$
|
|
459
|
+
if (kind && result) __defProp$d(target, key, result);
|
|
442
460
|
return result;
|
|
443
461
|
};
|
|
444
462
|
const passId$3 = "bloom";
|
|
@@ -540,7 +558,7 @@ const _BloomPlugin = (_a = class extends PipelinePassPlugin {
|
|
|
540
558
|
return config;
|
|
541
559
|
}
|
|
542
560
|
}, _a.PluginType = "Bloom", _a.OldPluginType = "BloomPlugin", _a);
|
|
543
|
-
__decorateClass$
|
|
561
|
+
__decorateClass$d([
|
|
544
562
|
uiConfig()
|
|
545
563
|
], _BloomPlugin.prototype, "_pass", 2);
|
|
546
564
|
let BloomPlugin = _BloomPlugin;
|
|
@@ -688,48 +706,48 @@ let BloomPluginPass = class extends ExtendedShaderPass {
|
|
|
688
706
|
if (setDirty !== false) this.setDirty();
|
|
689
707
|
}
|
|
690
708
|
};
|
|
691
|
-
__decorateClass$
|
|
709
|
+
__decorateClass$d([
|
|
692
710
|
uniform()
|
|
693
711
|
], BloomPluginPass.prototype, "prefilter", 2);
|
|
694
|
-
__decorateClass$
|
|
712
|
+
__decorateClass$d([
|
|
695
713
|
uiSlider("Threshold", [0, 2]),
|
|
696
714
|
onChange(BloomPluginPass.prototype._thresholdsUpdated),
|
|
697
715
|
serialize()
|
|
698
716
|
], BloomPluginPass.prototype, "threshold", 2);
|
|
699
|
-
__decorateClass$
|
|
717
|
+
__decorateClass$d([
|
|
700
718
|
uiSlider("Soft Threshold", [0, 1]),
|
|
701
719
|
onChange(BloomPluginPass.prototype._thresholdsUpdated),
|
|
702
720
|
serialize()
|
|
703
721
|
], BloomPluginPass.prototype, "softThreshold", 2);
|
|
704
|
-
__decorateClass$
|
|
722
|
+
__decorateClass$d([
|
|
705
723
|
uiSlider("Intensity", [0, 3]),
|
|
706
724
|
serialize(),
|
|
707
725
|
uniform()
|
|
708
726
|
], BloomPluginPass.prototype, "intensity", 2);
|
|
709
|
-
__decorateClass$
|
|
727
|
+
__decorateClass$d([
|
|
710
728
|
uiToggle("Background Bloom"),
|
|
711
729
|
serialize(),
|
|
712
730
|
matDefineBool("BACKGROUND_BLOOM")
|
|
713
731
|
], BloomPluginPass.prototype, "backgroundBloom", 2);
|
|
714
|
-
__decorateClass$
|
|
732
|
+
__decorateClass$d([
|
|
715
733
|
uiSlider("Iterations", [2, 7], 1),
|
|
716
734
|
onChange2(BloomPluginPass.prototype._updateWeights),
|
|
717
735
|
serialize()
|
|
718
736
|
], BloomPluginPass.prototype, "bloomIterations", 2);
|
|
719
|
-
__decorateClass$
|
|
737
|
+
__decorateClass$d([
|
|
720
738
|
uiSlider("Radius", [0, 1], 0.01),
|
|
721
739
|
onChange2(BloomPluginPass.prototype._updateWeights),
|
|
722
740
|
serialize()
|
|
723
741
|
], BloomPluginPass.prototype, "radius", 2);
|
|
724
|
-
__decorateClass$
|
|
742
|
+
__decorateClass$d([
|
|
725
743
|
uiSlider("Power", [0.2, 10], 0.01),
|
|
726
744
|
onChange2(BloomPluginPass.prototype._updateWeights),
|
|
727
745
|
serialize()
|
|
728
746
|
], BloomPluginPass.prototype, "power", 2);
|
|
729
|
-
__decorateClass$
|
|
747
|
+
__decorateClass$d([
|
|
730
748
|
uiToggle("Debug")
|
|
731
749
|
], BloomPluginPass.prototype, "bloomDebug", 2);
|
|
732
|
-
BloomPluginPass = __decorateClass$
|
|
750
|
+
BloomPluginPass = __decorateClass$d([
|
|
733
751
|
uiFolderContainer("Bloom Pass")
|
|
734
752
|
], BloomPluginPass);
|
|
735
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}";
|
|
@@ -737,14 +755,14 @@ const dofPoissonBox = "#include <randomHelpers>\n#include <common>\nvarying vec2
|
|
|
737
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);}";
|
|
738
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}";
|
|
739
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}";
|
|
740
|
-
var __defProp$
|
|
741
|
-
var __getOwnPropDesc$
|
|
742
|
-
var __decorateClass$
|
|
743
|
-
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;
|
|
744
762
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
745
763
|
if (decorator = decorators[i2])
|
|
746
764
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
747
|
-
if (kind && result) __defProp$
|
|
765
|
+
if (kind && result) __defProp$c(target, key, result);
|
|
748
766
|
return result;
|
|
749
767
|
};
|
|
750
768
|
const passId$2 = "depthOfField";
|
|
@@ -957,14 +975,14 @@ const _DepthOfFieldPlugin = class _DepthOfFieldPlugin extends PipelinePassPlugin
|
|
|
957
975
|
_DepthOfFieldPlugin.PluginType = "DepthOfField";
|
|
958
976
|
_DepthOfFieldPlugin.OldPluginType = "DepthOfFieldPlugin";
|
|
959
977
|
let DepthOfFieldPlugin = _DepthOfFieldPlugin;
|
|
960
|
-
__decorateClass$
|
|
978
|
+
__decorateClass$c([
|
|
961
979
|
serialize(),
|
|
962
980
|
uiToggle()
|
|
963
981
|
], DepthOfFieldPlugin.prototype, "enableEdit", 2);
|
|
964
|
-
__decorateClass$
|
|
982
|
+
__decorateClass$c([
|
|
965
983
|
serialize("focalPoint")
|
|
966
984
|
], DepthOfFieldPlugin.prototype, "_focalPointHit", 2);
|
|
967
|
-
__decorateClass$
|
|
985
|
+
__decorateClass$c([
|
|
968
986
|
serialize()
|
|
969
987
|
], DepthOfFieldPlugin.prototype, "crossFadeTime", 2);
|
|
970
988
|
const dofBlurMaterialPoisson = new ExtendedShaderMaterial({
|
|
@@ -1079,50 +1097,50 @@ let DepthOfFieldPluginPass = class extends ExtendedShaderPass {
|
|
|
1079
1097
|
renderManager.releaseTempTarget(renderTargetBlurTemp);
|
|
1080
1098
|
}
|
|
1081
1099
|
};
|
|
1082
|
-
__decorateClass$
|
|
1100
|
+
__decorateClass$c([
|
|
1083
1101
|
bindToValue({ obj: "focalDepthRange", key: "y" }),
|
|
1084
1102
|
uiSlider("Depth Range", [0.25, 3])
|
|
1085
1103
|
], DepthOfFieldPluginPass.prototype, "depthRange", 2);
|
|
1086
|
-
__decorateClass$
|
|
1104
|
+
__decorateClass$c([
|
|
1087
1105
|
bindToValue({ obj: "nearFarBlurScale", key: "x" }),
|
|
1088
1106
|
uiSlider("Near Blur Scale", [0, 1])
|
|
1089
1107
|
], DepthOfFieldPluginPass.prototype, "nearBlurScale", 2);
|
|
1090
|
-
__decorateClass$
|
|
1108
|
+
__decorateClass$c([
|
|
1091
1109
|
bindToValue({ obj: "nearFarBlurScale", key: "y" }),
|
|
1092
1110
|
uiSlider("Far Blur Scale", [0, 1])
|
|
1093
1111
|
], DepthOfFieldPluginPass.prototype, "farBlurScale", 2);
|
|
1094
|
-
__decorateClass$
|
|
1112
|
+
__decorateClass$c([
|
|
1095
1113
|
serialize(),
|
|
1096
1114
|
uniform()
|
|
1097
1115
|
], DepthOfFieldPluginPass.prototype, "nearFarBlurScale", 2);
|
|
1098
|
-
__decorateClass$
|
|
1116
|
+
__decorateClass$c([
|
|
1099
1117
|
serialize(),
|
|
1100
1118
|
uniform()
|
|
1101
1119
|
], DepthOfFieldPluginPass.prototype, "focalDepthRange", 2);
|
|
1102
|
-
__decorateClass$
|
|
1120
|
+
__decorateClass$c([
|
|
1103
1121
|
uniform()
|
|
1104
1122
|
], DepthOfFieldPluginPass.prototype, "crossCenter", 2);
|
|
1105
|
-
__decorateClass$
|
|
1123
|
+
__decorateClass$c([
|
|
1106
1124
|
uniform()
|
|
1107
1125
|
], DepthOfFieldPluginPass.prototype, "crossRadius", 2);
|
|
1108
|
-
__decorateClass$
|
|
1126
|
+
__decorateClass$c([
|
|
1109
1127
|
uniform()
|
|
1110
1128
|
], DepthOfFieldPluginPass.prototype, "crossAlpha", 2);
|
|
1111
|
-
__decorateClass$
|
|
1129
|
+
__decorateClass$c([
|
|
1112
1130
|
uniform()
|
|
1113
1131
|
], DepthOfFieldPluginPass.prototype, "crossColor", 2);
|
|
1114
|
-
DepthOfFieldPluginPass = __decorateClass$
|
|
1132
|
+
DepthOfFieldPluginPass = __decorateClass$c([
|
|
1115
1133
|
uiFolderContainer("DepthOfField Pass")
|
|
1116
1134
|
], DepthOfFieldPluginPass);
|
|
1117
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";
|
|
1118
|
-
var __defProp$
|
|
1119
|
-
var __getOwnPropDesc$
|
|
1120
|
-
var __decorateClass$
|
|
1121
|
-
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;
|
|
1122
1140
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
1123
1141
|
if (decorator = decorators[i2])
|
|
1124
1142
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1125
|
-
if (kind && result) __defProp$
|
|
1143
|
+
if (kind && result) __defProp$b(target, key, result);
|
|
1126
1144
|
return result;
|
|
1127
1145
|
};
|
|
1128
1146
|
let SSContactShadowsPlugin = class extends AViewerPluginSync {
|
|
@@ -1335,51 +1353,50 @@ let SSContactShadowsPlugin = class extends AViewerPluginSync {
|
|
|
1335
1353
|
};
|
|
1336
1354
|
SSContactShadowsPlugin.PluginType = "SSContactShadows";
|
|
1337
1355
|
SSContactShadowsPlugin.OldPluginType = "SSContactShadowsPlugin";
|
|
1338
|
-
__decorateClass$
|
|
1356
|
+
__decorateClass$b([
|
|
1339
1357
|
uiToggle("Enabled"),
|
|
1340
1358
|
serialize(),
|
|
1341
1359
|
onChange(SSContactShadowsPlugin.prototype.setDirty)
|
|
1342
1360
|
], SSContactShadowsPlugin.prototype, "enabled", 2);
|
|
1343
|
-
__decorateClass$
|
|
1361
|
+
__decorateClass$b([
|
|
1344
1362
|
uniform({ propKey: "sscsRadius", onChange: SSContactShadowsPlugin.prototype.setDirty }),
|
|
1345
1363
|
uiSlider("Radius", [1e-4, 0.1], 1e-4),
|
|
1346
1364
|
serialize()
|
|
1347
1365
|
], SSContactShadowsPlugin.prototype, "radius", 2);
|
|
1348
|
-
__decorateClass$
|
|
1366
|
+
__decorateClass$b([
|
|
1349
1367
|
uniform({ propKey: "sscsIntensity", onChange: SSContactShadowsPlugin.prototype.setDirty }),
|
|
1350
1368
|
uiSlider("Intensity", [1e-4, 1], 1e-4),
|
|
1351
1369
|
serialize()
|
|
1352
1370
|
], SSContactShadowsPlugin.prototype, "intensity", 2);
|
|
1353
|
-
__decorateClass$
|
|
1371
|
+
__decorateClass$b([
|
|
1354
1372
|
uniform({ propKey: "sscsTolerance", onChange: SSContactShadowsPlugin.prototype.setDirty }),
|
|
1355
1373
|
uiSlider("Tolerance", [0.1, 5]),
|
|
1356
1374
|
serialize()
|
|
1357
1375
|
], SSContactShadowsPlugin.prototype, "tolerance", 2);
|
|
1358
|
-
__decorateClass$
|
|
1376
|
+
__decorateClass$b([
|
|
1359
1377
|
matDefine("SSCS_DEBUG", void 0, true, SSContactShadowsPlugin.prototype.setDirty),
|
|
1360
1378
|
uiToggle("Debug only SSCS"),
|
|
1361
1379
|
serialize()
|
|
1362
1380
|
], SSContactShadowsPlugin.prototype, "onlySSCSDebug", 2);
|
|
1363
|
-
__decorateClass$
|
|
1381
|
+
__decorateClass$b([
|
|
1364
1382
|
matDefine("SSCS_STEP_COUNT", void 0, true, SSContactShadowsPlugin.prototype.setDirty),
|
|
1365
1383
|
uiSlider("Step count", [1, 8], 1),
|
|
1366
1384
|
serialize()
|
|
1367
1385
|
], SSContactShadowsPlugin.prototype, "stepCount", 2);
|
|
1368
|
-
SSContactShadowsPlugin = __decorateClass$
|
|
1386
|
+
SSContactShadowsPlugin = __decorateClass$b([
|
|
1369
1387
|
uiFolderContainer("SS Contact Shadows")
|
|
1370
1388
|
], SSContactShadowsPlugin);
|
|
1371
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;}";
|
|
1372
|
-
const
|
|
1373
|
-
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";
|
|
1374
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}";
|
|
1375
|
-
var __defProp$
|
|
1376
|
-
var __getOwnPropDesc$
|
|
1377
|
-
var __decorateClass$
|
|
1378
|
-
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;
|
|
1379
1396
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
1380
1397
|
if (decorator = decorators[i2])
|
|
1381
1398
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1382
|
-
if (kind && result) __defProp$
|
|
1399
|
+
if (kind && result) __defProp$a(target, key, result);
|
|
1383
1400
|
return result;
|
|
1384
1401
|
};
|
|
1385
1402
|
const passId$1 = "ssrefl";
|
|
@@ -1400,6 +1417,20 @@ let SSReflectionPlugin = class extends PipelinePassPlugin {
|
|
|
1400
1417
|
if (this._gbufferUnpackExtension) this._pass.setGBufferUnpackExtension(this._gbufferUnpackExtension);
|
|
1401
1418
|
else this._viewer.console.warn("SSReflectionPlugin: GBuffer unpack extension removed");
|
|
1402
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
|
+
};
|
|
1403
1434
|
this.enabled = enabled;
|
|
1404
1435
|
this.bufferType = bufferType;
|
|
1405
1436
|
this.sizeMultiplier = sizeMultiplier;
|
|
@@ -1443,6 +1474,13 @@ let SSReflectionPlugin = class extends PipelinePassPlugin {
|
|
|
1443
1474
|
if (viewer.getPlugin("Ground") || viewer.getPlugin("BaseGroundPlugin")) console.error("GroundPlugin must be added after SSReflectionPlugin");
|
|
1444
1475
|
this._gbufferUnpackExtensionChanged();
|
|
1445
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
|
+
});
|
|
1446
1484
|
}
|
|
1447
1485
|
onRemove(viewer) {
|
|
1448
1486
|
this._disposeTarget();
|
|
@@ -1478,13 +1516,13 @@ let SSReflectionPlugin = class extends PipelinePassPlugin {
|
|
|
1478
1516
|
};
|
|
1479
1517
|
SSReflectionPlugin.PluginType = "SSReflectionPlugin";
|
|
1480
1518
|
SSReflectionPlugin.OldPluginType = "SSReflection";
|
|
1481
|
-
__decorateClass$
|
|
1519
|
+
__decorateClass$a([
|
|
1482
1520
|
uiImage("SSReflection Buffer", { readOnly: true, hideOnEmpty: true })
|
|
1483
1521
|
], SSReflectionPlugin.prototype, "texture", 2);
|
|
1484
|
-
__decorateClass$
|
|
1522
|
+
__decorateClass$a([
|
|
1485
1523
|
uiConfig()
|
|
1486
1524
|
], SSReflectionPlugin.prototype, "_pass", 2);
|
|
1487
|
-
SSReflectionPlugin = __decorateClass$
|
|
1525
|
+
SSReflectionPlugin = __decorateClass$a([
|
|
1488
1526
|
uiFolderContainer("SSReflection Plugin")
|
|
1489
1527
|
], SSReflectionPlugin);
|
|
1490
1528
|
let SSReflectionPluginPass = class extends ExtendedShaderPass {
|
|
@@ -1531,8 +1569,14 @@ let SSReflectionPluginPass = class extends ExtendedShaderPass {
|
|
|
1531
1569
|
maskFrontFactor: { value: -0.1 },
|
|
1532
1570
|
tolerance: { value: 0 },
|
|
1533
1571
|
ssrRoughnessFactor: { value: 1 },
|
|
1534
|
-
sceneBoundingRadius: { value: 0 }
|
|
1572
|
+
sceneBoundingRadius: { value: 0 },
|
|
1535
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 }
|
|
1536
1580
|
},
|
|
1537
1581
|
vertexShader: shaderUtils.defaultVertex,
|
|
1538
1582
|
fragmentShader: `
|
|
@@ -1547,7 +1591,7 @@ ${samplePointHelpers}
|
|
|
1547
1591
|
|
|
1548
1592
|
${ssrtShader}
|
|
1549
1593
|
|
|
1550
|
-
${
|
|
1594
|
+
${getShaders().ssReflection}
|
|
1551
1595
|
|
|
1552
1596
|
${ssrShaderMain}
|
|
1553
1597
|
`
|
|
@@ -1570,6 +1614,7 @@ ${ssrShaderMain}
|
|
|
1570
1614
|
this.lowQualityFrames = 0;
|
|
1571
1615
|
this.maskFrontRays = true;
|
|
1572
1616
|
this.maskFrontFactor = -0.2;
|
|
1617
|
+
this.split = 0;
|
|
1573
1618
|
this.materialExtension = {
|
|
1574
1619
|
extraUniforms: {
|
|
1575
1620
|
tSSReflMap: () => {
|
|
@@ -1614,7 +1659,7 @@ ${ssrShaderMain}
|
|
|
1614
1659
|
},
|
|
1615
1660
|
onObjectRender: (_object, material, renderer) => {
|
|
1616
1661
|
var _a2, _b2, _c;
|
|
1617
|
-
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;
|
|
1618
1663
|
if (material.defines.SSREFL_ENABLED !== x) {
|
|
1619
1664
|
material.defines.SSREFL_ENABLED = x;
|
|
1620
1665
|
material.needsUpdate = true;
|
|
@@ -1643,7 +1688,7 @@ ${ssrShaderMain}
|
|
|
1643
1688
|
#include <randomHelpers>
|
|
1644
1689
|
${samplePointHelpers}
|
|
1645
1690
|
${ssrtShader}
|
|
1646
|
-
${
|
|
1691
|
+
${getShaders().ssReflection}
|
|
1647
1692
|
`}
|
|
1648
1693
|
#include <simpleCameraHelpers>
|
|
1649
1694
|
#endif
|
|
@@ -1675,7 +1720,12 @@ ${ssrShader}
|
|
|
1675
1720
|
projection: this.material.uniforms.projection,
|
|
1676
1721
|
cameraPositionWorld: this.material.uniforms.cameraPositionWorld,
|
|
1677
1722
|
cameraNearFar: this.material.uniforms.cameraNearFar,
|
|
1678
|
-
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
|
|
1679
1729
|
});
|
|
1680
1730
|
}
|
|
1681
1731
|
}
|
|
@@ -1763,85 +1813,90 @@ ${ssrShader}
|
|
|
1763
1813
|
Object.assign(this.materialExtension.extraDefines, this._gbufferUnpackExtension.extraDefines);
|
|
1764
1814
|
}
|
|
1765
1815
|
};
|
|
1766
|
-
__decorateClass$
|
|
1816
|
+
__decorateClass$a([
|
|
1767
1817
|
uiSlider("Intensity", [0, 4]),
|
|
1768
1818
|
serialize(),
|
|
1769
1819
|
uniform()
|
|
1770
1820
|
], SSReflectionPluginPass.prototype, "intensity", 2);
|
|
1771
|
-
__decorateClass$
|
|
1821
|
+
__decorateClass$a([
|
|
1772
1822
|
uiVector("Boost"),
|
|
1773
1823
|
serialize(),
|
|
1774
1824
|
uniform()
|
|
1775
1825
|
], SSReflectionPluginPass.prototype, "boost", 2);
|
|
1776
|
-
__decorateClass$
|
|
1826
|
+
__decorateClass$a([
|
|
1777
1827
|
uiSlider("Object Radius", [0.01, 2]),
|
|
1778
1828
|
serialize(),
|
|
1779
1829
|
uniform()
|
|
1780
1830
|
], SSReflectionPluginPass.prototype, "objectRadius", 2);
|
|
1781
|
-
__decorateClass$
|
|
1831
|
+
__decorateClass$a([
|
|
1782
1832
|
uiToggle("Auto radius"),
|
|
1783
1833
|
serialize(),
|
|
1784
1834
|
uniform()
|
|
1785
1835
|
], SSReflectionPluginPass.prototype, "autoRadius", 2);
|
|
1786
|
-
__decorateClass$
|
|
1836
|
+
__decorateClass$a([
|
|
1787
1837
|
uiSlider("Power", [0, 3]),
|
|
1788
1838
|
serialize(),
|
|
1789
1839
|
uniform()
|
|
1790
1840
|
], SSReflectionPluginPass.prototype, "power", 2);
|
|
1791
|
-
__decorateClass$
|
|
1841
|
+
__decorateClass$a([
|
|
1792
1842
|
uiSlider("Tolerance", [0.1, 5]),
|
|
1793
1843
|
serialize(),
|
|
1794
1844
|
uniform()
|
|
1795
1845
|
], SSReflectionPluginPass.prototype, "tolerance", 2);
|
|
1796
|
-
__decorateClass$
|
|
1846
|
+
__decorateClass$a([
|
|
1797
1847
|
uiSlider("Roughness Factor", [0.1, 1.25]),
|
|
1798
1848
|
serialize(),
|
|
1799
1849
|
uniform({ propKey: "ssrRoughnessFactor" })
|
|
1800
1850
|
], SSReflectionPluginPass.prototype, "roughnessFactor", 2);
|
|
1801
|
-
__decorateClass$
|
|
1802
|
-
uiSlider("Step count", [1, 32], 1),
|
|
1851
|
+
__decorateClass$a([
|
|
1852
|
+
uiSlider("Step count", [1, 32], 1, { tags: ["performance"] }),
|
|
1803
1853
|
serialize(),
|
|
1804
1854
|
matDefine("SSR_STEP_COUNT", void 0, void 0, SSReflectionPluginPass.prototype.setDirty)
|
|
1805
1855
|
], SSReflectionPluginPass.prototype, "stepCount", 2);
|
|
1806
|
-
__decorateClass$
|
|
1807
|
-
uiSlider("Ray count", [1, 8], 1),
|
|
1856
|
+
__decorateClass$a([
|
|
1857
|
+
uiSlider("Ray count", [1, 8], 1, { tags: ["performance"] }),
|
|
1808
1858
|
serialize(),
|
|
1809
1859
|
matDefine("SSR_RAY_COUNT", void 0, void 0, SSReflectionPluginPass.prototype.setDirty)
|
|
1810
1860
|
], SSReflectionPluginPass.prototype, "rayCount", 2);
|
|
1811
|
-
__decorateClass$
|
|
1861
|
+
__decorateClass$a([
|
|
1812
1862
|
uiToggle("Ray Blend MAX"),
|
|
1813
1863
|
serialize(),
|
|
1814
1864
|
matDefineBool("SSR_RAY_BLEND_MAX", void 0, void 0, SSReflectionPluginPass.prototype.setDirty, true)
|
|
1815
1865
|
], SSReflectionPluginPass.prototype, "rayBlendMax", 2);
|
|
1816
|
-
__decorateClass$
|
|
1866
|
+
__decorateClass$a([
|
|
1817
1867
|
uiSlider("Low Quality Frames", [0, 4], 1),
|
|
1818
1868
|
serialize(),
|
|
1819
1869
|
matDefine("SSR_LOW_QUALITY_FRAMES", void 0, void 0, SSReflectionPluginPass.prototype.setDirty)
|
|
1820
1870
|
], SSReflectionPluginPass.prototype, "lowQualityFrames", 2);
|
|
1821
|
-
__decorateClass$
|
|
1871
|
+
__decorateClass$a([
|
|
1822
1872
|
uiToggle("Ignore front rays"),
|
|
1823
1873
|
serialize(),
|
|
1824
1874
|
matDefineBool("SSR_MASK_FRONT_RAYS", void 0, void 0, SSReflectionPluginPass.prototype.setDirty)
|
|
1825
1875
|
], SSReflectionPluginPass.prototype, "maskFrontRays", 2);
|
|
1826
|
-
__decorateClass$
|
|
1876
|
+
__decorateClass$a([
|
|
1827
1877
|
uiSlider("Mask front rays factor", [-1, 1], 0.01, (that) => ({ hidden: () => !that.maskFrontRays })),
|
|
1828
1878
|
serialize(),
|
|
1829
1879
|
uniform()
|
|
1830
1880
|
], SSReflectionPluginPass.prototype, "maskFrontFactor", 2);
|
|
1831
|
-
|
|
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([
|
|
1832
1887
|
uiFolderContainer("SSReflection Pass")
|
|
1833
1888
|
], SSReflectionPluginPass);
|
|
1834
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);}";
|
|
1835
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;}";
|
|
1836
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.);}";
|
|
1837
|
-
var __defProp$
|
|
1838
|
-
var __getOwnPropDesc$
|
|
1839
|
-
var __decorateClass$
|
|
1840
|
-
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;
|
|
1841
1896
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
1842
1897
|
if (decorator = decorators[i2])
|
|
1843
1898
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
1844
|
-
if (kind && result) __defProp$
|
|
1899
|
+
if (kind && result) __defProp$9(target, key, result);
|
|
1845
1900
|
return result;
|
|
1846
1901
|
};
|
|
1847
1902
|
let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
@@ -1922,14 +1977,16 @@ let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
|
1922
1977
|
setDirty() {
|
|
1923
1978
|
super.setDirty();
|
|
1924
1979
|
if (!this._viewer) return;
|
|
1925
|
-
const picking = this._viewer.getPlugin(PickingPlugin);
|
|
1926
1980
|
const enabled = !this.isDisabled();
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
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
|
+
}
|
|
1933
1990
|
}
|
|
1934
1991
|
this._viewer.setDirty();
|
|
1935
1992
|
}
|
|
@@ -2051,61 +2108,61 @@ let OutlinePlugin = class extends AScreenPassExtensionPlugin {
|
|
|
2051
2108
|
};
|
|
2052
2109
|
OutlinePlugin.PluginType = "OutlinePlugin";
|
|
2053
2110
|
OutlinePlugin.OldPluginType = "Outline";
|
|
2054
|
-
__decorateClass$
|
|
2111
|
+
__decorateClass$9([
|
|
2055
2112
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2056
2113
|
uiToggle("Enable"),
|
|
2057
2114
|
serialize()
|
|
2058
2115
|
], OutlinePlugin.prototype, "enabled", 2);
|
|
2059
|
-
__decorateClass$
|
|
2116
|
+
__decorateClass$9([
|
|
2060
2117
|
uiToggle("Highlight"),
|
|
2061
2118
|
uniform({ propKey: "enableHighlight" }),
|
|
2062
2119
|
serialize()
|
|
2063
2120
|
], OutlinePlugin.prototype, "enableHighlight", 2);
|
|
2064
|
-
__decorateClass$
|
|
2121
|
+
__decorateClass$9([
|
|
2065
2122
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2066
2123
|
uiToggle("DynamicSelection"),
|
|
2067
2124
|
serialize()
|
|
2068
2125
|
], OutlinePlugin.prototype, "enableDynamicSelection", 2);
|
|
2069
|
-
__decorateClass$
|
|
2126
|
+
__decorateClass$9([
|
|
2070
2127
|
uiSlider("Intensity", [0, 4], 1e-3),
|
|
2071
2128
|
uniform({ propKey: "outlineIntensity" }),
|
|
2072
2129
|
serialize("outlineIntensity")
|
|
2073
2130
|
], OutlinePlugin.prototype, "intensity", 2);
|
|
2074
|
-
__decorateClass$
|
|
2131
|
+
__decorateClass$9([
|
|
2075
2132
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2076
2133
|
uiSlider("Transparency", [0, 1], 0.01),
|
|
2077
2134
|
serialize()
|
|
2078
2135
|
], OutlinePlugin.prototype, "highlightTransparency", 2);
|
|
2079
|
-
__decorateClass$
|
|
2136
|
+
__decorateClass$9([
|
|
2080
2137
|
uiColor("Color"),
|
|
2081
2138
|
uniform({ propKey: "outlineColor" }),
|
|
2082
2139
|
serialize("outlineColor")
|
|
2083
2140
|
], OutlinePlugin.prototype, "color", 2);
|
|
2084
|
-
__decorateClass$
|
|
2141
|
+
__decorateClass$9([
|
|
2085
2142
|
uiSlider("Thickness", [0, 10], 0.01),
|
|
2086
2143
|
uniform({ propKey: "outlineThickness" }),
|
|
2087
2144
|
serialize("outlineThickness")
|
|
2088
2145
|
], OutlinePlugin.prototype, "thickness", 2);
|
|
2089
|
-
__decorateClass$
|
|
2146
|
+
__decorateClass$9([
|
|
2090
2147
|
uiToggle("Debug"),
|
|
2091
2148
|
matDefineBool("DEBUG_OUTLINE", void 0, true)
|
|
2092
2149
|
], OutlinePlugin.prototype, "debugOutline", 2);
|
|
2093
|
-
__decorateClass$
|
|
2150
|
+
__decorateClass$9([
|
|
2094
2151
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2095
2152
|
uiToggle("Highlight Selected Materials")
|
|
2096
2153
|
], OutlinePlugin.prototype, "highlightSelectedMaterials", 2);
|
|
2097
|
-
__decorateClass$
|
|
2154
|
+
__decorateClass$9([
|
|
2098
2155
|
onChange(OutlinePlugin.prototype.setDirty),
|
|
2099
2156
|
uiToggle("Highlight Materials (same name)")
|
|
2100
2157
|
], OutlinePlugin.prototype, "highlightMaterialSameNames", 2);
|
|
2101
|
-
__decorateClass$
|
|
2158
|
+
__decorateClass$9([
|
|
2102
2159
|
uniform({ propKey: "highlightTransparency" })
|
|
2103
2160
|
], OutlinePlugin.prototype, "transparency", 2);
|
|
2104
|
-
__decorateClass$
|
|
2161
|
+
__decorateClass$9([
|
|
2105
2162
|
uniform({ propKey: "outlineBuffer" }),
|
|
2106
2163
|
uiImage("Outline Buffer", { readOnly: true })
|
|
2107
2164
|
], OutlinePlugin.prototype, "texture", 2);
|
|
2108
|
-
OutlinePlugin = __decorateClass$
|
|
2165
|
+
OutlinePlugin = __decorateClass$9([
|
|
2109
2166
|
uiFolderContainer("Outline")
|
|
2110
2167
|
], OutlinePlugin);
|
|
2111
2168
|
let OutlineRenderPass = class extends RenderPass {
|
|
@@ -2197,22 +2254,21 @@ let OutlineRenderPass = class extends RenderPass {
|
|
|
2197
2254
|
camera.updateShaderProperties(this.overrideMaterial);
|
|
2198
2255
|
}
|
|
2199
2256
|
};
|
|
2200
|
-
__decorateClass$
|
|
2257
|
+
__decorateClass$9([
|
|
2201
2258
|
uiToggle("Enabled")
|
|
2202
2259
|
], OutlineRenderPass.prototype, "enabled", 2);
|
|
2203
|
-
OutlineRenderPass = __decorateClass$
|
|
2260
|
+
OutlineRenderPass = __decorateClass$9([
|
|
2204
2261
|
uiFolderContainer((c) => c.passId + " Render Pass")
|
|
2205
2262
|
], OutlineRenderPass);
|
|
2206
|
-
const ssgiPatch = "\n#if defined(SSRTAO_ENABLED) && SSRTAO_ENABLED > 0\nvec4 ssgi=tSSGIMapTexelToLinear(texture2D(tSSGIMap,
|
|
2207
|
-
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";
|
|
2208
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;}";
|
|
2209
|
-
var __defProp$
|
|
2210
|
-
var __decorateClass$
|
|
2265
|
+
var __defProp$8 = Object.defineProperty;
|
|
2266
|
+
var __decorateClass$8 = (decorators, target, key, kind) => {
|
|
2211
2267
|
var result = void 0;
|
|
2212
2268
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
2213
2269
|
if (decorator = decorators[i2])
|
|
2214
2270
|
result = decorator(target, key, result) || result;
|
|
2215
|
-
if (result) __defProp$
|
|
2271
|
+
if (result) __defProp$8(target, key, result);
|
|
2216
2272
|
return result;
|
|
2217
2273
|
};
|
|
2218
2274
|
class BilateralFilterPass extends ExtendedShaderPass {
|
|
@@ -2257,22 +2313,22 @@ class BilateralFilterPass extends ExtendedShaderPass {
|
|
|
2257
2313
|
super.render(renderer, target, writeBuffer, deltaTime, maskActive);
|
|
2258
2314
|
}
|
|
2259
2315
|
}
|
|
2260
|
-
__decorateClass$
|
|
2316
|
+
__decorateClass$8([
|
|
2261
2317
|
serialize(),
|
|
2262
2318
|
uniform()
|
|
2263
2319
|
], BilateralFilterPass.prototype, "smoothEnabled");
|
|
2264
|
-
__decorateClass$
|
|
2320
|
+
__decorateClass$8([
|
|
2265
2321
|
serialize(),
|
|
2266
2322
|
uniform()
|
|
2267
2323
|
], BilateralFilterPass.prototype, "edgeSharpness");
|
|
2268
|
-
var __defProp$
|
|
2269
|
-
var __getOwnPropDesc$
|
|
2270
|
-
var __decorateClass$
|
|
2271
|
-
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;
|
|
2272
2328
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
2273
2329
|
if (decorator = decorators[i2])
|
|
2274
2330
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
2275
|
-
if (kind && result) __defProp$
|
|
2331
|
+
if (kind && result) __defProp$7(target, key, result);
|
|
2276
2332
|
return result;
|
|
2277
2333
|
};
|
|
2278
2334
|
const passId = "ssrtgi";
|
|
@@ -2334,6 +2390,13 @@ let SSGIPlugin = class extends PipelinePassPlugin {
|
|
|
2334
2390
|
if (viewer.getPlugin("Ground") || viewer.getPlugin("BaseGroundPlugin")) console.error("GroundPlugin must be added after SSGIPlugin");
|
|
2335
2391
|
this._gbufferUnpackExtensionChanged();
|
|
2336
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
|
+
});
|
|
2337
2400
|
}
|
|
2338
2401
|
onRemove(viewer) {
|
|
2339
2402
|
this._disposeTarget();
|
|
@@ -2375,13 +2438,13 @@ let SSGIPlugin = class extends PipelinePassPlugin {
|
|
|
2375
2438
|
};
|
|
2376
2439
|
SSGIPlugin.PluginType = "SSGIPlugin";
|
|
2377
2440
|
SSGIPlugin.OldPluginType = "SSGI";
|
|
2378
|
-
__decorateClass$
|
|
2441
|
+
__decorateClass$7([
|
|
2379
2442
|
uiImage("SSGI Buffer", { readOnly: true })
|
|
2380
2443
|
], SSGIPlugin.prototype, "texture", 2);
|
|
2381
|
-
__decorateClass$
|
|
2444
|
+
__decorateClass$7([
|
|
2382
2445
|
uiConfig()
|
|
2383
2446
|
], SSGIPlugin.prototype, "_pass", 2);
|
|
2384
|
-
SSGIPlugin = __decorateClass$
|
|
2447
|
+
SSGIPlugin = __decorateClass$7([
|
|
2385
2448
|
uiFolderContainer("SSGI Plugin")
|
|
2386
2449
|
], SSGIPlugin);
|
|
2387
2450
|
let SSGIPluginPass = class extends ExtendedShaderPass {
|
|
@@ -2430,8 +2493,14 @@ let SSGIPluginPass = class extends ExtendedShaderPass {
|
|
|
2430
2493
|
// maskFrontFactor: {value: -0.1},
|
|
2431
2494
|
tolerance: { value: 0 },
|
|
2432
2495
|
// ssrtaoRoughnessFactor: {value: 1},
|
|
2433
|
-
sceneBoundingRadius: { value: 0 }
|
|
2496
|
+
sceneBoundingRadius: { value: 0 },
|
|
2434
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 }
|
|
2435
2504
|
},
|
|
2436
2505
|
vertexShader: shaderUtils.defaultVertex,
|
|
2437
2506
|
fragmentShader: `
|
|
@@ -2446,7 +2515,7 @@ ${samplePointHelpers}
|
|
|
2446
2515
|
|
|
2447
2516
|
${ssrtShader}
|
|
2448
2517
|
|
|
2449
|
-
${
|
|
2518
|
+
${getShaders().calculateGI}
|
|
2450
2519
|
`
|
|
2451
2520
|
}, "tDiffuse", "tLastThis", "tLastFrame");
|
|
2452
2521
|
this.target = target;
|
|
@@ -2465,6 +2534,7 @@ ${ssrtaoShader}
|
|
|
2465
2534
|
this.stepCount = 8;
|
|
2466
2535
|
this.smoothEnabled = true;
|
|
2467
2536
|
this.renderWithCamera = true;
|
|
2537
|
+
this.split = 0;
|
|
2468
2538
|
this.materialExtension = {
|
|
2469
2539
|
// todo set priority wrt ssr etc
|
|
2470
2540
|
extraUniforms: {
|
|
@@ -2473,7 +2543,8 @@ ${ssrtaoShader}
|
|
|
2473
2543
|
return { value: ((_a2 = getOrCall(this.target)) == null ? void 0 : _a2.texture) ?? null };
|
|
2474
2544
|
},
|
|
2475
2545
|
ssaoPower: this.material.uniforms.power,
|
|
2476
|
-
ssgiIntensity: this.material.uniforms.intensity
|
|
2546
|
+
ssgiIntensity: this.material.uniforms.intensity,
|
|
2547
|
+
ssrtaoSplitX: this.material.uniforms.ssrtaoSplitX
|
|
2477
2548
|
// ssrMaskFrontFactor: this.material.uniforms.maskFrontFactor,
|
|
2478
2549
|
},
|
|
2479
2550
|
extraDefines: {
|
|
@@ -2507,7 +2578,7 @@ ${ssrtaoShader}
|
|
|
2507
2578
|
},
|
|
2508
2579
|
onObjectRender: (_object, material, renderer) => {
|
|
2509
2580
|
var _a2, _b2, _c;
|
|
2510
|
-
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;
|
|
2511
2582
|
if (material.defines.SSRTAO_ENABLED !== x) {
|
|
2512
2583
|
material.defines.SSRTAO_ENABLED = x;
|
|
2513
2584
|
material.needsUpdate = true;
|
|
@@ -2520,6 +2591,9 @@ ${ssrtaoShader}
|
|
|
2520
2591
|
uniform float ssaoPower;
|
|
2521
2592
|
uniform float ssgiIntensity;
|
|
2522
2593
|
uniform sampler2D tSSGIMap;
|
|
2594
|
+
#if defined(SSRTAO_ENABLED) && SSRTAO_ENABLED == 2
|
|
2595
|
+
uniform float ssrtaoSplitX;
|
|
2596
|
+
#endif
|
|
2523
2597
|
${getTexelDecoding("tSSGIMap", (_a2 = getOrCall(this.target)) == null ? void 0 : _a2.texture.colorSpace)}
|
|
2524
2598
|
${/*tLastFrame not requried in material extension
|
|
2525
2599
|
// uniform sampler2D tLastFrame;
|
|
@@ -2569,10 +2643,13 @@ ${ssrtaoShader}
|
|
|
2569
2643
|
if (this.smoothEnabled) {
|
|
2570
2644
|
this.bilateralPass.render(renderer, writeBuffer, readBuffer, deltaTime, maskActive);
|
|
2571
2645
|
}
|
|
2646
|
+
this.uniforms.lastProjectionViewMatrix.value.copy(this.uniforms.currentProjectionViewMatrix.value);
|
|
2572
2647
|
}
|
|
2573
2648
|
beforeRender(scene, camera, renderManager) {
|
|
2574
2649
|
if (!this.enabled) return;
|
|
2575
2650
|
this.updateShaderProperties([scene, camera, renderManager]);
|
|
2651
|
+
this.uniforms.currentProjectionViewMatrix.value.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
2652
|
+
this.uniforms.inverseViewMatrix.value.copy(camera.matrixWorld);
|
|
2576
2653
|
}
|
|
2577
2654
|
/**
|
|
2578
2655
|
* Returns a uiConfig to toggle SSGI on a material.
|
|
@@ -2639,79 +2716,84 @@ ${ssrtaoShader}
|
|
|
2639
2716
|
super.setDirty();
|
|
2640
2717
|
}
|
|
2641
2718
|
};
|
|
2642
|
-
__decorateClass$
|
|
2719
|
+
__decorateClass$7([
|
|
2643
2720
|
serialize()
|
|
2644
2721
|
], SSGIPluginPass.prototype, "bilateralPass", 2);
|
|
2645
|
-
__decorateClass$
|
|
2722
|
+
__decorateClass$7([
|
|
2646
2723
|
uiToggle("GI Enabled"),
|
|
2647
2724
|
serialize(),
|
|
2648
2725
|
matDefineBool("SSGI_ENABLED", void 0, void 0, SSGIPluginPass.prototype.setDirty, false)
|
|
2649
2726
|
], SSGIPluginPass.prototype, "giEnabled", 2);
|
|
2650
|
-
__decorateClass$
|
|
2727
|
+
__decorateClass$7([
|
|
2651
2728
|
uiSlider("Intensity", [0, 4]),
|
|
2652
2729
|
serialize(),
|
|
2653
2730
|
uniform()
|
|
2654
2731
|
], SSGIPluginPass.prototype, "intensity", 2);
|
|
2655
|
-
__decorateClass$
|
|
2732
|
+
__decorateClass$7([
|
|
2656
2733
|
uiSlider("Power", [0, 3]),
|
|
2657
2734
|
serialize(),
|
|
2658
2735
|
uniform()
|
|
2659
2736
|
], SSGIPluginPass.prototype, "power", 2);
|
|
2660
|
-
__decorateClass$
|
|
2737
|
+
__decorateClass$7([
|
|
2661
2738
|
uiToggle("Auto radius"),
|
|
2662
2739
|
serialize(),
|
|
2663
2740
|
uniform()
|
|
2664
2741
|
], SSGIPluginPass.prototype, "autoRadius", 2);
|
|
2665
|
-
__decorateClass$
|
|
2742
|
+
__decorateClass$7([
|
|
2666
2743
|
uiSlider("Object Radius", [0.01, 10]),
|
|
2667
2744
|
serialize(),
|
|
2668
2745
|
uniform()
|
|
2669
2746
|
], SSGIPluginPass.prototype, "objectRadius", 2);
|
|
2670
|
-
__decorateClass$
|
|
2747
|
+
__decorateClass$7([
|
|
2671
2748
|
uiSlider("Tolerance", [0.1, 5]),
|
|
2672
2749
|
serialize(),
|
|
2673
2750
|
uniform()
|
|
2674
2751
|
], SSGIPluginPass.prototype, "tolerance", 2);
|
|
2675
|
-
__decorateClass$
|
|
2752
|
+
__decorateClass$7([
|
|
2676
2753
|
uiSlider("Bias", [-0.3, 0.3]),
|
|
2677
2754
|
serialize(),
|
|
2678
2755
|
uniform()
|
|
2679
2756
|
], SSGIPluginPass.prototype, "bias", 2);
|
|
2680
|
-
__decorateClass$
|
|
2757
|
+
__decorateClass$7([
|
|
2681
2758
|
uiSlider("Falloff", [1e-4, 4]),
|
|
2682
2759
|
serialize(),
|
|
2683
2760
|
uniform()
|
|
2684
2761
|
], SSGIPluginPass.prototype, "falloff", 2);
|
|
2685
|
-
__decorateClass$
|
|
2686
|
-
uiSlider("Ray Count", [1, 5], 1),
|
|
2762
|
+
__decorateClass$7([
|
|
2763
|
+
uiSlider("Ray Count", [1, 5], 1, { tags: ["performance"] }),
|
|
2687
2764
|
serialize(),
|
|
2688
2765
|
uniform()
|
|
2689
2766
|
], SSGIPluginPass.prototype, "rayCount", 2);
|
|
2690
|
-
__decorateClass$
|
|
2691
|
-
uiSlider("Step count", [1, 16], 1),
|
|
2767
|
+
__decorateClass$7([
|
|
2768
|
+
uiSlider("Step count", [1, 16], 1, { tags: ["performance"] }),
|
|
2692
2769
|
serialize(),
|
|
2693
2770
|
matDefine("RTAO_STEP_COUNT", void 0, void 0, SSGIPluginPass.prototype.setDirty)
|
|
2694
2771
|
], SSGIPluginPass.prototype, "stepCount", 2);
|
|
2695
|
-
__decorateClass$
|
|
2772
|
+
__decorateClass$7([
|
|
2696
2773
|
uiToggle("Smooth Enabled"),
|
|
2697
2774
|
serialize()
|
|
2698
2775
|
], SSGIPluginPass.prototype, "smoothEnabled", 2);
|
|
2699
|
-
__decorateClass$
|
|
2776
|
+
__decorateClass$7([
|
|
2700
2777
|
uiToggle("Render with Camera")
|
|
2701
2778
|
], SSGIPluginPass.prototype, "renderWithCamera", 2);
|
|
2702
|
-
|
|
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([
|
|
2703
2785
|
uiFolderContainer("SSGI Pass")
|
|
2704
2786
|
], SSGIPluginPass);
|
|
2705
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);}";
|
|
2706
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));";
|
|
2707
|
-
var __defProp$
|
|
2708
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2709
|
-
var __decorateClass$
|
|
2710
|
-
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;
|
|
2711
2793
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
2712
2794
|
if (decorator = decorators[i2])
|
|
2713
2795
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
2714
|
-
if (kind && result) __defProp$
|
|
2796
|
+
if (kind && result) __defProp$6(target, key, result);
|
|
2715
2797
|
return result;
|
|
2716
2798
|
};
|
|
2717
2799
|
let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
@@ -3041,11 +3123,11 @@ let AnisotropyPlugin = class extends AViewerPluginSync {
|
|
|
3041
3123
|
};
|
|
3042
3124
|
AnisotropyPlugin.PluginType = "AnisotropyPlugin";
|
|
3043
3125
|
AnisotropyPlugin.ANISOTROPY_GLTF_EXTENSION = "WEBGI_materials_anisotropy";
|
|
3044
|
-
__decorateClass$
|
|
3126
|
+
__decorateClass$6([
|
|
3045
3127
|
uiToggle("Enabled", (that) => ({ onChange: that.setDirty })),
|
|
3046
3128
|
serialize()
|
|
3047
3129
|
], AnisotropyPlugin.prototype, "enabled", 2);
|
|
3048
|
-
AnisotropyPlugin = __decorateClass$
|
|
3130
|
+
AnisotropyPlugin = __decorateClass$6([
|
|
3049
3131
|
uiFolderContainer("Anisotropy (MatExt)")
|
|
3050
3132
|
], AnisotropyPlugin);
|
|
3051
3133
|
class GLTFMaterialsAnisotropyExtensionImport {
|
|
@@ -3124,13 +3206,13 @@ const anisotropyGLTFExtension = {
|
|
|
3124
3206
|
};
|
|
3125
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);}";
|
|
3126
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);}";
|
|
3127
|
-
var __defProp$
|
|
3128
|
-
var __decorateClass$
|
|
3209
|
+
var __defProp$5 = Object.defineProperty;
|
|
3210
|
+
var __decorateClass$5 = (decorators, target, key, kind) => {
|
|
3129
3211
|
var result = void 0;
|
|
3130
3212
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
3131
3213
|
if (decorator = decorators[i2])
|
|
3132
3214
|
result = decorator(target, key, result) || result;
|
|
3133
|
-
if (result) __defProp$
|
|
3215
|
+
if (result) __defProp$5(target, key, result);
|
|
3134
3216
|
return result;
|
|
3135
3217
|
};
|
|
3136
3218
|
const _Reflector2 = class _Reflector22 extends Mesh2 {
|
|
@@ -3348,10 +3430,10 @@ const _Reflector2 = class _Reflector22 extends Mesh2 {
|
|
|
3348
3430
|
return this._renderTarget;
|
|
3349
3431
|
}
|
|
3350
3432
|
};
|
|
3351
|
-
__decorateClass$
|
|
3433
|
+
__decorateClass$5([
|
|
3352
3434
|
onChange(_Reflector2.prototype._updateExtension)
|
|
3353
3435
|
], _Reflector2.prototype, "enabled");
|
|
3354
|
-
__decorateClass$
|
|
3436
|
+
__decorateClass$5([
|
|
3355
3437
|
onChange(_Reflector2.prototype._updateExtension)
|
|
3356
3438
|
], _Reflector2.prototype, "reflectorModePhysical");
|
|
3357
3439
|
let Reflector2 = _Reflector2;
|
|
@@ -3425,13 +3507,13 @@ class a {
|
|
|
3425
3507
|
return { next: () => Math.random() };
|
|
3426
3508
|
}
|
|
3427
3509
|
}
|
|
3428
|
-
var __defProp$
|
|
3429
|
-
var __decorateClass$
|
|
3510
|
+
var __defProp$4 = Object.defineProperty;
|
|
3511
|
+
var __decorateClass$4 = (decorators, target, key, kind) => {
|
|
3430
3512
|
var result = void 0;
|
|
3431
3513
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
3432
3514
|
if (decorator = decorators[i2])
|
|
3433
3515
|
result = decorator(target, key, result) || result;
|
|
3434
|
-
if (result) __defProp$
|
|
3516
|
+
if (result) __defProp$4(target, key, result);
|
|
3435
3517
|
return result;
|
|
3436
3518
|
};
|
|
3437
3519
|
class RandomizedDirectionalLight extends DirectionalLight2 {
|
|
@@ -3586,10 +3668,10 @@ class RandomizedDirectionalLight extends DirectionalLight2 {
|
|
|
3586
3668
|
// this.updateMatrixWorld()
|
|
3587
3669
|
// }
|
|
3588
3670
|
}
|
|
3589
|
-
__decorateClass$
|
|
3671
|
+
__decorateClass$4([
|
|
3590
3672
|
serialize("shadowParams")
|
|
3591
3673
|
], RandomizedDirectionalLight.prototype, "_shadowParams");
|
|
3592
|
-
__decorateClass$
|
|
3674
|
+
__decorateClass$4([
|
|
3593
3675
|
serialize("randomParams")
|
|
3594
3676
|
], RandomizedDirectionalLight.prototype, "_randomParams");
|
|
3595
3677
|
function getSample(rand, dir, extent) {
|
|
@@ -3602,13 +3684,13 @@ function getSample(rand, dir, extent) {
|
|
|
3602
3684
|
const oneminus = Math.sqrt(1 - r2.y * r2.y);
|
|
3603
3685
|
return o1.multiplyScalar(Math.cos(r2.x) * oneminus).add(o2.multiplyScalar(Math.sin(r2.x) * oneminus)).add(dir.multiplyScalar(r2.y));
|
|
3604
3686
|
}
|
|
3605
|
-
var __defProp$
|
|
3606
|
-
var __decorateClass$
|
|
3687
|
+
var __defProp$3 = Object.defineProperty;
|
|
3688
|
+
var __decorateClass$3 = (decorators, target, key, kind) => {
|
|
3607
3689
|
var result = void 0;
|
|
3608
3690
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
3609
3691
|
if (decorator = decorators[i2])
|
|
3610
3692
|
result = decorator(target, key, result) || result;
|
|
3611
|
-
if (result) __defProp$
|
|
3693
|
+
if (result) __defProp$3(target, key, result);
|
|
3612
3694
|
return result;
|
|
3613
3695
|
};
|
|
3614
3696
|
class FSShadowMaterial extends ShadowMaterial {
|
|
@@ -3668,17 +3750,17 @@ gl_FragColor = packDepthToRGBA(mix(last, shadow, opacity));
|
|
|
3668
3750
|
this.dispatchEvent({ ...options, type: "materialUpdate" });
|
|
3669
3751
|
}
|
|
3670
3752
|
}
|
|
3671
|
-
__decorateClass$
|
|
3753
|
+
__decorateClass$3([
|
|
3672
3754
|
uniform({ propKey: "tLastThis" })
|
|
3673
3755
|
], FSShadowMaterial.prototype, "lastFrameTexture");
|
|
3674
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);}";
|
|
3675
|
-
var __defProp$
|
|
3676
|
-
var __decorateClass$
|
|
3757
|
+
var __defProp$2 = Object.defineProperty;
|
|
3758
|
+
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
3677
3759
|
var result = void 0;
|
|
3678
3760
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
3679
3761
|
if (decorator = decorators[i2])
|
|
3680
3762
|
result = decorator(target, key, result) || result;
|
|
3681
|
-
if (result) __defProp$
|
|
3763
|
+
if (result) __defProp$2(target, key, result);
|
|
3682
3764
|
return result;
|
|
3683
3765
|
};
|
|
3684
3766
|
const _ShadowMapBaker = class _ShadowMapBaker2 extends SimpleEventDispatcher {
|
|
@@ -4069,44 +4151,44 @@ const _ShadowMapBaker = class _ShadowMapBaker2 extends SimpleEventDispatcher {
|
|
|
4069
4151
|
// this._viewer.renderManager.renderModel(mesh, this._viewer.scene.activeCamera!)
|
|
4070
4152
|
// }
|
|
4071
4153
|
};
|
|
4072
|
-
__decorateClass$
|
|
4154
|
+
__decorateClass$2([
|
|
4073
4155
|
serialize("randomizedLight")
|
|
4074
4156
|
], _ShadowMapBaker.prototype, "_light");
|
|
4075
|
-
__decorateClass$
|
|
4157
|
+
__decorateClass$2([
|
|
4076
4158
|
onChange(_ShadowMapBaker.prototype.reset),
|
|
4077
4159
|
serialize()
|
|
4078
4160
|
], _ShadowMapBaker.prototype, "maxFrameNumber");
|
|
4079
|
-
__decorateClass$
|
|
4161
|
+
__decorateClass$2([
|
|
4080
4162
|
onChange(_ShadowMapBaker.prototype.reset),
|
|
4081
4163
|
serialize()
|
|
4082
4164
|
], _ShadowMapBaker.prototype, "smoothShadow");
|
|
4083
|
-
__decorateClass$
|
|
4165
|
+
__decorateClass$2([
|
|
4084
4166
|
serialize(),
|
|
4085
4167
|
onChange(_ShadowMapBaker.prototype.reset)
|
|
4086
4168
|
], _ShadowMapBaker.prototype, "shadowMapType");
|
|
4087
|
-
__decorateClass$
|
|
4169
|
+
__decorateClass$2([
|
|
4088
4170
|
onChange(_ShadowMapBaker.prototype._groundMapModeChanged),
|
|
4089
4171
|
serialize()
|
|
4090
4172
|
], _ShadowMapBaker.prototype, "groundMapMode");
|
|
4091
|
-
__decorateClass$
|
|
4173
|
+
__decorateClass$2([
|
|
4092
4174
|
serialize(),
|
|
4093
4175
|
onChange(_ShadowMapBaker.prototype._alphaVignetteChanged)
|
|
4094
4176
|
], _ShadowMapBaker.prototype, "alphaVignette");
|
|
4095
|
-
__decorateClass$
|
|
4177
|
+
__decorateClass$2([
|
|
4096
4178
|
serialize(),
|
|
4097
4179
|
onChange(_ShadowMapBaker.prototype._alphaVignetteChanged)
|
|
4098
4180
|
], _ShadowMapBaker.prototype, "alphaVignetteAxis");
|
|
4099
|
-
__decorateClass$
|
|
4181
|
+
__decorateClass$2([
|
|
4100
4182
|
serialize()
|
|
4101
4183
|
], _ShadowMapBaker.prototype, "maxBakeCount");
|
|
4102
4184
|
let ShadowMapBaker = _ShadowMapBaker;
|
|
4103
|
-
var __defProp = Object.defineProperty;
|
|
4104
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4185
|
+
var __defProp$1 = Object.defineProperty;
|
|
4186
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
4105
4187
|
var result = void 0;
|
|
4106
4188
|
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
|
|
4107
4189
|
if (decorator = decorators[i2])
|
|
4108
4190
|
result = decorator(target, key, result) || result;
|
|
4109
|
-
if (result) __defProp(target, key, result);
|
|
4191
|
+
if (result) __defProp$1(target, key, result);
|
|
4110
4192
|
return result;
|
|
4111
4193
|
};
|
|
4112
4194
|
const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
@@ -4289,7 +4371,7 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4289
4371
|
{
|
|
4290
4372
|
label: "Alpha Vignette",
|
|
4291
4373
|
type: "checkbox",
|
|
4292
|
-
hidden: () => !this._material || this._material.transmission < 1e-4 && !this._material.transparent,
|
|
4374
|
+
hidden: () => !this._material || (this._material.transmission || 0) < 1e-4 && !this._material.transparent,
|
|
4293
4375
|
property: () => [this._shadowBaker, "alphaVignette"],
|
|
4294
4376
|
limitedUi: true,
|
|
4295
4377
|
onChange: () => {
|
|
@@ -4302,7 +4384,7 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4302
4384
|
type: "dropdown",
|
|
4303
4385
|
hidden: () => {
|
|
4304
4386
|
var _a3;
|
|
4305
|
-
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;
|
|
4306
4388
|
},
|
|
4307
4389
|
property: () => [this._shadowBaker, "alphaVignetteAxis"],
|
|
4308
4390
|
children: ["x", "y", "xy"].map((v) => ({ label: v, value: v })),
|
|
@@ -4437,33 +4519,190 @@ const _AdvancedGroundPlugin = (_b = class extends BaseGroundPlugin {
|
|
|
4437
4519
|
];
|
|
4438
4520
|
}
|
|
4439
4521
|
}, _b.PluginType = "AdvancedGroundPlugin", _b);
|
|
4440
|
-
__decorateClass([
|
|
4522
|
+
__decorateClass$1([
|
|
4441
4523
|
onChange(_AdvancedGroundPlugin.prototype._refresh3),
|
|
4442
4524
|
uiToggle("Baked Shadows"),
|
|
4443
4525
|
serialize()
|
|
4444
4526
|
], _AdvancedGroundPlugin.prototype, "bakedShadows");
|
|
4445
|
-
__decorateClass([
|
|
4527
|
+
__decorateClass$1([
|
|
4446
4528
|
onChange(_AdvancedGroundPlugin.prototype._refresh3),
|
|
4447
4529
|
uiToggle("Planar Reflections"),
|
|
4448
4530
|
serialize()
|
|
4449
4531
|
], _AdvancedGroundPlugin.prototype, "groundReflection");
|
|
4450
|
-
__decorateClass([
|
|
4532
|
+
__decorateClass$1([
|
|
4451
4533
|
onChange(_AdvancedGroundPlugin.prototype._refresh3),
|
|
4452
4534
|
uiToggle("Physical Reflections"),
|
|
4453
4535
|
serialize()
|
|
4454
4536
|
], _AdvancedGroundPlugin.prototype, "physicalReflections");
|
|
4455
|
-
__decorateClass([
|
|
4537
|
+
__decorateClass$1([
|
|
4456
4538
|
onChange(_AdvancedGroundPlugin.prototype._refresh3),
|
|
4457
4539
|
uiToggle("Auto Shadow Frustum Size"),
|
|
4458
4540
|
serialize()
|
|
4459
4541
|
], _AdvancedGroundPlugin.prototype, "autoFrustumSize");
|
|
4460
|
-
__decorateClass([
|
|
4542
|
+
__decorateClass$1([
|
|
4461
4543
|
serialize("shadowBaker")
|
|
4462
4544
|
], _AdvancedGroundPlugin.prototype, "_shadowBaker");
|
|
4463
|
-
__decorateClass([
|
|
4545
|
+
__decorateClass$1([
|
|
4464
4546
|
bindToValue({ key: "groundReflection" })
|
|
4465
4547
|
], _AdvancedGroundPlugin.prototype, "planarReflections");
|
|
4466
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);
|
|
4467
4706
|
const webgiPlugins = [
|
|
4468
4707
|
TemporalAAPlugin,
|
|
4469
4708
|
VelocityBufferPlugin,
|
|
@@ -4474,7 +4713,8 @@ const webgiPlugins = [
|
|
|
4474
4713
|
OutlinePlugin,
|
|
4475
4714
|
SSGIPlugin,
|
|
4476
4715
|
AnisotropyPlugin,
|
|
4477
|
-
AdvancedGroundPlugin
|
|
4716
|
+
AdvancedGroundPlugin,
|
|
4717
|
+
WatchHandsPlugin
|
|
4478
4718
|
];
|
|
4479
4719
|
export {
|
|
4480
4720
|
AdvancedGroundPlugin,
|
|
@@ -4494,6 +4734,7 @@ export {
|
|
|
4494
4734
|
TemporalAAPlugin,
|
|
4495
4735
|
TemporalAAPluginPass,
|
|
4496
4736
|
VelocityBufferPlugin,
|
|
4737
|
+
WatchHandsPlugin,
|
|
4497
4738
|
anisotropyGLTFExtension,
|
|
4498
4739
|
webgiPlugins
|
|
4499
4740
|
};
|