Ogre 2.x AtmosphereComponent

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
Lax
Hobgoblin
Posts: 583
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Ogre 2.x AtmosphereComponent

Post by Lax »

Hi dark_sylinc,

i'm testing the AtmosphereComponent and its working great so far! Thanks a lot for that nice feature dark_sylinc!

I'm a bit confiused about time of day. Its range is documentated as:

Must be in range [-1; 1] where range [-1; 0] is night and [0; 1] is day

So what does that mean in the format of hours and minutes? Because the night is not that long as the day in mid earth.
Which means:

    • -1 = 0 o'clock at night
    • -0.5 = 3 o'clock at night
    • 0 = 6 o'clock in the morning? Day starts?
    • 0.5 = 9 o'clock?
    • 0.75 = 18 o'clock?
    • 1 = 23:59 o'clock?

or what would be the correct mapping? Because I want to set a start time in the format hh:mm (0-24 o'clock) and convert that to the range above.

Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1280
Contact:

Re: Ogre 2.x AtmosphereComponent

Post by dark_sylinc »

First, it's not physically based, so it's not an exact science. If what I'm about to tell you doesn't suit your tastes, feel free to change the mapping.

Second, even if it were physically based, the "mapping" depends on your physical world location (e.g. 12pm in Ushuaia is not the same as 12pm in Spain). It also depends on politics (e.g. in Spain at 21hs on summer you still have plenty of sunlight, in Argentina which should be in GMT-4 but is in GMT-3 for no particular reason... at 21hs it's really dark already).

For simplicity, the model assumes that 0.5 -> sun is downwards at maximum brightness (i.e. typical 12pm midday) and -0.5 the same but at night (typical midnight?)

Now whether you want to apply a linear scale (e.g. 0 -> 6am-ish; 0.5 -> 12pm; 1.0 -> 9pm-ish; -1 -> 9pm-ish; -0.5 12am; 1 -> 6am-ish ) or another scale (e.g. you square / square root / cosine-interpolate the value) is up to your findings.

By different scales I mean:

  • Morning: lerp( 6am, 12pm, w * 2 ) for w in range [0; 0.5] vs:

  • Morning: lerp( 6am, 12pm, sqrt( w * 2 ) ) for w in range [0; 0.5] vs:

  • Morning: lerp( 6am, 12pm, pow( w * 2, factor ) ) for w in range [0; 0.5] vs:

  • Morning: cosine_interpolate( 6am, 12pm, w * 2 ) for w in range [0; 0.5] vs

  • Something else

Also on most locations the sun rarely is ever a perfect (0, -1, 0) nor does it move from (-1, 0, 0) to (1, 0, 0) where z is always 0 which is why we provide setSunDir where you can specify the sun direction explicitly (i.e. when z varies according to time of day).
We still ask for normalizedTimeOfDay to know how bright it should be and which colours to apply.

Does this satisfy the questions?

Lax
Hobgoblin
Posts: 583
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: Ogre 2.x AtmosphereComponent

Post by Lax »

Hi dark_sylinc,

ok you are totally right, its subjective. Thanks for the information.
I will see what I will do.

Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

Lax
Hobgoblin
Posts: 583
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: Ogre 2.x AtmosphereComponent

Post by Lax »

Hi dark_sylinc,

I found a weird behavior on atmosphere component.
In order to see whats going I modified the sample a litte bit by updating the timeOfDay automatically in the update function:

Code: Select all

 void AtmosphereGameState::update( float timeSinceLast )
    {
        mTimeOfDay += 0.1f * timeSinceLast;
        if( mTimeOfDay >= Ogre::Math::PI )
            mTimeOfDay = -Ogre::Math::PI + std::fmod( mTimeOfDay, (float)Ogre::Math::PI );

Now at 179.9 degree there are ugly artifacts visible And also at 0 degree. See the link to attached video:

http://www.lukas-kalinowski.com/Homepag ... sphere.mp4

It happens on the jump from positive to negative values.

I hope you can fix that.

Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1280
Contact:

Re: Ogre 2.x AtmosphereComponent

Post by dark_sylinc »

Oh... well. This is a "feature"

It's supposed to look like that at those extreme values (sunrise / sunset) however note:

  1. It happens extremely fast hence the value passed to updatePreset / setSunDir should slow down considerably

  2. If you don't like how it looks in that time range just provide a different preset for that brief time range until it looks how you want; or clamp the value so you never pass those extremes to updatePreset / setSunDir

Basically this is something that is intended to be tweaked at the higher level, rather than inside AtmosphereNpr.

If you happen to tweak this until it looks better PRs to improve the AtmosphereGameState.cpp sample can be considered.

Lax
Hobgoblin
Posts: 583
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: Ogre 2.x AtmosphereComponent

Post by Lax »

Oh ok, good to know. Then I will tweak the parameters. Thanks for clarification!

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

Post Reply