aleksandrbazhin / Unreal_2D_NBodySim

3 stars 0 forks source link

Is it possible that you could Give some instructions on how to start the project? #1

Open john012343210 opened 1 month ago

john012343210 commented 1 month ago

It seems that you are using a built Unreal engine. May I know which version is it.

I also see that there are some files called Cmake. May I know Do I need to care about them.

Thank you very much!

aleksandrbazhin commented 1 month ago

Hi! I developed this thing on Linux, where I had to build Unreal 4 from the source. I think CMake files are autogenerated. Then I had to convert it to Unreal 5 as it was a requirement for the task. I did not use Unreal before or after that week, so I don't remember exactly what was needed. It was done on Windows machine and the project "just worked". If I recall correctly it is a standard C++ project for Unreal, you just do it as with the other projects. Maybe later I will add instructions, if I ever launch it again.

john012343210 commented 1 month ago

@aleksandrbazhin May I know Do you know what exact version Of the unreal engine is used. Is it 5.4? Thank you very much!

aleksandrbazhin commented 1 month ago

The original was Unreal 4.27 - you just open the project and it works, just checked it. If it's the newer version - Unreal promts you to convert on the start. I converted to Unreal 5.3. Maybe there were some little things I had to fix before it was working. When I check, I will let you know here.

aleksandrbazhin commented 1 month ago

Just checked it on 5.3.2 - you don't need to do anything special - open the project, select convert in place, wait for shaders to compile, and it worked just fine.

john012343210 commented 1 month ago

@aleksandrbazhin Thanks so much. I have read your code to see How you achieve the smooth Rendering. I'm currently developing an unreal engine Project to render a force direct graph. Which the main part is to deal with the N bodies simulation. However, my rendering is very laggy. I wonder if I could have your kind help to give me some suggestions on how I could improve the rendering. https://github.com/ProgramIsFun/ue5-force-graphhhhhhhhh-521?tab=readme-ov-file#1 If you don't have time, sorry for bothering you, You have already helped me a lot.

aleksandrbazhin commented 1 month ago

I am in no way a professional in Unreal - this project is the only thing I ever done. So my total experience with Unreal is around one week. So I don't think I will be able to help you, you'll have to do your research. But I did dig a bit into optimization during that week. Actually without the n-body physics around 20000k particles were rendered smoothly on a cheap laptop with a built-in graphics. The key to this is using "instanced static mesh" - google it, or look up what I did (I honestly don't remember what it was). The other thing - is n-body problem is always computation-intensive. I did parallelize the computation inner loop - you can also look it up in the code. Unreal has that stuff as loop execution policy or something like that. But if you really need to get the most for n-body problem, you have to implement some spatial hashing or octo-tree or some n-body specific stuff that allows you to not calculate each body-to-body interaction every frame. I think that is all I can help you with, good luck!

aleksandrbazhin commented 1 month ago

This is the parallelization part for outer, not inner loop https://github.com/aleksandrbazhin/Unreal_2D_NBodySim/blob/707fee4488fdfbb8d8b9258b74927d3b8fe1d748/Source/NBodySim/BodyManager.cpp#L52C5-L52C16 And instanced static mesh means you only load the mesh to the GPU once, and reuse it N times. My machine ran ~2500 bodies at around 60 FPS with n-body gravity, and ~20000 without the gravity.