|
|
|
|
|
by luismedel
8 days ago
|
|
Nice. The earliest jaw-dropping water effect I saw (and somewhat understood at 14) was the awesome credits scene from the Iguana's Earthquake demo[0]. The code[1] contains the following explanation (ancient DOS chars fixed with chatGPT) ; // UpdateTable : performs one integration step on U[CT]
; Differential equation is: u = a²( u + u )
; tt xx yy
;
; Where a² = tension * gravity / surface_density.
;
; Approximating second derivatives by central differences:
;
; [ u(t+1)-2u(t)+u(t-1) ] / Δt² = a² (u(x+1)+u(x-1)+u(y+1)+u(y-1)-4u) / h²
;
; (where Δt = time step, h=Δx=Δy = mesh resolution)
;
; From where u(t+1) may be calculated as:
; ┌ 1 ┐
; u(t+1) = a²Δt²/h² │ 1 0 1 │u - u(t-1) + (2-4a²Δt²/h²)u
; └ 1 ┘
;
; When a²Δt²/h² = ½ last term vanishes, giving:
; ┌ 1 ┐
; u(t+1) = ½ │ 1 0 1 │u - u(t-1)
; └ 1 ┘
;
; This needs only 4 ADD/SUB and one SAR operation per mesh point!
[0] https://www.pouet.net/prod.php?which=364[1] https://hornet.org/code/demosrc/demos/hq_water.zip |
|