|
@@ -14,6 +14,7 @@ import VarNode from '../core/VarNode.js';
|
|
|
import VaryingNode from '../core/VaryingNode.js';
|
|
|
|
|
|
// accessors
|
|
|
+import BitangentNode from '../accessors/BitangentNode.js';
|
|
|
import BufferNode from '../accessors/BufferNode.js';
|
|
|
import CameraNode from '../accessors/CameraNode.js';
|
|
|
import MaterialNode from '../accessors/MaterialNode.js';
|
|
@@ -25,6 +26,7 @@ import PointUVNode from '../accessors/PointUVNode.js';
|
|
|
import PositionNode from '../accessors/PositionNode.js';
|
|
|
import ReferenceNode from '../accessors/ReferenceNode.js';
|
|
|
import StorageBufferNode from '../accessors/StorageBufferNode.js';
|
|
|
+import TangentNode from '../accessors/TangentNode.js';
|
|
|
import TextureNode from '../accessors/TextureNode.js';
|
|
|
import UserDataNode from '../accessors/UserDataNode.js';
|
|
|
import UVNode from '../accessors/UVNode.js';
|
|
@@ -124,65 +126,6 @@ export const label = nodeProxy( VarNode );
|
|
|
export const temp = label;
|
|
|
export const varying = nodeProxy( VaryingNode );
|
|
|
|
|
|
-// accesors
|
|
|
-
|
|
|
-export const buffer = ( value, nodeOrType, count ) => nodeObject( new BufferNode( value, getConstNodeType( nodeOrType ), count ) );
|
|
|
-export const storage = ( value, nodeOrType, count ) => nodeObject( new StorageBufferNode( value, getConstNodeType( nodeOrType ), count ) );
|
|
|
-
|
|
|
-export const cameraProjectionMatrix = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX );
|
|
|
-export const cameraViewMatrix = nodeImmutable( CameraNode, CameraNode.VIEW_MATRIX );
|
|
|
-export const cameraNormalMatrix = nodeImmutable( CameraNode, CameraNode.NORMAL_MATRIX );
|
|
|
-export const cameraWorldMatrix = nodeImmutable( CameraNode, CameraNode.WORLD_MATRIX );
|
|
|
-export const cameraPosition = nodeImmutable( CameraNode, CameraNode.POSITION );
|
|
|
-
|
|
|
-export const materialAlphaTest = nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST );
|
|
|
-export const materialColor = nodeImmutable( MaterialNode, MaterialNode.COLOR );
|
|
|
-export const materialEmissive = nodeImmutable( MaterialNode, MaterialNode.EMISSIVE );
|
|
|
-export const materialOpacity = nodeImmutable( MaterialNode, MaterialNode.OPACITY );
|
|
|
-//export const materialSpecular = nodeImmutable( MaterialNode, MaterialNode.SPECULAR );
|
|
|
-export const materialRoughness = nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
|
|
|
-export const materialMetalness = nodeImmutable( MaterialNode, MaterialNode.METALNESS );
|
|
|
-export const materialRotation = nodeImmutable( MaterialNode, MaterialNode.ROTATION );
|
|
|
-
|
|
|
-export const diffuseColor = nodeImmutable( PropertyNode, 'DiffuseColor', 'vec4' );
|
|
|
-export const roughness = nodeImmutable( PropertyNode, 'Roughness', 'float' );
|
|
|
-export const metalness = nodeImmutable( PropertyNode, 'Metalness', 'float' );
|
|
|
-export const alphaTest = nodeImmutable( PropertyNode, 'AlphaTest', 'float' );
|
|
|
-export const specularColor = nodeImmutable( PropertyNode, 'SpecularColor', 'color' );
|
|
|
-
|
|
|
-export const reference = ( name, nodeOrType, object ) => nodeObject( new ReferenceNode( name, getConstNodeType( nodeOrType ), object ) );
|
|
|
-export const materialReference = ( name, nodeOrType, material ) => nodeObject( new MaterialReferenceNode( name, getConstNodeType( nodeOrType ), material ) );
|
|
|
-export const userData = ( name, inputType, userData ) => nodeObject( new UserDataNode( name, inputType, userData ) );
|
|
|
-
|
|
|
-export const modelViewProjection = nodeProxy( ModelViewProjectionNode );
|
|
|
-
|
|
|
-export const normalGeometry = nodeImmutable( NormalNode, NormalNode.GEOMETRY );
|
|
|
-export const normalLocal = nodeImmutable( NormalNode, NormalNode.LOCAL );
|
|
|
-export const normalWorld = nodeImmutable( NormalNode, NormalNode.WORLD );
|
|
|
-export const normalView = nodeImmutable( NormalNode, NormalNode.VIEW );
|
|
|
-export const transformedNormalView = nodeImmutable( VarNode, normalView, 'TransformedNormalView' );
|
|
|
-
|
|
|
-export const modelViewMatrix = nodeImmutable( ModelNode, ModelNode.VIEW_MATRIX );
|
|
|
-export const modelNormalMatrix = nodeImmutable( ModelNode, ModelNode.NORMAL_MATRIX );
|
|
|
-export const modelWorldMatrix = nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX );
|
|
|
-export const modelPosition = nodeImmutable( ModelNode, ModelNode.POSITION );
|
|
|
-export const modelViewPosition = nodeImmutable( ModelNode, ModelNode.VIEW_POSITION );
|
|
|
-
|
|
|
-export const positionGeometry = nodeImmutable( PositionNode, PositionNode.GEOMETRY );
|
|
|
-export const positionLocal = nodeImmutable( PositionNode, PositionNode.LOCAL );
|
|
|
-export const positionWorld = nodeImmutable( PositionNode, PositionNode.WORLD );
|
|
|
-export const positionView = nodeImmutable( PositionNode, PositionNode.VIEW );
|
|
|
-export const positionViewDirection = nodeImmutable( PositionNode, PositionNode.VIEW_DIRECTION );
|
|
|
-
|
|
|
-export const texture = nodeProxy( TextureNode );
|
|
|
-export const sampler = ( texture ) => nodeObject( new ConvertNode( texture.isNode === true ? texture : new TextureNode( texture ), 'sampler' ) );
|
|
|
-export const uv = ( ...params ) => nodeObject( new UVNode( ...params ) );
|
|
|
-export const pointUV = nodeImmutable( PointUVNode );
|
|
|
-
|
|
|
-// gpgpu
|
|
|
-
|
|
|
-export const compute = ( node, count, workgroupSize ) => nodeObject( new ComputeNode( nodeObject( node ), count, workgroupSize ) );
|
|
|
-
|
|
|
// math
|
|
|
|
|
|
export const EPSILON = float( 1e-6 );
|
|
@@ -258,6 +201,80 @@ export const refract = nodeProxy( MathNode, MathNode.REFRACT );
|
|
|
export const smoothstep = nodeProxy( MathNode, MathNode.SMOOTHSTEP );
|
|
|
export const faceforward = nodeProxy( MathNode, MathNode.FACEFORWARD );
|
|
|
|
|
|
+// accessors
|
|
|
+
|
|
|
+export const buffer = ( value, nodeOrType, count ) => nodeObject( new BufferNode( value, getConstNodeType( nodeOrType ), count ) );
|
|
|
+export const storage = ( value, nodeOrType, count ) => nodeObject( new StorageBufferNode( value, getConstNodeType( nodeOrType ), count ) );
|
|
|
+
|
|
|
+export const cameraProjectionMatrix = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX );
|
|
|
+export const cameraViewMatrix = nodeImmutable( CameraNode, CameraNode.VIEW_MATRIX );
|
|
|
+export const cameraNormalMatrix = nodeImmutable( CameraNode, CameraNode.NORMAL_MATRIX );
|
|
|
+export const cameraWorldMatrix = nodeImmutable( CameraNode, CameraNode.WORLD_MATRIX );
|
|
|
+export const cameraPosition = nodeImmutable( CameraNode, CameraNode.POSITION );
|
|
|
+
|
|
|
+export const materialAlphaTest = nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST );
|
|
|
+export const materialColor = nodeImmutable( MaterialNode, MaterialNode.COLOR );
|
|
|
+export const materialEmissive = nodeImmutable( MaterialNode, MaterialNode.EMISSIVE );
|
|
|
+export const materialOpacity = nodeImmutable( MaterialNode, MaterialNode.OPACITY );
|
|
|
+//export const materialSpecular = nodeImmutable( MaterialNode, MaterialNode.SPECULAR );
|
|
|
+export const materialRoughness = nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
|
|
|
+export const materialMetalness = nodeImmutable( MaterialNode, MaterialNode.METALNESS );
|
|
|
+export const materialRotation = nodeImmutable( MaterialNode, MaterialNode.ROTATION );
|
|
|
+
|
|
|
+export const diffuseColor = nodeImmutable( PropertyNode, 'DiffuseColor', 'vec4' );
|
|
|
+export const roughness = nodeImmutable( PropertyNode, 'Roughness', 'float' );
|
|
|
+export const metalness = nodeImmutable( PropertyNode, 'Metalness', 'float' );
|
|
|
+export const alphaTest = nodeImmutable( PropertyNode, 'AlphaTest', 'float' );
|
|
|
+export const specularColor = nodeImmutable( PropertyNode, 'SpecularColor', 'color' );
|
|
|
+
|
|
|
+export const reference = ( name, nodeOrType, object ) => nodeObject( new ReferenceNode( name, getConstNodeType( nodeOrType ), object ) );
|
|
|
+export const materialReference = ( name, nodeOrType, material ) => nodeObject( new MaterialReferenceNode( name, getConstNodeType( nodeOrType ), material ) );
|
|
|
+export const userData = ( name, inputType, userData ) => nodeObject( new UserDataNode( name, inputType, userData ) );
|
|
|
+
|
|
|
+export const modelViewProjection = nodeProxy( ModelViewProjectionNode );
|
|
|
+
|
|
|
+export const normalGeometry = nodeImmutable( NormalNode, NormalNode.GEOMETRY );
|
|
|
+export const normalLocal = nodeImmutable( NormalNode, NormalNode.LOCAL );
|
|
|
+export const normalView = nodeImmutable( NormalNode, NormalNode.VIEW );
|
|
|
+export const normalWorld = nodeImmutable( NormalNode, NormalNode.WORLD );
|
|
|
+export const transformedNormalView = nodeImmutable( VarNode, normalView, 'TransformedNormalView' );
|
|
|
+export const transformedNormalWorld = normalize( transformDirection( transformedNormalView, cameraViewMatrix ) );
|
|
|
+
|
|
|
+export const tangentGeometry = nodeImmutable( TangentNode, TangentNode.GEOMETRY );
|
|
|
+export const tangentLocal = nodeImmutable( TangentNode, TangentNode.LOCAL );
|
|
|
+export const tangentView = nodeImmutable( TangentNode, TangentNode.VIEW );
|
|
|
+export const tangentWorld = nodeImmutable( TangentNode, TangentNode.WORLD );
|
|
|
+export const transformedTangentView = nodeImmutable( VarNode, tangentView, 'TransformedTangentView' );
|
|
|
+export const transformedTangentWorld = normalize( transformDirection( transformedTangentView, cameraViewMatrix ) );
|
|
|
+
|
|
|
+export const bitangentGeometry = nodeImmutable( BitangentNode, BitangentNode.GEOMETRY );
|
|
|
+export const bitangentLocal = nodeImmutable( BitangentNode, BitangentNode.LOCAL );
|
|
|
+export const bitangentView = nodeImmutable( BitangentNode, BitangentNode.VIEW );
|
|
|
+export const bitangentWorld = nodeImmutable( BitangentNode, BitangentNode.WORLD );
|
|
|
+export const transformedBitangentView = normalize( mul( cross( transformedNormalView, transformedTangentView ), tangentGeometry.w ) );
|
|
|
+export const transformedBitangentWorld = normalize( transformDirection( transformedBitangentView, cameraViewMatrix ) );
|
|
|
+
|
|
|
+export const modelViewMatrix = nodeImmutable( ModelNode, ModelNode.VIEW_MATRIX );
|
|
|
+export const modelNormalMatrix = nodeImmutable( ModelNode, ModelNode.NORMAL_MATRIX );
|
|
|
+export const modelWorldMatrix = nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX );
|
|
|
+export const modelPosition = nodeImmutable( ModelNode, ModelNode.POSITION );
|
|
|
+export const modelViewPosition = nodeImmutable( ModelNode, ModelNode.VIEW_POSITION );
|
|
|
+
|
|
|
+export const positionGeometry = nodeImmutable( PositionNode, PositionNode.GEOMETRY );
|
|
|
+export const positionLocal = nodeImmutable( PositionNode, PositionNode.LOCAL );
|
|
|
+export const positionWorld = nodeImmutable( PositionNode, PositionNode.WORLD );
|
|
|
+export const positionView = nodeImmutable( PositionNode, PositionNode.VIEW );
|
|
|
+export const positionViewDirection = nodeImmutable( PositionNode, PositionNode.VIEW_DIRECTION );
|
|
|
+
|
|
|
+export const texture = nodeProxy( TextureNode );
|
|
|
+export const sampler = ( texture ) => nodeObject( new ConvertNode( texture.isNode === true ? texture : new TextureNode( texture ), 'sampler' ) );
|
|
|
+export const uv = ( ...params ) => nodeObject( new UVNode( ...params ) );
|
|
|
+export const pointUV = nodeImmutable( PointUVNode );
|
|
|
+
|
|
|
+// gpgpu
|
|
|
+
|
|
|
+export const compute = ( node, count, workgroupSize ) => nodeObject( new ComputeNode( nodeObject( node ), count, workgroupSize ) );
|
|
|
+
|
|
|
// display
|
|
|
|
|
|
export const frontFacing = nodeImmutable( FrontFacingNode );
|
|
@@ -274,4 +291,4 @@ export const element = nodeProxy( ArrayElementNode );
|
|
|
|
|
|
export const difference = ( a, b ) => nodeObject( abs( sub( a, b ) ) );
|
|
|
export const dotNV = clamp( dot( transformedNormalView, positionViewDirection ) );
|
|
|
-export const transformedNormalWorld = normalize( transformDirection( transformedNormalView, cameraViewMatrix ) );
|
|
|
+export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
|