r/GraphicsProgramming

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 — 18 hours ago
▲ 14 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 — 17 hours ago

Asymmetrical rendering

Can this not be used for better performance I had an idea to improve latency but it evolved into this:

Theres 2 Pipelines:
Background: Which isnt as updated with heavy lighting and whatever else are calculated once then cached in VRAM and skipped for multiple frames, while a transition like dithering or something is used to merge it to a Live pipeline (or Live can be drawn ontop)(This is the entire 3D world not 2D) You can slap a VSM if you need time of day every few frames or whenever.

Live Pipline: Physics and inputs react like normal and you can move interactive objects and things such as signs, NPCs and the sky into the live pipeline if you want them to move (Or add another pipeline for them at a lower than live rate but higher than Background). By stopping the GPU and CPU from recalculating the universe every millisecond, you can get from 20 FPS to hundreds. And the multiple pipelines let you experiment aton.

reddit.com
u/l_aggy — 20 hours ago
▲ 1 r/GraphicsProgramming+2 crossposts

Need a partner for making a Minecraft using OpenGL and C/Rust.

I’m looking for someone who:

enjoys low-level graphics/game engine programming

has experience with OpenGL, C, or Rust

wants to work on a serious long-term project

is interested in learning and experimenting together

This is mainly a passion project for learning and building something impressive. If you’re interested, DM me.

reddit.com
u/PuzzleheadedTower523 — 17 hours ago

How to balance shader work vs bandwidth?

I am working on a small scale voxel engine and currently just trying to push rendering distance to its absolute limits.

One of the optimisations I hear often is reducing the amount of data sent to the GPU. So I reduced my vertex buffer 7x to 4 bytes (32 bits) by storing local chunk coordinates instead of float global coord, packing normal vector into first 3 bits of a byte (as it can only ever have 6 values) and using the rest for block type.

But the work I had to do in a shader to decode those values ended up resulting in (slightly but still) worse performance than when sending all the data raw, at least on my high end GPU.

Is there a rule of thumb somewhere about how much to send vs what to delegate to a shader? Is less bandwidth always better or does it only start to become an issue once you reach certain amount of data sent? Is this balance any different on lower end GPUs, and I will feel the optimisation if I benchmark on a different machine?

Sorry if the question is stipud, I’m just a beginner.

reddit.com
u/SurDno — 1 day ago

Learning resources for graphics programming

I'm sure you guys get asked this every day, so I apologize for yet another post (pls forgive me, I just wanted an updated guide in 2026)

I'm learning game development and I got really interested in code shaders in unity hlsl. And looking through the internals of unity shader code I realized, I know absolutely fck all.

Anyway, I decided to learn this the proper way, so I wanted to ask for a path to learning directX 12 or dx 11, which isnt outdated in 2026, or atleast not too outdated. And is there a book you recommend for graphics techniques.

Cause I've seen some really insane shaders people are making on youtube based on techniques which are scattered all throughout in different games and I wanted to see if there were some interesting resources that had a bunch of common techniques in it, or is it just looking up stuff on google scholar.

I don't mean PBR theory, but some neat graphical tricks people do for visual effects like, particle fog, screenspace volumetric fog with godrays, screenspace outlines, someone used FFT to make ocean waves, those kind of things.

Thank you for your time in reading this

reddit.com
u/ConfusedStudent3011 — 1 day ago
▲ 28 r/GraphicsProgramming+1 crossposts

Ray Marching Black Hole using OpenTK (it took me 2 hours to render)

I made this ray marching demo on C#. It took me 2 hours to render on 1080ti. Plasma is made from clouds, I added some post-processing and rendered it in 1080p 60fps. In realtime render I got like 0.4 FPS in 1080p and 30 FPS in 160 x 90. Very lightweight demo (:

youtu.be
u/Loose-Care6997 — 1 day ago
▲ 57 r/GraphicsProgramming+3 crossposts

Updated Grass System

Updated grass system to use instanced glb file with billboard grass clumps instead of procedurally generated grass blades(couldnt get this to look right)

u/underwatr_cheestrain — 2 days ago
▲ 7 r/GraphicsProgramming+1 crossposts

Is a hybrid particle-fluid simulation + solution-adaptive dynamic grid scientifically meaningful for a computer graphics project?

Hi everyone,

I’m working on a computer graphics course project and would really appreciate feedback from people with experience in computer graphics, CFD, SPH, adaptive meshing, adaptive mesh refinement, computational grid, irregular (organic) unstructured quadrilateral/hexagonal grid generation, or scientific visualization.

