Bump mapping and directional lightmap samples for proper normal-mapped lighting #40
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Normal maps (
$bumpmap) are loaded and applied to materials but only used for envmap reflection perturbation and water ripple distortion. They don't affect diffuse or specular lighting, so bumpmapped surfaces appear flat compared to the game.What's needed
Entity materials (VertexLitGeneric)
BSP surfaces (LightmappedGeneric)
Source engine uses 3 directional lightmap samples (basis vectors) for bumped lightmapped surfaces. Each sample captures light from a different direction, and the normal map selects the contribution from each:
Implementation considerations
$ssbump(self-shadowed bump maps)Related
Implemented in
a27c9ef. Full bump mapping pipeline for BSP LightmappedGeneric surfaces:lightmap.js): Extracts 3 directional lightmap layers (bump basis samples) from the BSP LIGHTING lump alongside the flat layer. Uses the same atlas layout/UVs.geometry.js): Computes tangent/bitangent vertex attributes fromtexinfo.textureVecsfor all BSP faces and displacements.bumpvects.h), applies squared falloff, weights the directional lightmap samples, and normalizes bydot(dp, vec3(1)). Perturbed world-space normal is used for envmap reflection direction.hasBumpmap = truewhen$bumpmapVMT property is defined and the texture loads successfully.Note: This covers BSP surfaces (LightmappedGeneric). VertexLitGeneric bump mapping for entity models (using the normal for N·L diffuse and specular) is not yet implemented — that's a simpler change but requires the same TBN pipeline on model geometry.