mojira.dev
MC-58177

Night vision rendered darker and orange when nearing light sources with brightness on moody

The bug

When exploring mineshafts using night vision, I found that the blocks nearing light sources always become darker and more orange. But the block just beside the light source is normal.

How to reproduce

  1. Set brightness in video options to minimum

  2. Make/Go to a place with light level 0. (Note: It does something else if exposed to sky, but still looks weird though.)

  3. Get Night Vision effect.

  4. Place any kind of light source.

  5. The blocks near but not beside the light source are rendered darker. (Note: Lava blocks and Fire blocks are rendered too dark too!)

New founds added 6/24:

Finally I got the idea why night vision looks weird under night sky. I found a ravine with a hole above it, and compare to the non exposed area, the place under the night sky are extremely blue.

How to reproduce

  1. Set brightness in video options to minimum

  2. Make (since it's a little difficult to find) a huge (at least 30x10x30) room with light level 0. (Suggested that use stone with some lapis ores)

  3. Get Night Vision effect.

  4. Make sure it's night time in game.

  5. Break a hole on the roof.

  6. Enjoy! Don't forget to try Fire blocks, they look FUNNY!! (?! Just kidding XD)

Code analysis

Code analysis by @unknown can be found in this comment.

Related issues

Attachments

Comments

migrated
[media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media]
migrated

Is your Java already the latest Java, if it is please add it to the "Java 7" in your environment.

migrated

can confirm with brightness on minimal

kumasasa

Somewhat confirmed with brightness on minimum.

migrated

Lava blocks and Fire blocks also have REALLY WEIRD dark blue color! :I

migrated

Confirmed for 14w26a and b

migrated

Still a concern in 14w27a and 14w27b.

kumasasa

Is this still an issue in 14w30c ?

migrated

Yes~ It still works for me

Sonicwave

Still an issue up to 1.8.2-pre1.

migrated

Can confirm for 1.11. Easiest to see with moody brightness and smooth lighting off.

migrated

The issue appears to be that some values can be outside of the range expected by the night vision effect code.

Fix is easy, just requires moving the code in EntityRenderer.updateLightmap() a little:

private void updateLightmap(float partialTicks)
{
	// ...
	
	// move this block from here ---
	if (this.mc.player.isPotionActive(MobEffects.NIGHT_VISION))
	{
		float f15 = this.getNightVisionBrightness(this.mc.player, partialTicks);
		float f12 = 1.0F / f8;

		if (f12 > 1.0F / f9)
		{
			f12 = 1.0F / f9;
		}

		if (f12 > 1.0F / f10)
		{
			f12 = 1.0F / f10;
		}

		f8 = f8 * (1.0F - f15) + f8 * f12 * f15;
		f9 = f9 * (1.0F - f15) + f9 * f12 * f15;
		f10 = f10 * (1.0F - f15) + f10 * f12 * f15;
	}

	if (f8 > 1.0F)
	{
		f8 = 1.0F;
	}

	if (f9 > 1.0F)
	{
		f9 = 1.0F;
	}

	if (f10 > 1.0F)
	{
		f10 = 1.0F;
	}
	
	// to here ---

	float f16 = this.mc.gameSettings.gammaSetting;
	float f17 = 1.0F - f8;
	float f13 = 1.0F - f9;
	float f14 = 1.0F - f10;
	f17 = 1.0F - f17 * f17 * f17 * f17;
	f13 = 1.0F - f13 * f13 * f13 * f13;
	f14 = 1.0F - f14 * f14 * f14 * f14;
	f8 = f8 * (1.0F - f16) + f17 * f16;
	f9 = f9 * (1.0F - f16) + f13 * f16;
	f10 = f10 * (1.0F - f16) + f14 * f16;
	f8 = f8 * 0.96F + 0.03F;
	f9 = f9 * 0.96F + 0.03F;
	f10 = f10 * 0.96F + 0.03F;
	
	// ...
}
migrated

Confirmed for 1.13.1.

migrated

Confirmed for 1.14-prerelease-5

Silicon42

Confirmed for 19w42a. It also affects the UI, color now, tinting it blue and darkening it. Should I make a separate bug report for that?

[Mod]Les3awe

@@unknown, 19w42a is this ticket MC-161849.

tryashtar

Is this fixed in 19w45a? It's hard for me to tell 😛

TheBoy358

Yeah it seem to be fixed in 19w45a for me.

TheBoy358

Still fixed in 19w45b.

migrated

this seems to be a glitch in 1.18!

[media]

migrated

(Unassigned)

Confirmed

Lighting, Rendering

brightness, color, light, night-vision, rendering

Minecraft 14w25b, Minecraft 14w26b, Minecraft 14w26c, Minecraft 14w27a, Minecraft 14w27b, ..., Minecraft 1.14.2, 1.14.4, 19w35a, 19w42a, 19w44a

19w45a

Retrieved