Access to modified geometry of vertex shader?

Florito's icon

Hi all,

In short: Is it possible to access vertex data after it has been processed by a vertex shader? As I've seen on the forum, using the "matrixoutput 1" option on sketch or mesh has no effect.. :(

I want to do the following:

  1. Render a jit.matrix with the jit.gl.sketch or jit.gl.mesh object, while applying a vertex shader, that modifies the positions of the vertices

  2. Read the outcoming vertices back into jitter (preferably as jit.matrix)

Rob Ramirez's icon

not possible.

efe's icon

Hello Marcus, very interesting question.
I don't think is possible to retrieve vertex data as direct matrices in jitter(please someone correct me if i am wrong!). There has been some discussion in how to access shader data:
https://cycling74.com/forums/field-lookup-on-gpu
https://cycling74.com/forums/min-and-max-value-in-texture

You need to bind the shader to an object. Look at the next example(attached):
if you apply the binding of the shader to the jit.gl.gridshape and then turn on the matrixoutput attribute, the jit.gl.mesh stills retrieves the original data from the gridshape. The shader wouldn't work until you bind it to the mesh object.

but so far they are not supported on jitter.

Maybe someone around here knows a way to ouput matrices with bound shader data(that would be really cool!)

-emmanuel

930.wobby.zip
zip
Andrew Benson's icon

Due to the nature of the programmable pipeline, you don't have access to the results of a vertex program, except within the fragment program of the same shader (as varying variables). The easy answer is that this is just not possible, and you should just do whatever vertex processing on the CPU if you want matrix-level access. Theoretically, you could find a way to capture vertex points to float32 texture using a special shader that passes the vertex positions as varying to the fragment program, but this would be a completely separate rendering stage and seems kinda overkill. To maintain your sanity, I would encourage you to not think too hard about it, and just use jit.expr to manipulate your vertex positions as you like.