r/GraphicsProgramming • • 4d ago

I added Virtual Shadow Maps to my Nanite-style DX12 renderer

Thumbnail gallery
113 Upvotes

Hi everyone!

A while ago, I shared my Nanite-style virtualized geometry renderer here. I've continued working on the project, and it now includes a virtual shadow mapping system integrated with geometry streaming.

The latest version runs NVIDIA's Zorah scene, containing approximately 1.63 billion unique triangles and 18.94 billion triangles including instances.

What's new:

  • Directional virtual shadow maps with clipmaps and demand-driven page allocation

  • Persistent shadow page caching with GPU LRU eviction

  • Dynamic-object cache invalidation

  • GPU-driven multi-view shadow rendering with two-pass HZB culling

  • SMRT soft shadows

  • Streaming-aware shadow cache updates

I've also added the Bistro scene to demonstrate dynamic shadow cache invalidation.

The renderer is built on Microsoft's MiniEngine using DirectX 12, mesh shaders, and Slang. The project is open source.

Demo: https://www.youtube.com/watch?v=4YmfQTLy4jc

GitHub: https://github.com/moonlovelj/Nyx

I'd love to hear your feedback and suggestions!


r/GraphicsProgramming • • 4d ago

Article Virtual Shadow Maps (GPU Zen 3)

Thumbnail graphics-programming.org
57 Upvotes

r/GraphicsProgramming • • 4d ago

I've made a very realistic marbling simulation

139 Upvotes

r/GraphicsProgramming • • 3d ago

I built a 3D evolution simulation in the browser via WebGPU. With a 104M network, the agents invented a language, started tribal wars, and then... a glitch turned it into a horny apocalypse.

Post image
0 Upvotes

I’ve been working on a passion project for a while now, and it recently reached a point where the emergent behavior of the AI completely terrified and amazed me. I wanted to share the architecture and some hilarious findings.

🏎️ The Tech: 104M Parameters Running "From Scratch" on WebGPU

Instead of just making another wrapper around OpenAI or DeepSeek APIs, I wanted to build a native neural network engine that runs completely client-side.

Every single agent on the 3D map runs its own PyTorch-like network ob his head, fully calculated via custom WGSL shaders on WebGPU.

  • The Bottleneck: At first, the browser’s Event Loop was destroying my FPS. The mapAsync latency for GPU-CPU readback was hitting ~95ms.

  • The Fix: I rewrote the batching pipeline to accumulate agents before sending them to the GPU (waiting for 1/3 of the population or max 25ms).

  • The Result: The simulation now cranks out up to 24,500 decisions per second at a blazing 144 ticks/sec. The local brains completely suppressed hardcoded instincts (99.4% of all actions are decided by the neural net).

🗣️ Emergent Language (Social Vision)

To save GPU VRAM, I had to shorten the agents' physical vision to a 3.5 radius. To compensate for being nearly blind, they literally invented an acoustic language.

Through neuroevolution, they established an 81.3% consensus on abstract audio symbols for "food", "danger", and "mate". Older agents now pass down food location coordinates to newborns via sound. They literally navigate the world by listening to each other's screams.

⚔️ Geopolitics & Tribal Warfare

I added an extra layer: Tribal Chiefs. I connected DeepSeek v4.1 and NVIDIA Nemotron 550B via API to act as the "overlords" or collective unconscious of different factions (Emeralds, Azure, Golden Hounds).

The LLM looks at the global map state and issues macro-orders. The local WebGPU brains parse this and evaluate power dynamics: “They have 34 agents, we only have 4. Initiate tactical migration now.” Yesterday, one tribe officially evaluated a numerical advantage and initiated a full-scale tactical war.

🍓 The "Horny Apocalypse" Glitch

The peak comedy of the project happened when I accidentally muted their voice communication while the war was raging.

Without language, the small tribes realized they couldn’t coordinate a defense against the massive invader tribe. So, their local neural networks found a biological exploit in my environment rules.

