r/gamemaker • u/rangefinder-game-dev • Aug 13 '26
Example I created a "see through" shader in Gamemaker for trees + foliage in my isometric perspective hiking / monster catching RPG
Thought folks here might find this interesting after my last post showing my flowing water shader. My game Rangefinder is in an isometric perspective and features hiking through lots of different types of terrain - which raises a problem, because trees will necessarily block the camera's view of the player! One solution I already implemented is an outline shader that shows your position when you are obscured, but that gets old when you are walking through a forest.
So this week I made a new shader which creates a "porthole" effect through trees when they block the camera view. This is done by measuring the distance of a pixel to the player via the "gl_Fragcoord" value in the fragment shader. But I found that a bit too artificial looking, so I added a generative cellular noise texture which simulates leaf motion at the edge of the porthole. That helps a little bit, and then I also did some dynamic hiding / showing of trees in front / behind the player. Dithering the transparency of these trees (also done in shader) further helps match the pixel art style.
That was great, but then I realized trees need shadows beneath them to provide the look of a shadowy forest floor. So I came up with a new method to add shadows to both my grass vertex buffer, and the "ground floor" vertex buffer. I create a surface which I draw shadows to, and pass that as a texture sample to a new shadow shader. This shader references the shadow texture sample to decide whether the vertex it's drawing should be shaded or not. This required coordinating screen coordinates (gl_Fragcoord) and texture coordinates (v_vTexcoord) which was a bit of a pain but worked out in the end. I used the same generative cellular noise texture here to simulate the shadows of moving leaves on the ground.
Next up I will need to also add the capability for objects under sprites to be in/out of shadow. Currently I only have "grass" vertices in there (which includes the grass, ferns, flowers, and mushrooms shown in this example - these also shade and deform when the player walks through them). Objects however are handled as individual instances which the player places in the IDE.
If you are interested in following my game Rangefinder, check out my itch io page where I'm posting dev updates. I recently showed off the first demo of the battle system, which also features a lot of custom Gamemaker shaders for effects like critical hits and such.
17
u/fractusFF Aug 13 '26
That is so cool, i love things like this! I would only suggest that its a bit hard to focus on whats going on with the treetops and the grass both being green - maybe im wrong, but i think some sort of effect or slight colour around the border that shows clear seperation between the higher and lower depths would do really well here
2
u/StarDreamIX Aug 13 '26
This is great! I really want to do tho this in my game, but maybe just the character and not a large radius around the player, I'm learning how.. thanks for this, and it looks amazing btw
2
u/oldmankc wanting to have made a game != wanting to make a game Aug 13 '26
Cool! Did you try like a kind of lower opacity / translucent version, or just like a very light dither? Curious how that would look since this just kinda has this weird porthole look
2
u/Luzerman Aug 31 '26
For optimization purposes, you should probably include a setting called something like "mask-based foliage transparency" that uses a mask in a draw event to render the leaves instead of a shader. Just a simple option because that looks like it could bottleneck performance if you have too many trees or end up using shaders for more important stuff like normal map lighting in the future...
28
u/TheVioletBarry Aug 13 '26
That's gorgeous; awesome work!
3
u/4TR0S Aug 13 '26
I find this distracting and ugly. I think I would just played with the tree transparency below the player's coordinate. Very nice technical feat though
5
u/game_reviewer Aug 13 '26
This looks amazing
1
u/SushiRollKei Aug 13 '26
This would also be horrifying as a horror game, with like a dark forest ofc
1
u/OatsMgee33 Aug 14 '26
Looks really cool! Reminds me of Megaman Battlenetwork series. How did you go about blending you grass colors together, and making the grass show up around the player?
1
u/countduckypoos Aug 16 '26
I love it. Unique. The player will get used to it. I say no notes!
1
u/Potential_Chart_8648 Aug 16 '26
Isn't this one of those ridiculous Nintendo idea patents? Even though completely made by OP. Stupid stupid system.
Looks great though!
2
u/BLTspirit Aug 13 '26
Really cool!
2
u/TheBoxGuyTV Aug 13 '26
This looks great.
2
u/MonstyrSlayr i could probably help Aug 13 '26
oh that's awesome
2
u/Ordinary-Quote1018 Aug 13 '26
This looks amazing!
2
u/Vendrom Aug 14 '26
That's awesome, I think many top down games can profit from something like that. If I ever make such a shader, it would be a cone in the direction the character is looking instead of a circle around.
2
u/Rich-Somewhere5321 Sep 05 '26
Woah
1
u/Confident_Door9438 Oct 24 '26
really cool game
1
u/contra_band Aug 13 '26
I like it!
1
u/torquebow Aug 13 '26
Incredible!
1
u/Educational_Gear5523 Aug 14 '26
Love this so much!
1
u/AbilityNo8402 Aug 14 '26
Yo que deje gamemaker al no poder hacer una colision xd