Skip to content

Improve rendering quality of imported images#11

Merged
flibber-hk merged 4 commits intosilksong-modding:mainfrom
kaycodes13:improvement/crisp-textures
Jan 2, 2026
Merged

Improve rendering quality of imported images#11
flibber-hk merged 4 commits intosilksong-modding:mainfrom
kaycodes13:improvement/crisp-textures

Conversation

@kaycodes13
Copy link
Copy Markdown
Contributor

This PR does two things to improve the quality of custom image assets when rendered in-game: prevents textures from generating mipmaps, and adds utilities for converting textures to the premultiplied alpha format.


First: Textures/sprites loaded with UnityHelper no longer generate mipmaps. The vast majority of image assets in Silksong don't generate mipmaps, so disabling mipmap generation for custom assets makes their appearance more consistent with existing assets when scaled up or down (for example, when the player changes their game's resolution).

For demonstration, here's a custom HUD asset shown at a lower in-game resolution. The top version has mipmaps turned on; the bottom has them turned off. Compare the clarity of the edges on the custom asset to those of the masks in the health bar.
mipmap_demo


Second: it adds two utility functions for premultiplying the alpha of an image, one for Sprites and one for Texture2Ds. Usage is simply myTexture.PremultiplyAlpha().

Unity expects the alpha format of pixels in its textures to have be premultiplied; but many image editing programs export in straight alpha format instead. This causes a lot of imported assets to have a white tint in areas of partial transparency, or a slight white halo around their edges. This can be fixed by manually converting the color data to have the correct alpha format.

For demonstration, the same custom HUD asset; the top version with straight alpha, the bottom with premultiplied alpha. Notice the white artifacts around the edges when it's in straight alpha format. (Open image in a new tab for higher resolution)
premultiply_demo

Comment thread UnityHelper/Util/SpriteUtil.cs
@flibber-hk
Copy link
Copy Markdown
Member

Looks good other than the one minor comment

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 this pull request may close these issues.

2 participants