playcanvas / playcanvas/engine
Allow custom vertex shader chunks to work with dynamic batching
@mvaligursky is already working on this.
Since Feb 7, 2020.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
The current batching.js has rather unnecessary this references to global pc.shaderChunks defaults.
this.transformVS = boneLimit + "#define DYNAMICBATCH\n" + pc.shaderChunks.transformVS;
this.skinTexVS = pc.shaderChunks.skinBatchTexVS;
this.skinConstVS = pc.shaderChunks.skinBatchConstVS;
It prevents custom vertex shader chunks to work with dynamic batching....since it re-overwrites them back to defaults!
if (dynamic) {
// Patch the material
material = material.clone();
material.chunks.transformVS = this.transformVS;
material.chunks.skinTexVS = this.skinTexVS;
material.chunks.skinConstVS = this.skinConstVS;
material.update();
}
why not: save the device boneLimit if needed....and then...
if (dynamic) {
// Patch the material
material = material.clone();
material.chunks.transformVS = boneLimit + "#define DYNAMICBATCH\n" + (material.chunks.transformVS ? material.chunks.transformVS : pc.shaderChunks.transformVS);// this.transformVS;
material.chunks.skinTexVS = (material.chunks.skinBatchTexVS ? material.chunks.skinBatchTexVS : pc.shaderChunks.skinBatchTexVS);
material.chunks.skinConstVS = (material.chunks.skinBatchConstVS ? material.chunks.skinBatchConstVS : pc.shaderChunks.skinBatchConstVS);
material.update();
}
That way, you check if there's any available custom implementations of those chunks before the batching occurs.
The tricky thing is he might assign Batch group within editor, and then sets material custom chunk later during a script.initialize() ...but he will need some way of informing the batch group to re-update, which can be tricky... Anyway of syncronising these aspects between custom vertex shader chunk settings and batching intialization? I see no way short of manually triggering the batching except by code or manual intiialization of batches by having batched entities within scene remain disabled first. Set custom vertex shader chunks first, then call batching manager to re-update. #
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.