Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPURenderer: Apply fog before tonemapping and encoding #868

Merged
merged 5 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3384,7 +3384,7 @@ index 5f45e45..cb3cbdf 100644

render();
diff --git a/examples-testing/examples/webgl_clipping_stencil.ts b/examples-testing/examples/webgl_clipping_stencil.ts
index 365087d..9dd56a1 100644
index aec09f6..5f0feae 100644
--- a/examples-testing/examples/webgl_clipping_stencil.ts
+++ b/examples-testing/examples/webgl_clipping_stencil.ts
@@ -3,9 +3,13 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
Expand Down Expand Up @@ -12918,10 +12918,10 @@ index 2e42ab5..9ea1dde 100644
renderer.render(scene, camera);

diff --git a/examples-testing/examples/webgl_shadowmesh.ts b/examples-testing/examples/webgl_shadowmesh.ts
index fd26313..203f44d 100644
index 01fd853..4cf69fe 100644
--- a/examples-testing/examples/webgl_shadowmesh.ts
+++ b/examples-testing/examples/webgl_shadowmesh.ts
@@ -12,18 +12,18 @@ const renderer = new THREE.WebGLRenderer();
@@ -12,18 +12,18 @@ const renderer = new THREE.WebGLRenderer({ stencil: true });

const sunLight = new THREE.DirectionalLight('rgb(255,255,255)', 3);
let useDirectionalLight = true;
Expand Down Expand Up @@ -13591,7 +13591,7 @@ index 6aadaf2..bb7fa30 100644
init();
animate();
diff --git a/examples-testing/examples/webgpu_backdrop_area.ts b/examples-testing/examples/webgpu_backdrop_area.ts
index a40092c..9dc155c 100644
index 5561ada..74fed79 100644
--- a/examples-testing/examples/webgpu_backdrop_area.ts
+++ b/examples-testing/examples/webgpu_backdrop_area.ts
@@ -24,8 +24,8 @@ import WebGPURenderer from 'three/addons/renderers/webgpu/WebGPURenderer.js';
Expand All @@ -13605,7 +13605,7 @@ index a40092c..9dc155c 100644

init();

