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

Allow custom vertex shader chunks to work with dynamic batching #1227

Open
Glidias opened this issue Jun 5, 2018 · 0 comments
Open

Allow custom vertex shader chunks to work with dynamic batching #1227

Glidias opened this issue Jun 5, 2018 · 0 comments
Assignees
Labels
area: graphics Graphics related issue

Comments

@Glidias
Copy link
Contributor

Glidias commented Jun 5, 2018

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. #

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
None yet
Development

No branches or pull requests

3 participants