Linear waves on 512×512 square.
2D wave equation
For the wave equation
∂t2u = Δu ,
u|t=0 = exp(-(r -
ro )2/ a2),
∂tu|t=0 = 0,
the simple explicit scheme
2ux,yt - ux,yt-1 +
(ux+1,yt + ux-1,yt +
ux,y+1t + ux,y-1t -
on square grid is used.
Simulations on GPU
To use calculated data many times (on every time step) we store them
in 3 Float32 N×N textures.
Every pixel corresponds to a lattice node.
We need only one component texture (i.e. LUMINANCE) but WebGL shader can render
to RGB or RGBA textures yet. To render the fragment shader output to these
textures they are bound to FBO, FBO1, FBO2 correspondingly.
In accordance with (*) calculations are made in 3 steps:
texture + texture1 → FBO2 (texture2) texture1 + texture2 → FBO (texture) texture2 + texture → FBO1 (texture1) The first fragment shader makes the main calculations in accordance with (*).
All pixels are rendered into texture attached to one of FBOs