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: Add more exports to ShaderNode #23901

Merged
merged 30 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
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
18 changes: 12 additions & 6 deletions examples/jsm/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ import CondNode from './math/CondNode.js';
import LightContextNode from './lights/LightContextNode.js';
import LightNode from './lights/LightNode.js';
import LightsNode from './lights/LightsNode.js';
import ReflectedLightNode from './lights/ReflectedLightNode.js';

// utils
import ArrayElementNode from './utils/ArrayElementNode.js';
import ConvertNode from './utils/ConvertNode.js';
import JoinNode from './utils/JoinNode.js';
import SplitNode from './utils/SplitNode.js';
import SpriteSheetUVNode from './utils/SpriteSheetUVNode.js';
import MatcapUVNode from './utils/MatcapUVNode.js';
import MaxMipLevelNode from './utils/MaxMipLevelNode.js';
import OscNode from './utils/OscNode.js';
import SplitNode from './utils/SplitNode.js';
import SpriteSheetUVNode from './utils/SpriteSheetUVNode.js';
import TimerNode from './utils/TimerNode.js';

// loaders
Expand Down Expand Up @@ -151,15 +153,17 @@ const nodeLib = {
LightContextNode,
LightNode,
LightsNode,
ReflectedLightNode,

// utils
ArrayElementNode,
ConvertNode,
JoinNode,
SplitNode,
SpriteSheetUVNode,
MatcapUVNode,
MaxMipLevelNode,
OscNode,
SplitNode,
SpriteSheetUVNode,
TimerNode,

// procedural
Expand Down Expand Up @@ -243,15 +247,17 @@ export {
LightContextNode,
LightNode,
LightsNode,
ReflectedLightNode,

// utils
ArrayElementNode,
ConvertNode,
JoinNode,
SplitNode,
SpriteSheetUVNode,
MatcapUVNode,
MaxMipLevelNode,
OscNode,
SplitNode,
SpriteSheetUVNode,
TimerNode,

// procedural
Expand Down
3 changes: 1 addition & 2 deletions examples/jsm/nodes/accessors/InstanceNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
element,
dot,
div,
temp,
LeviPesin marked this conversation as resolved.
Show resolved Hide resolved
instanceIndex,
positionLocal,
normalLocal
Expand All @@ -26,7 +25,7 @@ class InstanceNode extends Node {

const instanceBufferNode = buffer( instanceMesh.instanceMatrix.array, 'mat4', instanceMesh.count );

this.instanceMatrixNode = temp( element( instanceBufferNode, instanceIndex ) );
this.instanceMatrixNode = element( instanceBufferNode, instanceIndex );
LeviPesin marked this conversation as resolved.
Show resolved Hide resolved

}

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/nodes/accessors/ReflectNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Node from '../core/Node.js';
import { nodeObject, normalWorld, positionWorld, cameraPosition, sub, normalize, join, negate, reflect } from '../shadernode/ShaderNodeElements.js';
import { nodeObject, normalWorld, positionWorld, cameraPosition, sub, normalize, vec3, negate, reflect } from '../shadernode/ShaderNodeElements.js';

class ReflectNode extends Node {

Expand Down Expand Up @@ -34,7 +34,7 @@ class ReflectNode extends Node {
} else if ( scope === ReflectNode.CUBE ) {

const reflectVec = nodeObject( new ReflectNode( ReflectNode.VECTOR ) );
const cubeUV = join( negate( reflectVec.x ), reflectVec.yz );
const cubeUV = vec3( negate( reflectVec.x ), reflectVec.yz );

return cubeUV.build( builder );

Expand Down
2 changes: 0 additions & 2 deletions examples/jsm/nodes/core/VarNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,4 @@ class VarNode extends Node {

}

VarNode.prototype.isVarNode = true;

export default VarNode;
4 changes: 2 additions & 2 deletions examples/jsm/nodes/display/ColorSpaceNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import TempNode from '../core/Node.js';
import ShaderNode from '../shadernode/ShaderNode.js';
import { vec3, pow, mul, sub, mix, join, lessThanEqual } from '../shadernode/ShaderNodeElements.js';
import { vec3, pow, mul, sub, mix, vec4, lessThanEqual } from '../shadernode/ShaderNodeElements.js';

import { LinearEncoding, sRGBEncoding } from 'three';

Expand All @@ -22,7 +22,7 @@ export const LinearTosRGB = new ShaderNode( ( inputs ) => {

const rgbResult = mix( a, b, factor );

return join( rgbResult.r, rgbResult.g, rgbResult.b, value.a );
return vec4( rgbResult, value.a );

} );

Expand Down
6 changes: 3 additions & 3 deletions examples/jsm/nodes/display/NormalMapNode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TempNode from '../core/TempNode.js';
import ModelNode from '../accessors/ModelNode.js';
import ShaderNode from '../shadernode/ShaderNode.js';
import { positionView, normalView, uv, join, cond, add, sub, mul, dFdx, dFdy, cross, max, dot, normalize, inversesqrt, equal } from '../shadernode/ShaderNodeElements.js';
import { positionView, normalView, uv, vec3, cond, add, sub, mul, dFdx, dFdy, cross, max, dot, normalize, invSqrt, equal } from '../shadernode/ShaderNodeElements.js';

import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from 'three';

Expand All @@ -26,7 +26,7 @@ const perturbNormal2ArbNode = new ShaderNode( ( inputs ) => {
const B = add( mul( q1perp, st0.y ), mul( q0perp, st1.y ) );

const det = max( dot( T, T ), dot( B, B ) );
const scale = cond( equal( det, 0 ), 0, mul( faceDirection, inversesqrt( det ) ) );
const scale = cond( equal( det, 0 ), 0, mul( faceDirection, invSqrt( det ) ) );

return normalize( add( mul( T, mul( mapN.x, scale ) ), mul( B, mul( mapN.y, scale ) ), mul( N, mapN.z ) ) );

Expand Down Expand Up @@ -57,7 +57,7 @@ class NormalMapNode extends TempNode {
if ( scaleNode !== null ) {

const normalMapScale = mul( normalMap.xy, scaleNode );
normalMap = join( normalMapScale, normalMap.z );
normalMap = vec3( normalMapScale, normalMap.z );
sunag marked this conversation as resolved.
Show resolved Hide resolved

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/lights/LightContextNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LightContextNode extends ContextNode {

const { lightingModelNode } = this;

this.context.reflectedLight = reflectedLight();
this.context.reflectedLight = reflectedLight;
LeviPesin marked this conversation as resolved.
Show resolved Hide resolved

if ( lightingModelNode !== null ) {

Expand Down
Loading