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

Mechanism for batching of WebGL draw calls #209

Open
davidedc opened this issue Dec 2, 2013 · 0 comments
Open

Mechanism for batching of WebGL draw calls #209

davidedc opened this issue Dec 2, 2013 · 0 comments

Comments

@davidedc
Copy link
Owner

davidedc commented Dec 2, 2013

We currently have one WebGL draw call for each primitive we have on screen (two if we have both the fill and the stroke).

Performance would probably be much better by having fewer WebGL draw calls, which can done by packaging the information in a clever way. For example a thousand cubes can be batched by sending, together with the vertex data, also the world matrix info for each cube, the color and the transparency of each cube. The shader would then do everything on a batch of cubes instead than for each cube. The principle is explained here: http://youtu.be/rfQ8rKGTVlg?t=14m44s : the shader (and its invocation) are crafted so to take a bunch of cubes, each with their world matrix and their per-cube information. So the shader processes all the cubes at once, with dramatic performance improvement.

Reading this thread mrdoob/three.js#4160 on the three.js github, it looks like this could be done in Three.js by doing a merge every frame, passing custom attributes (for the time being I think it's just one/two matrixes, one transparency, one color for each object of the merged mesh) to a slightly modified shader.

This could really speed up things big times (some investigation required) - so maybe worth doing one day.

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

1 participant