Skip to content

Commit

Permalink
NodeMaterial: Fix env map for lambert and phong.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Jul 5, 2024
1 parent 5ee01f0 commit 2202035
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/nodes/materials/MeshLambertNodeMaterial.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
import BasicEnvironmentNode from '../lighting/BasicEnvironmentNode.js';
import PhongLightingModel from '../functions/PhongLightingModel.js';

import { MeshLambertMaterial } from '../../materials/MeshLambertMaterial.js';
Expand All @@ -21,6 +22,14 @@ class MeshLambertNodeMaterial extends NodeMaterial {

}

setupEnvironment( builder ) {

const envNode = super.setupEnvironment( builder );

return envNode ? new BasicEnvironmentNode( envNode ) : null;

}

setupLightingModel( /*builder*/ ) {

return new PhongLightingModel( false ); // ( specular ) -> force lambert
Expand Down
8 changes: 8 additions & 0 deletions src/nodes/materials/MeshPhongNodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
import { shininess, specularColor } from '../core/PropertyNode.js';
import { materialShininess, materialSpecular } from '../accessors/MaterialNode.js';
import { float } from '../shadernode/ShaderNode.js';
import BasicEnvironmentNode from '../lighting/BasicEnvironmentNode.js';
import PhongLightingModel from '../functions/PhongLightingModel.js';

import { MeshPhongMaterial } from '../../materials/MeshPhongMaterial.js';
Expand All @@ -27,6 +28,13 @@ class MeshPhongNodeMaterial extends NodeMaterial {

}

setupEnvironment( builder ) {

const envNode = super.setupEnvironment( builder );

return envNode ? new BasicEnvironmentNode( envNode ) : null;

}
setupLightingModel( /*builder*/ ) {

return new PhongLightingModel();
Expand Down

0 comments on commit 2202035

Please sign in to comment.