An issue with the shadows in the MZ RTP (and how to fix it)

Wecoc

Veteran
Veteran
Joined
Jul 4, 2021
Messages
59
Reaction score
139
First Language
Catalan
Primarily Uses
RMXP
I noticed something odd involving the RTP graphics in RPG maker MZ.

In MV, the shadows are pure black and have a transparency of around 50%. Even if the shadow itself is smooth, the color is always pure black (0, 0, 0) which makes it easy to pick, and then remove it or change its color, etc. That doesn't always happen, but it's almost guaranteed to be like that. That means even if the opacity is not fixed like in XP, it still acts like it's pixelart; this is very useful for recolors and things like that.

MZ_transparency01.png

Well, in MZ that doesn't happen at all, the color is just not consistent.

Here's the proof. I tried removing the shadow from the large skeletons in both MV and MZ over a green background and change it to white. MV looks fine but in MZ there's dirtiness all over the place.

MZ_transparency02.png

I made an Engine for WecTools that fixes this.

Simply paste it on the Engines folder with the name "MZ Alpha Bugfix", open the desired tileset/tile with the tool Simple Image Editor, execute the Engine (you will have to wait a bit if you're doing it with full tilesets), and after checking everything still looks fine, save it again.

Ruby:
"Simple Image Editor"

module MZ_Alpha_Bugfix
 
  # Define here the maximum shadow opacity. Everything over this threshold
  # won't be considered shadow so the color change won't be applied.
  OPACITY_THRESHOLD = 160

  # Define here the maximum luminosity threshold; that means transparent things
  # that are very bright (like halos) won't be considered shadows.
  LUMINOSITY_THRESHOLD = 32

  # If you toggle this option the transparency will be removed in anything
  # that's not considered shadow (from threshold to 255 everything will be
  # flatted to 255)
  FLAT_ALPHA_OBJECT = false
 
end

SIMPLE_IMAGE_NIL = "You must load an image before running this engine"

def color_is_shadow?(color)
  return false if color.alpha > MZ_Alpha_Bugfix::OPACITY_THRESHOLD
  lum = color.red + color.green + color.blue
  return false if lum > MZ_Alpha_Bugfix::LUMINOSITY_THRESHOLD
  return true
end

def run_engine
  if @simple_window.image.nil?
    MessageBox.set(SIMPLE_IMAGE_NIL)
    return
  end
  result = @simple_window.image.clone
  for iy in 0...result.height
    Graphics.update if iy % 100 == 0
    for ix in 0...result.width
      current = result.get_pixel(ix, iy)
      next if current.alpha == 255 || current.alpha == 0
      if !color_is_shadow?(current)
        if MZ_Alpha_Bugfix::FLAT_ALPHA_OBJECT
          current.alpha = 255
          result.set_pixel(ix, iy, current)
        end
      else
        result.set_pixel(ix, iy, Color.new(0, 0, 0, current.alpha))
      end
    end
  end
  @simple_window.image = result
end

run_engine

I hope this helps.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,899
Reaction score
14,995
First Language
English
Primarily Uses
RMMV

I've moved this thread to Useful Development Tools. Thank you.

 

Latest Threads

Latest Profile Posts

Does the word "research" imply that you're searching for something that had been found before?
So Dad broke the blinds two days ago and he finally decided to try to fix them. I doubt he'll do very well without some help. And I can't help him myself--I don't know how the stink to fix those blinds. My knowledge is just plushies, mascots, computers, animation, and video game design. And also, I've had to stop family and friends from downloading viruses too many times to count.
IlluminaughtyStore.jpg
:kaojoy:
Welcome to the Illuminaughty store.
Yes... they are "wearing Illuminati branded everything, reclining on huge Illuminati body pillows. Occasionally they'll "teehee" at each other and have pillow fights with Illuminati branded pillows full of hundred dollar bills."
BCj
Working on Escalia again, feels good. Have this overwhelming urge to map as well, but need to get some extra tiles commissioned first :D
Lee Sang wrote on Bandito's profile.
Hi, I've just tried your plugin "Game is Active" and when I tested it on Android, it gave me an error, something about "Cannot read property 'underfined' of underfined.

Forum statistics

Threads
113,872
Messages
1,078,082
Members
147,962
Latest member
CuidadoDoyJuegos
Top