@@ -137,13 +137,13 @@ function init() {
@@ -136,13 +136,13 @@ function init() {
};

const gui = new GUI();
Expand Down Expand Up @@ -13864,6 +13864,21 @@ index c89b95f..60e0571 100644
const time = (currentTime - startTime) / 1000;

object.position.y = 0.8;
diff --git a/examples-testing/examples/webgpu_custom_fog_background.ts b/examples-testing/examples/webgpu_custom_fog_background.ts
index 9f06a5a..5b5f93c 100644
--- a/examples-testing/examples/webgpu_custom_fog_background.ts
+++ b/examples-testing/examples/webgpu_custom_fog_background.ts
@@ -10,8 +10,8 @@ import { RGBELoader } from 'three/addons/loaders/RGBELoader.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';

-let camera, scene, renderer;
-let postProcessing;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: WebGPURenderer;
+let postProcessing: PostProcessing;

init();

diff --git a/examples-testing/examples/webgpu_lights_ies_spotlight.ts b/examples-testing/examples/webgpu_lights_ies_spotlight.ts
index 1430a29..58b951d 100644
--- a/examples-testing/examples/webgpu_lights_ies_spotlight.ts
Expand Down
2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 41 files
+15 −22 build/three.cjs
+15 −22 build/three.module.js
+1 −1 build/three.module.min.js
+1 −1 docs/api/ar/renderers/WebGLRenderer.html
+1 −1 docs/api/en/renderers/WebGLRenderer.html
+1 −1 docs/api/it/renderers/WebGLRenderer.html
+1 −1 docs/api/zh/renderers/WebGLRenderer.html
+1 −0 examples/files.json
+1 −0 examples/jsm/nodes/Nodes.js
+29 −0 examples/jsm/nodes/accessors/RendererReferenceNode.js
+26 −2 examples/jsm/nodes/core/Node.js
+2 −2 examples/jsm/nodes/core/NodeUtils.js
+17 −1 examples/jsm/nodes/display/PassNode.js
+8 −4 examples/jsm/nodes/display/ToneMappingNode.js
+4 −5 examples/jsm/nodes/fog/FogExp2Node.js
+13 −3 examples/jsm/nodes/fog/FogNode.js
+4 −3 examples/jsm/nodes/fog/FogRangeNode.js
+8 −8 examples/jsm/nodes/materials/NodeMaterial.js
+1 −1 examples/jsm/nodes/shadernode/ShaderNode.js
+2 −0 examples/jsm/renderers/common/Animation.js
+2 −2 examples/jsm/renderers/common/Background.js
+11 −19 examples/jsm/renderers/common/Info.js
+1 −1 examples/jsm/renderers/common/RenderContext.js
+3 −3 examples/jsm/renderers/common/RenderObject.js
+1 −1 examples/jsm/renderers/common/RenderObjects.js
+16 −10 examples/jsm/renderers/common/Renderer.js
+1 −1 examples/jsm/renderers/common/nodes/Nodes.js
+34 −19 examples/jsm/renderers/webgl/WebGLBackend.js
+22 −24 examples/jsm/renderers/webgpu/WebGPUBackend.js
+1 −1 examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js
+ examples/screenshots/webgpu_custom_fog_background.jpg
+1 −0 examples/tags.json
+1 −1 examples/webgl_clipping_stencil.html
+1 −1 examples/webgl_shadowmesh.html
+0 −1 examples/webgpu_backdrop_area.html
+0 −1 examples/webgpu_backdrop_water.html
+2 −6 examples/webgpu_compute_particles.html
+28 −22 examples/webgpu_compute_particles_snow.html
+150 −0 examples/webgpu_custom_fog_background.html
+66 −66 package-lock.json
+1 −1 src/renderers/WebGLRenderer.js
1 change: 1 addition & 0 deletions types/three/examples/jsm/nodes/Nodes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export {
} from "./accessors/PositionNode.js";
export { default as ReferenceNode, reference, referenceBuffer } from "./accessors/ReferenceNode.js";
export { default as ReflectVectorNode, reflectVector } from "./accessors/ReflectVectorNode.js";
export { default as RendererReferenceNode, rendererReference } from "./accessors/RendererReferenceNode.js";
export { default as SkinningNode, skinning } from "./accessors/SkinningNode.js";
export { default as StorageBufferNode, storage, storageObject } from "./accessors/StorageBufferNode.js";
export {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Renderer from "../../renderers/common/Renderer.js";
import { NodeTypeOption } from "../core/constants.js";
import { ShaderNodeObject } from "../shadernode/ShaderNode.js";
import ReferenceNode from "./ReferenceNode.js";

export default class RendererReferenceNode extends ReferenceNode<Renderer> {
renderer: Renderer | null;

constructor(property: string, inputType: NodeTypeOption, renderer?: Renderer | null);
}

export const rendererReference: (
name: string,
type: NodeTypeOption,
renderer?: Renderer | null,
) => ShaderNodeObject<RendererReferenceNode>;
2 changes: 2 additions & 0 deletions types/three/examples/jsm/nodes/display/PassNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export default class PassNode extends TempNode {

getTextureDepthNode(): ShaderNodeObject<PassTextureNode>;

getViewZNode(): ShaderNodeObject<Node>;

getDepthNode(): ShaderNodeObject<Node>;

setSize(width: number, height: number): void;
Expand Down
12 changes: 12 additions & 0 deletions types/three/examples/jsm/nodes/display/ToneMappingNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ToneMapping } from "three";
import RendererReferenceNode from "../accessors/RendererReferenceNode.js";
import Node from "../core/Node.js";
import TempNode from "../core/TempNode.js";
import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js";
Expand All @@ -19,3 +20,14 @@ export const toneMapping: (
exposure: NodeRepresentation,
color?: NodeRepresentation,
) => ShaderNodeObject<ToneMappingNode>;
export const toneMappingExposure: ShaderNodeObject<RendererReferenceNode>;

declare module "../shadernode/ShaderNode.js" {
interface NodeElements {
toneMapping: (
color: NodeRepresentation,
mapping?: NodeRepresentation,
exposure?: NodeRepresentation,
) => ShaderNodeObject<ToneMappingNode>;
}
}
15 changes: 10 additions & 5 deletions types/three/examples/jsm/nodes/fog/FogNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import Node from "../core/Node.js";
import NodeBuilder from "../core/NodeBuilder.js";
import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js";

export default class FogNode extends Node {
isFogNode: true;
colorNode: Node;
factorNode: Node;
colorNode: Node | null;
factorNode: Node | null;

constructor(colorNode: Node, factorNode: Node);
mixAssign(outputNode: Node): Node;
constructor(colorNode: Node | null, factorNode: Node | null);

getViewZNode(builder: NodeBuilder): Node;
}

export const fog: (colorNode: NodeRepresentation, factorNode: NodeRepresentation) => ShaderNodeObject<FogNode>;
export const fog: (
colorNode: NodeRepresentation | null,
factorNode: NodeRepresentation | null,
) => ShaderNodeObject<FogNode>;

declare module "../shadernode/ShaderNode.js" {
interface NodeElements {
Expand Down
14 changes: 9 additions & 5 deletions types/three/examples/jsm/nodes/fog/FogRangeNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import Node from "../core/Node.js";
import { ShaderNodeObject } from "../shadernode/ShaderNode.js";
import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js";
import FogNode from "./FogNode.js";

export default class FogRangeNode extends FogNode {
isFogRangeNode: true;
nearNode: Node;
farNode: Node;
nearNode: Node | null;
farNode: Node | null;

constructor(colorNode: Node, nearNode: Node, farNode: Node);
constructor(colorNode: Node | null, nearNode: Node | null, farNode: Node | null);
}

export const rangeFog: (colorNode: Node, nearNode: Node, farNode: Node) => ShaderNodeObject<FogRangeNode>;
export const rangeFog: (
colorNode: NodeRepresentation | null,
nearNode: NodeRepresentation | null,
farNode: NodeRepresentation | null,
) => ShaderNodeObject<FogRangeNode>;

declare module "../shadernode/ShaderNode.js" {
interface NodeElements {
Expand Down
Loading