textureStore
A command-like node specifically for writing data to a precise pixel coordinate within a Storage Texture. It is a core operation for GPGPU tasks like physics simulations and procedural generation to save computation results.
Core Advantages
Provides a clear, concise 'write' command that is fundamental for building multi-stage GPU computation pipelines. It allows updating a texture at precise pixel coordinates, seamlessly passing the result from one computation stage to the next.
Common Uses
Recording particle states in GPU particle simulations
Updating physics fields in real-time fluid or physics simulations
Writing pixels in procedural content generation or interactive painting
How to adjust
Control is achieved by precisely manipulating the write location (`uvNode`) and content (`storeNode`). For example, making the `storeNode` value time-dependent causes the target pixel to flash. Making the `uvNode` coordinate time-dependent will 'draw' a path on the texture over time.
Code Examples
1// Get the current thread's pixel coordinate (ivec2)
2const uv = dispatchThreadID.xy;
3
4// Calculate a color based on the coordinate
5const color = vec4( uv.x.tofloat().div( 512 ), uv.y.tofloat().div( 512 ), 0.5, 1.0 );
6
7// Execute the write command to the texture
8textureStore( myStorageTexture, uv, color );