FBO(Frame Buffer Object)
Resources
FBO particles (opens in a new tab)
threejs birds example (opens in a new tab)
epranka/gpucomputationrender-three (opens in a new tab)
Basic Usage from yomboprime
yomboprime/GPGPU-threejs-demos (opens in a new tab)
// Initialization...
// Create computation renderer
var gpuCompute = new GPUComputationRenderer(1024, 1024, renderer);
// Create initial state float textures
var pos0 = gpuCompute.createTexture();
var vel0 = gpuCompute.createTexture();
// and fill in here the texture data...
// Add texture variables
var velVar = gpuCompute.addVariable("textureVelocity", fragmentShaderVel, pos0);
var posVar = gpuCompute.addVariable("texturePosition", fragmentShaderPos, vel0);
// Add variable dependencies
gpuCompute.setVariableDependencies(velVar, [velVar, posVar]);
gpuCompute.setVariableDependencies(posVar, [velVar, posVar]);
// Add custom uniforms
velVar.material.uniforms.time = { value: 0.0 };
// Check for completeness
var error = gpuCompute.init();
if (error !== null) {
console.error(error);
}
// In each frame...
// Compute!
gpuCompute.compute();
// Update texture uniforms in your visualization materials with the gpu renderer output
myMaterial.uniforms.myTexture.value =
gpuCompute.getCurrentRenderTarget(posVar).texture;
// Do your rendering
renderer.render(myScene, myCamera);