collinsmith/riiablo

Tiles drawn with white pixels

Opened this issue · 4 comments

Noticed this issue on the latest version of Android where the 0 index on tiles shows up as white, even though glClearColor is set to black. Only occurs on acts 3-5 so far from what I've seen. This did not used to happen on older versions of Android, and does not occur on PC.

Tiles have always been drawn incorrectly where index 0 is transparent, and since the background is black and index 0 is black, it hasn't mattered, but something with the newer OpenGL ES may be effecting this behavior. I have a special draw setting for tiles that should draw index 0 as black, it might not be enabled, or the palettes might need to be looked at. Another possibility is the transparency draw call, i.e., are the tiles being drawn on the newer version of android as opaque, causing white pixels because it can't blit them correctly.

Screenshot_20210119-160529_Riiablo

I spoke too soon. The issue appears in all acts, just much less noticable. aside from the background color not matching black like on desktop, this looks like an index is mismatched. need to look into the specific index and pixel shader

Experimented using different blend mode and still got the same behavior.

Playing with the palettes directly shows that this appears to be an issue with index 254 across at least act 1 and 3 (the only ones that I've tested). The working assumption is that for some reason this value gets rounded up to index 255, which is white. Going to play around with texture filtering and wrapping and if need be, clamping the 0.5f offset to prevent a possible unwanted rounding because 254 is close enough to 2^8 (256).

Texture filtering looks alright -- I assigned the renders to the default values. My guess is that this is caused by some rounding issue relating to the pixel (frag) shader for the upper index. This will require more extensive investigation to a more permanent suitable fix, however in the meantime I've added a workaround to the shader to translate index 255 to index 254 which has had no apparent side effects (have not tested or looked for legitimate uses of index 255). I'm uncomfortable with this fix until I can figure out why this is happening in only newest version of android.

Index 255 is the same in every included palette (0xFFFFFF). I'd like to look through all included files and see if it's ever actually used -- many palettes with a white color seem to define it elsewhere in their table -- so it may just not ever be used, or it has some other meaning like index 0, or acts as a signature/terminator for palettes. In any case, this appears to be suitable workaround until this can be explorer further.