Lighting File Explained

Post Reply
aeffertz
Posts: 4029
Joined: Sat Sep 06, 2014 7:01 am
Team: Studio ATE
Location: Wiscansin

Lighting File Explained

Post 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.
Image
jlv
Site Admin
Posts: 14912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Lighting File Explained

Post 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.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
Jakob Hubbard
Posts: 1148
Joined: Fri Nov 24, 2017 3:16 am
Team: Phil's
Location: Cold
Contact:

Re: Lighting File Explained

Post by Jakob Hubbard »

Thanks Alex. This will be very useful.
Image
Wahlamt
Posts: 7933
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: Lighting File Explained

Post by Wahlamt »

Amazing! Finally able to understand this stupid thing... Is the top left -1 Y -1 and the bottom right 1 Y 1 ?
aeffertz
Posts: 4029
Joined: Sat Sep 06, 2014 7:01 am
Team: Studio ATE
Location: Wiscansin

Re: Lighting File Explained

Post 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.
Image
Wahlamt
Posts: 7933
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: Lighting File Explained

Post 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?
aeffertz
Posts: 4029
Joined: Sat Sep 06, 2014 7:01 am
Team: Studio ATE
Location: Wiscansin

Re: Lighting File Explained

Post 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.
Image
yzmxer608
Posts: 15352
Joined: Mon Dec 29, 2008 4:30 am
Team: SYS
Location: Wisconsin, U.S.A

Re: Lighting File Explained

Post 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.
TeamHavocRacing wrote:If I had a nickel for every time someone asked for this, I would have a whole shitload of nickels.
M@xTizZz
Posts: 2753
Joined: Wed Jan 25, 2012 4:20 pm
Team: TizZy-Design
Location: France

Re: Lighting File Explained

Post by M@xTizZz »

thanks a lot Alex, you wrote it fast :)
Maxime Tison
I AM NOT MXSEMF Official admin ANYMORE | PLEASE DO NOT CONTACT ME ABOUT MXSEMF
ColtonD719
Posts: 631
Joined: Tue Jun 21, 2016 4:15 am
Team: Privateer
Location: Oregon
Contact:

Re: Lighting File Explained

Post 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.
yzmxer608
Posts: 15352
Joined: Mon Dec 29, 2008 4:30 am
Team: SYS
Location: Wisconsin, U.S.A

Re: Lighting File Explained

Post by yzmxer608 »

TeamHavocRacing wrote:If I had a nickel for every time someone asked for this, I would have a whole shitload of nickels.
UncleLiberty76
Posts: 77
Joined: Wed Nov 14, 2018 7:29 pm
Team: Grunt-Style

Re: Lighting File Explained

Post by UncleLiberty76 »

Thanks for the info! Definitely is helping me troubleshoot my lighting issues
Image
Post Reply