Weather Effects: Snow

Lots of cool and useful tips to mod either serverside or clientside
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Weather Effects: Snow

Post by Apache Thunder »

I have created a pretty good looking snow effect (that DOESN'T lag) and I will release it for modders to enjoy. Just pack into your mod (or map) and place on the map in patches of 1 per 500 meters. Do NOT attempt to place more then one in any 500 meter area or risk a CTD. The game CTDs if there is more then 5000 sprites on the screen. (it won't crash if there was 5000+ particles though, but it would lag to hell. :P )

So this is the most snow you can get, but it's better then nothing and still looks great!

Video of the Christmas special:

Image

That video is a bit outdated. One I corrected the size of the snow flakes, and two, I have them spread out more evenly instead of spawning in a vertical tower. :P

Download link:

http://www.filefront.com/15151981/SnowEffect.rar

Contains the effect bundle code and the snow texture it uses. Full instructions included in the archive.
Last edited by Apache Thunder on Thu Dec 17, 2009 6:11 am, edited 1 time in total.
ImageImageImage
I have cameras in your head!
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Weather Effects: Snow

Post by Apache Thunder »

ImageImageImage
I have cameras in your head!
Poow
Posts: 271
Joined: Sun Nov 01, 2009 8:00 pm
Location: Germany
Contact:

Re: Weather Effects: Snow

Post by Poow »

:D
Nice! Also the whole heroes thing!
You are a real working machine :o
You’re entering a world of pain!
reegad
Posts: 81
Joined: Mon Nov 09, 2009 3:43 pm

Re: Weather Effects: Snow

Post by reegad »

Very cool indeed ^^
Image
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Weather Effects: Snow

Post by Senshi »

Nice effect, but sadly it's not really much snow...I'd probably cluster multiple snowflakes into single textures so I can increase the amount of snow without hurting the sprite counter :) . But the code is well done, gratz on that.
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Weather Effects: Snow

Post by Apache Thunder »

Yes it wasn't much in that one because half the snow didn't make to the ground. After further tweaks to the initial speed they spawn with and the gravity modifier, I got most of them to come down to the ground before their timeToLive expires. So it looks better now.

Here's an HD video of snow in Berlin. I used a different texture for the snow flakes in this one. The BFHeroes snow flake is a bit too cartoony for Berlin. :D

http://www.youtube.com/watch?v=l-iEjbRXR8g

If that won't convince you, nothing will! :D
ImageImageImage
I have cameras in your head!
Sniperjack
Posts: 24
Joined: Tue Oct 27, 2009 11:18 pm

Re: Weather Effects: Snow

Post by Sniperjack »

I have seen a very similar effect in custom Forgotten Hope maps, but I think this one has a nicer look to it.
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Weather Effects: Snow

Post by Senshi »

Well, I think the real strength of this method can be seen in the vid when he looks straight up in the sky. The particles appear to spread randomly, but also smooth enough to appear real. I can compare it right now with a look out of the window here. Some real nice flakes there, I might integrate that on our next projects' battle on Sunday...though it might be weird as we'll have to fight a desert map :D .
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Weather Effects: Snow

Post by Apache Thunder »

Thanks!

I will try and explain how it works.


OBJECTS.CON

Code: Select all

ObjectTemplate.create Bundle e_Snow
ObjectTemplate.hasMobilePhysics 0
ObjectTemplate.hasCollisionPhysics 0
ObjectTemplate.hasResponsePhysics 0
rem ------------------------------------
ObjectTemplate.addTemplate e_Snow_RotationalBundle

rem *** Must have a geometry if addTemplated effect bundles are going to work! ***
ObjectTemplate.create RotationalBundle e_Snow_RotationalBundle
ObjectTemplate.geometry radarbun_tow_M1
ObjectTemplate.createInvisible 1
ObjectTemplate.hasCollisionPhysics 0
ObjectTemplate.hasResponsePhysics 0
ObjectTemplate.setMinRotation 0/0/0
ObjectTemplate.setMaxRotation 0/0/0
ObjectTemplate.setMaxSpeed 200/0/0
ObjectTemplate.setAcceleration 200/0/0
ObjectTemplate.setContinousRotationSpeed 200/0/0
rem -------------------------------------------
ObjectTemplate.addTemplate e_Weather_Snow
ObjectTemplate.setPosition 0/90/256
ObjectTemplate.setRotation 0/-90/0
That is the important piece that makes this work. I put the effect bundle onto a rotational bundle. The effect bundle is rotated sideways so that the verticle vector is now the horizontal vector. The rotational bundle spins the whole effect around so that randomly spawned snow sprites using CRD_UNIFORM are spread out evenly. They spawn on the verticle axis vector (which is now on the horizontal axis vector) and thus there needed to be a rotational bundle.

