Skip to content

Commit

Permalink
Nodes: Add SSAAPassNode. (#1187)
Browse files Browse the repository at this point in the history
* Nodes: Add SSAAPassNode.

* Update three.js

* Add examples

* Update patch and delete examples
  • Loading branch information
Methuselah96 authored Aug 25, 2024
1 parent f020de2 commit 37b0597
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
41 changes: 41 additions & 0 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15120,6 +15120,47 @@ index cbc5a96b..66ec682e 100644

const params = {
enable: true,
diff --git a/examples-testing/examples/webgpu_postprocessing_ssaa.ts b/examples-testing/examples/webgpu_postprocessing_ssaa.ts
index 76e3a95c..7748d8f0 100644
--- a/examples-testing/examples/webgpu_postprocessing_ssaa.ts
+++ b/examples-testing/examples/webgpu_postprocessing_ssaa.ts
@@ -1,13 +1,13 @@
-import * as THREE from 'three';
-import { ssaaPass } from 'three/tsl';
+import * as THREE from 'three/webgpu';
+import { ssaaPass, SSAAPassNode, ShaderNodeObject } from 'three/tsl';

import { Timer } from 'three/addons/misc/Timer.js';
import Stats from 'three/addons/libs/stats.module.js';
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

-let scene, mesh, renderer, postProcessing;
-let camera, ssaaRenderPass;
-let gui, stats, timer;
+let scene: THREE.Scene, mesh: THREE.InstancedMesh, renderer: THREE.WebGPURenderer, postProcessing: THREE.PostProcessing;
+let camera: THREE.PerspectiveCamera, ssaaRenderPass: ShaderNodeObject<SSAAPassNode>;
+let gui: GUI | undefined, stats: Stats, timer: Timer;

const params = {
sampleLevel: 3,
@@ -148,7 +148,7 @@ function animate() {
mesh.rotation.y += delta * 0.5;
}

- let newColor = ssaaRenderPass.clearColor;
+ let newColor: THREE.ColorRepresentation = ssaaRenderPass.clearColor;

switch (params.clearColor) {
case 'blue':
@@ -173,7 +173,7 @@ function animate() {

ssaaRenderPass.sampleLevel = params.sampleLevel;

- camera.view.offsetX = params.viewOffsetX;
+ camera.view!.offsetX = params.viewOffsetX;

postProcessing.render();

diff --git a/examples-testing/examples/webgpu_postprocessing_transition.ts b/examples-testing/examples/webgpu_postprocessing_transition.ts
index b66bad12..babbe1a9 100644
--- a/examples-testing/examples/webgpu_postprocessing_transition.ts
Expand Down
2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 44 files
+1 −1 .github/workflows/ci.yml
+3 −3 .github/workflows/codeql-code-scanning.yml
+1 −1 .github/workflows/read-size.yml
+1 −1 docs/api/ar/audio/Audio.html
+1 −1 docs/api/en/audio/Audio.html
+1 −1 docs/api/fr/audio/Audio.html
+1 −1 docs/api/it/audio/Audio.html
+1 −1 docs/api/ko/audio/Audio.html
+1 −1 docs/api/pt-br/audio/Audio.html
+1 −1 docs/api/zh/audio/Audio.html
+7 −25 docs/examples/en/controls/ArcballControls.html
+3 −4 docs/examples/en/controls/Controls.html
+1 −1 docs/examples/en/controls/DragControls.html
+2 −32 docs/examples/en/controls/FirstPersonControls.html
+6 −32 docs/examples/en/controls/FlyControls.html
+1 −0 examples/files.json
+174 −158 examples/jsm/controls/ArcballControls.js
+1 −1 examples/jsm/controls/Controls.js
+175 −163 examples/jsm/controls/FirstPersonControls.js
+194 −188 examples/jsm/controls/FlyControls.js
+1 −1 examples/jsm/shaders/OutputShader.js
+ examples/screenshots/webgpu_postprocessing_ssaa.jpg
+1 −1 examples/webgpu_compute_texture.html
+215 −0 examples/webgpu_postprocessing_ssaa.html
+4 −0 examples/webgpu_shadowmap_opacity.html
+2 −1 src/nodes/Nodes.js
+1 −1 src/nodes/accessors/BatchNode.js
+1 −1 src/nodes/core/MRTNode.js
+1 −1 src/nodes/display/BloomNode.js
+1 −1 src/nodes/display/MotionBlurNode.js
+3 −3 src/nodes/display/RenderOutputNode.js
+267 −0 src/nodes/display/SSAAPassNode.js
+4 −4 src/nodes/display/ToneMappingNode.js
+16 −15 src/nodes/display/ViewportDepthNode.js
+19 −1 src/nodes/lighting/AnalyticLightNode.js
+13 −3 src/nodes/materials/NodeMaterial.js
+12 −2 src/nodes/math/OperatorNode.js
+2 −2 src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js
+6 −0 src/renderers/webgl-fallback/WebGLBackend.js
+1 −1 src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js
+1 −1 src/renderers/webgl/WebGLProgram.js
+13 −1 src/renderers/webgpu/WebGPUBackend.js
+1 −1 src/renderers/webgpu/nodes/WGSLNodeBuilder.js
+2 −2 src/renderers/webgpu/utils/WebGPUPipelineUtils.js
1 change: 1 addition & 0 deletions types/three/src/nodes/Nodes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export { default as RenderOutputNode, renderOutput } from "./display/RenderOutpu
export { default as RGBShiftNode, rgbShift } from "./display/RGBShiftNode.js";
export { sepia } from "./display/SepiaNode.js";
export { default as SobelOperatorNode, sobel } from "./display/SobelOperatorNode.js";
export { default as SSAAPassNode, ssaaPass } from "./display/SSAAPassNode.js";
export { default as ToneMappingNode, toneMapping } from "./display/ToneMappingNode.js";
export { default as TransitionNode, transition } from "./display/TransitionNode.js";
export {
Expand Down
3 changes: 3 additions & 0 deletions types/three/src/nodes/core/MRTNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Texture } from "../../textures/Texture.js";
import { Node } from "../Nodes.js";
import { ShaderNodeObject } from "../shadernode/ShaderNode.js";
import OutputStructNode from "./OutputStructNode.js";

export function getTextureIndex(textures: ReadonlyArray<Texture>, name: string): number;

declare class MRTNode extends OutputStructNode {
outputNodes: { [name: string]: Node };

Expand Down
26 changes: 26 additions & 0 deletions types/three/src/nodes/display/SSAAPassNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Camera } from "../../cameras/Camera.js";
import { RenderTarget } from "../../core/RenderTarget.js";
import { Color } from "../../math/Color.js";
import { Scene } from "../../scenes/Scene.js";
import UniformNode from "../core/UniformNode.js";
import { ShaderNodeObject } from "../shadernode/ShaderNode.js";
import PassNode from "./PassNode.js";

declare class SSAAPassNode extends PassNode {
readonly isSSAAPassNode: boolean;

sampleLevel: number;
unbiased: boolean;
clearColor: Color;
clearAlpha: number;

sampleWeight: UniformNode<number>;

sampleRenderTarget: RenderTarget | null;

constructor(scene: Scene, camera: Camera);
}

export const ssaaPass: (scene: Scene, camera: Camera) => ShaderNodeObject<SSAAPassNode>;

export default SSAAPassNode;

0 comments on commit 37b0597

Please sign in to comment.