• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Shaders Predator "shimmer" effect

JAG

Member
Hiya! Im working on a local multiplayer deathmatch game. One of my characters can cloak, and so far Ive been using a temporary low-alpha sprite to subtly "reveal" your location so you know where you are. The problem with this is that then your enemies also know where you are.

I had the idea that the light-bending "shimmer" from Predator is the way to go here -- it could be made subtle enough that you only see it if you're looking for it.

I've actually accomplished this effect the following way:

1. Make a copy of the application_surface (surf1)
2. Draw that surface to a second surface (surf2) with a magnification shader effect applied to the area around the character -- at this point I just have a big magnification bump being drawn on the surface.
3. Now the tricky part: Take surf1 and punch a character-shaped hole in it using alpha blending, like so:
Code:
surface_set_target(Surf1)
draw_set_blend_mode_ext(bm_inv_src_alpha, bm_inv_src_alpha)
draw_sprite(Owner.sprite_index, Owner.image_index, Owner.x, Owner.y)
draw_set_blend_mode(bm_normal)
surface_reset_target()
Now I can draw surf2 (with the magnification), and then draw surf1 (with the hole) on top, and there's my effect:
http://www.giphy.com/gifs/400DWx6FCZngNt7Fji

The problem is that in order to achieve this effect I had to draw my surfaces in the Draw-GUI event, because if I draw the effect to the application_surface the image stops moving (because its drawing the copy of the application_surface which it previously copied from the previous frame, which was also a copy of the previous etc etc):
http://www.giphy.com/gifs/63LW7x9MNUFXjs9jUh

But it feels very strange to render the whole game from the Draw-GUI event, and that comes with it's own host of issues.

How do I fix this this?! Any ideas, maybe for an alternate implementation?

Thanks!
 

TheouAegis

Member
Use Draw End instead?


If the game is on one screen, no scrolling, save the image of the room to one surface you can just copy each step instead of redrawing the screen each step. If terrain changes (or the surface gets freed), redraw the surface then.
 
Last edited:
  • Like
Reactions: JAG

JAG

Member
Thanks @TheouAegis, I figured out the issue

I was copying the application_surface in the step event -- for posterity, if anyone wants to create an effect like this that requires copying the application surface, make sure you copy the surface RIGHT BEFORE you apply your effect, ie inside the Draw event, not the step event.
 
Top