FalseTweaks

FalseTweaks

101k Downloads

[Visual]: Request to fix vanilla bug

DarianLStephens opened this issue ยท 21 comments

commented

OS

Windows

GPU

NVIDIA

Modpack (Optional)

No response

Game log

I don't think the log will help, considering it's a vanilla bug.

Description

Very hard lines between various bits of lighting along edges, especially noticeable in a white box.
2022-03-15_17 20 01
Close look to make it easier to see:
2022-03-15_17 23 38

It's only really noticeable in the dark, possibly entirely gone if in direct sunlight.
2022-03-15_17 24 24
It IS still visible at night, though.
2022-03-15_17 24 21

The bug is described in more detail, along with code examples and a fix, in this Mojang bug report:
https://bugs.mojang.com/browse/MC-43968

I know this isn't a bug with Triangulator, but I'm hoping it's something the mod might be able to fix given its fix of ambient occlusion.

commented

I don't know if this is related, but AO seems to have weird lines going through it, and a very abrupt end.
2022-03-15_17 30 15

I feel like it's meant to fade to 0 from the start, not seemingly half-way through.

commented

So i've looked into this rendering issue a bit further, it looks like an side effect of how vanilla minecraft calculates the combination of AO and changing light levels.

Currently, i have absolutely no idea how this could be fixed without rewriting the entire AO calculation logic of Minecraft (about 1200 lines of code)

commented

@FalsePattern Here's a fix I made for my private bugfix mod for MC-43968, not sure if it will fix this issue or not but you're welcome to use it/incorporate it if you'd like: https://gist.github.com/embeddedt/19e2c103841fac23145b0cf125268f73

It's essentially the fix described in the bug report but implemented using (very fragile) mixins instead.

commented

@FalsePattern Here's a fix I made for my private bugfix mod for MC-43968, not sure if it will fix this issue or not but you're welcome to use it/incorporate it if you'd like: https://gist.github.com/embeddedt/19e2c103841fac23145b0cf125268f73

It's essentially the fix described in the bug report but implemented using (very fragile) mixins instead.

so i've added your patch to triangulator, and all i can say is: wow
without your patch:
2022-06-01_17 08 17

with your patch:
2022-06-01_17 08 41

commented

YEAH!
I've wanted to see this thing fixed for literal years, and seeing it finally done is so awesome!

commented

I am quite curious about that 'private bugfix mod', though. I wonder what else is in there?

commented

While that specific staircase instance seems to be fixed, it unfortunately didn't help with the white wall.
2022-06-04_02 34 59
2022-06-04_02 35 10

I disabled all mods besides Triangulator, FalsePatternLib, and SpongeMixins.

commented

so i did some more digging, apparently the staircase and the wall bugs are completely separate.
the staircase glitch was caused by the AO code, while the blocky light is caused by the brightness smoothing code

The main difference is that in the AO bug, it was caused by an actual programming error, while it looks like the reason for the non-perfect smooth lighting is the fact that it uses ints instead of floats while calculating the per-vertex brightness (computing the light level instead of actual brightness values)

I'll try reusing the stuff i learned from embeddedt's AO fix code and attempt to fix this limitation

commented

image
i temporarily disabled AO with some test code to see smooth lighting without the AO adding noise, and yep, it's a smooth lighting bug 100%

commented

update:
image
image
image
i think it's fixed

commented

That's definitely way better, but I wonder if there's anything you can do about the strange lines?
It's like the brightness isn't being done properly, even if it's smoothed now.

commented

it's just an artifact from doing vertex-based lighting and the gpu doing linear interpolation. This is the best we can get without a full renderer overhaul.

It's practically not noticeable ingame thanks to the visual noise added by textures.

commented

I just wanted to see how far back these issues ran, and...
2022-06-04_04 42 42
I did not think they were present all the way back here!

I'll need to do a bit of survival to test it in earlier versions, but I could have sworn there was a point where it was okay, maybe even closer to the initial implementation of the Smooth Lighting mod?

commented

Okay, so, Beta 1.7.3 seemed okay.
2022-06-04_05 01 34

However, even that suffered from the directional AO problem! I never noticed it back then!
2022-06-04_05 01 46
I guess it's just one of those things that's always been there, and you can't unsee once you notice it, huh?

Also holy moly the FPS in these older versions!

commented

Is it possible to disable that interpolation you mentioned, or is it a consequence of how GPUs work?

commented

it's a fixed behaviour of GPUs, where data between the vertices of a triangle get interpolated linearly. This is how you can have textures, for instance, because the x/y coordinates of the texture gets interpolated across the whole triangle.

commented

I am quite curious about that 'private bugfix mod', though. I wonder what else is in there?

I have a lot of miscellaneous bugfixes for issues I'm encountering while playing 1.7. The main reason I've kept it private is because they are very untested and some of them might even be questionable. I also sometimes add experimental fixes that end up causing glitches in the world that are hard to revert (e.g. partially ungenerated structures), and I wouldn't want users' worlds to be corrupted by bugs I introduce. 1.7 is also even less popular than 1.12, itself a largely abandoned version.

Also, I cannot take credit for all of these fixes; some of them (including the AO fix) are based on the many pointers TheMasterCaver has left in his various forum posts and/or other players' code analyses in Mojira bug reports.

commented

The underwater bug is caused by the faster fall-off of lights, while the smooth lighting logic is coded for 1 light level per block falloff, can't really do anything about that

As for the non-full block rendering, it's implemented in completely different parts of the code i haven't read yet.

I might look into these in the future, but triangulator is low priority for the time being, i need to focus on some private projects for a few weeks

commented

Hey, sorry to bring this up again, but it seems that some non-full blocks have weird AO or smooth lighting, as well.
2022-06-08_06 22 34

Farmland is a vanilla example:
2022-06-08_07 13 34
2022-06-08_07 13 36

Another problem is present underwater, too:
2022-06-08_07 14 34

commented

I know you're not back yet, but I want to document this in case it helps once you are.
I've discovered something rather interesting about the non-full-block AO.

This is with Triangulator installed:
2022-06-10_06 45 18

And this is after removing Triangulator:
2022-06-10_06 49 43

commented

Also, thanks to some lighting error, I have a much better example of the directional bias in smooth lighting, a similar thing which you corrected (For the most part) in AO with your predictive triangle switching stuff:
2022-06-10_06 58 58