Volumetric coloring of fog, based on sun / moon & horizon color

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Volumetric coloring of fog, based on sun / moon & horizon color

by MirceaKitsune » Wed Jun 26, 2013 14:30

Before anyone gets upset, I'm not blindly suggesting copying things from Minecraft to Minetest. This is a feature which highly enhances immersion and environment, and regardless that I noticed it in MC or any other project that's the only reason I'm suggesting it for. On topic:

Like Minetest, Minecraft has fog covering the draw distance limit. Unlike Minetest however, it has a fantastic addition: Fog color is radially influenced by the sun and moon. In any direction you look, the fog is colored the same as the horizon, and brighter around the sun and moon. This is a huge visual enhancement, and makes the environment look a lot more beautiful and real. I'd love to see Minetest get this too.

Here's how Minetest's and fog and sky look like at sunset... very dull and simple:

Image

Now here's what Minecraft does instead:

Image

Image

Image

Again, this is not saying "copy everything Minecraft has". But I think no one can deny the sky + fog setup in MC is a ton more colorful, vivid and realistic, nor that it's something we want too. Some of it is just better sky coloring, but I think most of the beauty is due to the selective fog color.

Does Irrlicht support coloring distance fog in a volumetric manner? Can Minetest's architecture allow this so far?
Last edited by MirceaKitsune on Wed Jun 26, 2013 14:35, edited 1 time in total.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Wed Jun 26, 2013 14:46

Currently Minetests fog uses the color of the sky, so its exactly the color of the horizon.
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Wed Jun 26, 2013 14:46

That would be a very good thing to add to Minetest. Are you able to code it?
Last edited by Inocudom on Wed Jun 26, 2013 14:47, edited 1 time in total.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Wed Jun 26, 2013 15:10

Sunset/sunrise really seems much more impressive in Minecraft. If it could be improved in Minetest, that would be great. There where some screenshots with a real sky as background at night, but I was told that that worked only in very old versions. Perhaps that could be made to work again as well?
A list of my mods can be found here.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Wed Jun 26, 2013 15:14

RealBadAngel was working on a skydome, so we probably have to wait for him to finish it.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Wed Jun 26, 2013 17:31

PilzAdam wrote:Currently Minetests fog uses the color of the sky, so its exactly the color of the horizon.


Yes it does. But the fog has the same color everywhere. The magic Minecraft does is that if you look at the sun during sunset / sunrise, fog is orange. If you look behind however (where the moon is rising), fog is blue. Fog needs to be red at sunset / sunrise in front of the sun, and more white in front of the moon when it sets / rises, otherwise horizon color.

PilzAdam wrote:RealBadAngel was working on a skydome, so we probably have to wait for him to finish it.


Like I told RBA, I don't agree with the skydome concept. If I remember right, the sky dome is an inside-out mesh attached to the player. Although I appreciate all of his works, that's something I'd be scared to see upstream. As a mod it's ok if anyone wants it.

Only way I'd agree with it is if the sky dome can be generated dynamically in the code and customizable (no mesh files). Also if it has unlimited distance like most cubemap / spheremap skies, instead of being a huge floating half-sphere that follows the player around. Personally, I'd like to see abilities to texture the sun, moon, and horizon at sunset... I find the current sky system itself good.
Last edited by MirceaKitsune on Wed Jun 26, 2013 17:32, edited 1 time in total.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Wed Jun 26, 2013 17:47

From what I read in the code so far its only possible to set one color for the fog, I might be wrong, though.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Wed Jun 26, 2013 17:53

PilzAdam wrote:From what I read in the code so far its only possible to set one color for the fog, I might be wrong, though.


Minetest doesn't have any of this yet, so it depends on what Irrlicht allows whether or not it can be added easily. At worst though it should be possible to do it with shaders... but I'm not sure even about that to what extent it would work.
 

User avatar
BlockMen
Member
 
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen

by BlockMen » Wed Jun 26, 2013 19:14

MirceaKitsune wrote:Before anyone gets upset, I'm not blindly suggesting copying things from Minecraft to Minetest.


There are still alot good things we can take from MC, so nothing to get upset.
And a really good suggestion. It looks great at MC.

PilzAdam wrote:From what I read in the code so far its only possible to set one color for the fog, I might be wrong, though.


Then it may not be too hard to change the fog color at sunrise/sunset and moon. That would be a great improvement IMO
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Wed Jun 26, 2013 19:44

