@shapediver/viewer.rendering-engine.rendering-engine-threejs 3.3.4 → 3.3.6
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/package.json +19 -20
- package/src/RenderingEngine.ts +0 -1336
- package/src/index.ts +0 -81
- package/src/injectors/Tag3dGeometryCreationInjector.ts +0 -154
- package/src/injectors/TextureUnifierInjector.ts +0 -214
- package/src/interfaces/ILoader.ts +0 -3
- package/src/interfaces/IPostProcessingEffectDefinitions.ts +0 -402
- package/src/interfaces/IRenderingEngine.ts +0 -48
- package/src/loaders/EnvironmentMapLoader.ts +0 -357
- package/src/loaders/GeometryLoader.ts +0 -585
- package/src/loaders/HTMLElementAnchorLoader.ts +0 -107
- package/src/loaders/LightLoader.ts +0 -171
- package/src/loaders/MaterialLoader.ts +0 -1413
- package/src/managers/CameraManager.ts +0 -178
- package/src/managers/EnvironmentGeometryManager.ts +0 -224
- package/src/managers/PostProcessingManager.ts +0 -1181
- package/src/managers/RenderingManager.ts +0 -657
- package/src/managers/SceneTracingManager.ts +0 -127
- package/src/managers/SceneTreeManager.ts +0 -576
- package/src/managers/postprocessing/GodRaysManager.ts +0 -52
- package/src/managers/postprocessing/OutlineManager.ts +0 -58
- package/src/managers/postprocessing/SSAARenderPass.ts +0 -339
- package/src/managers/postprocessing/SelectiveBloomManager.ts +0 -58
- package/src/managers/postprocessing/ao/ao/AOEffect.ts +0 -180
- package/src/managers/postprocessing/ao/ao/AOPass.ts +0 -128
- package/src/managers/postprocessing/ao/ao/shader/ao_compose.glsl +0 -17
- package/src/managers/postprocessing/ao/ao/shader/ao_compose.ts +0 -19
- package/src/managers/postprocessing/ao/hbao/HBAOEffect.ts +0 -41
- package/src/managers/postprocessing/ao/hbao/shader/hbao.glsl +0 -96
- package/src/managers/postprocessing/ao/hbao/shader/hbao.ts +0 -98
- package/src/managers/postprocessing/ao/hbao/shader/hbao_utils.glsl +0 -92
- package/src/managers/postprocessing/ao/hbao/shader/hbao_utils.ts +0 -95
- package/src/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.ts +0 -259
- package/src/managers/postprocessing/ao/poissionDenoise/shader/poissionDenoise.glsl +0 -125
- package/src/managers/postprocessing/ao/poissionDenoise/shader/poissionDenoise.ts +0 -127
- package/src/managers/postprocessing/ao/ssao/SSAOEffect.ts +0 -106
- package/src/managers/postprocessing/ao/ssao/shader/ssao.glsl +0 -128
- package/src/managers/postprocessing/ao/ssao/shader/ssao.ts +0 -130
- package/src/managers/postprocessing/ao/utils/shader/basic.glsl +0 -6
- package/src/managers/postprocessing/ao/utils/shader/basic.ts +0 -8
- package/src/managers/postprocessing/ao/utils/shader/sampleBlueNoise.glsl +0 -36
- package/src/managers/postprocessing/ao/utils/shader/sampleBlueNoise.ts +0 -38
- package/src/managers/postprocessing/utils/CopyMaterial.ts +0 -130
- package/src/managers/postprocessing/utils/CopyShader.ts +0 -39
- package/src/managers/postprocessing/utils/FullScreenQuad.ts +0 -47
- package/src/managers/postprocessing/utils/NormalPass.ts +0 -222
- package/src/managers/postprocessing/utils/RenderPass.ts +0 -366
- package/src/materials/GemMaterial.ts +0 -268
- package/src/materials/MeshUnlitMaterialParameters.ts +0 -4
- package/src/materials/MultiPointsMaterial.ts +0 -646
- package/src/materials/SpecularGlossinessMaterial.ts +0 -182
- package/src/objects/SDBone.ts +0 -51
- package/src/objects/SDColor.ts +0 -54
- package/src/objects/SDData.ts +0 -44
- package/src/objects/SDObject.ts +0 -58
- package/src/shaders/PCSS.ts +0 -124
- package/src/shaders/gem.ts +0 -579
- package/src/shaders/gem_frag.glsl +0 -522
- package/src/shaders/gem_vert.glsl +0 -53
- package/src/shaders/multi_points.ts +0 -291
- package/src/shaders/multi_points_frag.glsl +0 -166
- package/src/shaders/multi_points_vert.glsl +0 -120
- package/src/styling/viewport-css.ts +0 -113
- package/src/styling/viewport.css +0 -111
- package/src/three/font.ts +0 -2
- package/src/three/geometries/TextGeometry.ts +0 -58
- package/src/three/loaders/FontLoader.ts +0 -205
- package/src/three/loaders/RGBELoader.ts +0 -496
- package/src/types/IThreejsData.ts +0 -16
- package/src/types/ThreejsData.ts +0 -43
- package/tsconfig.json +0 -20
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import { MeshStandardMaterial, MeshStandardMaterialParameters } from 'three';
|
|
3
|
-
|
|
4
|
-
export interface SpecularGlossinessMaterialParameters extends MeshStandardMaterialParameters {
|
|
5
|
-
// #region Properties (4)
|
|
6
|
-
|
|
7
|
-
glossiness?: number | undefined;
|
|
8
|
-
glossinessMap?: THREE.Texture | null | undefined;
|
|
9
|
-
specular?: THREE.ColorRepresentation | undefined;
|
|
10
|
-
specularMap2?: THREE.Texture | null | undefined;
|
|
11
|
-
|
|
12
|
-
// #endregion Properties (4)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class SpecularGlossinessMaterial extends MeshStandardMaterial {
|
|
16
|
-
// #region Properties (1)
|
|
17
|
-
|
|
18
|
-
public isGLTFSpecularGlossinessMaterial: boolean;
|
|
19
|
-
|
|
20
|
-
// #endregion Properties (1)
|
|
21
|
-
|
|
22
|
-
// #region Constructors (1)
|
|
23
|
-
|
|
24
|
-
constructor(params: SpecularGlossinessMaterialParameters) {
|
|
25
|
-
super();
|
|
26
|
-
|
|
27
|
-
this.isGLTFSpecularGlossinessMaterial = true;
|
|
28
|
-
|
|
29
|
-
//various chunks that need replacing
|
|
30
|
-
const specularMap2ParsFragmentChunk = [
|
|
31
|
-
'#ifdef USE_SPECULARMAP2',
|
|
32
|
-
' uniform sampler2D specularMap2;',
|
|
33
|
-
'#endif'
|
|
34
|
-
].join('\n');
|
|
35
|
-
|
|
36
|
-
const glossinessMapParsFragmentChunk = [
|
|
37
|
-
'#ifdef USE_GLOSSINESSMAP',
|
|
38
|
-
' uniform sampler2D glossinessMap;',
|
|
39
|
-
'#endif'
|
|
40
|
-
].join('\n');
|
|
41
|
-
|
|
42
|
-
const specularMap2FragmentChunk = [
|
|
43
|
-
'vec3 specularFactor = specular;',
|
|
44
|
-
'#ifdef USE_SPECULARMAP2',
|
|
45
|
-
' vec4 texelSpecular = texture2D( specularMap2, vUv );',
|
|
46
|
-
' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture',
|
|
47
|
-
' specularFactor *= texelSpecular.rgb;',
|
|
48
|
-
'#endif'
|
|
49
|
-
].join('\n');
|
|
50
|
-
|
|
51
|
-
const glossinessMapFragmentChunk = [
|
|
52
|
-
'float glossinessFactor = glossiness;',
|
|
53
|
-
'#ifdef USE_GLOSSINESSMAP',
|
|
54
|
-
' vec4 texelGlossiness = texture2D( glossinessMap, vUv );',
|
|
55
|
-
' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture',
|
|
56
|
-
' glossinessFactor *= texelGlossiness.a;',
|
|
57
|
-
'#endif'
|
|
58
|
-
].join('\n');
|
|
59
|
-
|
|
60
|
-
const lightPhysicalFragmentChunk = [
|
|
61
|
-
'PhysicalMaterial material;',
|
|
62
|
-
'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );',
|
|
63
|
-
'vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );',
|
|
64
|
-
'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',
|
|
65
|
-
'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.',
|
|
66
|
-
'material.roughness += geometryRoughness;',
|
|
67
|
-
'material.roughness = min( material.roughness, 1.0 );',
|
|
68
|
-
'material.specularColor = specularFactor;',
|
|
69
|
-
].join('\n');
|
|
70
|
-
|
|
71
|
-
const uniforms: { [key: string]: { value: any } } = {
|
|
72
|
-
specular: { value: new THREE.Color().setHex(0xffffff) },
|
|
73
|
-
glossiness: { value: 1 },
|
|
74
|
-
specularMap2: { value: null },
|
|
75
|
-
glossinessMap: { value: null }
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
(<any>this)._extraUniforms = uniforms;
|
|
79
|
-
|
|
80
|
-
this.onBeforeCompile = function (shader) {
|
|
81
|
-
for (const uniformName in uniforms) {
|
|
82
|
-
shader.uniforms[uniformName] = uniforms[uniformName];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
shader.fragmentShader = shader.fragmentShader
|
|
86
|
-
.replace('uniform float roughness;', 'uniform vec3 specular;')
|
|
87
|
-
.replace('uniform float metalness;', 'uniform float glossiness;')
|
|
88
|
-
.replace('#include <roughnessmap_pars_fragment>', specularMap2ParsFragmentChunk)
|
|
89
|
-
.replace('#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk)
|
|
90
|
-
.replace('#include <roughnessmap_fragment>', specularMap2FragmentChunk)
|
|
91
|
-
.replace('#include <metalnessmap_fragment>', glossinessMapFragmentChunk)
|
|
92
|
-
.replace('#include <lights_physical_fragment>', lightPhysicalFragmentChunk);
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
Object.defineProperties(this, {
|
|
97
|
-
specular: {
|
|
98
|
-
get: function () {
|
|
99
|
-
return uniforms.specular.value;
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
set: function (v) {
|
|
103
|
-
uniforms.specular.value = v;
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
specularMap2: {
|
|
108
|
-
get: function () {
|
|
109
|
-
return uniforms.specularMap2.value;
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
set: function (v) {
|
|
113
|
-
uniforms.specularMap2.value = v;
|
|
114
|
-
|
|
115
|
-
if (v) {
|
|
116
|
-
this.defines.USE_SPECULARMAP2 = ''; // USE_UV is set by the renderer for specular maps
|
|
117
|
-
|
|
118
|
-
} else {
|
|
119
|
-
delete this.defines.USE_SPECULARMAP2;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
glossiness: {
|
|
125
|
-
get: function () {
|
|
126
|
-
return uniforms.glossiness.value;
|
|
127
|
-
|
|
128
|
-
},
|
|
129
|
-
set: function (v) {
|
|
130
|
-
uniforms.glossiness.value = v;
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
glossinessMap: {
|
|
135
|
-
get: function () {
|
|
136
|
-
return uniforms.glossinessMap.value;
|
|
137
|
-
|
|
138
|
-
},
|
|
139
|
-
set: function (v) {
|
|
140
|
-
uniforms.glossinessMap.value = v;
|
|
141
|
-
|
|
142
|
-
if (v) {
|
|
143
|
-
this.defines.USE_GLOSSINESSMAP = '';
|
|
144
|
-
this.defines.USE_UV = '';
|
|
145
|
-
|
|
146
|
-
} else {
|
|
147
|
-
delete this.defines.USE_GLOSSINESSMAP;
|
|
148
|
-
delete this.defines.USE_UV;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
delete (<any>this).metalness;
|
|
156
|
-
delete (<any>this).roughness;
|
|
157
|
-
delete (<any>this).metalnessMap;
|
|
158
|
-
delete (<any>this).roughnessMap;
|
|
159
|
-
|
|
160
|
-
this.setValues(params);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// #endregion Constructors (1)
|
|
164
|
-
|
|
165
|
-
// #region Public Methods (1)
|
|
166
|
-
|
|
167
|
-
public copy(source: SpecularGlossinessMaterial) {
|
|
168
|
-
super.copy(source);
|
|
169
|
-
|
|
170
|
-
(<any>this).specularMap2 = (<any>source).specularMap2;
|
|
171
|
-
(<any>this).specular.copy((<any>source).specular);
|
|
172
|
-
(<any>this).glossinessMap = (<any>source).glossinessMap;
|
|
173
|
-
(<any>this).glossiness = (<any>source).glossiness;
|
|
174
|
-
delete (<any>this).metalness;
|
|
175
|
-
delete (<any>this).roughness;
|
|
176
|
-
delete (<any>this).metalnessMap;
|
|
177
|
-
delete (<any>this).roughnessMap;
|
|
178
|
-
return this;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// #endregion Public Methods (1)
|
|
182
|
-
}
|
package/src/objects/SDBone.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three'
|
|
2
|
-
import { Bone } from 'three'
|
|
3
|
-
import { mat4 } from 'gl-matrix'
|
|
4
|
-
import { ISDObject } from '@shapediver/viewer.rendering-engine.rendering-engine';
|
|
5
|
-
|
|
6
|
-
export class SDBone extends Bone implements ISDObject {
|
|
7
|
-
// #region Constructors (1)
|
|
8
|
-
|
|
9
|
-
#SDid: string;
|
|
10
|
-
#SDversion: string;
|
|
11
|
-
|
|
12
|
-
constructor(
|
|
13
|
-
SDid: string,
|
|
14
|
-
SDversion: string
|
|
15
|
-
) {
|
|
16
|
-
super();
|
|
17
|
-
this.#SDid = SDid;
|
|
18
|
-
this.#SDversion = SDversion;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public applyTransformation(transformation: mat4): void {
|
|
22
|
-
this.matrix.identity();
|
|
23
|
-
this.matrixWorld.identity();
|
|
24
|
-
this.position.set(0,0,0)
|
|
25
|
-
this.scale.set(1,1,1)
|
|
26
|
-
this.quaternion.set(0,0,0,1)
|
|
27
|
-
this.applyMatrix4(new THREE.Matrix4().fromArray(transformation));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// #endregion Constructors (1)
|
|
31
|
-
|
|
32
|
-
// #region Public Accessors (4)
|
|
33
|
-
|
|
34
|
-
public get SDid(): string {
|
|
35
|
-
return this.#SDid;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public set SDid(value: string) {
|
|
39
|
-
this.#SDid = value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public get SDversion(): string {
|
|
43
|
-
return this.#SDversion;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public set SDversion(value: string) {
|
|
47
|
-
this.#SDversion = value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// #endregion Public Accessors (4)
|
|
51
|
-
}
|
package/src/objects/SDColor.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three'
|
|
2
|
-
import { Color as ThreeColor } from 'three'
|
|
3
|
-
import { Color } from '@shapediver/viewer.shared.types';
|
|
4
|
-
|
|
5
|
-
export class SDColor extends ThreeColor {
|
|
6
|
-
// #region Properties (3)
|
|
7
|
-
|
|
8
|
-
private _colorSpace: 'srgb' | 'srgb-linear' = 'srgb-linear';
|
|
9
|
-
private _originalColorSpace: 'srgb' | 'srgb-linear' = 'srgb-linear';
|
|
10
|
-
|
|
11
|
-
// #endregion Properties (3)
|
|
12
|
-
|
|
13
|
-
// #region Constructors (1)
|
|
14
|
-
|
|
15
|
-
constructor(hexColor: string, originalColor: Color) {
|
|
16
|
-
super(hexColor);
|
|
17
|
-
if(typeof originalColor === 'number' || Array.isArray(originalColor) && (originalColor.length == 3 || originalColor.length == 4)) {
|
|
18
|
-
this._colorSpace = 'srgb-linear';
|
|
19
|
-
this._originalColorSpace = 'srgb-linear';
|
|
20
|
-
} else {
|
|
21
|
-
this._colorSpace = 'srgb';
|
|
22
|
-
this._originalColorSpace = 'srgb';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// #endregion Constructors (1)
|
|
27
|
-
|
|
28
|
-
// #region Public Methods (1)
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Depending on the current state and provided value, this function converts the color to a different color space.
|
|
32
|
-
*
|
|
33
|
-
* If the color is in 'srgb' space and active is set to true, it will be converted to 'srgb-linear' space.
|
|
34
|
-
* If the color is in 'srgb-linear' space, the color is not originally in 'srgb-linear' and active is set to false, it will be converted to 'srgb' space.
|
|
35
|
-
*
|
|
36
|
-
* @param active
|
|
37
|
-
*/
|
|
38
|
-
public colorCorrection(active: boolean) {
|
|
39
|
-
if(this._colorSpace === 'srgb' && active === true) {
|
|
40
|
-
// we assume all colors provided are in 'srgb' color space
|
|
41
|
-
// therefore we need to correct those colors to 'srgb-linear' if the color conversion is active
|
|
42
|
-
this.convertSRGBToLinear();
|
|
43
|
-
this._colorSpace = 'srgb-linear';
|
|
44
|
-
} else if(this._colorSpace === 'srgb-linear' && active === false && this._originalColorSpace !== 'srgb-linear') {
|
|
45
|
-
// if the color space is already 'srgb-linear', the color was already converted
|
|
46
|
-
// therefore we need to convert it back if the color conversion was deactivted
|
|
47
|
-
// if it was not originally in 'srgb-linear'
|
|
48
|
-
this.convertLinearToSRGB();
|
|
49
|
-
this._colorSpace = 'srgb';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// #endregion Public Methods (1)
|
|
54
|
-
}
|
package/src/objects/SDData.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { SDObject } from './SDObject';
|
|
2
|
-
|
|
3
|
-
export enum SD_DATA_TYPE {
|
|
4
|
-
GEOMETRY = 'geometry',
|
|
5
|
-
MATERIAL = 'material',
|
|
6
|
-
THREEJS = 'threejs',
|
|
7
|
-
LIGHT = 'light',
|
|
8
|
-
CAMERA = 'camera',
|
|
9
|
-
ANIMATION = 'animation',
|
|
10
|
-
INTERACTION = 'interaction',
|
|
11
|
-
HTML_ELEMENT_ANCHOR = 'html_element_anchor',
|
|
12
|
-
CUSTOM = 'custom'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class SDData extends SDObject {
|
|
16
|
-
// #region Properties (1)
|
|
17
|
-
|
|
18
|
-
#SDtype: SD_DATA_TYPE = SD_DATA_TYPE.CUSTOM;
|
|
19
|
-
|
|
20
|
-
// #endregion Properties (1)
|
|
21
|
-
|
|
22
|
-
// #region Constructors (1)
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
SDid: string,
|
|
26
|
-
SDversion: string
|
|
27
|
-
) {
|
|
28
|
-
super(SDid, SDversion);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// #endregion Constructors (1)
|
|
32
|
-
|
|
33
|
-
// #region Public Accessors (2)
|
|
34
|
-
|
|
35
|
-
public get SDtype(): SD_DATA_TYPE {
|
|
36
|
-
return this.#SDtype;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public set SDtype(value: SD_DATA_TYPE) {
|
|
40
|
-
this.#SDtype = value;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// #endregion Public Accessors (2)
|
|
44
|
-
}
|
package/src/objects/SDObject.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three'
|
|
2
|
-
import { Object3D } from 'three'
|
|
3
|
-
import { mat4 } from 'gl-matrix'
|
|
4
|
-
import { ISDObject } from '@shapediver/viewer.rendering-engine.rendering-engine';
|
|
5
|
-
|
|
6
|
-
export class SDObject extends Object3D implements ISDObject {
|
|
7
|
-
// #region Constructors (1)
|
|
8
|
-
|
|
9
|
-
#SDid: string;
|
|
10
|
-
#SDversion: string;
|
|
11
|
-
|
|
12
|
-
constructor(
|
|
13
|
-
SDid: string,
|
|
14
|
-
SDversion: string
|
|
15
|
-
) {
|
|
16
|
-
super();
|
|
17
|
-
this.#SDid = SDid;
|
|
18
|
-
this.#SDversion = SDversion;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public applyTransformation(transformation: mat4): void {
|
|
22
|
-
this.matrix.identity();
|
|
23
|
-
this.matrixWorld.identity();
|
|
24
|
-
this.position.set(0,0,0)
|
|
25
|
-
this.scale.set(1,1,1)
|
|
26
|
-
this.quaternion.set(0,0,0,1)
|
|
27
|
-
this.applyMatrix4(new THREE.Matrix4().fromArray(transformation));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// #endregion Constructors (1)
|
|
31
|
-
|
|
32
|
-
// #region Public Accessors (4)
|
|
33
|
-
|
|
34
|
-
public get SDid(): string {
|
|
35
|
-
return this.#SDid;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public set SDid(value: string) {
|
|
39
|
-
this.#SDid = value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public get SDversion(): string {
|
|
43
|
-
return this.#SDversion;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public set SDversion(value: string) {
|
|
47
|
-
this.#SDversion = value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public cloneObject(): SDObject {
|
|
51
|
-
const clone = this.clone();
|
|
52
|
-
clone.SDid = this.SDid;
|
|
53
|
-
clone.SDversion = this.SDversion;
|
|
54
|
-
return clone;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// #endregion Public Accessors (4)
|
|
58
|
-
}
|
package/src/shaders/PCSS.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
export const main = `
|
|
2
|
-
|
|
3
|
-
uniform float lightSizeUV;
|
|
4
|
-
uniform float blending;
|
|
5
|
-
|
|
6
|
-
#ifdef SHADOWMAP_TYPE_PCF
|
|
7
|
-
|
|
8
|
-
#define NEAR_PLANE 0.1
|
|
9
|
-
#define NUM_SAMPLES 20
|
|
10
|
-
#define NUM_RINGS 11
|
|
11
|
-
|
|
12
|
-
vec2 poissonDisk[NUM_SAMPLES];
|
|
13
|
-
|
|
14
|
-
void initPoissonSamples( const in vec2 randomSeed ) {
|
|
15
|
-
float ANGLE_STEP = PI2 * float(NUM_RINGS) / float(NUM_SAMPLES);
|
|
16
|
-
float INV_NUM_SAMPLES = 1.0 / float(NUM_SAMPLES);
|
|
17
|
-
|
|
18
|
-
// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/
|
|
19
|
-
float angle = rand(randomSeed) * PI2;
|
|
20
|
-
float radius = INV_NUM_SAMPLES;
|
|
21
|
-
float radiusStep = radius;
|
|
22
|
-
|
|
23
|
-
for (int i = 0; i < int(NUM_SAMPLES); i++ ) {
|
|
24
|
-
poissonDisk[i] = vec2(cos(angle), sin(angle)) * pow(radius, 0.75);
|
|
25
|
-
radius += radiusStep;
|
|
26
|
-
angle += ANGLE_STEP;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
float penumbraSize( const in float zReceiver, const in float zBlocker ) { // Parallel plane estimation
|
|
31
|
-
return (zReceiver - zBlocker) / zBlocker;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
float findBlocker(sampler2D shadowMap, const in vec2 uv, const in float zReceiver ) {
|
|
35
|
-
// This uses similar triangles to compute what
|
|
36
|
-
// area of the shadow map we should search
|
|
37
|
-
float searchRadius = lightSizeUV * (zReceiver - NEAR_PLANE) / zReceiver;
|
|
38
|
-
float blockerDepthSum = 0.0;
|
|
39
|
-
int numBlockers = 0;
|
|
40
|
-
|
|
41
|
-
for (int i = 0; i < int(NUM_SAMPLES); i++ ) {
|
|
42
|
-
float shadowMapDepth = unpackRGBAToDepth(texture2D(shadowMap, uv + poissonDisk[i] * searchRadius));
|
|
43
|
-
if (shadowMapDepth < zReceiver) {
|
|
44
|
-
blockerDepthSum += shadowMapDepth;
|
|
45
|
-
numBlockers++;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (numBlockers == 0) return -1.0;
|
|
50
|
-
|
|
51
|
-
return blockerDepthSum / float(numBlockers);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
float PCF_Filter(sampler2D shadowMap, vec2 uv, float zReceiver, float filterRadius) {
|
|
55
|
-
float sum = 0.0;
|
|
56
|
-
for (int i = 0; i < int(NUM_SAMPLES); i++ ) {
|
|
57
|
-
float depth = unpackRGBAToDepth(texture2D(shadowMap, uv + poissonDisk[i] * filterRadius));
|
|
58
|
-
if (zReceiver <= depth) sum += 1.0;
|
|
59
|
-
}
|
|
60
|
-
for (int i = 0; i < int(NUM_SAMPLES); i++ ) {
|
|
61
|
-
float depth = unpackRGBAToDepth(texture2D(shadowMap, uv + -poissonDisk[i].yx * filterRadius));
|
|
62
|
-
if (zReceiver <= depth) sum += 1.0;
|
|
63
|
-
}
|
|
64
|
-
return sum / (2.0 * float(NUM_SAMPLES));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
float PCSS(sampler2D shadowMap, vec4 coords) {
|
|
68
|
-
vec2 uv = coords.xy;
|
|
69
|
-
float zReceiver = coords.z; // Assumed to be eye-space z in this code
|
|
70
|
-
|
|
71
|
-
initPoissonSamples(uv);
|
|
72
|
-
// STEP 1: blocker search
|
|
73
|
-
float avgBlockerDepth = findBlocker(shadowMap, uv, zReceiver);
|
|
74
|
-
|
|
75
|
-
//There are no occluders so early out (this saves filtering)
|
|
76
|
-
if (avgBlockerDepth == -1.0) return 1.0;
|
|
77
|
-
|
|
78
|
-
// STEP 2: penumbra size
|
|
79
|
-
float penumbraRatio = penumbraSize(zReceiver, avgBlockerDepth);
|
|
80
|
-
float filterRadius = penumbraRatio * lightSizeUV * NEAR_PLANE / zReceiver;
|
|
81
|
-
|
|
82
|
-
// STEP 3: filtering
|
|
83
|
-
//return avgBlockerDepth;
|
|
84
|
-
return PCF_Filter(shadowMap, uv, zReceiver, filterRadius);
|
|
85
|
-
}
|
|
86
|
-
#endif
|
|
87
|
-
`;
|
|
88
|
-
|
|
89
|
-
export const entry = `
|
|
90
|
-
// PCSS implementation
|
|
91
|
-
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
92
|
-
float dx = texelSize.x;
|
|
93
|
-
float dy = texelSize.y;
|
|
94
|
-
vec2 uv = shadowCoord.xy;
|
|
95
|
-
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
96
|
-
uv -= f * texelSize;
|
|
97
|
-
float shadow1 = (
|
|
98
|
-
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
99
|
-
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
100
|
-
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
101
|
-
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
102
|
-
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
103
|
-
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
104
|
-
f.x ) +
|
|
105
|
-
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
106
|
-
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
107
|
-
f.x ) +
|
|
108
|
-
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
109
|
-
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
110
|
-
f.y ) +
|
|
111
|
-
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
112
|
-
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
113
|
-
f.y ) +
|
|
114
|
-
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
115
|
-
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
116
|
-
f.x ),
|
|
117
|
-
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
118
|
-
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
119
|
-
f.x ),
|
|
120
|
-
f.y )
|
|
121
|
-
) * ( 1.0 / 9.0 );
|
|
122
|
-
float shadow2 = PCSS( shadowMap, shadowCoord );
|
|
123
|
-
shadow = shadow1 * (1.0 - blending) + blending * shadow2;
|
|
124
|
-
`
|