Thursday, April 28, 2016

lighting - How does Minecraft render its sunset and sky?



In Minecraft, the sunset looks really beautiful and I've always wanted to know how they do it.


Do they use several skyboxes rendered over eachother? That is, one for the sky (which can turn dark and light depending on the time of the day), one for the sun and moon, and one for the orange horizon effect?


I was hoping someone could enlighten me... I wish I could enter wireframe or something like that but as far as I know that is not possible.


enter image description here



Answer



I'm going to gamble on the fact that you really want to know how to achieve a similar effect, and not specifically how Minecraft does it, which wouldn't be an on-topic question.



Do they use several skyboxes rendered over eachother? That is, one for the sky (which can turn dark and light depending on the time of the day), one for the sun and moon, and one for the orange horizon effect?



You don't need that much geometry -- a single skybox and some geometry for the sun/moon is sufficient. Skyboxes are generally rendered in such a fashion as to ensure they are always the same distance from the eye, thus giving them the "infinitely far away" effect. The same thing can be applied to the geometry for the sun and moon, except you'll also want to transform the sun and moon by some global time value.



That same global time value feeds in to the skybox effect, which can be done with a shader that modulates between day and night textures (or just colors if you want to be simple) based on the time.


To get the "orange glow" on the horizon you'll want to also modulate in some vertex (or pixel) colors on the textures. Atmospheric scattering and perspective play a large part in determining these effects in the real world, and several papers exist presenting various ways of simulating those variables in software. The paper A Practical Analytical Model for Daylight is one I've personally used and implemented (dead image links there, you'll want to make sure you get the PDF on the linked site).


The Virtual Terrain Project has a section of curated links to relevant papers as well.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...