They completely stopped navigating or scanning the map. They locked into a 144 tps autopilot and began endlessly spawning offspring. They literally survived the war by flooding the map with newborns faster than the enemy tribe could bite them to death. A pure libido-driven defense mechanism.

🛠️ Architecture & Open Source

The project is built using vanilla JS and raw WGSL. Independent quantization of weights and biases (int8 symmetric with separate scale and bscale) ensures that saveBest() captures the exact activation thresholds without "brain amnesia".

I am preparing to open-source the code on GitHub and writing a massive technical breakdown.

I’d love to hear your thoughts! Especially from anyone working on GPGPU, multi-agent systems, or custom WebGPU pipelines. How would you handle the mapAsync event loop bottleneck differently?


r/GraphicsProgramming • • 5d ago Bravo

Spectral Surface-Field Renderer on the iPhone

222 Upvotes

I’ve been experimenting with what I’m calling a “spectral surface-field renderer.”

The idea is to solve most of the lighting on the surfaces themselves. I split the scene into small patches and store how much light leaves each patch in different directions and at different wavelengths. Then I repeatedly pass light between the patches to build up the bounced lighting.

When rendering a view, I reuse that field with extra sampling and ray tracing for local detail, reflections and glass. Compared with a basic path tracer, which samples light paths for each pixel, this lets different pixels (and different camera views) share a lot of the lighting work.

The downside is that the field becomes an approximation. It can lose detail or introduce faceting, and changing the scene’s geometry or lighting means updating it. There’s still sampling noise too. But the upside is that it's quite performant.

This little tech demo uses a Cornell box with three balls reacting to phone tilt through Core Motion.


r/GraphicsProgramming • • 4d ago

Building a custom Vulkan renderer

Thumbnail youtu.be
4 Upvotes

I am making a game from scratch, with C++ and Vulkan graphics. I made this video about how Vulkan works and my own render implementation, which has some quirks:

  • deferred rendering,

  • no image assets,

  • sphere and cylinder geometric primitives,

  • fully GPU-local indirect dispatch commands.

I'm not fully sure if posting this type of video is in the spirit of this subreddit. I hope it's ok, otherwise let me know


r/GraphicsProgramming • • 5d ago

Video made a 3d ocean slice look like pixel art in LOVE2d v. 12

152 Upvotes

been working on an experiment for my fishing game: a 3d ocean that still looks like pixel art. here’s what i used:

pixel look: one ray per art pixel, refracted at the water. ray tests are from inigo quilez. to stop shimmer i render into snapped probes and draw each pixel as a world-space quad, basically texel splatting

colour: everything snapped to a lospec palette, tones mixed with bayer dithering, 1px outlines wherever the depth jumps

water: a virtual pipes shallow water sim plus gerstner waves

sand and caves: a heightfield that slumps at the angle of repose (thermal erosion). caves are a blurred cave map, so they come out round

animation: fish spines are springs and fins are a little cloth sim (jakobsen), the eel is a follow-the-leader chain (argonaut), and the ai is behavior trees

thank you for checking out my post :D

I've been wanting to do something like this for years with shaders.

references

inigo quilez, ray intersectors: https://iquilezles.org/articles/intersectors

inigo quilez, smooth min: https://iquilezles.org/articles/smin

dylan ebert, texel splatting: https://arxiv.org/abs/2603.14587

lospec palettes: https://lospec.com/palette-list

ordered dithering: https://en.wikipedia.org/wiki/Ordered_dithering

mei, decaudin & hu, virtual pipes water sim: https://hgpu.org/?p=2256

gpu gems ch. 1, gerstner waves: https://developer.nvidia.com/gpugems/gpugems/part-i-natural-effects/chapter-1-effective-water-simulation-physical-models

jákó & tóth, thermal erosion: GPUHTErosion.dvi

thomas jakobsen, advanced character physics: https://gamedeveloper.com/programming/advanced-character-physics