BlockMen wrote:
PilzAdam wrote:From what I read in the code so far its only possible to set one color for the fog, I might be wrong, though.


Then it may not be too hard to change the fog color at sunrise/sunset and moon. That would be a great improvement IMO

The fog color already changes on sunset/sunrise, the problem is to change only the part that is in the direction of the sun/moon.
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Wed Jun 26, 2013 20:25

What all is RealBadAngel working on? If any of you are able to, you could assist him.
Last edited by Inocudom on Wed Jun 26, 2013 20:25, edited 1 time in total.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Thu Jun 27, 2013 23:01

Brought this up on IRC. PilzAdam suggested a simpler technique, which although of less quality would be easy to do: Instead of setting a different fog color in each direction, we could change fog color dynamically based on where the player is looking.

So if the sun is setting and the moon is rising; When the player looks into the sun, fog is a bright orange. When the player is looking into the moon, fog is a brighter pale blue. When looking at neither, fog is the horizon color (same as currently). Of course colors gradually fade in between.

This should be very simple to do, but yields one issue: What if a client's FOV is so big (for some reason) that it covers 90* of the sky? One would notice that fog is the same everywhere and only changes based on where you're looking. Still, I assume it should look good enough.

If anyone can point out where fog color is set in the Minetest code, I might give this a try myself. As long as I'm able to read daytime and player view angles within that function, and detect how close the crosshair is to the sun and moon.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Thu Jun 27, 2013 23:57

MirceaKitsune wrote:Brought this up on IRC. PilzAdam suggested a simpler technique, which although of less quality would be easy to do: Instead of setting a different fog color in each direction, we could change fog color dynamically based on where the player is looking.

No, I did not. It was celeron55.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Fri Jun 28, 2013 09:56

PilzAdam wrote:No, I did not. It was celeron55.


My mistake. Anyway the idea sounds good, at least until someone can figure position coloring for fog later on.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Fri Jun 28, 2013 17:24

I've started working on this today. Found a way to read the player's Pitch and Yaw from sky.cpp, and SunColor + MoonColor are already existent in Sky::Render where this code fits like a glove. Only thing left to do are the maths, which replace horizon + fog color with sun / moon color gradually, the more you look into the sun or moon.

The formula I'm aiming at is: If sun or moon aren't in your view, you see the normal fog color. The more the sun or moon is visible, the more fog color changes to reflect that. When you look straight into the moon or sun, fog color becomes its color.

Normally this should look great nice, and also yield in a simple "god rays" effect. But I'm not sure how the extreme yellow fits against the blue sky still. Here is a screenshot from a test, which always sets horizon to sun color. Tell me what you think and if it seems acceptable. There aren't many alternatives to the screenshot below however, though I can make the horizon a bit darker and see how that goes.

Image
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Fri Jun 28, 2013 19:26

Weird, unnatural and i like it.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Fri Jun 28, 2013 20:05

MirceaKitsune wrote:Image
Lookin' good! But, you need to make this a gradient.

EDIT: It's piss yellow.
Last edited by Jordach on Fri Jun 28, 2013 20:19, edited 1 time in total.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
BlockMen
Member
 
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen

by BlockMen » Fri Jun 28, 2013 21:25

MirceaKitsune wrote:Image


It goes definitively in the right direction. Keep on good work!
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Fri Jun 28, 2013 23:46

Glad you like :) I'm onto finishing it, but right now am stuck at one big problem. If someone can name a solution it would be very appreciated.

I must use the pitch and yaw of the local player to determine if they're looking into the sun. To get this done properly, I work with angles. First I convert the sun position: 0* at midnight, 90* at sunrise, 180* at midday, 270* at sunset. Then I convert the player's pitch and yaw to match the same angle mapping, so when you look as high as the sun you automatically have the same converted yaw as the converted time of day. By subtracting yaw angle from sun angle I obtain the angular difference between the player's crosshair and the sun, then of course I can use pitch to obtain distance laterally as well. It sounds like it should all work... but here is the problem:

The player might be looking up or down either toward where the sun rises or where it sets. If we blindly account yaw, we'll see the sun effect in both directions at the same time. Therefore we need to tell if the player is looking forward or backward. So I convert yaw to use a 360* approach... which means 0* when looking down, 90* when looking straight forward, 180* when looking up into the sky, 270* when looking straight backward (matching the angles I described for the sun earlier). If pitch is between 0 and 180 yaw is calculated from looking into the ground (0*) to looking into the sky (180*), whereas if pitch is between 180 and 360 yaw is calculated from looking into the sky (180*) to looking into the ground (360*). It partly fixes the issue and the sun is theoretically tracked at any time of day... but here's the remaining problem:

The moment pitch exits the 0* to 180* range, converted yaw snaps to a different angle. If the player is looking straight up as he turns around, there's no problem and yaw transition is smooth. But if they're looking at the horizon while the pitch range changes, 90 becomes 270 when the pitch range changes, and so on. There's no way to get rid of this snapping if I am to track the player's pitch all across the sky.

So how can I follow the yaw from one end to the other (sunrise to sunset) by having the same amount of yaw be 90* at one and 270* at other, without the value suddenly snapping when I go from 0 - 180 pitch to 180 - 360 pitch? This is a bit complicated to explain so it's ok if many don't understand what I'm talking about. If anyone does and has a solution however, please let me know. I'll likely finish tomorrow if this is solved.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Sat Jun 29, 2013 13:57

Got a lot further with the code today. You can ignore my last post, since I decided to go for another approach: Instead of tracking the crosshair - sun distance, I track the crosshair's distance from the sunset and sunrise locations and apply a -90 to 90 degree scale. This is both simpler and more correct since it's the least extreme way of changing between colors.

So far I got a glimpse of how this will look like. I'm applying sun color at sunrise, moon color at sunset, and horrizon color at any of the two in-betweens. Next comes the maths to filter and reverse them based on time of day, and only during the time when the sun and moon are transitioning. I can say the colors and transition look pretty beautiful, especially compared to how it did before with one fog color.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Sat Jun 29, 2013 22:24

Finished working on the code for today. At this moment it's almost entirely ready... I'm only finishing optimizations to the formula and tweaks to the colors themselves. The sun and moon are combined all the way from 0 to 180 pitch, so the transitions are as smooth and unnoticeable as possible... which I think is what Minecraft does as well to achieve this. Will likely post the code and screenshots tomorrow when it's ready.
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Sat Jun 29, 2013 22:32

Very good work, MirceaKitsune. This feature is a step in the right direction for giving life to Minetest.
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Sun Jun 30, 2013 00:15

Taoki (MK) wrote:Will likely post the code and screenshots tomorrow when it's ready.
It's now tomorrow. Can we have screenshots?
Last edited by Jordach on Sun Jun 30, 2013 00:16, edited 1 time in total.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

ashenk69
Member
 
Posts: 230
Joined: Tue Jul 03, 2012 00:08

by ashenk69 » Sun Jun 30, 2013 04:01

Jordach wrote:It's now tomorrow. Can we have screenshots?

Patience is a virtue
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Sun Jun 30, 2013 08:56

ashenk69 wrote:
Jordach wrote:It's now tomorrow. Can we have screenshots?

Patience is a virtue
I was having a joke.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Sun Jun 30, 2013 09:13

Jordach wrote:
Taoki (MK) wrote:Will likely post the code and screenshots tomorrow when it's ready.
It's now tomorrow. Can we have screenshots?


For me, tomorrow just started now. So expect more within the next hours :)
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Sun Jun 30, 2013 09:15

MirceaKitsune wrote:
Jordach wrote:
Taoki (MK) wrote:Will likely post the code and screenshots tomorrow when it's ready.
It's now tomorrow. Can we have screenshots?


For me, tomorrow just started now. So expect more within the next hours :)
I was using timezones here as the hinge for the joke.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

Thermal_Shock
Member
 
Posts: 76
Joined: Mon Jun 24, 2013 09:10

by Thermal_Shock » Sun Jun 30, 2013 09:42

Thanks for tackling this MirceaKitsune. Sometimes I find myself stopping and just watching the sunsets in Minecraft because they look so good. I think it would be a very immersive feature for Minetest.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Sun Jun 30, 2013 17:56

At this point we can say the code is ready. I got some nice color transitions going, with a realistic to surrealistic feel.

The code is ready for testing and pushing upstream if no one complains. Note that I had to use some weirder formulas for the sun color... it was difficult to do the transitions and that's the best I could get. If anyone can optimize the maths and code feel free to, but please don't change the looks! I'm quite fond of the current color set, and if urgent changes are to be made I'd rather be the one to do them. Anyway let me know what you think.

GIT branch of the code.

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Sun Jun 30, 2013 18:00

Taoki wrote:PICS

It's a bit toooo sharp. But it looks good. The intensity of fog is way way way way way way way way too powerful.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

Next

Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 3 guests

cron