Comments (5)
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.
@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.
Good point. Thanks for the link!
from webgl.
Related Issues (20)
- Memory leak when creating a mesh in update/view HOT 1
- Version 1.1.0 Runtime error "Uncaught Error: Trying to use (==)"
- Use gl.drawArrays for non-indexed meshes
- Hot-reloading corrupts shaders HOT 2
- Allow efficiently clearing depth and stencil buffers
- Allow creation of Textures from existing image data HOT 1
- Redundant WebGL calls HOT 5
- Add support for OES_standard_derivatives extension?
- Add premultiply option for texture loading
- Cache attribute locations for a program
- WebGL content can fail to show up immediately on Edge HOT 1
- Parallelise shader compilation and programs linking
- Don't bind attribute buffers for the same program if they don't change
- Enable OES_element_index_uint
- Workaround for uniform array type inference failure HOT 2
- Inconsistent default behavior for WebGL.entity between Firefox and Chrome HOT 4
- Dynamic textures support HOT 5
- Dynamic mesh support HOT 5
- GLSL with apostrophes breaks JS output HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webgl.