DreamFilter

Community Forums/Showcase/DreamFilter

Afrohorse(Posted 2004) [#1]
Here's a screenshot of a real-time fullscreen filter I've been working for a dream sequence - "The Dream filter"



It's got a mix of motion blur, high dynamic range and depth of field (it's not exact - but it's close enough ;) )

As you can imagine it's heavy on fill-rate and I think you'll need a geforce 3 or above for it to run smoothly (runs at around 140 fps on a geforce 4 ti4600 ). Actually, if anyone wants to try it out for me just let me know.

I tried to post it on the Gallery, but it didn't appear after a couple of days, so I posted it here instead.

Enjoy :)


Filax(Posted 2004) [#2]
Realy nice !


Clique(Posted 2004) [#3]
Yeah looks great, i would try it but i dont have a good system spec, but hey i could still try it out to see how it runs on my comp and i will tell you the fps, if you want to send it me, my email is on my profile.
nice work!


Afrohorse(Posted 2004) [#4]
Ok, I've put together a test I'd like people to try out just to see how other machines handle it!

Here it is! (1.9Mb)

It crashes on exit though, there seems to be a problem with the level exported from cshop :( - but that's another story...

Please give it a go - and enjoy :)


jhocking(Posted 2004) [#5]
Wow, that demo is really slick. The 800x600 runs at 114-150 fps on this 2.4GHz Xeon with 2GB RAM and QuadroFX. Mind posting code?


Shambler(Posted 2004) [#6]
An interesting effect,

140-180 640*800
130-150 800*600

Details in sig.


gellyware(Posted 2004) [#7]
218fps @ 640x800
180fps @ 800X600

Using a radeon 9800pro, pentium 3.06ghz 512 ram


Beaker(Posted 2004) [#8]
That is gonna choke on my Matrox G400... brb with a report...


Beaker(Posted 2004) [#9]
24-25 FPS @ 640x480
18-19 FPS @ 800x600

Matrox G400max
AMD1300

Quite watchable and a nice effect even at those frame rates.


GfK(Posted 2004) [#10]
~45FPS @ 640x480
~35FPS @ 800x600

Athlon 900MHz
GeForce2MX (32Mb)


ErikT(Posted 2004) [#11]
57-59 fps - 640x480
38-41 fps - 800x600

AMD 1.6 Ghz
Geforce2 64 MB ram

Cool stuff.


dan_upright(Posted 2004) [#12]
140fps @ 640
110fps @ 800
athlon xp 2k+
256 meg geforcefx 5600


Kanati(Posted 2004) [#13]
180fps @ 800x600
215fps @ 640x480

Athlon64 3000 / Radeon 9600XT

Love to see what it could do with a top notch vid card and my cpu.

Kanati


RifRaf(Posted 2004) [#14]
120fps @ 800x600
110fps @ 640x480

p4 2.4ghz radeon 9600


bruZard(Posted 2004) [#15]
80-93 FPS @ 640x480
73-79 FPS @ 800x600

Radeon9600 - P4 2.4GHz


biostrike(Posted 2004) [#16]
21 FPS @ 640x480
15 FPS @ 800x600 :(

Intel 845G/GL - P4 2.5GHz


napole0n(Posted 2004) [#17]
27 fps @ 800x600
31 fps @ 800x600

P4 2Ghz, nVidia Quadro2 Pro

Looks very nice!


M2PLAY(Posted 2004) [#18]
WOOO!!! Fantastic!!!
640x480 22fps
old machine
P II 400 MMX
NVIDIA TNT2 Model/64 Pro 32 Mb


Skitchy(Posted 2004) [#19]
Wow, very nice FX :) Almost looks pre-rendered.


koekjesbaby(Posted 2004) [#20]
you might call it "the dream filter" i just call it feedback. i did the same thing a zillion times by rendering the screen to a texture en and put that texture on a transparent (and optionally with blend mode 3) plane just before the camera. the effect greatly depends on how big and transparent the plane is.

examples:
here the feedback plane is actually smaller than the area rendered by the camera creating an "inwards" effect (no it's not motion blur and the blocks are not moving, altho this effect could be used to create some sweet motion blur).


regular feedback:


the variations in the light (the "rays") are caused by the relative low resolution of the feeback texture(256x256).


also, really funcky effects (winamp visualisation anyone?) can be accomplished by rotating the plane (over any axis) or using the "vortex" descibed by jeppe nielsen in this thread ( http://www.blitzbasic.com/Community/posts.php?topic=29282 ) as feedback plane.

if anybody want to have my source (it's pretty modular in setup, two include files: one to setup the cameras (you actually need two) and one for the rendering) with dutch comments and dutch varable names, i'd be happy to provide it.


Gabriel(Posted 2004) [#21]
Very cool effects, both by Afrohorse and by koekjesbaby.

Not really much point in posting my FPS because I always get the same as Shambler ( same cpu, same GPU ) but still :

140-180 640*800
130-150 800*600


Athlon 2700+ Ati Radeon 9700Pro 1GB Ram 120GB HD


I'd definitely like to see source for those effects, koekjesbaby. I'd like to see the source to AfroHorse's work too, but you didn't offer so I'll mind my own business ;)


Afrohorse(Posted 2004) [#22]
Thankyou all for testing the filter - its nice to see this kind of support from people :) So in return I'll post up the source code for it.

Well done to Lucid for the highest frame rate, and I'm quite surprised that the lower end graphics cards manage the fill-rate (22fps on a TNT2 Model/64 Pro!) - great!

Yes it is based on the old feedback method, I just called it the dream filter because thats what it looked like - so here's the code, I'll also try and post it to the code archives too:

;===============================================================================
; Dream Filter - Ian Lindsey (Afrohorse)
; ------------
; 03 Feb 2004
;
; The scene is rendered to a smaller sized viewport and copied into a texture.
; The texture is placed onto a sprite that overlays the entire screen, using 
; an additive blend - this sprite also is scaled slightly larger than the screen.
; (The filtering will blur the scene - like depth of field)
;
; The sprite is then fed back into the next frame (motion blur), so that the 
; additive blend burns the brighter parts of the scene into the texture. The 
; slight scale up of the sprite will add a bloom effect around these bright parts
; (High dynamic range).
;
; Example Usage:
; --------------
;
; <Program Start>
; Create the camera (use Global g_Camera)
; NBDreamFilter_Create()
;
; <Main Loop>
; Program Update code..
; NBDreamFilter_Update()
;
; RenderWorld
; Flip
; <End Of Main Loop>
; 
; <Program End>
; NBDreamFilter_Destroy()
; 
; =====================================================================
; NOTE: The scenes camera should be placed in a global variable called
;       g_Camera
; =====================================================================
;
; 
;===============================================================================

; Includes /////////////////////////////////////////////////////////////////////

; Constants ////////////////////////////////////////////////////////////////////

; Tweakable Values 
Const k_HDRTextureSize 	= 256		; Blur texture size, must be power of 2
Const k_HDRMotionZoom#	= 1.022		; The amount the blur sprite scales
Const k_HDRBlurFeedBack = 220		; 0 - 255 The amount of previous frame to feedback
Const k_HDRBlurFilter	= 100		; 0 - 255 The amount of the filter to overlay (additive) to the scene

Const k_HDRZSpritePos#	= 1.1
Const k_HDRSpriteOffs#	= 0.001

; Globals //////////////////////////////////////////////////////////////////////
Global g_BlurTex
Global g_BlurSprite

; Functions ////////////////////////////////////////////////////////////////////

;///////////////////////////////////////////////////////////////////////////////
; Creates the Dream filter
;///////////////////////////////////////////////////////////////////////////////
Function NBDreamFilter_Create()
	
	; Create a fullscreen sprite
	spr 		= CreateMesh(g_Camera)
	sf 		= CreateSurface(spr)
	
	; Make a quad
	AddVertex   sf, -1, 1, 0, 0, 0
	AddVertex   sf,  1, 1, 0, 1, 0
	AddVertex   sf, -1,-1, 0, 0, 1
	AddVertex   sf,  1,-1, 0, 1, 1
		
	AddTriangle sf, 0, 1, 2
	AddTriangle sf, 3, 2, 1
	
	; Set up the sprites position, scale etc...
	zpos#		= k_HDRZSpritePos#
	range#		= k_HDRMotionZoom*zpos#
	PositionEntity  spr,  -k_HDRSpriteOffs#, k_HDRSpriteOffs#, zpos#
	ScaleEntity   	spr,  range#, range#, 1.0
	EntityOrder	spr,  -10000
	
	; Set full colour & additive blend
	EntityFX 		spr, 1
	EntityBlend     	spr, 3
	g_BlurSprite  = 	spr
	
	; Create blur texture
	g_BlurTex = CreateTexture(k_HDRTextureSize, k_HDRTextureSize)
	EntityTexture spr, g_BlurTex
	
End Function

;///////////////////////////////////////////////////////////////////////////////
; Destroys the Dream filter
;///////////////////////////////////////////////////////////////////////////////
Function NBDreamFilter_Destroy()

	FreeTexture g_BlurTex
	FreeEntity  g_BlurSprite
 	
End Function


;///////////////////////////////////////////////////////////////////////////////
; Updates the Dream filter
;///////////////////////////////////////////////////////////////////////////////
Function NBDreamFilter_Update()

	; Set the viewport to the same size as the blur texture 
	CameraViewport g_Camera, 0, 0, k_HDRTextureSize, k_HDRTextureSize
	
	; Set the blur feedback value (Additive)
	col = k_HDRBlurFeedBack
	EntityColor g_BlurSprite, col,col,col

	; Render the scene (including the blur sprite and copy it into the texture)
	RenderWorld 
	CopyRect  0,0,k_HDRTextureSize,k_HDRTextureSize, 0, 0, BackBuffer(), TextureBuffer(g_BlurTex)
	
	; Reset the viewport to fullscreen
	CameraViewport g_Camera,0,0,GraphicsWidth(),GraphicsHeight()
	
	; Set the blur filter value (Additive)
	col = k_HDRBlurFilter
	EntityColor g_BlurSprite, col,col,col
	
End Function


There are quite a few tweakable values (the constants at the top) in there so you can play with it to see what looks the best for your game.

I don't mind giving away the whole source code & graphics for the demo if people really want it - just ask...


koekjesbaby(Posted 2004) [#23]
heh, grab my code here: http://student-kmt.hku.nl/~hessel2/feedback/feedbacksample.zip (one sample file and two include files).

please not that my code is not a teensey weensey bit better or worse than afrohorses' code.

and yes, there should be more animals with afros.


Danny(Posted 2004) [#24]
8 fps on 640x480

Unable to create 3D Scene on 800x600x32 because I can't run that.

The fact that it actually works, and surprisingly good (albeit 8fps) on my crappy laptop with only 8Mb video ram (1Ghz proc) is a GREAT COMPLIMENT!

looks pretty damn good too! nice one,-

-Danny
p.s. all donations welcome ;)


Danny(Posted 2004) [#25]
He koekiemonster, nice effect man! Runs pretty smooth too!

Mind if I used it in my game (wich will make me $Millions, and won't take more than 9 years to develop)... With proper credit ofcourse?

cheers,
-Danny


koekjesbaby(Posted 2004) [#26]
Danny: not at all, have fun with all you millions :)

ps. doe eens wat aan je website man, allemaal missende plaatjes daar.


jfk EO-11110(Posted 2004) [#27]
Ah - this first Screenie gave me the impression of some kind of volumetric Light. I was not far from saying "Hit me - that's looking wicked!!!", but now I see, it's only a very nice looking level and a videofeedback on a Quad. Anyway, very nice Screenshot.


Afrohorse(Posted 2004) [#28]
yes - of course it is a cheat, but so are most rendering effects from vertex lighting to cubic environment mapping (can't wait for real-time hardware ray tracing ;) )

I think the end effect is the most important thing and in the demo it honestly looks like some volumetric lighting casting through the scene - now you know how it works, its like looking behind the scenes at a movie set.


jhocking(Posted 2004) [#29]
Well I didn't know about the feedback rendering effect, so thanks for the very useful tips/code.


mrtricks(Posted 2004) [#30]
105
95
AMD 2000XP
GeForce 4 ti4600 128Mb

Nice...


Sterling(Posted 2004) [#31]
Cool

126 800x600x32
133 640x480x32

P4 1.7, Geforce 4 ti4400