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

Nodes: StereoCompositePassNode.js #1202

Merged
merged 7 commits into from
Aug 25, 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
11 changes: 6 additions & 5 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -13531,10 +13531,10 @@ index 4a2e6c80..22eeb6d0 100644
init();

diff --git a/examples-testing/examples/webgpu_display_stereo.ts b/examples-testing/examples/webgpu_display_stereo.ts
index 48358dcf..f69959cf 100644
index 7eb45fa2..b2af0ebb 100644
--- a/examples-testing/examples/webgpu_display_stereo.ts
+++ b/examples-testing/examples/webgpu_display_stereo.ts
@@ -1,23 +1,36 @@
@@ -1,24 +1,37 @@
-import * as THREE from 'three';
-
-import { stereoPass, anaglyphPass, parallaxBarrierPass } from 'three/tsl';
Expand Down Expand Up @@ -13570,16 +13570,17 @@ index 48358dcf..f69959cf 100644
const position = new THREE.Vector3();

-const params = {
+const params: { effect: 'stereo' | 'anaglyph' | 'parallaxBarrier' } = {
+const params: { effect: 'stereo' | 'anaglyph' | 'parallaxBarrier'; eyeSep: number } = {
effect: 'stereo',
eyeSep: 0.064,
};

-const effects = { Stereo: 'stereo', Anaglyph: 'anaglyph', ParallaxBarrier: 'parallaxBarrier' };
+const effects = { Stereo: 'stereo', Anaglyph: 'anaglyph', ParallaxBarrier: 'parallaxBarrier' } as const;

init();

@@ -87,7 +100,7 @@ function init() {
@@ -90,7 +103,7 @@ function init() {
controls.maxDistance = 25;
}

Expand All @@ -13588,7 +13589,7 @@ index 48358dcf..f69959cf 100644
if (value === 'stereo') {
postProcessing.outputNode = stereo;
} else if (value === 'anaglyph') {
@@ -106,7 +119,7 @@ function onWindowResize() {
@@ -109,7 +122,7 @@ function onWindowResize() {
renderer.setSize(window.innerWidth, window.innerHeight);
}

Expand Down
24 changes: 12 additions & 12 deletions src-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2601,11 +2601,11 @@ index 9a41cc7d..df337a72 100644

lights = sortLights(lights);
diff --git a/src-testing/src/nodes/shadernode/ShaderNode.ts b/src-testing/src/nodes/shadernode/ShaderNode.ts
index b158091d..66e3295d 100644
index b6b773d5..ef3c8944 100644
--- a/src-testing/src/nodes/shadernode/ShaderNode.ts
+++ b/src-testing/src/nodes/shadernode/ShaderNode.ts
@@ -6,11 +6,49 @@ import SplitNode from '../utils/SplitNode.js';
import SetNode from '../utils/SetNode.js';
@@ -7,11 +7,49 @@ import SetNode from '../utils/SetNode.js';
import FlipNode from '../utils/FlipNode.js';
import ConstNode from '../core/ConstNode.js';
import { getValueFromType, getValueType } from '../core/NodeUtils.js';
+import NodeBuilder from '../core/NodeBuilder.js';
Expand Down Expand Up @@ -2654,7 +2654,7 @@ index b158091d..66e3295d 100644
const NodeElements = new Map(); // @TODO: Currently only a few nodes are added, probably also add others

export function addNodeElement(name, nodeElement) {
@@ -24,6 +62,141 @@ export function addNodeElement(name, nodeElement) {
@@ -25,6 +63,141 @@ export function addNodeElement(name, nodeElement) {
NodeElements.set(name, nodeElement);
}

Expand Down Expand Up @@ -2794,9 +2794,9 @@ index b158091d..66e3295d 100644
+type ConstructedNode<T> = T extends new (...args: any[]) => infer R ? (R extends Node ? R : never) : never;
+
const parseSwizzle = props => props.replace(/r|s/g, 'x').replace(/g|t/g, 'y').replace(/b|p/g, 'z').replace(/a|q/g, 'w');
const parseSwizzleAndSort = props => parseSwizzle(props).split('').sort().join('');

const shaderNodeHandler = {
@@ -113,7 +286,7 @@ const shaderNodeHandler = {
@@ -117,7 +290,7 @@ const shaderNodeHandler = {
const nodeObjectsCacheMap = new WeakMap();
const nodeBuilderFunctionsCacheMap = new WeakMap();

Expand All @@ -2805,7 +2805,7 @@ index b158091d..66e3295d 100644
const type = getValueType(obj);

if (type === 'node') {
@@ -182,18 +355,20 @@ const ShaderNodeImmutable = function (NodeClass, ...params) {
@@ -186,18 +359,20 @@ const ShaderNodeImmutable = function (NodeClass, ...params) {
};

class ShaderCallNodeInternal extends Node {
Expand All @@ -2829,7 +2829,7 @@ index b158091d..66e3295d 100644
const { shaderNode, inputNodes } = this;

const properties = builder.getNodeProperties(shaderNode);
@@ -268,7 +443,15 @@ class ShaderCallNodeInternal extends Node {
@@ -272,7 +447,15 @@ class ShaderCallNodeInternal extends Node {
}
}

Expand All @@ -2845,7 +2845,7 @@ index b158091d..66e3295d 100644
constructor(jsFunc, nodeType) {
super(nodeType);

@@ -284,7 +467,7 @@ class ShaderNodeInternal extends Node {
@@ -288,7 +471,7 @@ class ShaderNodeInternal extends Node {
return /^\((\s+)?\[/.test(this.jsFunc.toString());
}

Expand All @@ -2854,7 +2854,7 @@ index b158091d..66e3295d 100644
this.layout = layout;

return this;
@@ -301,6 +484,8 @@ class ShaderNodeInternal extends Node {
@@ -305,6 +488,8 @@ class ShaderNodeInternal extends Node {
}
}

Expand All @@ -2863,7 +2863,7 @@ index b158091d..66e3295d 100644
const bools = [false, true];
const uints = [0, 1, 2, 3];
const ints = [-1, -2];
@@ -394,10 +579,27 @@ export function ShaderNode(jsFunc, nodeType) {
@@ -398,10 +583,27 @@ export function ShaderNode(jsFunc, nodeType) {
return new Proxy(new ShaderNodeInternal(jsFunc, nodeType), shaderNodeHandler);
}

Expand Down Expand Up @@ -7482,7 +7482,7 @@ index 936cb08d..64711d5e 100644
}

diff --git a/src-testing/src/renderers/webgpu/nodes/WGSLNodeBuilder.ts b/src-testing/src/renderers/webgpu/nodes/WGSLNodeBuilder.ts
index aa652d81..62f6a101 100644
index e317836a..23e69691 100644
--- a/src-testing/src/renderers/webgpu/nodes/WGSLNodeBuilder.ts
+++ b/src-testing/src/renderers/webgpu/nodes/WGSLNodeBuilder.ts
@@ -10,7 +10,7 @@ import {
Expand Down
11 changes: 4 additions & 7 deletions types/three/src/nodes/display/AnaglyphPassNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { Camera } from "../../cameras/Camera.js";
import { StereoCamera } from "../../cameras/StereoCamera.js";
import { Scene } from "../../scenes/Scene.js";
import { ShaderNodeObject } from "../shadernode/ShaderNode.js";
import PassNode from "./PassNode.js";
import StereoCompositePassNode from "./StereoCompositePassNode.js";

declare class AnaglyphPassNode extends PassNode {
declare class AnaglyphPassNode extends StereoCompositePassNode {
readonly isAnaglyphPassNode: true;

stereo: StereoCamera;

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

export const anaglyphPass: (scene: Scene, camera: Camera) => ShaderNodeObject<AnaglyphPassNode>;

export default AnaglyphPassNode;

export const anaglyphPass: (scene: Scene, camera: Camera) => ShaderNodeObject<AnaglyphPassNode>;
11 changes: 4 additions & 7 deletions types/three/src/nodes/display/ParallaxBarrierPassNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { Camera } from "../../cameras/Camera.js";
import { StereoCamera } from "../../cameras/StereoCamera.js";
import { Scene } from "../../scenes/Scene.js";
import { ShaderNodeObject } from "../shadernode/ShaderNode.js";
import PassNode from "./PassNode.js";
import StereoCompositePassNode from "./StereoCompositePassNode.js";

declare class ParallaxBarrierPassNode extends PassNode {
declare class ParallaxBarrierPassNode extends StereoCompositePassNode {
readonly isParallaxBarrierPassNode: true;

stereo: StereoCamera;

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

export const parallaxBarrierPass: (scene: Scene, camera: Camera) => ShaderNodeObject<ParallaxBarrierPassNode>;

export default ParallaxBarrierPassNode;

export const parallaxBarrierPass: (scene: Scene, camera: Camera) => ShaderNodeObject<ParallaxBarrierPassNode>;
17 changes: 17 additions & 0 deletions types/three/src/nodes/display/StereoCompositePassNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Camera } from "../../cameras/Camera.js";
import { StereoCamera } from "../../cameras/StereoCamera.js";
import { CoordinateSystem } from "../../constants.js";
import { Scene } from "../../scenes/Scene.js";
import PassNode from "./PassNode.js";

declare class StereoCompositePassNode extends PassNode {
readonly isStereoCompositePassNode: true;

stereo: StereoCamera;

constructor(scene: Scene, camera: Camera);

updateStereoCamera(coordinateSystem: CoordinateSystem): void;
}

export default StereoCompositePassNode;
Loading