# Darken ground with altitude

## Recommended Posts

Getting some great results fiddling with PTA. Thanks for the tool.

I was trying to think about how to darken the terrain with altitude, reducing the light level of the ground in linear line from say 10,000 ft. Writing that expression is way beyond me.

If it is possible to do, I would appreciate help in getting an expression to work.

##### Share on other sites
 Help AVSIM continue to serve you!Please donate today!

Here an example of how to lower terrain lighting when going higher :

1.0 - ( cb_altitude / 13000 * 0.2 )

On ground level you have a terrain brightness of 1.0

Up to 13000 m it is lowered gradually till it is 0.2 lower ( so 0.8 ).

At 6500 m : 1.0 - ( 6500 / 13000 * 0.2 )  =  1.0 - ( 0.5 * 0.2 ) = 1.0 - ( 0.1 ) = 0.9

regards, Gerard

##### Share on other sites

Thanks alot, and I can see how the expression works now too.

##### Share on other sites

Gerard, where to put that formula ?

##### Share on other sites

Terrein Lighting where you put the sun value ( Diffuse )

##### Share on other sites

Had to go a bit deeper to get it to work. Just reducing the diffuse was not getting the full effect, and was also reducing down to black higher up, so I needed to clamp it. I think I have worked out a solution, but the maths is not that elegant, and appreciate input if there is a better way to do it.

The aim is to reduce the brightness of terrain, and buildings up to an altitude of 25,000 ft (more realistic for UK winter flying), then clamp it there. I have come up with;

[LIGHTING_TERRAIN_LIGHTING]
IsActive=1
SunDiffuseCoeff=(clamp(3.0 - (cb_Altitude/3048), 0.4, 2.4))
SunAmbientCoeff=(clamp(0.72 - (cb_Altitude/12700), 0.1, 0.6))
MoonDiffuseCoeff=1.50
MoonAmbientCoeff=1.00

[LIGHTING_AUTOGEN_LIGHTING]
IsActive=1
SunDiffuseCoeff=(clamp(3.0 - (cb_Altitude/3048), 0.5, 2.4))
SunAmbientCoeff=(clamp(0.72 - (cb_Altitude/12700), 0.1, 0.6))
MoonDiffuseCoeff=0.8
MoonAmbientCoeff=0.5

[LIGHTING_TERRAIN_SATURATION]
IsActive=1
SaturateRatio=(clamp(0.9 - (cb_Altitude/38100), 0.7, 0.9))

Before the tweak

After the tweak

Using this formula, the darkening effect does not start until around 6000 ft

If you want to try the formulas, you will probably need to fiddle with the values to fit your preset, HDR lighting etc.

The last two figures are the clamp figures, so you can use those to constrain the results, especially the lower figure. Set to a higher number and it won't get so dark.

##### Share on other sites

Bear in mind that the overall sunlight is already different in all seasons. So in the winter everything is darker than in the summer.  Also the sky.

And by climbing the scenery also gets a little darker.

It might be a good idea to darken AG as It sometimes can be seen at a too high altitude.

##### Share on other sites
11 hours ago, mole_man said:

The aim is to reduce the brightness of terrain, and buildings up to an altitude of 25,000 ft (more realistic for UK winter flying), then clamp it there. I have come up with;

[LIGHTING_TERRAIN_LIGHTING]
IsActive=1
SunDiffuseCoeff=(clamp(3.0 - (cb_Altitude/3048), 0.4, 2.4))
SunAmbientCoeff=(clamp(0.72 - (cb_Altitude/12700), 0.1, 0.6))
MoonDiffuseCoeff=1.50
MoonAmbientCoeff=1.00

[LIGHTING_AUTOGEN_LIGHTING]
IsActive=1
SunDiffuseCoeff=(clamp(3.0 - (cb_Altitude/3048), 0.5, 2.4))
SunAmbientCoeff=(clamp(0.72 - (cb_Altitude/12700), 0.1, 0.6))
MoonDiffuseCoeff=0.8
MoonAmbientCoeff=0.5

[LIGHTING_TERRAIN_SATURATION]
IsActive=1
SaturateRatio=(clamp(0.9 - (cb_Altitude/38100), 0.7, 0.9))

