Trying to apply an effect over entire screen [SOLVED]

Started by eri0o, Fri 11/08/2017 00:04:37

Previous topic - Next topic

eri0o

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
Spoiler

Code: ags


// Effect on entire screen using overlay
DynamicSprite* Spr_ScreenShot;
DynamicSprite* Spr_EffectedSShot;
DrawingSurface* EffectedSShot_Surface;
Overlay* Effect_Overlay ;
bool Effect_enabled;

// Effect_start is exposed using import on header
function Effect_start(){
  Spr_ScreenShot = DynamicSprite.CreateFromScreenShot(320, 180);
  Spr_EffectedSShot = DynamicSprite.CreateFromExistingSprite(Spr_ScreenShot.Graphic, false);
  Effect_enabled=true;
  Effect_Overlay = Overlay.CreateGraphical(0,0 , Spr_EffectedSShot.Graphic, true);
}

// Effect_stop is exposed using import on header
function Effect_stop(){
  if(Effect_enabled){
    Effect_enabled=false;
    Effect_Overlay.Remove();
    Spr_EffectedSShot.Delete();
    Spr_ScreenShot.Delete();
  }
}



function renderEffect(){
  Effect_Overlay.Remove();
  EffectedSShot_Surface = Spr_EffectedSShot.GetDrawingSurface();
  
  //draw stuff on the surface and manipulate it ...
  
  EffectedSShot_Surface.Release();
  Effect_Overlay = Overlay.CreateGraphical(0,0 , Spr_EffectedSShot.Graphic, true);
  
}


// draws the effect once it's enabled
function repeatedly_execute_always()
{
  if (!IsGamePaused() && Effect_enabled)
  {
    renderEffect();
    
  }
}

// certify that effect stops when leaving the room
function on_event(EventType event, int data){
    if(event == eEventLeaveRoom){
      Effect_stop();
    }
}


[close]

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

Mandle

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

#2
Quote from: eri0o on Fri 11/08/2017 00:04:37

  • 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: ags

Mouse.Visible = false;
Wait(1); // this is to force redraw
spr = DynamicSprite.CreateFromScreenShot();
Mouse.Visible = true;

Although I cannot predict if the blinking will be noticeable with screen-sized overlay toggling on and off.

Quote from: eri0o on Fri 11/08/2017 00:04:37
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.

Snarky

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

#4
Quote from: Snarky on Sun 13/08/2017 07:36:48
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?

eri0o

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

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.

eri0o

#7
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!

SMF spam blocked by CleanTalk