Screen fade?

Started by
5 comments, last by Supernat02 18 years, 9 months ago
How can i make a screen that fade to black or white..in d3d? i will put it between two scene so the change between scene go smoothly.. or on the time scene1 will change to scene2, scene1 will go transparant and scene2 will be more clear to see (sorry for my english :) ) Thanks
Advertisement
Simply draw an alpha blended quad over the whole screen and smoothly change its alpha value. The color of the the quad, is the color you're fading to.
You seem to have mentioned two related but slightly different things:

"Fade To Colour" - e.g. from your rendered image fading out to black

"Fade transition" - e.g. one rendered scene fading into another rendered scene

The former is easily done by using a TLQuad set to be the size of the screen and the end colour (e.g. black). You can then modify the alpha values (+blending) to fade to your specified colour.

The latter would require you to use render-to-texture (or similar) and then feed the results of BOTH rendered images into a post-processing step that modulated between them as appropriate.

Arguably they're equally easy to program, but the second idea is likely to tax your system a little bit more by virtue of having to render BOTH scenes for the during of the transition.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

IDirect3DDevice9::SetGammaRamp
Quote:Original post by Kamikaze15
IDirect3DDevice9::SetGammaRamp

The gamma ramps are pretty cool, but I wouldn't use them for this.

Why?

Well primarily because they have a few quirks (messes up windowed-mode rendering) and is quite dependent on driver/hardware support (I've even come across hardware that enabled/disabled gamma operations between driver versions [oh]).

On the other hand, gamma correction is very useful for getting the correct colour balance in a graphics application. I always remember how much better Half-Life (#1!) looked when I used some tools that came with my hardware to correctly set-up my monitor and gamma correction. No more washed out colours[attention]

---

The blending options *should* work on pretty much any/every piece of consumer hardware you're likely to come across.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Wow, I didn't know about all those issues.
Thank you for the info :)
Jack's right. Gamma controls are only useful for full screen apps, and some hardware doesn't support them. As far as fading between two scenes, there are three approaches you could take.

1) You can render to two render targets each frame, then alpha blend them together full-screen. This could be really slow, because the only reason you'd do this is to keep the animation going. i.e. you're running while the screen is fading to the new location. The problem is that you have to then do all of the physics, a.i., rendering, everything twice in one frame.
2) You could render every other frame. This frame you render scene A and call AI for that scene and physics and terrain rendering, but you render it to a render target and then render the two render targets of scene A and B with alpha blending. Next frame, you render scene B the same way, using scene A's render target from the previous frame for the blend. I don't know that this approach gains you anything from approach one, but it might be easier to implement in your engine.
3) You could render to two render targets on the last 2 frames just before you start blending the old with the new. Render the old frame, display it completely, then in the next frame render the new frame to a render target, then simply modulate the two over time to produce the blend affect to your desire. This is faster than rendering to both render targets every frame, but of course you lose all gameplay capability and animation, i.e. it becomes a freeze frame fade. However, it would work on slower systems better and you could just call it a freeze effect. :) If you did it rather quickly, it wouldn't be noticable. You could also add some further effects (perhaps even some shaders) to make it more fun.
Chris ByersMicrosoft DirectX MVP - 2005

This topic is closed to new replies.

Advertisement