Git Product home page Git Product logo

Comments (4)

mattdesl avatar mattdesl commented on June 12, 2024

will log to console.error by default unless quiet: true (for unit tests etc)

screen shot 2015-05-21 at 2 47 17 pm

though console.warn looks nice too

screen shot 2015-05-21 at 1 37 27 pm

from glo.

mattdesl avatar mattdesl commented on June 12, 2024

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.

mikolalysenko avatar mikolalysenko commented on June 12, 2024

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.

mattdesl avatar mattdesl commented on June 12, 2024

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 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.