Comments (4)
will log to console.error
by default unless quiet: true
(for unit tests etc)
though console.warn
looks nice too
from glo.
looking into this a bit more. the shader wrapper that stackgl uses is quite nice since it allows for a clean way of handling structs and arrays:
shader.uniforms.lights[0] = {
position: ...
}
Compare with string-based access.
The downside is that you end up very easily calling glGetUniform
which can destroy framerate, and also it doesn't behave like you would expect. Generally using getter/setter to perform a complex action can lead to surprises IMHO.
//does not work as expected
vec3.add(shader.uniforms.lightPosition, aVec, bVec)
EDIT:
Alternative syntax where the discrete uniforms are functions:
//query current uniform looks like this
var pos = shader.uniforms.lights[0].position()
//set uniform, no ambiguity here since it's a function
vec3.add(tmp, aVec, bVec)
shader.uniforms.lights[0].position(tmp)
Or more verbose:
shader.uniforms.lights[0].position.set(tmp)
shader.uniforms.lights[0].position.get()
from glo.
I actually think that maybe it is worth killing gl-shader long term. A more ideal solution would be to have a "draw command" that could take the shader source as a string argument, along with all uniforms that need to be set. Then these could be grouped using some "draw list" that would combine and reorder draw commands so that the number of shader state changes and uniform updates are minimized.
from glo.
Interesting idea. Definitely going to think about it and how it could all look for the end-user.
from glo.
Related Issues (4)
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 glo.