Skip to content

Renderer: TBN matrix for normal mapping #24

@robinwils

Description

@robinwils

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    renderingGraphics and visual improvements

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions