|
@@ -9,7 +9,6 @@
|
|
|
|
|
|
<div id="info">
|
|
<div id="info">
|
|
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> WebGPU - Compute Ping/Pong Texture
|
|
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> WebGPU - Compute Ping/Pong Texture
|
|
- <br>Texture generated using GPU Compute.
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script type="importmap">
|
|
<script type="importmap">
|
|
@@ -113,7 +112,11 @@
|
|
let indexUV = vec2u( posX, posY );
|
|
let indexUV = vec2u( posX, posY );
|
|
let uv = getUV( posX, posY );
|
|
let uv = getUV( posX, posY );
|
|
|
|
|
|
- textureStore( writeTex, indexUV, vec4f( vec3f( rand2( uv + seed ) ), 1 ) );
|
|
|
|
|
|
+ let r = rand2( uv + seed * 100 ) - rand2( uv + seed * 300 );
|
|
|
|
+ let g = rand2( uv + seed * 200 ) - rand2( uv + seed * 300 );
|
|
|
|
+ let b = rand2( uv + seed * 200 ) - rand2( uv + seed * 100 );
|
|
|
|
+
|
|
|
|
+ textureStore( writeTex, indexUV, vec4( r, g, b, 1 ) );
|
|
|
|
|
|
}
|
|
}
|
|
`, [ rand2 ] );
|
|
`, [ rand2 ] );
|
|
@@ -131,7 +134,7 @@
|
|
|
|
|
|
let color = blur( readTex, indexUV ).rgb;
|
|
let color = blur( readTex, indexUV ).rgb;
|
|
|
|
|
|
- textureStore( writeTex, indexUV, vec4f( color, 1 ) );
|
|
|
|
|
|
+ textureStore( writeTex, indexUV, vec4f( color * 1.05, 1 ) );
|
|
|
|
|
|
}
|
|
}
|
|
`, [ rand2 ] );
|
|
`, [ rand2 ] );
|
|
@@ -181,9 +184,9 @@
|
|
|
|
|
|
function render() {
|
|
function render() {
|
|
|
|
|
|
- // reset every 50 frames
|
|
|
|
|
|
+ // reset every 200 frames
|
|
|
|
|
|
- if ( renderer.info.render.frame % 50 === 0 ) {
|
|
|
|
|
|
+ if ( renderer.info.render.frame % 200 === 0 ) {
|
|
|
|
|
|
seed.value.set( Math.random(), Math.random() );
|
|
seed.value.set( Math.random(), Math.random() );
|
|
|
|
|