Pages

Friday, September 28, 2018

Cross Platform Vulkan

With the release of MacOS 10.14 Mojave, Apple has deprecated not only its long suffering OpenGL implementation, but also OpenCL. As they were the original creator of OpenCL, I think it's safe to say it's as good as dead. That leaves Apple with no viable Graphics or Compute platform. Fortunately, The Brenwill Workshop open sourced their MoltenVK library, which acts as a very lean Vulkan layer that sits on top of Metal. After getting a very rudimentary single window with a shader example going on the 3 platforms I care about, being Windows, Linux and MacOS, I can say that not only does MoltenVK work, it is arguably the best library on the entire MacOS ecosystem. There are a few small gotchas, and I wish to detail them here.

Firstly, there are only three supported surface formats. This is because MoltenVK uses a CAMetalLayer for its rendering, and this only supports five formats, and two of them are just downright odd, so justifiably ignored. These translate into the following Vulkan surface formats...

VK_FORMAT_B8G8R8A8_UNORM
VK_FORMAT_B8G8R8A8_SRGB
VK_FORMAT_R16G16B16A16_SFLOAT


...which gives us plenty to work with. This should not be considered odd at all, the current Nvidia drivers on Linux, 396.54, as well as the current Nvidia Windows drivers, 411.70, only report the first two of those formats on the 750M I tested (the same MacBookPro I tested the Mac version on). It should be noted, that on Windows and Linux, Vulkan will initialise with other formats, where as on Mac it will crash with a...

*** Terminating app due to uncaught exception 'CAMetalLayerInvalid', reason: 'invalid pixel format 70'


The only other quirk I encountered was the order of operations. As the shader takes a single float in a uniform buffer, the exact location of the vkCmdCopyBuffer() call to update the uniform buffer caused the drawing to stop right after the clear command was issued, so I was left with a ClearColor coloured window, even though everything was reporting success. That was without the full Command Queue debugging options enabled, so I suspect that will complain if you have it enabled.

If you want to play with shaders on Vulkan, on either of the three platforms, the repository is here.

Thursday, June 15, 2017

Fresh System Install

This is primarily for my own records, but I think it's also needed for programmers to detail their *exact* setup so people can play along at home. Not so important on Linux (because Linux is a programmers OS, that stuff works really well), but utterly essential on Windows, where this time around I counted over half a dozen different distributions of *mingw* alone. Here you will find, what is in my opinion, the "best practice" method of getting my cross platform dev environment going. If you're watching my Voxel Project at all, this combined with the readme.md located there, will tell you *exactly* how to set up your compilers, covering *every single step* required to make it work. I write this today, because the instructions I wrote last time are no longer working. Lets see how long it lasts this time.

* Windows updated as of 2019-06-14
* Linux updated as of 2018-11-09

All OS's

google.com/chrome

Ubuntu 16.04.02

ubuntu-16.04.2-desktop-amd64.iso
Win32 Disk Imager - allows UEFI to work, on unix use "dd"

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-410 vulkan-utils

# from Voxel Repo
sudo apt-get install a56 imagemagick git-core libglu1-mesa-dev libxi-dev ocl-icd-opencl-dev mingw-w64

sudo apt-get install clang vlc vim-gnome

# from GitHub
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
ssh-add
ssh-copy-id username@oldhost

Windows 10

Windows 10 USB Install Tool

All OS's Step 2


git config --global user.email your_email@example.com
git config --global user.name "your name"

Tuesday, March 24, 2015

dhewm3 1.3.1.1304 x86_64 binaries 2015-03-23

Off topic, but I couldn't find them anywhere, so I stepped up and made them.
Stick 'em in your DOOM3 directory, and enjoy. This will not work with the BFG Edition.

These are built from this version of dhewm3, I didn't modify the source code at all. The licensing info is in COPYING.txt, it's GPL3 + some extra terms. The licenses of the libraries are in LICENSES.txt. The DOOM3 data is still very much copyright, I recommend you read the dhewm3 Readme for links to where to buy DOOM3 so you can put these binaries to use.

Following are the steps I took...

Mac OS X


After installing XCode, CMake and MacPorts, I ran...

xcode-select --install
sudo port -v selfupdate

sudo port install openal-soft libsdl-framework
git clone git@github.com:dhewm/dhewm3.git
cd dhewm3/neo
cmake -GXcode
xcodebuild -configuration Release

Ubuntu 14.04 x86_64


sudo apt-get install libogg-dev libopenal-dev \
     libsdl1.2-dev libvorbis-dev libcurl4-gnutls-dev
git clone git@github.com:dhewm/dhewm3.git
cd dhewm3/neo
cmake .
make -j8

Windows


I tried compiling the dependencies myself, but it's fraught with peril. Just download the official dhewm3-libs in a Zip file and extract them into the directory you run these commands. Importantly they must be run from a shell that does not have sh in it's path.


git clone git@github.com:dhewm/dhewm3.git
cd dhewm3/neo
cmake -G"MinGW Makefiles" -DDHEWM3LIBS=../../dhewm3-libs-master/x86_64-w64-mingw32/ .
make -j8



Phew.

Wednesday, September 17, 2014

Tardis, Now with Ambient Occlusion

Thought I should throw some Ambient Occlusion its way, because it makes such a huge difference. I also modified the way the geometry is created, it's just one corner of the Tardis now, mirrored around the X and Z axis with abs(). This allowed me to use less objects, allowing me to use more objects! So now all of the windows have the panes on them, and I added some of the little bars around the roof light. I'm thinking the next step is to improve the time vortex, describing it as "basic" is being needlessly polite. Here's the link.

Another Dr Who Themed Shader Experiment

Here's another ShaderToy, this time based off of the time coordinates as seen in Doctor Who (2005) S7E13 - "The Name of the Doctor". While the picture does justice to the line drawing algorithm I created for the task (I was offline at the time), to really appreciate it you need to see it moving. This one maintains a constant framerate on my Nexus5, so should work pretty well on WebGL devices with at least that much power.

Wednesday, September 10, 2014

Shadertoy's Dalek was Lonely


So I decided I'd create this shader to keep him company. Then a nice chap called Andre told me I could use his awesome sound shader (sound shaders a black magic to me, which makes Andre's accomplishment all the more impressive) as background music. Took me about 5 hours of effort, which included "figuring out how this raymarching biz works". The lighting is a bit off but I figure light is supposed to be funny in the time vortex. Also I'm not aware of a way to do ambient occlusion in a raymarching fragment shader.

Friday, January 17, 2014

Starting to Look Impressive - Crytek Sponza

You're not really showing off your real-time rendering code unless you're showing the Crytek Sponza. Sadly no GI... yet.

I've added *basic* LOD support, and added the all important colour bricks. Lighting bricks are the next brick in line. There are still some odd ray errors, and the colour does odd things when it's really thin (which at the moment, is always). Here's the commit.