Simulating Ocean Waves with FFT on GPU
来源:互联网 发布:iphone6s连不上4g网络 编辑:程序博客网 时间:2024/04/29 09:27
10/20/2011
9 Comments
There are many, many complicated equations in Tessenforf's paper. The first time when I read it, it appeared math-intense. However, most of them are not directly related to building the height field for waves, but are important oceangraphic concept, such as Gerstner Wave. Here, I will try to illustrate it in an as simple as possible way and will only discuss several key equations that's directly related to implementing this algorithm.
This algorithm is based on a statistical model, in which wave height is a random variable of horizontal position and time,h(X,t). It decomposes the wave height field into a set of sinus waves with different amplitudes and phases. The model itself provides us with a method to generate these amplitudes and phases, and we use inverse FFT as a mean to quickly evaluate the sum of these sinus waves.
First, let's take a look at the equation of which we need to perform FFT to evaluate the sum:
We now want to generate a set of time-dependent amplitude and phase with Phillips spectrum. To do that, we first need to create a set of amplitudes and phases at time zero, and then we animate the field. The following equation will finish the first task.
Now, we have a set animated amplitudes and phases to which we can perform FFT to evaluate the sum. We can also perform FFT to other equations to producing the choppy vectors as well as slope vectors of the height field, but they are not discussed here.
The computational cost of performing FFT with dimensions of 512x512 is extremely high on CPU. Therefore I implemented it on the pixel shader on the GPU, the parallel computing ability of which vastly enhances the efficiency of this algorithm, and enable it to run in real-time.
FFT is a delicate algorithm. The basic idea can be illustrated by the figure below:
My implementation is simply to first pre-compute all the indices and weights(W) in the figures above and pack the pre-computed data into a texture. At each stage, these indices and weights are fetched in the pixel shader and used to perform a single butterfly operation. Two Ping-Pong textures are used to write data back and forth between stages. The following is the HLSL code for a basic butterfly operation along the horizontal direction.
Simply best explanation. Big thanks ;)
can i get the program?
Nice article. I got to the point where I've calculated H(k,t)~. Is it correct that during the real time update I see concentric circles radially leaving the center of the image ? ...
Wonderful! This really cleared up a lot of small -yet complicated- things up for me. After reading Tessendorf's paper, Keith Lantz' implementation, and Eric Bruneton's gpu fft code, this gave me the spark I needed!
Has anyone an example how the pre-computed butterfly texture should look like? Would be really nice, cause i think that is the problem in my implementation.
Thx for this explanation. It helped me a lot to understand how this works. But there is one thing, I still don't understand. As far as I know, additions of complex numbers can't be performed if the complex numbers are given in polar coordinates. So what would I have to do to calculate the following equation?
~h(k,t) = ~h0(k) exp(iwt) + ~H0*(-k) exp(-iwt)
just complex multiply ~h0(k) with exp(iwt) and ~h0*(-k) with exp(-iwt) (note: exp(ix) = cos(x) + isin(x)). then complex add the results, thats all.
Nice article!
But i guess you misuse the term "gravitational constant" which is equal to 6.674e−11 and is notated by Big "G". It should not be confused with "small g" (g), which is the local gravitational field of Earth equal to approx. 9.81
I get erro from gl_Position = gl_ProjectionMatrix * fragmentPos
10/20/2011
9 Comments
There are many, many complicated equations in Tessenforf's paper. The first time when I read it, it appeared math-intense. However, most of them are not directly related to building the height field for waves, but are important oceangraphic concept, such as Gerstner Wave. Here, I will try to illustrate it in an as simple as possible way and will only discuss several key equations that's directly related to implementing this algorithm.
This algorithm is based on a statistical model, in which wave height is a random variable of horizontal position and time,h(X,t). It decomposes the wave height field into a set of sinus waves with different amplitudes and phases. The model itself provides us with a method to generate these amplitudes and phases, and we use inverse FFT as a mean to quickly evaluate the sum of these sinus waves.
First, let's take a look at the equation of which we need to perform FFT to evaluate the sum:
We now want to generate a set of time-dependent amplitude and phase with Phillips spectrum. To do that, we first need to create a set of amplitudes and phases at time zero, and then we animate the field. The following equation will finish the first task.
Now, we have a set animated amplitudes and phases to which we can perform FFT to evaluate the sum. We can also perform FFT to other equations to producing the choppy vectors as well as slope vectors of the height field, but they are not discussed here.
The computational cost of performing FFT with dimensions of 512x512 is extremely high on CPU. Therefore I implemented it on the pixel shader on the GPU, the parallel computing ability of which vastly enhances the efficiency of this algorithm, and enable it to run in real-time.
FFT is a delicate algorithm. The basic idea can be illustrated by the figure below:
My implementation is simply to first pre-compute all the indices and weights(W) in the figures above and pack the pre-computed data into a texture. At each stage, these indices and weights are fetched in the pixel shader and used to perform a single butterfly operation. Two Ping-Pong textures are used to write data back and forth between stages. The following is the HLSL code for a basic butterfly operation along the horizontal direction.
Simply best explanation. Big thanks ;)
can i get the program?
Nice article. I got to the point where I've calculated H(k,t)~. Is it correct that during the real time update I see concentric circles radially leaving the center of the image ? ...
Wonderful! This really cleared up a lot of small -yet complicated- things up for me. After reading Tessendorf's paper, Keith Lantz' implementation, and Eric Bruneton's gpu fft code, this gave me the spark I needed!
Has anyone an example how the pre-computed butterfly texture should look like? Would be really nice, cause i think that is the problem in my implementation.
Thx for this explanation. It helped me a lot to understand how this works. But there is one thing, I still don't understand. As far as I know, additions of complex numbers can't be performed if the complex numbers are given in polar coordinates. So what would I have to do to calculate the following equation?
~h(k,t) = ~h0(k) exp(iwt) + ~H0*(-k) exp(-iwt)
just complex multiply ~h0(k) with exp(iwt) and ~h0*(-k) with exp(-iwt) (note: exp(ix) = cos(x) + isin(x)). then complex add the results, thats all.
Nice article!
But i guess you misuse the term "gravitational constant" which is equal to 6.674e−11 and is notated by Big "G". It should not be confused with "small g" (g), which is the local gravitational field of Earth equal to approx. 9.81
I get erro from gl_Position = gl_ProjectionMatrix * fragmentPos
- Simulating Ocean Waves with FFT on GPU
- Simulating Ocean Water
- Simulating Ocean Water
- FFT水面加入Choppy Waves
- 读《Simulating Physics with Computers》
- Simulating queueing systems with simmer
- GPU Powered DeepLearning with NVIDIA DIGITS on EC2
- Run rbgirshick/py-faster-rcnn on ubuntu with gpu
- 170620 How to install tensorflow with GPU on linux
- C++ AMP: .Massive Data Parallelism on the GPU with Microsoft's C++ AMP (Accelerated Massive Parallel
- caffe setup on ubuntu 15.04 with CPU and NO GPU and NO Python
- FFT快速卷积GPU加速----pycuda
- AMGCL----AMG ON GPU
- Julia On GPU
- Android 模拟器 GPU ON
- CUDA on NVIDIA GPU
- Using+GPU+with+Cuda
- 编译ffmpeg with gpu
- 潘丽云:魏尔斯特拉斯的复变函数思想分析(2009)(2011-01-14 22:34:30)
- Socket编程实践(8) --套接字IO超时设置方法
- SAR图像处理 MSTAR数据库利用问题
- 计算机网络
- 第一次成功实现的WebSocket代码
- Simulating Ocean Waves with FFT on GPU
- 源泉书签入口
- Activity的生命周期
- SDWebImage异步加载图片及缓存的管理与清理 -- 推荐
- 学习嵌入式过程的一些感想和思考
- Rendering underwater scene with EDXRay
- Makefile常见问题汇总
- SD实践代码
- hdu 1827 Summer Holiday