Giter Site home page Giter Site logo

Mesh instancing support about webgl HOT 5 OPEN

elm-explorations avatar elm-explorations commented on July 28, 2024 1
Mesh instancing support

from webgl.

Comments (5)

MartinSStewart avatar MartinSStewart commented on July 28, 2024

I've done some research. It looks like WebGL 1* only supports instancing via ANGLE_instanced_arrays. Unfortunately this doesn't suppprt my idea of having an array of uniform groups and running the vertex shader on all the attributes once for each group of uniforms. As I understand it, you instead include an additional attribute array that only advances after all of the "normal" attributes have been used by the vertex shader.

Since we need to use attribute arrays instead of an array of uniforms groups to get instancing to work, my guess is that a new function and new shader type will be needed. Something like this:

manyEntities : 
    InstanceShader attributes perInstanceAttributes uniforms varyings
    -> Shader {} uniforms varyings
    -> Mesh attributes
    -> List perInstanceAttributes -- List.length here determines how many instances we draw. Also unlike attributes, perInstanceAttributes will change often.
    -> uniforms -- Same data is used for all instances
    -> Entity

I imagine adding a new shader type is a substantial change. Maybe even requires changes to the compiler. I think it's worthwhile but I imagine it won't be added anytime soon.

I haven't worked with WebGL much so someone let me know if I'm totally off track or if there's a better solution.

*I'm assuming this package targets WebGL 1 because version 2 isn't supported on Safari or Edge yet.

from webgl.

w0rm avatar w0rm commented on July 28, 2024

@MartinSStewart thanks for investigating this use case! I'm not exactly sure if we should add custom api for each custom use case like this, or we should rather model WebGL api to be lower level than it is now.

By the way, there is a post on discourse about rendering particles. I linked to this issue from there.

from webgl.

MartinSStewart avatar MartinSStewart commented on July 28, 2024

Good point. Thanks for the link!

from webgl.

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.