Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeMaterial: Only call setupDepth() with active depth buffer. #29799

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/materials/nodes/NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class NodeMaterial extends Material {

builder.context.setupNormal = () => this.setupNormal( builder );

const renderer = builder.renderer;
const renderTarget = renderer.getRenderTarget();

// < VERTEX STAGE >

builder.addStack();
Expand All @@ -121,7 +124,21 @@ class NodeMaterial extends Material {

const clippingNode = this.setupClipping( builder );

if ( this.depthWrite === true ) this.setupDepth( builder );
if ( this.depthWrite === true ) {

// only write depth if depth buffer is configured

if ( renderTarget !== null ) {

if ( renderTarget.depthBuffer === true ) this.setupDepth( builder );

} else {

if ( renderer.depth === true ) this.setupDepth( builder );

}

}

if ( this.fragmentNode === null ) {

Expand All @@ -148,11 +165,9 @@ class NodeMaterial extends Material {

// MRT

const renderTarget = builder.renderer.getRenderTarget();

if ( renderTarget !== null ) {

const mrt = builder.renderer.getMRT();
const mrt = renderer.getMRT();
const materialMRT = this.mrtNode;

if ( mrt !== null ) {
Expand Down