gre / gl-react

gl-react – React library to write and compose WebGL shaders

Home Page:https://gl-react-cookbook.surge.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(question) Is there a way to render to texture?

pedroqueiroga opened this issue · comments

I am trying to port the following shadertoy to gl-react: https://www.shadertoy.com/view/4sG3WV

I can't make those iChannels work. It would be simple if I could render to texture and then pass it as the required iChannels, it doesn't seem like simply stacking would be possible (couldn't make it work), as the examples in the docs show.

How could I proceed?

component composition: when you have nested GL components that's essentially what's happening.

https://gl-react-cookbook.surge.sh/diamondhello

HelloBlue is being rendered in a framebuffer that is being passed as a texture to DiamondCrop.

I know that we can stack, but what that shader requires is something a bit different, is it not? Sorry if I am missing a point, I am new to shaders.
To me it looks like gl-react can implement shaders of the type:
A[i]->A[i+1]->B[i]->B[i+1]->C[i]...

What that effect uses is something like:
A[i](A[i-1], B[i-1])->A[i+1];
B[i](B[i-1])->B[i+1];
C[i](A[i],B[i])

I'm trying to represent the inputs and outputs where i = frame number.

At a certain pass, A needs the texture rendered by it in the previous pass, and the texture rendered by B in the previous pass. How could I represent that with gl-react?