r/vulkan

▲ 11 r/vulkan

I built a Vulkan ray-marched voxel sandbox in Rust because I got tired of switching between Minecraft and external tools just to make custom blocks

https://preview.redd.it/ylepaccpbkwg1.png?width=1312&format=png&auto=webp&s=f80a28aaa4cfb7bf2619919ad9c9330cddd3c949

My daughter and I have spent countless hours in Minecraft creative mode. Over time we kept reaching for external apps to design custom blocks, models, and textures. It worked, but the context switching killed the flow. At some point I thought -- why isn't all of this just... in the game? An ultimate creative mode where you never have to leave to make something new.

So I built Voxel World.

It's a GPU-accelerated voxel sandbox written in Rust that renders entirely through Vulkan compute shaders. No vertex/fragment pipeline -- everything is ray marched through a 3D texture. I went this route because I wanted to see how far you could push pure compute-based voxel rendering and honestly because it was a fun engineering challenge.

What started as a rendering experiment turned into a pretty full-featured creative sandbox:

World building tools -- 20+ tools for cube, sphere, torus, arch, bridge, bezier curves, helix, stairs, terrain brushes, clone stamp, and more. All the stuff we wished Minecraft had built in.

In-game model editor -- Sub-voxel models at 8^3, 16^3, or 32^3 resolution with 32-color palettes and per-voxel emission. 175 built-in models (torches, fences, doors, glass panes, etc.) and a full editor for making your own with pencil, fill, mirror, undo/redo. This was the big one for us -- being able to design a model and place it without alt-tabbing.

Procedural texture generator -- Design custom block textures in-game with real-time pattern preview. No more exporting to an image editor and hoping the tiling works.

The world itself is procedurally generated with 17 biomes, 4 cave types, 9 tree species, water/lava simulation, and falling block physics. 47 block types with 608 painted variants (any of 19 textures in any of 32 color tints). Day/night cycle, shadow rays, ambient occlusion, animated clouds, stars, water, point lights with animation modes. Quality presets scale from potato to ultra depending on your hardware.

Multiplayer is still very work in progress but getting better. Encrypted UDP, up to 4 players, full world sync. The networking stack has been the hardest part to get right -- epoch-aware chunk dedup, LZ4 compression, handling the host running both server and client. It works but I wouldn't call it battle-tested yet.

Runs on Linux, macOS, and Windows. MIT licensed, fully open source.

Repo: https://github.com/paulrobello/voxel-world

Build from source: git clone https://github.com/paulrobello/voxel-world.git && cd voxel-world && make run

If you have any questions about the rendering pipeline, the sub-voxel model system, or the chunk streaming architecture I'm happy to dig into the details. This has been a wild project to work on and I've learned a ton building it.

reddit.com
u/probello — 14 hours ago
▲ 0 r/vulkan

I may sound dumb but is there anyway to add extensions on Mali GPUs?

So I've recently tired minecraft java with zalith launcher on android I tried the new snap shot put it on vulkan and restarted it crashed the reason was because I don't have 2 required extensions

reddit.com
u/Silly_Security6958 — 8 hours ago
▲ 9 r/vulkan

Anybody use Clion with Vulkan?

If so, why did you go with Clion over other IDEs? In what ways is it better for your personal use case?

reddit.com
u/qwtd — 2 days ago
▲ 8 r/vulkan

The preferred way to generate instance data?

I know mesh shaders can solve the problem, but I'm supporting older and mobile devices. As per vulkan spec, vkCmdDispatch can be done in render pass scope, but memory synchronization is effectively reduced to a memorybarrier. This pretty much meant one cannot easily do more fine grained synchronization. Is it preferable to use a separate pass for each draw, so that the dispatch and barrier is outside the render pass? I know you can generate all the data at the start, but when instance count goes up, the memory budget can mean prefering a ping pong of two scratch buffers.

reddit.com
u/shangjiaxuan — 2 days ago
🔥 Hot ▲ 151 r/vulkan+1 crossposts

Building an app from scratch in C & Vulkan with a node graph system ~

Been working on my fully custom C/Vulkan app, pretty excited with how it’s coming together! 

Rendering Bézier curves turned out to be an especially challenging thing…