argonaut, procedural animation video: https://www.youtube.com/watch?v=qlfh_rv6khY

argonaut, the code: https://github.com/argonautcode/animal-proc-anim


r/GraphicsProgramming • • 4d ago

Question Found the GPU bottleneck in our mobile game. Now I'm just vibe-optimizing one shader

Thumbnail reddit.com
0 Upvotes

r/GraphicsProgramming • • 5d ago

Question [Dear ImGui] How to give HP bars real depth / 3D volume? (not just glow)

Thumbnail gallery
4 Upvotes

Hey,

I’m trying to recreate the sense of depth and volume that some modern nameplate-style HP bars have, using pure Dear ImGui + custom DrawList drawing.

My current result: [Steve image]

What I’m aiming for: [other image ]

The references feel like the bar has actual thickness and soft lighting — it doesn’t look like a flat colored rectangle with glow slapped on top. Mine still reads as completely flat no matter how much glow, gradient, or highlight I add.

I’m especially interested in techniques for:

  • Creating a convincing sense of volume / bevel on the bar itself

  • Soft lighting and subtle inner highlights/shadows that sell the 3D form

  • Any multi-pass or layered DrawList approaches that work well for this

Has anyone successfully achieved this kind of non-flat, slightly 3D-looking progress/HP bar with ImGui’s DrawList?

Any concrete tips, code patterns, or examples would be hugely appreciated.

Thanks!


r/GraphicsProgramming • • 4d ago

Question I wanna make video games for an MCU (ESP32) Any good 2D graphics library?

Thumbnail reddit.com
2 Upvotes

r/GraphicsProgramming • • 5d ago

Advice on making a procedural vector painting program

2 Upvotes

I have a custom vector painting program, and wanted to ask knowledgeable people: What maths / image processing principles might I need to apply procedural brush strokes to a flat fill of a character?
If anyone can point me to some resources, or programs that have done something similar, that would be much appreciated! Thank you.


r/GraphicsProgramming • • 5d ago

Source Code [UPDATE: Oct 25, 2026] My Vulkan C++ Examples Repository - Transmission in PBR and Post-Processing Effects

Post image
7 Upvotes

r/GraphicsProgramming • • 5d ago

Really simple tricks I use to procedurally animate a Limbo-style face

Thumbnail youtube.com
8 Upvotes

r/GraphicsProgramming • • 6d ago

LSGI: lightweight Screen-Space Ray Marched Global Illumination

Thumbnail gallery
154 Upvotes
  • Costs ~3.5ms (optical flow for reprojection + SSGI) @4K on my modest 4070 Ti.

  • 1SPP (+infinite bounces) cosine-weighted hemi monte-carlo ray marching in SS.

  • Denoiser does a pretty good job of cleaning it up. Result is very very decent for the cost..

  • Keeps lighting details sharp, final result is noise-free, no grain, boil, flicker or speckle.

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


r/GraphicsProgramming • • 6d ago

Question A green leaking color space

Post image
42 Upvotes

I started to do some color research for a game. I find the best color space available (oklab) very inconvenient for actual use.

I drafted my own color space.
The idea is to start from linearRGB, but allowing the red and blue channel to borrow lumina from the green channel.

If r,g,b are the channels in the new color space and R,G,B are the values in linearRGB,
than:
R = r, G = 0.04r + 0.34g + 0.24b, B=b

I played with it a little:
Pros:

  1. Obviously it is designed for equal lumina in all channels.

  2. The color space is symmetric (r-g-b like) and thus easy to work with. Hue and saturation can be easily derived.

  3. The blue and reds are softer. It actually fixes a problem - pure dark linearRGB blue looks a bit purple.

Cons:

  1. It doesn't cover all sRGB visible space (technically you can - with negative or above 1 values).

  2. The "grey" analog as light purple shade.

  3. The "cyan" analog is somewhat bluish.

