Skip to content

Commit c2c9d55

Browse files
authored
Merge pull request #17368 from sunag/dev2-ibl-irradiance-nodes
NodeMaterial - refactoring based in PRs merged
2 parents 55263f9 + 7c936ea commit c2c9d55

17 files changed

+185
-257
lines changed

examples/jsm/nodes/Nodes.d.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ export * from './math/CondNode';
5757
export * from './procedural/NoiseNode';
5858
export * from './procedural/CheckerNode';
5959

60-
// bsdfs
61-
62-
export * from './bsdfs/BlinnShininessExponentNode';
63-
export * from './bsdfs/BlinnExponentToRoughnessNode';
64-
export * from './bsdfs/RoughnessToBlinnExponentNode';
65-
6660
// misc
6761

6862
export * from './misc/TextureCubeUVNode';
@@ -79,6 +73,7 @@ export * from './utils/TimerNode';
7973
export * from './utils/VelocityNode';
8074
export * from './utils/UVTransformNode';
8175
export * from './utils/MaxMIPLevelNode';
76+
export * from './utils/SpecularMIPLevelNode';
8277
export * from './utils/ColorSpaceNode';
8378

8479
// effects

examples/jsm/nodes/Nodes.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ export { CondNode } from './math/CondNode.js';
5959
export { NoiseNode } from './procedural/NoiseNode.js';
6060
export { CheckerNode } from './procedural/CheckerNode.js';
6161

62-
// bsdfs
63-
64-
export { BlinnShininessExponentNode } from './bsdfs/BlinnShininessExponentNode.js';
65-
export { BlinnExponentToRoughnessNode } from './bsdfs/BlinnExponentToRoughnessNode.js';
66-
export { RoughnessToBlinnExponentNode } from './bsdfs/RoughnessToBlinnExponentNode.js';
67-
6862
// misc
6963

7064
export { TextureCubeUVNode } from './misc/TextureCubeUVNode.js';
@@ -81,6 +75,7 @@ export { TimerNode } from './utils/TimerNode.js';
8175
export { VelocityNode } from './utils/VelocityNode.js';
8276
export { UVTransformNode } from './utils/UVTransformNode.js';
8377
export { MaxMIPLevelNode } from './utils/MaxMIPLevelNode.js';
78+
export { SpecularMIPLevelNode } from './utils/SpecularMIPLevelNode.js';
8479
export { ColorSpaceNode } from './utils/ColorSpaceNode.js';
8580
export { SubSlotNode } from './utils/SubSlotNode.js';
8681

examples/jsm/nodes/accessors/ReflectNode.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,22 @@ ReflectNode.prototype.generate = function ( builder, output ) {
5555
case ReflectNode.VECTOR:
5656

5757
var viewNormalNode = builder.context.viewNormal || new NormalNode();
58+
var roughnessNode = builder.context.roughness;
5859

5960
var viewNormal = viewNormalNode.build( builder, 'v3' );
6061
var viewPosition = new PositionNode( PositionNode.VIEW ).build( builder, 'v3' );
62+
var roughness = roughnessNode ? roughnessNode.build( builder, 'f' ) : undefined;
6163

62-
var code = `inverseTransformDirection( reflect( -normalize( ${viewPosition} ), ${viewNormal} ), viewMatrix )`;
64+
var method = `reflect( -normalize( ${viewPosition} ), ${viewNormal} )`;
65+
66+
if ( viewNormalNode && roughness ) {
67+
68+
// Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.
69+
method = `normalize( mix( ${method}, ${viewNormal}, ${roughness} * ${roughness} ) )`;
70+
71+
}
72+
73+
var code = `inverseTransformDirection( ${method}, viewMatrix )`;
6374

6475
if ( isUnique ) {
6576

examples/jsm/nodes/bsdfs/BlinnExponentToRoughnessNode.d.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/jsm/nodes/bsdfs/BlinnExponentToRoughnessNode.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

examples/jsm/nodes/bsdfs/BlinnShininessExponentNode.d.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/jsm/nodes/bsdfs/BlinnShininessExponentNode.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/jsm/nodes/bsdfs/RoughnessToBlinnExponentNode.js

Lines changed: 0 additions & 94 deletions
This file was deleted.

examples/jsm/nodes/inputs/CubeTextureNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ CubeTextureNode.prototype.generate = function ( builder, output ) {
4141

4242
if ( bias === undefined && builder.context.bias ) {
4343

44-
bias = new builder.context.bias( this ).build( builder, 'f' );
44+
bias = builder.context.bias.setTexture( this ).build( builder, 'f' );
4545

4646
}
4747

examples/jsm/nodes/inputs/TextureNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ TextureNode.prototype.generate = function ( builder, output ) {
4242

4343
if ( bias === undefined && builder.context.bias ) {
4444

45-
bias = new builder.context.bias( this ).build( builder, 'f' );
45+
bias = builder.context.bias.setTexture( this ).build( builder, 'f' );
4646

4747
}
4848

0 commit comments

Comments
 (0)