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

Node: Add FilmNode. #1084

Merged
merged 8 commits into from
Jul 20, 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
42 changes: 18 additions & 24 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,16 @@ index eb7e7ca0..4d327e38 100644
}

diff --git a/examples-testing/examples/misc_controls_fly.ts b/examples-testing/examples/misc_controls_fly.ts
index 5c37e20a..acb42943 100644
index 4e58a36e..ce66548e 100644
--- a/examples-testing/examples/misc_controls_fly.ts
+++ b/examples-testing/examples/misc_controls_fly.ts
@@ -19,11 +19,15 @@ const MARGIN = 0;
@@ -1,4 +1,4 @@
-import * as THREE from 'three';
+import * as THREE from 'three/webgpu';
import { pass } from 'three/tsl';

import Stats from 'three/addons/libs/stats.module.js';
@@ -15,11 +15,15 @@ const MARGIN = 0;
let SCREEN_HEIGHT = window.innerHeight - MARGIN * 2;
let SCREEN_WIDTH = window.innerWidth;

Expand All @@ -894,17 +900,17 @@ index 5c37e20a..acb42943 100644
+let camera: THREE.PerspectiveCamera,
+ controls: FlyControls,
+ scene: THREE.Scene,
+ renderer: THREE.WebGLRenderer,
+ renderer: THREE.WebGPURenderer,
+ stats: Stats;
+let geometry: THREE.SphereGeometry, meshPlanet: THREE.Mesh, meshClouds: THREE.Mesh, meshMoon: THREE.Mesh;
+let dirLight: THREE.DirectionalLight;

-let composer;
+let composer: EffectComposer;
-let postProcessing;
+let postProcessing: THREE.PostProcessing;

const textureLoader = new THREE.TextureLoader();

@@ -55,7 +59,7 @@ function init() {
@@ -51,7 +55,7 @@ function init() {
// y scale is negated to compensate for normal map handedness.
normalScale: new THREE.Vector2(0.85, -0.85),
});
Expand All @@ -913,7 +919,7 @@ index 5c37e20a..acb42943 100644

// planet

@@ -72,7 +76,7 @@ function init() {
@@ -68,7 +72,7 @@ function init() {
map: textureLoader.load('textures/planets/earth_clouds_1024.png'),
transparent: true,
});
Expand All @@ -922,7 +928,7 @@ index 5c37e20a..acb42943 100644

meshClouds = new THREE.Mesh(geometry, materialClouds);
meshClouds.scale.set(cloudsScale, cloudsScale, cloudsScale);
@@ -84,7 +88,7 @@ function init() {
@@ -80,7 +84,7 @@ function init() {
const materialMoon = new THREE.MeshPhongMaterial({
map: textureLoader.load('textures/planets/moon_1024.jpg'),
});
Expand Down Expand Up @@ -14451,16 +14457,13 @@ index cbc5a96b..66ec682e 100644
const params = {
enable: true,
diff --git a/examples-testing/examples/webgpu_refraction.ts b/examples-testing/examples/webgpu_refraction.ts
index 3270efea..0458832f 100644
index dc018c6d..6c7faf4d 100644
--- a/examples-testing/examples/webgpu_refraction.ts
+++ b/examples-testing/examples/webgpu_refraction.ts
@@ -1,15 +1,13 @@
@@ -1,13 +1,13 @@
-import * as THREE from 'three';
-import { MeshBasicNodeMaterial, viewportSharedTexture, texture, uv } from 'three/nodes';
-
-import WebGPURenderer from 'three/addons/renderers/webgpu/WebGPURenderer.js';
+import * as THREE from 'three/webgpu';
+import { MeshBasicNodeMaterial, viewportSharedTexture, texture, uv } from 'three/tsl';
import { viewportSharedTexture, texture, uv } from 'three/tsl';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

Expand All @@ -14475,7 +14478,7 @@ index 3270efea..0458832f 100644

init();

@@ -42,7 +40,7 @@ function init() {
@@ -40,7 +40,7 @@ function init() {

const verticalNormalScale = 0.1;
const verticalUVOffset = texture(floorNormal, uv().mul(5)).xy.mul(2).sub(1).mul(verticalNormalScale);
Expand All @@ -14484,15 +14487,6 @@ index 3270efea..0458832f 100644

const planeGeo = new THREE.PlaneGeometry(100.1, 100.1);

@@ -104,7 +102,7 @@ function init() {

// renderer

- renderer = new WebGPURenderer({ antialias: true });
+ renderer = new THREE.WebGPURenderer({ antialias: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setAnimationLoop(animate);
diff --git a/examples-testing/examples/webgpu_textures_anisotropy.ts b/examples-testing/examples/webgpu_textures_anisotropy.ts
index 21cc1197..eec04d7e 100644
--- a/examples-testing/examples/webgpu_textures_anisotropy.ts
Expand Down
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 @@ -302,6 +302,7 @@ export {
} from "./display/ColorSpaceNode.js";
export { default as DepthOfFieldNode, dof } from "./display/DepthOfFieldNode.js";
export { default as DotScreenNode, dotScreen } from "./display/DotScreenNode.js";
export { default as FilmNode, film } from "./display/FilmNode.js";
export { default as FrontFacingNode, faceDirection, frontFacing } from "./display/FrontFacingNode.js";
export { default as GaussianBlurNode, gaussianBlur } from "./display/GaussianBlurNode.js";
export { default as NormalMapNode, normalMap } from "./display/NormalMapNode.js";
Expand Down
25 changes: 25 additions & 0 deletions types/three/src/nodes/display/FilmNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Node from "../core/Node.js";
import TempNode from "../core/TempNode.js";
import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js";

declare class FilmNode extends TempNode {
inputNode: Node;
intensityNode: Node | null;
uvNode: Node | null;

constructor(inputNode: Node, intensityNode?: Node | null, uvNode?: Node | null);
}

export const film: (
inputNode: NodeRepresentation,
intensityNode?: NodeRepresentation | null,
uvNode?: NodeRepresentation | null,
) => ShaderNodeObject<FilmNode>;

declare module "../shadernode/ShaderNode.js" {
interface NodeElements {
film: typeof film;
}
}

export default FilmNode;
Loading