GSOC 26: apply mtl material state to single-material models - #9110
Open
Nixxx19 wants to merge 3 commits into
Open
GSOC 26: apply mtl material state to single-material models#9110Nixxx19 wants to merge 3 commits into
Nixxx19 wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
buildMaterialPartsreturned 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 apartState, so nothing from its.mtlwas ever applied. the maps were parsed and fetched, then thrown away at the last step.single material with one
map_Kdis 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
partStateand setsparts = [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
usemtlplus 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.