I couldn't get the reletivePositionInRight command to work with CRD_UNIFORM, despite whatever I used, it didn't work. They all still spawned in random places only on the vertical vector. (reletivePositionInUp). Hince the reason why I had to put it on a rotational bundle. (if you know a way of getting the ReletivePositionInRight to accept CRD_UNIFORM correctly, then please do tell. :P )


It is also centered on the rotational bundle. So that from the center, each arm of the vertical axis of the effect spans 256 meters in both directions. Imagine it like those spinner things in some Car washes. It simply rains snow and the spinner just spins around spraying out the snow evenly. ;)

EFFECTS.CON:

Code: Select all

ObjectTemplate.create Emitter em_Snow
ObjectTemplate.template Fx_Snow
ObjectTemplate.lodDistance 512
ObjectTemplate.timeToLive CRD_NONE/1/0/0
ObjectTemplate.intensity CRD_NONE/200/0/0
ObjectTemplate.relativePositionInUp CRD_UNIFORM/0/512/0
ObjectTemplate.positionalSpeedInUp CRD_UNIFORM/5/-5/0
ObjectTemplate.startRotation CRD_NONE/0/0/0
ObjectTemplate.looping 1
ObjectTemplate.addChild 1
ObjectTemplate.startAtCreation 1
ObjectTemplate.startProbability 1

ObjectTemplate.create SpriteParticle Fx_Snow
ObjectTemplate.texture e_Snow
ObjectTemplate.mipMaps 0
objectTemplate.drag CRD_NONE/0.1/0/0
ObjectTemplate.timeToLive CRD_UNIFORM/10/18/0
ObjectTemplate.size CRD_UNIFORM/0.08/0.15/0
ObjectTemplate.gravityModifier CRD_UNIFORM/0.1/0.2/0
ObjectTemplate.destBlendMode BMOne
objectTemplate.hasStaticColor 1
And that's the Effect bundle. It spawns 200 sprites per second. Each sprite has a CRD_UNIFORM setting for timeToLive that has them last from 10 to 18 seconds. My rough math puts that at a max of 4000 sprites that could be on the screen at once, though the timeToLive random factor will always meen there will be less then 4000, but 4000 is the theoretical limit. that this effect is set to produce. So it's about as close as I can get it without hitting the 5000 CTD ceiling. Now despite that being a CRAP LOAD OF SPRITES, it doesn't lag at all! At least not on my machine. My machine isn't some suped up rig that can run all the latest games at high settings either. So if it doesn't lag my machine, it really shouldn't lag yours either. And the effect quality setting might alter how this effect behaves as well. So some users can just turn down the effect quality setting if it lags them for whatever reason. One of my guess as to why it doesn't lag is the code for the SpriteParticles are as simple as they can get. There is no color over time setting, nor is there a size over time setting and nothing overly fancy is done with them other then the drag modifier. The rain in the King of the Hill map in DCX however uses Particles and they do some fancy things like change in size and move around and stuff. The game handles the physics for Particles differently then Sprites. Thus, the rain effects in DCX lags to hell. ;)

The ObjectTemplate.positionalSpeedInUp also has a CRD_UNIFORM setting. It will spawn the flakes in from -5 to 5 speed. So they will have random directions to them much like how real snow is. :P

For rain, I pan to have that as a CRD_NONE with a constant direction so that I can slant the rain in a direction and it will not be random like the snow. ;)

I added the lodDistance setting and set it as 512 meters. So in theory you should be able to place more the one effect bundle on the map and have them separated from each other by that amount. But I won't know if that can work properly or not. I also used to have a lod system set up for the bundle that has the rotational bundle. But it wouldn't behave in DesertCombat (not activating the effect like it should), thus I removed it and updated all my links. ;)

I sent this code to DACV and he will soon test it in BFV. I do not know how this effect will behave in BFV since I don't have the game installed right now. There is also the possibility that BFV won't crash if you exceed 5000 sprites like BF42 does. So BFV might handle it better. I encourage those who have BFV to stress test this effect and see how BFV handles it. Also, you can add BFV specific commands to the effect and perhaps improve it's appearance in way that BF42 can't do.
ImageImageImage
I have cameras in your head!
User avatar
Iced Earth
Posts: 209
Joined: Sun Oct 18, 2009 2:07 pm
Contact:

Re: Weather Effects: Snow

Post by Iced Earth »

nice dude!

That reminds me, I wanted to post it here but never got around to it. I was searching for random maps on bf1942files.com (bf2files.com), and found a map named Donner. I opened it in BC before playing, and it looked pretty dull. It has a nice grey sky and rain effect with nice sounds though:

http://www.xfire.com/video/19ce07/

Here's a link to the map:
http://battlefield2.filefront.com/file/Donner;99801
Image
Post Reply