mojira.dev
MC-258630

Moon is rendered too bright when it is lower in the sky

When the moon is lower in the sky, the moon is rendered brighter. When the moon is rising, it is noticeably brighter than its appearance when it is higher in the sky. This is the opposite behaviour of what actually happens for the real moon. The real moon is less bright when it is rising than when it is nearly overhead due to atmospheric extinction of light. An extreme case can be seen when the moon is seen low down in the void: the moon loses all its texture and appears like the sun.

The moon is rendered using the same rendering code as the sun. This is technically incorrect because the moon is not a self-luminous body. Instead of using the same rules for both, the moon should be darkened instead of lightened, and this adjustment should be based on the position of the sun (and not the moon). A simple 50% darkening of the colours of the moon should suffice when the sun is above the horizon (eg: 0xffffff white darkens to 0x7f7f7f) , with similar transition rules as the rendering of the sun uses.

To reproduce:
1. Create a superflat world (gamerule: doDayLightCycle = false).
2. Face east.
3. Set the time to 14500. -> The moon is higher in the sky and appears dimmer: this behaviour is correct.
4. Set the time to 12950. -> The moon is on the horizon and appears too bright. Compare to the appearance in the previous step.
5. Teleport to Y=320.
6. Look down.
7. Set the time to 6000. -> The moon appears below the player, and is so bright that it loses its finer texture and looks like the sun.

Attachments:

  • moon.png: shows the difference between moon at time=12950 and time=14500.

  • moon 6000.png: shows the moon below the player when the player is at Y=~300 in a superflat world.

  • moon 6000 possible fix.png: How the moon may look below the player when this is fixed. Created in Gimp by creating a sky-coloured background and superimposing a cropped image of the moon taken overhead, darkened with Curves by 50% and combining the layers in Addition mode.

  • moon 6000 possible fix.xcf: The Gimp file used to create the above.

This bug report was created at the request of a moderator on /r/mojira. The discussion of this issue can be seen here: https://www.reddit.com/r/Mojira/comments/zjonwq/request_to_reopen_mc45044_two_suns_because_the/

This is an old bug that was originally reported as MC-45044 (plus others), but that report was closed as "Working as intended" because the bug was not described very well.

Linked issues

Attachments

Comments 2

I can confirm this issue though idk it's intended or not.

Although this issue is currently marked as "won't fix", nevertheless I will post the findings of my investigation. Anyone choosing to fix this in the future will find this information useful, including mod makers.

The cause of the issue is an incorrect Open GL rendering mode when drawing the moon. When the moon is rendered, the source colour (the moon) is added to the destination colour (the sky) and this causes the colour to exceed 255, which is clamped to 255 by the rendering engine.

I created a test moon that had grey pixels ranging from 0 (black) to 255 (white), set this as the moon texture in a void world and set the time to 6000. Then I took a screenshot of the moon and examined a selection of pixels to determine what their colour was.

The following was found by testing in a void world where the sky color RGB is B8 D2 FF (hex).
PixelCol SkyPixel
00 00 00 | b8 d2 ff
10 10 10 | c8 e2 ff
20 20 20 | d8 f2 ff
30 30 30 | e8 ff ff
40 40 40 | f8 ff ff
50 50 50 | ff ff ff

The pattern is easy to see: the sky pixel is the sum of the pixel colour and the sky background, clamped at ff hex. This proves the OpenGL rendering options for the colours are similar to GL_ONE, GL_ONE (add destination to source without modification). This is acceptable for rendering the sun, but not the moon.

In principle, fixing this is simple. Change the OpenGL rendering of the colours for the moon to GL_ONE_MINUS_DST_COLOR, GL_ONE, and then change it back again (if needed) after the moon is rendered.

bdm68

(Unassigned)

Confirmed

Rendering

1.19.3

Retrieved