Home / Forums / Understanding the View-Projection Matrix: Camera Space to Normalized Device Coordinates

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

Understanding the View-Projection Matrix: Camera Space to Normalized Device Coordinates

DisasmGeek
Capstone & Keystone Specialist
MEMBER
Rep: 160
Join Date: Dec 2024
Posts: 21
Thanks: 38
4y ago · May 4, 2022 8:08 AM
#1
Step-by-step mathematical breakdown of how 3D world coordinates transform through View and Projection matrices into [-1, 1] NDC space.
DisasmGeek · Capstone / Keystone Engine Integration
The following users thanked DisasmGeek for this post:
ParanormalDev
MelonLoader / BepInEx Dev
MEMBER
Rep: 230
Join Date: Sep 2023
Posts: 21
Thanks: 58
4y ago · May 4, 2022 9:50 AM
#2
World * ViewMatrix converts to Camera View Space (Z is depth). ViewSpace * ProjectionMatrix transforms into Homogeneous Clip Space (x, y, z, w).
ParanormalDev | MelonLoader & ImGui Modding
HexRays99
Senior Reverse Engineer
VIP
Rep: 380
Join Date: Apr 2022
Posts: 36
Thanks: 94
4y ago · May 4, 2022 3:50 PM
#3
Dividing x and y by w (Perspective Divide) yields NDC coordinates ready for viewport screen scaling.
HexRays99 · Reverse Engineering & Static Analysis
CPP
// Always check your pointers!
if (!pLocalPlayer) return;