Skip to content

Commit 807d042

Browse files
authored
LightingModel: Refactor indirect lighting (#28824)
1 parent 6b23527 commit 807d042

6 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/nodes/core/LightingModel.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ class LightingModel {
88

99
directRectArea( /*input, stack, builder*/ ) {}
1010

11-
indirectDiffuse( /*input, stack, builder*/ ) { }
12-
13-
indirectSpecular( /*input, stack, builder*/ ) { }
11+
indirect( /*input, stack, builder*/ ) { }
1412

1513
ambientOcclusion( /*input, stack, builder*/ ) { }
1614

src/nodes/functions/BasicLightingModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BasicLightingModel extends LightingModel {
1212

1313
}
1414

15-
indirectDiffuse( { ambientOcclusion, reflectedLight } ) {
15+
indirect( { ambientOcclusion, reflectedLight } ) {
1616

1717
reflectedLight.indirectDiffuse.addAssign( diffuseColor.rgb );
1818

src/nodes/functions/PhongLightingModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class PhongLightingModel extends BasicLightingModel {
5656

5757
}
5858

59-
indirectDiffuse( { ambientOcclusion, irradiance, reflectedLight } ) {
59+
indirect( { ambientOcclusion, irradiance, reflectedLight } ) {
6060

6161
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );
6262

src/nodes/functions/PhysicalLightingModel.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,14 @@ class PhysicalLightingModel extends LightingModel {
507507

508508
}
509509

510+
indirect( context, stack, builder ) {
511+
512+
this.indirectDiffuse( context, stack, builder );
513+
this.indirectSpecular( context, stack, builder );
514+
this.ambientOcclusion( context, stack, builder );
515+
516+
}
517+
510518
indirectDiffuse( { irradiance, reflectedLight } ) {
511519

512520
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );

src/nodes/functions/ToonLightingModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ToonLightingModel extends LightingModel {
3838

3939
}
4040

41-
indirectDiffuse( { ambientOcclusion, irradiance, reflectedLight } ) {
41+
indirect( { ambientOcclusion, irradiance, reflectedLight } ) {
4242

4343
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );
4444

src/nodes/lighting/LightsNode.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ class LightsNode extends Node {
9999

100100
//
101101

102-
lightingModel.indirectDiffuse( context, stack, builder );
103-
lightingModel.indirectSpecular( context, stack, builder );
104-
lightingModel.ambientOcclusion( context, stack, builder );
102+
lightingModel.indirect( context, stack, builder );
105103

106104
//
107105

0 commit comments

Comments
 (0)