Skip to content

Add smoothBlend functionality to crispBlend for transparent texture mipmaps#1104

Open
TorutheRedFox wants to merge 1 commit intosmartcmd:mainfrom
TorutheRedFox:transparent-mipmap-fix
Open

Add smoothBlend functionality to crispBlend for transparent texture mipmaps#1104
TorutheRedFox wants to merge 1 commit intosmartcmd:mainfrom
TorutheRedFox:transparent-mipmap-fix

Conversation

@TorutheRedFox
Copy link
Contributor

Description

Fixes water opacity in default texture pack, making it no longer fully opaque when mipmaps kick in.

Changes

Previous Behavior

Water was fading to opaque due to crispBlend destroying texture alpha in mipmaps.

Root Cause

This seems to be a long standing bug in LCE because they used Notch's crispBlend algorithm to blend texels when calculating mipmaps in realtime, which is intended for cutout textures, not transparent textures. Java edition scrapped the generation of mipmaps for a good while, but in its unused implementation it used smoothBlend to calculate the mips for textures that were supposed to be transparent, i.e. water. This PR just merges their functionality based on the detected alpha value of the pixels.

New Behavior

Transparent textures such as water keep their transparency in their mipmaps.

Fix Implementation

If both pixels involved in the blend operation have an alpha value less than 224, they'll be treated as transparent and the smoothBlend algorithm is used to blend the pixels instead, preserving the alpha in the process. If either pixel has an alpha value of 224 or more, crispBlend blends them as normal to avoid losing detail in cutout textures.

AI Use Disclosure

No AI was used in the making of this code.

@TorutheRedFox
Copy link
Contributor Author

Video of how water now looks

2026-03-10.10-37-59.mp4

@codeHusky
Copy link
Collaborator

That does look a lot better. Was this particular bug ever fixed in LCE in like a future TU?

@TorutheRedFox
Copy link
Contributor Author

i don't recall it ever getting fixed

@codeHusky
Copy link
Collaborator

While this does look better to me, if this is a departure from how LCE has historically looked it should be a setting to enable the fix rather than having it default on.

@TorutheRedFox
Copy link
Contributor Author

i'd need some assistance with the swf modding then

@DeanLemans
Copy link

Could we get some before vs now photos?

@TorutheRedFox
Copy link
Contributor Author

when i get home :P

@mattsumi
Copy link
Collaborator

when i get home :P

I'd love to see this if this is still available.

@TorutheRedFox
Copy link
Contributor Author

when i get home :P

I'd love to see this if this is still available.

oh sorry i completely forgot lmao

@TorutheRedFox
Copy link
Contributor Author

here's an image comparison

image image

note how the water remains transparent all the way to the horizon

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.

4 participants