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

Update materialProperties.environment even if program doesn't change #19027

Merged
merged 1 commit into from
Apr 4, 2020

Conversation

Oletus
Copy link
Contributor

@Oletus Oletus commented Apr 3, 2020

The environment map can be switched to a different image while still using the exact same shader. It's important to update materialProperties.environment in this case so that unnecessary calls to initMaterial can be avoided. Prior to this fix FPS could be halved after changing scene.environment to a different texture of the same type.

The environment map can be switched to a different image while still using the exact same shader. It's important to update materialProperties.environment in this case so that unnecessary calls to initMaterial can be avoided. Prior to this fix FPS could be halved after changing scene.environment.
@Oletus
Copy link
Contributor Author

Oletus commented Apr 3, 2020

@mrdoob @Mugen87 I hope this could be reviewed and merged soon, this bug had a really big impact on the performance of our app when trying to use scene.environment.

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 3, 2020

Okay, I see the issue. When Scene.environment is changed, initMaterial() is called because of the following check:

} else if ( materialProperties.environment !== environment ) {
initMaterial( material, scene, object );

However, since the shader program does not change, initMaterial() never updates the internal materialProperties object. So the change does make sense however I would move the line to:

materialProperties.fog = scene.fog;

In this way, the scene properties (fog and environment) are managed at the same place.

@mrdoob mrdoob added this to the r116 milestone Apr 3, 2020
@mrdoob
Copy link
Owner

mrdoob commented Apr 3, 2020

What @Mugen87 said. I'll merge and clean up 👍

@mrdoob mrdoob merged commit 9be3b98 into mrdoob:dev Apr 4, 2020
@mrdoob
Copy link
Owner

mrdoob commented Apr 4, 2020

Thanks!

@Oletus
Copy link
Contributor Author

Oletus commented Apr 4, 2020

Thanks for the really quick turnaround on this, the cleanup makes sense! 👍

@Oletus Oletus deleted the fix-initmaterial-repeat branch April 4, 2020 07:02
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