Skip to content

GSOC 26: apply mtl material state to single-material models - #9110

Open
Nixxx19 wants to merge 3 commits into
processing:mainfrom
Nixxx19:fix/single-material-maps
Open

GSOC 26: apply mtl material state to single-material models#9110
Nixxx19 wants to merge 3 commits into
processing:mainfrom
Nixxx19:fix/single-material-maps

Conversation

@Nixxx19

@Nixxx19 Nixxx19 commented Aug 23, 2026

Copy link
Copy Markdown
Member

found while testing the mtl work against real models downloaded off the internet rather than my own fixtures. a model with exactly one material loads its textures and then drops them, so it renders untextured.

what was happening

buildMaterialParts returned early when a file named fewer than two materials. that was deliberate on my part, to keep single-material rendering byte-for-byte unchanged, but it also meant such a model never received a partState, so nothing from its .mtl was ever applied. the maps were parsed and fetched, then thrown away at the last step.

single material with one map_Kd is the most common shape a real export takes, so this is the case most people would hit first.

the fix

a geometry already carries its own partState and sets parts = [this], so when one material covers every face the state can go straight onto the geometry. no split, no part allocated, parts[0] is still the geometry, and nothing about the geometry layout changes.

splitting instead would have duplicated every vertex to describe the same thing, and would have broken parts[0] === geometry, which the existing tests rely on.

the mixed case is untouched. an obj with faces declared before any usemtl plus one named material still returns early and renders as it did, since applying that material to the whole geometry would wrongly colour the faces that have none.

tests

one new fixture, a single-material obj with map_Kd, and a test asserting the geometry stays its own only part while carrying the texture, shininess and specular colour.

full suite passes. one typography screenshot test is flaky on this machine, but it flakes the same way on a clean checkout with no changes, so it is unrelated.

@p5-bot

p5-bot Bot commented Aug 23, 2026

Copy link
Copy Markdown

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