ID:2112574
 
I'm wondering if there's any way to do masked or subtractive images, in Dream Maker

For example, i'd like to make a ripped clothes effect - a sprite that would be overlayed on clothing and subtract areas from it,making transparent spots, creating holes to show the underlying skin. Is that possible?

Is there any means for using masks too? For example, to make a character look like smoke by applying a square smoke texture and masking it with their base icon so it creates a human-shaped smoke area.

These seem like obvious features for a 2D game, but i'm not sure how advanced byond's graphical tech is
Nope, there's no built-in masking system. There's also no user-made masking library either, as far as I know.

You might try to do it using icon.DrawBox(null, x1, y1, x2, y2) to modify the icons involved, but it's not exactly a great substitute.
You could probably also do some kind of hacky Blend() usage, but again, not a great solution.

Masking outright would be really awesome.
NanakoAC wrote:
For example, i'd like to make a ripped clothes effect - a sprite that would be overlayed on clothing and subtract areas from it,making transparent spots, creating holes to show the underlying skin. Is that possible?

Can be done with code:
var/icon/clothing = icon('clothing.dmi',"shirt")
var/icon/rip = icon('clothing.dmi',"shirt_rip")
clothing.Blend(rip, ICON_MULTIPLY)

"shirt" is any old clothing sprite, "shirt_rip" is completely white except for areas that are to be "cut out" of the shirt sprite, those patches are drawn transparent like holes (eg: drawing a few holes in the "shirt_rip" state will lead to holes in the "shirt" state, wherever the shirt and the blobs line up)

Here's an example of the above that I did for SS13 to cut out the fake flesh of a robot (makes for a cool "damaged" state)




Is there any means for using masks too? For example, to make a character look like smoke by applying a square smoke texture and masking it with their base icon so it creates a human-shaped smoke area.

Again, doable in code:
var/icon/smoke = icon('effects.dmi',"smoke")
var/icon/human = icon('humans.dmi',"human")
human.Blend(smoke,ICON_ADD)

The above code blends a full square of smoke onto a human icon

Example from my random test world:

Which uses:

as it's "smoke square" (in this case however, it's an ice/frozen effect)

If you want to use these icon objects as icon_states you can do
fcopy(ICON_OBJECT,"a_new_file_name.dmi")

to output the icon as a new .dmi file

Here's a mask that doesn't use icons at all:

object being blended onto is src

    //ugly to reduce image() calls and appearance churn
var/obj/debuggery = new(locate(x+3,y+1,z))

var/image/together = new()
together.appearance_flags = KEEP_TOGETHER
var/image/alpha_mask = image('icons/generic.dmi', "square")
alpha_mask.color = list(0,0,0,1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,0)
alpha_mask.appearance_flags = KEEP_TOGETHER
var/image/texture = new()
texture.appearance = appearance
texture.blend_mode = BLEND_MULTIPLY
texture.color = list(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,0,0,0, 0,0,0,1) //move alpha to red channel
alpha_mask.overlays += texture
texture.icon_state = TEXTURE_TO_MAP //replace with icon_state of your mask
//texture.icon = //replace with icon of your mask
alpha_mask.overlays += texture
together.overlays += alpha_mask
texture.color = list(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,0, 0,0,0,1)
together.overlays += texture

debuggery.overlays += together

var/obj/debuggery2 = new(locate(x+2,y+1,z))
debuggery2.appearance = appearance
debuggery2.overlays += together
You guys are amazing, great work. Bookmarking this thread, i will revisit it for a near-future project