Special Effects using AGS (Screen warping/mattes)

Started by Scavenger, Sun 01/03/2009 03:07:13

Previous topic - Next topic

Scavenger

I want to give my game more of an immersive feel using the technology we have available in AGS - to not only recreate the style of the past, but take tips from modern games, too. For this, I hope to use 320x240 16bit, rather than 32bit, simply because I really don't like messing with alpha channels and I feel the effect might be too slow at higher res.


VERTIGO

The first thing I want to do is recreate the "vertigo" effect that CoC: DCoTE* had, wherein when something was terribly, terribly wrong, it showed on the player's screen. Gave a sense of urgency and disorientation to the player, as well as the player character. Here are a couple of mockups that I made to demonstrate what I mean.


Three layers:
- 100% size, 100% transparency
- 120% size, 30% transparency
- 80% size, 50% transparency
Effect is basically to resize the duplicates from 100% to 120 and 80 and back again,

This one, when played slowly once, can give the impression of height or disorientation on a closeup (long pit, dead body), if played regularly along with a heartbeat like rhythm, it can suggest something cosmic and powerful.


Base layer, along with translucent duplicate offset 30 and 60 degrees.
This effect rotates rather than resizes the two duplicates, making a weirder effect. Not quite sure how I'd use this one, though.

Now, I haven't coded for AGS since 2.61, but I do know about the Dynamic Sprite commands. The resizing vertigo effect would have to take place as (in psuedocode):

Quotechar gradient = 0;
char bigpercentile;
char smallpercentile;
char direction = 1;
char usevertigo;

rep_ex () {

if (usevertigo == 1)
{
bigpercentile = 100 + gradient;
smallpercentile = 100 - gradient;
DynamicSpriteFromScreenshot (MASTER);
DuplicateDynamicSprite (MASTER to BIG);
DuplicateDynamicSprite (MASTER to SMALL);
ResizeDynamicSprite (BIG, bigpercentile);
ResizeDynamicSprite (small, smallpercentile);
DrawTransparentSprite (BIG, some, coordinates, 50%);
DrawTransparentSprite (SMALL, some, coordinates, 50%);

if (gradient < 1) direction = 1;
else if (gradient > 19) direction = -1;
gradient = gradient + direction;
}
}

Now, as far as I remember, DynamicSprites are based off of RawDraw functions, which are PAINFULLY slow. I'm thinking any attempt to code the above (with proper syntax, OOisms and adequate timing, of course) will end up with the framerate of the game dropping to nigh unplayable levels and ruining the whole atmosphere. It's also important that the entire screen is affected, not just the background image, as we're including, not excluding, the player. I just don't see any way I can do it without it causing major slowdown. Unless I'm totally wrong, of course. I'd like to be wrong in this case.

Mattes

I've been working on a film project recently, and I've discovered a newfound love for mattes and chroma keying. Now, most of the uses for chroma keying we can duplicate simply because heck, it's not film and we can do amazing things as animators. But something has bugged me that I can't solve: How can we blend together video and sprites? Not like, playing a game and suddenly a video takes away your control, but using video as part of the workings of the game. Seamless.

I have no idea whether it's feasable or not, but is it possible to play video underneath the sprites and background on a kind of green screen? Here is a pictoral example.



Here we have our background graphic - someone's house pulled from Google. Notice that the sky is magic pink. This is our "green screen", just like any sprite has around its edges. We want something to happen in that sky in full video, but importing it as an object would be too large and cumbersome (Say the video is 5mb, the individual frames would be 500mb, for example) to bother with. So we set our characters on their merry way into this room's background graphic, and we play the video, using the matte to not render any video that's not on the pink bit, and we end up with this:


(except not psychadelic and bouncing around like that)

Dunno if it would work, though, as I believe video is rendered in blocks on a YUV layer rather than pixels on the RGB layer. But if it did, well, you've probably seen it before on games for the original Playstation-era consoles, and perhaps some FMV games. I definitely think it has utility, especially for animations too complex and cumbersome to merely add as objects (say, for prerendered 3D). It has the advantage of cutting out the characters (as the characters are not magic pink), leaving them to interact on a moving, fully animated background. But the slowdown it might have... terrible.  And I'm not even sure it's possible. But it would look fantastic.

If you've read this far, thanks for your time. If you haven't, thankyou anyway. ^^ I hope I've explained everything well enough - I'm not a programmer by any stretch of the imagination, nor am I very adept at the new scripting style. So, I guess my question would be - does anyone have any advice on implementing these in the script?


*Call of Cthulhu: Dark Corners of the Earth

Ultra Magnus

Quote from: Scavenger on Sun 01/03/2009 03:07:13
I have no idea whether it's feasable or not, but is it possible to play video underneath the sprites and background on a kind of green screen?

Scotch's Theora plugin will do that for you.
You may have to have the house as an object to sit it in front of the background, but that should work fine.
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

Pumaman

Yes, trying to do an effect like that with dynamic sprites probably would slow the game to a crawl.

Realistically, the only way to get a performant version of that working would probably be with a plugin that would have more direct access to the video card to do effects. But writing a plugin is a complex task and you'd need to know C++ to do so.

SMF spam blocked by CleanTalk