Raised This Month: $ Target: $400
 0% 

How to : create semi - realistic fog / Haze


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Timmi the savage
Senior Member
Join Date: Jul 2004
Location: seattle
Old 01-11-2005 , 06:24   How to : create semi - realistic fog / Haze
Reply With Quote #1

This will cover how to create a matrix for your fogfield, setup your render style, sprite and any effects you want to add to it. This way is fine although with variations of the effect needed.

Also it will explain how you can achieve high quality fog by the
(CPU CONSUMING) per pixel method.
and I will explain a work around for lowering cpu consumption.
Timmi the savage is offline
Send a message via Yahoo to Timmi the savage
Timmi the savage
Senior Member
Join Date: Jul 2004
Location: seattle
Old 01-11-2005 , 07:28  
Reply With Quote #2

Please read through this and test it before attempting a per pixel method.....

Part one.
------------------------------------------------------------------------------------
In the attemp to create a new fog / haze /smoke for a pluging im working on / FFX for some effects I had added in I just recently. I was playing around with a matrix for some angle calculations ( GO HERE FOR THE ANGLES HOW TO ) it struck me that there was an easy uniform way to create fog/smoke which was more realistic than what is currently availalbe in hl1.

First you will need some origins you can either grab the origin from a player_entity // map.ini // entity // ect..

Code:
v_origin[3]  //..""Ie: get_user_origin(id, v_origin, 3)""..

needs to be a non float number

Now we will decide on a box/rectangle type, a circle type,or a sphere type.
We need to define the size of our area now use a matrix.

We'll decide.
for mediumsprites
Code:
     size = 30// like 1 players side by side back to back size = 60// like 2 players side by side back to back size = 90// like 3 players side by side back to back ect. New Float:f_m_fogfield[32][3][size]

Code:
Define x_size Define y_size Define z_size

-----------------------------------------------------------------------------------
Now lets define the number of sprites we will create
(lower number less quality / more performance)
This is how many sprites per area ""( xyz ) = total area ""

Lets say our area size is 100
and we have a perfect box
now we need a good sprite...
Good sprite is the key... I will provide a few samples.

We will say about 70 sprites.. // the amount
the sprite will need to be lets say..
medium = 6


Code:
amount = (( fogfieldsize * 2 + height  / ( height )) / z_layers == amt )

amount =(( 100 * 2 + 20 )  /  height) / 4   == 55
So 55 sprites
..

For circle the whole format changes

Next : Creating your matrix
Timmi the savage is offline
Send a message via Yahoo to Timmi the savage
Timmi the savage
Senior Member
Join Date: Jul 2004
Location: seattle
Old 01-11-2005 , 08:53  
Reply With Quote #3

Now that we have our information right we will set up a function to create the inital information.

Code:
createfogtable(args[4]) {    new v_orgin[3]    get_user_origin( id, v_origin, 3 )    for ( new v = 0 ; v < 2 ; v ++ ) {      f_m_fogfield[args[0][v][0] = v_origin[0]      }    for( new i = 0 ; i < args[1] ; i ++)      new offsetx = args[1] / args[3]      for (new m = 0 ; m < 2 ; m ++ )        f_m_fogfield[args[0]][m][args[i]] = f_m_fogfield[args[0]][m][args[i]] +  offsetx      }   }   return PLUGIN_CONTINUE }

Now what we just did was set up our entities fogfield.

--------------------------------------------------------------------------
refernece
Code:
args[0] = fog number / count
args[1] = size max for all 3 vecs
args[2] = height
args[3] = vertical layers
--------------------------------------------------------------------------

So with all of that in done now lets start creating the entity

new timer = 0
Code:
public createfog(args[6]) {     if (timer >= 99) return PLUGIN_CONTINUE     new addtimer = args[4] + args[3] * 2     timer = timer + addtimer / args[5]     // light = 50 -- dark     // light = 100 -- medium     new light = random_num(180, 200)     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)     write_byte( 17)     write_coord( args[0] )     write_coord( args[1] )     write_coord( args[2] )     write_short( fogspr) // sprite     write_byte( 1.1) // scale     write_byte( light) // brightness up to 255     message_end()     return PLUGIN_CONTINUE }
All we need to do now is tell it to run ...

Code:
public itssmokeyinhere(entid) {     if (timer >= 99) return PLUGIN_CONTINUE     new x, y, z     args[0] = x     args[1] = y     args[2] = z     args[3] = 100     args[4] = 20     args[5] = 4     x = f_m_fogfield[entid][0][timer]     y = f_m_fogfield[entid][1][timer]     z = f_m_fogfield[entid][2][timer]     createfog(args[])     return PLUGIN_CONTINUE }
-------------------------------------------------------------------------
set a task for this every second and end it when you odnt want it any more.

for high quality the function is easier but the cpu usage is high
Code:
new timer = 0 public createfog(args[3]) {     if (timer >= 99) return PLUGIN_CONTINUE     timer++     // light = 50 -- dark     // light = 100 -- medium     new light = random_num(180, 200)     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)     write_byte( 17)     write_coord( args[0] )     write_coord( args[1] )     write_coord( args[2] )     write_short( smallfogspr) // sprite     write_byte( 0.5) // scale     write_byte( light) // brightness up to 255     message_end()     return PLUGIN_CONTINUE } public itssmokeyinhere(entid) {     if (timer >= 99) return PLUGIN_CONTINUE     new x, y, z     args[0] = x     args[1] = y     args[2] = z     x = f_m_fogfield[entid][0][timer]     y = f_m_fogfield[entid][1][timer]     z = f_m_fogfield[entid][2][timer]     createfog(args[])     return PLUGIN_CONTINUE }

The only big difference is it add a fully packed field
Timmi the savage is offline
Send a message via Yahoo to Timmi the savage
Timmi the savage
Senior Member
Join Date: Jul 2004
Location: seattle
Old 01-11-2005 , 08:55  
Reply With Quote #4

Example comming soon.

with spherical field added.
Timmi the savage is offline
Send a message via Yahoo to Timmi the savage
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode