Fade to black
Blitz3D Forums/Blitz3D Programming/Fade to black
| ||
Hi, been lookikng in the forums and although many people have posted questions and answers regarding how to fade to black (and for that matter fade from black to show your scene) there doesn't seem to be anything that works well like you see in commercial games. Has anyone got any thoughts/code to show how to do it smoothly and successfully? Thanks. |
| ||
If it's full screen, you could use the gamma commands. Or you could put a black sprite or quad covering the whole screen and slowly change it's transparecny. Might be slow on some computers tho, because the sprite is filling the whole screen. |
| ||
Well image you have 8000+ entities to alpha fade - that would be slow noh? Cos thats what I have. Also a black sprite or quad in front of the camera seems a little brutal somehow, I guess that whilst it has an alpha of 0 then it is not sent to the render anyway. Would it take a lot of to draw a black quad in front of the camera, it would only be having to draw 12 tris. |
| ||
check out my screentransition lib... composed out of demos i gathered and wrote... http://www.balpoint.com/files//tek%20demos/ScreenTransition.Archive.Demo.exe Source included.... also this is simple source for fading P.S *For the smart ones...* I loved the album! Function Fader(Image$,FadeToRGB,Pause) Local Camera = CreateCamera() CameraClsMode Camera,0,1 Local FadeSprite = CreateSprite() EntityColor FadeSprite,Left$(FadeToRGB,3),Left$(Mid$(FadeToRGB,4),3),Right$(FadeToRGB,3) MoveEntity FadeSprite,0,0,1 EntityOrder FadeSprite,-100 Local Logo = LoadImage(Image$) Local FadeIn = False Local FadeOut = False Local FadeLevel# = 1 Local Done = False Local Timer = 0 While Done = False Timer = Timer + 1 If Timer = 100 FadeIn = True EndIf Cls DrawImage Logo,(GraphicsWidth()/2)-(ImageWidth(Logo)/2),(GraphicsHeight()/2)-(ImageHeight(Logo)/2) If FadeIn = True EntityAlpha FadeSprite,FadeLevel# FadeLevel# = FadeLevel# - .01 If FadeLevel# <= 0 FadeLevel# = 0 FadeIn = False EndIf EndIf If FadeOut = True EntityAlpha FadeSprite,FadeLevel# FadeLevel# = FadeLevel# + .01 If FadeLevel# => 1 FadeLevel# = 1 Done = True EndIf EndIf If GetKey() Or GetJoy() Or Timer >= Pause FadeIn = False FadeOut = True EndIf RenderWorld Flip Wend FreeEntity FadeSprite FreeEntity Camera FreeImage Logo End Function |
| ||
P.S *For the smart ones...* I loved the album! Me too :D |
| ||
That cod eis nice but doesn't help fading a 3d scene. |
| ||
Eh, a quad is made up of 2 triangles :) And you right, it doesn't get rendered when alpha is zero. Best hiding it tho. Also try using the gamma commands. |
| ||
Err, what gamma commands? |
| ||
Does your scene have to continue moving while fading in/out? |
| ||
http://www.blitzbasic.com/b3ddocs/command.php?name=SetGamma&ref=2d_a-z Try that. there's an example to in blitz. |
| ||
Rottbott, yes would be nice... |
| ||
Hey, try this. Press 1 to fade in, and 2 to fade out. Adjust fade_speed to change how quick the fade is.Graphics3D 800,600 SetBuffer BackBuffer() Global light=CreateLight() Global camera=CreateCamera() PositionEntity camera,0,0,-10 CameraRange camera,0.1,1000 Global sphere=CreateSphere() PositionEntity sphere,2,0,0 Global cube=CreateCube() PositionEntity cube,-2,0,0 Global fade_quad=CreateMesh() surf=CreateSurface(fade_quad) v0 = AddVertex (surf, -2,-2,0, 0 ,0) v1 = AddVertex (surf, 2,-2,0, 0 ,0) v2 = AddVertex (surf, -2, 2,0, 0 ,1) v3 = AddVertex (surf, 2, 2,0, 0 ,1) tri = AddTriangle (surf,v0,v2,v1) tri1 = AddTriangle (surf,v1,v2,v3) EntityParent fade_quad,camera PositionEntity fade_quad,0,0,0.5 EntityColor fade_quad,0,0,0 Global fade_alpha#=1 Global fade_dir=1; 1 to fade out, 0 to fade in, -1 for no change Global fade_speed#=0.01; adjust for fade speed While Not KeyHit(1) If KeyHit(2) Then fade_in() If KeyHit(3) Then fade_out() fade() UpdateWorld RenderWorld Flip Wend End Function fade() If fade_dir=0 Then fade_alpha=fade_alpha-fade_speed If fade_alpha<0 Then fade_alpha=0 fade_dir=-1 End If ElseIf fade_dir=1 Then fade_alpha=fade_alpha+fade_speed If fade_alpha>1 Then fade_alpha=1 fade_dir=-1 End If End If EntityAlpha fade_quad,fade_alpha End Function Function fade_out() fade_dir=1 End Function Function fade_in() fade_dir=0 End Function should do what you want :) |
| ||
@dewwzil my code does fade 3d scenes....and there is lots of code in my arc. It's an alternative to teh gamma commands. My code creates a sprite of any color and uses entityalpha to fadeinto view or out...... |
| ||
I just whack a black quad in front of the camera, then alpha it from 1 to 0 to fade in and from 0 to 1 to fade out. Works great and is the simple solution. Tracer |
| ||
As my code demonstrats and i think dark lords does too. :) |
| ||
Yep, that's what I do too. It seems excessive, but for most people, it should be a lot faster than continually updating the gamma table, which is actually pretty slow if you haven't noticed. |
| ||
Thanks for the tip Anthony. Never knew that one :) |