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: Do not access materialProperties. #20126

Merged
merged 1 commit into from
Aug 19, 2020
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
14 changes: 4 additions & 10 deletions examples/jsm/nodes/materials/NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,11 @@ Object.defineProperties( NodeMaterial.prototype, {

NodeMaterial.prototype.onBeforeCompile = function ( shader, renderer ) {

var materialProperties = renderer.properties.get( this );
this.build( { renderer: renderer } );

if ( this.version !== materialProperties.__version ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what did this code check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Material.onBeforeCompile() was previously called way more often than now, I suspect this check should prevent unnecessary material builds. However, just checking for materialProperties.__version is not correct anyway since program updates might be necessary because of other reasons (e.g. WebGLRenderer.outputEncoding changes).

Hence, it's more correct if the material system let WebGLRenderer decide when to update shaders.


this.build( { renderer: renderer } );

shader.uniforms = this.uniforms;
shader.vertexShader = this.vertexShader;
shader.fragmentShader = this.fragmentShader;

}
shader.uniforms = this.uniforms;
shader.vertexShader = this.vertexShader;
shader.fragmentShader = this.fragmentShader;

};

Expand Down