Game Development Community

Bug Fog Layer Color Doesn't Work

by Dan - · in Torque Game Engine · 02/01/2004 (10:23 am) · 29 replies

I have looked in my release 1.2.0 and the head and in both cases the fog layers color are not set. Instead the fog layers us the main fog color.

from the .mis file:
fogVolumeColor1 = "0.9000000 0.000000 0.000000 0.000000";
      fogVolumeColor2 = "0.9000000 0.5000000 0.000000 1.000000";
      fogVolumeColor3 = "0.9000000 0.9000000 0.000000 1.000000";
Does not work and is ignored. Only the
fogColor
is used for setting the color.

I have tried my best as a fairly new person to debug into the C++ code what I have found is:
- The Alpha (the 4th parameter) is ignored and set to odd values because it is never initilized. Sky::Sky() initilizes the other values but not the .alpha. Also the .alpha is part of the color structure but never passed from the .mis file to the engine.
- It appears the the other colors ARE referenced in the code and used for calculations. For the live of me I can't figure out where the disconnect is.

The current head has for these values (from starter.fps):
fogVolumeColor1 = "128.000000 128.000000 128.000000 -222768174765569861149077900047473967104.000000";
      fogVolumeColor2 = "128.000000 128.000000 128.000000 0.000000";
      fogVolumeColor3 = "128.000000 128.000000 128.000000 -170698929442160049016675429178998259712.000000";
Which seems to be way off from the way it was suppost to work.

I have search the forums and over time the fog layer color seems to have been broken and then fixed.

So the am I missing something, are these values on the way out or is this just another fog layer bug?

Thank you,

Dan
Page «Previous 1 2
#1
02/01/2004 (10:53 am)
Afaik, none of the fogVolumeColorX ever worked since Torque has been released. They can only take the same color as the general fog iirc.
Don't know if it's really a bug, or leftover cruft... :)
#2
02/01/2004 (10:55 am)
Nicolas,

If that is the case it would make sense. Too bad then I wasted a 2 days trying to make it work.

Thanks,
#3
02/02/2004 (5:25 am)
Dan, Nicholas, a few further points on this fogcolor stuff...

1) I may be completely wrong, but it seems that the engine is not using three fog layers at all.

The "fogvolume" struct is utilised in scenegraph.cc only if the "usespecial" flag is on, (which can be traced to a "specialFog" flag that can be set for gameconnection, but isn't).
So "buildFogTexture" is called, and that uses only one layer of fog, from terrain minheight, all the way to terrain maxheight, and is coloured with plain old fogcolor.

2) If you set "usespecial" in scenegraph.cc, then "buildFogTextureSpecial" is called, which then uses the three fogvolume structs and creates three fogbanks. Try this and see the "special" result.

In fairness, this code claims to be a work in progress, and from the result you will see that to be true. It doesn't work much if you don't want rainbow coloured terrain beyond the visible distance.

BTW, the fogvolume struct had visible distance, minheight, maxheight, and percentage, but allows setting of only the first three from script, so I assume that percentage is somehow being linked to the alpha value of the fogvolumecolor fields.

Ideally we need someone from GG who knows this code better to confirm/deny the above conclusion, most specifically, that currently the engine only uses one layer of fog.

Thoughts?
#4
02/02/2004 (8:40 am)
Thanks Matthew,

The $specialFog = "1"; cause the "fog colors" to be used (Although it isn't the effect I had wanted or expected.)
#5
02/02/2004 (9:01 am)
Pleasure, Dan. (And thanx for getting the scriptable value out to the non-SDk folks).

The code in buildFogTextureSpecial isn't pretty, but it shouldn't (theoretically) be too difficult to fix.

We basically need to change the 3 layer code to resemble the 1 layer code, but make it use the various layer parameters instead.

The one concern is with the blending/separation of the layers visually. One is going to see the change of colour as a visual line unless there is a fade-from fade-to effect, and that might be tricky.

Perhaps we should appeal to the GG guys and the rest of the community for ideas/thoughts before we tackle the code changes.

EDIT: spelling
#6
02/02/2004 (7:55 pm)
Matthew, you can get three distinct fog layers--it's just that they all must be the same color, as defined by fogColor.

-Eric F
#7
02/02/2004 (11:04 pm)
Eric, are you sure about the three distinct fog layers?

If so, please advise:

Where does it build the fog texture for each layer?
And if it uses the same texture three times... why bother with three layers? Visually it is going to look as if it's one layer anyway.

Most importantly, if it uses three layers, where does the engine get/set the minheight and maxheight for each layer?

I know Sky.cc has code for the various fog volumes, but the code seems only to be invoked for one layer, and that layer is from terrain minheight to terrain maxheight.

(The three layer code only seems to be invoked when the $specialFog flag is set).
#8
02/02/2004 (11:13 pm)
Perhaps we are talking of different items?

Three fog layers can be set in the mission file, each with varying degrees of opacity, and each with different starting/stopping heights.
#9
02/03/2004 (4:19 am)
Eric,

That is correct. There are three layers, but they all take on the main fog layer color (fogColor) even though each have their own color settings (fogVolumeColorX). Only using $specialFog = "1"; will cause the indivual fog layers to use the color, but the effect isn't layers of fog but a shadding of the ground.

So what is wanted is a way to have the 3 fog layers act like they do when $specialFog = "0";, but have the color of the layer use "fogVolumeColorX" instead of using "fogColor".

Being able to do this would allow one to make the lowest fog layer a dark color. The one above it lighter and the one above that even lighter. You might also be able to get some weird alien world looks by making some of the layers different colors.

I might just have to sit down and roam through the code some more to get this to work. Now that I know about the $specialFog = "1"; I might stand a better chance. :)
#10
02/03/2004 (9:07 am)
Eric, the point I'm making is that the scriptable fogvolume stuff is not utilised without setting a flag, so the engine doesn't have min/max heights to use for three fog layers. (It uses the terrain block min/max heights).

