• 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 other magnify shader?

R

Remix The Idiot

Guest
I am currently using the magnify shader from this pack: https://marketplace.yoyogames.com/assets/261/free-shaders
I have looked everywhere and this seems to be the only magnify shader out there, but this magnify shader doesn't seem to like being in anything other than a Draw GUI event.

You see, what I am trying to do is create a boss distortion effect, where the background and only the background behind/around the boss is being all distorted and stuff. I would use the magnify shader to accomplish this. But the shader only seems to want to work on a Draw GUI event, anywhere else and it starts acting up in some strange and seemingly random ways, I would try to fix them and sometimes they'll work but afterwards will start being goofy again for no discernible reason at all. Obviously the Draw events don't work, I've also tried using layer_script_start/end() but that just does the exact same thing.

I have been trying for about a week now, I've checked the internet for any solutions, and spent more than half of my week staring at numbers and codes, and it appears that I am truly stumped and my only solution now is to hit the books and ask for help, I understand how the shader works (i did change the code and they worked) but I have no idea how to make shaders myself. Does anyone know any other magnify shaders out there?

like I said I am making a boss distortion effect, any similarities or example I can find of a game that does this would be the modern Touhou games as they do a similar thing with their bosses and by that I mean I want to replicate that effect.
I would do so by using a magnify shader and make it change size and circle around the boss and such which I don't need help with.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You could always just use surfaces? Simply take a section of the app surface and draw it scaled up. :) That's pretty much what my own magnify asset does....
 
R

Remix The Idiot

Guest
You could always just use surfaces? Simply take a section of the app surface and draw it scaled up. :) That's pretty much what my own magnify asset does....
I made the mistake of not showing a video example, here's a video showing what I want to do, I edited the video so it's impossible to miss it's point. Your link I think is actually the only reason no other similar shader other than the one I showed exists lel.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
That looks remarkable like this: https://marketplace.yoyogames.com/assets/5696/shockwave

:)

So, that effect is created by using two strips of textured primitives that you then draw one inside the other, using the texture from the application surface. While drawing the strips, you simply change the UV's to "distort" the image underneath. There are also shaders resources that do this on the MP I think, and I'm certain that if you google "Shockwave" and "GameMaker" you'll find a tutorial or editable example. I'd help you out further with the shader stuff, but I rarely use shaders and honestly don't know how it would be done (which is why I made a surface based version :)).
 
R

Remix The Idiot

Guest
It's not a shockwave, it's a magnify glass that is orbiting around a point, the point being the flame dude.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
It looks like the shockwave effect to me.... Textured primitves around a fixed point distorting (magnifying) what's around it. Anyway, the concept I'm suggesting is the exact same regardless of what you want to call it. Create a vertex buffer and format, get the app surface as a texture, draw some prims textured with the app surface texture, offsetting the prim positions to distort the texture. So, once you have a format and buffer, get the center point for the effect, then create a triangle strip around this point (you could use trianlge_fan for this too, but it won't be cross platform compatible, only desktop). When you draw the prims, randomly change the position of the outer edge so that it distorts the texture, giving you the effect you are looking for.
 
R

Remix The Idiot

Guest
I DID IT!


I have no idea what primitives and vertexes are so I had to look them up, and while I was doing so managed to salvage my shader by complete accident as I saw a part of the manual talking about shaders! So for anyone wanting to accomplish the same effect here's how I did it:

Apparently there was this thing you can do with surfaces called surface_set_target(id) and an accompanying surface_reset_target() which I can't believe I've never seen because I thought surfaces were a useless feature back then. So after some messing around and experiments this was the solution I managed to create

Below every other layer there will be 2 instance layers I named them "bg_shader" and "background"
they are in this order:
every_other_layer
bg_shader
background

There will only be a single instance in these layer's both being "controller" objects

the object in the background layer is straightforward
It draws the application surface in a draw, event not draw gui or anything else.

the object in bg_shader is a bit more messy and can probably be more efficient, but I've only been doing GM2 for half a year and only a week has passed since I was introduced to surfaces and primitives but anyway.

the object in bg_shader will have a create and draw event
In the create it will basically set up everything:
First it set's up all the uniforms of the magnify shader and then creates a surface with the width and height of the game (resolution)
and then draws the background inside the surface using surface_set_target() like this:

surf = surface_create(800,640);
surface_set_target(surf);
draw_background_stuffs(stuff1,stuffx,stuffy); <=== not an actual gml thing
surface_reset_target();

As for the draw event it will set the shader up and make sure our background surface that we just created is affected by the shader like this:

shader_set(shd_magnify);
shader_set_uniform_f();
draw_surface(surf,0,0);
shader_reset();

And you're done.
Thanks for introducing me to vertexes and stuff, and helping me accidentally stumble upon the solution.
3d sounds fun.
Will probably change the post title and tags.
 
Top