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

Material cache non-unique hash - onBeforeCompile.toString #15948

Closed
3 of 13 tasks
ghost opened this issue Mar 11, 2019 · 2 comments
Closed
3 of 13 tasks

Material cache non-unique hash - onBeforeCompile.toString #15948

ghost opened this issue Mar 11, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 11, 2019

Description of the problem

Two different materials is being recognised as the same material here:

this.getProgramCode = function ( material, parameters ) {

let someString = 'a';
const materialA = new THREE.MeshBasicMaterial();
materialA.onBeforeCompile = function() {
  // do something with someString
}

someString = 'b';
const materialB = new THREE.MeshBasicMaterial();
materialB.onBeforeCompile = function() {
  // do something with someString
}

The hash of those materials will be the same when using onBeforeCompile.toString() but they do different things because of different variable values.

So the compiled version of materialA is equal to the compiled version of materialB when they are not equal.

Three.js version
  • Dev
  • r96
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)
@pailhead
Copy link
Contributor

pailhead commented Mar 16, 2019

This is not a bug this is a feature. Duplicate though:

#13192

Related:
#14232

Workarounds:
https://github.com/pailhead/three-refactor-chunk-material
https://medium.com/@pailhead011/extending-three-js-materials-with-glsl-78ea7bbb9270

Alternate proposal that has no issues with hashing:

#14231

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 17, 2019

This issue can be considered as a "Won't fix" (see #14245 (comment)).

@f1cognite Please use one of the existing workarounds to avoid the issue.

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