Skip to content

Preserve material opacity when parsing RGB colors - #159

Open
civilwarinfrance wants to merge 1 commit into
pywavefront:masterfrom
civilwarinfrance:fix/material-rgb-opacity
Open

civilwarinfrance wants to merge 1 commit into
pywavefront:masterfrom
civilwarinfrance:fix/material-rgb-opacity

Conversation

@civilwarinfrance

Copy link
Copy Markdown

MTL RGB color statements replace the stored alpha with zero. As a result, a default-opaque Kd color gets alpha 0, and d 0.25 before Kd gives a different result from the same statements in reverse order.

When a parsed Ka/Kd/Ks/Ke color omits alpha, supply the current material opacity. Keep the public Material color setters and existing explicit RGBA behavior unchanged. This also preserves opacity for abbreviated colors without changing their existing RGB interpretation.

The Alias/Wavefront material manual permits statements in any order and defines default dissolve as fully opaque.

Validation on macOS/Python 3.11.15:

  • Original source: 22 new cases fail and 24 controls pass.
  • Fixed: all 137 project tests pass, including 46 new cases for default opacity, d/Tr before and after colors, zero opacity, all four color attributes, explicit RGBA compatibility, and an OBJ using two plain/gzip materials.
  • CI blocking Flake8 passes. Advisory check: the same 211 pre-existing findings, no additions; new test file is lint-clean. git diff --check passes.

No dependency or rendering changes. GPU output and the legacy platform/Python matrix were not tested.

AI assistance: OpenAI Codex prepared and tested this contribution.

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