r/GraphicsProgramming

Experimental voxel renderer
▲ 287 r/GraphicsProgramming+1 crossposts

Experimental voxel renderer

I've been playing with a minecraft style voxel renderer. Current demo has about 11 different techniques to render large worlds as fast as possible.

Demo also has TAA, distance and height fog, shadow maps for directional and ambient cube with per voxel baked AO for ambient, tonemapping and sharpening.

Data is the kings landing model duplicated 100X to make the world bigger. I would ideally like a much larger mesh but memory usage is already quite high so it'll need to be optimize and potentially streamed in on demand. Screenshot is at about 7ms @ 1440p on a 5070 Laptop. Being in the corner so all 100 worlds can be scene is about 15ms. Still a huge amount of various optimizations to be done.

u/Kooky-Advance7870 — 5 hours ago

Trying to join more coding communities and meet other programmers

Hey everyone,
I recently started learning OpenGL, GLSL, and C++ seriously and I’ve been spending a lot of time coding, fixing bugs, reading docs, and building small projects. Now I want to join more coding communities where people share projects, help each other, discuss graphics programming/game dev, and just grow together.

I’m especially interested in:

  • OpenGL / graphics programming
  • Game development
  • C++
  • Shaders / GLSL
  • Creative coding
  • Programming communities in general

I already ask questions when I get stuck and try helping others when I can too. I want to improve faster by surrounding myself with people who love programming.

What are some good communities, Discord servers, forums, subreddits, or places online where beginner/intermediate programmers hang out and learn together?

Would love recommendations.

reddit.com
u/Full-Stranger9249 — 11 hours ago

Shadow artifacts

There is a self shadow artifact, the black rectangle on the side of the wall. Weirdly this is also dependent on zoom level.

What do you think is causing this issue?

u/Foreign-Reply5841 — 19 hours ago

Internship as a second year physics student

Hello everyone,

As of writing this post I'm 19 years old in my first year of a bachelor's degree in Greece studying physics. I've been passionate about programming since I was a kid and I've been programming since, but in the past few years I've been really passionate about graphics programming and especially the maths and simulations aspect behind it.

