File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import renderFragmentShaderSource from "./shaders/render-frag.glsl?raw";
66// constnats
77const PI = Math . PI ;
88const random = Math . random ;
9+ const RANDOM_IMG_SIZE = 200 ;
910/** shader names */
1011// Uniforms
1112const U_DT = "dt" ;
@@ -72,9 +73,9 @@ const getInitialData = (maxParticles: number) => {
7273} ;
7374
7475/** generate random RG data for source of randomness within the simulation */
75- const randomRGData = ( sizeX : number , sizeY : number ) : Uint8Array => {
76+ const randomRGData = ( ) : Uint8Array => {
7677 const data = [ ] ;
77- for ( let i = 0 ; i < sizeX * sizeY ; i ++ ) data . push ( random ( ) * 255.0 , random ( ) * 255.0 ) ;
78+ for ( let i = 0 ; i < 2 * RANDOM_IMG_SIZE ** 2 ; i ++ ) data . push ( random ( ) * 255 ) ;
7879 return new Uint8Array ( data ) ;
7980} ;
8081
@@ -212,12 +213,12 @@ const simulate = (
212213 gl . TEXTURE_2D ,
213214 0 ,
214215 gl . RG8 ,
215- 200 ,
216- 200 ,
216+ RANDOM_IMG_SIZE ,
217+ RANDOM_IMG_SIZE ,
217218 0 ,
218219 gl . RG ,
219220 gl . UNSIGNED_BYTE ,
220- randomRGData ( 200 , 200 ) ,
221+ randomRGData ( ) ,
221222 ) ;
222223
223224 gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_S , gl . MIRRORED_REPEAT ) ;
You can’t perform that action at this time.
0 commit comments