Procedural Universe Sim using OpenGL and OpenCL

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
JDB
Posts: 41
Joined: August 5th, 2015, 9:50 am
Location: Australia

Procedural Universe Sim using OpenGL and OpenCL

Post by JDB » June 12th, 2019, 1:22 pm

Just another one of my random projects I thought I'd share here. Spent a couple of weeks creating the groundwork for a procedural universe game where you can actually travel to any star you can see and fly into the solar system. It uses an interesting mix of OpenGL and OpenCL for generating and rendering stars. It uses OpenCL to render the planets as analytical spheres (no mesh) using ray-tracing, but they don't have any textures yet. It's still in early stages of development has a few bugs such as crappy camera control, I need to switch over to using quaternions for rotation. A Windows release is available on GitHub if you want to try it out, although it may not work with all GPU's. I probably wont be able to work on this for a while so feel free to improve it.

Source: https://github.com/JacobBruce/CosmicVoid
Attachments
screen.png
(1.02 MiB) Not downloaded yet

albinopapa
Posts: 3825
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Procedural Universe Sim using OpenGL and OpenCL

Post by albinopapa » June 12th, 2019, 5:51 pm

however at some point the plan is to shift over to an RTX API for ray-tracing since AMD seems to be phasing out OpenCL.
I'm a bit confused on your reasoning here.

Perhaps look into something not proprietary and is still cross platform.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 3825
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Procedural Universe Sim using OpenGL and OpenCL

Post by albinopapa » June 12th, 2019, 5:51 pm

Oh, btw, the screen shot looks very nice.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

JDB
Posts: 41
Joined: August 5th, 2015, 9:50 am
Location: Australia

Re: Procedural Universe Sim using OpenGL and OpenCL

Post by JDB » June 12th, 2019, 9:22 pm

albinopapa wrote:
June 12th, 2019, 5:51 pm
however at some point the plan is to shift over to an RTX API for ray-tracing since AMD seems to be phasing out OpenCL.
I'm a bit confused on your reasoning here.

Perhaps look into something not proprietary and is still cross platform.
Because it can provide ray-traced rendering which is on par with the speed of rasterization since it's hardware based, and also because I don't really see any other cross platform alternatives to OpenCL. AMD has Radeon-Rays which is built on top of OpenCL anyway and Nvidia has OptiX which is probably what I really want if it supports RTX cards. However I believe Vulkan does or will at some point have an RTX API, but Vulkan seems a bit too complicated for my liking. The ray-tracing stuff is actually a small fraction of the OpenCL kernel, what I really want is a general way to write algorithms for the GPU in the way OpenCL and CUDA allow, and also provide interoperability with the graphics pipeline. I think OpenGL has something called a "compute shader" which might provide another alternative solution but isn't as flexible as OpenCL.

albinopapa
Posts: 3825
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Procedural Universe Sim using OpenGL and OpenCL

Post by albinopapa » June 12th, 2019, 10:05 pm

Yeah, OpenCL and Cuda are the only two GPGPU languages/apis that I know of. Vulkan is really only used for graphics and from what I gather has limited but growing support for compute or gpgpu workloads. DirectX also has compute shaders, didn't know OpenGL did as well. Unfortunately, it seems that C++Amp development has come to a halt. It converted C++ code to DirectX HLSL compute shader 5.0 code to be run on gpu. Last time I checked it out, it's development stopped with C++14 support, which kind of sucks as C++17 has some stuff which I find very useful.

The Sycl project uses OpenCL in the back end, and all C++ for it's front end so again relying on OpenCL. DXR (DirectX Ray-tracing ) would be a good place to turn if you are strictly wanting ray-tracing stuff. The downside is you need a video card supporting those features, but since you want to move to RTX API anyway, you are still limiting your audience to those chose nVidia and the RTX line of graphics cores, which is more limiting than CUDA, at least CUDA will run using SSE and multi-threading I believe if you don't have an nVidia card.

Maybe one day, the C++ committee will eventually get their act together and bring those features to the language. It would be nice to be able to stick with C++ and just pass an execution model ( executor ) to an algorithm and it will use the gpu or distributed network without having to create special code sections of code.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

JDB
Posts: 41
Joined: August 5th, 2015, 9:50 am
Location: Australia

Re: Procedural Universe Sim using OpenGL and OpenCL

Post by JDB » June 13th, 2019, 10:27 am

albinopapa wrote:
June 12th, 2019, 10:05 pm
Maybe one day, the C++ committee will eventually get their act together and bring those features to the language. It would be nice to be able to stick with C++ and just pass an execution model ( executor ) to an algorithm and it will use the gpu or distributed network without having to create special code sections of code.
I don't think this approach would be very fast, even OpenCL isn't that fast compared to a shader, but it operates at the GPU driver level so if you write code the right way it's still pretty fast, the restrictions and guidelines of OpenCL ensure you're writing code well suited for parallel computation. Shader code is even faster because glsl and hlsl are optimized for the GPU and the graphics drivers are optimized to make use of the hardware as effectively as possible.

Post Reply