CaffeineMC / sodium-fabric

A Minecraft mod designed to improve frame rates and reduce micro-stutter
Other
4.72k stars 808 forks source link

Smooth Lighting for emissive blocks #2653

Open MehVahdJukaar opened 1 month ago

MehVahdJukaar commented 1 month ago

Request Description

I noticed that the game only applies smooth lighting to blocks that dont emit light level. When placing say many lamps with light level 5 next to a torch emitting 15 one can clearly see each lamp block has a distinct "shading" to it, similar to how every block looks when smooth lighting is off. I think having this would be a flat visual improvements for all those blocks. Screenshot to explain my point. Note how each of those white blocks has a slightly different shade and the illumination isnt smooth on their surface

image

djmrFunnyMan commented 1 month ago

This is a vanilla issue https://bugs.mojang.com/browse/MC-225516 (though would be nice if sodium fixed it)

PepperCode1 commented 1 month ago

Changing this behavior for all blocks may break other mods that rely on it, but it is possible to force-enable AO on blocks that emit light using MaterialFinder#ambientOcclusion(TriState.TRUE) in FRAPI.

MehVahdJukaar commented 1 month ago

Well even with that on the effect isn't what one wants. It's ends up creating darker edges on the edge of the block as it blends it's light to neighboring lower light values blocks which looks bad for a block that is supposed to look all the same brightness throughout it's entire face. This is very likely why that was turned off

PepperCode1 commented 1 month ago

I don't understand what behavior you want then. The behavior of the FRAPI option is that it force-enables smooth lighting. You say you don't want light blending and say that the faces of these blocks should all have the same brightness but that is exactly what flat lighting does and what is seen in the original screenshot.

MehVahdJukaar commented 1 month ago

If a block emits light level 5 it should in theory have each quad have at least light level 5 thought its entirety. This is what vanilla does. Catch is when you place Brighter light sources next to it you will notice discontinuities. The probable reason why these don't have AO is because when blending Down they get darker edges, hence making my first statement not true. So lights like that to look best and proper should only blend up not down

IMS212 commented 1 month ago

This seems like a request for a FRAPI enhancement to separate ambient occlusion from smooth lighting? Vanilla makes no distinction between the two.

MehVahdJukaar commented 1 month ago

From what I know sodium has its own ambient occlusion code which fixes vanilla bugs too hence why I posted it here. I'm not sure but it could be that as you say It would mean somehow conceptually separating those two but I don't know too much about their internals so I can't say

IMS212 commented 1 month ago

Separating these two is definitely possible, even in Vanilla; it's just a question of whether that's in scope of FRAPI. If FRAPI adds it, Sodium will likely support it; so I'd recommend making an issue for that.

djmrFunnyMan commented 1 month ago

Well as far as I understand this is a suggestion of fix a vanilla bug (smooth lighting broken on light sources) That FRAPI has a somewhat related feature to force enable AO isn't really relevant

MehVahdJukaar commented 1 month ago

I'll suggest on fabric API tho I still believe could still be a nice visual improvement that fixes vanilla bug, akin to other similar sodium improvements

MehVahdJukaar commented 1 month ago

I did some testing and provided the AO light values of each vertices are capped to be AT LEAST the light value OF THAT block (given we are dealing with emissive blocks), just turning on AO for these blocks fixes all issues that are associated with that