BrendanO123 / GLFWMinecraftClone

An attempt to make a Minecraft clone in C++ with GLFW. Inspired by: https://github.com/EvanatorM/ScuffedMinecraft.git
MIT License
0 stars 0 forks source link

Mipmap textures for transparent blocks are way darker than their normal textures. #5

Open BrendanO123 opened 1 month ago

BrendanO123 commented 1 month ago

I was just playing around with the FOV of the camera and I noticed that zooming out on leaves, grass, and flowers that where far away made them noticeably darker. It appears like the mipmap texture on the block is causing the fragment shader to return black (instead of discarding the fragment) for pixels on the leaves that should be transparent. On closer inspection, the same seems to be happening to the billboard blocks. I am really not sure what to do about this as the sprite map is already RGBA and in the call to glTexImage2D() in the main function it is set to also store the texture in RGBA. Additionally, the mipmap is set to nearest mipmap, nearest pixel so it shouldn't be blending in the other pixels anyway.

BrendanO123 commented 1 week ago

The mipmap setting is now set to linear mipmap and nearest pixel, and the fragment shader now discards fragments with an alpha below an adjustable cut off. However, the transparent pixels on higher mipmap levels are still rendered as opaque, and the opaque (normal) pixels are still getting tinged towards black. I would like to figure out how to fix this color bleeding into the normal pixels, and the opacity bleeding into the transparent pixels. However, I am really not sure what to do about this.