Author Topic: Trying to apply an effect over entire screen [SOLVED]  (Read 253 times)  Share 

Hi guys,

I am trying to create an effect over the entire screen on room load, imagine like a old tube TV effect.

Right now my implementation uses DynamicSprite.CreateFromScreenShot(320, 180) to get the screen after the room is loaded, I create another DynamicSprite where I get this first image and apply the effects, then I use MyOverlay.Remove() and Overlay.CreateGraphical(0,0 , MyScreenFromSShot.Graphic, true) on the repeatedly_execute_always to generate my effect.

Ok so this approach has some problems:

  • I can only apply the dynamic effect from the first possible screenshot in the room, so I can use the effect only for a short transition;
  • The fade in has to be finished before I can take a screenshot;
  • The screenshot will include the game cursor, which is undesirable.

Also this is working slow under Direct Draw but working with no fps drop under Linux - I haven't tested OpenGL on Windows yet, so I am not that worried right now about performance.

Have you guys tried to do any over entire screen effect? Is there a way to capture the screen just before it's drawn and edit the painting without having to use screenshot, which essentially has to let the entire screen be painted at least one frame before being useful.

Example implementation of what I described above
Add spoiler tag for Hidden:
Code: Adventure Game Studio
  1.  
  2. // Effect on entire screen using overlay
  3. DynamicSprite* Spr_ScreenShot;
  4. DynamicSprite* Spr_EffectedSShot;
  5. DrawingSurface* EffectedSShot_Surface;
  6. Overlay* Effect_Overlay ;
  7. bool Effect_enabled;
  8.  
  9. // Effect_start is exposed using import on header
  10. function Effect_start(){
  11.   Spr_ScreenShot = DynamicSprite.CreateFromScreenShot(320, 180);
  12.   Spr_EffectedSShot = DynamicSprite.CreateFromExistingSprite(Spr_ScreenShot.Graphic, false);
  13.   Effect_enabled=true;
  14.   Effect_Overlay = Overlay.CreateGraphical(0,0 , Spr_EffectedSShot.Graphic, true);
  15. }
  16.  
  17. // Effect_stop is exposed using import on header
  18. function Effect_stop(){
  19.   if(Effect_enabled){
  20.     Effect_enabled=false;
  21.     Effect_Overlay.Remove();
  22.     Spr_EffectedSShot.Delete();
  23.     Spr_ScreenShot.Delete();
  24.   }
  25. }
  26.  
  27.  
  28.  
  29. function renderEffect(){
  30.   Effect_Overlay.Remove();
  31.   EffectedSShot_Surface = Spr_EffectedSShot.GetDrawingSurface();
  32.  
  33.   //draw stuff on the surface and manipulate it ...
  34.  
  35.   EffectedSShot_Surface.Release();
  36.   Effect_Overlay = Overlay.CreateGraphical(0,0 , Spr_EffectedSShot.Graphic, true);
  37.  
  38. }
  39.  
  40.  
  41. // draws the effect once it's enabled
  42. function repeatedly_execute_always()
  43. {
  44.   if (!IsGamePaused() && Effect_enabled)
  45.   {
  46.     renderEffect();
  47.    
  48.   }
  49. }
  50.  
  51. // certify that effect stops when leaving the room
  52. function on_event(EventType event, int data){
  53.     if(event == eEventLeaveRoom){
  54.       Effect_stop();
  55.     }
  56. }
  57.  
  58.  

EDIT: SOLVED

Link to mp4 video of it working!

Hey guys, thanks for pointing me in the right direction! I followed the Underwater module, arj0n gave me the source, and there was the FakeScreen module. I modified it to generate a constant FakeSprite and used it's graphic in my VHSEffect! :D
« Last Edit: 14 Aug 2017, 00:17 by eri0o »

Mandle

  • NO PIXEL LEFT BEHIND!!!
  • Mandle worked on a game that was nominated for an AGS Award!
Re: Trying to apply an effect over entire screen
« Reply #1 on: 13 Aug 2017, 06:49 »
Hmmmm... didn't Chicky achieve something like this in his game "Drowning In The Bitstream"?

I might be way off of course, but it kind of sounds like what you are trying to do... AND it's an awesome game to check out anyway if not...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Re: Trying to apply an effect over entire screen
« Reply #2 on: 13 Aug 2017, 07:23 »
  • I can only apply the dynamic effect from the first possible screenshot in the room, so I can use the effect only for a short transition;
  • The screenshot will include the game cursor, which is undesirable.
What if you try hiding overlay and mouse cursor before making next screenshot? The trick often used for making screenshot without the mouse is:
Code: Adventure Game Studio
  1. Mouse.Visible = false;
  2. Wait(1); // this is to force redraw
  3. spr = DynamicSprite.CreateFromScreenShot();
  4. Mouse.Visible = true;
  5.  
Although I cannot predict if the blinking will be noticeable with screen-sized overlay toggling on and off.

The fade in has to be finished before I can take a screenshot;

This may be solved only setting transition to instant and doing custom fade-in/fade-out effect, I think.

Other than this, you could try writing an engine plugin. Plugins can receive events at different render stages. You might need to use AGS 3.4.1 for it to work with Direct3D/OpenGL properly though.
« Last Edit: 13 Aug 2017, 14:42 by Crimson Wizard »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Trying to apply an effect over entire screen
« Reply #3 on: 13 Aug 2017, 07:36 »
If the effect you're going for is something like this, you can probably achieve something quite close just using a semi-transparent overlay of the pattern on a GUI.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Re: Trying to apply an effect over entire screen
« Reply #4 on: 13 Aug 2017, 14:45 »
If the effect you're going for is something like this, you can probably achieve something quite close just using a semi-transparent overlay of the pattern on a GUI.

That depends on what effect eri0o is trying to achieve. If that's just a semi-translucent image overlay, then there is no need of screenshot at all.
But what if that's some kind of original image's transformation, like skewing?
I think clarification is needed.

I remembered, there is this "Underwater" module, although from the description it sounds like it modifies background and objects separately. I cannot tell for sure.
http://www.adventuregamestudio.co.uk/forums/index.php?topic=38592.0

Maybe try to check its code?
« Last Edit: 13 Aug 2017, 14:47 by Crimson Wizard »

Re: Trying to apply an effect over entire screen
« Reply #5 on: 13 Aug 2017, 16:58 »
Hey Crimson Wizard! Great module, that's the kind of thing I am looking for, distortion of the image while being able to move the character around and the character itself being effected by the distortion!

Unfortunately, the link to this underwater module is offline, so I couldn't check it's code. :/

Here is an example that I made, but I am using screenshot and it only works with stills, I would like to advance this effect:

Example video rewind effect

The messages on the forum tells something about a module called FakeScreen.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Re: Trying to apply an effect over entire screen
« Reply #6 on: 13 Aug 2017, 17:27 »
There is something that looks like an excerpt from a module posted in that thread:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=38592.msg508423#msg508423

Also, you could try PM module's author for download update, he has been around recently.

Re: Trying to apply an effect over entire screen
« Reply #7 on: 13 Aug 2017, 20:59 »
Thanks! Just sent him a message.

About the game Drowning In The Bitstream, the source is not available, am I missing something here?

Edit:

It seems Chicky didn't use any distortion, apparently it's all pre-made, as stated here.

Edit 2:

Holy Cow you guys are amazing! Thanks!
« Last Edit: 14 Aug 2017, 00:11 by eri0o »