Create a new TransformFeedback instance.
The input vertex buffer.
Optional
usage: number = BUFFER_GPUDYNAMICThe optional usage type of the output vertex buffer. Can be:
Defaults to BUFFER_GPUDYNAMIC (which is recommended for continuous update).
The current input buffer.
The current output buffer.
Runs the specified shader on the input buffer, writes results into the new buffer, then optionally swaps input/output.
A vertex shader to run. Should be created with TransformFeedback.createShader.
Optional
swap: boolean = trueSwap input/output buffer data. Useful for continuous buffer processing. Default is true.
Static
createCreates a transform feedback ready vertex shader from code.
The graphics device used by the renderer.
Vertex shader code. Should contain output variables starting with "out_".
Unique name for caching the shader.
A shader to use in the process() function.
This object allows you to configure and use the transform feedback feature (WebGL2 only). How to use:
out vec3 out_vertex_position
, note that there must be out_ in the name. You can then simply assign values to these outputs in VS. The order and size of shader outputs must match the output buffer layout.TransformFeedback.createShader(device, vsCode, yourShaderName)
.const tf = new TransformFeedback(inputBuffer)
. This object will internally create an output buffer.tf.process(shader)
. Shader will take the input buffer, process it and write to the output buffer, then the input/output buffers will be automatically swapped, so you'll immediately see the result.