making my stars blur

Blitz3D Forums/Blitz3D Beginners Area/making my stars blur

GameCoder(Posted 2004) [#1]
Hi! I wrote this code to try and implement a blur effect. I have not added any blur effect yet, I just want some tips on how I could achieve it.

The code below is just some stupid code that makes a starfield. Basically and hints or tips only that will point me in the right direction for making each star have a blur effect. ie leaving a blurry trail behind it as it goes down the screen


Graphics3d 1024,768,16
SetBuffer BackBuffer()

Type particle
	
	Field x#
	Field y#
	Field g#
	Field s#
	
End Type

Global maxstars = 0
Global numstars = 10

While Not KeyHit(1)
	
	Cls
		
		make_stars()
		plot_stars()
		increase_stars()
		
		Text 0,750,"Number of stars =" +numstars
		Text 0,740,"Maximum Stars on screen =" +maxstars
		Text 0,10,"Press Left Control key to increase stars"
	Flip
	
Wend

End

Function make_stars()
	
	For i = maxstars To numstars 
		
		p.particle = New particle
		maxstars = maxstars + 1
		p\y = -1
		p\x = Rnd(0,1024)
		p\s = Rnd(1,10)
		
	Next
	
End Function


Function plot_stars()
	
	For p.particle = Each particle
		
		Plot p\x,p\y
		
		p\y = p\y + p\s
		
		If p\y > 768 Then
			
			 Delete p
			 maxstars = maxstars - 1
		EndIf
		
	Next
	
End Function

Function increase_stars()
	
	If KeyDown(29) = True
		
		numstars = numstars + 1
		
	EndIf
	
End Function



Should I start by looking at locking buffers?


Ross C(Posted 2004) [#2]
There's an excellent fast blur in the code archives. Basically you copy the backbuffer to a quad or sprite in front of the screen, every frame.


GameCoder(Posted 2004) [#3]
Thx Ross. :) I'll have a look.


Neo Genesis10(Posted 2004) [#4]
Or you could set CameraClsMode to clear Z buffer only and set a translucent black sprite in front of the camera. The opacity would then vary the intensity of the blur.


Perturbatio(Posted 2004) [#5]
Sticking with 2D only, I added a z coord which varies the intensity of the star, and a slight trail. Is this what you were thinking about or did you want more blur?

Also, I changed it to re-use the particles rather than deleting and recreating them every time.




GameCoder(Posted 2004) [#6]
Thats what I was looking for Pertubation. Thx :) Although a little more trailing blur would be nice. :)