super-three 0.155.0 → 0.156.0
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/build/three.cjs +107 -125
- package/build/three.js +107 -125
- package/build/three.min.js +1 -1
- package/build/three.module.js +104 -126
- package/build/three.module.min.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +13 -5
- package/examples/jsm/csm/CSMShader.js +35 -1
- package/examples/jsm/libs/tween.module.js +790 -735
- package/examples/jsm/libs/utif.module.js +1644 -1558
- package/examples/jsm/loaders/DDSLoader.js +46 -3
- package/examples/jsm/loaders/EXRLoader.js +4 -4
- package/examples/jsm/loaders/FBXLoader.js +2 -0
- package/examples/jsm/loaders/GLTFLoader.js +17 -7
- package/examples/jsm/loaders/KTX2Loader.js +126 -77
- package/examples/jsm/loaders/LogLuvLoader.js +2 -2
- package/examples/jsm/loaders/MMDLoader.js +10 -7
- package/examples/jsm/loaders/RGBELoader.js +48 -66
- package/examples/jsm/loaders/STLLoader.js +7 -0
- package/examples/jsm/nodes/Nodes.js +3 -0
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +28 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +18 -3
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +2 -4
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -33
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
- package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +6 -2
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
- package/examples/jsm/nodes/core/AttributeNode.js +2 -2
- package/examples/jsm/nodes/core/Node.js +17 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
- package/examples/jsm/nodes/core/NodeUniform.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
- package/examples/jsm/nodes/core/PropertyNode.js +2 -0
- package/examples/jsm/nodes/core/StackNode.js +4 -4
- package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
- package/examples/jsm/nodes/display/ViewportNode.js +19 -5
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +12 -3
- package/examples/jsm/nodes/math/HashNode.js +35 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +4 -0
- package/examples/jsm/nodes/utils/SplitNode.js +1 -1
- package/examples/jsm/postprocessing/FilmPass.js +3 -5
- package/examples/jsm/postprocessing/RenderPass.js +30 -12
- package/examples/jsm/postprocessing/SAOPass.js +23 -98
- package/examples/jsm/postprocessing/SSAOPass.js +10 -30
- package/examples/jsm/renderers/common/Backend.js +11 -8
- package/examples/jsm/renderers/common/Binding.js +6 -0
- package/examples/jsm/renderers/common/Bindings.js +5 -4
- package/examples/jsm/renderers/common/Pipelines.js +2 -2
- package/examples/jsm/renderers/common/RenderContexts.js +26 -1
- package/examples/jsm/renderers/common/RenderList.js +12 -4
- package/examples/jsm/renderers/common/RenderObject.js +6 -2
- package/examples/jsm/renderers/common/Renderer.js +12 -3
- package/examples/jsm/renderers/common/SampledTexture.js +2 -1
- package/examples/jsm/renderers/common/Sampler.js +1 -1
- package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
- package/examples/jsm/renderers/common/Textures.js +155 -15
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +43 -9
- package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
- package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +279 -40
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +89 -59
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +34 -9
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +26 -135
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
- package/examples/jsm/shaders/FilmShader.js +11 -54
- package/examples/jsm/shaders/SAOShader.js +0 -13
- package/examples/jsm/shaders/SSAOShader.js +33 -26
- package/package.json +1 -1
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +6 -0
- package/src/constants.js +4 -1
- package/src/core/Object3D.js +1 -14
- package/src/core/UniformsGroup.js +2 -2
- package/src/loaders/DataTextureLoader.js +0 -2
- package/src/materials/Material.js +2 -2
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +3 -3
- package/src/math/Vector4.js +4 -4
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/renderers/WebGLRenderer.js +21 -49
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
- package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
- package/src/renderers/webgl/WebGLBackground.js +5 -14
- package/src/renderers/webgl/WebGLProgram.js +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +5 -1
- package/src/renderers/webgl/WebGLTextures.js +4 -4
- package/src/renderers/webgl/WebGLUtils.js +27 -20
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +9 -1
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
- /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
|
@@ -59,7 +59,7 @@ class SplitNode extends Node {
|
|
|
59
59
|
|
|
60
60
|
if ( this.components.length === nodeTypeLength && this.components === stringVectorComponents.slice( 0, this.components.length ) ) {
|
|
61
61
|
|
|
62
|
-
//
|
|
62
|
+
// unnecessary swizzle
|
|
63
63
|
|
|
64
64
|
snippet = builder.format( nodeSnippet, type, output );
|
|
65
65
|
|
|
@@ -7,7 +7,7 @@ import { FilmShader } from '../shaders/FilmShader.js';
|
|
|
7
7
|
|
|
8
8
|
class FilmPass extends Pass {
|
|
9
9
|
|
|
10
|
-
constructor(
|
|
10
|
+
constructor( intensity = 0.5, grayscale = false ) {
|
|
11
11
|
|
|
12
12
|
super();
|
|
13
13
|
|
|
@@ -24,10 +24,8 @@ class FilmPass extends Pass {
|
|
|
24
24
|
|
|
25
25
|
} );
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
|
|
30
|
-
if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
|
|
27
|
+
this.uniforms.intensity.value = intensity; // (0 = no effect, 1 = full effect)
|
|
28
|
+
this.uniforms.grayscale.value = grayscale;
|
|
31
29
|
|
|
32
30
|
this.fsQuad = new FullScreenQuad( this.material );
|
|
33
31
|
|
|
@@ -5,7 +5,7 @@ import { Pass } from './Pass.js';
|
|
|
5
5
|
|
|
6
6
|
class RenderPass extends Pass {
|
|
7
7
|
|
|
8
|
-
constructor( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
|
|
8
|
+
constructor( scene, camera, overrideMaterial = null, clearColor = null, clearAlpha = null ) {
|
|
9
9
|
|
|
10
10
|
super();
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ class RenderPass extends Pass {
|
|
|
15
15
|
this.overrideMaterial = overrideMaterial;
|
|
16
16
|
|
|
17
17
|
this.clearColor = clearColor;
|
|
18
|
-
this.clearAlpha =
|
|
18
|
+
this.clearAlpha = clearAlpha;
|
|
19
19
|
|
|
20
20
|
this.clear = true;
|
|
21
21
|
this.clearDepth = false;
|
|
@@ -31,7 +31,7 @@ class RenderPass extends Pass {
|
|
|
31
31
|
|
|
32
32
|
let oldClearAlpha, oldOverrideMaterial;
|
|
33
33
|
|
|
34
|
-
if ( this.overrideMaterial !==
|
|
34
|
+
if ( this.overrideMaterial !== null ) {
|
|
35
35
|
|
|
36
36
|
oldOverrideMaterial = this.scene.overrideMaterial;
|
|
37
37
|
|
|
@@ -39,16 +39,21 @@ class RenderPass extends Pass {
|
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
if ( this.clearColor ) {
|
|
42
|
+
if ( this.clearColor !== null ) {
|
|
43
43
|
|
|
44
44
|
renderer.getClearColor( this._oldClearColor );
|
|
45
|
-
|
|
45
|
+
renderer.setClearColor( this.clearColor );
|
|
46
|
+
|
|
47
|
+
}
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
if ( this.clearAlpha !== null ) {
|
|
50
|
+
|
|
51
|
+
oldClearAlpha = renderer.getClearAlpha();
|
|
52
|
+
renderer.setClearAlpha( this.clearAlpha );
|
|
48
53
|
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
if ( this.clearDepth ) {
|
|
56
|
+
if ( this.clearDepth == true ) {
|
|
52
57
|
|
|
53
58
|
renderer.clearDepth();
|
|
54
59
|
|
|
@@ -56,17 +61,30 @@ class RenderPass extends Pass {
|
|
|
56
61
|
|
|
57
62
|
renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
if ( this.clear === true ) {
|
|
65
|
+
|
|
66
|
+
// TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
|
|
67
|
+
renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
renderer.render( this.scene, this.camera );
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
// restore
|
|
74
|
+
|
|
75
|
+
if ( this.clearColor !== null ) {
|
|
76
|
+
|
|
77
|
+
renderer.setClearColor( this._oldClearColor );
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if ( this.clearAlpha !== null ) {
|
|
64
82
|
|
|
65
|
-
renderer.
|
|
83
|
+
renderer.setClearAlpha( oldClearAlpha );
|
|
66
84
|
|
|
67
85
|
}
|
|
68
86
|
|
|
69
|
-
if ( this.overrideMaterial !==
|
|
87
|
+
if ( this.overrideMaterial !== null ) {
|
|
70
88
|
|
|
71
89
|
this.scene.overrideMaterial = oldOverrideMaterial;
|
|
72
90
|
|
|
@@ -6,14 +6,13 @@ import {
|
|
|
6
6
|
DstAlphaFactor,
|
|
7
7
|
DstColorFactor,
|
|
8
8
|
HalfFloatType,
|
|
9
|
-
MeshDepthMaterial,
|
|
10
9
|
MeshNormalMaterial,
|
|
11
10
|
NearestFilter,
|
|
12
11
|
NoBlending,
|
|
13
|
-
RGBADepthPacking,
|
|
14
12
|
ShaderMaterial,
|
|
15
13
|
UniformsUtils,
|
|
16
|
-
|
|
14
|
+
DepthStencilFormat,
|
|
15
|
+
UnsignedInt248Type,
|
|
17
16
|
Vector2,
|
|
18
17
|
WebGLRenderTarget,
|
|
19
18
|
ZeroFactor
|
|
@@ -23,7 +22,6 @@ import { SAOShader } from '../shaders/SAOShader.js';
|
|
|
23
22
|
import { DepthLimitedBlurShader } from '../shaders/DepthLimitedBlurShader.js';
|
|
24
23
|
import { BlurShaderUtils } from '../shaders/DepthLimitedBlurShader.js';
|
|
25
24
|
import { CopyShader } from '../shaders/CopyShader.js';
|
|
26
|
-
import { UnpackDepthRGBAShader } from '../shaders/UnpackDepthRGBAShader.js';
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* SAO implementation inspired from bhouston previous SAO work
|
|
@@ -31,7 +29,7 @@ import { UnpackDepthRGBAShader } from '../shaders/UnpackDepthRGBAShader.js';
|
|
|
31
29
|
|
|
32
30
|
class SAOPass extends Pass {
|
|
33
31
|
|
|
34
|
-
constructor( scene, camera,
|
|
32
|
+
constructor( scene, camera, resolution = new Vector2( 256, 256 ) ) {
|
|
35
33
|
|
|
36
34
|
super();
|
|
37
35
|
|
|
@@ -41,9 +39,6 @@ class SAOPass extends Pass {
|
|
|
41
39
|
this.clear = true;
|
|
42
40
|
this.needsSwap = false;
|
|
43
41
|
|
|
44
|
-
this.supportsDepthTextureExtension = useDepthTexture;
|
|
45
|
-
this.supportsNormalTexture = useNormals;
|
|
46
|
-
|
|
47
42
|
this.originalClearColor = new Color();
|
|
48
43
|
this._oldClearColor = new Color();
|
|
49
44
|
this.oldClearAlpha = 1;
|
|
@@ -65,30 +60,17 @@ class SAOPass extends Pass {
|
|
|
65
60
|
|
|
66
61
|
this.saoRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, { type: HalfFloatType } );
|
|
67
62
|
this.blurIntermediateRenderTarget = this.saoRenderTarget.clone();
|
|
68
|
-
|
|
63
|
+
|
|
64
|
+
const depthTexture = new DepthTexture();
|
|
65
|
+
depthTexture.format = DepthStencilFormat;
|
|
66
|
+
depthTexture.type = UnsignedInt248Type;
|
|
69
67
|
|
|
70
68
|
this.normalRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, {
|
|
71
69
|
minFilter: NearestFilter,
|
|
72
70
|
magFilter: NearestFilter,
|
|
73
|
-
type: HalfFloatType
|
|
71
|
+
type: HalfFloatType,
|
|
72
|
+
depthTexture: depthTexture
|
|
74
73
|
} );
|
|
75
|
-
this.depthRenderTarget = this.normalRenderTarget.clone();
|
|
76
|
-
|
|
77
|
-
let depthTexture;
|
|
78
|
-
|
|
79
|
-
if ( this.supportsDepthTextureExtension ) {
|
|
80
|
-
|
|
81
|
-
depthTexture = new DepthTexture();
|
|
82
|
-
depthTexture.type = UnsignedShortType;
|
|
83
|
-
|
|
84
|
-
this.beautyRenderTarget.depthTexture = depthTexture;
|
|
85
|
-
this.beautyRenderTarget.depthBuffer = true;
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
this.depthMaterial = new MeshDepthMaterial();
|
|
90
|
-
this.depthMaterial.depthPacking = RGBADepthPacking;
|
|
91
|
-
this.depthMaterial.blending = NoBlending;
|
|
92
74
|
|
|
93
75
|
this.normalMaterial = new MeshNormalMaterial();
|
|
94
76
|
this.normalMaterial.blending = NoBlending;
|
|
@@ -100,10 +82,8 @@ class SAOPass extends Pass {
|
|
|
100
82
|
uniforms: UniformsUtils.clone( SAOShader.uniforms )
|
|
101
83
|
} );
|
|
102
84
|
this.saoMaterial.extensions.derivatives = true;
|
|
103
|
-
this.saoMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1;
|
|
104
|
-
this.saoMaterial.defines[ 'NORMAL_TEXTURE' ] = this.supportsNormalTexture ? 1 : 0;
|
|
105
85
|
this.saoMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
|
|
106
|
-
this.saoMaterial.uniforms[ 'tDepth' ].value =
|
|
86
|
+
this.saoMaterial.uniforms[ 'tDepth' ].value = depthTexture;
|
|
107
87
|
this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
|
|
108
88
|
this.saoMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
|
|
109
89
|
this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
@@ -116,10 +96,10 @@ class SAOPass extends Pass {
|
|
|
116
96
|
vertexShader: DepthLimitedBlurShader.vertexShader,
|
|
117
97
|
fragmentShader: DepthLimitedBlurShader.fragmentShader
|
|
118
98
|
} );
|
|
119
|
-
this.vBlurMaterial.defines[ 'DEPTH_PACKING' ] =
|
|
99
|
+
this.vBlurMaterial.defines[ 'DEPTH_PACKING' ] = 0;
|
|
120
100
|
this.vBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
|
|
121
101
|
this.vBlurMaterial.uniforms[ 'tDiffuse' ].value = this.saoRenderTarget.texture;
|
|
122
|
-
this.vBlurMaterial.uniforms[ 'tDepth' ].value =
|
|
102
|
+
this.vBlurMaterial.uniforms[ 'tDepth' ].value = depthTexture;
|
|
123
103
|
this.vBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
|
|
124
104
|
this.vBlurMaterial.blending = NoBlending;
|
|
125
105
|
|
|
@@ -129,10 +109,10 @@ class SAOPass extends Pass {
|
|
|
129
109
|
vertexShader: DepthLimitedBlurShader.vertexShader,
|
|
130
110
|
fragmentShader: DepthLimitedBlurShader.fragmentShader
|
|
131
111
|
} );
|
|
132
|
-
this.hBlurMaterial.defines[ 'DEPTH_PACKING' ] =
|
|
112
|
+
this.hBlurMaterial.defines[ 'DEPTH_PACKING' ] = 0;
|
|
133
113
|
this.hBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
|
|
134
114
|
this.hBlurMaterial.uniforms[ 'tDiffuse' ].value = this.blurIntermediateRenderTarget.texture;
|
|
135
|
-
this.hBlurMaterial.uniforms[ 'tDepth' ].value =
|
|
115
|
+
this.hBlurMaterial.uniforms[ 'tDepth' ].value = depthTexture;
|
|
136
116
|
this.hBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y );
|
|
137
117
|
this.hBlurMaterial.blending = NoBlending;
|
|
138
118
|
|
|
@@ -153,13 +133,6 @@ class SAOPass extends Pass {
|
|
|
153
133
|
this.materialCopy.blendDstAlpha = ZeroFactor;
|
|
154
134
|
this.materialCopy.blendEquationAlpha = AddEquation;
|
|
155
135
|
|
|
156
|
-
this.depthCopy = new ShaderMaterial( {
|
|
157
|
-
uniforms: UniformsUtils.clone( UnpackDepthRGBAShader.uniforms ),
|
|
158
|
-
vertexShader: UnpackDepthRGBAShader.vertexShader,
|
|
159
|
-
fragmentShader: UnpackDepthRGBAShader.fragmentShader,
|
|
160
|
-
blending: NoBlending
|
|
161
|
-
} );
|
|
162
|
-
|
|
163
136
|
this.fsQuad = new FullScreenQuad( null );
|
|
164
137
|
|
|
165
138
|
}
|
|
@@ -176,20 +149,11 @@ class SAOPass extends Pass {
|
|
|
176
149
|
|
|
177
150
|
}
|
|
178
151
|
|
|
179
|
-
if ( this.params.output === 1 ) {
|
|
180
|
-
|
|
181
|
-
return;
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
152
|
renderer.getClearColor( this._oldClearColor );
|
|
186
153
|
this.oldClearAlpha = renderer.getClearAlpha();
|
|
187
154
|
const oldAutoClear = renderer.autoClear;
|
|
188
155
|
renderer.autoClear = false;
|
|
189
156
|
|
|
190
|
-
renderer.setRenderTarget( this.depthRenderTarget );
|
|
191
|
-
renderer.clear();
|
|
192
|
-
|
|
193
157
|
this.saoMaterial.uniforms[ 'bias' ].value = this.params.saoBias;
|
|
194
158
|
this.saoMaterial.uniforms[ 'intensity' ].value = this.params.saoIntensity;
|
|
195
159
|
this.saoMaterial.uniforms[ 'scale' ].value = this.params.saoScale;
|
|
@@ -218,26 +182,8 @@ class SAOPass extends Pass {
|
|
|
218
182
|
|
|
219
183
|
}
|
|
220
184
|
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
renderer.setRenderTarget( this.beautyRenderTarget );
|
|
224
|
-
renderer.clear();
|
|
225
|
-
renderer.render( this.scene, this.camera );
|
|
226
|
-
|
|
227
|
-
// Re-render scene if depth texture extension is not supported
|
|
228
|
-
if ( ! this.supportsDepthTextureExtension ) {
|
|
229
|
-
|
|
230
|
-
// Clear rule : far clipping plane in both RGBA and Basic encoding
|
|
231
|
-
this.renderOverride( renderer, this.depthMaterial, this.depthRenderTarget, 0x000000, 1.0 );
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if ( this.supportsNormalTexture ) {
|
|
236
|
-
|
|
237
|
-
// Clear rule : default normal is facing the camera
|
|
238
|
-
this.renderOverride( renderer, this.normalMaterial, this.normalRenderTarget, 0x7777ff, 1.0 );
|
|
239
|
-
|
|
240
|
-
}
|
|
185
|
+
// render normal and depth
|
|
186
|
+
this.renderOverride( renderer, this.normalMaterial, this.normalRenderTarget, 0x7777ff, 1.0 );
|
|
241
187
|
|
|
242
188
|
// Rendering SAO texture
|
|
243
189
|
this.renderPass( renderer, this.saoMaterial, this.saoRenderTarget, 0xffffff, 1.0 );
|
|
@@ -250,24 +196,10 @@ class SAOPass extends Pass {
|
|
|
250
196
|
|
|
251
197
|
}
|
|
252
198
|
|
|
253
|
-
|
|
254
|
-
// Setting up SAO rendering
|
|
255
|
-
if ( this.params.output === 3 ) {
|
|
256
|
-
|
|
257
|
-
if ( this.supportsDepthTextureExtension ) {
|
|
258
|
-
|
|
259
|
-
this.materialCopy.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.depthTexture;
|
|
260
|
-
this.materialCopy.needsUpdate = true;
|
|
199
|
+
const outputMaterial = this.materialCopy;
|
|
261
200
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
this.depthCopy.uniforms[ 'tDiffuse' ].value = this.depthRenderTarget.texture;
|
|
265
|
-
this.depthCopy.needsUpdate = true;
|
|
266
|
-
outputMaterial = this.depthCopy;
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
} else if ( this.params.output === 4 ) {
|
|
201
|
+
// Setting up SAO rendering
|
|
202
|
+
if ( this.params.output === SAOPass.OUTPUT.Normal ) {
|
|
271
203
|
|
|
272
204
|
this.materialCopy.uniforms[ 'tDiffuse' ].value = this.normalRenderTarget.texture;
|
|
273
205
|
this.materialCopy.needsUpdate = true;
|
|
@@ -279,8 +211,8 @@ class SAOPass extends Pass {
|
|
|
279
211
|
|
|
280
212
|
}
|
|
281
213
|
|
|
282
|
-
// Blending depends on output
|
|
283
|
-
if ( this.params.output ===
|
|
214
|
+
// Blending depends on output
|
|
215
|
+
if ( this.params.output === SAOPass.OUTPUT.Default ) {
|
|
284
216
|
|
|
285
217
|
outputMaterial.blending = CustomBlending;
|
|
286
218
|
|
|
@@ -359,11 +291,9 @@ class SAOPass extends Pass {
|
|
|
359
291
|
|
|
360
292
|
setSize( width, height ) {
|
|
361
293
|
|
|
362
|
-
this.beautyRenderTarget.setSize( width, height );
|
|
363
294
|
this.saoRenderTarget.setSize( width, height );
|
|
364
295
|
this.blurIntermediateRenderTarget.setSize( width, height );
|
|
365
296
|
this.normalRenderTarget.setSize( width, height );
|
|
366
|
-
this.depthRenderTarget.setSize( width, height );
|
|
367
297
|
|
|
368
298
|
this.saoMaterial.uniforms[ 'size' ].value.set( width, height );
|
|
369
299
|
this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
@@ -382,9 +312,7 @@ class SAOPass extends Pass {
|
|
|
382
312
|
|
|
383
313
|
this.saoRenderTarget.dispose();
|
|
384
314
|
this.blurIntermediateRenderTarget.dispose();
|
|
385
|
-
this.beautyRenderTarget.dispose();
|
|
386
315
|
this.normalRenderTarget.dispose();
|
|
387
|
-
this.depthRenderTarget.dispose();
|
|
388
316
|
|
|
389
317
|
this.depthMaterial.dispose();
|
|
390
318
|
this.normalMaterial.dispose();
|
|
@@ -392,7 +320,6 @@ class SAOPass extends Pass {
|
|
|
392
320
|
this.vBlurMaterial.dispose();
|
|
393
321
|
this.hBlurMaterial.dispose();
|
|
394
322
|
this.materialCopy.dispose();
|
|
395
|
-
this.depthCopy.dispose();
|
|
396
323
|
|
|
397
324
|
this.fsQuad.dispose();
|
|
398
325
|
|
|
@@ -401,11 +328,9 @@ class SAOPass extends Pass {
|
|
|
401
328
|
}
|
|
402
329
|
|
|
403
330
|
SAOPass.OUTPUT = {
|
|
404
|
-
'Beauty': 1,
|
|
405
331
|
'Default': 0,
|
|
406
|
-
'SAO':
|
|
407
|
-
'
|
|
408
|
-
'Normal': 4
|
|
332
|
+
'SAO': 1,
|
|
333
|
+
'Normal': 2
|
|
409
334
|
};
|
|
410
335
|
|
|
411
336
|
export { SAOPass };
|
|
@@ -32,7 +32,7 @@ import { CopyShader } from '../shaders/CopyShader.js';
|
|
|
32
32
|
|
|
33
33
|
class SSAOPass extends Pass {
|
|
34
34
|
|
|
35
|
-
constructor( scene, camera, width, height ) {
|
|
35
|
+
constructor( scene, camera, width, height, kernelSize = 32 ) {
|
|
36
36
|
|
|
37
37
|
super();
|
|
38
38
|
|
|
@@ -45,7 +45,6 @@ class SSAOPass extends Pass {
|
|
|
45
45
|
this.scene = scene;
|
|
46
46
|
|
|
47
47
|
this.kernelRadius = 8;
|
|
48
|
-
this.kernelSize = 32;
|
|
49
48
|
this.kernel = [];
|
|
50
49
|
this.noiseTexture = null;
|
|
51
50
|
this.output = 0;
|
|
@@ -57,17 +56,15 @@ class SSAOPass extends Pass {
|
|
|
57
56
|
|
|
58
57
|
//
|
|
59
58
|
|
|
60
|
-
this.generateSampleKernel();
|
|
59
|
+
this.generateSampleKernel( kernelSize );
|
|
61
60
|
this.generateRandomKernelRotations();
|
|
62
61
|
|
|
63
|
-
//
|
|
62
|
+
// depth texture
|
|
64
63
|
|
|
65
64
|
const depthTexture = new DepthTexture();
|
|
66
65
|
depthTexture.format = DepthStencilFormat;
|
|
67
66
|
depthTexture.type = UnsignedInt248Type;
|
|
68
67
|
|
|
69
|
-
this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType } );
|
|
70
|
-
|
|
71
68
|
// normal render target with depth buffer
|
|
72
69
|
|
|
73
70
|
this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
|
|
@@ -93,7 +90,8 @@ class SSAOPass extends Pass {
|
|
|
93
90
|
blending: NoBlending
|
|
94
91
|
} );
|
|
95
92
|
|
|
96
|
-
this.ssaoMaterial.
|
|
93
|
+
this.ssaoMaterial.defines[ 'KERNEL_SIZE' ] = kernelSize;
|
|
94
|
+
|
|
97
95
|
this.ssaoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
|
|
98
96
|
this.ssaoMaterial.uniforms[ 'tDepth' ].value = this.normalRenderTarget.depthTexture;
|
|
99
97
|
this.ssaoMaterial.uniforms[ 'tNoise' ].value = this.noiseTexture;
|
|
@@ -160,7 +158,6 @@ class SSAOPass extends Pass {
|
|
|
160
158
|
|
|
161
159
|
// dispose render targets
|
|
162
160
|
|
|
163
|
-
this.beautyRenderTarget.dispose();
|
|
164
161
|
this.normalRenderTarget.dispose();
|
|
165
162
|
this.ssaoRenderTarget.dispose();
|
|
166
163
|
this.blurRenderTarget.dispose();
|
|
@@ -178,16 +175,10 @@ class SSAOPass extends Pass {
|
|
|
178
175
|
|
|
179
176
|
}
|
|
180
177
|
|
|
181
|
-
render( renderer, writeBuffer /*,
|
|
178
|
+
render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
|
|
182
179
|
|
|
183
180
|
if ( renderer.capabilities.isWebGL2 === false ) this.noiseTexture.format = LuminanceFormat;
|
|
184
181
|
|
|
185
|
-
// render beauty
|
|
186
|
-
|
|
187
|
-
renderer.setRenderTarget( this.beautyRenderTarget );
|
|
188
|
-
renderer.clear();
|
|
189
|
-
renderer.render( this.scene, this.camera );
|
|
190
|
-
|
|
191
182
|
// render normals and depth (honor only meshes, points and lines do not contribute to SSAO)
|
|
192
183
|
|
|
193
184
|
this.overrideVisibility();
|
|
@@ -225,14 +216,6 @@ class SSAOPass extends Pass {
|
|
|
225
216
|
|
|
226
217
|
break;
|
|
227
218
|
|
|
228
|
-
case SSAOPass.OUTPUT.Beauty:
|
|
229
|
-
|
|
230
|
-
this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
|
|
231
|
-
this.copyMaterial.blending = NoBlending;
|
|
232
|
-
this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
|
|
233
|
-
|
|
234
|
-
break;
|
|
235
|
-
|
|
236
219
|
case SSAOPass.OUTPUT.Depth:
|
|
237
220
|
|
|
238
221
|
this.renderPass( renderer, this.depthRenderMaterial, this.renderToScreen ? null : writeBuffer );
|
|
@@ -249,7 +232,7 @@ class SSAOPass extends Pass {
|
|
|
249
232
|
|
|
250
233
|
case SSAOPass.OUTPUT.Default:
|
|
251
234
|
|
|
252
|
-
this.copyMaterial.uniforms[ 'tDiffuse' ].value =
|
|
235
|
+
this.copyMaterial.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
|
|
253
236
|
this.copyMaterial.blending = NoBlending;
|
|
254
237
|
this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
|
|
255
238
|
|
|
@@ -332,7 +315,6 @@ class SSAOPass extends Pass {
|
|
|
332
315
|
this.width = width;
|
|
333
316
|
this.height = height;
|
|
334
317
|
|
|
335
|
-
this.beautyRenderTarget.setSize( width, height );
|
|
336
318
|
this.ssaoRenderTarget.setSize( width, height );
|
|
337
319
|
this.normalRenderTarget.setSize( width, height );
|
|
338
320
|
this.blurRenderTarget.setSize( width, height );
|
|
@@ -345,9 +327,8 @@ class SSAOPass extends Pass {
|
|
|
345
327
|
|
|
346
328
|
}
|
|
347
329
|
|
|
348
|
-
generateSampleKernel() {
|
|
330
|
+
generateSampleKernel( kernelSize ) {
|
|
349
331
|
|
|
350
|
-
const kernelSize = this.kernelSize;
|
|
351
332
|
const kernel = this.kernel;
|
|
352
333
|
|
|
353
334
|
for ( let i = 0; i < kernelSize; i ++ ) {
|
|
@@ -432,9 +413,8 @@ SSAOPass.OUTPUT = {
|
|
|
432
413
|
'Default': 0,
|
|
433
414
|
'SSAO': 1,
|
|
434
415
|
'Blur': 2,
|
|
435
|
-
'
|
|
436
|
-
'
|
|
437
|
-
'Normal': 5
|
|
416
|
+
'Depth': 3,
|
|
417
|
+
'Normal': 4
|
|
438
418
|
};
|
|
439
419
|
|
|
440
420
|
export { SSAOPass };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
let vector2 = null;
|
|
2
2
|
let vector4 = null;
|
|
3
3
|
|
|
4
|
-
import { Vector2, Vector4 } from 'three';
|
|
4
|
+
import { Vector2, Vector4, REVISION, createCanvasElement } from 'three';
|
|
5
5
|
|
|
6
6
|
class Backend {
|
|
7
7
|
|
|
@@ -118,7 +118,12 @@ class Backend {
|
|
|
118
118
|
|
|
119
119
|
if ( domElement === null ) {
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
domElement = ( this.parameters.canvas !== undefined ) ? this.parameters.canvas : createCanvasElement();
|
|
122
|
+
|
|
123
|
+
// OffscreenCanvas does not have setAttribute, see #22811
|
|
124
|
+
if ( 'setAttribute' in domElement ) domElement.setAttribute( 'data-engine', `three.js r${REVISION}` );
|
|
125
|
+
|
|
126
|
+
this.domElement = domElement;
|
|
122
127
|
|
|
123
128
|
}
|
|
124
129
|
|
|
@@ -126,16 +131,14 @@ class Backend {
|
|
|
126
131
|
|
|
127
132
|
}
|
|
128
133
|
|
|
129
|
-
|
|
134
|
+
// resource properties
|
|
135
|
+
|
|
136
|
+
set( object, value ) {
|
|
130
137
|
|
|
131
|
-
|
|
132
|
-
canvas.style.display = 'block';
|
|
133
|
-
return canvas;
|
|
138
|
+
this.data.set( object, value );
|
|
134
139
|
|
|
135
140
|
}
|
|
136
141
|
|
|
137
|
-
// resource properties
|
|
138
|
-
|
|
139
142
|
get( object ) {
|
|
140
143
|
|
|
141
144
|
let map = this.data.get( object );
|
|
@@ -80,9 +80,11 @@ class Bindings extends DataMap {
|
|
|
80
80
|
|
|
81
81
|
for ( const binding of bindings ) {
|
|
82
82
|
|
|
83
|
-
if ( binding.
|
|
83
|
+
if ( binding.isSampledTexture ) {
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
const store = binding.store === true;
|
|
86
|
+
|
|
87
|
+
this.textures.updateTexture( binding.texture, { store } );
|
|
86
88
|
|
|
87
89
|
} else if ( binding.isStorageBuffer ) {
|
|
88
90
|
|
|
@@ -109,10 +111,9 @@ class Bindings extends DataMap {
|
|
|
109
111
|
|
|
110
112
|
for ( const binding of bindings ) {
|
|
111
113
|
|
|
112
|
-
const isShared = binding.isShared;
|
|
113
114
|
const isUpdated = updateMap.get( binding ) === frame;
|
|
114
115
|
|
|
115
|
-
if (
|
|
116
|
+
if ( isUpdated ) continue;
|
|
116
117
|
|
|
117
118
|
if ( binding.isUniformBuffer ) {
|
|
118
119
|
|
|
@@ -343,7 +343,7 @@ class Pipelines extends DataMap {
|
|
|
343
343
|
data.stencilWrite !== material.stencilWrite || data.stencilFunc !== material.stencilFunc ||
|
|
344
344
|
data.stencilFail !== material.stencilFail || data.stencilZFail !== material.stencilZFail || data.stencilZPass !== material.stencilZPass ||
|
|
345
345
|
data.stencilFuncMask !== material.stencilFuncMask || data.stencilWriteMask !== material.stencilWriteMask ||
|
|
346
|
-
data.side !== material.side
|
|
346
|
+
data.side !== material.side || data.alphaToCoverage !== material.alphaToCoverage
|
|
347
347
|
) {
|
|
348
348
|
|
|
349
349
|
data.material = material; data.materialVersion = material.version;
|
|
@@ -355,7 +355,7 @@ class Pipelines extends DataMap {
|
|
|
355
355
|
data.stencilWrite = material.stencilWrite; data.stencilFunc = material.stencilFunc;
|
|
356
356
|
data.stencilFail = material.stencilFail; data.stencilZFail = material.stencilZFail; data.stencilZPass = material.stencilZPass;
|
|
357
357
|
data.stencilFuncMask = material.stencilFuncMask; data.stencilWriteMask = material.stencilWriteMask;
|
|
358
|
-
data.side = material.side;
|
|
358
|
+
data.side = material.side; data.alphaToCoverage = material.alphaToCoverage;
|
|
359
359
|
|
|
360
360
|
needsUpdate = true;
|
|
361
361
|
|
|
@@ -12,7 +12,32 @@ class RenderContexts {
|
|
|
12
12
|
get( scene, camera, renderTarget = null ) {
|
|
13
13
|
|
|
14
14
|
const chainKey = [ scene, camera ];
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
let attachmentState;
|
|
17
|
+
|
|
18
|
+
if ( renderTarget === null ) {
|
|
19
|
+
|
|
20
|
+
attachmentState = 'default';
|
|
21
|
+
|
|
22
|
+
} else {
|
|
23
|
+
|
|
24
|
+
let format, count;
|
|
25
|
+
|
|
26
|
+
if ( renderTarget.isWebGLMultipleRenderTargets ) {
|
|
27
|
+
|
|
28
|
+
format = renderTarget.texture[ 0 ].format;
|
|
29
|
+
count = renderTarget.texture.length;
|
|
30
|
+
|
|
31
|
+
} else {
|
|
32
|
+
|
|
33
|
+
format = renderTarget.texture.format;
|
|
34
|
+
count = 1;
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
attachmentState = `${count}:${format}:${renderTarget.samples}:${renderTarget.depthBuffer}:${renderTarget.stencilBuffer}`;
|
|
39
|
+
|
|
40
|
+
}
|
|
16
41
|
|
|
17
42
|
const chainMap = this.getChainMap( attachmentState );
|
|
18
43
|
|