Archived

This topic is now archived and is closed to further replies.

invictus

fade image from & to black

Recommended Posts

persil    199
No.



In fact, there are two ways of doing it, that I know of firsthandedly...

1. Use the Gamma Ramp controls, which I''ve seen somewhere in the tutorials here, if I remember correctly, or somewhere around the net...

Or

2. Code a custom function which locks input and destination surfaces and read every pixel and applies a percentage to each of its color components, then writes it back to the destination surface.

Correct me if I''m wrong anyone.

Share this post


Link to post
Share on other sites
circlesoft    1178
You could just render a black, alpha-blended rectangle on top of everything. Just increase or decrease the alpha component of the color of the rect to make the final output more black or less black.

DevLiquidKnight: how can you use the view matrix in d3d?

[edited by - circlesoft on March 20, 2004 9:48:45 PM]

Share this post


Link to post
Share on other sites
Promit    13246
Generally it''s done with a single alpha blended quad stretched over the screen. This also has the advantage of easily extending to screen flashes, screen blood flashes (a la Doom), blood pouring over your vision (again Doom), underwater, etc.

Share this post


Link to post
Share on other sites
invictus    122
quote:
Original post by circlesoft
You could just render a black, alpha-blended rectangle on top of everything. Just increase or decrease the alpha component of the color of the rect to make the final output more black or less black.

DevLiquidKnight: how can you use the view matrix in d3d?

[edited by - circlesoft on March 20, 2004 9:48:45 PM]


Is this a good way of doing it? is it difficult? and how is the performance?

Share this post


Link to post
Share on other sites
jack_1313    536
quote:
Original post by Promit
Generally it''s done with a single alpha blended quad stretched over the screen. This also has the advantage of easily extending to screen flashes, screen blood flashes (a la Doom), blood pouring over your vision (again Doom), underwater, etc.


He is using DirectDraw, therefore this is not possible. The only way you are going to get acceptable performance in DirectDraw is to use the Gamma controls, or to ''dissolve'' the screen by adding a few new black pixels to the backbuffer each frame.

Share this post


Link to post
Share on other sites
Wavewash    202
If anyone has the book Windows Game Programming for dummies I remember there was a fade to black function in there. If I find my copy I''ll be sure to paste the code.

~Wave

Share this post


Link to post
Share on other sites
well if u use direct3d u just change the alpha value of the texture that is drawn to the view matrix but sense your not using direct3d u cant so yea... if you want to do 2d with direct3d look into direct3d sprites.

[edited by - DevLiquidKnight on March 21, 2004 11:41:19 PM]

Share this post


Link to post
Share on other sites
fractoid    703
quote:
Original post by jack_1313
quote:
Original post by Promit
Generally it's done with a single alpha blended quad stretched over the screen. This also has the advantage of easily extending to screen flashes, screen blood flashes (a la Doom), blood pouring over your vision (again Doom), underwater, etc.


He is using DirectDraw, therefore this is not possible. The only way you are going to get acceptable performance in DirectDraw is to use the Gamma controls, or to 'dissolve' the screen by adding a few new black pixels to the backbuffer each frame.
Actually, IIRC you can get hardware-accelerated 2D blending with DirectDraw, or at least you could with DirectDraw 3 which is the last one I used (dd sucks more than d3d, and d3d is, well, 3d. D3D8 didn't suck, finally, though... and I hear 9 is good.)

Edit: Oh, and as for the 'which is better' question: Neither. Both. A monkey.
Direct3D is a 3D rendering API, which means that even if you're only drawing 2D sprites, you can do things like alpha blend them, apply lighting/colouring effects, rotate them smoothly, and even zoom in and out on your game world, all with no measurable performance hit. On the other hand, DirectDraw works on anything with a VGA card so if you're targetting platforms with no hardware 3D accelleration, DD is the way to go.

[edited by - fractoid on March 22, 2004 4:25:24 AM]

Share this post


Link to post
Share on other sites
DrunkenHyena    805
quote:
Original post by DevLiquidKnight
well if u use direct3d u just change the alpha value of the texture that is drawn to the view matrix but sense your not using direct3d u cant so yea... if you want to do 2d with direct3d look into direct3d sprites.


Just to correct some terminology, you don''t render to a View Matrix. The View Matrix is used to transform vertices from World Space into View Space.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
DrunkenHyena    805
quote:
Original post by fractoid
Actually, IIRC you can get hardware-accelerated 2D blending with DirectDraw, or at least you could with DirectDraw 3

No, DirectDraw has no support for blending. The best it has is a colour key. In DirectDraw the common way was to use assembly (MMX) and do all blending in system memory, then blit the results to the back buffer.



Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
persil    199
Indeed, that''s just what I was saying. I''m currently deep down into exactly this kinda stuff, and I''m having some speed problems. However, it doesn''t really come from the alpha-blit, but from the sysmem->vidmem blit, which is too slow for what it should be

Share this post


Link to post
Share on other sites
fractoid    703
Sorry... brain fart. I was thinking of hardware *scaling*, which I did manage to coax it to do, but yeah, no alpha in direct draw.

What res. are you using? Are you doing the system->vid blit manually or drawing into a system memory surface and then using blt or bltfast or whatever? It shouldn''t be slow on a modern pc...

Share this post


Link to post
Share on other sites
persil    199
DevLiquidKnight:

Yeah, this is a pretty well known tutorial from what I''ve gathered.

Look there:

http://www.gamedev.net/reference/list.asp?categoryid=40#29

There''s a couple of them, all about alpha blending

Share this post


Link to post
Share on other sites