playcanvas / playcanvas/engine
setParameter does not respect global scope value.
@mvaligursky is already working on this.
Since Oct 1, 2020.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
Using setParameter on some meshes/materials, sets it uniform values, but its also overrides global scope value - which is unintended when other meshes/materials have this uniform undefined.
It is useful to set some global uniforms:
// global value
var scopeGlobal = this.app.graphicsDevice.scope.resolve('custom_uniform');
scopeGlobal.setValue(globalValue);
And then be able to override them using local setParameter:
// local value
entity.model.meshInstances[0].setParameter('custom_unform', localValue);
Issue here, is once local value is set, it overrides global value, so further draw calls will have it, even if they have no local value defined. Basically leading to uniforms leak to other drawcalls.
Here is simple project, to demonstrate an issue: https://playcanvas.com/editor/scene/1000034
Only cube has setParameter called, but it also affects sphere.
Expected result would be: sphere to use global value, set once before.
Workaround is to find all meshes that need this uniform, and set them global value directly, but this is hard in dynamic scenes and not efficient.
Also ScopeSpace.prototype.getSubSpace is not used anywhere within engine, is it redundant?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.