Walking through the code, I don't see that three fog layers are being rendered. (Maybe I'm missing something?) All I see executed is the code for one big fog layer, using fogcolor.

@Dan, the place to start is in sceneGraph.cc, although the actual fog rendering seem to be done in Sky.cc.
#11
02/03/2004 (9:49 am)
No, you can get 3 fog layers, no problem, if you forget about the different colors. ie they'll all be the same color as the distance fog.
There are few threads, maybe even tutorials/resources on how to use them
#12
02/03/2004 (9:51 am)
Nicholas, where does the engine get the min/maxheight for each fog layer?
#13
02/03/2004 (9:56 am)
In sky.cc, in the Sky constructor and the onAdd method
#14
02/03/2004 (10:22 am)
Nicholas, sorry to be obtuse, but I'm afraid I still can't see it.
Neither Sky constructor or onAdd set mFogVolumes min/max height. They initialise visible distance, percentage and color, but don't touch min/max height.
#15
02/03/2004 (10:29 am)
Well, it certainly does something with min height and max height in pack/unpack methods...
I do not know that part of the code, as I haven't played with it.
I recall putting up to 3 fog volumes in a map, using simply the Mission Editor, no coding involved.
#16
02/03/2004 (10:36 am)
It just reads/writes them in pack/unpackupdate. The only loading of min/max height is done in sceneGraph via gameConnection (loaded from script only if specialFog flag = 1).

Which brings me back to my original question. Does the engine (by default) do just one big fog layer?

GG staff, can you please advise and explain how it works in sceneGraph/Sky (if I've lost the plot)?
#17
02/03/2004 (10:48 am)
Matt, the values are input in the Mission Editor, ie tgeScript variables that have tie ins to the engine are often c++ references to their C++ counterparts.
So, you might want to look at the Mission Editor for the actual changing of values.
Clamoring for GG help doesn't have much chance to work, as they do not have time to read all the forums.
#18
02/03/2004 (11:13 am)
Nicholas, I understand all that, and I thank you for your help so far.

However, if you read the above responses you'll see that I'm the one who tracked why the fogcolumecolor stuff wasn't being used from script all the way into the c++ engine. (And pointed out how to get it to be used).

BTW The mission editor is no help here as it just generates the script that the engine starts with.

The point I'm making is that with only one fog color used it is surely not possible to see whether three layers are being used. It looks like a single sheet of fog.

RE: Clamouring for GG help.

1) I do not see what I am doing as clamouring. This is a legitimate concern as the the Torque documentation states (in several places) that there are 3 layers of fog, and from the response to this and other fog threads, everybody thinks that there is, and that it works. If this is not so, surely we must register the fact with GG?

2) If it works, then fine and great and pray do tell - how does it work? Legitimate question, surely.

3) If it is broken, then also fine. I'll even try my hand at fixing it, and have a good idea of how and where, but we need to know.

4) This is a SDK Bugs forum. Surely they read that?
#19
02/03/2004 (11:22 am)
Just meant it as a friendly warning to not get your hopes too high about GG direclty responding to this problem/bug, as they're a lot of stuff on their todolist, including more important bugs in the engine.

And here is some info for you, so you can test that you can actually have 3 fog layers (ie easier to think of them as horizontal layers than as true volumes ;)), all using the same color, ie the distance fog color.
tork.beffy.de/tge_snipits/view_snipits_in_category.php?fk_tge_snipit_category_id...

Btw, just verified that it works : it still does :)
#20
02/03/2004 (11:28 am)
Thanx, Nicholas, no offense meant or I hope taken.

Thanx for the link, but I'v been to there, done that. It show show to set up fog, but doesn't address the central issue of this bug report).

EDIT: OK, now I think get it. (And thanx, on a third reading the link did help).
Page «Previous 1 2