-
-
Notifications
You must be signed in to change notification settings - Fork 36k
Closed
Labels
Milestone
Description
Description
Just like in the examples webgpu_compute_points
and webgpu_compute_particles_rain
would it be possible to use the TSL Syntax with tslFn
to compute texture storage data? @sunag
For example I started to try to port the webgpu_compute_texture
example to tsl but it seems that texture_storage_2d
is not supported yet or I don't know how to use it:
const width = 512, height = 512;
const storageTexture = new StorageTexture( width, height );
const computeShaderFn = tslFn( ( [ storageTexture ] ) => {
// https://www.shadertoy.com/view/Xst3zN
const posX = instanceIndex.mod( width );
const posY = instanceIndex.div( height );
const indexUV = vec2( posX, posY );
const x = float( posX ).div( 50. );
const y = float( posY ).div( 50. );
const v1 = sin( x );
const v2 = sin( y );
const v3 = sin( x.add( y ) );
const v4 = sin( sqrt( x.mul( x ).add( y.mul( y ) ) ).add( 5. ) );
const v = v1.add( v2 ).add( v3 ).add( v4 );
const PI = 3.14159265359;
const r = sin( v );
const g = sin( v.add( PI ) );
const b = sin( v.add( PI ).sub( 0.5 ) );
return textureStore( storageTexture, indexUV, vec4( r, g, b, 1 ) );
} );
const computeNode = computeShaderFn().compute( width * height );
Something to keep in mind would be to be able to, just like in #27367, have a WebGL fallback where we would somehow ping pong basic textures I guess.