Hi i’m working to generate real time ocean surface through ocean spectrum in BGE, the code to generate the spectrum is ready, now the only thing to do is an inverse FFT to obtain height field. I don’t know how to performe it in GLSL, the only solution is to save the texture and do the transform in python. is there any way to save a texture from glsl?
Yes, but it’s slow and I wouldn’t suggest trying to use it in any sort of real-time sense.
You create a Render To Texture (bge.texture.ImageRender) with a camera that points at the plane with your shader on it, and then you can extract the image data from that.
The issue is that it is really, really slow to get the data from the GPU to the CPU. So what I would suggest is to try keep it all in the GPU. Either compute the heightfield in the same shader (you may have to multi-sample) or use ImageRender, but instead of extracting the data back to the CPU, use it as a texture input to another shader.
Thanks john. I’m studyin how to perform FFT in a shader. The steps to achieve this project are:
List item compute the spectrum of the ocean
List item get the heigth field from the spectrum through an inverse Fast Fourier Transform
List item then apply the heigth field to a plane
I’ve alredy done a test in python with numpy and matplot lib and it worked. But it’s very slow becaise i have to calculate all frames and then make a video.
My inspiration is martins upitis. But as aleays he is unbelievable and i can’t reach him but i’m trying with all i have to improve.