diff --git a/types/three/examples/jsm/nodes/Nodes.d.ts b/types/three/examples/jsm/nodes/Nodes.d.ts index 624caa154..20d259dca 100644 --- a/types/three/examples/jsm/nodes/Nodes.d.ts +++ b/types/three/examples/jsm/nodes/Nodes.d.ts @@ -9,6 +9,12 @@ export { default as BypassNode, bypass } from './core/BypassNode.js'; export { default as CacheNode, cache } from './core/CacheNode.js'; export { default as ConstNode } from './core/ConstNode.js'; export { default as ContextNode, context, label } from './core/ContextNode.js'; +export { + default as LightingModel, + LightingModelReflectedLight, + LightingModelDirectInput, + LightingModelIndirectInput, +} from './core/LightingModel.js'; export { default as Node } from './core/Node.js'; export { default as NodeAttribute } from './core/NodeAttribute.js'; export { default as NodeBuilder } from './core/NodeBuilder.js'; @@ -330,7 +336,7 @@ export { default as PointLightNode } from './lighting/PointLightNode.js'; export { default as SpotLightNode } from './lighting/SpotLightNode.js'; export { default as LightsNode, lights } from './lighting/LightsNode.js'; export { default as LightingNode } from './lighting/LightingNode.js'; -export { default as LightingContextNode, lightingContext, LightingModelNode } from './lighting/LightingContextNode.js'; +export { default as LightingContextNode, lightingContext } from './lighting/LightingContextNode.js'; export { default as HemisphereLightNode } from './lighting/HemisphereLightNode.js'; export { default as EnvironmentNode } from './lighting/EnvironmentNode.js'; export { default as AONode } from './lighting/AONode.js'; @@ -363,4 +369,5 @@ export { getDistanceAttenuation } from './lighting/LightUtils.js'; export { default as getGeometryRoughness } from './functions/material/getGeometryRoughness.js'; export { default as getRoughness } from './functions/material/getRoughness.js'; -export { default as physicalLightingModel } from './functions/PhysicalLightingModel.js'; +export { default as PhongLightingModel } from './functions/PhongLightingModel.js'; +export { default as PhysicalLightingModel } from './functions/PhysicalLightingModel.js'; diff --git a/types/three/examples/jsm/nodes/core/LightingModel.d.ts b/types/three/examples/jsm/nodes/core/LightingModel.d.ts new file mode 100644 index 000000000..d23fd3dde --- /dev/null +++ b/types/three/examples/jsm/nodes/core/LightingModel.d.ts @@ -0,0 +1,36 @@ +import Node from './Node.js'; +import NodeBuilder from './NodeBuilder.js'; +import StackNode from './StackNode.js'; + +export interface LightingModelReflectedLight { + directDiffuse: Node; + directSpecular: Node; + indirectDiffuse: Node; + indirectSpecular: Node; +} + +export interface LightingModelDirectInput { + lightDirection: Node; + lightColor: Node; + reflectedLight: LightingModelReflectedLight; +} + +export interface LightingModelIndirectInput { + radiance: Node; + irradiance: Node; + iblIrradiance: Node; + ambientOcclusion: Node; + reflectedLight: LightingModelReflectedLight; + backdrop: Node; + backdropAlpha: Node; + outgoingLight: Node; +} + +export default class LightingModel { + start(input: LightingModelIndirectInput, stack: StackNode, builder: NodeBuilder): void; + finish(input: LightingModelIndirectInput, stack: StackNode, builder: NodeBuilder): void; + direct(input: LightingModelDirectInput, stack: StackNode, builder: NodeBuilder): void; + indirectDiffuse(input: LightingModelIndirectInput, stack: StackNode, builder: NodeBuilder): void; + indirectSpecular(input: LightingModelIndirectInput, stack: StackNode, builder: NodeBuilder): void; + ambientOcclusion(input: LightingModelIndirectInput, stack: StackNode, builder: NodeBuilder): void; +} diff --git a/types/three/examples/jsm/nodes/core/NodeBuilder.d.ts b/types/three/examples/jsm/nodes/core/NodeBuilder.d.ts index f09aeb7d4..08f5dc143 100644 --- a/types/three/examples/jsm/nodes/core/NodeBuilder.d.ts +++ b/types/three/examples/jsm/nodes/core/NodeBuilder.d.ts @@ -17,6 +17,7 @@ import NodeParser from './NodeParser.js'; import NodeUniform from './NodeUniform.js'; import NodeVar from './NodeVar.js'; import NodeVarying from './NodeVarying.js'; +import StackNode from './StackNode.js'; export type BuildStageOption = 'construct' | 'analyze' | 'generate'; @@ -60,7 +61,7 @@ export default abstract class NodeBuilder { shaderStage: NodeShaderStage | null; buildStage: BuildStageOption | null; - stack: Node[]; + stack: StackNode; setHashNode(node: Node, hash: string): void; addNode(node: Node): void; diff --git a/types/three/examples/jsm/nodes/functions/PhongLightingModel.d.ts b/types/three/examples/jsm/nodes/functions/PhongLightingModel.d.ts new file mode 100644 index 000000000..49d02a593 --- /dev/null +++ b/types/three/examples/jsm/nodes/functions/PhongLightingModel.d.ts @@ -0,0 +1,7 @@ +import LightingModel from '../core/LightingModel.js'; + +export default class PhongLightingModel extends LightingModel { + specular: boolean; + + constructor(specular?: boolean); +} diff --git a/types/three/examples/jsm/nodes/functions/PhysicalLightingModel.d.ts b/types/three/examples/jsm/nodes/functions/PhysicalLightingModel.d.ts index f5f140349..6964b163a 100644 --- a/types/three/examples/jsm/nodes/functions/PhysicalLightingModel.d.ts +++ b/types/three/examples/jsm/nodes/functions/PhysicalLightingModel.d.ts @@ -1,11 +1,20 @@ -import { ShaderNode } from '../shadernode/ShaderNode.js'; +import LightingModel from '../core/LightingModel.js'; import Node from '../core/Node.js'; -declare const PhysicalLightingModel: { - direct: ShaderNode<{ lightDirection: Node; lightColor: Node; reflectedLight: Node }>; - indirectDiffuse: ShaderNode<{ irradiance: Node; reflectedLight: Node }>; - indirectSpecular: ShaderNode<{ radiance: Node; iblIrradiance: Node; reflectedLight: Node }>; - ambientOcclusion: ShaderNode<{ ambientOcclusion: Node; reflectedLight: Node }>; -}; +export default class PhysicalLightingModel extends LightingModel { + clearcoat: boolean; + sheen: boolean; + iridescence: boolean; -export default PhysicalLightingModel; + clearcoatRadiance: Node | null; + clearcoatSpecularDirect: Node | null; + clearcoatSpecularIndirect: Node | null; + sheenSpecularDirect: Node | null; + sheenSpecularIndirect: Node | null; + iridescenceFresnel: Node | null; + iridescenceF0: Node | null; + + constructor(clearcoat?: boolean, sheen?: boolean, iridescence?: boolean); + + computeMultiscattering(singleScatter: Node, multiScatter: Node, specularF90?: Node): void; +} diff --git a/types/three/examples/jsm/nodes/lighting/LightingContextNode.d.ts b/types/three/examples/jsm/nodes/lighting/LightingContextNode.d.ts index c3cbfe0df..0ade3c7c5 100644 --- a/types/three/examples/jsm/nodes/lighting/LightingContextNode.d.ts +++ b/types/three/examples/jsm/nodes/lighting/LightingContextNode.d.ts @@ -1,23 +1,24 @@ import ContextNode from '../core/ContextNode.js'; import Node from '../core/Node.js'; -import { ShaderNode, ShaderNodeObject } from '../shadernode/ShaderNode.js'; - -export interface LightingModelNode { - indirectDiffuse?: ShaderNode; - indirectSpecular?: ShaderNode; - ambientOcclusion?: ShaderNode; -} +import { ShaderNodeObject } from '../shadernode/ShaderNode.js'; +import LightingModel, { LightingModelIndirectInput } from '../core/LightingModel.js'; export default class LightingContextNode extends ContextNode { - lightingModelNode: LightingModelNode | null; + lightingModelNode: LightingModel | null; + backdropNode: Node | null; + backdropAlphaNode: Node | null; + + constructor( + node: Node, + lightingModel?: LightingModel | null, + backdropNode?: Node | null, + backdropAlphaNode?: Node | null, + ); - constructor(node: Node, lightingModelNode?: LightingModelNode | null); + getContext(): LightingModelIndirectInput; } -export const lightingContext: ( - node: Node, - lightingModelNode?: LightingModelNode, -) => ShaderNodeObject; +export const lightingContext: (node: Node, lightingModelNode?: LightingModel) => ShaderNodeObject; declare module '../shadernode/ShaderNode.js' { interface NodeElements { diff --git a/types/three/examples/jsm/nodes/materials/NodeMaterial.d.ts b/types/three/examples/jsm/nodes/materials/NodeMaterial.d.ts index f2f781dd3..3960a257d 100644 --- a/types/three/examples/jsm/nodes/materials/NodeMaterial.d.ts +++ b/types/three/examples/jsm/nodes/materials/NodeMaterial.d.ts @@ -16,6 +16,8 @@ import MeshPhysicalNodeMaterial from './MeshPhysicalNodeMaterial.js'; import MeshStandardNodeMaterial from './MeshStandardNodeMaterial.js'; import PointsNodeMaterial from './PointsNodeMaterial.js'; import SpriteNodeMaterial from './SpriteNodeMaterial.js'; +import LightsNode from '../lighting/LightsNode.js'; +import LightingModel from '../core/LightingModel.js'; export default class NodeMaterial extends ShaderMaterial { readonly isNodeMaterial: true; @@ -24,7 +26,7 @@ export default class NodeMaterial extends ShaderMaterial { colorSpaced: boolean; - lightsNode: Node | null; + lightsNode: LightsNode | null; envNode: Node | null; colorNode: Node | null; @@ -48,15 +50,15 @@ export default class NodeMaterial extends ShaderMaterial { build(builder: NodeBuilder): void; setup(builder: NodeBuilder): void; setupDepth(builder: NodeBuilder): void; - setupPosition(builder: NodeBuilder): void; + setupPosition(builder: NodeBuilder): Node; setupDiffuseColor(builder: NodeBuilder): void; setupVariants(builder: NodeBuilder): void; - setupNormal(): void; - getEnvNode(builder: NodeBuilder): void; - setupLights(builder: NodeBuilder): void; - setupLightingModel(builder: NodeBuilder): void; - setupLighting(builder: NodeBuilder): void; - setupOutput(builder: NodeBuilder, outputNode: Node): void; + setupNormal(builder: NodeBuilder): void; + getEnvNode(builder: NodeBuilder): Node | null; + setupLights(builder: NodeBuilder): LightsNode; + setupLightingModel(builder: NodeBuilder): LightingModel; + setupLighting(builder: NodeBuilder): Node; + setupOutput(builder: NodeBuilder, outputNode: Node): Node; setDefaultValues(material: Material): void;