Possibility for a Displacement Plugin? [Cool Example included]

Started by subspark, Sat 15/11/2008 09:57:02

Previous topic - Next topic

subspark

Would it be possible for a plugin to be written that allows screen buffer distortion?
Have a look at this effect done in Adobe After Effects:

Displacement:


Result:


Is this possible in AGS?

Cheers,
Sparx.

Anteater

I'd say it's absolutely possible with a plugin, but some work would be required.

Gilbert

Actually, I think it is even possible without a plugin. Just grab a dynamic of the whole screen and do whatever modification you want to it. It may be quite slow though.

GarageGothic

I wrote a module (not yet released to the public) that allows you to turn Objects into "EffectObjects" that can work as lenses, mirrors and/or just provide distortion of whatever background/object/character is behind it. For a water distortion effect similar to what you describe it uses simple sine functions performed on columns and/or rows of pixels. Using a graphical displacement map would make it much, much slower as you would need to call GetPixel on every pixel of the displacement map. As is, it's still pretty tough on the CPU, but keeps decent framerates as long as you don't use too many or too large effect objects in the same scene.

For full-screen manipulation a plugin would be preferable, and absolutely necessary if you want to use displacement maps. I don't think it should be too difficult to code, but I don't have any real experience with plugins as I prefer using modules.

subspark

#4
Would anyone be up for the challenge? It would be really cool to see some games made with real-time distortion effects such as the ones described. You could even do forcefields or shockwaves! 8)

Cheers,
Sparx.

BOYD1981

i'm no expert on the subject but what with the DirectX engine couldn't this sort of stuff be done if shader support was implemented?

Limey Lizard, Waste Wizard!
01101101011000010110010001100101001000000111100101101111011101010010000001101100011011110110111101101011

subspark

Thats kind of what I'm thinking. But something that could be run (in theory) on the PC equivilant of a PSP Processor.

Cheers,
Sparx. :)

Dualnames

If someone manages to write anything to do that effect we will have all AGS games under-water!!
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

subspark

QuoteIf someone manages to write anything to do that effect we will have all AGS games under-water!!
Or with cool room to room transitions! ;D

Sparx.

Ryan Timothy B

#9
One thing I really could see this being used for, is heat waves.  Like in Final Fantasy 3 where you fight in the desert with the heat waves in the background.
I love the idea of having this effect.
I could probably do a simple version of this (with hack programming of course--nothing but. :P), but definitely nothing like you've shown here.  Especially with the displacement background.

Rather than me explaining how I would attempt to do this the overcomplicated way, I'll just show a picture.



I would place a bunch x and y coords on the screen (Green), connect them all in the form of a triangle (incomplete demonstration pic above), and have the x and y coords randomly move around +/- 1 or 2 pixels on both x and y randomly.  But never letting them break the triangle by going through itself.  Then I'd check each pixel in the VERY first background (always keeping a fresh copy of this background for reference) and align them to their knew mathematical location in the new triangle.  Wouldn't be too, too, hard but I bet AGS would hate it and your computer would as well.

Oh, and you'd have to keep a radius limit as to where the x+y coords could move and not beyond (you'd have to keep the x and y coords from the original triangle location to where it is now).  Otherwise the effect would literally walk off the screen.
What you'd do with the 'stretched' pixel I wouldn't have a clue.  And that is what would make the background look like poo. :P

subspark

Hey thats a pretty neat approximation! Good going Ryan. Does your method work or are you still testing it?

Good suggestion Ryan. Heatwaves are also very appropriate for screen displacement effects.
Also you could import the full-screen displacenment frames as an 8 bit grayscale 32 color set of sprites and add them into a looping view.
The image compression would certainly free up some more resources maybe even relax the proccessor a bit too?

Cheers,
Sparx.

Ryan Timothy B

Nah it was just an Idea of How I would do this myself.  I only slapped some lines on your pic to give a visual explanation on how I'd do this, IF I were to attempt it.

It definitely wouldn't look as good as your Adobe effect, but I think it would still pass as water/heat etc just as long as the triangles didn't stretch or shrink too much.

subspark

#12
Well we can always animated backgrounds and have custom displacement loops for characters. But a plugin that allows dynamic solution would be extremely beneficial.
Cheers,
Sparx.

Dualnames

Still I think Radiant, is definetely a coding beast concerning raw draw cool effects..ask him..or make him do it ;D
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

subspark

Radiant? You about buddy? I'd like to get your thoughts on such a plugin.

Cheers,
Sparx.

Dualnames

Well, thing is if it can be done internally with AGS Engine, I could definetely give it a shot. But concerning plugins, well I couldn't. I think the plugin is definetely something that would help AGS engine benefit.

As for the displacement, wondering does the displacement affect the characters, it should.
It should be done using Rawdraw taking input from Screenshot. However, what my concern and main difficult and obstacle as how to code is, what exactly does displacement do? Takes parts of the screen and moves them? Cause if it's that(as a main idea), it is definetely possible AGS internally.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

GarageGothic

Dualnames: It's definitely possible to do in-engine (see my previous post), and quite easy scripting wise. Only horribly slow to do full-screen - and even worse when using Direct3D mode. Even grabbing a single screenshot to DynamicSprite causes my framerate to stutter in Direct3D mode, I couldn't imagine at what pace the game would run if doing it every loop.

The most realistic solution would be to use pre-rendered animation frames for the distorted background, either done in an external application such as AfterEffects or dynamically generated upon room entry and only apply real-time distortion to the characters/objects. I should be able to add character support to my effect module if enough people are truly interested.

Ghost

Let's say one would create five distorted images upon entering the room, and store these as the five possible cycling backgrounds- it wouldn't be as fluid an animation, but should save processor power. I like the general idea of a distortion plugin very much, but I see Dualnames point- it's eye candy that's easy to overuse.

Dualnames

I'll give it a shot..and if it succeeds at any point, I'll give it out. As for Ghost's words, well, yes it could get misused, but that happens with most of the cool things, even SSH star wars scroller can easily achieve the same effect. Just see how many games have Star Wars scrolling text effect.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ryan Timothy B

Quote from: GarageGothic on Fri 21/11/2008 14:13:38
[..]Even grabbing a single screenshot to DynamicSprite causes my framerate to stutter in Direct3D mode, I couldn't imagine at what pace the game would run if doing it every loop.[..]

I don't understand why you'd need to take a screenshot between each frame.  Explain this to me if you will.
I'm not too advanced with AGS yet, so I there may be limitations I'm not aware of yet.  But I know how I'd do it in a program like Turbo Pascal, and it's very similar to how I'd do it in AGS.

SMF spam blocked by CleanTalk