-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebGPURenderer: Add MeshLambertNodeMaterial (#26448)
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import BRDF_Lambert from './BSDF/BRDF_Lambert.js'; | ||
import { lightingModel } from '../core/LightingModel.js'; | ||
import { diffuseColor } from '../core/PropertyNode.js'; | ||
import { transformedNormalView } from '../accessors/NormalNode.js'; | ||
import { tslFn } from '../shadernode/ShaderNode.js'; | ||
|
||
const RE_Direct_Lambert = tslFn( ( { lightDirection, lightColor, reflectedLight } ) => { | ||
|
||
const dotNL = transformedNormalView.dot( lightDirection ).clamp(); | ||
const irradiance = dotNL.mul( lightColor ); | ||
|
||
reflectedLight.directDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor: diffuseColor.rgb } ) ) ); | ||
|
||
} ); | ||
|
||
const RE_IndirectDiffuse_Lambert = tslFn( ( { irradiance, reflectedLight } ) => { | ||
|
||
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) ); | ||
|
||
} ); | ||
|
||
const lambertLightingModel = lightingModel( null, RE_Direct_Lambert, RE_IndirectDiffuse_Lambert ); | ||
|
||
export default lambertLightingModel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js'; | ||
import lambertLightingModel from '../functions/LambertLightingModel.js'; | ||
|
||
import { MeshLambertMaterial } from 'three'; | ||
|
||
const defaultValues = new MeshLambertMaterial(); | ||
|
||
class MeshLambertNodeMaterial extends NodeMaterial { | ||
|
||
constructor( parameters ) { | ||
|
||
super(); | ||
|
||
this.isMeshLambertNodeMaterial = true; | ||
|
||
this.lights = true; | ||
|
||
this.setDefaultValues( defaultValues ); | ||
|
||
this.setValues( parameters ); | ||
|
||
} | ||
|
||
constructLightingModel( /*builder*/ ) { | ||
|
||
return lambertLightingModel; | ||
|
||
} | ||
|
||
} | ||
|
||
export default MeshLambertNodeMaterial; | ||
|
||
addNodeMaterial( MeshLambertNodeMaterial ); |