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

Legacy GM [SOLVED] Black hole space distort (bend) effect?

E

Edwin

Guest
How to make the object (black hole) do this effect? Maybe shader or something else?

This is how it needs to look like:
UZEZi.jpg
It's gravity is so powerful, that bends space around itself! \( o_o)/

Thanks for your future help =)
 
N

NeZvers

Guest
First thing that pops in mind is shaders, but for that I don't know any ready to use, so you need to learn shader programming.
Other way not so flexible but make sprite animation of it.
 

NightFrost

Member
Yeah that looks like a shader effect. A pixel passthrough where read position is calculated according to some gravity style formula. The sample picture looks more than just a simple pinch though, more like some sort of gravity lensing effect.
 
Oh, sh... That's amazing! Can I use it, please? :eek:
I wouldn't have posted it if I wanted you not to use it.

Inside the fragment shader, there is a function called "distort", which has been heavily simplified from a much more complicated refraction process I found somewhere online. Now, it does not produce exactly the same results, but it still looks pretty nice. If you find you would like to experiment with other distortions, you can rewrite the code inside of that "distort" function. And the starting basis of a new distort function would be vec2 B = T - 0.5; which just transforms the texture coordinates (of the sprite) so that the middle of the sprite is has coordinates (0,0). The return value is T plus some offset. In the distort function I wrote, the offset has been calculated such that it fades to zero at the edge of a circle that fits within the sprite.

Also note that the texture coordinates of the sprite are assumed to be in the range 0 to 1, so the sprite needs to be marked "used for 3d" in gms1, or "seperate texture page" in gms 2.

ALSO, the blackhole should be drawn after everything else, so either give it a lower depth than everything else, or else draw it in the end draw event. Actually, anything you don't want to be distorted by its "gravity" should be drawn after it.
 
Last edited:
Top