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

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Aug 19, 2020

NodeMaterial.onBeforeCompile() should not access materialProperties which is for internal use only. AFAICS, after the introduction of NodeMaterial.getHash() and the refactoring of when onBeforeCompile() is executed in WebGLRenderer, this check is not necessary anymore.

Sidenote: In order to solve #15047, the access to renderer internals like materialProperties should stop anyway.

@Mugen87 Mugen87 requested a review from sunag August 19, 2020 11:56

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.

Copy link
Collaborator

@sunag sunag left a comment

Choose a reason for hiding this comment

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

Nice @Mugen87

@Mugen87 Mugen87 added this to the r120 milestone Aug 19, 2020
@mrdoob mrdoob merged commit b67ceb2 into mrdoob:dev Aug 19, 2020
@mrdoob
Copy link
Owner

mrdoob commented Aug 19, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants