informa
/
2 MIN READ
Blogs

GMTWeekly: Extended Blend Modes Pt.1

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).

GMTWeekly0.gmx.rar

-Z

Latest Jobs

IO Interactive

Hybrid (Malmö, Sweden)
3.02.23
Gameplay Director (Project Fantasy)

Arizona State University

Los Angeles, CA, USA
2.27.23
Assistant Professor of XR Technologies

IO Interactive

Hybrid (Copenhagen, Denmark)
3.02.23
Animation Tech Programmer

Purdue University

West Lafayette, IN, USA
3.02.23
Assistant Professor in Game Design and Development
More Jobs   

CONNECT WITH US

Explore the
Advertise with
Follow us

Game Developer Job Board

Game Developer

@gamedevdotcom

Explore the

Game Developer Job Board

Browse open positions across the game industry or recruit new talent for your studio

Browse
Advertise with

Game Developer

Engage game professionals and drive sales using an array of Game Developer media solutions to meet your objectives.

Learn More
Follow us

@gamedevdotcom

Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more