Z-Order Sort for 4 Polygons
Z-Order Sort for 4 Polygons
Based on the ALPHA transparency issue with sorting polygons from this thread: viewtopic.php?f=2&t=1170
Here's a solution that will automatically Z-Sort 4 Polygons arranged in a carousel. Example:
It's useful when you want to overlap 4 polygons with full ALPHA (Greenscreen video with ChromaKeyFast module used as an example). The sorting is synched with a simple Global Spin Rate variable.
Here's a solution that will automatically Z-Sort 4 Polygons arranged in a carousel. Example:
It's useful when you want to overlap 4 polygons with full ALPHA (Greenscreen video with ChromaKeyFast module used as an example). The sorting is synched with a simple Global Spin Rate variable.
Re: Z-Order Sort for 4 Polygons
Haha, as I was going about my day today I absolutely KNEW in the back of my head that you were going to figure out a solution like this. (I was thinking of a similar thing but yours is much more well thought out). Very nicely done
Re: Z-Order Sort for 4 Polygons
It took me a little while to understand what was going on here but very nicely done. This is computational problem solving pure and simple. (also, your use of annotations to explain and document is excellent)
Re: Z-Order Sort for 4 Polygons
Thanks Sadler. I think the general technique has broad applicability. Working on it made me realize that the lack of conditionals in MMV might not be as much of a limitation as I previously thought. (Having said that, I'd love for there to be support for conditionals with Globals.)
The main problem with the solution is that it kicks the issue down the road. The Z-Sort problem is solved, but it becomes a Time-Sorting problem. It only works in one direction, if you reverse the direction of the spin you need to re-sort the order of the inputs. With conditionals you can solve the general problem, irrespective of time order.
The main problem with the solution is that it kicks the issue down the road. The Z-Sort problem is solved, but it becomes a Time-Sorting problem. It only works in one direction, if you reverse the direction of the spin you need to re-sort the order of the inputs. With conditionals you can solve the general problem, irrespective of time order.
Re: Z-Order Sort for 4 Polygons
How would you need to use conditionals? The Expression modifier does support them: https://github.com/ArashPartow/exprtk/b ... readme.txt
Re: Z-Order Sort for 4 Polygons
To set up ranges where "if angle is within this range then this sort order. " From the comment above, it only works in one direction right now without rewiring.
Can I set up multiple "if then" statements with the Exp modifier? I don't see how I can work it.
Can I set up multiple "if then" statements with the Exp modifier? I don't see how I can work it.
Re: Z-Order Sort for 4 Polygons
i've used multiple consecutive exp modifiers with if statememts successfully. they either do something, or do nothing. if they do nothing and just pass through x, then the next if statement has the chance to do something, etc.
Re: Z-Order Sort for 4 Polygons
@Blackdot. Cool. Can you throw up a quick screenshot of what that looks like?
Re: Z-Order Sort for 4 Polygons
DOH! User error. I found a sorting error, so now it works irrespective of order. (I guess that's what happens when you stay up to the wee hours working on stuff.) If the Spin Rate Global goes out of the range (0-1) it does mess up, though. An EXPRESSION modifier of (1-x) makes it spin backwards fine. Attachment updated.artnik wrote:The main problem with the solution is that it kicks the issue down the road. The Z-Sort problem is solved, but it becomes a Time-Sorting problem. It only works in one direction, if you reverse the direction of the spin you need to re-sort the order of the inputs. With conditionals you can solve the general problem, irrespective of time order.
AND... conditionals. Is there anything MMV doesn't do?! I misspoke before investigating enough. The way the file is set up it doesn't actually need conditionals now the sort error is fixed. :-/
Re: Z-Order Sort for 4 Polygons
i wanted to make a little animation of an object that deforms in a certain way when i press different midi inputs. so i did a little test with 3 inputs. to "fake" the object behaving differently i made animations for every possible solution and triggered t hem depending on the inputs i pressed.artnik wrote:@Blackdot. Cool. Can you throw up a quick screenshot of what that looks like?
so with 3 buttons, you get 7 solutions:
A, B, C, AB, AC, BC and ABC (the order does not matter). so i rendered 7 image sequences and hooked them up like this:
i hope this is understandable .
the values for 1.1, 1.2 and 1.35 i chose pretty randomly, hoping they would result in unique different numbers if they're added.
Re: Z-Order Sort for 4 Polygons
Thanks Blackdot! That's clever summing the inputs.
That makes total sense. I was having trouble with the syntax, and this makes it crystal clear.
Have you used CASE?
That makes total sense. I was having trouble with the syntax, and this makes it crystal clear.
Have you used CASE?
Re: Z-Order Sort for 4 Polygons
well i dont know if we can use it . that would surely make it more easy instead of using 7 different modifiers. can we use that?artnik wrote:Thanks Blackdot! That's clever summing the inputs.
That makes total sense. I was having trouble with the syntax, and this makes it crystal clear.
Have you used CASE?
Re: Z-Order Sort for 4 Polygons
Well, if not perhaps in the future? It looks like that library supports more than single line code. It would be like adding scripting.
Re: Z-Order Sort for 4 Polygons
woah, switch is actually working.
https://github.com/ArashPartow/exprtk/b ... e.txt#L514
i tried it with
and just copied the whole thing into t he expression modifier. it works. awesome .
https://github.com/ArashPartow/exprtk/b ... e.txt#L514
i tried it with
Code: Select all
switch
{
case x == 1.1 : 10;
case x == 1.3 : 30;
case x == 1.5 : 50;
default : x;
}
-
- Posts: 176
- Joined: Tue Aug 26, 2014 11:22 am
Re: Z-Order Sort for 4 Polygons
what a great work, thanks a lot !
Re: Z-Order Sort for 4 Polygons
Thank you for this topic, I've learned a lot. I was afraid to use expressions. Now you have cleared the way a bit: I'm still afraid but I have some example to cut my teeth
Very clever and elegant solution for the Z sorting, hats off!
Very clever and elegant solution for the Z sorting, hats off!
Re: Z-Order Sort for 4 Polygons
@blockdot if the variable x is never exactly assigned the values (1.1, 1.3, 1.5), it's be better to use the 'equal' function which uses a quantized epsilon approach to determining equality between the floating point values.
For example 1.3 and 1.2999999999 (potential value of x) wont be considered equal in the original expression code, however in following code they will be:
For example 1.3 and 1.2999999999 (potential value of x) wont be considered equal in the original expression code, however in following code they will be:
Code: Select all
switch
{
case equal(x,1.1) : 10;
case equal(x,1.3) : 30;
case equal(x,1.5) : 50;
default : x;
}