Giter Club home page Giter Club logo

Comments (6)

cdata avatar cdata commented on May 11, 2024

@jsantell @mrdoob could you take a stab at describing the approaches you each mentioned to using a shared context?

from model-viewer.

jsantell avatar jsantell commented on May 11, 2024

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.

from model-viewer.

cdata avatar cdata commented on May 11, 2024

@jsantell I like the fullscreen-sized context idea. Do you think that could obviate the need for post-processing antialiasing?

from model-viewer.

jsantell avatar jsantell commented on May 11, 2024

@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

from model-viewer.

jsantell avatar jsantell commented on May 11, 2024

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

from model-viewer.

mrdoob avatar mrdoob commented on May 11, 2024

FWIW 16 is the max WebGL contexts I could create without things breaking

I think it's 8 in mobile.

Try loading https://mrdoob.github.io/rome-gltf/ on mobile.

from model-viewer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.