Fog Layers are the Tool of the Devil
by Eli McClanahan · in Artist Corner · 04/24/2003 (1:48 pm) · 6 replies
I noticed about half a dozen threads about this problem tucked away in the background of GG, but none of them explained what the problem was. If there was a link with possible information, I was denied access to it.
Now that we've gotten the "why don't you try looking yourself" part out of the way... If you don't know what fog layers are, read away. If you do, skip to the bottom paragraph.
As I've managed to gather, the three fog layers work like this: each layer is seperate from the other and has three numerical values (0, 0, 0) that control a horizontal layer of fog. The normal fog layer (the fog distance value) is meant to make the transition of objects drawn in the distance appear more natural. However, if you wanted to make fog lay in a valley floor but not be present above that point, you'd have to use the fog layers. The obvious problem is that it stretches indefinitely across the playing field, unlike, say, a water block, making it impossible to place in a small area only. But I digress.
Now, let's say I want to make a layer of fog in a valley floor that is very dense at the bottom but eventually dissipates as you reach the top of the valley. Let us also say that this is a very high area: say, the lowest terrain point is "0" (the last value when you place an object on the map) and the highest point is "5000", a very tall mountain peak.
Before we try to create our layer of fog, we have to understand what the three values in each layer do. As it's been my understanding, this is what each number is: the first is the visible distance of that layer of fog. This is the same thing as the normal "Fog Distance" value. If you set it to "10" it will be 10 meters in front of you. The next number is where the fog begins. That is to say, it is the point on a vertical scale where the fog is created. If I set it to "0" then the fog will start at the bottom of our valley. If I set it to "50", it will start 50 meters above that valley floor. If you were standing there, it would be clear in front of you, but 50 meters above you, you'd notice a large sheet of fog. The last value is where the fog ends. If the fog starts at 50 meters and I set the last value to 100, then the fog will no longer exist above 100 meters. If I were standing 150 meters above "0", I would see clear skies in front of me, but below me I'd notice a layer of fog. In this example, the 3 values of Fog Layer 1 would be "10 50 100".
Okay, now that we have the supposedly accurate facts, let's try to make a nice cloudy valley floor. I want really thick fog down at the bottom, so I'll set the first value at "0", for 0 meters in front of my face. I want the fog to go all the way down to the bottom of the map, so I'll make the second value "0" as well. I want to be able to see this fog from way up, so we'll make this a large layer. I'll make the last value "1024". (Remember, our map is 5000 meters high, and that's a lot in mapping terms.) Okay, this makes our first fog layer (Fog Layer 1) "0 0 1024".
Now that we have our fog layer, we could quit. But, I want to make my fog fade all the way to the top, until it's not so thick anymore. To make the fog less thick, we'll set the first value of the second fog layer to a higher number than "0", like "256". The next fog layer will be 256 meters in front of my face. Now, we'll start off this fog layer where the last one left off. So, we'll use the last number of the first layer as the second number of the second layer. Confused? Don't be. We're stacking fog like layers of cheese and meat on a sandwhich. The meat doesn't float above the cheese, right? So, we have to make sure it looks right by putting them as close together as they should be. So, our second number is "1024". Now, we'll make the last number extend quite a bit, so it looks a bit more natural. We'll double 1024 to get our last number for the second layer, "2048". So, our second fog layer is "256 1024 2048".
I shouldn't have to explain what I'm going to do here. We'll use the same principles and get our next sequence of numbers: "512 2048 4096". The fog in this layer is drawn 512 meters in front of me, at a vertical distance of 2048 meters from the terrain's lowest point, and it ends 4096 meters above the terrain's lowest point.
We're done! Or are we? According to what the fog layers are supposed to do, I should be able to stand on my mountain top 5000 meters above the surface and see a thin layer of fog right below me, as long as I'm 512 meters from the 4096 meter point, since that's the point the fog is first drawn at. Everything is perfect.
But yet, it does not work. The way I'm told it works does not work, and in every test and trial and error I've been through, it has yet to ever work correctly. I've gotten it to work a few times by randomly typing in numbers into the mission editor and bashing the apply button until I'm blue in the face. Fog layers are a definite mystery to me, as they don't work the way people say they do. Is there some kind of interference going on? Maybe the original Fog Distance value is causing some kind of interference. I tried setting this value to both 0 up to 5000 with no results. Nothing changes. I've asked numerous people how to work this, and they explain it the same way, yet when I do it, it doesn't work. No one can tell me why it doesn't work, and apparently a lot of other people before me have been baffled by this as well.
If someone can figure this out, I'll give you a cookie. Although, if I do get an actual response, it will probably be something I do not understand, or "you're screwed." By the way, do not post a response saying "You're screwed." It may be humorous, but I will track you down and hurt you nontheless, as I am not a happy man.
Now that we've gotten the "why don't you try looking yourself" part out of the way... If you don't know what fog layers are, read away. If you do, skip to the bottom paragraph.
As I've managed to gather, the three fog layers work like this: each layer is seperate from the other and has three numerical values (0, 0, 0) that control a horizontal layer of fog. The normal fog layer (the fog distance value) is meant to make the transition of objects drawn in the distance appear more natural. However, if you wanted to make fog lay in a valley floor but not be present above that point, you'd have to use the fog layers. The obvious problem is that it stretches indefinitely across the playing field, unlike, say, a water block, making it impossible to place in a small area only. But I digress.
Now, let's say I want to make a layer of fog in a valley floor that is very dense at the bottom but eventually dissipates as you reach the top of the valley. Let us also say that this is a very high area: say, the lowest terrain point is "0" (the last value when you place an object on the map) and the highest point is "5000", a very tall mountain peak.
Before we try to create our layer of fog, we have to understand what the three values in each layer do. As it's been my understanding, this is what each number is: the first is the visible distance of that layer of fog. This is the same thing as the normal "Fog Distance" value. If you set it to "10" it will be 10 meters in front of you. The next number is where the fog begins. That is to say, it is the point on a vertical scale where the fog is created. If I set it to "0" then the fog will start at the bottom of our valley. If I set it to "50", it will start 50 meters above that valley floor. If you were standing there, it would be clear in front of you, but 50 meters above you, you'd notice a large sheet of fog. The last value is where the fog ends. If the fog starts at 50 meters and I set the last value to 100, then the fog will no longer exist above 100 meters. If I were standing 150 meters above "0", I would see clear skies in front of me, but below me I'd notice a layer of fog. In this example, the 3 values of Fog Layer 1 would be "10 50 100".
Okay, now that we have the supposedly accurate facts, let's try to make a nice cloudy valley floor. I want really thick fog down at the bottom, so I'll set the first value at "0", for 0 meters in front of my face. I want the fog to go all the way down to the bottom of the map, so I'll make the second value "0" as well. I want to be able to see this fog from way up, so we'll make this a large layer. I'll make the last value "1024". (Remember, our map is 5000 meters high, and that's a lot in mapping terms.) Okay, this makes our first fog layer (Fog Layer 1) "0 0 1024".
Now that we have our fog layer, we could quit. But, I want to make my fog fade all the way to the top, until it's not so thick anymore. To make the fog less thick, we'll set the first value of the second fog layer to a higher number than "0", like "256". The next fog layer will be 256 meters in front of my face. Now, we'll start off this fog layer where the last one left off. So, we'll use the last number of the first layer as the second number of the second layer. Confused? Don't be. We're stacking fog like layers of cheese and meat on a sandwhich. The meat doesn't float above the cheese, right? So, we have to make sure it looks right by putting them as close together as they should be. So, our second number is "1024". Now, we'll make the last number extend quite a bit, so it looks a bit more natural. We'll double 1024 to get our last number for the second layer, "2048". So, our second fog layer is "256 1024 2048".
I shouldn't have to explain what I'm going to do here. We'll use the same principles and get our next sequence of numbers: "512 2048 4096". The fog in this layer is drawn 512 meters in front of me, at a vertical distance of 2048 meters from the terrain's lowest point, and it ends 4096 meters above the terrain's lowest point.
We're done! Or are we? According to what the fog layers are supposed to do, I should be able to stand on my mountain top 5000 meters above the surface and see a thin layer of fog right below me, as long as I'm 512 meters from the 4096 meter point, since that's the point the fog is first drawn at. Everything is perfect.
But yet, it does not work. The way I'm told it works does not work, and in every test and trial and error I've been through, it has yet to ever work correctly. I've gotten it to work a few times by randomly typing in numbers into the mission editor and bashing the apply button until I'm blue in the face. Fog layers are a definite mystery to me, as they don't work the way people say they do. Is there some kind of interference going on? Maybe the original Fog Distance value is causing some kind of interference. I tried setting this value to both 0 up to 5000 with no results. Nothing changes. I've asked numerous people how to work this, and they explain it the same way, yet when I do it, it doesn't work. No one can tell me why it doesn't work, and apparently a lot of other people before me have been baffled by this as well.
If someone can figure this out, I'll give you a cookie. Although, if I do get an actual response, it will probably be something I do not understand, or "you're screwed." By the way, do not post a response saying "You're screwed." It may be humorous, but I will track you down and hurt you nontheless, as I am not a happy man.
#2
Unlike the regular fog distance value, setting it at 0 doesn't make it as close as possible. For some reason it looks at 0 as being the part that says "don't bother making fog."
I assume this is the issue that's been plaguing so many people for so long, as it works fine now. Well, "fine" that is.
04/24/2003 (4:05 pm)
Okay, I've figured out the problem here. Don't use a "0" for any of the first numbers. It should go without saying that you shouldn't have 0 as a third number either, obviously. That's common sense though.Unlike the regular fog distance value, setting it at 0 doesn't make it as close as possible. For some reason it looks at 0 as being the part that says "don't bother making fog."
I assume this is the issue that's been plaguing so many people for so long, as it works fine now. Well, "fine" that is.
#3
04/29/2003 (10:58 am)
You can have three layers of fogVolumes with layer 1 being the lowest. The three values are visible distance (how dense is the fog), level of the bottom of the layer, and level of the top of the layer. Also, I think the maximum vertical range in TGE is 500 meters (not 5000).
#4
It's not as good as getting the fog to work the way you want, but it's better than nothing.
05/11/2003 (11:23 pm)
Either that or since there's no actual code in the engine to make you swim in water (you simply walk along the bottom of the ocean) why not try using a water block to create a fog effect for the small area you want the fog to be in?It's not as good as getting the fog to work the way you want, but it's better than nothing.
#5
refers to last post
I'm actually writing a tutorial on using the mission editor in mapping right now. As soon as I find the time and desire to continue anyway.
05/12/2003 (10:39 am)
I've gotten everything to work fine now.refers to last post
I'm actually writing a tutorial on using the mission editor in mapping right now. As soon as I find the time and desire to continue anyway.
#6
05/12/2003 (11:19 am)
You can use a trigger and set the white out to certain levels as well which kind of simulates visibility restrictions in certain areas. If you do it with a few triggers at different sizes, each one can lead into the next. I forget if the function setWhiteOut() is in the engine by default, but you can look at Tim Newell's lens flare tutorial on how to add that on that. Link the function to the console. Does this make sense?
Torque Owner J. Donavan Stanley