Video-Tutorial: Underwater Shader Effect

TheMagician

Member
GM Version: GameMaker Studio
Target Platform: All (if the hardware supports shaders)
Download: Finished Project File
Links: Part 1 - Godray Shader --- Part 2 - Wave Distortion Shader

Summary:
This two-part video gives a quick overview of shaders and then uses two Shadertoy shaders (godray and wave distortion) to create a nice underwater effect.

Tutorial:
Check the links above to get to the two videos.

In the first one we talk about shaders in general (just a quick overview) and then we have a look at how to adapt shaders from the website Shadertoy so they can be used in GameMaker. We walk through the most common compiler errors and how to fix them. Finally we pick a godray shader and adapt it for GM.

In the second video we select a more complex wave distortion shader and talk about how you can feed the application surface (which contains the backgrounds and sprites) into the shader as a texture.

In the end we have a nice underwater effect which looks much better in motion than in the following screenshot. Check out the beginning of the first video to see the end result in action.



Have fun!
 

Silverfire

Member
Very good tutorial with good info, thank you! I was able to apply the underwater shader to my project without difficulty.
 

lolslayer

Member
It's an oasis, though, I could totally see it what you mean. haha. Thank you! No, my game is not from Spongebob.
I just think it's cool how versatile shaders can be if you learn how to use them effectively.
\

Explains, with a heatwave it shoulld also move up and down a little bit though

And indeed, especially for 3D shaders come in really handy, you'll love it :)
 

Slyddar

Member
Great tutorial, thank you.

I applied the shader to my underwater room, but the room is 2048x1024 and the view is 1280x720. I changed the post Draw shader_set_uniform_f and the rectangle both to larger resolutions, and I can get whole screen coverage, but what I want is the shader to be applied to the whole room, but not move when I move the player. I'm using the inbuilt object following in views, so not sure if that's causing me the problem.

Any suggestions how I get the shader to not move when I move as it breaks the illusion?
 

steskle

Member
It's a great tutorial, but did they change something about the shaders in Game Maker Studio 2?
I followed it step by step but I just can't make it work.
The screen remains black and glitchy.
 
Top