mojira.dev
MC-43968

Smooth lighting no longer works properly in certain block configurations

NOTE: the following fix pertains to 1.7, an updated version will be needed for 1.16+

Let me first off say that I know this is a duplicate, but I have code-fixes for it.

As you can see in the 2 images, the first one (The bugged version), has inconsistent lighting travelling from one block to the next, the corners don't match up. This is primarily noticeable in 1 wide staircases underground, and for good reason.

Basically what is happening is that the render code is checking the transparency of blocks with an incorrect offset. When you get your coordinates wrong you're bound to get some weird results.

This code is drawing the bottom face.

if (this.renderMinY <= 0.0D)
{
     --y;
}

this.aoBrightnessXYNN = par1Block.getMixedBrightnessForBlock(this.blockAccess, x - 1, y, z);
this.aoBrightnessYZNN = par1Block.getMixedBrightnessForBlock(this.blockAccess, x, y, z - 1);
this.aoBrightnessYZNP = par1Block.getMixedBrightnessForBlock(this.blockAccess, x, y, z + 1);
this.aoBrightnessXYPN = par1Block.getMixedBrightnessForBlock(this.blockAccess, x + 1, y, z);
this.aoLightValueScratchXYNN = par1Block.getAmbientOcclusionLightValue(this.blockAccess, x - 1, y, z);
this.aoLightValueScratchYZNN = par1Block.getAmbientOcclusionLightValue(this.blockAccess, x, y, z - 1);
this.aoLightValueScratchYZNP = par1Block.getAmbientOcclusionLightValue(this.blockAccess, x, y, z + 1);
this.aoLightValueScratchXYPN = par1Block.getAmbientOcclusionLightValue(this.blockAccess, x + 1, y, z);
transparencyXYPN = Block.canBlockGrass[this.blockAccess.getBlockId(x + 1, y - 1, z)];
transparencyXYNN = Block.canBlockGrass[this.blockAccess.getBlockId(x - 1, y - 1, z)];
transparencyYZNP = Block.canBlockGrass[this.blockAccess.getBlockId(x, y - 1, z + 1)];
transparencyYZNN = Block.canBlockGrass[this.blockAccess.getBlockId(x, y - 1, z - 1)];

if (!transparencyYZNN && !transparencyXYNN)
{
     this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXYNN;
     this.aoBrightnessXYZNNN = this.aoBrightnessXYNN;
}
else
{
     this.aoLightValueScratchXYZNNN = par1Block.getAmbientOcclusionLightValue(this.blockAccess, x - 1, y, z - 1);
     this.aoBrightnessXYZNNN = par1Block.getMixedBrightnessForBlock(this.blockAccess, x - 1, y, z - 1);
}

What it does is decrements the y value to save a bunch of subtractions since the whole next section uses "y - 1". It appears as if in the case of every face, a part was left as "y - 1" (Or any other respective coordinate changes such as "y + 1", "x - 1", "x + 1", "z - 1", "z + 1").

transparencyXYPN = Block.canBlockGrass[this.blockAccess.getBlockId(x + 1, y - 1, z)];
transparencyXYNN = Block.canBlockGrass[this.blockAccess.getBlockId(x - 1, y - 1, z)];
transparencyYZNP = Block.canBlockGrass[this.blockAccess.getBlockId(x, y - 1, z + 1)];
transparencyYZNN = Block.canBlockGrass[this.blockAccess.getBlockId(x, y - 1, z - 1)];

The way I was able to fix this was by adding 3 ints at the top of the method called xConst, yConst, zConst (or more appropriate names), set those to the coordinates passed into the function and changed the code to

transparencyXYPN = Block.canBlockGrass[this.blockAccess.getBlockId(x + 1, yConst - 1, z)];
transparencyXYNN = Block.canBlockGrass[this.blockAccess.getBlockId(x - 1, yConst - 1, z)];
transparencyYZNP = Block.canBlockGrass[this.blockAccess.getBlockId(x, yConst - 1, z + 1)];
transparencyYZNN = Block.canBlockGrass[this.blockAccess.getBlockId(x, yConst - 1, z - 1)];

This bug is both aesthetically unpleasing, but also causes the "Lava light leaking through corners" bug.

Also, while I was looking through the rendering code, I found the source of the upside-down half-slab lighting bug. A half-slab gets lit using the highest of the neighbour's light values, but it doesn't check the light value of the block below.

topBrightness = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2, par3 + 1, par4);
eastBrightness = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2 + 1, par3, par4);
int westBrightness = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2 - 1, par3, par4);
int northBrightness = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2, par3, par4 + 1);
int southBrightness = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2, par3, par4 - 1);

if (eastBrightness > topBrightness)
{
	topBrightness = eastBrightness;
}

if (westBrightness > topBrightness)
{
	topBrightness = westBrightness;
}

if (northBrightness > topBrightness)
{
	topBrightness = northBrightness;
}

if (southBrightness > topBrightness)
{
	topBrightness = southBrightness;
}

return topBrightness;

The first idea that comes to mind is to push this code into the Block class so that it can be overloaded in child classes such as slabs.

Linked issues

Attachments

Comments 29

This is still a concern in 1.8.1-pre3. Old bug, but still present. I recently made a report about a different issue with ambient occlusion... Best fix is to start from scratch.

Still a concern in 1.8.2.

Still a concern in 1.8.4. Added a screenshot showing a much more noticeable example.

[media]

[media]


Confirmed for 17w47b

19 more comments

Either this bug or MC-148689 is still present in 26.1.2 and 26.2 Snapshot 5.

This is also happening in since 26.2-pre-2 up until 26.2-pre-6 MC-308740

2026-06-12_19.40.10.png
2026-06-12_19.41.18.png
2026-06-12_19.35.44.png
2026-06-13_14.26.16.png
2026-06-13_14.27.09.png
2026-06-13_14.38.03.png
2026-06-12_16.37.44.png
2026-06-12_16.37.31.png
2026-06-12_16.37.02.png
2026-06-12_19.48.12.png
2026-06-12_16.38.47.png
2026-06-12_16.40.58.png
2026-06-12_16.41.07.png
2026-06-13_14.31.03.png
2026-06-13_14.31.09.png
2026-06-13_14.39.13.png
2026-06-13_14.38.11.png
2026-06-13_14.39.02.png
2026-06-13_14.38.58.png
2026-06-13_14.38.27.png

The following screenshots here are from 26.2-pre-5, 26.2-pre-6, 26.2-rc-1 and then in 26.2-rc-2

I hope this gets a lot of attention to be immediately fixed

i did this in 26.2-rc-2 and seems like MC-138211 and MC-148689 might have the same issues here i think maybe and i started my own: MC-308740 not realizing these things exist

2026-06-13_16.10.14.png
2026-06-13_16.10.22.png
2026-06-13_16.10.26.png
2026-06-13_16.10.32.png

muzikbike

(Unassigned)

Confirmed

Platform

Normal

Lighting, Rendering

rendering, smooth-lighting, smooth-lighting-interpolation-incorrect, smooth-lighting-not-smooth

Minecraft 1.7.4, Minecraft 1.8.1-pre3, Minecraft 1.8.2, Minecraft 1.8.4, Minecraft 15w42a, , 22w16b, 23w44a, 1.21.5, 1.21.11, 26.1.2

Retrieved