Unreal Snow Particals

Blitz3D Forums/Blitz3D Programming/Unreal Snow Particals

Neochrome(Posted 2003) [#1]
Any one got any nice out door snow FX i could play with? Mine is just a load of particals and REALY Eats my processor :o(

if you have suguestions or sample codes i could look at ?


Ross C(Posted 2003) [#2]
Single surface particle system? Bouncer had one and he managed a huge number of particles. Something like 10,000! ran at 50 fps on my computer, but it's good!


Warren(Posted 2003) [#3]
The key is to only spawn the snow around the player in a certain radius. Fade/scale them as they get further away and you're done. You don't need to hose the entire level with snow.


poopla(Posted 2003) [#4]
/me wonders why everyone thinks because something was done in Unreal 2... that it is somehow using a mysterious technique.


Warren(Posted 2003) [#5]
Everyone doesn't think that.


Neochrome(Posted 2003) [#6]
i need a quick and simple way of doing it, tho when i walk about my snow disapears. and im already using a tad too many paticals already :o(

would it be better to use one sprite over the screen and render the snow on that?


poopla(Posted 2003) [#7]
Spawn the particles only arround your player, and offset their spawn position by your players global motion vector. They will spawn where he is heading and be in view (of course a bit of a change has to occure when he moves backwards or the particles will spawn behind the camera's view frustrum..


Ross C(Posted 2003) [#8]
i'd personally spawn particles behind the player. So that when he turns round, there are half fallen particles etc behind him. They won't be rendered anyways.


Ross C(Posted 2003) [#9]
Hey, try this out. I couildn't get the alpha on the particles to look right, and there a bit to big, but the program does what it's supposed to. Use arrow keys to move. The codes not commented too much, but it's pretty straight forward. I've commented the lines to change to acheive a greater snow radius. The snow fallsfrom a height of 10 unit above the player, and 3 units below his feet.

Graphics3D 800,600
SetBuffer BackBuffer()

Global camera=CreateCamera()
PositionEntity camera,0,2,0

Global light=CreateLight()

Global plane=CreatePlane()
EntityColor plane,50,50,250

Global tex=CreateTexture(32,32,1+4)
SetBuffer TextureBuffer(tex)
Color 255,255,255
Oval 0,0,32,32
SetBuffer BackBuffer()

Global main_sprite=CreateSprite()
EntityTexture main_sprite,tex
HideEntity main_sprite

Dim cubes(15)

For loop=0 To 15
	cubes(loop)=CreateCube()
	PositionEntity cubes(loop),Rnd(-30,30),0,Rnd(-30,30)
Next

Type particle
	Field x#,y#,z#
	Field angle#
	Field distance#
	Field ent
	Field speed#
	Field alpha#
	Field size#
End Type

Global snow_parts=50; NUMBER OF SNOW PARTICLES!!!
Global distance=40; CHANGE THIS FOR A GREATER RADIUS OF SNOW!!!


For loop=1 To snow_parts
	p.particle=New particle

	p\ent=CopyEntity(main_sprite)

	p\angle=Rnd(0,359)
	p\distance=Rnd(3,distance)
	
	p\x=EntityX(camera)+Cos(p\angle)*p\distance
	p\z=EntityZ(camera)+Sin(p\angle)*p\distance
	p\y=EntityY(camera)
	PositionEntity p\ent,p\x,p\y,p\z
	
	p\speed=Rnd(0.1,0.8)

	p\size=Rnd(0.1,0.8)
	ScaleSprite p\ent,p\size,p\size

	EntityAutoFade p\ent,0,distance
Next



While Not KeyHit(1)



	If KeyDown(200) Then MoveEntity camera,0,0,0.2
	If KeyDown(208) Then MoveEntity camera,0,0,-0.2
	If KeyDown(203) Then TurnEntity camera,0,1,0
	If KeyDown(205) Then TurnEntity camera,0,-1,0
	
	updateparticles(EntityX(camera),EntityY(camera),EntityZ(camera))
	
	UpdateWorld
	RenderWorld
	Flip
Wend
End

Function updateparticles(x#,y#,z#)
	For p.particle=Each particle
		p\y=p\y-p\speed
		PositionEntity p\ent,p\x,p\y,p\z
		If p\y<(y-3) Then
			p\y=y+10
			p\angle=Rnd(0,359)
			p\distance=Rnd(3,distance)
			
			p\x=EntityX(camera)+Cos(p\angle)*p\distance
			p\z=EntityZ(camera)+Sin(p\angle)*p\distance
			p\speed=Rnd(0.1,0.8)
			PositionEntity p\ent,p\x,p\y,p\z
			
			p\size=Rnd(0.1,0.8)
			ScaleSprite p\ent,p\size,p\size
		End If
	Next
End Function



Neochrome(Posted 2003) [#10]
Whoohoo, thats about it!! NICE!! would you mind me using this?


Ross C(Posted 2003) [#11]
Yeah, sure. It's you i coded it for :)


Neochrome(Posted 2003) [#12]
Cool.. houw would i make this go in to a single surface? its very simulare to what i originially came up with, but this one has cos, and sins! haha


poopla(Posted 2003) [#13]
Ross C., your essentially saying "oh, dont worry about the hundreds of parrticles being updated behind you you will never see. There are better ways to do it.


Ross C(Posted 2003) [#14]
There's only about 25 behind the player. They aren't rendered, and it doesn't take much time to cycle thru 50 types.

I done a test a while back, and if entites aren't onscreen and they aren't using collisions, then it's no better to hide them. Of course, it depends on how tight you wanna make it. But of course you have a point in maybe the amount of memory each particle might take up. Again, i don't think this would be a problem, but i usually learn things the hard way :)

Going single surface may give you a slight boost.
I think if you wanted to use this in single surface particles, just apply the x,y,z co-ords to the quads, and go about what you would normally do.


poopla(Posted 2003) [#15]
I don't know his situation, so it may work fine for him. In my case however I am using a huge ammount of processing power every loop for rendering, multiplayer, physics, collisions, mesh deformations etc etc. So I focus on saving every last drop of system performance.


Ross C(Posted 2003) [#16]
Yeah, i suppose. It was just a 10 minute job. I'll try and optimise some more maybe.


cbmeeks(Posted 2003) [#17]
EDIT:

Nevermind...I had to reload my video card drivers...stupid dell computer!!

All I get is a blank screen?

cb