@plastic-software/three 0.183.4 → 0.184.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 +773 -286
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +426 -180
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +7 -1
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2979 -1281
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2942 -1281
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +11 -0
- package/examples/jsm/animation/CCDIKSolver.js +5 -1
- package/examples/jsm/controls/ArcballControls.js +4 -1
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +2 -2
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +21 -5
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +169 -114
- package/examples/jsm/inspector/RendererInspector.js +2 -2
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +34 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +105 -3
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +273 -176
- package/examples/jsm/inspector/ui/Style.js +64 -10
- package/examples/jsm/inspector/ui/Tab.js +39 -7
- package/examples/jsm/inspector/ui/Values.js +39 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +682 -43
- package/examples/jsm/loaders/FBXLoader.js +233 -33
- package/examples/jsm/loaders/GLTFLoader.js +24 -7
- package/examples/jsm/loaders/HDRLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +8 -2
- package/examples/jsm/loaders/LDrawLoader.js +39 -47
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/VTKLoader.js +5 -1
- package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
- package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
- package/examples/jsm/loaders/usd/USDAParser.js +6 -0
- package/examples/jsm/loaders/usd/USDCParser.js +26 -0
- package/examples/jsm/loaders/usd/USDComposer.js +656 -103
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +14 -2
- package/examples/jsm/objects/SkyMesh.js +23 -6
- package/examples/jsm/renderers/Projector.js +18 -38
- package/examples/jsm/renderers/SVGRenderer.js +6 -25
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/GTAONode.js +2 -1
- package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
- package/examples/jsm/tsl/display/GodraysNode.js +2 -11
- package/examples/jsm/tsl/display/OutlineNode.js +66 -16
- package/examples/jsm/tsl/display/SSGINode.js +0 -4
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +48 -7
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +13 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +4 -4
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +6 -0
- package/src/Three.WebGPU.Nodes.js +3 -0
- package/src/Three.WebGPU.js +6 -0
- package/src/animation/AnimationAction.js +11 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/Clock.js +1 -1
- package/src/core/Object3D.js +1 -5
- package/src/core/RenderTarget.js +1 -0
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +1 -2
- package/src/loaders/ImageBitmapLoader.js +4 -6
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +25 -4
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +27 -0
- package/src/materials/nodes/NodeMaterial.js +0 -27
- package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
- package/src/math/Line3.js +3 -0
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +13 -9
- package/src/math/Plane.js +4 -3
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +12 -8
- package/src/math/Vector4.js +13 -9
- package/src/nodes/Nodes.js +0 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/BufferAttributeNode.js +9 -3
- package/src/nodes/accessors/CubeTextureNode.js +7 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/SceneProperties.js +2 -8
- package/src/nodes/accessors/StorageBufferNode.js +10 -4
- package/src/nodes/accessors/StorageTextureNode.js +4 -9
- package/src/nodes/accessors/TextureNode.js +10 -2
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +1 -1
- package/src/nodes/core/ArrayNode.js +1 -1
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/Node.js +83 -12
- package/src/nodes/core/NodeBuilder.js +117 -16
- package/src/nodes/core/NodeUtils.js +1 -1
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/ParameterNode.js +1 -1
- package/src/nodes/core/StackNode.js +1 -1
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +1 -1
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +27 -7
- package/src/nodes/display/RenderOutputNode.js +4 -4
- package/src/nodes/display/ScreenNode.js +1 -1
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +18 -7
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +69 -44
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/lighting/LightsNode.js +6 -27
- package/src/nodes/lighting/ShadowNode.js +24 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +73 -1
- package/src/nodes/math/OperatorNode.js +1 -1
- package/src/nodes/math/PackFloatNode.js +1 -1
- package/src/nodes/math/UnpackFloatNode.js +1 -1
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +21 -3
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +30 -0
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/objects/BatchedMesh.js +17 -2
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +147 -48
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +0 -8
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/BindGroup.js +1 -8
- package/src/renderers/common/Bindings.js +2 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Pipelines.js +36 -3
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +5 -2
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/RenderObjects.js +3 -3
- package/src/renderers/common/RenderPipeline.js +35 -6
- package/src/renderers/common/Renderer.js +232 -53
- package/src/renderers/common/Textures.js +72 -3
- package/src/renderers/common/UniformsGroup.js +1 -1
- package/src/renderers/common/XRManager.js +34 -27
- package/src/renderers/common/extras/PMREMGenerator.js +23 -15
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeManager.js +230 -99
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +0 -1
- package/src/renderers/shaders/UniformsLib.js +7 -2
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +13 -13
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +6 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLMaterials.js +12 -13
- package/src/renderers/webgl/WebGLOutput.js +4 -1
- package/src/renderers/webgl/WebGLProgram.js +4 -0
- package/src/renderers/webgl/WebGLPrograms.js +19 -3
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLState.js +43 -0
- package/src/renderers/webgl/WebGLTextures.js +129 -26
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +160 -146
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +13 -2
- package/src/utils.js +23 -1
- package/src/nodes/utils/RemapNode.js +0 -125
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TempNode } from 'three/webgpu';
|
|
2
2
|
import {
|
|
3
3
|
nodeObject,
|
|
4
4
|
Fn,
|
|
5
|
-
uniform,
|
|
6
5
|
convertToTexture,
|
|
7
6
|
float,
|
|
8
7
|
vec4,
|
|
9
8
|
uv,
|
|
10
|
-
NodeUpdateType,
|
|
11
9
|
} from 'three/tsl';
|
|
12
10
|
|
|
13
11
|
/**
|
|
@@ -45,15 +43,6 @@ class ChromaticAberrationNode extends TempNode {
|
|
|
45
43
|
*/
|
|
46
44
|
this.textureNode = textureNode;
|
|
47
45
|
|
|
48
|
-
/**
|
|
49
|
-
* The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node updates
|
|
50
|
-
* its internal uniforms once per frame in `updateBefore()`.
|
|
51
|
-
*
|
|
52
|
-
* @type {string}
|
|
53
|
-
* @default 'frame'
|
|
54
|
-
*/
|
|
55
|
-
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
56
|
-
|
|
57
46
|
/**
|
|
58
47
|
* A node holding the strength of the effect.
|
|
59
48
|
*
|
|
@@ -75,26 +64,6 @@ class ChromaticAberrationNode extends TempNode {
|
|
|
75
64
|
*/
|
|
76
65
|
this.scaleNode = scaleNode;
|
|
77
66
|
|
|
78
|
-
/**
|
|
79
|
-
* A uniform node holding the inverse resolution value.
|
|
80
|
-
*
|
|
81
|
-
* @private
|
|
82
|
-
* @type {UniformNode<vec2>}
|
|
83
|
-
*/
|
|
84
|
-
this._invSize = uniform( new Vector2() );
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* This method is used to update the effect's uniforms once per frame.
|
|
90
|
-
*
|
|
91
|
-
* @param {NodeFrame} frame - The current node frame.
|
|
92
|
-
*/
|
|
93
|
-
updateBefore( /* frame */ ) {
|
|
94
|
-
|
|
95
|
-
const map = this.textureNode.value;
|
|
96
|
-
this._invSize.value.set( 1 / map.image.width, 1 / map.image.height );
|
|
97
|
-
|
|
98
67
|
}
|
|
99
68
|
|
|
100
69
|
/**
|
|
@@ -155,8 +124,7 @@ class ChromaticAberrationNode extends TempNode {
|
|
|
155
124
|
{ name: 'uv', type: 'vec2' },
|
|
156
125
|
{ name: 'strength', type: 'float' },
|
|
157
126
|
{ name: 'center', type: 'vec2' },
|
|
158
|
-
{ name: 'scale', type: 'float' }
|
|
159
|
-
{ name: 'invSize', type: 'vec2' }
|
|
127
|
+
{ name: 'scale', type: 'float' }
|
|
160
128
|
]
|
|
161
129
|
} );
|
|
162
130
|
|
|
@@ -166,8 +134,7 @@ class ChromaticAberrationNode extends TempNode {
|
|
|
166
134
|
uvNode,
|
|
167
135
|
this.strengthNode,
|
|
168
136
|
this.centerNode,
|
|
169
|
-
this.scaleNode
|
|
170
|
-
this._invSize
|
|
137
|
+
this.scaleNode
|
|
171
138
|
);
|
|
172
139
|
|
|
173
140
|
} );
|
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { HalfFloatType, RenderTarget, Vector2, NodeMaterial, RendererUtils, QuadMesh, TempNode, NodeUpdateType } from 'three/webgpu';
|
|
2
|
+
import { Fn, float, vec2, vec3, vec4, ivec2, int, uv, floor, fract, abs, max, min, clamp, saturate, sqrt, select, exp2, nodeObject, passTexture, textureSize, textureLoad, convertToTexture } from 'three/tsl';
|
|
3
|
+
|
|
4
|
+
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
|
+
const _size = /*@__PURE__*/ new Vector2();
|
|
6
|
+
|
|
7
|
+
let _rendererState;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Post processing node for applying AMD FidelityFX Super Resolution 1 (FSR 1).
|
|
11
|
+
*
|
|
12
|
+
* Combines two passes:
|
|
13
|
+
* - **EASU** (Edge-Adaptive Spatial Upsampling): Uses 12 texture samples in a cross pattern
|
|
14
|
+
* to detect local edge direction, then shapes an approximate Lanczos2 kernel into an
|
|
15
|
+
* ellipse aligned with the detected edge.
|
|
16
|
+
* - **RCAS** (Robust Contrast-Adaptive Sharpening): Uses a 5-tap cross pattern to apply
|
|
17
|
+
* contrast-aware sharpening that is automatically limited per-pixel to avoid artifacts.
|
|
18
|
+
*
|
|
19
|
+
* Note: Only use FSR 1 if your application is fragment-shader bound and cannot afford to render
|
|
20
|
+
* at full resolution. FSR 1 adds its own overhead, so simply shaded scenes will render faster
|
|
21
|
+
* at native resolution without it. Besides, FSR 1 should always be used with an anti-aliased
|
|
22
|
+
* source image.
|
|
23
|
+
*
|
|
24
|
+
* Reference: {@link https://gpuopen.com/fidelityfx-superresolution/}.
|
|
25
|
+
*
|
|
26
|
+
* @augments TempNode
|
|
27
|
+
* @three_import import { fsr1 } from 'three/addons/tsl/display/fsr1/FSR1Node.js';
|
|
28
|
+
*/
|
|
29
|
+
class FSR1Node extends TempNode {
|
|
30
|
+
|
|
31
|
+
static get type() {
|
|
32
|
+
|
|
33
|
+
return 'FSR1Node';
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Constructs a new FSR 1 node.
|
|
39
|
+
*
|
|
40
|
+
* @param {TextureNode} textureNode - The texture node that represents the input of the effect.
|
|
41
|
+
* @param {Node<float>} [sharpness=0.2] - RCAS sharpening strength. 0 = maximum sharpening, 2 = no sharpening.
|
|
42
|
+
* @param {Node<bool>} [denoise=false] - Whether to attenuate RCAS sharpening in noisy areas.
|
|
43
|
+
*/
|
|
44
|
+
constructor( textureNode, sharpness = 0.2, denoise = false ) {
|
|
45
|
+
|
|
46
|
+
super( 'vec4' );
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The texture node that represents the input of the effect.
|
|
50
|
+
*
|
|
51
|
+
* @type {TextureNode}
|
|
52
|
+
*/
|
|
53
|
+
this.textureNode = textureNode;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* RCAS sharpening strength. 0 = maximum, 2 = none.
|
|
57
|
+
*
|
|
58
|
+
* @type {Node<float>}
|
|
59
|
+
*/
|
|
60
|
+
this.sharpness = nodeObject( sharpness );
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Whether to attenuate RCAS sharpening in noisy areas.
|
|
64
|
+
*
|
|
65
|
+
* @type {Node<bool>}
|
|
66
|
+
*/
|
|
67
|
+
this.denoise = nodeObject( denoise );
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The render target for the EASU upscale pass.
|
|
71
|
+
*
|
|
72
|
+
* @private
|
|
73
|
+
* @type {RenderTarget}
|
|
74
|
+
*/
|
|
75
|
+
this._easuRT = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );
|
|
76
|
+
this._easuRT.texture.name = 'FSR1Node.easu';
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The render target for the RCAS sharpen pass.
|
|
80
|
+
*
|
|
81
|
+
* @private
|
|
82
|
+
* @type {RenderTarget}
|
|
83
|
+
*/
|
|
84
|
+
this._rcasRT = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );
|
|
85
|
+
this._rcasRT.texture.name = 'FSR1Node.rcas';
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The result of the effect as a texture node.
|
|
89
|
+
*
|
|
90
|
+
* @private
|
|
91
|
+
* @type {PassTextureNode}
|
|
92
|
+
*/
|
|
93
|
+
this._textureNode = passTexture( this, this._rcasRT.texture );
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The material for the EASU pass.
|
|
97
|
+
*
|
|
98
|
+
* @private
|
|
99
|
+
* @type {?NodeMaterial}
|
|
100
|
+
*/
|
|
101
|
+
this._easuMaterial = null;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The material for the RCAS pass.
|
|
105
|
+
*
|
|
106
|
+
* @private
|
|
107
|
+
* @type {?NodeMaterial}
|
|
108
|
+
*/
|
|
109
|
+
this._rcasMaterial = null;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders
|
|
113
|
+
* its effect once per frame in `updateBefore()`.
|
|
114
|
+
*
|
|
115
|
+
* @type {string}
|
|
116
|
+
* @default 'frame'
|
|
117
|
+
*/
|
|
118
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Sets the output size of the effect.
|
|
124
|
+
*
|
|
125
|
+
* @param {number} width - The width in pixels.
|
|
126
|
+
* @param {number} height - The height in pixels.
|
|
127
|
+
*/
|
|
128
|
+
setSize( width, height ) {
|
|
129
|
+
|
|
130
|
+
this._easuRT.setSize( width, height );
|
|
131
|
+
this._rcasRT.setSize( width, height );
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* This method is used to render the effect once per frame.
|
|
137
|
+
*
|
|
138
|
+
* @param {NodeFrame} frame - The current node frame.
|
|
139
|
+
*/
|
|
140
|
+
updateBefore( frame ) {
|
|
141
|
+
|
|
142
|
+
const { renderer } = frame;
|
|
143
|
+
|
|
144
|
+
_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );
|
|
145
|
+
|
|
146
|
+
//
|
|
147
|
+
|
|
148
|
+
renderer.getDrawingBufferSize( _size );
|
|
149
|
+
this.setSize( _size.x, _size.y );
|
|
150
|
+
|
|
151
|
+
// EASU pass
|
|
152
|
+
|
|
153
|
+
renderer.setRenderTarget( this._easuRT );
|
|
154
|
+
|
|
155
|
+
_quadMesh.material = this._easuMaterial;
|
|
156
|
+
_quadMesh.name = 'FSR1 [ EASU Pass ]';
|
|
157
|
+
_quadMesh.render( renderer );
|
|
158
|
+
|
|
159
|
+
// RCAS pass
|
|
160
|
+
|
|
161
|
+
renderer.setRenderTarget( this._rcasRT );
|
|
162
|
+
|
|
163
|
+
_quadMesh.material = this._rcasMaterial;
|
|
164
|
+
_quadMesh.name = 'FSR1 [ RCAS Pass ]';
|
|
165
|
+
_quadMesh.render( renderer );
|
|
166
|
+
|
|
167
|
+
//
|
|
168
|
+
|
|
169
|
+
RendererUtils.restoreRendererState( renderer, _rendererState );
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Returns the result of the effect as a texture node.
|
|
175
|
+
*
|
|
176
|
+
* @return {PassTextureNode} A texture node that represents the result of the effect.
|
|
177
|
+
*/
|
|
178
|
+
getTextureNode() {
|
|
179
|
+
|
|
180
|
+
return this._textureNode;
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* This method is used to setup the effect's TSL code.
|
|
186
|
+
*
|
|
187
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
188
|
+
* @return {PassTextureNode}
|
|
189
|
+
*/
|
|
190
|
+
setup( builder ) {
|
|
191
|
+
|
|
192
|
+
const textureNode = this.textureNode;
|
|
193
|
+
const inputTex = textureNode.value;
|
|
194
|
+
|
|
195
|
+
// Note on performance: Compared to the orginal FSR1 code, texture sampling does
|
|
196
|
+
// not make use of textureGather() yet. This is only available with WebGPU so the
|
|
197
|
+
// WebGL 2 backend needs a fallback. Besides, in WebGPU and WebGL 2 we also
|
|
198
|
+
// can't make use of packed math (e.g. FP16) which would considerably lower
|
|
199
|
+
// the arithmetic costs (e.g. two 16-bit ops in parallel).
|
|
200
|
+
|
|
201
|
+
// Accumulate edge direction and length for one bilinear quadrant.
|
|
202
|
+
|
|
203
|
+
const _accumulateEdge = ( dir, len, w, aL, bL, cL, dL, eL ) => {
|
|
204
|
+
|
|
205
|
+
const dc = dL.sub( cL ).toConst();
|
|
206
|
+
const cb = cL.sub( bL ).toConst();
|
|
207
|
+
const dirX = dL.sub( bL ).toConst();
|
|
208
|
+
const lenX = max( abs( dc ), abs( cb ) ).toConst();
|
|
209
|
+
const sLenX = saturate( abs( dirX ).div( max( lenX, float( 1.0 / 65536.0 ) ) ) ).toConst();
|
|
210
|
+
|
|
211
|
+
dir.x.addAssign( dirX.mul( w ) );
|
|
212
|
+
len.addAssign( sLenX.mul( sLenX ).mul( w ) );
|
|
213
|
+
|
|
214
|
+
const ec = eL.sub( cL ).toConst();
|
|
215
|
+
const ca = cL.sub( aL ).toConst();
|
|
216
|
+
const dirY = eL.sub( aL ).toConst();
|
|
217
|
+
const lenY = max( abs( ec ), abs( ca ) ).toConst();
|
|
218
|
+
const sLenY = saturate( abs( dirY ).div( max( lenY, float( 1.0 / 65536.0 ) ) ) ).toConst();
|
|
219
|
+
|
|
220
|
+
dir.y.addAssign( dirY.mul( w ) );
|
|
221
|
+
len.addAssign( sLenY.mul( sLenY ).mul( w ) );
|
|
222
|
+
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// Compute an approximate Lanczos2 tap weight and accumulate.
|
|
226
|
+
|
|
227
|
+
const _accumulateTap = ( aC, aW, offset, dir, len2, lob, clp, color ) => {
|
|
228
|
+
|
|
229
|
+
const vx = offset.x.mul( dir.x ).add( offset.y.mul( dir.y ) ).toConst();
|
|
230
|
+
const vy = offset.x.mul( dir.y ).negate().add( offset.y.mul( dir.x ) ).toConst();
|
|
231
|
+
|
|
232
|
+
const sx = vx.mul( len2.x ).toConst();
|
|
233
|
+
const sy = vy.mul( len2.y ).toConst();
|
|
234
|
+
const d2 = min( sx.mul( sx ).add( sy.mul( sy ) ), clp ).toConst();
|
|
235
|
+
|
|
236
|
+
const wB = d2.mul( 2.0 / 5.0 ).sub( 1.0 ).toConst();
|
|
237
|
+
const wA = d2.mul( lob ).sub( 1.0 ).toConst();
|
|
238
|
+
const w = wB.mul( wB ).mul( 25.0 / 16.0 ).sub( 25.0 / 16.0 - 1.0 ).mul( wA.mul( wA ) ).toConst();
|
|
239
|
+
|
|
240
|
+
aC.addAssign( color.mul( w ) );
|
|
241
|
+
aW.addAssign( w );
|
|
242
|
+
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// EASU pass: edge-adaptive spatial upsampling.
|
|
246
|
+
|
|
247
|
+
const easu = Fn( () => {
|
|
248
|
+
|
|
249
|
+
const targetUV = uv();
|
|
250
|
+
const texSize = vec2( textureSize( textureNode ) );
|
|
251
|
+
|
|
252
|
+
const pp = targetUV.mul( texSize ).sub( 0.5 ).toConst();
|
|
253
|
+
const fp = floor( pp ).toConst();
|
|
254
|
+
const f = fract( pp ).toConst();
|
|
255
|
+
|
|
256
|
+
// Fetch exact texel values at integer coordinates (no filtering).
|
|
257
|
+
|
|
258
|
+
const ifp = ivec2( int( fp.x ), int( fp.y ) ).toConst();
|
|
259
|
+
const tap = ( dx, dy ) => textureLoad( inputTex, ifp.add( ivec2( dx, dy ) ) );
|
|
260
|
+
|
|
261
|
+
// 12-tap cross pattern:
|
|
262
|
+
// b c
|
|
263
|
+
// e f g h
|
|
264
|
+
// i j k l
|
|
265
|
+
// n o
|
|
266
|
+
|
|
267
|
+
const sB = tap( 0, - 1 ), sC = tap( 1, - 1 );
|
|
268
|
+
const sE = tap( - 1, 0 ), sF = tap( 0, 0 ), sG = tap( 1, 0 ), sH = tap( 2, 0 );
|
|
269
|
+
const sI = tap( - 1, 1 ), sJ = tap( 0, 1 ), sK = tap( 1, 1 ), sL = tap( 2, 1 );
|
|
270
|
+
const sN = tap( 0, 2 ), sO = tap( 1, 2 );
|
|
271
|
+
|
|
272
|
+
// Approximate luminance for edge detection.
|
|
273
|
+
|
|
274
|
+
const luma = ( s ) => s.r.mul( 0.5 ).add( s.g ).add( s.b.mul( 0.5 ) );
|
|
275
|
+
|
|
276
|
+
const bL = luma( sB ), cL = luma( sC );
|
|
277
|
+
const eL = luma( sE ), fL = luma( sF ), gL = luma( sG ), hL = luma( sH );
|
|
278
|
+
const iL = luma( sI ), jL = luma( sJ ), kL = luma( sK ), lL = luma( sL );
|
|
279
|
+
const nL = luma( sN ), oL = luma( sO );
|
|
280
|
+
|
|
281
|
+
// Accumulate edge direction and length from 4 bilinear quadrants.
|
|
282
|
+
|
|
283
|
+
const dir = vec2( 0 ).toVar();
|
|
284
|
+
const len = float( 0 ).toVar();
|
|
285
|
+
|
|
286
|
+
const w0 = float( 1 ).sub( f.x ).mul( float( 1 ).sub( f.y ) ).toConst();
|
|
287
|
+
const w1 = f.x.mul( float( 1 ).sub( f.y ) ).toConst();
|
|
288
|
+
const w2 = float( 1 ).sub( f.x ).mul( f.y ).toConst();
|
|
289
|
+
const w3 = f.x.mul( f.y ).toConst();
|
|
290
|
+
|
|
291
|
+
_accumulateEdge( dir, len, w0, bL, eL, fL, gL, jL );
|
|
292
|
+
_accumulateEdge( dir, len, w1, cL, fL, gL, hL, kL );
|
|
293
|
+
_accumulateEdge( dir, len, w2, fL, iL, jL, kL, nL );
|
|
294
|
+
_accumulateEdge( dir, len, w3, gL, jL, kL, lL, oL );
|
|
295
|
+
|
|
296
|
+
// Normalize direction, defaulting to (1, 0) when gradient is negligible.
|
|
297
|
+
|
|
298
|
+
const dirSq = dir.x.mul( dir.x ).add( dir.y.mul( dir.y ) ).toConst();
|
|
299
|
+
const zro = dirSq.lessThan( 1.0 / 32768.0 ).toConst();
|
|
300
|
+
const rDirLen = float( 1.0 ).div( sqrt( max( dirSq, float( 1.0 / 32768.0 ) ) ) ).toConst();
|
|
301
|
+
|
|
302
|
+
dir.x.assign( select( zro, float( 1.0 ), dir.x ) );
|
|
303
|
+
dir.mulAssign( select( zro, float( 1.0 ), rDirLen ) );
|
|
304
|
+
|
|
305
|
+
// Shape the kernel based on edge strength.
|
|
306
|
+
|
|
307
|
+
len.assign( len.mul( 0.5 ) );
|
|
308
|
+
len.mulAssign( len );
|
|
309
|
+
|
|
310
|
+
// Stretch factor: 1.0 for axis-aligned edges, sqrt(2) on diagonals.
|
|
311
|
+
|
|
312
|
+
const stretch = dir.x.mul( dir.x ).add( dir.y.mul( dir.y ) ).div( max( abs( dir.x ), abs( dir.y ) ) ).toConst();
|
|
313
|
+
|
|
314
|
+
// Anisotropic lengths: x stretches along edge, y shrinks perpendicular.
|
|
315
|
+
|
|
316
|
+
const len2 = vec2(
|
|
317
|
+
float( 1.0 ).add( stretch.sub( 1.0 ).mul( len ) ),
|
|
318
|
+
float( 1.0 ).sub( len.mul( 0.5 ) )
|
|
319
|
+
).toConst();
|
|
320
|
+
|
|
321
|
+
// Negative lobe: strong on flat areas (0.5), reduced on edges (0.21).
|
|
322
|
+
|
|
323
|
+
const lob = float( 0.5 ).add( float( 1.0 / 4.0 - 0.04 - 0.5 ).mul( len ) ).toConst();
|
|
324
|
+
const clp = float( 1.0 ).div( lob ).toConst();
|
|
325
|
+
|
|
326
|
+
// Accumulate weighted taps.
|
|
327
|
+
|
|
328
|
+
const aC = vec4( 0 ).toVar();
|
|
329
|
+
const aW = float( 0 ).toVar();
|
|
330
|
+
|
|
331
|
+
_accumulateTap( aC, aW, vec2( 0, - 1 ).sub( f ), dir, len2, lob, clp, sB );
|
|
332
|
+
_accumulateTap( aC, aW, vec2( 1, - 1 ).sub( f ), dir, len2, lob, clp, sC );
|
|
333
|
+
_accumulateTap( aC, aW, vec2( - 1, 0 ).sub( f ), dir, len2, lob, clp, sE );
|
|
334
|
+
_accumulateTap( aC, aW, vec2( 0, 0 ).sub( f ), dir, len2, lob, clp, sF );
|
|
335
|
+
_accumulateTap( aC, aW, vec2( 1, 0 ).sub( f ), dir, len2, lob, clp, sG );
|
|
336
|
+
_accumulateTap( aC, aW, vec2( 2, 0 ).sub( f ), dir, len2, lob, clp, sH );
|
|
337
|
+
_accumulateTap( aC, aW, vec2( - 1, 1 ).sub( f ), dir, len2, lob, clp, sI );
|
|
338
|
+
_accumulateTap( aC, aW, vec2( 0, 1 ).sub( f ), dir, len2, lob, clp, sJ );
|
|
339
|
+
_accumulateTap( aC, aW, vec2( 1, 1 ).sub( f ), dir, len2, lob, clp, sK );
|
|
340
|
+
_accumulateTap( aC, aW, vec2( 2, 1 ).sub( f ), dir, len2, lob, clp, sL );
|
|
341
|
+
_accumulateTap( aC, aW, vec2( 0, 2 ).sub( f ), dir, len2, lob, clp, sN );
|
|
342
|
+
_accumulateTap( aC, aW, vec2( 1, 2 ).sub( f ), dir, len2, lob, clp, sO );
|
|
343
|
+
|
|
344
|
+
// Normalize.
|
|
345
|
+
|
|
346
|
+
aC.divAssign( aW );
|
|
347
|
+
|
|
348
|
+
// Anti-ringing: clamp to min/max of the 4 nearest samples (f, g, j, k).
|
|
349
|
+
|
|
350
|
+
const min4 = min( min( sF, sG ), min( sJ, sK ) ).toConst();
|
|
351
|
+
const max4 = max( max( sF, sG ), max( sJ, sK ) ).toConst();
|
|
352
|
+
|
|
353
|
+
return clamp( aC, min4, max4 );
|
|
354
|
+
|
|
355
|
+
} );
|
|
356
|
+
|
|
357
|
+
// RCAS pass: robust contrast-adaptive sharpening.
|
|
358
|
+
|
|
359
|
+
const easuTex = this._easuRT.texture;
|
|
360
|
+
|
|
361
|
+
const rcas = Fn( () => {
|
|
362
|
+
|
|
363
|
+
const targetUV = uv();
|
|
364
|
+
const texSize = vec2( textureSize( textureLoad( easuTex ) ) );
|
|
365
|
+
|
|
366
|
+
const p = ivec2( int( floor( targetUV.x.mul( texSize.x ) ) ), int( floor( targetUV.y.mul( texSize.y ) ) ) ).toConst();
|
|
367
|
+
|
|
368
|
+
const e = textureLoad( easuTex, p );
|
|
369
|
+
const b = textureLoad( easuTex, p.add( ivec2( 0, - 1 ) ) );
|
|
370
|
+
const d = textureLoad( easuTex, p.add( ivec2( - 1, 0 ) ) );
|
|
371
|
+
const f = textureLoad( easuTex, p.add( ivec2( 1, 0 ) ) );
|
|
372
|
+
const h = textureLoad( easuTex, p.add( ivec2( 0, 1 ) ) );
|
|
373
|
+
|
|
374
|
+
// Approximate luminance (luma times 2).
|
|
375
|
+
|
|
376
|
+
const luma = ( s ) => s.g.add( s.b.add( s.r ).mul( 0.5 ) );
|
|
377
|
+
|
|
378
|
+
const bL = luma( b );
|
|
379
|
+
const dL = luma( d );
|
|
380
|
+
const eL = luma( e );
|
|
381
|
+
const fL = luma( f );
|
|
382
|
+
const hL = luma( h );
|
|
383
|
+
|
|
384
|
+
// Sharpening amount from user parameter.
|
|
385
|
+
|
|
386
|
+
const con = exp2( this.sharpness.negate() ).toConst();
|
|
387
|
+
|
|
388
|
+
// Min and max of ring.
|
|
389
|
+
|
|
390
|
+
const mn4 = min( min( b.rgb, d.rgb ), min( f.rgb, h.rgb ) ).toConst();
|
|
391
|
+
const mx4 = max( max( b.rgb, d.rgb ), max( f.rgb, h.rgb ) ).toConst();
|
|
392
|
+
|
|
393
|
+
// Compute adaptive lobe weight.
|
|
394
|
+
// Limiters based on how much sharpening the local contrast can tolerate.
|
|
395
|
+
|
|
396
|
+
const RCAS_LIMIT = float( 0.25 - 1.0 / 16.0 ).toConst();
|
|
397
|
+
|
|
398
|
+
const hitMin = min( mn4, e.rgb ).div( mx4.mul( 4.0 ) ).toConst();
|
|
399
|
+
const hitMax = vec3( 1.0 ).sub( max( mx4, e.rgb ) ).div( mn4.mul( 4.0 ).sub( 4.0 ) ).toConst();
|
|
400
|
+
const lobeRGB = max( hitMin.negate(), hitMax ).toConst();
|
|
401
|
+
|
|
402
|
+
const lobe = max(
|
|
403
|
+
RCAS_LIMIT.negate(),
|
|
404
|
+
min( max( lobeRGB.r, max( lobeRGB.g, lobeRGB.b ) ), float( 0.0 ) )
|
|
405
|
+
).mul( con ).toConst();
|
|
406
|
+
|
|
407
|
+
// Noise attenuation.
|
|
408
|
+
|
|
409
|
+
const nz = bL.add( dL ).add( fL ).add( hL ).mul( 0.25 ).sub( eL ).toConst();
|
|
410
|
+
const nzRange = max( max( bL, dL ), max( eL, max( fL, hL ) ) ).sub( min( min( bL, dL ), min( eL, min( fL, hL ) ) ) ).toConst();
|
|
411
|
+
const nzFactor = float( 1.0 ).sub( abs( nz ).div( max( nzRange, float( 1.0 / 65536.0 ) ) ).saturate().mul( 0.5 ) ).toConst();
|
|
412
|
+
|
|
413
|
+
const effectiveLobe = this.denoise.equal( true ).select( lobe.mul( nzFactor ), lobe ).toConst();
|
|
414
|
+
|
|
415
|
+
// Resolve: weighted blend of cross neighbors and center.
|
|
416
|
+
|
|
417
|
+
const result = b.rgb.add( d.rgb ).add( f.rgb ).add( h.rgb ).mul( effectiveLobe ).add( e.rgb )
|
|
418
|
+
.div( effectiveLobe.mul( 4.0 ).add( 1.0 ) ).toConst();
|
|
419
|
+
|
|
420
|
+
return vec4( result, e.a );
|
|
421
|
+
|
|
422
|
+
} );
|
|
423
|
+
|
|
424
|
+
//
|
|
425
|
+
|
|
426
|
+
const context = builder.getSharedContext();
|
|
427
|
+
|
|
428
|
+
const easuMaterial = this._easuMaterial || ( this._easuMaterial = new NodeMaterial() );
|
|
429
|
+
easuMaterial.fragmentNode = easu().context( context );
|
|
430
|
+
easuMaterial.name = 'FSR1_EASU';
|
|
431
|
+
easuMaterial.needsUpdate = true;
|
|
432
|
+
|
|
433
|
+
const rcasMaterial = this._rcasMaterial || ( this._rcasMaterial = new NodeMaterial() );
|
|
434
|
+
rcasMaterial.fragmentNode = rcas().context( context );
|
|
435
|
+
rcasMaterial.name = 'FSR1_RCAS';
|
|
436
|
+
rcasMaterial.needsUpdate = true;
|
|
437
|
+
|
|
438
|
+
//
|
|
439
|
+
|
|
440
|
+
const properties = builder.getNodeProperties( this );
|
|
441
|
+
properties.textureNode = textureNode;
|
|
442
|
+
|
|
443
|
+
//
|
|
444
|
+
|
|
445
|
+
return this._textureNode;
|
|
446
|
+
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Frees internal resources. This method should be called
|
|
451
|
+
* when the effect is no longer required.
|
|
452
|
+
*/
|
|
453
|
+
dispose() {
|
|
454
|
+
|
|
455
|
+
this._easuRT.dispose();
|
|
456
|
+
this._rcasRT.dispose();
|
|
457
|
+
|
|
458
|
+
if ( this._easuMaterial !== null ) this._easuMaterial.dispose();
|
|
459
|
+
if ( this._rcasMaterial !== null ) this._rcasMaterial.dispose();
|
|
460
|
+
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export default FSR1Node;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* TSL function for creating an FSR 1 node for post processing.
|
|
469
|
+
*
|
|
470
|
+
* @tsl
|
|
471
|
+
* @function
|
|
472
|
+
* @param {Node<vec4>} node - The node that represents the input of the effect.
|
|
473
|
+
* @param {(number|Node<float>)} [sharpness=0.2] - RCAS sharpening strength. 0 = maximum, 2 = none.
|
|
474
|
+
* @param {(boolean|Node<bool>)} [denoise=false] - Whether to attenuate RCAS sharpening in noisy areas.
|
|
475
|
+
* @returns {FSR1Node}
|
|
476
|
+
*/
|
|
477
|
+
export const fsr1 = ( node, sharpness, denoise ) => new FSR1Node( convertToTexture( node ), sharpness, denoise );
|
|
@@ -25,8 +25,9 @@ let _rendererState;
|
|
|
25
25
|
* const scenePassDepth = scenePass.getTextureNode( 'depth' );
|
|
26
26
|
*
|
|
27
27
|
* const aoPass = ao( scenePassDepth, scenePassNormal, camera );
|
|
28
|
+
* const aoPassOutput = aoPass.getTextureNode();
|
|
28
29
|
*
|
|
29
|
-
* renderPipeline.outputNode =
|
|
30
|
+
* renderPipeline.outputNode = scenePassColor.mul( vec4( vec3( aoPassOutput.r ), 1 ) );
|
|
30
31
|
* ```
|
|
31
32
|
*
|
|
32
33
|
* Reference: [Practical Real-Time Strategies for Accurate Indirect Occlusion](https://www.activision.com/cdn/research/Practical_Real_Time_Strategies_for_Accurate_Indirect_Occlusion_NEW%20VERSION_COLOR.pdf).
|
|
@@ -98,6 +98,14 @@ class GaussianBlurNode extends TempNode {
|
|
|
98
98
|
this._textureNode = passTexture( this, this._verticalRT.texture );
|
|
99
99
|
this._textureNode.uvNode = textureNode.uvNode;
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* The material for the blur pass.
|
|
103
|
+
*
|
|
104
|
+
* @private
|
|
105
|
+
* @type {?NodeMaterial}
|
|
106
|
+
*/
|
|
107
|
+
this._material = null;
|
|
108
|
+
|
|
101
109
|
/**
|
|
102
110
|
* The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders
|
|
103
111
|
* its effect once per frame in `updateBefore()`.
|
|
@@ -303,6 +311,8 @@ class GaussianBlurNode extends TempNode {
|
|
|
303
311
|
this._horizontalRT.dispose();
|
|
304
312
|
this._verticalRT.dispose();
|
|
305
313
|
|
|
314
|
+
if ( this._material !== null ) this._material.dispose();
|
|
315
|
+
|
|
306
316
|
}
|
|
307
317
|
|
|
308
318
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Frustum, Matrix4, RenderTarget, Vector2, RendererUtils, QuadMesh, TempNode, NodeMaterial, NodeUpdateType, Vector3, Plane
|
|
1
|
+
import { Frustum, Matrix4, RenderTarget, Vector2, RendererUtils, QuadMesh, TempNode, NodeMaterial, NodeUpdateType, Vector3, Plane } from 'three/webgpu';
|
|
2
2
|
import { cubeTexture, clamp, viewZToPerspectiveDepth, logarithmicDepthToViewZ, float, Loop, max, Fn, passTexture, uv, dot, uniformArray, If, getViewPosition, uniform, vec4, add, interleavedGradientNoise, screenCoordinate, round, mul, uint, mix, exp, vec3, distance, pow, reference, lightPosition, vec2, bool, texture, perspectiveDepthToViewZ, lightShadowMatrix } from 'three/tsl';
|
|
3
3
|
|
|
4
4
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
@@ -351,8 +351,6 @@ class GodraysNode extends TempNode {
|
|
|
351
351
|
*/
|
|
352
352
|
setup( builder ) {
|
|
353
353
|
|
|
354
|
-
const { renderer } = builder;
|
|
355
|
-
|
|
356
354
|
const uvNode = uv();
|
|
357
355
|
const lightPos = lightPosition( this._light );
|
|
358
356
|
|
|
@@ -389,15 +387,8 @@ class GodraysNode extends TempNode {
|
|
|
389
387
|
|
|
390
388
|
const shadowPosition = lightShadowMatrix( this._light ).mul( worldPos );
|
|
391
389
|
const shadowCoord = shadowPosition.xyz.div( shadowPosition.w );
|
|
392
|
-
let coordZ = shadowCoord.z;
|
|
393
|
-
|
|
394
|
-
if ( renderer.coordinateSystem === WebGPUCoordinateSystem ) {
|
|
395
|
-
|
|
396
|
-
coordZ = coordZ.mul( 2 ).sub( 1 ); // WebGPU: Conversion [ 0, 1 ] to [ - 1, 1 ]
|
|
397
|
-
|
|
398
|
-
}
|
|
399
390
|
|
|
400
|
-
return vec3( shadowCoord.x, shadowCoord.y.oneMinus(),
|
|
391
|
+
return vec3( shadowCoord.x, shadowCoord.y.oneMinus(), shadowCoord.z );
|
|
401
392
|
|
|
402
393
|
};
|
|
403
394
|
|