Why does the direction use w = 0?
vec4 dir = vec4(d, 0.0); vec4 pos = vec4(p, 1.0);
- So it gets normalised automatically
- So the GPU stores it in fewer bits
- So translation has no effect on it
- So it always points at the camera
A 4x4 transform multiplies its translation column by w, so w = 0 keeps rotation and scale but ignores position offsets.
Play Game Dev ▸