Thursday, December 12, 2013

OpenCL up to Speed, and 4K Voxelisation Has Been Attained

As you can see there are still plenty of graphical errors, but I have finally cracked that magical 1024 voxel dimension limits I have had for all this time. 2k isn't that impressive these days, so I jumped straight to 4k, which is needed to see pretty much all of the little patterns on the inside and outside edges of the Stargate. Amusingly, that 16 fold increase in detail didn't noticeably impact performance at all, at least on the rendering side of things (brick creation on the other hand...). Also the OpenCL renderer has been brought up to speed, and currently works at least as well as the OpenGL renderer. Sadly the same can not be for OpenCL's performance, which is really quite poor, at least on my GTX680 it appears to be roughly a quarter of the frame rate of the GLSL version. The Stargate model comes from here. Source code for the current progress as always is available from GitHub.

Thursday, December 5, 2013

Success! We Have Voxels!

Here's the code. Finally, the current implementation matches the original in terms of capability. It also significantly exceeds the original in terms of performance, and contains a version of the LRU allocation scheme (even if in its current state it isn't doing anything). This is almost a complete implementation of Cyril CrassinGigaVoxel method, albeit missing the spatial mipmapping, and about a thousand visual tweaks, most of which depend on the mipmapping. I can almost taste the Global Illumination.

Tuesday, December 3, 2013

Underwhelming Screenshot 5: Gelatinous Cube Eats Bunny

Significantly more whelm than previous entries, still lacking that whole voxel thing I set out to accomplish. As far as I can tell, the only thing that's not working is for some reason the voxel rendering shader can't get brick id's, which is curious as the brick creation shader is most certainly writing to the brick texture (I checked). The really amazing part about this, is how fast it runs. This is *very* real-time. This Octtree is 7 levels deep, and it took 7 frames to generate. Frame rate appeared to stay well above 40fps. It's quite mesmerising watching a bunny form out of blocky nothingness. Even though it doesn't completely work, I'm still quite chuffed, as building the Octtree and associated 3D texture took tens of seconds in the old version, where as this does it's job tens of times per second. Source for the adventurous.

Tuesday, November 26, 2013

Underwhelming Screenshot 4: Yet Another Cube

While this happens to be the very same cube as the last one, from exactly the same angle IIRC, this one is of note for being output from GLSL, and more importantly this should run on AMD GPU's... but I haven't tested it. In the "Display" menu there is an option to switch between GLSL and OpenCL for rendering on the fly. I took the time to make sure they are pixel for pixel the same, correcting the GLSL fragment coords to achieve this.

Of particular interest is the horizontal line through the middle of the cube. It only appears at certain angles, and I believe it to be the result of GLSL not handling infinity quite as nicely as OpenCL does, as the AABB-Slab method I used exploits floating points ability to store both positive and negative infinity. Alas I'm not sure if this is a bug or intended behaviour. Back in good news land, there as yet appears to be no difference in performance between the two implementations on my GTX 680. Here's the relevant commit.

Wednesday, November 13, 2013

Underwhelming Screenshot 3, but it's Perspective Correct!

Take a hard look at this one folks, it's something I can almost guarantee you've never seen in real-time graphics. It's a perspective correct cube. Check out those subtle curves on the edges, yeah triangles don't do that. Here's the GitHub link for the revision.

Monday, November 4, 2013

Shadertoy like OpenCL Kernel Tester

EDIT 2017-11-10: The build environment instructions I've given here are quite out of date, a current one can be found here. Regarding DLL's, MinGW can link directly against them, so there should no longer ever be a need to use dlltool or gendef in anger. END-EDIT

Well I say it's like Shadertoy, but it's nowhere near as good. Either way, it's OpenGL using a texture that's generated in OpenCL, and the CPU isn't getting involved. I've also rewiggled the build system, so now it should theoretically build Windows binaries from Linux, although my Debian Wheezy tests have so far not yielded success. I'm hoping there were bugs in the gcc-4.6 version of mingw64, but there's probably a flag somewhere I'm missing, as my Windows test with the same build config on native Windows version of mingw64 with gcc 4.8 worked a treat.

