Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Physics Engine on GPU
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mirhagk




PostPosted: Tue May 31, 2011 12:39 pm   Post subject: Physics Engine on GPU

So I've thought alot lately about how a 2D game could utilize the GPU, since I don't like when so much power just sits there unused. Post-processing is really the only potential thing that a 2D game could use a GPU for (without using just as much CPU to process the info).

I'm thinking I might try to build a physics engine on the graphics card, since entities are seperated well enough that every object can be updated seperately (full potential for multi-threading). I know how to code the actual physics engine on the graphics card, that's a non-issue the real issue are the following:

1. How do I pass all of the objects to the graphics card.
2. How do I pass all of the information back.


I am using XNA, so what I'm thinking about doing is passing the informationg through a texture, that gets rendered using spritebatch, so each pixel is a seperate element in the physics engine, and I can do all of it in the pixel shader. spritebatch takes care of all the CPU and vertex shader work, so all I need to do then is to write each object into a texture, and then write the code to process the texture in the graphics card.

So I introduce a couple of new problems, the texture is merely a 4 bytes of color data (one for each of rgba), so I need to convert positions (2 floats) to colours. Also I doubt I can resonably have 1 pixel per object, so I'm thinking about assigning a couple to each object, and then modding by that number on the GPU to determine whether we need to process it or not.

EDIT: Sorry lol, so what I want to know is whether this is reasonable, and what the best way to convert positions of floats to bytes.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: