Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
Game Maker Tutorial of the week! Today I discuss a blend mode that I often use for ink/blood splatter and silhouette effects.
[NOTE: This turtorial is content from my personal blog and may seem incomplete when taken out of context]
Hello everyone!
I have been wanting to get back into some #gamedev tutorials for quite some time now. For the time being, I'm going to start doing weekly Game Maker: Studio tutorials to get things rolling. I have a fairly long list of requests, but feel free to send your other ideas my way!
Blend Modes
What are blend modes? Blend modes tell GM what formula(s) to use when blending pixels (your source) with pixels that have previously been drawn to the screen (your destination). By default, GM uses a mode called bm_normal. This mode draws everything how you'd typically expect things to be drawn. If you have a red pixel, and you draw blue over the top of it, it becomes a blue pixel (this is somewhat dependent on the alpha channel of each pixel, as well).
Extended Blend Modes
Ok, so what are extended blend modes? Extended blend modes are a bit more difficult to grasp for most beginner to intermediate users. When setting an extended blend mode, you choose a mode for both your source and destination, separately.
draw_set_blend_mode_ext(source, destination);
The formula for drawing a pixel to the screen is as follows:
((Rs, Gs, Bs, As) * BLEND_MODE_INFO_SOURCE) + ((Rd, Gd, Bd, Ad) * BLEND_MODE_DEST)
Practical Example
Today I will talk about an applicable example that I use in both my previous project, INK. Simply put, it prevents anything from "drawing outside of the lines".
I also use this effect to draw silhouettes in our new Spaceboy Games project, FaraWay. When an object is behind another object, you draw the *behind* object blended with black (after applying the blend mode) to draw all or partial silhouettes on top of the *front* object.
Project
I have attached a sample project that allows you to mess with this blend mode by drawing colorful shapes when the left mouse button is down. The extended blend mode allows you to scribble around freely without any of the ink effecting anything other than the blank white sprite space (the black background is left unaltered).
-Z
Read more about:
BlogsYou May Also Like