/BERGASMS/GAMES/001
28/02/26: 001
So i have about a million ideas for games written down in various books and notes and stuff. But an unrealised idea is not much good to anyone, so I am actually trying to finish something off. Naturally, this is about the 50th time I have decided this, but oh well. The current idea is kind of like the old pirates of the Caribbean game from the original xbox where you traded between islands but instead uses airships and the entire world is floating above a cloud of toxic gas or somesuch. I am writing the whole thing in zig, using vulkan and sdl3, and apart from freetype those are the only dependencies. I have ported a version of cassowary to zig so I can do autolayout, and I have written my own UI and everything. I've also got a lot of helpers for vulkan stuff that is annoying like descriptor sets and that.
Precisely none of my code is written using an LLM. I enjoy writing code, so for my personal projects I'm going to do that, instead of babysitting a neural network. I can do that at work plenty on their dime not mine. So all the success is mine, and all the failures as well.
So this is where we are at. there are some white sort of cubes with some bridges between them made of wooden planks. Mostly this is all tech demo stuff. But, it's a start. So the next thing I want to add is a sort of background. Not a skybox, but a... groundbox? groundplane? anyway, it's gotta be a sort of foggy cloudy layer that sits below the stuff.
The whole feel of the game style is sort of N64 or playstation2 levels, nothing special. So I am thinking a decent effect can be obtained by just having a diamond square generated texture or 5 transparently layered on a couple planes. So we will work on that for now, with maybe a bit of colour thrown in.
OK, so that's what a basic white plane looks like, without any positioning. I'm reaping the benefits of the work I did to set up helpers. So we want to make it a bit transparent, and with a texture on it. So we will set up the texture generation first. I have a compute shader setup that lets me generate various images, so I'm gonna see if you can easily run diamond square in a compute shader or is it better to just do it in app... or should i just use the smooth noise stuff i already have. I kinda want diamond square though just for nostalgia sake so that's what is happening.
..thinking happened here
OK, i want to implement diamond square mostly because it will give me some more tools surrounding compute shaders, and also synchronisation of data. Basically you need to continually dispatch the shader with progressively smaller step sizes and continually flip flop two buffers as the read and write sources till you get to where you need to be. So i will do that.
..coding happened here
It turns out, whilst i was setting up my check conditions, that I don't have a shader set up to render transparent stuff. So I will need to do that first. FYI, check conditions probably have a fancier name but to me they are basically the leg work that I have to do in order to be able to correctly see the results of the thing I am doing. In this case, I wanted to make sure I could put a texture on the plane i generated, so i just generated a mishmash of noise, but I noticed the alpha wasn't being applied.
texture works, but i tried it with varying alpha and no difference
All that being said, it's probably a good thing that I have a seperate pipeline for rendering the fog box because it's gonna be a fairly bespoke sort of thing, so a seperate pipeline will let me mess about with things in the shader to get some good effects.
..thinking happened here
Hey!, that looks pretty cool. transparency works well. I had to make sure i could supply blend state to the pipeline builder but that was the only trick. So now i know i can do transparent, and I know i can see the results, so all that is left is to get the texture i'm after which i'll use diamond square for.
..sleep happened here
So whilst i'm working on this, I realise i probably need the ability to transform texture coordinates. So before moving on i'm going to be sidetracked add in a transform matrix to my per instance stuff.
And there we go, that looks really cool. I've animated the textures such that they move faster or slower depending on depth, and they also have scaling. I'm going to start a new page to discuss the compute shader stuff, if you want to chat about this page, go here.
Discussion Link