Skip to main content
gamedev.net
🔒 Locked

Snow

Started by black_mage_s 20 replies 450+ views
Original Post
black_mage_s
black_mage_s
i am looking to add a snow effect in my game (also to be used for ash and dust FX) but dont know where to start. Can anyone help me or just point me in the right direction? Thx!
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me
JimboC
JimboC
I would think you''d just want to create some kind of a particle spray.

What language are you using and what API?
black_mage_s
black_mage_s
language : c++
api : direct 3d
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me
Shannon Barber
Shannon Barber
I think you need a particle system to do convincing snow. A really good one at that.
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Pactuul
Pactuul
create a particle system... with particle systems each "flake" would be particle with a vector for it''s speed and direction. and so to adjust this you would update each particle each frame by moving the particle''s position by the velocity vector. with this you could also add in gravity by multiplying vectors together. But that''s just some ideas to get you started.

Mostly creating a particle class with these properites and what ever other editable stuff you want and then have a particle system class that contains an arry of particles...


Pactuul
-Pac "The thing I like about friends in my classes is that they can't access my private members directly." "When listening to some one tell about their problem (whether it's code or not), don't listen to what went right or wrong, but what they assumed....."
black_mage_s
black_mage_s
it is already snowing, and the land covered in snow has an effect where you leave footprints that dissapear after time (fade away). I saw the exact thing i want in this demo [url]http://home.mindspring.com/~tcbaker/demo6_12_01.zip[/url]
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me
black_mage_s
black_mage_s
so can anyone else help?
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me
krez
krez
rather than using single snowflakes for the particles, you should make a bunch of flakes per particle (use a sprite with several white dots on it)... that way you can have more particles without slowing down the game too much. if you do it right (with some overlap of the snow particle sprites) it will look like eddies in the air blowing snow, not just that some flakes are "attached" as you might think.

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
black_mage_s
black_mage_s
hmmm... yes, that would work, but i dont know how to do particles.

one of my ideas was to have a large poly over the area i want the snow in that looks like this
/--/ \--\
| | | |
| | | |
/ \--/ \

and goes like that. then i just map a bitmap texture on and shift the dimesions of the poly. but it isnt a good idea
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me
krez
krez
this guy has a tutorial on particles:
http://64.23.12.52//Tutorials/DirectX7/IM_Particles.asp
this uses D3D from directx 7 i think, but even if that isnt what you are using the basic stuff behind it is the same.

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Gladiator
Gladiator
well particles are simple...

here's a simple structure for a particle..

struct PARTICLE
{
float x; // \ location
float y; // / of particle

float xVel; // \ velocity
float yVel; // / of particle

float color; // color

// you might add energy, and a lot of other funky stuff..
};

then you have a list of particles.. you can use array or linked list... depending on how oyu want your particles to work (both methods have their onw advantages/disadvantages concerned with speed/memory

you have to initialize your particles in the beginning of your program...

then in each frame you erase the particles, then move them, and draw them again...

the important function here is the moving function. heres where you define the path of your particles.. reasearch a snow algorithm and get a formula that will resemble snow path (there are many ways that you can do snow which will not exactly look like snow but will be pretty close so the player knows what's going on

i have old program i wrote that's like a fountain of fire works..

for example try this:

xVel += -1+random( 3 )
yVel = 1

for i = 0 to numParticles
begin
x += xVel
y += yVel
xVel += -1+random( 3 )
yVel += 1
end

that might go for a look-alike of snow

the velocity is basically the most important aspect of particles since it gives them the path and that's how you define what the particle system resembles..

you can have wind factor and a lot more... if you want the snow to fall on the ground then you can do something like this

pseudo code:

if x < 0 or x > SCREEN_WIDTH-1
makeNewSnowFlake( )
if y >= SCREEN_HEIGHT-1
putPermanentFlake( x, SCREEN_HEIGHT-1 )
if getpixel(x,y+1) equal WHITE
putPermanentFlake( x, y )


you check if the flake is out of view on the way down..if it's out of view then you make a new flake...
if the snow is just starting to snow and theres no snow on the ground you will check to see if the flake goes out of view from the bottom of the screen if so you put a snowflake on the bottom...after a while there will be snow flakes on the bottom of the screen so you also have to check if theres a snowflake already under the current snow flake and if that's the case you place the current one on top of it.

well it's not that difficult..if i think of something else i'll let you know..or you ask questions..

-------------------------------
Did someone say "banana"?

..-=gLaDiAtOr=-..

Edited by - Gladiator on October 13, 2001 9:55:40 PM
Gladiator
Gladiator
oh another think..you can make the snow fall down if a lot of snow has collected over a short distance..if you wanna do that you''d most likely wanna use a linked list since you keep a record of all the flakes that are on the ground (you will also have to add a state so you can mark them DEAD once they are on the ground). once a snow flake is dead you insert a node with a new flake (instead of reseting the current flake''s values..) it''s up to you... search for particle tutorials on google or yahoo... im sure you''ll find plenty

-------------------------------
Did someone say "banana"?

..-=gLaDiAtOr=-..
black_mage_s
black_mage_s
wow, you guys are great help!
This stuff is great.
i may just be able to use it all
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me
bishop_pass
bishop_pass
Hmmm, just for fun, I thought I would drag out this old debate on snow. It focuses on how snow deposits on the landscape and where it remains during the course of melting.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
Zimans
Zimans
Something you may want to consider instead of just accumulating more and more particles on the ground, is to meld them into a new texture associated with whatever they are hitting (2d tile quad, terrain quad, etc.) Then instead of having to draw more triangles, you just have another texture being blended in with the original texture, wich if I am correct would be faster as more snow flakes accumulate. Plus you could probably get some nice effects with alpha blending.

-Zims
krez
krez
after reading the debate mentioned above by bishop_pass, i would suggest forgetting snow completely. move your game to the tropics

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
black_mage_s
black_mage_s
that was the dumbest topic i have seen, plus making an rpg would be hard to do without my snow places
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me
GalaxyQuest
GalaxyQuest
uhh..there is more to it then whats been discussed. Here are some issues that you would need to consider, which i didnt see mentioned:

You only want to create "snow" particles within the view frustrum, to lessen impact on triangles on screen.

Particles usually have all 3 axis, x,y and z so your not limited to just "snow" but explosions, etc later when u need such things.

If these particles are textured triangles, you may need to consider the orientation of the particles. Will the particles always be facing you, even if you turn your head a little bit?

Keep lookin for tutorials on how to do particle systems. And use google!

Have you looked at ParticleSystems.com ??
bishop_pass
bishop_pass
quote:
Original post by black_mage_s
that was the dumbest topic i have seen, plus making an rpg would be hard to do without my snow places


Why thank you, black_mage_s. Your comment reminds me of many of those made in my topic. Good luck with your endeavors.

_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
black_mage_s
black_mage_s
i meant dumbest topic by some of the aguments made. it seems a lot of people are favoring eye candy over gameplay, when there should be an even balance
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.