Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

City lights on the dark side of planets

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 609
Joined: Sun Jul 21, 2013 12:26 pm

Re: City lights on the dark side of planets

Post by Astrobe »

another_commander wrote: Sat Mar 19, 2016 1:29 pm
spara wrote:
Wasn't there something like a shady planet branch or something? Wasn't it supposed to do something like that? What happened to that?
It went stale long time ago and there have been many changes in the planet drawing code and shaders since then, so it may not be such a simple job bringing it up to date.

In any case, I think that shaders would be the way to go about implementing this request. I doubt that flashers or other look-alike effects would be able to cut it.
Almost there (temporary hosting):

Image

The relief in 1.85 with perlin textures is a little bit too strong in my opinion, so I was trying to make it more "flat". I changed the rescale factor from 127.5 to 63.5 at lines 491-493 in OOPlanetTextureGenerator.m. N

However, there are side effects that are more or less welcome (~3MB).

Obviously I don't know what I'm doing. I believe I accidentally flipped the normals for the oceans. Someone more knowledgeable than me about that stuff can probably put it to good use.
Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 609
Joined: Sun Jul 21, 2013 12:26 pm

Re: City lights on the dark side of planets

Post by Astrobe »

Actually my first goal was to try to mix the old generator and the new generator to obtain landscape features. But it came to me that there may be an easier and cheaper way: use the clouds texture.

Something like: take the clouds texture, keep only the highest values of alpha, and mix it with the ground texture in reverse pixel order (so that the trick isn't too obvious). High alpha values could be use to introduce terrain features with a different color (maybe swap components of the ground color?), low values could be used for city lights. Can someone explain what I've accidentally discovered to me?
Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 609
Joined: Sun Jul 21, 2013 12:26 pm

Re: City lights on the dark side of planets

Post by Astrobe »

After some more reading, trial and error (temp hosting):

Image

This is the dark side of a planet near the dawn line; one can see a bit of the lit part in the bottom right corner. The bright dot on the left is a star, the other isolated points are space dust.

I targeted the coastlines to make tests more easy, so it looks a bit ugly and silly (actually on this picture the criteria was still including water bodies). As far as I understand it, I indeed flipped the depth coordinate of the normal vectors (Z in [0..128] instead of [128..255]).

The downside is that the brighter the point is on the dark side, the darker it will appear on the lit side. So it looks terrible especially on the coastlines which are normally pale, but I think it's still usable for cities which can be dark patches. Maybe it will be possible to mitigate this by picking a bright color for them.
Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 609
Joined: Sun Jul 21, 2013 12:26 pm

Re: City lights on the dark side of planets

Post by Astrobe »

I give up. The glow is too faint on the dark side and it looks horrible on the light side no matter what, and it doesn't look like cities anyway.

I guess we will have to wait for shader gurus to pick it up. I think the way to go would be something like:
1. Create predefined city patterns textures with associated shaders,
2. Pick a bunch of them pseudo-randomly and superpose them,
3. Apply the texture generator on top of that map to get relief, oceans, specular lighting etc.

Or maybe run the texture generator first then apply the city textures on top of it.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4704
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: City lights on the dark side of planets

Post by phkb »

Sometimes things work out, and sometimes they don't, but we won't know until we try. Thanks for your work on this, even though it didn't work out the way you wanted. Well done.

Shader gurus .. over to you!
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 666
Joined: Sat Aug 09, 2014 4:16 pm

Re: City lights on the dark side of planets

Post by Commander_X »

<popping in, while still waiting for the gurus>

Not that difficult with the shaders. Tweaking the parameters for the noise now, _that_ will be a challenge.

Image

The noise looks a bit better in game, it twinkles[*] ;)

*Which of course is an unexpected "feature".
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6569
Joined: Wed Feb 28, 2007 7:54 am

Re: City lights on the dark side of planets

Post by another_commander »

Interesting. Looks nice. What happens when the cloud layer is over the lit areas? Do they get temporarily hidden or dimmed while the clouds pass over them?
Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 609
Joined: Sun Jul 21, 2013 12:26 pm

Re: City lights on the dark side of planets

Post by Astrobe »

Commander_X wrote: Sun Sep 24, 2017 5:04 am
Not that difficult with the shaders. Tweaking the parameters for the noise now, _that_ will be a challenge.
How did you do that? Is this the mysterious "shady planet" branch Spara was talking about earlier?
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 666
Joined: Sat Aug 09, 2014 4:16 pm

Re: City lights on the dark side of planets

Post by Commander_X »

another_commander wrote: Sun Sep 24, 2017 8:30 am
What happens when the cloud layer is over the lit areas?
Astrobe wrote:
How did you do that? Is this the mysterious "shady planet" branch Spara was talking about earlier?
Trying to answer both questions at once: it's done through the trunk planet fragment shader, only. Thus, the clouds obscure this.
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1388
Joined: Thu Aug 27, 2015 4:24 pm

Re: City lights on the dark side of planets

Post by cbr »

This all looks very nice, does it have some twink'ling too?
Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 609
Joined: Sun Jul 21, 2013 12:26 pm

Re: City lights on the dark side of planets

Post by Astrobe »

Commander_X wrote: Sun Sep 24, 2017 4:43 pm
Trying to answer both questions at once: it's done through the trunk planet fragment shader, only. Thus, the clouds obscure this.
Sorry, is it a branch in the oolite github repo or is it in a separate repo?
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 666
Joined: Sat Aug 09, 2014 4:16 pm

Re: City lights on the dark side of planets

Post by Commander_X »

Astrobe wrote: Tue Sep 26, 2017 11:52 am
Sorry, is it a branch in the oolite github repo or is it in a separate repo?
It's on my computer at the moment. I can provide the simple changes (given my -- rather slow -- release cycle tendencies) but I'd rather not pollute the forum with potentially dangerous, definitely not polished and very likely shameful code :oops: .
I guess PM for the adventurous shouldn't be a problem, though.
Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 609
Joined: Sun Jul 21, 2013 12:26 pm

Re: City lights on the dark side of planets

Post by Astrobe »

Commander_X wrote: Tue Sep 26, 2017 2:08 pm
It's on my computer at the moment. I can provide the simple changes (given my -- rather slow -- release cycle tendencies) but I'd rather not pollute the forum with potentially dangerous, definitely not polished and very likely shameful code :oops: .
I guess PM for the adventurous shouldn't be a problem, though.
Yes, please! You can PM them to me as diffs/patches if that's easier for you.
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 666
Joined: Sat Aug 09, 2014 4:16 pm

Re: City lights on the dark side of planets

Post by Commander_X »

Astrobe wrote: Thu Sep 28, 2017 2:12 pm
Yes, please! You can PM them to me as diffs/patches if that's easier for you.
Done. There are some changes that mainly modify the pattern the lights are spread (to avoid the potato distribution :) )

For reference, this is what Lave should look like when launching a new Jameson:

Image
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1388
Joined: Thu Aug 27, 2015 4:24 pm

Re: City lights on the dark side of planets

Post by cbr »

while ring month fades away, city lights awaits... :)
Post Reply