Skip to content

GSOC 26: normal (bump) map support - #9067

Open
Nixxx19 wants to merge 8 commits into
processing:mainfrom
Nixxx19:normal-mapping
Open

GSOC 26: normal (bump) map support#9067
Nixxx19 wants to merge 8 commits into
processing:mainfrom
Nixxx19:normal-mapping

Conversation

@Nixxx19

@Nixxx19 Nixxx19 commented Aug 9, 2026

Copy link
Copy Markdown
Member

what

adds normal (bump) map support (map_Bump), the last of the mtl texture maps. a normal-mapped material perturbs the surface normal per pixel so lighting shows surface detail that isn't in the geometry.

note: this is stacked on #9066 (specular/ambient/shininess maps) since it reuses the same per-part texture infrastructure. until #9066 merges, the diff here also shows those changes. the normal-map-specific work is the tangent pipeline below.

how

normal mapping needs a per-vertex tangent basis, which p5 didn't have. the pieces:

  1. p5.Geometry.computeTangents() (new) computes a per-vertex surface tangent from the uvs (edge vectors + uv deltas, accumulated per vertex, Gram-Schmidt orthogonalised against the normal). the bitangent handedness is stored in the tangent's w so the shader can rebuild it as cross(normal, tangent) * w.
  2. the loader computes tangents once on the aggregate (only when a material has a normal map) and buildMaterialParts hands each part its slice, mirroring how normals flow.
  3. a new aTangent vertex attribute (defaults to a dummy so it's always valid; the shader only uses it when a normal map is bound).
  4. phong.vert transforms the tangent into view space alongside the normal and passes it on.
  5. phong.frag rebuilds the TBN basis, samples the normal map, and perturbs the normal, gated by uHasNormalMap so untextured draws are unaffected.

zero regression

the aTangent attribute and shader branch are gated/defaulted so existing 3D draws are untouched. confirmed by the full visual + unit suite staying green.

testing

  • computeTangents() unit test with a known triangle (asserts the exact tangent vector + handedness), plus the no-uvs case
  • loadModel test: a normal-mapped obj computes tangents, and the part carries both the normal map and its own per-vertex tangents
  • mtlToPartState unit test for the normal map field
  • a visual regression test rendering a normal-mapped model under a point light
  • full unit + visual suite green

part of the gsoc multi-material .mtl work, follows #8879, #8955, #9063, and #9066.

@p5-bot

p5-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown

Continuous Release

CDN link

Published Packages

Commit hash: 61f213a

Previous deployments

This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant