r/GraphicsProgramming • • Mar 14 '26

Source Code I finally built a Vulkan renderer

Post image
177 Upvotes

I don’t even remember anymore when I started learning computer graphics (probably around 2020-2021). Lost count of how many times I’ve tried, always feeling overwhelmed and like I don’t know a thing.

Here’s what I did this time:

I copied and pasted the full completed code from the Vulkan website, made sure it runs and shows the .obj.

After that I started adding abstraction layers to it. It sounds counterintuitive/counter productive, but every time I divided a chunk of code, structured how it made sense to me and gave it a name, it helped me understand how it works and to create a mental map.

At some point I got the same example but using my abstractions. Every time I wanted to add something I had “this feeling” of where the pieces were. It became a game of adding/modifying blocks.

I kept going and now I have this thing that does deferred rendering, a basic PBR, tone mapping, IBL and (my favorite part) multi-pass rendering.

Compared to what I’ve seen people post in this subreddit, I know this isn’t much. But I just feel good to finally have something that works and that I feel I can eventually plug it into a game engine. Also, I think that maybe this way of learning may benefit someone (idk).

Here’s the git repo: https://github.com/MerliMejia/Abstracto

Feedback is more than welcome and appreciated.


r/GraphicsProgramming • • Feb 23 '26

My Black Hole Shader (Python/OpenGL) - Second Update

177 Upvotes

Posted earlier about my Black Hole Shader

Made some improvement to the gravitational-lensing, reduced shimmering from aliasing and introduced spiral gas.

Edit: i made some further improvements


r/GraphicsProgramming • • Jan 02 '26

3D rendering in the terminal from scratch

177 Upvotes

I discovered this wonderful explanation by tsoding on a simple maths formulae for 3D rendering.

I figured why not try it out in the terminal too, made from scratch :)

Edit: here's the repo


r/GraphicsProgramming • • Dec 26 '24

I've made an open-source path tracer using WebGPU API: github.com/lisyarus/webgpu-raytracer

Post image
177 Upvotes

r/GraphicsProgramming • • Nov 23 '24

Video I made a Model, View, and Projection (MVP) transformation matrix visualizer with raylib

177 Upvotes

r/GraphicsProgramming • • Jun 04 '21

"Captain Harlock's maiden voyage" - Procedural GLSL shader live coded on Twitch

177 Upvotes

r/GraphicsProgramming • • Mar 27 '21

Video After 6 months, with a lot of help from this community, I'm finally about ready to release my volumetric sky and clouds asset for Unity!

177 Upvotes

r/GraphicsProgramming • • Jul 18 '26

Video Free SDF raymarcher for Godot 4 metaballs that blend colors, in one shader (CC0 + MIT)

176 Upvotes

Signed distance field raymarching in Godot 4, authored with nodes. Physics-driven metaballs melt into the SDF cubes in one fullscreen pass, and since every CSG op works on (color, distance) pairs, the colors blend along with the shapes.

Two free editions: Standalone shader (CC0): one .gdshader, no scripts paste onto a QuadMesh, edit map(). Godot Shaders

Node-based project (MIT): shapes as Node3D nodes, live editor preview, physics, up to 32 primitives and a write-up. VavLabs Mit

Distance functions after Inigo Quilez.


r/GraphicsProgramming • • Oct 19 '25

Article ReGIR - An advanced implementation for many-lights offline rendering

Post image
176 Upvotes

https://tomclabault.github.io/blog/2025/regir/

The illustration of this reddit post is a 1SPP comparison of power sampling on the left and the ReGIR implementation I came up with (which does not use any sort of temporal reuse, this is raw 1SPP).

I spent a few months experimenting with ReGIR, trying to improve it over the base article published in 2021. I ended up with something very decent (and which still has a lot of potential!) which mixes mainly ReGIR, Disney's cache points and NEE++ and is able to outperform the 2018 ATS light hierarchy by quite a lot.

Let me know what you think of the post, any mistakes, typos, anything missing, any missing data that you would have liked to see, ...

Enjoy : )


r/GraphicsProgramming • • Jan 18 '25

Video Light delay, length contraction, & doppler shifting in my special relativistic game engine prototype

176 Upvotes

More info in the comments.


r/GraphicsProgramming • • 9d ago

Rendering & Physics using TinyBVH

175 Upvotes

Our students are working on Metal Gear Solid (PS1) for their Y1 C++ project at Breda University. I wanted to join in on the fun so here's the Cargo Dock level, ray traced using TinyBVH, using just the CPU. In this demo TinyBVH is also used to detect collisions (there's scene/sphere collision functionality) and to handle them. The spheres end up in their own BLAS, which is combined with the level triangles under a TLAS. Code is 600 lines, all-in.


r/GraphicsProgramming • • Jun 26 '26

Question Feel like it's impossible to learn graphics programming, need help

Post image
175 Upvotes

Yesterday I finished the third episode of Victor Gordan's OpenGL tutorial, and made my first triangle. I also learned how to modify it (like changing vertex positions, color, etc).

But when I look at the code I wrote, it feels impossible to remember like I could write any of this without looking at the tutorial. When I was learning C++, mostly everything instantly stuck with me, but graphics programming seems like I'll never memorize 80% of it

How did you guys get decent at this and actually retain the knowledge and be able to write it independently? Or am I judging too early? I started 3 days ago


r/GraphicsProgramming • • Jun 08 '26

webGL path tracer

Thumbnail
gallery
174 Upvotes

This is officially my first post here and I'm pretty proud of it. This took me the better part of a week to finish, and I've been extending it bit by bit for the past 6 months. I used the monte carlo method for sampling (maximum 8 bounces per ray), and the stills shown here are after 15000 SPP, although half of that would've been fine for a good result.

I only have primitives in my scenes, but I'm really happy with how it turned out. I plan to keep building on it and try to get rid of the visible fireflies, but I'm mostly satisfied with where its at right now. Any suggestions/tips are welcome!

I'm in my final year of uni and I'm always awed coming onto this sub and seeing the cool things people are working on, detailed landscapes, realistic clouds etc. I hope to reach that level some day.

(implemented in WebGL + HTML/JS, using twgl). I can't publicly post the code as this was submitted for grades.


r/GraphicsProgramming • • Apr 11 '26

Attempt at SSR

Thumbnail
gallery
174 Upvotes

Roughness-scaled normal jitter + blue-noise ray variance + smoothed normals + bump mapping + step dithering (breaks staircase) → temporal accumulation for single-sample stochastic denoising.

https://github.com/umar-afzaal/LumeniteFX

https://discord.gg/deXJrW2dx6


r/GraphicsProgramming • • Aug 19 '26

Video I implemented "Spherical Harmonic Exponentials for Efficient Glossy Reflections" in D3D12

173 Upvotes

I implemented Activision's new SH reflections paper in D3D12 and released the code on github!