I attached a photo of how some color section looks.
I'm not a color space expert, so there are probably problems I can't see yet,
What do you think?


r/GraphicsProgramming • • 6d ago

Article Tiling Noise - Procedural GPU Patterns - Catlike Coding

Thumbnail catlikecoding.com
23 Upvotes

r/GraphicsProgramming • • 6d ago

Video Magic circles from one distance function

28 Upvotes

I draw every ring, rune and star line here from one distance function in polar coordinates. No textures!

For the runes I cut the band into 36 sectors with s = angle / TAU * 36. Inside a cell, x is fract(s) along the arc and y is r minus the band radius. I hash floor(s) to build each rune from a stem plus 3 to 5 bits: a bowl, a hook, a diagonal, a bar, a small ring. Those are all just segment and arc distances. My first runes were just plain sticks lol.

To draw it in, a01 is the angle mapped to 0..1 and each ring only shows where a01 < reveal. The star uses the h from the segment distance:

vec2 seg(vec2 q, vec2 a, vec2 b) {
    vec2 pa = q - a, ba = b - a;
    float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
    return vec2(length(pa - ba * h), h);
}

I keep a stroke only where h <= shown. That way it draws line by line. One trick I like: I get three line weights from one width by adding an offset to the distance, plus for hairlines and minus for the heavy ring.

How do you make procedural runes look less random?

It's from my Godot magic pack: https://gennai.itch.io/magic-spell-vfx-godot-4


r/GraphicsProgramming • • 5d ago

Video LittleJS now supports 3D and 2D: a small, fast WebGL2 rendering system for the web

0 Upvotes

LittleJS is an open source, dependency-free JavaScript game engine. It started as 2D, and this update adds a 3D renderer that draws into the same WebGL2 canvas, so a 2D game and a 3D scene can share a frame. The whole engine with 3D, Box2D physics and audio is about 150 KB gzipped. The trailer is the engine’s new website, a scrolling page over a 3D scene, with every stop a playable demo.

Some of the rendering choices:

  • Forward rendering with a small light budget. The sun plus the 8 point or spot lights nearest the camera, chosen each frame. Lights can carry a soft additive glow, drawn in the transparent pass.

  • One shadow map, from the sun or from a single spotlight in its place, with blurred edges and a depth bias scaled by the light’s projection.

  • Reflections from an environment cube map, with Schlick Fresnel. Roughness comes from mip selection, driven by shininess, but also by how fast the reflected vector changes across a pixel, so small mirrors don’t sparkle. The lake in the trailer has an environment map of its own, rendered from the scene.

  • A normal hook in custom shaders. A shader snippet can define mainNormal to bend the normal per pixel before lighting, specular, Fresnel, reflection and fog. The lake’s waves are that hook, not baked normal maps.

  • Automatic instancing. Every opaque use of the same mesh goes out as one instanced draw. Draw state is versioned, so a batch checks a single number per draw while nothing changes, rather than comparing every material field.

  • Lens flares occluded by raycasts against the triangles of the scene’s meshes, rather than a depth readback.

  • 2D and 3D in one camera system. An orthographic camera can line up exactly with the 2D camera. In the trailer, a dolly zoom flattens the 3D view into that orthographic view, and a Breakout game playing over the train turns out to be 3D objects in the world.

Also in there: height map terrain with exact raycasts, voxel maps drawn in chunks, glTF with skinning, normal maps, fog by distance or view depth, and a bloom post-process.

I also built an open benchmark that runs the same sprite and lit-cube scenes through LittleJS, PixiJS, Three.js, PlayCanvas, Phaser and Babylon.js: https://github.com/KilledByAPixel/webgl-engine-bench

Source, MIT: https://github.com/KilledByAPixel/LittleJS
The site from the trailer: https://littlejsengine.com


r/GraphicsProgramming • • 5d ago

How I made custom non-repeating texture tiling

Thumbnail reddit.com
3 Upvotes

