Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating information from the vertex shader

Tags:

glsl

webgl

In the vertex shader program of a WebGL application, I am doing the following:

Calculate gl_Position P using a function f(t) that varies in time.

My question is:

Is it possible to store the updated P(t) computed in the vertex shader so I can use it in the next time step? This will be useful for performing some boundary tests.

I have read some information on how textures can be used to store and updated vextex positions, but is this feasible in WebGL, since even texture access from a vertex program is unsupported in OpenGL ES 1.0?

For a more concrete example, let us say that we are trying to move a point according to the equation R(t) = (k*t, 0, 0). These positions are updated in the vertex shader, which makes the point move. Now if I want to make the point bounce at the wall located at R = (C, 0, 0). To do that, we need the position of the point at t - dt. (previous time step).

Any ideas appreciated.

Regards

like image 888
M-V Avatar asked Nov 14 '22 00:11

M-V


1 Answers

In addition to the previous answers, you can circumvent vertex texture fetch by PBOs, but I do not know, if they are supported in WebGL or GLES, as I have only desktop GL experience. You write the vertex positions into the framebuffer. But then, instead of using these as vertex texture, you copy them into a vertex buffer (which works best via PBOs) and use them as a usual vertex attribute. That's the old way of doing transform feedback, which I suppose is not supported.

like image 82
Christian Rau Avatar answered Nov 23 '22 23:11

Christian Rau