Texture height being a multiple of 256 causes the model to not render (due to alpha channel becoming 0 ?)
- Dominant language
- Python
- Stars
- 645
- Forks
- 59
- PR merge metrics
- No merged PRs in 30d
Description
I found a bug where if the input texture's height (`y`) is a multiple of 256 (ex.: 256x256), the model completely fails to render in-game.
**Estimated Cause:**
In `objmc.py`, the texture size is encoded into the second pixel of the header:
```
out.putpixel((1, 0), (int(x / 256), x % 256, int(y / 256), y % 256))
```
When `y` is a multiple of 256 (like 256, 512, etc.), the alpha channel (y % 256) evaluates to 0.
(According to an Gemini, it says: Because Minecraft's texture engine optimizes fully transparent pixels by discarding their RGB data, the shader ends up reading this pixel as (0, 0, 0, 0). This causes the shader to interpret the texture size as 0x0, breaking the rendering entirely.)
**Workaround:**
Resizing the texture __height__ to something like 255 (ex. 256x255) prevents the alpha from becoming 0 and works perfectly.
*The same issue might also happen with `nvertices` if it hits a multiple of 256 and the alpha becomes 0.
(keyword for searching: model invisible, transparent)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in objmc.py at the texture-header encoding shown in the report, then reproduce the failure with a 256x256 texture and trace how the header is consumed during rendering. Confirm the behavior for dimensions that are multiples of 256, including the possible nvertices case; done means affected models render correctly without regressing other sizes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100