This tech is a little bit different from normal spherical harmonics, and there are 4 main differences:

  1. They use log space instead of linear space for the lighting, which reduces ringing and enables #2 and #3 to actually work.

  2. Instead of using a circular symmetry assumption (i.e. N=V=R) as with the split sum approximation used for IBL, they instead factorise a pair of spherical harmonics, with an Order 4 SH parameterised by the reflection vector, and an Order 2 SH parameterised by the halfway vector.

  3. To enable a continuous roughness representation, they convolve the coefficients (or rather, the basis function) by the von Mises Fisher kernel which takes 1/alpha=1/roughness^2 as a parameter.

  4. To actually obtain the spherical harmonic coefficients we have to collect samples for several normals, views and roughness levels (or more specifically alpha levels since we're using linear roughness, not perceptual), and then optimise the coefficients using least squares.

My code does this all end to end with HLSL compute shaders, even the least squares optimisation, and we achieve above 95% MSE compared to a raytraced ground truth for roughness in the range [0.5, 1.0], which actually beats split sum IBL.

Only downside is for roughness below 0.5 the spherical harmonics simply don't have enough detail for accurate reflections... HOWEVER, when applied to "bumpy" low roughness surfaces (like the leaf textures at the beginning of the video) you can hardly see a difference, so this effect is only apparent for flat surfaces and surfaces with near zero roughness.

Activision got their SH representation down to 400 bytes, but I went further using 16 bit packing to get down to 208 bytes which gives us better performance due to fewer memory loads. The 16 bit implementations come in 4 flavors: emulated 16 bit for older GPUs and native 16 bit, and SRV packed vs CBV packed. There also exists a 10 bit packed SRV flavor, but the extra bitshift work ends up being slower.

On my RTX 2080 Super and my wife's RTX 4070 Super, the native 16 bit CBV packed shader runs the fastest, and compared to the IBL version it is only 0.1 milliseconds slower while using 2000x less memory!


r/GraphicsProgramming • • Dec 03 '20

Article A common mistake in graphics programming is doing computations with sRGB colors. Why is that wrong and what are the consequences? I made a blog post to cover that and the basics of color science.

Thumbnail
bottosson.github.io
173 Upvotes

r/GraphicsProgramming • • Mar 13 '26

Video I built a wallpaper that shifts perspective when you move your head looking for feedback

172 Upvotes

r/GraphicsProgramming • • Oct 27 '25

Custom 2D Particle System

172 Upvotes

Hello, I made a small GPU-based particle system in Unity using compute shaders. You can download source and/or executable from github:

https://github.com/jastrz/custom-particle-system


r/GraphicsProgramming • • Jan 14 '25

WebGPU Sponza

172 Upvotes

r/GraphicsProgramming • • Sep 08 '26

Raytracing in one weekend completed [added OpenMP multhread]

Post image
171 Upvotes

Completed in slightly more than a weekend (sickness et al). The final render task of width 1200 and samples per pixel 500(!) seemed impossible, so added a multithreaded workaround with OpenMP which finished it in around 35 minutes on my MBP M1 Pro and the penultimate DOF spheres under 10 seconds.

Changes:

#include <atomic>
#include <omp.h>
#include <vector>

void render(const hittable& world) {

#pragma omp parallel
        {
#pragma omp single
            std::clog << "OpenMP threads: " << omp_get_num_threads() << '\n';
        }
        initialize();

        std::vector<color> framebuffer(image_width * image_height);

        std::clog << "Rendering..." << std::endl;
        std::atomic<int> rows_completed{0};

#pragma omp parallel for schedule(dynamic)
        for (int j = 0; j < image_height; j++) {
            for (int i = 0; i < image_width; i++) {

                color pixel_color(0, 0, 0);

                for (int sample = 0; sample < samples_per_pixel; sample++) {
                    ray r = get_ray(i, j);
                    pixel_color += ray_color(r, max_depth, world);
                }

                framebuffer[j * image_width + i] = pixel_samples_scale * pixel_color;
            }

            int completed = rows_completed.fetch_add(1) + 1;

            if (completed % 8 == 0 || completed == image_height) {
#pragma omp critical(render_progress)
                {
                    std::clog << "\rScanlines remaining: " << (image_height - completed) << ' '
                              << std::flush;
                }
            }
        }

        std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";

        for (int j = 0; j < image_height; j++) {
            for (int i = 0; i < image_width; i++) {
                write_color(std::cout, framebuffer[j * image_width + i]);
            }
        }

        std::clog << "Done.\n";
    }

and

inline double random_double() {
    thread_local std::mt19937 generator(std::random_device{}());

    return std::uniform_real_distribution<double>(0.0, 1.0)(generator);
}

r/GraphicsProgramming • • Jun 04 '26

I created a voxel raymarcher which runs in browser (link + source code)

171 Upvotes

The link to run it is here and and the source code is available here. If you are considering writing a voxel raymarcher yourself, maybe give the source code a look as it is heavily commented and I think pretty approachable. The raymarcher is written in WebGPU's shader language and the UI is a simple html/css/js page overlayed on top of it. If you have any questions let me know!


r/GraphicsProgramming • • Jan 29 '26

High-Quality BVHs with PreSplitting optimization

Post image
171 Upvotes

I did a writeup on BVH PreSplitting optimization. An unknown but very powerful technique that splits "problematic" triangles before the BVH build. It can achieve very similar quality to that of SBVH which is regarded as the best builder of them all. If you already have a solid BVH (like BinnedSAH/SweepSAH/PLOC) and want to improve perf some more this should be interesting. It's suprisingly simple to implement


r/GraphicsProgramming • • Feb 04 '25

Why is graphics so fragmented?

171 Upvotes

We have so many APIs: Vulkan, Metal, DirectX, OpenGL, WebGL, OpenGL ES (dying), and WebGPU.

It's feels like a very stretched field between AAA studios, indie devs, and browsers. Apple straight up doesn't care. They deprecated OpenGL in 2018 and are pushing Metal.

Will there ever be a push to unify these APIs?


r/GraphicsProgramming • • Jul 27 '21

Voxel-grids-on-an-LBVH raytracing. GTX 1050Ti at 1080p. Vulkan multi-threaded rendering.

171 Upvotes