The project started from two separate interests:

  1. A GPU particle-based (Lagrangian grid-free) fluid simulation in Unity, inspired by Sebastian Lague’s fluid simulation work (https://www.youtube.com/watch?v=rSKMYc1CQHE).
  2. A custom organic irregular quadrilateral/hexagonal grid that I had previously built in Unity, inspired by Oskar Stålberg's Townscaper game. I'm a bit concerned about using this grid, since Oskar used it more for creativity/artistic reasons in his game, to get that organic European look for his town assets (https://x.com/OskSta/status/1147881669350891521).

More recently, I came across the paper (is it okay that it's 20+ years old?) “A Solution-Adaptive Grid Generation Scheme for Atmospheric Flow Simulations” (https://www.researchgate.net/publication/2379446_A_Solution-Adaptive_Grid_Generation_Scheme_for_Atmospheric_Flow_Simulations), which gave me the idea to combine these two directions. I am not trying to reproduce the full atmospheric solver from the paper. Instead, I’m trying to reinterpret the solution-adaptive grid-generation idea in a real-time graphics context.

My current implementation is roughly:

  • A GPU particle-fluid simulation, where particles carry position, velocity, density, etc.
  • A custom organic irregular quadrilateral grid.
  • A regular uniform quad grid as a comparison baseline (or maybe something else?).
  • A bridge that samples the fluid state and assigns an importance value to each adaptive grid cell.
  • Cells are dynamically refined/coarsened based on particle count, density, velocity, or combined importance.
  • The grid itself is CPU-side topology, while the fluid simulation and importance sampling are GPU-side in Unity.
  • The organic grid boundary can also be used as the physical fluid collision boundary.

The part I am unsure about is the scientific meaning framing.

Since the fluid simulation is particle-based/Lagrangian, the adaptive grid is not actually solving the fluid equations directly. Instead, the grid adapts to the particle solution field. So the project is more of a hybrid particle-grid / scientific visualization / adaptive representation prototype than a traditional grid-based CFD solver.

My tentative research question is something like:

How effectively can a particle-based fluid simulation drive solution-adaptive refinement of an organic irregular quadrilateral grid in real time, and how does this compare to a regular uniform adaptive grid?

To make this project idea scientifically meaningfull I need to make the evaluation look like a research investigation, not only a demo. So basically, I need to ground this exploratory investigation idea into state-of-the-art evaluation methods for my approach. I struggle with this part as well.

I might be considering evaluating (do correct me if this seems incorrect or too much or too unnecessary):

  • FPS / frame time
  • adaptation time
  • active cell count
  • base cell count
  • max refinement level
  • particle count scalability
  • percentage of particles covered by refined cells
  • percentage of refined cells that are empty/wasted
  • organic grid vs uniform grid performance and adaptive behavior
  • possibly mesh-quality metrics such as aspect ratio, angle quality, or cell area variation

My doubts are:

  1. Is this hybrid approach scientifically meaningful, even though the adaptive grid is not the main fluid solver?
  2. Is comparing an organic irregular adaptive grid against a uniform adaptive grid a valid research-style comparison?
  3. Would it be more correct to frame this as adaptive scientific visualization / adaptive spatial representation rather than CFD accuracy?
  4. What evaluation metrics would make this feel like a serious graphics/scientific computing project rather than just a creative Unity demo?
  5. Are there related methods or papers I should reference, especially around particle-grid coupling, adaptive mesh refinement, scientific visualization, or fluid-driven level of detail?

I would be grateful for any critique, suggestions, or warnings. I especially want to make sure I am not overclaiming what the project does. My goal is to present it honestly as a research-inspired real-time graphics prototype with a meaningful evaluation, not as a fully validated CFD solver. My interests lie more in the computational grid, spatial discretisation, computational geometry, implicit representation, shape representation, uncovering shapes, geometries, patterns, and structures in a space, and the spatial intelligence side of research, rather than physics itself.

Any help would be appreciated! Let me know if you need more info regarding this.

Thanks in advance!

u/DocumentFederal — 1 day ago
▲ 361 r/GraphicsProgramming+1 crossposts

My first triangle in OpenGL

Hello, World!

I have started learning graphics programming for a few days with the help of learnopengl.com and I feel like I learned quite a lot in these few days. Setting up an OpenGL 3.3 project with C++ in Visual Studio, Drawing a blank window with GLFW and then drawing an RGB triangle in it with OpenGL and GLSL. Learned about shaders, buffers and different OpenGL objects and their use.

I am really getting a lot interested in this field of computer science. but, I am also a bit nervous about it. As there is a lot mathematics involved in this which is my biggest weakpoint.

I would like to hear about how y'all got into graphics programming and what challenges did y'all face while learning it.

u/whos-this-nerd — 3 days ago
▲ 176 r/GraphicsProgramming+2 crossposts

I wanted to understand how Cycles works, so I coded my own GPU Path Tracer from scratch in C#. Here is my final render!

https://reddit.com/link/1tflvbe/video/ajy6qm93do1h1/player

https://preview.redd.it/0pcbp4wbdo1h1.png?width=2560&format=png&auto=webp&s=71fe1904133ba0c0790feebeb02a0709e8266cb8

Hey r/blender,

I've spent countless hours watching Cycles do its magic, so I decided to learn the math under the hood and write my own GPU Path Tracer from scratch in C#!

It runs directly on my Nvidia GTX 1050 using ILGPU to compile C# into CUDA. Here is a 3-second camera flyby I just rendered!

Tech Stack & Features:

  • GPU-Accelerated: No game engine, just a pure C# console app running on CUDA via ILGPU.
  • PBR Materials: Rough metals, glass with refraction (including hollow glass), and shiny plastic (using Schlick's approximation for clearcoat Fresnel).
  • Physical Camera: Real Depth of Field (adjustable aperture/focus distance) and lens bokeh.
  • Lighting: Physical sphere sun casting soft shadows, combined with global illumination.
  • Post-Processing: ACES Tonemapping, Gamma 2.2, and a custom GPU Bilateral Denoise Filter to clean up fireflies while keeping edges crisp.

I literally started with a flat, solid red circle on a blue screen. Seeing it evolve into normal mapping, moving it to the GPU, and finally watching ACES and the denoiser work together has been an incredible coding journey.

Since I am only 15 and still learning, I'd love to hear your feedback! How close does this look to Cycles in your opinion? What features should I code next?

Code is fully version-controlled on Git, and I'll keep optimizing it!

https://github.com/noackjona-hash/GPU-Path-Tracer-from-scratch-in-C-

reddit.com
u/Usual-Wall5405 — 3 days ago
▲ 155 r/GraphicsProgramming+1 crossposts

MeltedForge: My game engine written in C now supports more cool things!!

So, here are the things I added to my game engine in the past month or so.

  • Skybox support (From equirectangular map to cubemap image)
  • Mipmap generation support for any kind of textures (Including skybox too)
  • PBR support
  • Diffuse + Specular IBL
  • More stabalizing of the engine's core
  • Added VMA to the engine
  • Some helper tonemapping functions in the shader utils like ACES, Reinhard and Uncharted 2's tonemapper

As of now, the performance isn't good (Don't take the performance in the screenshot seriously, it showed that deltaTime due to the screenshot). There are lots of things left to be added and to be improved. But yeah, that's it for the updates.

Here is the github repo is anybody wondering :- MeltedForge

u/SubhamayGamer2127 — 3 days ago

Why is the texture mapping of my minecraft grass texture so.. blended, if the filtering is correctly set to nearest?

Things i have tried:

the mag and min parameters of the texture are correctly set to gl.NEAREST and gl.NEAREST_MIPMAP_NEAREST

the overall canvas has the .imageRendering css property set to "pixelated"

the uv coordinates, for the face displayed, i believe are correct

u/SnurflePuffinz — 2 days ago

3D math - graphics engineer interview prep

Sorry in advance if this isn't the right place!

I'm a software engineer who had a rendering position for less than a year before layoffs kicked me out of my dream job a few years ago. I've been in a position where luckily I get to work in C++ and keep those skills refined, but I've been slacking in keeping up with all the graphics skills I need.

I've been itching to get back into graphics instead of the swe job I have now, and actually got an interview lined up! The recruiter in the phone screening emphasized a lot that 3D math questions would be in the next round - enough to make me nervous and worry about how rusty I may be.

Any advice for what I should focus on reviewing or potential questions? Resources are also welcome!

Please and thank you!!

reddit.com
u/notlikeotherbees — 3 days ago
▲ 256 r/GraphicsProgramming+2 crossposts

What did Takizawa mean when he said "In technological terms, the Wii U can present a wide range of brightness"?

Hi all,

Does anyone happen to know the specific technical concept he's describing here? (Source: https://www.nintendo.com/en-za/Iwata-Asks/Iwata-Asks-The-Legend-of-Zelda-The-Wind-Waker-HD/The-Legend-of-Zelda-The-Wind-Waker-HD/5-Over-designed/5-Over-designed-807330.html )

I have noticed that Wind Waker HD has much brighter brights and darker darks than its GameCube predecessor. I've also noticed that this is the case generally when it comes to 8th gen games compared to 6th gen ones.

But I was wondering, specifically what is the reason for this? It's not true that the GameCube couldn't display anything that bright or that dark, right? So why couldn't you have that high contrast look you see in newer games? Like why do say ps2 games look so flat and washed out compared to a lot of ps4 ones in terms of tonal contrast?

u/Calm-Preparation-679 — 3 days ago
▲ 254 r/GraphicsProgramming+1 crossposts

[Compute Shaders] Built a custom LBM voxel fluid simulation with 100% GPU advection. 180 FPS on a 4070ti at 192³ resolution.

Hey everyone! I've been working on a custom, from-scratch voxel engine utilizing Unity's Compute Shaders and StructuredBuffers.

Unlike traditional particle pipelines or VFX Graph, everything here runs within a single flat StructuredBuffer<uint4> directly on the GPU. The fluid simulation under the hood is based on a custom Lattice Boltzmann Method (LBM).

Currently pushing around 180 FPS on a RTX 4070ti at 192³ grid volume. My next immediate goals are dynamic light propagation and material thermodynamics.

u/Useful-Turnip1994 — 4 days ago