GMS 2.3+ [SOLVED] Apply shader to a single tile layer as a whole

Hello everyone! I've been working with Game Maker for almost 2 years now, but I've barely touched shaders and surfaces. Lately I've started playing with both and found myself stuck very often. :/

I want to use a shader only on one tile layer, but I noticed that with the layer_shader and layer_script_begin/end methods the shader is applied per tile, pretty awfully. I want the shader applied to the layer as a whole.
I thought about drawing the layer on a surface and then draw the surface with the shader, but I don't know what would be the best approach. If possible, I would prefer to avoid disabling application_surface_draw_enable and have to draw every single layer on surfaces individually as I'm using quite a lot of layers.

Thanks for any suggestion! :)
 

muki

Member
you are correct in that you want to draw the tile layer to a surface, then apply the shader to the surface before drawing it to the screen. you would use draw_tilemap to do this.


here's a semi-detailed write-up on the steps needed:

old.reddit.com/r/gamemaker/comments/j9za66/made_this_ingame_scrollable_ui_for/g8p7154/

you will still have to set up a control object that draws layers manually. it's what I did. there might be an easier way but I didn't find it. ultimitely I'm glad I did as it gave me a huge amount of control to be able to have pretty fancy effects.
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
The advice given by @muki is spot on and sadly exactly what you need to do. I would also suggest that you (and everyone else that wants to do this) contacts YoYo Games with a bug report about the behaviour of setting a shader on a tile layer, as it's not at all what one would expect and shouldn't require such work arounds in my opinion. They might say no, or it can't be changed or even suggest a better method, but it could also be something they could fix, so I'd let them know about it. :)
 
Top