Description
Add tangent-space normal mapping to the Blinn-Phong shader pipeline. Most infrastructure already exists — calcTangents() is implemented in src/renderer/bgfx_utils.cpp but never called. Vertex layouts lack the tangent attribute and materials don't expose a normal map texture slot. The vertex shader has a commented-out TBN line ready to be enabled.
Steps
- Add
Tangent (vec4) to vertex layouts and call calcTangents() in the model loader after vertex creation
- Update
varying.def.sc with vec4 v_tangent, compute TBN matrix in vs_blinnphong.sc and pass to fragment shader
- Update
fs_blinnphong.sc to sample normal map texture and transform via TBN
- Add normal map texture slot to
BlinnPhongMaterial
- Test with a model that has normal maps
Description
Add tangent-space normal mapping to the Blinn-Phong shader pipeline. Most infrastructure already exists —
calcTangents()is implemented insrc/renderer/bgfx_utils.cppbut never called. Vertex layouts lack the tangent attribute and materials don't expose a normal map texture slot. The vertex shader has a commented-out TBN line ready to be enabled.Steps
Tangent(vec4) to vertex layouts and callcalcTangents()in the model loader after vertex creationvarying.def.scwithvec4 v_tangent, compute TBN matrix invs_blinnphong.scand pass to fragment shaderfs_blinnphong.scto sample normal map texture and transform via TBNBlinnPhongMaterial