Manipulating fog with Lua

Questions about the content creation procedure go here, including using Forge, Anvil, or other editors, or operating emulators like Basilisk II.
Post Reply
User avatar
ktaur
Born on Board
Posts: 44
Joined: Jul 16th '08, 18:12
Contact:

i'm hoping somebody more proficient in Lua will be able to give me some insight on this.

i'm wondering if it's possible to set fog properties for specific polygons. For example, if i wanted a particular room to be "filled with poison gas", could i write a Lua script (i'm assuming Lua would be the only way to accomplish this) telling Aleph One to display green fog within just the polygons that compose that room, leaving the rest of the map clear?

Another reason for 'selective fog' in this sense is just the opposite; designating 'fog-free' polygons in an otherwise foggy map; in order to fix such aesthetically problematic situations as looking out into a landscape-textured room and being unable to see the landscape due to the fog (as is the case on Ne Cede Malis when played with fog turned on...the player looks out the window at the beginning, but the 'space' landscape is obscured by the fog).

Also...if i may further complicate things...is there a way to cause fog density to increase or decrease based on floor height? i've built several maps in which the player descends into a subterranean area via a platform...it would be a great effect to have fog grow steadily denser as the player descends...

Anybody have any thoughts on this?
Last edited by ktaur on Jan 19th '10, 22:12, edited 1 time in total.
User avatar
thermoplyae
Mjolnir Mark IV
Posts: 735
Joined: Sep 10th '06, 17:35
Contact:

K wrote:i'm hoping somebody more proficient in Lua will be able to give me some insight on this.

i'm wondering if it's possible to set fog properties for specific polygons. For example, if i wanted a particular room to be "filled with poison gas", could i write a Lua script (i'm assuming Lua would be the only way to accomplish this) telling Aleph One to display green fog within just the polygons that compose that room, leaving the rest of the map clear?

Another reason for 'selective fog' in this sense is just the opposite; designating 'fog-free' polygons in an otherwise foggy map; in order to fix such aesthetically problematic situations as looking out into a landscape-textured room and being unable to see the landscape due to the fog (as is the case on Ne Cede Malis when played with fog turned on...the player looks out the window at the beginning, but the 'space' landscape is obscured by the fog).

Also...if i may further complicate things...is there a way to cause fog density to increase or decrease based on floor height? i've built several maps in which the player descends into a subterranean area via a platform...it would be a great effect to have fog grow steadily denser as the player descends...

Anybody have any thoughts on this?
the answer is both yes and no.

lua can detect which polygon the player is in, what height he's at, and so forth, and manipulate the fog to reflect that

buuuut, for example, if you stood outside the "fog-filled" room and looked it, you couldn't see any fog. then you'd step through the door and your view would fill with it. it's not a very good trick, but it's all we've got at the moment, i think (unless shaders fixed this somehow? seems unlikely, but hmmm)
dude, seriously. dude.
User avatar
treellama
Vidmaster
Posts: 6107
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

No, the engine does not support volumetric fog, so obviously neither can Lua.
User avatar
Dugit
Vidmaster
Posts: 1803
Joined: Mar 22nd '09, 16:33
Location: Hampshire, UK
Contact:

Dang. That would be cool. It would also sort out some problems with fog maps I've seen, but I thought, "If it's possible, then it probably would be done. However, it's not done, so it's probably not possible." Meh. I would've liked to see it.
Polyplicity my second (less sucky) net pack. Go on. Download it. You know you don't want to.
Marathon Aeon- My scenario in the works ~on Simplici7y

riveting six-vertice amnesty ratifications
Fishman92
Mjolnir Mark IV
Posts: 528
Joined: May 22nd '09, 21:54

Treellama wrote:No, the engine does not support volumetric fog, so obviously neither can Lua.
I don't see how this would not work; aleph one can change density and the colour of the fog actively, yeah? So Explain why it is not possible. This isn't a case of volumetric fog, merely changing the opacity of it.
User avatar
Wrkncacnter
Vidmaster
Posts: 1948
Joined: Jan 29th '06, 03:51
Contact:

Fishman92 wrote:I don't see how this would not work; aleph one can change density and the colour of the fog actively, yeah? So Explain why it is not possible. This isn't a case of volumetric fog, merely changing the opacity of it.
Congratulations, dude.
User avatar
ktaur
Born on Board
Posts: 44
Joined: Jul 16th '08, 18:12
Contact:

Fishman92 wrote:I don't see how this would not work; aleph one can change density and the colour of the fog actively, yeah? So Explain why it is not possible. This isn't a case of volumetric fog, merely changing the opacity of it.
That's kind of what i was hoping. i'm not interested in truly volumetric fog so much as i am interested in the illusion of it. i tried out a lua-scripted map where the fog changed colours and density in-game, and figured there was a way to control that...make it less random; say, the player enters a polygon (steps into a room), and the fog changes from zero density to 50% or whatnot. Or, the player punches a switch and fog starts to fill the map...as if gas were leaking or something. i think it would make a great effect, and add a dynamic element to the 'mission' of a solo map. It seems like it wouldn't be hard...i just don't know how to do it. Obviously i know how to set the fog density/color/thickness in the MML script, but i don't know how to manipulate that using Lua.

Thanks.
User avatar
treellama
Vidmaster
Posts: 6107
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

Fishman92 wrote:I don't see how this would not work
That's because you don't know what the hell you are talking about. Or, if you do, why don't you explain, in detail, how it would work?
This isn't a case of volumetric fog, merely changing the opacity of it.
He asked for the very definition of volumetric fog.
Last edited by treellama on Jan 20th '10, 20:41, edited 1 time in total.
User avatar
ktaur
Born on Board
Posts: 44
Joined: Jul 16th '08, 18:12
Contact:

Treellama wrote:That's because you don't know what the hell you are talking about. Or, if you do, why don't you explain, in detail, how it would work?
He asked for the very definition of volumetric fog.
The example i was referring to is here:

http://www.youtube.com/watch?v=cSQGIbeZ1z0

There is a way to accomplish volumetric fog (or at least the illusion of it) with Lua. i simply don't know how to do it, or more specifically, control it based on the player's actions, hence my asking for help.
User avatar
treellama
Vidmaster
Posts: 6107
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

K wrote:The example i was referring to is here:

http://www.youtube.com/watch?v=cSQGIbeZ1z0

There is a way to accomplish volumetric fog (or at least the illusion of it) with Lua. i simply don't know how to do it, or more specifically, control it based on the player's actions, hence my asking for help.
That's not what you asked for originally, and also isn't even the illusion of volumetric fog, which would involve being able to see the fog's edges at least. You can achieve that effect by changing Level.fog. Check out Lua.html for more details.
User avatar
ktaur
Born on Board
Posts: 44
Joined: Jul 16th '08, 18:12
Contact:

Treellama wrote:That's not what you asked for originally, and also isn't even the illusion of volumetric fog, which would involve being able to see the fog's edges at least. You can achieve that effect by changing Level.fog. Check out Lua.html for more details.
i know what i asked for originally, and per this conversation, i now know that truly volumetric fog is not possible. Since there's no helping that, i'm perfectly happy settling for increasing/decreasing the fog level gradually after the player steps into a particular polygon.

(a) How do i set a particular polygon as the 'trigger'
(b) Is there a way to cause the fog level to increase from 0% to 50% over a period of, say, 5 seconds?

That's all i'm looking for. You'll have to forgive me...i'm a novice, to say the least, with Lua.

Thanks
User avatar
treellama
Vidmaster
Posts: 6107
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

K wrote:(a) How do i set a particular polygon as the 'trigger'
(b) Is there a way to cause the fog level to increase from 0% to 50% over a period of, say, 5 seconds?
The polygon a player is in can be found by player.monster.polygon. There is a way to increase fog, the idle trigger gets called each tick so you would increase the fog depth by the appropriate amount each time.
That's all i'm looking for. You'll have to forgive me...i'm a novice, to say the least, with Lua.
You should probably learn the basics of Lua first, then by looking through Lua.html you'll understand what you can / need to do.
User avatar
ktaur
Born on Board
Posts: 44
Joined: Jul 16th '08, 18:12
Contact:

Treellama wrote:The polygon a player is in can be found by player.monster.polygon. There is a way to increase fog, the idle trigger gets called each tick so you would increase the fog depth by the appropriate amount each time.
You should probably learn the basics of Lua first, then by looking through Lua.html you'll understand what you can / need to do.
Thank you. i appreciate the help. Your advice is well taken.
User avatar
Crater Creator
Vidmaster
Posts: 943
Joined: Feb 29th '08, 03:54
Contact:

Treellama wrote:That's not what you asked for originally, and also isn't even the illusion of volumetric fog, which would involve being able to see the fog's edges at least. You can achieve that effect by changing Level.fog. Check out Lua.html for more details.
I think in the first part of that video, where the player descends a platform, an uninformed observer could rationally conclude that the density of fog changed as a function of height, rather than as a function of time. In other words, the video does create an illusion that the fog occupies a distinct volume nonuniformly. I'm guessing you don't consider it volumetric unless the fog density is perceived as non-constant in all three dimensions.

Anyway, in addition to the methods already discussed, you could fake a 'ground effect' layer of fog by using a semitransparent liquid that looks like fog. Then your fog would occupy only the polygons you want, plus it could rise, fall, and flow. The biggest weakness of this approach is seeing the fog liquid from the side, so I would keep this kind of fog ankle-deep or lower.
Post Reply