Skip to content

Commit

Permalink
Nodes: Simplify builder.createNodeMaterial() usage (#27580)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Jan 17, 2024
1 parent 21b0b81 commit 9eefe18
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/jsm/nodes/core/NodeBuilder.js
Expand Up @@ -1171,7 +1171,7 @@ class NodeBuilder {

}

createNodeMaterial( type ) {
createNodeMaterial( type = 'NodeMaterial' ) {

return createNodeMaterialFromType( type );

Expand Down
3 changes: 1 addition & 2 deletions examples/jsm/nodes/display/AfterImageNode.js
Expand Up @@ -108,8 +108,7 @@ class AfterImageNode extends TempNode {

//

const materialComposed = this._materialComposed || ( this._materialComposed = builder.createNodeMaterial( 'MeshBasicNodeMaterial' ) );
materialComposed.toneMapped = false;
const materialComposed = this._materialComposed || ( this._materialComposed = builder.createNodeMaterial() );
materialComposed.fragmentNode = afterImg();

quadMeshComp.material = materialComposed;
Expand Down
3 changes: 1 addition & 2 deletions examples/jsm/nodes/display/GaussianBlurNode.js
Expand Up @@ -139,8 +139,7 @@ class GaussianBlurNode extends TempNode {

//

const material = this._material || ( this._material = builder.createNodeMaterial( 'MeshBasicNodeMaterial' ) );
material.toneMapped = false;
const material = this._material || ( this._material = builder.createNodeMaterial() );
material.fragmentNode = blur();

//
Expand Down
13 changes: 9 additions & 4 deletions examples/jsm/nodes/lighting/AnalyticLightNode.js
Expand Up @@ -2,7 +2,7 @@ import LightingNode from './LightingNode.js';
import { NodeUpdateType } from '../core/constants.js';
import { uniform } from '../core/UniformNode.js';
import { addNodeClass } from '../core/Node.js';
import { /*vec2,*/ vec3 } from '../shadernode/ShaderNode.js';
import { /*vec2,*/ vec3, vec4 } from '../shadernode/ShaderNode.js';
import { reference } from '../accessors/ReferenceNode.js';
import { texture } from '../accessors/TextureNode.js';
import { positionWorld } from '../accessors/PositionNode.js';
Expand All @@ -12,7 +12,7 @@ import { WebGPUCoordinateSystem } from 'three';

import { Color, DepthTexture, NearestFilter, LessCompare } from 'three';

let depthMaterial = null;
let overrideMaterial = null;

class AnalyticLightNode extends LightingNode {

Expand Down Expand Up @@ -54,7 +54,12 @@ class AnalyticLightNode extends LightingNode {

if ( shadowNode === null ) {

if ( depthMaterial === null ) depthMaterial = builder.createNodeMaterial( 'MeshBasicNodeMaterial' );
if ( overrideMaterial === null ) {

overrideMaterial = builder.createNodeMaterial();
overrideMaterial.fragmentNode = vec4( 1 );

}

const shadow = this.light.shadow;
const rtt = builder.getRenderTarget( shadow.mapSize.width, shadow.mapSize.height );
Expand Down Expand Up @@ -169,7 +174,7 @@ class AnalyticLightNode extends LightingNode {

const currentOverrideMaterial = scene.overrideMaterial;

scene.overrideMaterial = depthMaterial;
scene.overrideMaterial = overrideMaterial;

rtt.setSize( light.shadow.mapSize.width, light.shadow.mapSize.height );

Expand Down

0 comments on commit 9eefe18

Please sign in to comment.