(The bug can be avoided by never using image interpolation)
---
While working on a renamed and refurbished material_map{} feature for
the yuqk fork, ran across a bug where non-indexed / non-palette image
was - by numerical noise - sometimes slipping into an indexed state of 0
when interpolation was used. This happening no matter whether the base
image was indexed or not.
The bug traced to two functions in imageutil.cpp called
InterpolateBicubic() and Interp(). These are general routines so the
exposure touches any code which looks at the calculated 'index' value to
decide later actions.
The fix I used was to apply rounding rather than a cast to int when
returning the index value - which is always calculated alongside the red
/ grey color channel. (Yes, the index values themselves are interpolated
too for actual indexed images)
---
In InterpolateBicubic() change:
*index = (int)tempIndex;
to:
*index = (int)std::lround(tempIndex);
---
In Interp() change:
*index = (int)temp_index;
to:
*index = (int)std::lround(temp_index);
Find attached a sample scene for v3.8 beta 2 and an image where the top
portion shows noise from the bug and the bottom being the yuqk fork's
current output for the same set up with the fixes above applied.
Bill P.
Post a reply to this message
Attachments:
Download 'image_indexed_textures_v38.pov.txt' (2 KB)
Download 'material_map_bug.jpg' (198 KB)
Preview of image 'material_map_bug.jpg'
|