The node system seems to come close to being functional with its auto collision resolution, smart connections re-routing on node(s) removal, box selection, several interaction states, and other things

The UI foundation is ready for what’s coming next as well...

One draw call for everything!

u/niksonder — 4 days ago
▲ 4 r/vulkan

Help with semaphore semantics in Vulkan Tutorial

Hi guys, I have recently started learning Vulkan and am having a bit of trouble with one specific thing in the tutorial.

In the drawFrame() function, I am trying to submit some info to the queue and am getting an error which I believe is due to storing pointers to temporary addresses when the buffers and semaphores are dereferenced and then have their addresses taken (using &*, which is kinda wacky).

This is how it's done in the example code in the tutorial, but it's not not working for me and I'm wondering if this is an issue possibly with something else in my code.

I am also curious as to why I can't just set the wait semaphore and signal semaphore pointers equal to the RAII semaphore pointers, my guess is cause the submitInfo is looking for a non-RAII version, but some insight into that would be helpful as well.

I'm new to C++ as well which definitely doesn't help haha, but I figured I'd just throw myself into the deep end and learn how to swim while drowning (very aware this is not the ideal way to do it but eh).

Thanks and let me know if you need any more info!

//sempahores and buffer initialization

vk::raii::CommandBuffer commandBuffer   = nullptr; 
vk::raii::Semaphore presentCompleteSemaphore = nullptr;
vk::raii::Semaphore renderFinishedSemaphore  = nullptr;

...

//Semaphores set

void createSyncObjects()
{
presentCompleteSemaphore = vk::raii::Semaphore(device, vk::SemaphoreCreateInfo());
renderFinishedSemaphore  = vk::raii::Semaphore(device, vk::SemaphoreCreateInfo());
}

...

//submitInfo creation

const vk::SubmitInfo   submitInfo{
.waitSemaphoreCount   = 1,
.pWaitSemaphores      = &*presentCompleteSemaphore,
.pWaitDstStageMask    = &waitDestinationStageMask,
.commandBufferCount   = 1,
.pCommandBuffers      = &*commandBuffer,
.signalSemaphoreCount = 1,
.pSignalSemaphores    = &*renderFinishedSemaphore
};

queue.submit(submitInfo, *drawFence);

The thrown exception:

Exception thrown at 0x00007FFE9D8BE346 (nvoglv64.dll) in 00_base_code.exe: 0xC0000005: Access violation writing location 0x0000000000000000.

reddit.com
u/Wingitalways — 2 days ago
🔥 Hot ▲ 121 r/vulkan+1 crossposts

Real Time Rendering Progress

This is my attempt to implement PBR with:

  • Diffuse_EON
  • GGX
  • Schlick's Fresnel Approximation:
  • IBL
  • GTAO

What do you guys think? Also, what should be my next step? I am planning to add TAA but I need long term plan

u/Important_Earth6615 — 5 days ago
▲ 6 r/vulkan

A question about SPIR-V

Is SPIR-V compilation output dependent on the hardware/graphics driver on which it’s compiled, and if not, can they be moved between PCs and run with no issue? I’m asking this because I’ve been trying to do runtime GLSL to SPIR-V compilation but I can’t get either glslang or libshaderc to work using the static runtime library (/MT and /MTd) in Visual Studio.

reddit.com
u/BackStreetButtLicker — 4 days ago
▲ 3 r/vulkan

Mesh geometry buffers

Hi there,

So i've been trying for a couple of days to get model loading going and the hard part is done, the asset manager produces a Vertex vector and an indices vector but what i can't wrap my head around is HOW should i structure the vulkan part?

Should i just create two buffers for each mesh, one for vertices one for indices?

I want to do simple rendering right now, no instancing, but with many objects of the same mesh or different meshes to build a scene.

reddit.com
u/codec-the-penguin — 3 days ago
▲ 27 r/vulkan

Proof-of-concept: cross-platform (polyglot) Vulkan binary

