Comments (2)
Currently conflicted on this. Compiling shaders is expensive, so I wouldn't want to introduce that as a best practice. I know that one of your use cases is the ability to add multiple lights. In practice, what happens?
- Recompile shaders as the number of lights in your scene changes
- Have a fixed length array of lights, so you can have up to N lights?
I admit I don't know much about where/why arrays are used in WebGL and am unfamiliar with best practices here.
Just so you're aware, I really don't want to break the current "guarantee" that you never get a runtime exception from missing attributes. Imagine if I passed in either an empty List or empty Array, but my shader expects a non-empty sequence. So homogenous tuples really might be the best fit in the interim that Elm doesn't have first-class fixed-length sequences.
from elm-webgl.
I understand. Yeah, I've lately been searching the interwebs and I don't seem to see like there is much of a consensus. I'm not an expert in WebGL which is why I've decided to see what others have done.
Seems like the threejs guys bumped into this problem a few years back.
Their solution was just to put this flag at the API level so that the users figure out the best course of action. Basically, how it works is that if the user is ever gonna do something funky like change the size of an array which is passed as a uniform, they should set material.needsUpdate
to true
to tell Three.js to actually recompile the shaders.
This problem seems to be really common, as in here and here, although the latter has just a tiny mention about the dynamic compilation of shaders.
I know that the guarantee of types is super duper important because it allows for the awesome feature that the compiler can yell at you for not sending the right types to the GPU (which saves headaches cuz I've come to realize how bad the error messages, if any, from the GPU are).
That said, the problem with tuples, unless I'm missing something, is that its much harder to work with cuz every tuple is fundamentally a different type. I'm not an FP ninja, but how do you pattern-match on an n-tuple when n is unknown?
I'm leaning more on passing Array and warning users to exercise caution when using them. Like, if you pass an empty array, you'd get the MAX_ARRAY_LENGTH
set to 0
and should warn users to use if statements or if-def guards when working with arrays.
Pity GLSL doesn't have Maybe, that would've helped us in this case.
from elm-webgl.
Related Issues (20)
- Rename zipTriangle to mapTriangle2? HOT 2
- Add support for passing structs as uniforms HOT 3
- Add support for passing booleans as uniforms HOT 2
- Add support for lines HOT 1
- Add/Test/Change native support for passing arrays of Entity to webgl HOT 7
- Mouse.position change not reflected HOT 1
- Package fails to install and reports missing elm-package.json HOT 1
- What kind of syntantic construct is [glsl| ... |] ? HOT 1
- regression: texture load timeout HOT 1
- Need Access to RenderingContext to change blendmode HOT 3
- Links to the examples in the README HOT 1
- Version 4.0.x is totally untested HOT 2
- port Task WebGL.Error Texture HOT 1
- Texture loading does not work, causes runtime error "fun(...) is not a function" HOT 2
- There is no way to specify WebGL context attributes
- Unable to install elm packages for examples HOT 3
- Examples linked in README don't work
- Elm 0.17 support HOT 1
- Mysterious variable? HOT 2
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 elm-webgl.