Search code examples
c#xnagpuperlin-noise

c# xna: real time 2d Generation. include GPU? use hlsl or bramaha?


Hey i recently finished my world Generation Algorithmus, wich is going to run in real time. The Algorithmus itself takes about 4 sec for 4x my screen (1920x1080). Now i wondered if and how i could use the GPU to generate the simplex noise I am using to split up the work between my CPU and GPU and make it a little faster. So i wondered how to properly include the GPU. Should i use bramha or hlsl or anything else? And what should i use the GPU for? I have heared that it will be faster when doing many similar operations.

Edit: And how about handling collisions on gpu? (like SAT- Collisions?)


Solution

  • You will definitely want to use the GPU. I would recommend that you use a render to texture step and HLSL. HLSL is pretty easy to pick up, and I do believe there's a sample for rendering to a texture. (you could do multiple passes too if you pass it back in again)

    Here's a good blog on HLSL using XNA 4: http://digitalerr0r.wordpress.com/2011/12/12/xna-4-0-shader-programming-1intro-to-hlsl-ambient-light/

    Here's an example of render-to-texture in XNA 4: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Render_to_texture.php

    Basically speaking, render targets in XNA are textures and can be used just like one.