Skip to content

Commit

Permalink
Nodes: Fix tangentView and move TBNViewMatrix to AccessorsUtils (#…
Browse files Browse the repository at this point in the history
…27696)

* Fix tangentView

* Move TBN to AccessorsUtils

* Update webgpu_loader_gltf_compressed.jpg
  • Loading branch information
sunag authored Feb 7, 2024
1 parent 6826426 commit bd885e9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion examples/jsm/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
export * from './shadernode/ShaderNode.js';

// accessors
export { TBNViewMatrix } from './accessors/AccessorsUtils.js';
export { default as BitangentNode, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, transformedBitangentView, transformedBitangentWorld } from './accessors/BitangentNode.js';
export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
export { default as BufferNode, buffer } from './accessors/BufferNode.js';
Expand Down Expand Up @@ -111,7 +112,7 @@ export { default as BumpMapNode, bumpMap } from './display/BumpMapNode.js';
export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance, threshold } from './display/ColorAdjustmentNode.js';
export { default as ColorSpaceNode, linearToColorSpace, colorSpaceToLinear, linearTosRGB, sRGBToLinear } from './display/ColorSpaceNode.js';
export { default as FrontFacingNode, frontFacing, faceDirection } from './display/FrontFacingNode.js';
export { default as NormalMapNode, normalMap, TBNViewMatrix } from './display/NormalMapNode.js';
export { default as NormalMapNode, normalMap } from './display/NormalMapNode.js';
export { default as PosterizeNode, posterize } from './display/PosterizeNode.js';
export { default as ToneMappingNode, toneMapping } from './display/ToneMappingNode.js';
export { default as ViewportNode, viewport, viewportCoordinate, viewportResolution, viewportTopLeft, viewportBottomLeft, viewportTopRight, viewportBottomRight } from './display/ViewportNode.js';
Expand Down
6 changes: 6 additions & 0 deletions examples/jsm/nodes/accessors/AccessorsUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { bitangentView } from './BitangentNode.js';
import { normalView } from './NormalNode.js';
import { tangentView } from './TangentNode.js';
import { mat3 } from '../shadernode/ShaderNode.js';

export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
4 changes: 2 additions & 2 deletions examples/jsm/nodes/accessors/TangentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { varying } from '../core/VaryingNode.js';
import { normalize } from '../math/MathNode.js';
import { cameraViewMatrix } from './CameraNode.js';
import { modelViewMatrix } from './ModelNode.js';
import { nodeImmutable } from '../shadernode/ShaderNode.js';
import { nodeImmutable, vec4 } from '../shadernode/ShaderNode.js';

class TangentNode extends Node {

Expand Down Expand Up @@ -54,7 +54,7 @@ class TangentNode extends Node {

} else if ( scope === TangentNode.VIEW ) {

const vertexNode = modelViewMatrix.mul( tangentLocal ).xyz;
const vertexNode = modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz;
outputNode = normalize( varying( vertexNode ) );

} else if ( scope === TangentNode.WORLD ) {
Expand Down
8 changes: 3 additions & 5 deletions examples/jsm/nodes/display/NormalMapNode.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import TempNode from '../core/TempNode.js';
import { add } from '../math/OperatorNode.js';
import { bitangentView } from '../accessors/BitangentNode.js';

import { modelNormalMatrix } from '../accessors/ModelNode.js';
import { normalView } from '../accessors/NormalNode.js';
import { positionView } from '../accessors/PositionNode.js';
import { tangentView } from '../accessors/TangentNode.js';
import { TBNViewMatrix } from '../accessors/AccessorsUtils.js';
import { uv } from '../accessors/UVNode.js';
import { faceDirection } from './FrontFacingNode.js';
import { addNodeClass } from '../core/Node.js';
import { addNodeElement, tslFn, nodeProxy, vec3, mat3 } from '../shadernode/ShaderNode.js';
import { addNodeElement, tslFn, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';

import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from 'three';

Expand Down Expand Up @@ -101,8 +101,6 @@ export default NormalMapNode;

export const normalMap = nodeProxy( NormalMapNode );

export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );

addNodeElement( 'normalMap', normalMap );

addNodeClass( 'NormalMapNode', NormalMapNode );
Binary file modified examples/screenshots/webgpu_loader_gltf_compressed.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bd885e9

Please sign in to comment.