I was thinking about next summer ( so I've finished my second year of uni) trying to apply for an internship for computer graphics (or any programming job that sounds interesting) in jobs across Europe and my question is regarding my actual possibilities of actually landing an internship

I've made a small game engine, made a lot of small unity games and joined a few game jams and I'm currently working on a physically based renderer and I'm hoping by the end of this summer I can have it render small movies. And also I've made a rigidbody simulator which I'm planning on continuing after the renderer.

My biggest concerns are that i haven't got my degree yet and the only thing for me to show is my GitHub page and my 2 years of physics degree. Also it's kinda worrying the fact that I'm currently studying physics instead of computer science.

My choice for choosing to study physics comes from the fact that in making simulations and programming projects I mostly like the math and how everything works instead of designing algorithms and such and also I really like physics and applied math overall.

reddit.com
u/Base-After — 20 hours ago

Shadows are flickering when I move the camera

The Problem / Questions:

Orbiting the camera translates cameraPos and zooms change the frustum splits, shifting the stable bounding spheres and triggering texel-snapping updates. However, the resulting edge shimmering is severe.

  1. Reconstruction Precision: Reconstructing worldPos in the fragment shader via u_InvViewProj * ndc is highly sensitive to single-precision float accuracy under view-matrix updates. Should we reconstruct view-space position first via u_InvProj and then analytically reconstruct world-space position?
  2. Texel Snapping Math: Does offsetting the projection matrix (proj.columns[3].x += ...) introduce floating-point drift/mismatch when used with Metal's coordinate system (Z∈[0,1])?
  3. Cascade Fluttering: Cascade selection uses viewDepth = abs((u_View * vec4(worldPos, 1.0)).z). Since worldPos is reconstructed, does this float round-trip cause cascade indices to flutter back and forth at boundaries?

1. CPU-Side: Bounding Spheres & Texel Snapping

To make cascade sizes rotation-invariant, bounding spheres are centered at the camera position:

cpp// Center is camera position, radius is constant based on split distances
const Vec3 center = cameraPos;
float radius = farDist * fovAspectFactor + 2.0f; // 2.0f PCF padding
StableCascadeData cascadeData = MakeStableCascadeViewProj(*shadowLight, center, radius, CASCADE_MAP_SIZE);

Grid snapping shifts projection boundaries to world-space texel alignment using std::floor:

cpp// Project world origin (0, 0, 0) into light space
Mat4x4 viewProj = proj * view;
Vec4 shadowOrigin = viewProj * Vec4(0.0f, 0.0f, 0.0f, 1.0f);
shadowOrigin.x /= shadowOrigin.w;
shadowOrigin.y /= shadowOrigin.w;
const f32 halfMapSize = (f32)mapSize * 0.5f;
const f32 originX = shadowOrigin.x * halfMapSize;
const f32 originY = shadowOrigin.y * halfMapSize;
// Offset the projection translation column
proj.columns[3].x += (std::floor(originX) - originX) / halfMapSize;
proj.columns[3].y += (std::floor(originY) - originY) / halfMapSize;

2. GPU-Side: Reconstruction & Sampling

We use nearest filtering for reading G-Buffer depth to prevent edge interpolation jitter, reconstructing world position via u_InvViewProj:

glslvec3 ReconstructWorldPos(vec2 uv, float depth) {
    vec2 screenUV = vec2(uv.x, 1.0 - uv.y); // Metal UV flip
    vec4 ndc = vec4(screenUV * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
    vec4 world = u_InvViewProj * ndc;
    return world.xyz / world.w;
}

In the sampling step, we apply world-space normal bias scaled by texel size, and evaluate shadows using a 9-tap bilateral PCF gather (5x5 footprint):

glslfloat SampleCascade(sampler2D shadowMap, mat4 cascadeVP, int cascadeIndex, vec3 worldPos, vec3 N, float NdotL) {
    float texelSize = max(u_CascadeTexelSize[cascadeIndex], 1e-5);
    float depthRange = max(u_CascadeDepthRange[cascadeIndex], 1e-3);
    // Apply normal bias in world units
    vec3 shadowPos = worldPos + N * (u_ShadowParams.y * 30.0 * texelSize);
    vec4 lightClip = cascadeVP * vec4(shadowPos, 1.0);
    vec3 projected = lightClip.xyz / lightClip.w;
    vec2 shadowUV  = vec2(projected.x * 0.5 + 0.5, 1.0 - (projected.y * 0.5 + 0.5));
    float currentDepth = projected.z * 0.5 + 0.5;
    // Slope-scaled depth bias
    float slopeScale = sqrt(max(1.0 - NdotL * NdotL, 0.0)) / max(NdotL, 0.05);
    float bias = u_ShadowParams.z * (texelSize / depthRange) * (1.0 + 1.75 * clamp(slopeScale, 0.0, 4.0));
    // PCF grid sampling using textureGather...
    return EvaluatePCF(shadowMap, shadowUV, currentDepth, bias); 
}
u/Foreign-Reply5841 — 1 day ago
▲ 67 r/GraphicsProgramming+3 crossposts

Cellular automata simulation

Hello everyone, I've made a zero player game cellular automata simulation with C++ - Conweys game of Life.

The rule of the game is very simple:

The world is an infinite grid and A cell would be alive if it had 2-3 neighbours alive.

It can die by under and overpopulation.

That's it.

But to render and simulate I've made the world as a 100x100 grid with a torus wrap. This is a very fun way to learn and spend time.

To use this all you have to do is just open the file and run the code. By default it has an Acorn Pattern and a ready to use other two patterns.

So yeah take a look at my GitHub and give my repo a star.

GitHub: https://github.com/Radhees-Engg

u/Rude-Flan-404 — 1 day ago

How do you turn ideas into implementation?

I’m currently working through chapter 1 of GPU Gems 3 (link: https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-1-generating-complex-procedural-terrains-using-gpu) as a way to strengthen my understanding of the Metal API and implement some interesting stuff. For context, I’m relatively novice though not unfamiliar with the api.

The issue I’m having is that after reading the chapter, I now understand the concepts and the rough idea of how they implemented it, but I had no clue as to how to even start. I used Claude to help me translate the problem into actual metal concepts, and that helped me get started.

My question is, how do you guys generally deconstruct a problem/paper/idea into the design of a solution and eventually into implementation? Is there a framework you have built up which has helped you to speed up this process? Further, is it possible I’m biting off more than I can chew and should seek something a little more within my metal abilities? Let me know what you think.

TLDR: Would love to get some ideas on how I can improve translating ideas to code.

u/FirePenguu — 1 day ago

Added better materials to my path tracer

Added better materials to my path tracer and added multiple importance sampling.

  1. Glass (varying roughness)
  2. Glossy (varying roughness)
  3. Diffuse (varying roughness)
  4. mix(diffuse, glossy, 0.1) (glossy of varying roughness) Roughness vary from left to right (0.0, 0.5, 1.0). Glass and Glossy material uses single-scattering GGX and Diffuse uses Energy-preserving Oren-Nayar model.

Edit: 3D model is from here: https://sketchfab.com/3d-models/laughing-buddha-646f46ae29084d8696afc4efa5c81c39

u/BlackGoku36 — 2 days ago
▲ 6 r/GraphicsProgramming+1 crossposts

What is a reasonable frame budget (ms) for the post-processing pass in a custom Deferred Renderer?

Hi everyone,

I am currently building a custom DirectX 11 engine from scratch for my portfolio. The project is a high-end action RPG inspired by Lost Ark, utilizing a deferred rendering pipeline.

Right now, my post-processing pipeline includes:

* SSAO

* Exposure / Auto-Exposure

* Bloom

* Tonemapping

As I keep adding more shader passes to the post-processing stage, I am starting to feel a noticeable drop in frame rate. I've been trying to research the typical "frame budget" or average milliseconds (ms) allocated specifically for the post-processing phase in high-end or mid-to-high-end PC games, but I couldn't find any concrete numbers online.

**My Specs & Target:**

* **Current Dev Environment:** 1600 x 900 resolution on a Laptop RTX 4070.

* **Target Spec:** I am aiming to optimize this for mid-to-high-end mainstream PCs (around desktop RTX 3060 / 4060) targeting 1080p 60 FPS.

**What I'm doing & Looking for:**

I am currently implementing progressive downsampling (1/2 -> 1/4 -> 1/8) to optimize the Bloom and SSAO passes. However, I want to make sure I am measuring and optimizing the performance correctly.

  1. For a shader-heavy game targeting 60 FPS (16.6ms total), how many ms does the post-processing stage usually take in professional pipelines under these target specs?

  2. At what point should I look at my post-process cost and say, "Okay, this is too high, I need to optimize"?

  3. Any profiling tips or best practices for debugging shader/bandwidth bottlenecks in DX11 custom engines? (e.g., specific ways to measure GPU time accurately per pass or what to look for in RenderDoc).

I would really appreciate any insights, industry standards, or optimization advice you could share.

Thanks in advance!

reddit.com
u/Over-Radish-5914 — 2 days ago

Textbook vs. Reality: Reversing a AAA Game Engine to see how a Perspective Projection Matrix is actually calculated

We all know the math of a Projection Matrix but what does that math look like in a triple A game engine?

I recently spent a few weeks reverse-engineering the Dunia Engine's rendering pipeline to see how a AAA engine handles its per-frame matrix construction.

The write-up breaks down how the engine interleaves _mm_unpacklo_ps instructions to build the matrices, how it handles asymmetric frustum offsets for the camera, how it avoids heavy MatrixInverse calls (like Cramer's rule) in favor of a hardcoded, inline algebraic "fast inverse" to save CPU cycles, spotting production quirks and even redundancy.

If you are interested in the bridge between rendering theory and low-level engine execution, you can check out the full teardown here: https://zero-irp.github.io/Proj-Blog/

reddit.com
u/zer0_1rp — 3 days ago
▲ 1 r/GraphicsProgramming+2 crossposts

how to study glsl shader on the website

Hey everyone,

I've been building Pixel Shader Academy

a browser-based, interactive GLSL learning site aimed at people who are completely new to shaders. It's free and live here: https://shader.dolstep.com

The full source is on itch.io https://bobddadoo.itch.io/pixel-shader-academy-full-source

What it actually is

A sequence of bite-sized stages where each lesson hands you a real fragment shader running in a WebGL canvas next to a code editor. You edit GLSL → it recompiles live → the result is the puzzle target. Stages walk through the usual fundamentals: UV coordinates, step/smoothstep, mix, SDFs for circles/rectangles, polar coordinates, time-based animation, simple noise, and a few small post-effects toward the end.

Implementation notes

  • Frontend: Vite + vanilla JS, no framework. Each stage is a small data file (starter code, target image, hint text, success predicate).
  • Rendering: a single full-screen triangle with a per-stage fragment shader. Shader compile errors are surfaced inline in the editor with the GLSL line number mapped back.
  • Validation: I render the user's shader and a reference shader to offscreen framebuffers at the same resolution, then do a per-pixel diff with a tolerance threshold. Below the threshold = stage passes. It's dumb but it works surprisingly well for "did you reproduce this image" puzzles.
  • Asset pipeline: all reference images are baked from the reference shaders themselves at build time, so I never have to hand-author solution PNGs.
  • Mobile: the biggest pain. Float precision differences (highp vs mediump) on some Android GPUs broke a few SDF stages — I ended up forcing highp and adding small epsilons in the diff.
  • I built it almost entirely by pairing with Claude (Anthropic). I designed the curriculum and made the pedagogical calls; Claude wrote most of the boilerplate and helped iterate on shader puzzles.

What I'd love feedback on

  1. The per-pixel-diff validator feels naive. Anyone done something smarter for "did the student reproduce this image" without being brittle to anti-aliasing differences across GPUs?
  2. Curriculum ordering — is there a fundamental I'm missing before noise/post-fx, or one I'm teaching too early?
  3. Any classic GLSL "aha" exercises you'd add?
  4. Anything else I should add?

Happy to answer anything about the architecture, the validator, or the Claude-assisted workflow. Roasts welcome.

u/Bobthief — 3 days ago
▲ 22 r/GraphicsProgramming+1 crossposts

[Update] Kiln: WebGPU-native out-of-core volume rendering

Hi folks,

A few weeks ago I wrote about one of my current projects on volume rendering here.

Since then the renderer got some traction in the bioimaging community. Since then I worked on things like better support for the OME-Zarr format, local filesystem streaming (Chrome/Edge) and a few other improvements regarding performance and usability.

And today the project was accepted to the OME-NGFF tools list and is now listed on their community portal as a suggested viewer for people who work with Zarr datasets.

https://ngff.openmicroscopy.org/resources/tools/index.html#zarr-viewers

Still early days with support for v0.5, single-channel 8/16-bit unsigned int, but features such as v0.4 support, multi-channel rendering and more are already planned.

Wanted to share this here, since the renderer evolved into something that is now part of the ecosystem. Which feels great!

A big thanks to everyone who commented and provided feedback — it really helped shape this into something that is actually useful.

For reference:

Live demo: https://mpanknin.github.io/kiln-render

GitHub: https://github.com/MPanknin/kiln-render

u/Away_Falcon_6731 — 3 days ago
▲ 25 r/GraphicsProgramming+2 crossposts

Should I learn Vulkan using vulkan.h or vulkan.hpp as a beginner ?

I have some ++basic OpenGL and D3D11 experience and I want to learn Vulkan properly from scratch , not just making things compile without understanding them.

The problem: most tutorials I find are outdated like https://vulkan-tutorial.com or use wrappers that abstract things to make things easier and avoid boilerplate like https://vkguide.dev . The official Khronos tutorial looks solid and modern (Vulkan 1.4, dynamic rendering, timeline semaphores) but uses vulkan.hpp with RAII instead of raw vulkan.h:
docs.vulkan.org/tutorial/latest

My concern is that vulkan.hpp will negatively affect the learning the Vulkan concepts or it doesn't matter since it is a thin wrapper.

reddit.com
u/Latter_Relationship5 — 3 days ago
▲ 27 r/GraphicsProgramming+1 crossposts

Fractal Tunnel Shader Tutorial

Here is a tutorial on a Fractal Tunnel Shader Tutorial

#float speed 0.5 0.1 2.0
#float zoom  2.0 0.5 5.0
#float twist 3.0 0.0 10.0
#color color1 #ff3366
#color color2 #3366ff
#color color3 #33ff66

void main() {
    vec2 uv = v_uv * 2.0 - 1.0;
    uv.x *= u_resolution.x / u_resolution.y;

    float t = u_time * speed;
    float r = length(uv);
    float a = atan(uv.y, uv.x);

    float tunnel = 1.0 / (r + 0.1);
    float angle  = a + tunnel * twist + t;

    float pattern = 0.0;
    for (int i = 0; i < 4; i++) {
        float fi = float(i);
        float scale = zoom * (1.0 + fi * 0.5);
        float wave  = sin(tunnel * scale - t * (1.0 + fi * 0.2));
        wave       += sin(angle * (3.0 + fi) + t);
        pattern    += wave / (2.0 + fi);
    }
    pattern = pattern * 0.5 + 0.5;

    vec3 color = mix(color1, color2, sin(pattern * PI) * 0.5 + 0.5);
    color = mix(color, color3, sin(pattern * 6.28318 + t) * 0.5 + 0.5);
    color *= 1.0 - r * 0.5;

    fragColor = vec4(color, u_opacity);
}
u/nycgio — 3 days ago