Picture/Image masking plugin, simple graphic effect.

ShadowDragon​

this is a real lifesaver and it works well, but is there any way I can make sure the resulting masked image stays under the player and all events?
pictures in general so far I know are drawn on top of it.
but if you want it below player/events, I can see what I can do for that, probably with a new parameter during
the apply, so it will be below or above when setting it.

but allow me some time to fiddle around this week.
@cutebutwhy Set below Characters/events should work, now, can't test in MZ
Spoiler: Helpfile
Code:
 Introduction
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 This plugin allows one picture to act as a graphical mask for another.

 A mask controls pixel visibility:
   - White areas of the mask reveal the picture.
   - Black or transparent areas hide the picture.

 
 How to use
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 1) Show pictures in an event:

    Show Picture #2  → Object Picture (the picture to be masked)
    Show Picture #1  → Mask Picture (the picture used as mask)

 2) Make sure:
    - The Object Picture ID is higher than the Mask Picture ID.
    - The mask picture is visually below the object picture.

 3) Apply the mask via script call:

    $gameScreen.setPictureMask(objectId, maskIds, belowCharacters);

    - objectId        → ID of the object picture to mask
    - maskIds         → single number or array of mask IDs
    - belowCharacters → set pictures below characters or events (default false)

 Example:
    $gameScreen.setPictureMask(2, [1,3,5]);  //=> to apply multiple masks

 Notes:
    - Multiple masks can be applied to the same object picture.
    - The last mask in the array is applied visually (overwrites previous mask).


 To remove mask(s):
 
 1) Remove BOTH object and mask(s):

    $gameScreen.removeMask(objectId);

 Behavior:
   - Detaches all masks from the object picture.
   - Erases the object picture.
   - Erases mask pictures*only if no other objects are using them**.

 Example (Shared Mask):
   Object 1 → Mask 5
   Object 2 → Mask 5

   removeMask(1) →
       - Object 1 is removed
       - Mask 5 stays because Object 2 still uses it

 2) Remove ONLY a specific mask from an object (keep pictures visible):

    $gameScreen.removeMaskFromPicture(objectId, maskId, removeObject = false);

 Behavior:
   - Detaches the specified mask from the object picture.
   - Other masks on the same object remain applied.
   - Both the object picture and unused masks remain visible.

 Example:
   Object 1 → Masks [4,5,6]

   removeMaskFromPicture(1, 5) →
       - Mask 5 is removed
       - Object 1 remains masked by 4 and 6

 Optional:
   removeMaskFromPicture(1, 5, true) →
       - Mask 5 is removed
       - Object 1 picture is erased along with all its masks.

 
 MZ Plugin Commands
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
   SetPictureMask
      - Object Picture ID: number
      - Mask Picture IDs: string (comma-separated list for multiple masks)

      Example: Object ID 2, Mask IDs "1,3,5"

   RemoveMask
      - Object Picture ID: number
 

 MV Plugin Commands
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
   setPictureMask objectId maskIds
      - maskIds can be a single number or a comma-separated string: "1,3,5"

   removeMask objectId

 Example (MV):
   setPictureMask 2 1,3,5       (place picture above characters/events)
   setPictureMask 2 1,3,5 true  (place picture below characters/events)

 
 Reminder
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 • Masks are automatically restored after exiting menus, battles, or map transfers.
 • Shared masks are reference-counted:
   - A mask is only erased when no objects are using it.
 • Multiple masks per object are supported.
 • The last mask applied is visually active (on top of previous masks).
 • Designed for full compatibility and stability in both MV and MZ.

New added, set new parameter to set it below characters or events (true/false)
restructed the container to play nicely with a new picture container to find
which picture is in which container in order to remove them cleanly.
@ShadowDragon really appreciate the quick work on this, thank you. However it's not working in my test project. Maybe I'm doing something wrong?

This is my event that activates through a switch, shows the two pictures and activates the plugin commands.

1772141563783.png


revealed_inmask is the image I want to show inside the masked area. Outside the mask I want to show the parallax layer I have set up with Galv's Parallax in the map note area. I am taking the player's screen X and Y so the mask moves with the player.

1772141699657.png


However you can see that the mask doesn't show my parallax in the black area, and it still shows the masked image above the character and events layer.

I am thinking that maybe I could be setting up the mask in the wrong way? Right know it is a black image with an alpha in the middle, which is where the masked image shows through.

Regardless, appreciate your work on this and for making it usable on MZ.
Outside the mask I want to show the parallax layer I have set up with Galv's Parallax in the map note area. I am taking the player's screen X and Y so the mask moves with the player.

you event show mask ID 2 while the helpfile is clearly written as:

Code:
 *    Show Picture #2  → Object Picture (the picture to be masked)
 *    Show Picture #1  → Mask Picture (the picture used as mask)

I don't know if this affect ordering explicit as I use it as the above
as the higher number picture ID = the main object, the lower one
go for masking.

aside from that, I didn't test it for parallax layers though, but if you wan't
parallax to be masked, that I need to check galv or how parallax works
for MV and MZ in order to tackle this one.

but I can check probably next week or somewhere this week when able.

but DM me with all info and I see what I can do.
@ShadowDragon Bedankt! I actually tested it on a new game without any plugins and for some reason I get an error. I'm also attaching here the actions setup in this new file.

1772145869081.png


Btw how do you DM here? 😳

1772145890335.png
Anyone that download the latest has a MZ command type bug (patched).
there is also a layer mistake (which is my bad).

New version will be available later this day, which replace the previous version
to a new version with bug fixes and MZ command typo.

sorry for the inconvenience.

Edit:
version is rolled back, but corrected an issue for not masking instantly.
below characters is removed for the time being, as Star tiles go above pictures
as well.

However, I try to add "parallax masking" which can work for below tilesets (and characters).

below character gets messy as I need to deal with events, alter star passability and more.
and I don't know how to deal with this yet, so if any has an idea, let me know and I see
what I can do by than.

Original thread: https://forums.rpgmakerweb.com/threads/picture-image-masking-plugin-simple-graphic-effect.119767/