Game Development Community

dev|Pro Game Development Curriculum

Zone Fog using PrecipitationData

by Paul Yoskowitz · 09/12/2011 (7:17 pm) · 15 comments

What I was looking for was a zone wide fog bank. I wasnt too happy with the fog options available so i started looking at PrecipitationData because of what Richard Ranft had mentioned.

So what is fog..... basically (in this case) rain. Enlarge the drop size, slow the fall rate, remove the splatter effect.... fog. Now, i will say, this DOES effect framerate. Im not sure if there is a way around that or not.

What I did was to first go into the environment.cs file and copy/paste the "Heavy Rain" datablock to the bottom of the page. Mine looks like this:
// ----------------------------------------------------------------------------
// Fog
// ----------------------------------------------------------------------------

datablock PrecipitationData(Fog)
{
dropTexture = "art/environment/precipitation/rain";
//splashTexture = "art/environment/precipitation/water_splash";
dropSize = 35;
splashSize = 0;
useTrueBillboards = false;
splashMS = 0;
};

You can then add this datablock into the mission file:
new Precipitation(zonefog) {
numDrops = "40960";
boxWidth = "2000";
boxHeight = "100";
dropSize = "50";
splashSize = "0";
splashMS = "0";
animateSplashes = "0";
dropAnimateMS = "0";
fadeDist = "0";
fadeDistEnd = "10";
useTrueBillboards = "1";
useLighting = "0";
glowIntensity = "0 0 0 0";
reflect = "0";
rotateWithCamVel = "0";
doCollision = "0";
hitPlayers = "0";
hitVehicles = "0";
followCam = "1";
useWind = "1";
minSpeed = "0";
maxSpeed = "0";
minMass = "10";
maxMass = "15";
useTurbulence = "0";
maxTurbulence = "0";
turbulenceSpeed = "0";
dataBlock = "Fog";
position = "123.786 -76.4658 390";
rotation = "1 0 0 0";
scale = "1 1 1";
canSave = "1";
canSaveDynamicFields = "1";
};

And the effect that you get can be seen on this post:
http://www.garagegames.com/community/forums/viewthread/127662

As a side note - for an area of fog:
change

numDrops = "40960";
boxWidth = "2000";
boxHeight = "100";

to

numDrops = "4096";
boxWidth = "200";
boxHeight = "100";

and then UNCHECK followCam

That should create a small area of fog instead of something zone wide.



#1
09/12/2011 (8:25 pm)
Thanks for the nod, but it's all you man! This rocks! And thanks for sharing - awesome work, really.

As for frame rate, maybe play with the materials so you can use fewer "drops." Fewer polys is always better. 40960 drops is 81920 sorted alpha blended polygons - try that by hand! The squirrels are dying.... Perhaps reduce the render radius to cause the precipitation to fall off nearer the player, or in some other way alter the density of particles to relieve some of the strain on the video card.

Wait - is the precipitation on quads? Could render it on single triangles, with some adjustments for long narrow raindrop tris and big fat fog tris. Potentially cut the polycount in half.
#2
09/12/2011 (8:42 pm)
40960 isnt BAD considering its a zone but your right. it really gets to be how THICK of a fog youre looking at.

I was playing with ways of effecting it using zoning and portals for the smaller area stuff, but i think your right, this may end up being a material or possibly lower the count, make the box smaller and leave followCam checked.

Dunno yet. Thats gonna be a bit of playing around involved. This will be an effect in an MMO (for me at least) and available in OMNI(what we are calling the MMO Software Suite) that WinterLeaf Entertainment is working on so im SURE that ill get to hear about it as we work on things more. :)

#3
09/12/2011 (11:03 pm)
this looks great as a zone effect but not so good in small areas. the billboards really kill the effect. Will be interested to see what you come up with.
#4
09/13/2011 (3:56 am)
I think i give this a try, today. May some fog like this resource looks cool in "Proton" :)
#5
09/13/2011 (5:29 am)
If you use particle emitters for the location-based fog I believe you can also affect it with wind emitters. This would also let you cause the billboards to spin slowly to help with the "cloud" look for that, along with a gradual fade in/out.

I guess I should get off my butt and look at the precipitation on the engine side to see what it does for culling. I was misinterpreting the drop count as what was to be rendered in the player's range of view.

Looks great, though.
#6
09/13/2011 (8:19 am)
This has lots of promise and I too shall keep watching a tinkering with it. I am hoping for a small area of fog and not a full zone so may have to find another way. But this is great for zone fog, great work.
#7
09/13/2011 (8:52 am)
@Greg - i had to double my zone and the pics i posted were from a small area fog. maybe im missing what your issue is.
#8
09/13/2011 (2:17 pm)
I want to mess around a bit more and make sure it's not something stupid in my settings. I am wanting a small area of 'fog' around ground/floor level for catacombs and dungeons. this effect once lowered and placed in a small dark area gets real streaky from billboarding. could also be my settings. if I don't get anything figured out I can post a screen pic and show you what I am getting
#9
09/14/2011 (3:39 am)
I try out this, but never got fog, like i will have. I used different texturs and settings, and allways i was not really happy. May the particle idea looks better. I think also, that it need a fade in/out.
#10
09/16/2011 (9:33 am)
Using particles for fog is rather inefficient and, as some have already mentioned, often ugly as well. Why wouldn't you use volumetric fog, which can be implemented in a shader? It's more efficient and better-looking...


#11
09/16/2011 (12:36 pm)
@kevin - thats simple. Because I know nothing about implementing shaders. HOWEVER, if u do, and would care to post a resource on it, plz be my guest :) i was simply working with that I know.
#12
09/20/2011 (3:29 pm)
I'm afraid I don't have an immediate solution for you; however, if you google "volumetric fog" or "area fog" you will find a lot of info on the subject.
#13
09/23/2011 (7:48 am)
ah, from your post i thought you would already have a solution handy :)

This will have to do for now then. as much as I would love a better fog, thats lower on the list until i can get more help on this project.
#14
10/06/2011 (1:50 am)
Thanks! It made for a quick, easy fog.

Before:
jyaskus.com/images/misc/screenshot_001-00000.pngjyaskus.com/images/misc/plane_crash1.wmv

After:
jyaskus.com/images/misc/screenshot_002-00000.pngjyaskus.com/images/misc/plane_crash2.wmv

Shader version would be great ... but this is a good start!
#15
01/29/2013 (5:54 am)
awesome,thank you~~