Willard21 / MineKhan

Minecraft for Khan Academy
78 stars 52 forks source link

[Feature Request] Mipmapping #87

Open MicrolemurDev opened 2 years ago

MicrolemurDev commented 2 years ago

While technically a map is generated due to how WebGL works, it would be helpful to have mipmapping levels like Minecraft does. This is just a QoL feature that just is a bit of eye candy without killing FPS (It just increases Video RAM requirements)

Mist-Stego commented 2 years ago

Mipmapping levels could be good, but it would be a burden on people who do not have a dedicated graphics card. I think that Willard could consider it if he made requirements to play, but my laptop at the moment has almost no VRAM and a 7 year-old i5 intel processor. You can (probably) see where I am going with this 🤣

Willard21 commented 2 years ago

I have no idea what Minecraft's mipmap levels do. Mipmapping is already enabled, and it only brings the texture size from 262KB to 393KB. Mipmapping is either on or off. If it's on, then it generates textures at 8x8, 4x4, 2x2, and 1x1 to match the original 16x16 texture. Then if the texture is being drawn on the screen super far away, it'll use the mipmap level that's closest to the rendered size. image

MicrolemurDev commented 2 years ago

Yeah I looked at the code and found that mipmapping is used. I don't know how this would be implemented though.

Willard21 commented 1 year ago

I heard that there's some texture bleeding for some people. I read that generating my own mipmaps could fix that, but it still wouldn't be a customizable setting since WebGL requires mipmaps to be defined for all levels down to 1x1.

MicrolemurDev commented 1 year ago

For the texture bleeding you could also attempt to use texture arrays over a texture atlas if you are willing to upgrade to WebGL2 (caniuse.com suggests ~90% of systems support WebGL2, with texture arrays being a feature of it).

For my improved mipmapping suggestion you might be able to try build a translucent shader pass which would allow you to use filtering on the non-translucent textures (playing around with a modified version of the codebase based upon the KA version shows artifacts when using filtering on translucents but not on blocks with no transparency). Albeit, this is not an ideal solution but it is one option if you are looking to also do some post-processing effects on the transparent textures and are fine with using an additional texture unit.

TLDR; Texture arrays could help texture bleeding, and texture filtering is a complex issue.