So GNU/Linux users, to build this type "make". You'll need the OpenCL dev files, and some X11 stuff. It should all be in your repository. It doesn't matter if you install the Nvidia OpenCL headers, or the AMD ones, or the Intel ones. They all work the same, and all speak to each other. Your distro's package manager should have everything on hand, shouldn't be more than a couple of megabytes.

Windows users, to build this type "make". Setting it up to be that easy is a bit of a task. First go download and install the mingw-get-setup.exe, run that and it will do some downloading and some thinking, and then present you with a list of things to install. Down the bottom is MSYS, we need that. We also need the minimal MinGW option at the top for a DLL tool it has, and while we're at it combine it with g++. Once that has finished its thing, (~100Mb later), go download MinGW-w64, and extract it to your C:\ drive. Yes in the root directory, it's a compiler, they're special beasts. Now right click on My computer, or whatever it is these days, and work your way to Advanced Settings and finally to edit your environment variables. Edit your Path, and at the start of it put the text... "c:\mingw64\bin;c:\MinGW\msys\1.0\bin;c:\MinGW\bin;". Now you've got a little bit of unix for your very ownsome. You can open a command prompt and type ls, rm, grep, even bash. Ahem, the last step is installing the OpenCL headers and libraries. I might get in trouble for distributing these files, but it's in good faith so err lets find out. The header files come from Khronos (via Nvidia), the def files were generated against Nvidia's OpenCL.dll and OpenCL64.dll. I'm pretty sure I modified the headers to not complain about using older style OpenCL commands, because that's all my implementation supported. So the files are not official, download this file OpenCL-MinGW.7z, put the contents of the include directory into your c:\mingw64\x86_64-w64-mingw32\include\ directory, and plonk the def files down for a tick, and run this command...
dlltool -l libOpenCL.a -d OpenCL.def -k -A
dlltool -l libOpenCL64.a -d OpenCL64.def -k -A
That will give you the lib.a files you need, stick them in c:\mingw64\x86_64-x64-mingw32\lib\ When the time comes that you want to use more modern OpenCL, you'll have to download the OpenCL SDK from your hardware manufacturer, find their DLL's, and run these commands on them...
gendef OpenCL.dll
gendef OpenCL64.dll
That will give you the .def files you need to give to dlltool. If you're cross compiling from GNU/Linux, dlltool is named "x86_64-w64-mingw32-dlltool". It can be coerced into producing the lib file straight from the DLL, but there's no way I'm going to distribute their DLL's.

Well, here's the link to the code. It builds on Debian Wheezy, and 64bit windows. You can build it in 32bit mode, but I've got datasets too big to fit in 4Gb of RAM. I don't support 32bit for this project. The upper case sigma, "Σ", reloads the OpenCL kernel from disk.

A note about OpenCL. If you've got current video card drivers from Nvidia or AMD then you already have all the OpenCL you need. I expect my OpenCL kernel will disagree with AMDs OpenCL compiler... feel free to fix it AMD owners :-)

Friday, September 13, 2013

Most Underwhelming Screenshot Attempt 2

Another in a soon to be oh so very long line of underwhelming screenshots. This one demonstrates OpenCL borrowing a texture from OpenGL, filling it with gradients, and returning it.

Just like the last underwhelming screenshot and if anything moreso, this is a portent of things to come.

Sunday, June 2, 2013

GUI progress

So there's the progress on the GUI so far. As I plan on making it the usual, here is the branch on GitHub. There's nothing particularly fancy to report, it's yet another GUI framework for OpenGL, but this has the almost unique distinction of being written in C99. It's all WIP, so if you use it, don't be surprised when the next version breaks everything.