To make others understand these expressions :

25000 ft = 7620 m

SunDiffuseCoeff=(clamp(3.0 - (cb_Altitude/3048), 0.4, 2.4))  —> direct sunlight on the terrain

Minimum value = 0.4

Maximim value = 2.4

Starting value = 3.0

At 0 m altitude : 3.0 - 0 = 3.0 —> max value 2.4       —> 3.0 - ( 0/3048 ) = 3.0 - 0

At 1000 m altitude : 3.0 -  0.33 = 2.67 —> max value 2.4     —> 3.0 - ( 1000/3048 ) = 3.0 - 0.33

At 1968.5 m altitude : 3.0 - 0.6 = 2.4     —> 3.0 - ( 1968.5/3048 ) = 3.0 - 0.6

So above 1968.5 m ( 6458.33 ft ) the diffuse lighting starts to get less till the min value of 0.4 , which will be at 7925 m ( 26000.66 ft )

At 5000 m altitude : 3.0 - 1.95 = 1.05     —> 3.0 - ( 5000/3048 ) = 3.0 - 1.95

Any higher than 7925 m ( 26000.66 ) and it will stay at the minimum value of 0.4.

At 10000m altitude , which is above 26000.66 ft : 3.0 - 2.6 = 0.4     —> 3.0 - ( 10000/3048 )  —>   3.0 - ( 3.28 ) = - 0.72 which is less than the minimum of 0.4 , so the value will be 0.4

##### Share on other sites

Good explanation.

What is AG short for? Not sure what to look at tweaking next to fine tune the effect.

##### Share on other sites
13 minutes ago, mole_man said:

Good explanation.

What is AG short for? Not sure what to look at tweaking next to fine tune the effect.

AG = autogen

Autogen Lighting ( window/door lights )

Object lights ( brightness of the buildings and trees  —> as you darken terrain and AG lights , you also should darken the buildings .....

##### Share on other sites

Autogen lighting is just for night lights I think, 'Autogen Emissive Lighting'? I like to keep them bright, but users could put same formulas into that section to darken nightlights with altitude.

Not tested in every season/TOD yet. Will end up with many presets through the year I expect, and probably different parts of the world do not see the ground go so dark with altitude as it does in Northern Europe/USA

How to vary the formula by season is the next challenge...

##### Share on other sites
On 11/13/2017 at 10:15 PM, GSalden said:

Here an example of how to lower terrain lighting when going higher :

1.0 - ( cb_altitude / 13000 * 0.2 )

On ground level you have a terrain brightness of 1.0

Up to 13000 m it is lowered gradually till it is 0.2 lower ( so 0.8 ).

At 6500 m : 1.0 - ( 6500 / 13000 * 0.2 )  =  1.0 - ( 0.5 * 0.2 ) = 1.0 - ( 0.1 ) = 0.9

regards, Gerard

Hi Gerard,

What would be the line if i wanted the brightness to go up with the altitude ? i want to do this for the urban area lightning brightness.

Thank you as usual !

##### Share on other sites

1.0 + ( cb_altitude / 13000 * 0.2 )

At 13.000 m it is : 1.0 + ( 1 * 0.2 ) = 1.2

• 1

##### Share on other sites
2 minutes ago, GSalden said:

1.0 + ( cb_altitude / 13000 * 0.2 )

At 13.000 m it is : 1.0 + ( 1 * 0.2 ) = 1.2

Thanks a lot Gerard !

##### Share on other sites
3 hours ago, GSalden said:

1.0 + ( cb_altitude / 13000 * 0.2 )

At 13.000 m it is : 1.0 + ( 1 * 0.2 ) = 1.2

Some wrong parameter message when trying to put it there. Got it was missing -()

##### Share on other sites
3 hours ago, GSalden said:

1.0 + ( cb_altitude / 13000 * 0.2 )

At 13.000 m it is : 1.0 + ( 1 * 0.2 ) = 1.2

it lets me save it but no ground at all...

## Create an account

Register a new account

• Tom Allensworth,
Founder of AVSIM Online

• ### Hot Spots

• Flight Simulation's Premier Resource!

AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!