Opened 6 years ago
Last modified 3 years ago
#5022 new defect
Greyscale to RGBA texture conversion fails silently (failing Atlas heightmap import)
Reported by: | elexis | Owned by: | |
---|---|---|---|
Priority: | Should Have | Milestone: | Backlog |
Component: | Core engine | Keywords: | |
Cc: | Patch: |
Description (last modified by )
After importing an image as a heightmap to atlas, the vertex with the highest coordinates is wrong.
For example if you load an entirely black image, you get a flat surface with one pixel at the corner up in the sky.
(See #5021 for the wrong border, this ticket is only about that one corner)
Attachments (1)
Change History (9)
by , 6 years ago
Attachment: | example2.jpg added |
---|
comment:1 by , 6 years ago
Description: | modified (diff) |
---|
comment:2 by , 6 years ago
Component: | Atlas editor → Core engine |
---|---|
Milestone: | Alpha 23 → Backlog |
Owner: | removed |
Status: | assigned → new |
Summary: | Atlas heightmap image off by 1 byte wrong texture decoding → Greyscale to RGBA texture conversion fails silently (failing Atlas heightmap import) |
comment:3 by , 6 years ago
Does that code handle the other texture loading because I know some of our AO and spec textures use grayscale to save size.
comment:6 by , 3 years ago
The bug is inside tex.cpp
, the code fails to an add alpha channel to a grayscale image. Even in case it's going to be converted to a color image:
if(transforms & TEX_ALPHA) { // add alpha channel if(bpp == 24) { dstSize = (srcSize / 3) * 4; t->m_Bpp = 32; } // remove alpha channel else if(bpp == 32) { return INFO::TEX_CODEC_CANNOT_HANDLE; } // can't have alpha with grayscale else { return INFO::TEX_CODEC_CANNOT_HANDLE; } }
follow-up: 8 comment:7 by , 3 years ago
(would argue it's not necessarily a bug, but would probably be nice to implement. That said, the ticket is named incorrectly, as the failure is very much not silent.)
comment:8 by , 3 years ago
Replying to wraitii:
(would argue it's not necessarily a bug, but would probably be nice to implement. That said, the ticket is named incorrectly, as the failure is very much not silent.)
Nope, it fails silently. So it's the bug.
When loading a greyscale png, the code of r12308 first tries to convert it to RGBA. But that silently fails.
tex.m_Flags
consists of onlyTEX_GREY
andTEX_TOP_DOWN
after thetex.transform_to
. Then the following heightmap import code still reads 3 channels per pixel, which results in an out of bounds read for the very last pixel.So it's something wrong with the texture conversion code, not with the atlas heightmap import code apparently.