Transform feedback is an advanced rendering technique that allows you to capture the state of a shader into a buffer after processing the vertex portion of the transform, then resubmit it to be processed multiple times. This is especially useful for creating GPU based particle systems or for any vertex process that requires multiple stages or prior-state awareness.
The feature is currently exposed via the jit.gl.tf object, which is designed to work with jit.gl.buffer and jit.gl.mesh.
Binding buffers for transform feedback
To add buffers to the transform feedback process, you need to create both a jit.gl.tf object and one or more jit.gl.buffer objects. The jit.gl.tf object must include an argument for the total number of buffers (inputs) and for each jit.gl.buffer you must specify the buffer type and outname attributes. The type in each gl.buffer must match one of the internal buffers of jit.gl.mesh (position, normal, color, vertex_attr, etc.) and will override the default buffer to use as directed in the shader. The outname can be any symbol, but is used by the shader to perform the feedback operation in GPU memory, so make sure that it matches the out name in the shader. So if you have a setup like this:
then in your shader params declaration you need something like:
and in the program body you would declare both the in AND out names like this:
<param name="position" type="vec3" state="POSITION" /> <param name="velocity" type="vec3" state="NORMAL" />
Once your system is setup you must start the transform feedback via the jit.gl.tf enable attribute.
in vec3 position; in vec3 velocity; out vec3 Position1; out vec3 Velocity1;
Example patches that demonstrate transform feedback
|Working with OpenGL||Working with OpenGL|
|jit.gl.mesh||Generate GL geometry from matrices|