I could say that "static linking" of graphical apps has been a small obsession of mine for quite some time (https://szmer.info/post/6877785).

With the development of Cosmopolitan & some new workarounds needed to make Nvidia's driver's happy, I was finally able to make it work!

This is a small PoC of a single cross-platform binary that properly initializes & shows a Vulkan window. It's an .EXE that runs on Linux natively, without Wine - and talks with X11 / Wayland directly.

The days of shipping multiple binaries may soon be over!

github.com
u/mafikpl — 4 days ago
🔥 Hot ▲ 146 r/vulkan+2 crossposts

C++23 UI library with CSS-like styling, animations and custom render backend

u/neil_m007 — 7 days ago
▲ 1 r/vulkan+1 crossposts

Is vulkan bootstrap good?

So i just moved from openGL to Vulkan, but i seen so many code to write just for run triangle, so i searched a tools for easier vulkan and i found vk-bootstrap, is it good?

reddit.com
u/Plane_Unit9357 — 4 days ago
▲ 16 r/vulkan

Another way to render microfacet brdf!?

Hello.

Have been at this for the past few months. Looking to render microfacet brdf without the `brdf / pdf`.

It basically tries to separate how the material parameters interact with each other and with the incoming light based on the values of parameters.

e.g. for a metal, the base color is the tint of the specular reflection, for a dielectric it is the tint of the diffuse reflection.

Attached are screen shots first from a brute force implementation in vulkan + slang, followed by a render of the same scene in Blender. Because it is brute force, only mesh emitters are used here.

I have attempted to explain my thought process on these pages.

https://github.com/nihalkenkre/nihalkenkre.github.io/tree/master/pbr_without_brdf_pdf

https://nihalkenkre.github.io/pbr_without_brdf_pdf/ - tables and mermaid diagram show up as text :(

Brute Force implementation - https://github.com/nihalkenkre/chizen-rs

Direct Light Sampling + Indirect Light - https://github.com/nihalkenkre/satori

Would love your feedback / suggestions / improvements on everything from the algorithm, to the layout of the blog.

Cheers.

u/amadlover — 4 days ago
▲ 3 r/vulkan

Beginner: need help on device-specific extension function pointers

I couldn't find a dedicated Vulkan help subreddit, so I'm hoping that this is good enough.

So I'm new to Vulkan, and I've tried to make a Vulkan program using an online tutorial. It was going well so far, until I had to create a swapchain. I am for some reason unable to get the function pointer for vkCreateSwapchainKHR.

For context, I'm using GLFW for window creation. I have it configured so that it makes Vulkan calls directly through the program instead of having the Vulkan library load at runtime. Because of this, I have to load Vulkan extension functions manually.

For a previous section of the code, I had configured the Vulkan instance to load VK_KHR_surface, VK_KHR_xcb_surface and VK_EXT_debug_report. The first two extensions were used by GLFW to create a window surface (glfwCreateWindowSurface), the third extension I used to get Vulkan error messages. The Vulkan header provides extension-specific functions like vkCreateDebugReportCallbackEXT but actually using them gives undefined reference errors on the linking stage. Loading the function pointers using vkGetInstanceProcAddr gets them working (they do not return NULL).

My problem is with vkCreateSwapchainKHR. I have the device configured to load VK_KHR_swapchain and it does so without error. Listing the available extensions shows it in the list. Calling the function directly from the Vulkan header doesn't cause any linking errors, but upon running the program some embedded Vulkan loader tells me that the function pointer is NULL and promptly aborts the program. Manually retrieving the function pointer myself with vkGetDeviceProcAddr returns a NULL pointer. I don't see what I'm doing wrong here, so in the end I'm making this post to see if anyone has the answer.

Here are some code snippets:

/* Retrieves device extension information */
vkEnumerateDeviceExtensionProperties(
    p_vk_device_physical,
    NULL,
    &p_vk_device_physical_extensions_count,
    NULL
);
p_vk_device_physical_extensions_data = malloc(sizeof(VkExtensionProperties[p_vk_device_physical_extensions_count]));
vkEnumerateDeviceExtensionProperties(
    p_vk_device_physical,
    NULL,
    &p_vk_device_physical_extensions_count,
    p_vk_device_physical_extensions_data
);
for (iter01 = 0; iter01 < p_vk_device_physical_extensions_count; iter01++) {
    if (strcmp(p_vk_device_physical_extensions_data[iter01].extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) {
        p_vk_device_physical_extensions_found_swapchain = 1;
    }
}
if (!p_vk_device_physical_extensions_found_swapchain) {
    fprintf(stderr, "ERROR: Vulkan device extension \"%s\" not present.\n", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
    return 0x2140;
}



/* Global constants for initializing device extensions */
const uint8_t p_c_vk_device_extensions_enabled_count = 1;
const char* const p_c_vk_device_extensions_enabled[] = {
    VK_KHR_SWAPCHAIN_EXTENSION_NAME
};



/* Function for initializing the logical device create info */
void p_init_vk_device_logical() {
    /* Present Queue Creation Info */
    p_vk_device_physical_present_queue_createinfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
    p_vk_device_physical_present_queue_createinfo.queueFamilyIndex = p_vk_device_physical_present_queue_index;
    p_vk_device_physical_present_queue_createinfo.queueCount = 1;
    p_vk_device_physical_present_queue_createinfo.pQueuePriorities = &p_vk_device_physical_present_queue_priorities;

    /* Logical Device Creation Info */
    p_vk_device_logical_createinfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
    p_vk_device_logical_createinfo.queueCreateInfoCount = 1;
    p_vk_device_logical_createinfo.pQueueCreateInfos = &p_vk_device_physical_present_queue_createinfo;
    p_vk_device_logical_createinfo.enabledLayerCount = p_c_vk_layers_enabled_count;
    p_vk_device_logical_createinfo.ppEnabledLayerNames = p_c_vk_layers_enabled;
    p_vk_device_logical_createinfo.enabledExtensionCount = p_c_vk_device_extensions_enabled_count;
    p_vk_device_logical_createinfo.ppEnabledExtensionNames = p_c_vk_device_extensions_enabled;
    p_vk_device_logical_createinfo.pEnabledFeatures = &p_vk_device_physical_features;
}



/* Creates a Vulkan logical device */
p_vk_device_logical_createsuccess = vkCreateDevice(
    p_vk_device_physical,
    &p_vk_device_logical_createinfo,
    NULL,
    &p_vk_device_logical
); /* VK_KHR_swapchain exists on system, no error returned */
if (p_vk_device_logical_createsuccess != VK_SUCCESS) {
    fputs("ERROR: Unable to create Vulkan logical device.\n", stderr);
    return 0x2100;
}



/* Function for initializing VK_KHR_swapchain extension specific functions */
void p_init_vk_extension_swapchain() {
    lvkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)vkGetDeviceProcAddr(
        p_vk_device_logical,
        "vkCreateSwapchainKHR"
    ); /* Always returns NULL */
    if (lvkCreateSwapchainKHR == NULL) puts("egg"); /* Always outputs "egg" */
}



/* Tries to create a swapchain with the manually loaded function */
p_vk_surface_main_createsuccess = lvkCreateSwapchainKHR(
    p_vk_device_logical,
    &p_vk_surface_main_swapchain_createinfo,
    NULL,
    &p_vk_surface_main_swapchain
); /* Calling of NULL pointer, always triggers a segmentation fault */
if (p_vk_surface_main_swapchain_createsuccess != VK_SUCCESS) {
    fputs("ERROR: Unable to create swapchain for Vulkan surface.\n", stderr);
    return 0x2200;
}
reddit.com
u/twoseveneight — 5 days ago
▲ 11 r/vulkan+1 crossposts

Attempted recreation of Divinity: Original Sin 2 fire surfaces

Just wanted to share my attempted recreation of D:OS2 Fire Surfaces.

I use topdown grid to track which areas are affected, and then during rendering I sample the value of grid and apply some noise. Additionally there is billboard rendering, and bloom post processing.

https://reddit.com/link/1simtcu/video/fefrsuvt2lug1/player

reddit.com
u/IL799 — 4 days ago
▲ 15 r/vulkan

Task and mesh shaders for voxel graphics, is it worth it?

I’m making a voxel game engine and I’m wondering if such a solution wouldn’t be not only simpler to implement but also faster during runtime.

reddit.com
u/Green_223 — 7 days ago
▲ 0 r/vulkan

My GPU supports vulkan but anything that uses vulkan doesnt work

My gpu is the GeForce RTX 4070 SUPER and i frequently install new drivers but anything that uses vulkan crashes before the main window even opens
Im on windows 11

reddit.com
u/IKEA_Cone — 8 days ago