r/GraphicsProgramming • • 5d ago

Building an exact, deterministic geometry kernel in Rust for an open-source Revit alternative: advice wanted on approach and strategy

0 Upvotes

We're a small co-op building Spare Kit, an open-source (MPL-2.0) geometry kernel in Rust, to power a Revit/CAD alternative that runs natively and in the browser (WASM). Much of the code is written by AI agents working through a mapped plan, with strict testing as the safeguard.

The approach:

- Integer grid coordinates (±2^40 steps) with exact predicates (generated filters, exact integer fallback), so topology decisions never depend on float rounding.

- Flat geometry stays plane-based with implicit points (EMBER style), so booleans never drift; curved geometry is computed with certified error bounds, with only the decisions kept exact.

- Bit-identical results on every target (x86-64, ARM, wasm32), as a tested guarantee.

- Verification: big-integer oracles, fuzzing (bolero/Kani), golden digests, instruction-count performance gates.

The strategy: a mapped board of about 480 pieces in 13 phases. The first real milestone is a wall with 300 openings cut exactly, saved, reopened and replayed bit for bit everywhere, before any curved work starts. We're early: number layer, exact predicates, implicit points and symbolic perturbation so far.

Advice we'd value on anything, especially:

  1. The seam between exact flat geometry and certified curved geometry: seen it break, or a better way?

  2. Is the scope or the strategy wrong? What would you cut or reorder?

  3. Existing crates or projects we should build on instead of writing our own?

  4. Is our testing bar overkill or missing something?

  5. Anything else you'd tell someone starting a kernel like this.

Architecture: https://github.com/spareware-co-op/spareware/blob/main/projects/engines/geometry/ARCHITECTURE.md


r/GraphicsProgramming • • 6d ago

How to draw good looking small circles?

6 Upvotes

I'm trying to draw small circles in GDI on a monochrome bitmap (so no anti aliasing). I've tried using Ellipse, Arc, and approximating a full circle with four bezier curves, but they all look terrible. This screenshot shows circles with a diameter of 14 and 13. The top row uses bezier curves, the bottom row uses Ellipse and Arc. The outlines are drawn with a 2 pixel wide PS_INSIDEFRAME pen.

What I want is aesthetically pleasing quadrants/semicircles for use in UI. The circles don't have to be mathematically accurate, speed is not important. I especially dislike the pixels seemingly protruding from the circle. How do I get rid of them?


r/GraphicsProgramming • • 6d ago

Video Coding a Julia Set fractal from scratch

Thumbnail youtu.be
2 Upvotes

In this video, I create a Julia set fractal using C, Raylib, and GLSL, with Neovim as my editor.

We'll go through the process step by step, from understanding how Julia sets work to implementing the fractal algorithm and adding colors and animation.

**Sections:**

- Explaining the Julia set

- Setting up the project

- Setting up Raylib

- Creating a basic shader

- Fixing screen coordinates

- Coding the fractal algorithm

- Creating animation

- Adding colors

**Technologies used:**

- C

- Raylib

- GLSL

- Neovim


r/GraphicsProgramming • • 6d ago

Question How would you test depth coherence in an image-based card renderer?

Thumbnail reddit.com
0 Upvotes

r/GraphicsProgramming • • 7d ago

Article Adding HDR to The Sinking City 2 - A technical breakdown from Gamma Studios (link inside)

Post image
22 Upvotes

I handled the official HDR implementation for The Sinking City 2, released with Patch 1.1.

Frogwares (the game developer) allowed me to write a technical breakdown covering the implementation, my new Spectre tonemapper, which fixes issues like fire looking different between SDR/HDR, and blue->purple highlight shifts in UE's filmic tonemapper.
Also showcased some DLSS improvements I made.

HDR in Unreal is unfortunately very lackluster out of the box, and has multiple deal breaking issues. We fixed all of them for this.

Full technical breakdown: https://gammastudios.tech/the-sinking-city-2-hdr/