#island scene, renderer rewrite from rust (C++, Vulkan)
1548 messages Β· Page 2 of 2 (latest)
Cat forgot to clear the backbuffer
i like it
free trial here we go
i've used designer a bit before, but i wanted to give painter a try too
did a bit more texturing work, it's kinda fun even though I have no idea what I'm doing
i need to stop working on these damn barrels though π
Time to rename the thread to barrel dev
π
it is a nice barrel
today on youtube: shirtless man designs plane in blender while being held at gunpoint
thats part of the tutorial yeah
modelling is hard as shit
simple plane though
i think I need to start a bit smaller with modelling
so I actually learn why I'm doing what I'm doing
all I know atm is inset and extrudeee
also uv mapping no clue
well how to uv map anyway
knocked up a quick gun on my lunch break
well just a basic model, then got it rotating nicely
i need to figure out the best way of doing things with blender, ideally I could make the plane in blender with the turret on so I can easily adjust scale etc but atm I'm just changing their position in my game
crate practice
first one looks terrible
my friend at work gave me a few tips for blender
so that's beenm really helpful
crate progression
These are pretty nice
i just keeping ask my environment art friend for help lol
he's very handy
i'm just afraid to model something that isn't a cube π₯΅
thank you π
I like the texturing :)
Maybe soon you can use andromeda for drawing your terrain 
it is slowly but surely becoming somewhat usable
hehe that would be cool, I've been quite busy the past few days but it's been cool to see your progress
i was showing someone at work too π
honestly terrain stuff is so fun and there's so many different things you can do with it
so i'm looking forward to seeing what different things you add
Yeah I chose it because it's narrow enough to keep me focused on one goal but broad enough to do lots of things for a while
definitely, can't wait to see erosion π
thats definitely coming :)
going awol for a bit, life got in the way π
o7
im going to regret not documenting properly when I get back to this π
1.5 yrs on, lets see how true this
might rewrite in C++, considering that's what I've been using at work the past 3 years, albeit without the training wheels of Unreal
i haven't touched Rust since this project and while I enjoy it, i doubt I'll be using it professionally anytime soon
also it'll make me rego over everything graphics related and reimplement it
i will miss the crate system though
perfect, starting Wednesday I'm beginning again in C++ lol
Renderer Rewrite (C++. Vulkan)
why do you switch back to c++ from rust?
i haven't programmed anything in Rust since I dropped this project, I've been using C++ the whole time since
and rewriting will force me to go over each bit of the project again, of which I've forgotten a fair amount
zar_gfx, renderer rewrite (C++, Vulkan)
cool, I've got vkguide downloaded and building as a base
i'm going to follow that seen as though it's updated, it might give me some ideas for structuring things
then start to bring over some of my helper abstractions
and go from there
vulkan, we meet again
yippee
mostly just following vkguide, but ported my resource manager across to C++
been looking back at my old project
i did a lot more than I give myself credit for!
but most of it was structurally rather than graphics side
i want to ensure I'm doing more graphics features this time
less worrying about optimal code solutions and more just good enough ones
thinking this morning, one thing I have always failed to do in vulkan is make it easy to add custom materials
so I'm going to make that one of my first goals
so that I can more easily mess around with shaders
well, custom in that I can load up a shader from outside the renderer instead of just having one for all of my meshes inside the renderer
i'll probably just use the same layout in the material buffer for all of them, so then they can all use the same pipeline
if you were to have different layouts, I guess I could make a material buffer per pipeline π€
because that's the only thing I would be changing
ok, so I decided to pretty much just delete all of the vkguide stuff and start over
because it was helping me get back to a point where I could continue on similarly from where I was, but it's making me gloss over all those steps of frustration of figuring things out myself
and how i actually want to structure stuff
and I already know a good 75% of whats happening, it's more the handy structures that are made in it for automating descriptor pool allocation etc, which I can always reference
aight, it's been a bit of a mess, but getting somewhere
every 5s i have to remind myself not to try and abstract everything and get on with programming
i made a MeshPool class that stores meshes in big buffers for me, I was going to make that also handle copying the data and telling the device to copy it from a staging buffer, but I decided that it probably shouldn't be responsible for doing that
i had made a device class and stuff for it to be able to do that
i just deleted that
so now it just holds the buffer handles it needs and has a slotmap which stores where the meshes are stored within those, when i add a mesh to it it just returns where to put the mesh
technically I could call that and then just not upload the mesh to the buffer and it would be a big empty space it's keeping track of, but meh. works for now
just trying not to make things harder to reason about
and pass dependencies only when I need to
setup my bindless image array
was struggling with writing the descriptor until I realised I missed the pNext for passing the extra info needed
next is to get image loading in, atm I can only make them
so gotta do that + generate mip maps
then it's make an island time
gunna make an island, with water around
and then put some shit on the island
just like i did in university
but this time make it look 10x better
the concept
island scene, renderer rewrite from rust (C++, Vulkan)
then I can chill on the island once I'm unemployed 
oh I could try make some dope ass music for it too
hell yeah
can't wait to be drawing stuff to the screen again
thank you learn opengl + vkguide
had to consult guides more than I was hoping for, but I haven't done graphics in a while, so I'll let myself off
now I'm on my own path to making this island at least
and I've already added stuff on top so it's not like I'm 100% just the same as the guide
gunna get instanced drawing working and then I'm making me island
should just be a case of setting up an instance buffer
i do need to look into BDA properly because vkguide was using it so I'm using it for my vertex buffer atm, so I might be able to use that for my other transform/material etc buffers I would usually throw in a descriptor set
nice
just did the buffers the way i know how to for now π
instance draw yippee
maybe I'll look into indirect one day
this is probably already overkill for now
considering ya know
there's 10 quads in the scene
i was hoping to have the basics of the scene setup today but things took a bit longer than I thought
so tomorrow
was having some interesting issues trying to draw a second mesh
turns out I wasn't calculating the offset into the vertex & index buffer in bytes
when I was copying stuff
all solved now though, was a bit awkward as I was just getting VK_TIMEOUT or VK_ERROR_DEVICE_LOST
need to make the terrain not just a plane, but nearly there
wondering how to handle my different materials
so I have a Material buffer which atm just has a texture to use
struct MaterialData {
int textureHandle;
int padding[3];
};
but obviously my water is going to need different parameters than my terrain, which will need different parameters than all my other objects(probs going to do a terrain shader that blends between heights).
i'm thinking that for each material type, i make a buffer for it. then, when I pass my material buffer device address to the pipeline, i just hook up the correct buffer for the pipeline. and in that shader it assumes that material buffer is laid out a certain way
For example:
struct WaterParameters{
float speed;
float amplitude;
};
struct TerrainParameters{
float blendHeight;
float blendStrength;
};
struct DefaultMaterialParameters{
float blendHeight;
float blendStrength;
};
// Shaders:
layout(buffer_reference, std430) readonly buffer MaterialBuffer{
MaterialParameters materials[];
};
layout(push_constant) uniform constants
{
VertexBuffer vertexBuffer;
MaterialBuffer materialBuffer;
} PushConstants;
// Water Shader
struct MaterialParameters {
waterParams...
};
// Terrain Shader
struct MaterialParameters {
terrainParams...
};
// Default Shader
struct MaterialParameters {
default params...
};
also, probably need to find a better place to store the vertex and material buffer rather than push constants.
the vertex buffer doesn't change atm, I just have a huge one, so that could easily be stored somewhere.
in this case though, materialBuffer would obviously change per material, so would need to store all of the different buffer addresses in a buffer somewhere
i'm just making this up on the spot
need to think more about it
I wonder:
- MaterialInstanceBuffer which holds Material Buffer Address and Index into it
- MaterialBuffer for each material which holds material params for each material instance of that type
Then:
- InstanceData has an index into MaterialInstance buffer which it can then use to grab Material parameters
do you have layer messages enabled?
I have a very similar layout, for shaders as you, except I just have one shader for drawing opaques,
im using vkconfig, but I think I need to change the preset
as on further inspection it's missing some options
I turn on sync validation after I make changes to how I send data
or if I add a layout transition etc
I also turn on best practices every so often to see if I need to fix anything
it's really slow so I don't leave those on
i just turned most things on and there's nothing too worrying there, so that's good
but yeah I will probably have a general purpose shader for drawing most of my objects too
the terrain and water are just special cases
I like sine waves
ye
its a start
spent the rest of the evening making it so now I can just make a RenderModel with the material, mesh and modelMatrix and it'll get sorted and drawn
was previously just manually doing all the draws for the two different materials
so now it's super easy to add more of an object
messed around with using noise to colour it instead of a texture
tomorrows goals:
- actually make the island
- load skybox so there is no black void
- profit??
oh and add depth foam to the water
also reflections in the water, fresnel and underwater caustics please
skydome reflected from the water
been trying to get a skybox working for the past 2 hours
idk whats different
i've implemented them in vulkan before but I can't figure it out lol
nevermind
i did have it working
my skybox just looks like ass
ok so I finally got my skybox working with reverse Z
i was messing around with the depth bounds for ages, then realised I didn't have the bound test enabled
thank god for renderdoc
not an actual island yet, but that's due to my blender lack of knowledge
but loading in a gltf π just a simple version for now
Nice
just spent half an hour chasing down a sync issue only to realise it was rivatuner
what a bastard
Looking super, this wip submission references tessendorf, maybe you already know all this but thought it would be relevant to you if you didnβt #wip message
not done too much today graphically, but got material instances working
setting up the code was a lot more work than I expected it to be C++ side
but i got there
not particularly happy about the quality of the code, but it's a start
made some simple imgui that lets me change the material parameters nicely
probably a bit overkill but it's nice to have debug and see things change in real time
tomorrows goals: create a new shader for the terrain then add some basic lighting onto it
terrain has it's own shader now π
no lighting as of yet
oh
i just realised my mipmaps weren't being generated for the images
also reduced how much they tile
as it was wayyyy too much
tomorrow: lighting!
gunna just do a directional light for now, donβt have a ton of use for pointlights/spotlights yet
before I head to bed: skybox reflections on the water
remembered I had done that at university
harder to tell in a still image but it's nice to see them move in the water
clearer image you can see at the bottom where it gets stretched on the wave
nabbed the code that's calculating my normals for me from uni code, so need to actually dissect it and remember what it's doing another day
so i was actually calculating linear depth wrong
i was doing depth/near plane lol
which was my water "distance factor" had to be so high
it all makes sense now π
i've added an invLerp now so that I can just say the linear distance i want it to fade between
result is a lot looking different blend but thats ok
added some foam too
n
great progress
wow
needs trees now
you know in Civ I always like to create custom island maps and play a sea faring civilization and build a huge navy power
islands are fun
you'll probably want to add shadows after you add trees
if you don't have them already
Oh yeah lol
Forgot about shadows
iβve done them before but they were pretty ugly
so I wanna make them nicer this time
just gunna start with directional light shadow
and try do csm
hopefully with my material stuff i've been doing it should be fairly easy to setup the shadow pass
but we'll see
there's still a fair amount of boilerplate and duplication when I need a new pipeline
but I'm trying not to bikeshed too much
because I'll just pick out the more useful parts into a library once I'm done anyway
ok, so I'll:
- add trees in (will need to work on gltf loading so I can load up a scene with them in from blender, atm it's just simply loading the mesh in)
- add in shadows which I can stress test on all the trees
- implement pbr
I am never happy with my shadows but they are always getting a little bit better
they can be hard to get right from what I remember
what types of shadows do you have?
just one cascade right now
which I guess is not really a CSM, but it is written as a CSM with one cascade
it is a directional light with an orthographic matrix
I don't have point light shadows
not yet
I will though
i remember doing point light shadows at university and i remember doing it a pretty scuffed way
or it felt scuffed
maybe that was just opengl lol
i'm just redoing stuff I should have learnt a lot over by now
i still haven't done much new in my rewrite compared to my rust engine I had
but I'll get there
why'd you change to C++?
i haven't touched rust reallyy since I did that
and I couldn't be bothered to try and pick it back up
i didn't have a great grasp on the language back then so it was a lot of learning it while trying to make an engine
and I thought I'd just avoid it this time around
and it's also nice to get to use C++ on it's own, at work I use Unreal Engine, so the C++ there is easy mode
ok I knew something was up with my specular code
i was calculating the direction when I already had the direction lol
also just removed the calculation for my terrain because it does not need it at all
trees! but all using the wrong material lol
trees
nice
i was messing around seeing if I could just integrate Streamline so I could setup DLSS in the future
but having cmake problems + it doesn't seem to like working with the vulkan imgui default backend
thus I give up for now
idk why I was trying to do it anyway
wow that was quick
yeah, there's a bunch of issues to work through though
there's self shadowing
they dont look good at all
and the water doesn't appear to be putting them in the right place when I tried to add it to it lol
but its a start
also, for the trees, need to discard their alpha in the shadow pass
i have a lot of refactoring to do code side to clean up how I'm handing my render passes
atm i just have an enum and do different things based on that
but I'm going to make an actual struct I think
worked on shadows a bit, looking a lil better
the trees now discard using their texture
that was a bit annoying to sort
so I have material buffers for each material, and they store the instances of that material
for each object I draw I have an entry into an instance buffer which has an index into a transform buffer, and an index into a material buffer
because those material buffers are separate, the indices can overlap with each other between different materials
but for a shadow pass I just want one buffer filled with what texture to check to discard against if there is one
so I have to go through each material, copy it to that buffer and then keep at which offset it was put into the discard material buffer
then I just offset the material buffer address when I'm drawing the objects in the shadow pass
it works, but it seems obtuse
and overcomplicated
i can see now why you would want some way of essentially saying for material X, this would be the diffuse output (like in Unreal for example), because then instead of manually converting between my CPU structs which have their own versions of image handles, you could just say for material X, what is the diffuse output
i guess the reason I have this overcomplicated conversion step is that I could just run a version of the shadow shader for each material, but the material structs are different for each one
so that would require me to have 2 different versions of the fragment shader, one that could pull out the diffuse from an opaque material and one that could pull out the diffuse from the terrain
not like the terrain even needs this alpha discard functionality for shadow passes
but I guess my intention would be for future objects
for now though, I'll stick with this jank conversion step
and take a look back at it again if I ever try to generalise my materials more
for now I just have a few different CPU structs stored in a variant, then on the renderer side it just converts it into vectors of each of them but in a GPU struct version
that way the interface is nice for the CPU side and then the GPU version is where all the texture handles get converted into bindless indices
it's very verbose and each time I make a new material I need to add the pipeline for it, setup the material buffer for it, setup the CPU and GPU versions of the structs, setup the conversion step, add the copy buffer step etc
but it's some form of material support
which is more than I've ever had before
oh yeah I also changed how the terrain shading works
need to make it blend now
atm I just have hard ifs for normal gradient and height
wanna add rock too so that there isn't a pile of sand
and then triplanar mapping
not much progress made tbh, just trying to clean up my renderer a bit
considering how huge it is
inside sponza while I work on lighting & shadows π
probably need to look into this at some point
it looks a bit naff
probably hard to though
π€·ββοΈ
i got CSM implemented today
just followed the logl tutorial for now
need to clean up a bunch of stuff
loading sponza so I had to modify my basic asset loading code too
ok so I may have done someting cursed
i have a resource manager i use for creating buffers and images that gives out Handle<Image> etc
and that's handy in all my utility classes where I can pass a handle instead of the actual vk objects
but anytime I want to pass a swapchain image, I need to then find some way of handling both cases
so I've just decided to make it so I can add images into the resource manager myself
even though they aren't really managed by the ResourceManager
amazing name of course
oh well
maybe there is a case for keeping them separate but for now I would rather have the utility of being able to access all my images with a single handle type
and if it bites me in the arse I can refactor later
had the ImGUI srgb fun today after realising how dark everything was
just modified the shader for now
well actually
it was because I made my swapchain SRGB
and then obviously it fucked up ImGUI
adding normal maps
turned out to be quite faffy
but I'm there
generating unindexed vertices -> using mikktspace to get tangents -> using mesh optimiser to weld them together
i believe is the right steps
the helmet is back
now I just need to actually work on lighting
and make it look good
added some super scuffed and very incorrect sampling from the skybox
but it looks neat!
made the water less bright
and also respect the ambient light
before it was essentially emissive lol
god
everytime i have to add a new library in C++ i die a little inside
but I now have spdlog
it wasn't playing nicely with fmt
Yeah rust's cargo is a drug
Until u get some errors with it because conflicts
yeah
i have probably blocked out any problems I had with it
but C++ messages always so confusing
i need to speed up my asset loading as it's starting to irk me
over 1s in release, i tried removing some tracing but really the problem is that I'm loading from gltf every time
and especially when I'm using mikktspace to generate tangents everytime, there's a lot of wasted time everytime I load up the program doing the same thing
i've never made my own binary format but that'll be the way to go
cool, I've got some vertices and indices being written to a file and loaded back
but obviously for a full GLTF model I'm going to need a lot more than that
need to handle multiple meshes, then haven't even though about materials or textures yet
i need to generate tangents after I've loaded it in
so it's easier to just save it back to my own format
it's quicker!
all back up to the same functionality now
debug mode is no longer horrible with sponza
and i have old poo poo sponza
god forbid i tried to load intel sponza
atm I'm just dumping the textures data into the file along with everything else, but I'll probably need to modify that at some point
tried to load intel sponza
as expected
death
but that's ok
I know for a fact I'm not handling the gltf format correctly in terms of transforms and things
and then the textures are facking huge
so I would need to figure out how people compress them
for now, old sponza
π
so my rotations were always borked importing from fastgltf
because i'm an idiot
and didn't check what the rotation value actually was
i was doing a rotate around a vector when it's a quaternion lol
the only thing is atm I bake all of the child transforms when I cook, so each node just has a transform and it doesn't have to consider child/parent etc
but I should really preserve those relationships so it's actually useful data once you load in the cooked mesh
but for now it's one less thing to do
and I'm not moving objects around in the scene once cooked so it doesn't matter too much
and then I don't have to think about how i would handle all of that yet
tbh I'm kinda just bikeshedding the past few days
instead of working on the island
but it's been nice making my import process more functional
and I've made my own binary format! which is cool
messing about with grass
just handling it through my normal rendering pipeline for now
will push it through that until I need it to perform better
want to turn off drawing the grass to the shadow pass, so that's something new to add to my materials
because I don't necessarily need a whole new material for it, it's just: don't include it in this pass but draw it the same way otherwise
because as soon as the light gets more angled, you can see how having the grass in the shadow pass starts to mess stuff up
the shadowing on itself doesn't look good at all
progress slowed down but still plodding away
not sure how I'll handle materials in deferred land yet
but atm my understanding is that I'll probably share vertex shaders for forward and deferred materials, the fragment shader will then be different for each one
but in both cases I want the lighting calculations to be the same
just happening in different places
for now because I'm just back down to one material type, i don't have to worry about that
realistically most of my materials are going to be either forward or deferred, not both
so I just need to figure out a nice way of sharing the lighting code across all those shaders so I'm not duplicating them
even if it's just a function I pass a bunch of params into
finally got round to moving my mesh binary file logic into a library instead of part of my engine
so now i should be able to make a program that just runs that logic on a file, and call that as part of my build process
didn't take as long to set up deferred as I expected, although I guess I done it a few times
my gbuffer layout probably isn't ideal atm but oh well
currently got:
- colour : VK_FORMAT_R8G8B8A8_SRGB
- normals + roughness: VK_FORMAT_R8G8B8A8_UNORM
- emissive + metallic: VK_FORMAT_R8G8B8A8_UNORM
but thinking, seen as though emissive is also colour data, it should be sRGB? or I should just handle the conversion myself
still a lot for me to learn about colour anyhow
added my own sun in this morning
need to find a skybox without one on now
also setup an executable to bake assets for me, so i now have it setup as part of the build process
and it's already compiled into an executable so no need to recompile it everytime
so much speedier π
just realised there's something going wrong with my mesh here lol
this will be fun to find out
ah man im such an idiot
been modifying the cooker without building a new release version
hmm, still something weird going on
im just confused when this happened
looks like I fixed this and then my tangent calculations break
hmm :/
ohhh
im such an idiot
i thought I had fixed a bug in my code when I was unindexing my mesh to prepare for mikktspace calculations
but i actually had it right the first time lol
ffs lol
back to normal
added a little debug combo box
did some work on my binary format
textures are separated out into their own files now
on second thought, not sure I needed to do that
was going to try and start compressing my textures
and for some reason felt it would be easier in their own files
but really it should still work as part of one big binary file
there's probably other benefits to having them separate from the main file
but I'll leave it as it was for now
also, pretty sure that'll just compress the files on disc
need to read more about gpu texture compression
ah ok, looks like i need dds
hmm, so if I'm understanding correctly, i need to compress the textures within vulkan and then save back to disk?
and then next time I can just load the compressed texture
and not deal with png/jpg etc
or you use some tool beforehand to compress the textures the first time
ok so im dumb
you do just use a tool to compress them
seems like nvtt is what I should use
so, my asset-cooker will load image from png/jpg whatever, compress using nvtt then save that to a file
then I load that up with dds_image
and throw into an image?
with the compressed format set
man
im so dumb
i've been accidentally flipping the depth values for my shadows this whole time
and rendering them as if I'm using reverse-z
oh
im still getting weird problems
i give up
working on SSAO today
need to add in a blur
it was a lot of pain until I realised I was calculating my fragment positions in world space instead of view space
but still
hmm, i my normals are also in world space
need to fix that
man
i am even dumber
so
i couldn't convert my normals to world space from screen space
(now outputting sceen space normals in gbuffer)
turns out i was using an unsigned format for my normals which meant anything below 0 didn't work
very smart i am
very smart
oh yeah
you can see it was broken beforer
now the back wall is completely white
i got a new job! i start next week
thats why I been so quiet here
want to keep up with this but took a backseat to relaxing before starting


