Previous topicNext topic

Performant transparency when iterating

Questions, comments, feedback, etc.
Post Reply
Sadler
Posts: 1143
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Performant transparency when iterating

Post by Sadler »

I use random triggers a lot with iterators, often to randomise the colour across iterations. In this case, I want to use a random trigger to control the transparency of polygons. In Magic there are two ways to add transparency - using a colour node or a transparency node. A colour node requires both brightness and alpha to be adjusted to get a fully transparent element, so the random trigger must be applied to both.
.
random-trigger-colour-alpha-params.jpg
random-trigger-colour-alpha-params.jpg (21.31 KiB) Viewed 734 times
.

However, there is no way to connect them (that I can think of) and this means that brightness and alpha can be one of four values. 0 brightness and 0 alpha gives full transparency. 1 brightness and 1 alpha gives no transparency. 00 and 11 is what I want, but the random trigger on two separate parameters can also be 01 and 10.
random-trigger-colour-alpha-iterator.jpg
random-trigger-colour-alpha-iterator.jpg (11.44 KiB) Viewed 734 times
.

A shared global won't do, because it won't work with the iterator. A transparency node will, but the iterator makes a copy of the transparency node for each iteration and the frame rate drops quickly. I can have 1000 polys with a colour node but barely 40 with a transparency node before 60fps starts to degrade.

So is there either a performant transparency (for the iterator) with a single param (for the trigger) or is there a way to use a global to connect the two parameters that I've missed?
Terry Payman
Posts: 711
Joined: Sun Sep 14, 2014 8:15 am
Location: UK
Contact:

Re: Performant transparency when iterating

Post by Terry Payman »

Not an answer to the question, but perhaps a custom ISF would make a good workaround.
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Performant transparency when iterating

Post by Magic »

How about a pseudo-random number generator? Which takes the iteration # as the input and outputs 0 or 1? Giving the same iteration # would therefore result in the same value. But it would look random-ish. Quick Google search: https://devpost.com/software/sinusoidal ... -generator. Seems like you could easily simplify/modify it to output only 0 or 1.
Sadler
Posts: 1143
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Performant transparency when iterating

Post by Sadler »

Terry wrote:perhaps a custom ISF would make a good workaround
Even the simplest ISF has a similar overhead as Transparency and other FX. Unless you meant something else?
Eric/Mike wrote:How about a pseudo-random number generator?
An interesting idea. I had trouble with your link but rolled my own simple PRNG with an expression using a global increase as time (though this constantly updated). Tried again using a global with a random trigger based on audio - this works satisfactorily, though the algorithm needs fine tuning and I don't fully understand it yet.
Screenshot 2024-03-08 214406.jpg
Screenshot 2024-03-08 214406.jpg (29.84 KiB) Viewed 721 times
x is the iteration# and rnd2 is the random trigger

And, just for testing, 1000 iterations still work.
Sadler
Posts: 1143
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Performant transparency when iterating

Post by Sadler »

Tying up this thread, this is what I had in mind during a waking up dream - the poly arrangement changes on the beat. 144 polys in total for the cube with no cooling fan noise. Nice!
Screenshot 2024-03-09 091036.jpg
Screenshot 2024-03-09 091036.jpg (206.61 KiB) Viewed 709 times
Post Reply