Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable premultiplied alpha when mipmapping illumination textures #3

Open
osreboot opened this issue Oct 24, 2023 · 1 comment · May be fixed by #4
Open

Disable premultiplied alpha when mipmapping illumination textures #3

osreboot opened this issue Oct 24, 2023 · 1 comment · May be fixed by #4

Comments

@osreboot
Copy link

osreboot commented Oct 24, 2023

Just wanted to say that this is a great tool, and I used it extensively during the recent 20th anniversary contest.

Unfortunately, I noticed an issue with the mipmap generation for the self-illumination textures (BC3, ending in "_I"). In TM2020, the self-illumination alpha channel value of zero encodes to brake lights, however the color information in fully transparent regions doesn't seem to exist in lower-level mipmaps generated by this tool. Practically, this means that when exporting the default game illumination file for car details, the brake meter on the front wheels is missing unless the camera is really close to the car.

Example file with consistent RGB rows and horizontally varied alpha value:

First mipmap generated by GIMP BC3 .dds export (expected):
image

First mipmap generated by this tool:
image

I believe this is due to using premultiplied alpha for all mipmap generation, which can destroy RGB data for pixels with an alpha of zero. NVTT's sample code recommends avoiding premultiplication for textures where the alpha channel represents non-transparency material data. Because you're already using file suffixes to automatically determine the compression type, it seems like you could also use this to disable premultiplied alpha when mipmapping illumination textures.

I need C++ practice and I'd love to implement this change myself if you think it's appropriate!

@bozbez
Copy link
Owner

bozbez commented Oct 24, 2023

Yeah go for it, I'd make a small helper class that wraps nvtt::Format and a premultiply alpha bool and move GuessFormat and FormatToString into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants