Giter VIP home page Giter VIP logo

Comments (6)

Lemon-King avatar Lemon-King commented on June 25, 2024 1

Actually, gonna reopen this since it could use further documentation.

from gl-react.

wyhinton avatar wyhinton commented on June 25, 2024 1

It'd be great if there was an example showing how to use the Uint8Array to make a data texture, perhaps something to the effect of this tutorial? https://webglfundamentals.org/webgl/lessons/webgl-qna-how-to-get-audio-data-into-a-shader.html

from gl-react.

Lemon-King avatar Lemon-King commented on June 25, 2024

Alrighty, after finally figuring this out and anyone like me poking around how to do this.

You'll want to use a library called NDArray and set it up as NDArray(Uint8Array, [width, height, 4]), assign it to a uniform that is referenced as a sampler2d in your shader code.

And for a few keywords for anyone googling this problem: putImageData, Uint8Array, imageData

from gl-react.

gre avatar gre commented on June 25, 2024

👍 btw i think it's [height,width,4] with NDArray, but well it depends how your data is aligned indeed.

from gl-react.

iamterryclark avatar iamterryclark commented on June 25, 2024

@Lemon-King did you use ndarray node module for this?

I've tried to use ndarray(buffer, [width, height, 4]) as I also have a rgba array but I get a no loader found for value issue.

Edit: oh I am using reactjs also not native.

from gl-react.

Lemon-King avatar Lemon-King commented on June 25, 2024

I had a Node with an OnDraw event which I used to capture the NDArray when there was a draw event.
From there I handled the NDArray like any other unclamped uint8array using some undocumented calls after a considerable amount of digging in the source.

This will return the NDArray from the node, from there you may have to flip it as it'll be in opengl uv space.

    <Node
        ref={"image_node"}
        width={100}
        height={100}
        shader={shaders.canvas}
        uniforms={uniforms}
        clear={null}
        onDraw={() => {
            let imageData: ndarray.Data<number> = this.refs.image_node.capture();
            // handle data as needed
        }}
    />

from gl-react.

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.