30-08-2008, 05:33 PM
Quote:boojiboy16 wrote:
can you give any pointers on how to edit the NightScript.cs file, I'd like to see how the night maps would look if the lights were a little
brighter.
well you need to set
UseCSharpScripts = Yes
in FSEarthMasks.ini to activate scripts. Then you can program in the script what every you like. It is C# code.
It becomes read in when FSEM is started and compiled at runtime. You don't need to do anything more than changes in the Script file.
They are active at once. (well with the next FSEM start)
Programming is simple. By intention I keept the most simple structure.
It's just a pixel color change routine that goes trough every pixel. pixel for pixel.
The grid is:
That gets the pixel count in X and Y of the texture (bitmap):
Int32 vPixelCountInX = iTexture.GetPixelCountInX();
Int32 vPixelCountInY = iTexture.GetPixelCountInY();
Two nested for Loops that count through all pixel (row after row)
for (Int32 vY = 0; vY < vPixelCountInY; vY++)
{
for (Int32 vX = 0; vX < vPixelCountInX; vX++)
{
That one gets the Red green and Blue Color information of the pixel at vX,vY in the texture:
iTexture.GetPixelRGB(vX, vY, ref vRed, ref vGreen, ref vBlue);
That one is optional but you can ask if the pixel is a water pixel. Might be you don't want to change the water color...
Boolean vIsWater = iTexture.IsWaterOrWaterTransition(vX, vY);
That one builds the sumof the Color compnents.
vSum = vRed + vGreen + vBlue;
From here on you do your color changes depending on the original color values. You can do anything you like.
//DO YOUR color changes
That one is importand and limit sthe color components to the allowed color component range of 0..255 (in your manipulation you can
happen to have higher values.. so you need to cut/limit them before writing them back into the pixel)
iTexture.LimitRGBValues(ref vRed, ref vGreen, ref vBlue);
that one writes the color information it back to the pixel at position vX,vY
iTexture.SetPixelRGB(vX, vY, vRed, vGreen, vBlue);
And here are the 2 brakets that mark the end of the 2 for loops
}
}
But before you start writing a new script maybe play with the Night parameters in the FSEarthMasks.ini first.
They can be used and are used in the default script to alter the color.
This 3 build the Street detection condition (streets = light)
NightStreetGreyConditionGreyToleranceValue = 11
NightStreetConditionRGBSumLessEqualThanValue = 510
NightStreetConditionRGBSumLargerThanValue = 0
That means it is a street if difference between each Color component (red, green,blue) is lessthan 11 and the summ of the color
components between 0 and 510 includeing 510.
(You need to check the script to understand it. )
Now you have 2 cases.
1. It is a street THAN:
NightStreetLightDots1DitherProbabily = 0.01
NightStreetLightDots2DitherProbabily = 0.02
NightStreetLightDots3DitherProbabily = 0.05
are the probability for inserting 3 special bright light-pixel (dots)
that have this colors:
(dot1 full white)
ightStreetLightDot1Red = 255
NightStreetLightDot1Green = 255
NightStreetLightDot1Blue = 255
dot2
NightStreetLightDot2Red = 255
NightStreetLightDot2Green = 200
NightStreetLightDot2Blue = 140
dot3
NightStreetLightDot3Red = 255
NightStreetLightDot3Green = 180
NightStreetLightDot3Blue = 80
if non of teh probability got hit..it just changes the street color by adding this values to its components:
(so if you want to make the street looks brighter you most porbabily should do changes here)
NightStreetRedAddition = 100
NightStreetGreenAddition = 50
NightStreetBlueAddition = -50
2. It is No Street THAN
this factor is applayed to all Color components. reducing their intensity to 33% (one third)
NightNonStreetLightness = 0.3
hope that helps you somehow.
Note that the night map creation result and the seasons in general will depend very much on the services and the region.
For one service and region it might produce good result for another bad or non.
Also note that the street detection by simple checkiong the color is no real street detection. mountains withrocks that are colored in the
same range will be recogniced as street and become lightened in the night. A real street detection is a very difficult thing. You need to
detect the shape for example or what is evern better you could use street maps from other source to decide what is a street and what not.
hope i could help you.