Skip to content

Fix ambient occlusion in non-terrain block rendering fixes #3780#3795

Merged
douira merged 1 commit into
CaffeineMC:devfrom
meta-legend:fix-#3780
Jul 2, 2026
Merged

Fix ambient occlusion in non-terrain block rendering fixes #3780#3795
douira merged 1 commit into
CaffeineMC:devfrom
meta-legend:fix-#3780

Conversation

@meta-legend

Copy link
Copy Markdown
Contributor

Fixes #3780

The Fabric non-terrain block renderer was receiving the ambient occlusion setting through the constructor but wasn't applying it to the block's lighting state. Because of that, moving/non-terrain blocks could use flat lighting when they were supposed to use the smooth AO lighting, making them render too dark.

I can't reproduce the lighting issue with the setup from #3780 with the new fix, so it seems good.

@douira

douira commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Does this also fix #3594? I made a patch to potentially fix that issue, which affects the same lines of code, but I was unsure about it's correctness in all situations.

@meta-legend

Copy link
Copy Markdown
Contributor Author

I think it should

@meta-legend

Copy link
Copy Markdown
Contributor Author

I looked at your patch, and the diff between yours and mine is that mine makes it so that moving light-emitting blocks don't get AO, while in yours they could get AO, but only if the quad explicitly sets AO to TriState.TRUE.

@douira douira requested a review from IMS212 July 1, 2026 23:55
@meta-legend

Copy link
Copy Markdown
Contributor Author

my fix could be modified further if you removed the "&& this.defaultAo" inside the else block of the processQuad method of the NonTerrainBlockRenderContext class to mimic the functionality of your patch if you wanted it to

@douira

douira commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Would that improve the situation? I'm not sure what this code does or what defaultAo is for.

@meta-legend

Copy link
Copy Markdown
Contributor Author

My code makes it so the tesselateBlock method actually uses the global AO provided by the constructor. this.defaultAo is true when Ambient Occlusion is enabled globally in the context and if the block doesn't emit light. Removing this.defaultAo would allow light-emitting blocks that are rendered through the NonTerrainBlockRenderContext to get AO if TriState.TRUE is passed through the method. If you keep it, they will never get AO even if TriState.TRUE is passed through the processQuad method.

@douira

douira commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Removing this.defaultAo would allow light-emitting blocks that are rendered through the NonTerrainBlockRenderContext to get AO if TriState.TRUE is passed through the method.

So doing this is necessary for correctness?

@meta-legend

Copy link
Copy Markdown
Contributor Author

It depends on if the intended functionality for TriState.TRUE is to force AO no matter whether a block is emitting light or not. If it is, then i could remove it.

@douira

douira commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

I don't know what the intended functionality of this code is. I'll try to find out from other people.

@douira

douira commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Well it turns out nobody knows what this code is supposed to be doing. So I'll just merge this and if it breaks we can look into it again. Thanks for taking the time to work through this.

@douira douira merged commit ceca5f7 into CaffeineMC:dev Jul 2, 2026
1 check passed
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.

moving blocksare very dark in some situations

2 participants