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

Improve model shader caching #9141

Open
lilleyse opened this issue Sep 6, 2020 · 0 comments
Open

Improve model shader caching #9141

lilleyse opened this issue Sep 6, 2020 · 0 comments

Comments

@lilleyse
Copy link
Contributor

lilleyse commented Sep 6, 2020

Model.js caches shaders so that multiple Model instances that load the same glTF can share the same GL shader program. A model recreates a new shader for itself when it toggles a feature that would alter the shader source, such as clipping planes or color blend mode. One case where this is wasteful is when clipping planes are added to a 3D Tileset because all of the tiles recreate their own shader instead of sharing.

Model.js should have a global shader cache similar to GlobeSurfaceShaderSet where it caches based on feature state. This way shaders can be shared across many different glTFs. While CesiumJS has a lower-level shader cache this new system would avoid unnecessary processing.

One example where the old system has a bug is when a model has both clipping planes and specular environment maps and clipping planes get turned off. The model will fall back to the cached shader which didn't include the specular environment map code because the environment map wasn't ready when the shader was first created. This would be fixed in the new system if the shader key incorporates both the clipping plane and IBL state.

Peek 2020-09-06 14-34

Sandcastle

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

No branches or pull requests

2 participants