xLightsSequencer / xLights

xLights is a sequencer for Lights. xLights has usb and E1.31 drivers. You can create sequences in this object oriented program. You can create playlists, schedule them, test your hardware, convert between different sequencers.
GNU General Public License v3.0
549 stars 208 forks source link

Method to limit depth of layer blending #4552

Open schreyack opened 5 months ago

schreyack commented 5 months ago

I'm always frustrated when I want to apply a layer blending mask in layer 1 which impacts layer 2, but not layer3.

I would like to be able to apply layer blending of "Blend End" to layer 3, which would then allow all layers below (layers 4+) to not have any impact from the blending in layer 1.

I have tried every method I can think of to get around the mask, such as applying the mask to a different group, but there doesn't seem to be any way to avoid the mask. If there is already a way to do this, I apologize.

computergeek1507 commented 5 months ago

I'm pretty sure you can do this with Canvas mode and off effects

schreyack commented 5 months ago

I did try that... layer 3 is off effect (i tried both with transparent and not) set to normal and canvas mode. layer 4 is on effect and selected as the layer to blend into layer 3. I also tried layer 3 as on effect. In all cases, nothing overrides the mask from layer 1.

cybercop23 commented 5 months ago

Can you create a sample layout with one/two models and a sample sequence with the setting(s) you have tried?

AzGilrock commented 5 months ago

Is layer 1 the very top layer or the bottom layer? Cause the bottom layer renders first and the top layer renders last so you won't override the top layer using layers below it right?

schreyack commented 5 months ago

Is layer 1 the very top layer or the bottom layer? Cause the bottom layer renders first and the top layer renders last so you won't override the top layer using layers below it right?

No, layers render top to bottom, unlike elements which render bottom to top.

schreyack commented 5 months ago

Can you create a sample layout with one/two models and a sample sequence with the setting(s) you have tried?

Here you go! Test.zip

dkulp commented 5 months ago

What are you expecting it to do? It looks correct to me. Layer 2 is a white on effect with "normal" blending. Thus, everything below that is pretty much irrelevant. Layer 1 is Circles as unmask which would be unmasking the white from the layer below it.

AzGilrock commented 5 months ago

Not sure what you are calling a layer vs an element but inside a model the layers render bottom first. Models and groups render top to bottom based on master view.

schreyack commented 5 months ago

What are you expecting it to do? It looks correct to me. Layer 2 is a white on effect with "normal" blending. Thus, everything below that is pretty much irrelevant. Layer 1 is Circles as unmask which would be unmasking the white from the layer below it.

this is a somewhat silly example - but i want the layer 1 unmask to apply to layer 2 only, so that i can then apply an effect in layer 3+ that would show behind the circles being unmasked by layer 1.

schreyack commented 5 months ago

here's an example that hopefully explains better what i'm trying to accomplish - i'm using the layer 1 unmask to create an animation of a rocket trail (think 4th of july show) moving across the scene by only showing a bit of a pinwheel in layer 2. which works great. but then i want to have an effect like twinkle in layer 3 showing on the entire background, not just the area being exposed by the unmask. does that make sense? Test 2.zip

AzGilrock commented 5 months ago

I'm not sure there's a way to do but it seems like we should have that capability. The Twinkle renders first, then the Pinwheel, and so the Circle ends up masking both of them cause it evaluates last. I thought maybe you could put the Twinkle on a Group containing the Matrix but it ends up clipping that also cause the way it works is the cross model blending copies what's on the group into the buffer first so its just like putting it on the bottom layer of the model. I thought this topic was discussed and some sequencers had come up with ways to do it. I don't sequence much anymore cause I'm writing xLights and then get sequences from vendors.

dkulp commented 5 months ago

The question to me is whether the bg.Set(0, 0, 0); in the unmasks should be bg.Set(0, 0, 0, 0); instead. I need to experiment a bit more with that to see what it may break. That would allow a canvas to be used for the pinwheel+shape that would then have the "black" areas be transparent and not black.

AzGilrock commented 5 months ago

Or we create yet another unmask type. :)

MrPierreB commented 5 months ago

You can do what you want already by either re-ordering your layers to achieve the effect or you can use canvas mode and using off effects to apply the layers below above the masking your are doing.

For example in your example. you can place the twinkle effect as the top layer and have the layer blending set to layered. I know that is beside the point here as you want to know how to do it if it was at the bottom. The way you could do it when the layer is below the masking effect as you suggest.. is to have 5 layers in this case. The very bottom layer is your twinkle effect. Then you have an standard off effect on the layer above it to turn it off so it is not shown on the pinwheel layer which is the layer above it. then above the pinwheel you have your shape effect with your 1 is true unmask layer blending style. then the top layer is another off effect, but this one you set to Canvas mode and you click the layers button and select Layer 5. Set it to be transparent and then set your layer blending to Layered. That will accomplish the same thing.

If you have multiple layers and not only a twinkle you want to show above, you will use another off effect to combine them using transparent and persistent.

schreyack commented 5 months ago

@MrPierreB thank you! that works as you described.

@dkulp @AzGilrock given there is a solution to this problem (although, i would describe it as a work around) i don't know if it's worth the development effort to have a less convoluted way to achieve this. but it would be nice. :)

AzGilrock commented 5 months ago

Thanks Pierre....you know I tried last night to figure out that Canvas feature and I couldn't make it work. I've never used it and didn't write that part so I went to the user manual which led me to believe Canvas was only useful if you were using the Warp or Kaliedescope effects. I'd need to go home to see this in action but it seems like if you pull in a lower layer how does it not look like its above the layers below it same as if you had just put the twinkle on top?

schreyack commented 5 months ago

because you set the layer blending to "layered". (i think that's what you're asking)

edit - oh - you mean, why not just put twinkle on top and make it layered. ha. yes, that works as well. but there are cases where you have something on a lower layer already and it's easier to pull it to the top.

AzGilrock commented 5 months ago

I'll have to lookup what Layered does. To accomplish what we are talking about it would have to flip itself below the buffer that has already built up below it an do a Normal blend with transparency

dkulp commented 5 months ago

I just pushed a bunch of changes that will make this a bit easier. The main problem was due to "Canvas" mode effects always ending up being 100% solid (alpha always at 255) which then didn't allow any decent way of blending with layers below it that were not part of the canvas. I fixed that, but that doesn't really address this as the "True Unmask" blending also sets everything to solid black. To deal with that, I've added new "Styles" to the transparent off effect used for canvas blending to provide options to convert Black -> Transparent. This allows a Canvas off to blend the two layers to create the meteor, but making all the "Black" outside the meteor to be transparent which would then blend onto the twinkles below it like a normal effect.

dkulp commented 5 months ago

I should add that I'm hoping those changes don't break anything too seriously. :)

AzGilrock commented 5 months ago

There's a 100% chance someone was relying on the old behavior. :)

schreyack commented 5 months ago

wow, that was quick! thank you!!

MrPierreB commented 5 months ago

I always understood it as on mulitple layers it renders from the bottom up.. it would apply the layer above to the layer below, and after it did its processing , that now becomes 'Effect 2' and will render the layer above onto that , then that becomes 'Effect 2' etc... And canvas mode is taking the layers below and drawing it physically onto that layer as if the pixels were on that layer (and you can select which layers it uses). So in this sense it makes sense and working from the bottom up works. Don't think going other way and now limitting how many layers down it affects would be wise. Would definetly break those who use many layers (I'm releasing a sequence soon and hoping this change wont affect it) and I know Doug Reel uses alot of canvas mode.

AzGilrock commented 5 months ago

I have no idea who Doug Reel is and he's never given me anything so impact away....lol.