Comments (6)
Actually, gonna reopen this since it could use further documentation.
from gl-react.
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.
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.
👍 btw i think it's [height,width,4] with NDArray, but well it depends how your data is aligned indeed.
from gl-react.
@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.
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)
- Possible Bug: Image data flipped when captured
- TypeError: undefined is not a function (near '...GL.createComponent...') HOT 1
- image disappeared after refocus the screen
- gl-react-native App crashed with Surface with style prop HOT 5
- Update Peer Dependency to gl-react-5?
- How to remove white Background from the image HOT 1
- GL is currently not available (have you enabled remote debbuging) shows up on Android HOT 1
- Camera preview dimensions ignored? - distorted on iOS HOT 2
- Question About Texts on Images in react-native HOT 1
- [iOS] app crash calling "capture": NSInvalidArgumentException HOT 2
- How to load spine animation json file in react-native HOT 1
- Specify texture format
- GL.Node does not support video surfaces HOT 2
- Failed to execute 'shaderSource' on 'WebGL2RenderingContext': parameter 1 is not of type 'WebGLShader' HOT 4
- Bad quality camera on Android devices HOT 5
- Image from local storage are not reading , surface view coming black.
- headless example HOT 1
- How to use gl-react with next.js ? Is there any documentation about this ? HOT 1
- Runtime error: `Unable to resolve module expo-modules-core`
- ReferenceError: Can't find variable: global 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 gl-react.