Multiply??

New releases and general discussions.

Post » Tue Nov 20, 2007 4:28 pm

Why is the effect Multiply used to create light effecs? I mean, it works like it should, but I think the name is a bit missleading. What does the effect actually do? how does it work? :?
B
1
G
5
Posts: 20
Reputation: 1,265

Post » Tue Nov 20, 2007 4:45 pm

Because it multiplies pixels together :)

I thought about calling it "Lighting" or something, but the standard name in all graphics applications is Multiply, so I thought I'd keep it consistent.

The way pixel shaders work is every pixel is made up of values ranging from 0 to 1 for red, green and blue. So a dark red might be RGB 0.5, 0, 0, and 50% grey would be 0.5, 0.5, 0.5.

If you use a multiply effect on a dark red background with a gradient from white (1, 1, 1) to black (0, 0, 0), you'll notice:

(1, 1, 1) x (0.5, 0, 0) = (0.5, 0, 0)
i.e. the white areas of a multiply effect have no effect on the background

(0.5, 0.5, 0.5) x (0.5, 0, 0) = (0.25, 0, 0)
i.e. the 50% grey areas of a multiply effect darken the background by 50%

(0, 0, 0) x (0.5, 0, 0) = (0, 0, 0)
i.e. the black areas of a multiply effect are always black (anything multiplied by 0 is 0).

This means you can use a greyscale image with a multiply effect to darken regions of the background by different amounts, making a nice lighting effect.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Tue Nov 20, 2007 4:55 pm

Aah! thanks!
B
1
G
5
Posts: 20
Reputation: 1,265

Post » Tue Nov 20, 2007 10:04 pm

Oh, I have a few questions about effects too!

Does erase do nothing else than changes the object it's applied black? Isn't it basically the same as applying a black colour filter?

Back then, there was discussion about "cookie cutter" effect, or something like that. Is that effect implemented? The description of "Mask" looks like it, but it just reverses the alpha channel.

Are the "combine" effects supposed to look this messy?
[url:aq0dl0ad]http://student.sipoonlukio.com/~kontiopyry/misc/combine_additive.png[/url:aq0dl0ad]
What do they actually do?

Does Glow have any other usage than using it after blur?

What kind of blends are Overlay and Screen?
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Tue Nov 20, 2007 10:23 pm

Erase and Mask are very similar if I recall correctly. They will erase the object's shape from the current display (like a cookie cutter). This is only useful with layers: each layer draws to its own texture, and then draws to the screen. Erase means the object's shape is erased from the texture drawn so far, so when the layer is added to the main display, there's a hole.

However Construct will draw the layer directly to the screen if there are no effects on it (and opacity is 100% and colour filter is white). This means erase and mask won't work, because it can't cut holes from the main display! This is an unintentional side-effect of this display optimisation, so I'll add some kind of option to override it. For now setting a layer's opacity to 99% is a workaround.

Eg. try:
Layer 2: black background, 99% opacity, with a mouse-controlled sprite with Erase on it
Layer 1: some tiled background so you can see what this layer looks like.

The sprite will cut a hole in layer 2.

The combine effects are special experimental effects. They combine the last stage in the effect chain with the first so must be used with other effects (otherwise you get undefined drawing like your picture) using blending (either additive or dodge). I think originally the theory was for a glow-round-the-edges effect - a thick outline followed by a blur, then add it together with the original image - but I just had a play with it and cant seem to do anything useful with them :P

AFAIK Glow and HDR are only useful after blurs or softens.

I forget what overlay is useful for, but Screen is a much nicer way of additive blending things like explosions.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Tue Nov 20, 2007 11:30 pm

Thanks, I got it now and I love the effect. Do you think that option to override the optimisation is manual or is Construct going to do it automatically, if there's erase or mask effect on the layer?
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Tue Nov 20, 2007 11:35 pm

I'll probably make it a checkbox in layer properties. I don't like hard coding these things and there might be other areas that forcing a layer to its own texture might be useful.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 3 guests