Page 1 of 1

Lighting File Explained

Posted: Tue Jan 30, 2018 2:53 am
by aeffertz
Figured it'd be a cool idea to make a quick run down on the lighting file from things I've learned from playing with it and reading all over this site and compile all the info into one place. So we'll break it down part by part.

sun_vector [X Y Z] - The location of the sun. Probably the most important part of the lighting for a well lit track.

The x-axis indicates the sun's distance east (positive) or west (negative) of the center of the map.
The y-axis indicates how high or low the sun is.
The z-axis indicates the sun's distance south (positive) or north (negative) of the center of the map.

Image

So if we wanted the sun to be in the top left corner (or northwest corner) we could make the values [-1 Y -1], which moves the sun one unit to the west and one unit north from the center and is now aiming towards the center of the map. Basically, look at the layout of your track to best determine which direction you want the shadows to be casted

One important thing to keep in mind, any track sections that run parallel with the direction of the sun will be casting shadows on the front or back of a bump. Where this comes into play is erode and ruts in a section. You can shade the front or backside of a jump face with decal work since those won't be changing but you can't shade the ruts that form through out a race. So it is best to have the sun shining in a direction that is not parallel to any lane on the track (or as best as possible) for even lighting through out the entire track.

The sun will cast no shadows if centered. Here is [0 1 0] Terrible, no bumps are shaded.
Image

Now let's just move it straight east. Here is [1 1 0] Now you are able to see some ruts but others are still practically invisible.
Image

So let's find a good place. Something diagonal should work just fine with this track layout. Keep in mind, the further away the sun, the darker the track will get but you will get deeper shadows. So find a happy balance that goes along with the style of track. We can also adjust brightness a few other ways. For this track, I've decided on [.75 .75 -1] works best overall for rut shading and overall track brightness.
Image

sun_color [R G B] - Color/intensity of the sun.

Equivalent to RGB values in photoshop divided by 255. [1 1 1] would equal white, so something like [0.8 0.8 1.0] would have a blueish tint. Choosing a higher number will equate to more intense lighting and often it will wash out colors on trackside objects or the bike rider but you can go with something like [2 2 2] for an extreme bright lighting. If you moved the sun far away from your track for shadows and want to brighten it up without losing detail in the decals, make the sun color bright but keep an eye on objects.

ambient [R G B] - Dirt decal ambient lighting.

Same rules apply as the sun color, only this value only effects the terrain decals.This is another way to brighten decals, however raising this value will wash out details in the decal file as you brighten it up. It will also wash out lighten the shading. So play with these numbers if you have too dark of shading or decals on the track but like the rest of the lighting over all since this will only affect the ground.

global_ambient [R G B] - trackside objects/bike/rider/etc lighting.

Same color rules again, only this just affects objects. If your rider looks like he's way too bright compared to the rest of the track or washed out, lower these values. Or if he appears too shaded, raise these values.

near_plane 0.25
far_plane 5000


In 3D rendering there are two planes that control the nearest and farthest distances things can be rendered at.The closer together they are the more precise your Z buffer is.

Image

Anything outside of the two planes won't be rendered. This setting is usually just set it and forget it for most tracks, but if you are having weird rendering issues on track objects, maybe try adjusting your far plane.

Re: Lighting File Explained

Posted: Tue Jan 30, 2018 2:59 am
by jlv
Nice write up! One correction - the sun vector is just a direction. The game will act as if it's infinitely distant. The length of the vector doesn't matter.

Re: Lighting File Explained

Posted: Tue Jan 30, 2018 3:59 am
by Jakob Hubbard
Thanks Alex. This will be very useful.

Re: Lighting File Explained

Posted: Tue Jan 30, 2018 5:27 am
by Wahlamt
Amazing! Finally able to understand this stupid thing... Is the top left -1 Y -1 and the bottom right 1 Y 1 ?

Re: Lighting File Explained

Posted: Tue Jan 30, 2018 5:35 am
by aeffertz
Wahlamt wrote:Amazing! Finally able to understand this stupid thing... Is the top left -1 Y -1 and the bottom right 1 Y 1 ?
Yep. You could do [2 Y 2] [.5 Y 1.5] etc.

Re: Lighting File Explained

Posted: Tue Jan 30, 2018 5:47 am
by Wahlamt
aeffertz wrote:
Wahlamt wrote:Amazing! Finally able to understand this stupid thing... Is the top left -1 Y -1 and the bottom right 1 Y 1 ?
Yep. You could do [2 Y 2] [.5 Y 1.5] etc.
An then it would be somewhere "outside the map", right?

Re: Lighting File Explained

Posted: Tue Jan 30, 2018 5:57 am
by aeffertz
Well like JLV mentioned, it's more so just the direction in which the lighting shines. The farther away you go, the dimmer it gets though.

Re: Lighting File Explained

Posted: Tue Jan 30, 2018 3:12 pm
by yzmxer608
Thanks! I struggled for along time with the vectors, a visualization like this helps a lot. I also have a small program that will create the lighting file for you based on what you enter with color pickers etc. that Wheels made. I can't seem to find his original post on it but can upload it if anyone wants.

Re: Lighting File Explained

Posted: Wed Jan 31, 2018 1:04 am
by M@xTizZz
thanks a lot Alex, you wrote it fast :)

Re: Lighting File Explained

Posted: Fri Feb 02, 2018 9:22 am
by ColtonD719
Thanks for putting this together! I never quite understood the sun vectors, and always just used this calculator: http://forum.mxsimulator.com/viewtopic.php?f=11&t=25668

But this definitely helps me wrap my brain around what is going on better.

Re: Lighting File Explained

Posted: Sat Feb 03, 2018 3:57 am
by yzmxer608

Re: Lighting File Explained

Posted: Sat Mar 23, 2019 3:06 pm
by UncleLiberty76
Thanks for the info! Definitely is helping me troubleshoot my lighting issues