How to create a glow effect
Blitz3D Forums/Blitz3D Programming/How to create a glow effect
| ||
Could anyone tell me the teory on how to create a glow effect filter like in Prince of Persia - Sand of time |
| ||
It is a 'Bloom filter' - has been done in Blitz recently. There were a couple of demos knocking about. I don't know anything about it but Googling on 'Bloom Filter' will help. |
| ||
Create a texture with texture flag 256 so it is stored in video ram. (This makes copying from video ram to it faster.) Then each frame, render your scene in a small viewport, but do not flip, and copy the viewport to the texture you created. Then set your viewport back to normal size, and place a quad over the viewport with the texture applied and scaled properly. Set the quad to add blend. Then render the scene and flip. |
| ||
I had this in my archives: Anyone know why the text refuses to print??? |
| ||
Yes - Because you forgot SetBuffer Backbuffer() after you used it with TextureBuffer() And I do not know what you use as Computer - but that is so damn fast here on my old set, that after I even touch the keyboard the sphere is lightyears away ;-) [Edited] I see what's wrong and why its so fast... It should not be y=y+1 : better is y=1 since you use Moveentity You programmed an enormous acceleration into it. After 1/10 second keydown it made 12 units/sec here. |
| ||
D'oh!!!! No I have the same sphere moving problem. It has to do with scale... scale everything up and the sphere moves more slowly... Your y=1 is a great solution too... I wrote that for a missle type game... forgot to rewrite it... double d'oh!!! RZ |
| ||
Thanks guys.. sswift, you make my glow code really glow. I try and got this. I don't know how its happen but its work. ; CreateCamera Example ; -------------------- Graphics3D 640,480,16,2 SetBuffer BackBuffer() ; Create camera Global camera=CreateCamera() MoveEntity camera,3,3,0 RotateEntity camera,30,30,0 light=CreateLight() Global cube=CreateCube() PositionEntity cube,0,0,5 ;glow setup Global sizex=160 Global sizey=120 Global glowtexture=CreateTexture (384,384,256) Global sp=CreateSprite(camera) MoveEntity sp,-.25,-.05,1.2 EntityAlpha sp,.9 ScaleTexture glowtexture,GraphicsWidth()/sizex,GraphicsHeight()/sizey EntityTexture sp,glowtexture While Not KeyDown( 1 ) CameraViewport camera,0,0,sizex,sizey RenderWorld CopyRect 0,0,sizex,sizey,0,0,BackBuffer(),TextureBuffer(glowtexture) CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight() RenderWorld Flip Wend End ..but I still don't have any idea on how to put a sprite just in front of viewport perfectlly. |
| ||
looks like it is raycasting... have you tried to move the cube or increase the size of the viewport OR decrease the glow effect? RZ |
| ||
After I tweek some of the variable, I get the result that I want. I put this code in code archieve. Thanks all you guys for the help.Graphics3D 640,480,32,2 SetBuffer BackBuffer() ; Create camera Global camera=CreateCamera() MoveEntity camera,3,3,0 RotateEntity camera,30,30,0 light=CreateLight() Global cube=CreateCube() PositionEntity cube,0,0,5 tex0=CreateTexture(300,300) SetBuffer TextureBuffer(tex0) ClsColor 255,255,255 Cls SeedRnd(MilliSecs()) For k=1 To 50 Color Rand(256),Rand(256),Rand(256) Rect Rand(600),Rand(600),Rand(600),Rand(600) Next EntityTexture cube,tex0 SetBuffer BackBuffer() ;glow setup s=1 Global sizex=640/s Global sizey=480/s Global glowtexture=CreateTexture (384,384,256) Global sp=CreateSprite(camera) MoveEntity sp,-.25,-0.06,1.18 EntityAlpha sp,.32 ScaleTexture glowtexture,GraphicsWidth()/sizex,GraphicsHeight()/sizey EntityTexture sp,glowtexture TextureBlend glowtexture, 5 While Not KeyDown( 1 ) TurnEntity cube,0.5,0.5,0.5 CameraViewport camera,0,0,sizex,sizey RenderWorld CopyRect 0,0,sizex,sizey,0,0,BackBuffer(),TextureBuffer(glowtexture) CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight() RenderWorld Flip Wend End If somebody know the best way to put a sprite in front of a screen (for this effect purpose), please help me.. |
| ||
Use EntityOrder for making the sprite appear in front of everything. eg. EntityOrder mysprite,-9999 |
| ||
A little something I used in SpaceJunk (WIP) Before = And with the filter = |
| ||
Use EntityOrder for making the sprite appear in front of everything. eg. EntityOrder mysprite,-9999 Thanks, that is to force drawing layer but the sprite position is my issue. When we move or rotate the camera, we need to also move and scale our sprite so that its perfectlly in front of our view. The distance from camera must always consistant. How do I archieve that. Btw, really good stuff there.. I will look into the above code letter.. |
| ||
Then parent the sprite to the camera. It will always be where you want it:) like in the code above d\BlurMesh = CreateMesh(cam) |
| ||
TQ |
| ||
It's a pleasure. |
| ||
| | V |
| ||
er...nm |