Previous topicNext topic

More inputs for the "Blend" module

Suggestions for new features for Magic.
Post Reply
TKS
Posts: 139
Joined: Mon May 17, 2021 10:40 am

More inputs for the "Blend" module

Post by TKS »

Right now when I have to blend 4 images I have to use 3 "Blend" modules because it only accepts 2 inputs. With more images (or sources in general) a scene gets very crowded.

It would be much more convenient if I could connect all 4 (or more) images to one single "Blend" module, and it would blend the first with the second input, blend the result of this with the third input, blend the result of this with the fourth input and etc.etc.
Terry Payman
Posts: 710
Joined: Sun Sep 14, 2014 8:15 am
Location: UK
Contact:

Re: More inputs for the "Blend" module

Post by Terry Payman »

Which blend are you choosing? A very simple ISF module could Add all the images and could easily accommodate (say) six inputs. It could more efficient to limit the module to four inputs, I haven't yet compared performance. Useful to have the module name indicate the maximum number of inputs that can be accommodated, eg "Add4.fs", as further inputs would be apparently be accepted by the module but would not be added into the output.
Terry Payman
Posts: 710
Joined: Sun Sep 14, 2014 8:15 am
Location: UK
Contact:

Re: More inputs for the "Blend" module

Post by Terry Payman »

Attached is a module that can Add up to 6 inputs. On my system there's no performance penalty in having the extra inputs available but unused - it's only a matter of how many inputs are actually connected. With 6 connected inputs the performance is very close to having 4 inputs to 3 Blend modules.

Alpha of the inputs is ignored. Alpha of the output is 1.0

EDIT: This is a trivial and efficient example, demonstrating the ease with which multiple inputs can be accommodated. Here only a single (and simple) blend mode is implemented, but I expect the approach could be extended to other blend modes and to offer a choice of alternative modes.
Attachments
Add 6 inputs.fs
ISF file that adds up to six inputs
(1005 Bytes) Downloaded 435 times
TKS
Posts: 139
Joined: Mon May 17, 2021 10:40 am

Re: More inputs for the "Blend" module

Post by TKS »

Terry Payman wrote:Attached is a module that can Add up to 6 inputs.
That's actually quite simple to understand and to expand.
I think I remember that someone posted tons of different code to mix/average/whatever different inputs, so it should be doable for me to start with your Shader and add the different "Blend" modes I would probably need.

Thanks a lot :!:
Terry Payman
Posts: 710
Joined: Sun Sep 14, 2014 8:15 am
Location: UK
Contact:

Re: More inputs for the "Blend" module

Post by Terry Payman »

You're welcome :D
I played around a bit further and I made the attached Difference blend module which could be more generally useful than an Add

Further thought on module naming: Starting names with "Blend" will make them easier to find.

I think this could be the source of the code you saw: https://magicmusicvisuals.com/forums/vi ... .php?t=153. I'd almost forgotten about this thread, and my conversation with Eric about the trade-off between versatility and performance. With 6 inputs this attached module is significantly more efficient than cascading 5 Blend modules (140fps vs 96fps on a stress test at 4k resolution), so it might be worth creating separate modules to suit each of your desired blend modes as well as combining all the modes into one module. In a specific instance you can then readily compare the blend options using the all-in-one blend module, perhaps then substituting a dedicated blend module if performance is critical.
Attachments
Blend Diff 6.fs
ISF file that differences up to 6 inputs
(1.39 KiB) Downloaded 451 times
Post Reply