Author Topic: Figuring out BLEND_SHADOW.  (Read 2987 times)

Figuring out BLEND_SHADOW.
« on: June 21, 2016, 03:49:04 PM »
(Just to clear things up, I'm FAR from being an expert at Danmakufu AND blending. In fact, I'm just an amateur at both.)

After so many years, some things in Danmakufu ph3 are still a mystery. For example, nobody hasn't even figured out what BLEND_SHADOW does yet.
Since ph3 is now THE engine that everyone who wants to start scripting in Danmakufu should use, undocumented things like these are abysmal.

So, BLEND_SHADOW. It darkens every single object with a smaller layer than itself. It doesn't work if the object with the said blend is not layered above anything. (It's a ->shadow<-, what do you expect?)
An object with the blend also seems to completely ignore its alpha. Even if you set the object's alpha to 0, it still will be as visible as it was with 255.

Then, after experimenting a bit, I've discovered that it also inverts the colors completely! Here's an image of a Doremy cutin with BLEND_SHADOW applied.



I think it might turn pure black into transparency as well, explaining why the Doremy cutin seems less transparent on the silvery moon, rather than on the blue background.
But that's as far as it goes for me. I have no idea what use could such a strange blend serve, but it sure is interesting.

EDIT: Actually, now I'm pretty sure it turns PURE WHITE into transparency, not pure black. The moon was just an illusion. Damn lunarians!
« Last Edit: June 21, 2016, 03:55:06 PM by iVAwalys »
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: Figuring out BLEND_SHADOW.
« Reply #1 on: June 23, 2016, 02:20:04 AM »

PhantomSong

  • The Ghost Living through Everyday Life.
  • Eh, it doesn't matter.
Re: Figuring out BLEND_SHADOW.
« Reply #2 on: June 24, 2016, 08:06:18 AM »
An object with the blend also seems to completely ignore its alpha. Even if you set the object's alpha to 0, it still will be as visible as it was with 255.

Just to note, this is a given. To my knowledge, the only blend type to use alpha properties is, in fact, the alpha blend.

EDIT: This would also include ADD_ARGB.
« Last Edit: June 24, 2016, 06:48:06 PM by PhantomSong »

Re: Figuring out BLEND_SHADOW.
« Reply #3 on: June 24, 2016, 09:30:11 AM »
Just to note, this is a given. To my knowledge, the only blend type to use alpha properties is, in fact, the alpha blend.

I thought ADD_ARGB also has alpha properties? (Hence the letter A.)
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Drake

  • *
Re: Figuring out BLEND_SHADOW.
« Reply #4 on: June 24, 2016, 10:06:44 AM »
Add-blend (ARGB) also uses the alpha channel.

And um, sorry to disappoint, but after thinking about it for a bit and using it myself, I realized that Shadow-blend is literally just Subtract-blend. Which would explain why it's undocumented.
Seeming to invert the colors of the image is to be expected, since if you subtract the image from (255, 255, 255) you'll just get the inverted image. It is black that is made "transparent", since subtracting (0, 0, 0) from the source won't do anything. Subtracting colors close to black (like Doremy's shirt, book, and hair) will only lightly darken. Also note that subtracting her red hat from the purple background gives you blue.

Basically just swap BLEND_SHADOW and BLEND_SUBTRACT and see that nothing changes.

EDIT: Above is wrong. See my post below.
« Last Edit: June 24, 2016, 02:11:05 PM by Drake »

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Figuring out BLEND_SHADOW.
« Reply #5 on: June 24, 2016, 10:58:20 AM »
And um, sorry to disappoint, but after thinking about it for a bit and using it myself, I realized that Shadow-blend is literally just Subtract-blend. Which would explain why it's undocumented.
Seeming to invert the colors of the image is to be expected, since if you subtract the image from (255, 255, 255) you'll just get the inverted image. It is black that is made "transparent", since subtracting (0, 0, 0) from the source won't do anything. Subtracting colors close to black (like Doremy's shirt, book, and hair) will only lightly darken. Also note that subtracting her red hat from the purple background gives you blue.

Basically just swap BLEND_SHADOW and BLEND_SUBTRACT and see that nothing changes.

Nope.



The image on the left shows Sanae with subtractive rendering. The one on the right shows Sanae with BLEND_SHADOW. They're clearly a bit different.
Yes, both of these photos were taken in the exact same position, so you can't blame it on the background. Yes, they both have default alpha (255).
No, I didn't change anything in the code, aside from the blend type.
Lunatic 1CCs: PCB, IN, PoFV, HSiFS
Extra: All except PC-98.

Oh hey look I can do DNH scrips.

Drake

  • *
Re: Figuring out BLEND_SHADOW.
« Reply #6 on: June 24, 2016, 02:09:57 PM »
Alright, I got a use case that gave different results and I've figured out what it does. Your examples weren't very convincing but it got me to take another look so hey we good.

BLEND_SHADOW simply inverts the image, then uses a multiply-blend.



Left-to-right: No image, original image, shadow-blend, and manual invert-and-multiply. Note that they are exactly equal images.
« Last Edit: June 24, 2016, 02:16:34 PM by Drake »

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

PhantomSong

  • The Ghost Living through Everyday Life.
  • Eh, it doesn't matter.
Re: Figuring out BLEND_SHADOW.
« Reply #7 on: June 24, 2016, 06:46:29 PM »
I thought ADD_ARGB also has alpha properties? (Hence the letter A.)

Add-blend (ARGB) also uses the alpha channel.

Ah, you're correct. My apologies.

Drake

  • *
Re: Figuring out BLEND_SHADOW.
« Reply #8 on: June 25, 2016, 02:47:58 PM »
I've written up more comprehensive documentation on the wiki about the blend types; formulas included.
http://dmf.shrinemaiden.org/wiki/Render_Object_Functions#ObjRender_SetBlendType

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -