Transparency
As you can see, the current handling of transparency presents some issues, especially when dealing with overlapping faces. This can be resolved using depth peeling, which I plan to experiment with in the future.
This Minecraft clone was made from scratch using modern C++20, Vulkan, GLSL, and SDL. The clone is built upon RealCore and my own Vulkan abstraction, which is named Real3D. The project handles some of the rendering aspects of Minecraft, including random terrain generation, transparency, sprites, and animated textures. Real3D is not a perfect abstraction, but I enjoyed working on it, and I am planning on improving it and learning more about Vulkan. For this project, it works quite well in my opinion. My interest in graphics programming skyrocketed while working on this project, and I have many more projects like this in mind.
View on GithubYou've probably heard of it, Minecraft, it is an infinitely large sandbox game where the player can build everything they can think of. The terrain is made of cubes layed out by using a noise algorithm. The world consists of multiple chunks (meshes). Only a small amount of these chunks are rendered obviously, for performance reasons. On my laptop, my clone of the game ran smoothly (60FPS) up to a render distance of 12 (25 x 25 chunks). When traveling, new chunks are created, while old chunks, now out of the render distance, are deleted. Any progression on any save will be saved.
Real3D was built by following the Vulkan Tutorial. The version the Minecraft clone was built upon was created in the course of 12 weeks. The engine of course handles everything render related, and comes with some handy components, like a camera component and a mesh component. There is also an option to load meshes, textures and shaders. Materials with custom pipelines can also be created by the user and applied to any mesh. Frustum culling using AABB is also implemented in the engine for a better performance. Sadly I didn't find the time to fully include ImGui in the project yet, but this is on the top of my todo list.
Some of RealMinecraft's features include transparency (water, leaves, flowers), animated textures (water), sprites (flowers), procedurally generated terrain using simplex noise,
dynamic meshes and loading/saving of chunks.
Transparency was definitely the hardest to implement, I chose to sort the faces of the transparent meshes from furthest to closest to the player,
but that came with its own flaws. I later learned about depth peeling, but I didn't have the time anymore to implement this. I am very interested in this subject and have done already some research,
and would love to build a project around this. As mentioned, meshes in Real3D are dynamic, there can be vertices added and removed during rum time, so the player can place and
destroy blocks wherever it wants.
Chunks are stored in a binary , I found it quit clever and fun to mess with this. Every chunk has one file, where its stores
all the blocks that have been changed. The position and type of the block are all mashed in a couple of bytes for maximum efficiency.
As mentioned before, improving and learning more about transparency in graphics programming is definitely a priority for me. I found it quit intriguing that such a simple thing as transparency that we don't even think about in real life, can be so difficult to add on to our screens. I also wanted to experiment more with shaders, as this project lacks a bit of those. Dynamic lighting is also something that I could experiment with.
As you can see, the current handling of transparency presents some issues, especially when dealing with overlapping faces. This can be resolved using depth peeling, which I plan to experiment with in the future.
The water shader uses a larger sprite and a time parameter to create an animated effect by switching textures.
The mesh component is dynamic, allowing vertices to be added or removed during runtime. This means the player can place and destroy blocks in any chunk.
Chunks are created when in range and deleted when out of range. Placed and destroyed blocks are saved to a file to ensure your progress is preserved.