Skip to content

Conversation

@mc-saw
Copy link
Contributor

@mc-saw mc-saw commented Oct 28, 2025

Normally to reduce aliasing in games mip maps are used, but mip maps increases the amount of texture memory used with around 50%. Another way to get the same effect as mip maps is to sample the texture 4 times and take an average of the color value. This solution works good on web devices where we would like to minimize the used memory. To the users who want this type of anti aliasing they can set the compile flag -D anti_aliasing in their build.hxml and also set the runtime flag globals.set("global.antiAliasing", 1);.

@mc-saw mc-saw force-pushed the anti-aliasing-texture branch from 2787219 to c8987c9 Compare October 31, 2025 09:52
@BorisRaymondPerier
Copy link

This is not technically an antialiasing but a texture filtering technic, so it should not be activated with an antialiasing flag.
And I think it shouldn't be integrated in a generic texture shader while it's really a custom approximation of a runtime mipmapping that only works on its first level.

@lbergman
Copy link
Contributor

The reason for putting it at texture level is that this becomes a problem with all textures with some browser window sizes on some resolutions. For example if I open a game on my 42" 4K monitor with device pixel ratio of 1:1, and scale down browser to only use a part of the screen, aliasing becomes really bad.
On devices with a high device pixel ratio, like mobile devices or many desktop screens with OS Scaling, it is not an issue, so we like to enable it in runtime when it is actually needed.

I agree that ideally it would be a separate shader, but not sure if there is a nice way to add a shader to all textures?

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.

3 participants