Page 8 of 13

Re: Oysi's 3D Rendering & Physics Engine

Posted: Mon Jun 09, 2014 8:15 pm
by Nautical Mile
If you are interested in fluids in video games, this series of articles gives a great introduction for those who are competent programmers, but are new to CFD. Dr. Gourlay uses the discrete vortex method (DVM) for the first 16 articles, and then discusses Smoothed Particle Hydrodynamics (SPH), from article 17 onward. DVM is more applicable to gases and swirling flows, while SPH is more applicable to liquids.

Beware: this is likely a more significant undertaking than what you have accomplished so far. My research is in CFD, and I have some knowledge of how fluids can be implemented in 3D games. If you want to know how far the rabbit hole goes, let me know. ;)

Re: Oysi's 3D Rendering & Physics Engine

Posted: Tue Jun 10, 2014 6:51 am
by Someguynamedpie
Nice job! Out of curiosity, do you offload any of the work onto separate threads?

Re: Oysi's 3D Rendering & Physics Engine

Posted: Tue Jun 10, 2014 2:52 pm
by badfitz66
I've always been interested in water physics in 2D games.

Re: Oysi's 3D Rendering & Physics Engine

Posted: Tue Jun 10, 2014 5:32 pm
by Nautical Mile
That's cool you guys are interested, but this thread is taking a pretty big detour. I will start a new, general discussion on the topic containing more info when I have some free time (hopefully within 48h).

Re: Oysi's 3D Rendering & Physics Engine

Posted: Wed Jun 11, 2014 3:36 pm
by Oysi
@Nautical Mile
Those articles look very intriguing. I have done similar things, but not quite like that. It will be a good read, once I get around to it. =P And it would be very helpful if you would make that thread. =)

Someguynamedpie wrote:Nice job! Out of curiosity, do you offload any of the work onto separate threads?
Nope, Lua doesn't even have multithreading, so I don't see how you could. The only thing that runs on separate "threads" is the shader stuff, the GLSL code (which runs on the GPU). But my demos sometimes use it and sometimes don't. For all the physics videos, I don't use any shaders. The shading there is done by Lua code. What uses shaders in my demos, are: diffuse & specular shading, z buffer (& shadows), god rays, texture/normal mapping, color interpolation. Generally stuff where all the pixels on a polygon aren't the same.

Re: Oysi's 3D Rendering & Physics Engine

Posted: Wed Jun 11, 2014 3:59 pm
by mickeyjm
Oysi wrote: Nope, Lua doesn't even have multithreading, so I don't see how you could.
I'm sure it wouldn't be too hard to add threads.

Re: Oysi's 3D Rendering & Physics Engine

Posted: Wed Jun 11, 2014 8:17 pm
by Oysi
Interesting. I didn't know Love2D did that. But still, my statement stands. Lua really doesn't support multithreading. Best they could do is run 2 versions of Lua at the same time, on different CPU threads. And coroutines have nothing to do with multithreading. They let you do many things, as well as mimic the appearance of multithreading, but it's not actual multithreading.

But I will try this out. Experiment. It has some clear limitations, due to (again, like I said) lua not supporting multithreading, so I will have to change up my stuff a bit and do some tedious stuff as well. But I will try. =)

Re: Oysi's 3D Rendering & Physics Engine

Posted: Wed Jun 11, 2014 10:37 pm
by Oysi
After further consideration, I realize that I can't really use the thread system. I rely too much on multidimensional tables, and those aren't supported. Splitting up the data would be tedious, and will slow it down so much that it might not give a speed increase at all. For now I will stick to one thread.

On the other hand, I was trying to optimize my god rays, when something very strange happened.
(Currently I have no idea what is going on, but it looks pretty)

Image

Re: Oysi's 3D Rendering & Physics Engine

Posted: Wed Jun 11, 2014 10:40 pm
by slime
Oysi wrote:After further consideration, I realize that I can't really use the thread system. I rely too much on multidimensional tables, and those aren't supported.
A typical use for threads in games is to have some sort of job system, where you have a pool of a handful of threads waiting for jobs, and you send a few jobs off (via a channel or whatever) and then get the results back when you need them. The jobs would be some kind of self-contained calculation or other kind of workload.

Re: Oysi's 3D Rendering & Physics Engine

Posted: Wed Jun 11, 2014 11:24 pm
by Someguynamedpie
I added you on steam to go through some of the things you could shove into threads.