azagaya / laigter

Laigter: automatic normal map generator for sprites!
https://azagaya.itch.io/laigter
GNU General Public License v3.0
905 stars 62 forks source link

Fix specular maps outputting black images when tile mode enabled #97

Closed lewiji closed 1 year ago

lewiji commented 1 year ago

Fixes #96

Specular modification wasn't taking into account the neighbours, generating a regular sized image, and so ImageProcessor::calculate_specular() was trying to crop the new specular image to the size it already was. Apparently, the CImg default behaviour without adding a boundary_conditions flag to crop() in this situation is to fill the image in with black (???)

I changed ImageProcessor::modify_specular() to use the same process as the parallax generation, i.e. use TextureTypes::Neighbours image if tileable, else TextureTypes::SpecularBase. This generates the bigger image for tile mode that can be successfully cropped, which fixes the black output image, and also correctly fixes up the edges of the specular map for tiling.

Since the heightmap is regenerated when update_tileable is set to true by tile mode properties being changed, I added calculate_specular() alongside it so specular is also updated.

azagaya commented 1 year ago

Thanks!