You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Edit @jsantell: Previously "Ensure that we can have as many instances of <xr-model> on a page as desired", using a single webgl context to circumvent the 16 context limit, and for performance improvements]
There is a limit of how many WebGL contexts a single document can have. I think it's 12.
One WebGLRenderingContext can be used to render all scenes by using Canvas2DRenderingContext's drawImage (three.js example, webxr-polyfill does the same thing to fake having two canvases). Might be a bit weird if elements are different sizes, may have to have the WebGL context at fullscreen size and change the viewport for every element. The WebGL context could be from an OffscreenCanvas on the main thread. Doesn't matter in this case.
I have a PR out for the webxr-polyfill that improves perf that handles the canvas copying with ImageBitmapRenderingContexts instead of Canvas2DRenderingContexts, using an async createImageBitmap(). In this case, each model element would be have an image bitmap and async create bitmaps from the WebGL context, which should be cheaper than drawImage. Bonus points, because then an OffscreenCanvas in a worker could be implemented resulting in the best perf option that won't block the main thread unless the GPU is completely clogged -- more info on this solution in the PR. OffscreenCanvas is still Chrome only, I think in 69.
An orthogonal solution could be using an Intersection Observer and lazily draw only models in view, but this probably not necessary off the bat.
@cdata not using post processing, we can use the regular WebGL context attribute antialias which works, but if we do use PP, then we'll use render targets which do not work with antialias, which means if we use any sort of PP, we'll need to add SSAA in the chain
changed the title [-]Ensure that we can have as many instances of `<xr-model>` on a page as desired[/-][+]Single WebGL Context for all elements[/+]on Oct 23, 2018
Activity
cdata commentedon Oct 18, 2018
@jsantell @mrdoob could you take a stab at describing the approaches you each mentioned to using a shared context?
jsantell commentedon Oct 19, 2018
There is a limit of how many WebGL contexts a single document can have. I think it's 12.
One WebGLRenderingContext can be used to render all scenes by using Canvas2DRenderingContext's
drawImage(three.js example, webxr-polyfill does the same thing to fake having two canvases). Might be a bit weird if elements are different sizes, may have to have the WebGL context at fullscreen size and change the viewport for every element. The WebGL context could be from an OffscreenCanvas on the main thread. Doesn't matter in this case.I have a PR out for the webxr-polyfill that improves perf that handles the canvas copying with ImageBitmapRenderingContexts instead of Canvas2DRenderingContexts, using an async
createImageBitmap(). In this case, each model element would be have an image bitmap and async create bitmaps from the WebGL context, which should be cheaper than drawImage. Bonus points, because then an OffscreenCanvas in a worker could be implemented resulting in the best perf option that won't block the main thread unless the GPU is completely clogged -- more info on this solution in the PR. OffscreenCanvas is still Chrome only, I think in 69.An orthogonal solution could be using an Intersection Observer and lazily draw only models in view, but this probably not necessary off the bat.
cdata commentedon Oct 19, 2018
@jsantell I like the fullscreen-sized context idea. Do you think that could obviate the need for post-processing antialiasing?
jsantell commentedon Oct 19, 2018
@cdata not using post processing, we can use the regular WebGL context attribute
antialiaswhich works, but if we do use PP, then we'll use render targets which do not work with antialias, which means if we use any sort of PP, we'll need to add SSAA in the chain[-]Ensure that we can have as many instances of `<xr-model>` on a page as desired[/-][+]Single WebGL Context for all elements[/+]jsantell commentedon Oct 23, 2018
Updated this issue to directly address the single webgl context solution. Opening issues for other performance improvements.
FWIW 16 is the max WebGL contexts I could create without things breaking
mrdoob commentedon Oct 24, 2018
I think it's 8 in mobile.
Try loading https://mrdoob.github.io/rome-gltf/ on mobile.
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes #10
Use a single WebGLContext for all model elements on a page. Fixes goo…
Use a single WebGLContext for all model elements on a page. Fixes #10