POV-Ray : Newsgroups : povray.off-topic : Differential equations FTW! Server Time
11 Oct 2024 09:19:16 EDT (-0400)
  Differential equations FTW! (Message 31 to 31 of 31)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: scott
Subject: Re: Differential equations FTW!
Date: 11 Jan 2008 04:53:21
Message: <47873c91$1@news.povray.org>
> If I get time I would like to try and implement this in a pixel shader, 
> it's exactly the thing that GPUs are good at - performing the same code on 
> a huge number of different pixels.

OK so I implemented the wave equation in a pixel shader (well 3 of them 
actually).

Runs at 75 fps at 1280x800 and looks v. sexy and smooth.  I only made a 
basic black/blue gradient for now, but it uses a texture LUT for the 
colour-map so I can replace it with anything later.

CPU usage is essentially zero during the execution, the program is speed 
limited by the number of texture look-ups to do the 2nd order 
differentiation in the x and y directions.

I used the following algorithm:

u = texture of "heights"
v = texture of velocity of heights
t = temp texture

set u and v as input textures, and t as the render target
 - calculate the new height velocity using the wave equation

swap v and t

set u and v as input textures, and t as the render target
 - calculate the new heights using the velocity information

swap u and t

set u and the input texture and the screen as the render target
 - use the colour-map LUT to choose a colour

There is another integration method called Verlet or something that 
supposedly can do this sort of simulation without needing to store the 
velocities, that should speed things up a lot as swapping around render 
targets and textures are slow operations.

After I've optimised this one a bit more I may start on implementing the 
diffuse-reaction equation next week :-)


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.