Zep Palen |
I have been playing with the IF Component to use as a color replacement Tool in a script and came about this funny situation.
The attached screenshot shows two almost identical setups. All are same colors and operation type. Except for the ELSE result. The ELSE result map is set to a none Alpha in TEST 1 and to a Alpha in TEST 2. I am aware of that comparisment is done on a bitwise basis on the Source input maps and therefor values here is not just as using the RGB values to test with. But that is not really the issue... The issue is: IF (Source A < Source B = TRUE) in TEST 1 then it should also be in TEST 2 and because of that just return the THEN Result. What am I missing here? ![]() |
|||||||
Posted: December 29, 2013 6:23 pm | ||||||||
ThreeDee
![]() |
Certainly looks like a bug, IF component seems to use ELSE as the alpha source regardless of the operation.
|
|||||||
Posted: December 30, 2013 4:39 am | ||||||||
Zep Palen |
Yes. Exactly what I thought. And in other operation modes it makes similar results.
It seems like the bug is only there if Alpha is set to other values than full opacity on the ELSE input map. |
|||||||
Posted: December 30, 2013 4:46 am | ||||||||
Vladimir Golovin
Administrator |
Yes, the alpha handling looks buggy, especially given the fact that the help states that "All four channels, including the alpha channel, are processed this way.". We'll look into this.
|
|||||||
Posted: December 30, 2013 5:59 am | ||||||||
Vladimir Golovin
Administrator |
Actually, I just checked the alpha-channel separately, and everything seems to be in order. I'm attaching the test filter. Open it in the editor and go through all operations: everything seems to work as expected.
AlphaTest.ffxml |
|||||||
Posted: December 30, 2013 6:13 am | ||||||||
Vladimir Golovin
Administrator |
Let's see: Setup #1: A.Alpha = 1.0 B.Alpha = 1.0 THEN.Alpha = 1.0 ELSE.Alpha = 1.0 OP = A.Alpha < B.Alpha = 1.0 < 1.0 Expected result = ELSE.Alpha = 1.0 Factual result = 1.0 Setup #2: A.Alpha = 1.0 B.Alpha = 1.0 THEN.Alpha = 1.0 ELSE.Alpha = 0.0 OP = A.Alpha < B.Alpha = 1.0 < 1.0 Expected result = ELSE.Alpha = 0.0 Factual result = 0.0 Your picture shows the same results, for both cases. Perhaps you're missing the fact that the return of 1.0 < 1.0 is not true, it's false, and this holds for both cases, so the ELSE.Alpha is going to the output in both cases. When you change it from 1.0 to 0.0, the output just changes accordingly. |
|||||||
Posted: December 30, 2013 6:22 am | ||||||||
Zep Palen |
My point is that the IF component gets 2 different results of the same math.
it is like saying that 2 +2 = 4 only returns true sometimes. in the following code sample the code should always goto label a. Never to label b. And that is what my example is about. var q = white IF (2+2=4) then label a ELSE label b END |
|||||||
Posted: December 30, 2013 6:27 am | ||||||||
Vladimir Golovin
Administrator |
Which is expected, because the operation and both its operands (A.Alpha = 1.0 and B.Alpha = 1.0) are the same in both examples -- why should the execution branch be different? The only difference is ELSE.Alpha: 1.0 in the first example and 0.0 in the second one. |
|||||||
Posted: December 30, 2013 6:27 am | ||||||||
Vladimir Golovin
Administrator |
Zep, the correct pseudocode for your examples is this:
Edit: corrected an obvious error. |
|||||||
Posted: December 30, 2013 6:33 am | ||||||||
Zep Palen |
It still doesn't make sense to me. At least not the way the component and its input parameters are named.
The way I see your explaination is that I should read it something like: function iffy(THEN, ELSE) if (SourceA<SourceB) then return truth else return falsehood end function If that is the case the component and its parameters namings are "slightly" misleading ![]() It is kind of turning IF...THEN....ELSE upside Down. |
|||||||
Posted: December 30, 2013 7:01 am | ||||||||
Vladimir Golovin
Administrator |
I'd rather say
(you can't use THEN and ELSE as argument names, they are reserved keywords.)
What naming and parametrization would you suggest? |
|||||||
Posted: December 30, 2013 7:08 am | ||||||||
Zep Palen |
I am aware of that. I was just showing that you would enter the values fr om your "THEN" and "ELSE" inputs there.
I have no idea because I don't think I understand the purpose of the component. It just doesn't make sense with the visual design as IF..THEN..ELSE I would also expect this component to output only what is in THEN or ELSE, but I can reproduce situations where it outputs the Sources instead. It seems extremely illogical. |
|||||||
Posted: December 30, 2013 7:33 am | ||||||||
Zep Palen | ||||||||
Posted: December 30, 2013 7:40 am | ||||||||
Vladimir Golovin
Administrator |
Sources (or, more precisely, their RGBA channels) don't leak into the output. For example, if you use R and G channels in Sources, but only B and Alpha in THEN and ELSE, you'll never see any red or green in the output.
Did you read the help for the IF component? http://filterforge.com/more/help/Comp...th/If.html And this article? http://filterforge.com/more/help/Misc...sWork.html Pay attention to this part (emphasis mine):
Channel-wise. Not bit-wise, as you presumed in the original post. There are no bits in Filter Forge, because it doesn't make sense to handle double-precision floating point numbers as binary numbers. |
|||||||
Posted: December 30, 2013 7:42 am | ||||||||
Zep Palen |
I read the articles and help before creating this thread, but it still doesnt make sense.
But lets leave this by it. We will probably never agree on the interpretation of logics here anyway. |
|||||||
Posted: December 30, 2013 8:01 am | ||||||||
Vladimir Golovin
Administrator |
OK. I'll just give you a hint on how to get the results you expect. In order to get TRUE and FALSE color to the output in their original form, you must convert both colors you want to compare to grayscale before feeding them into SourceA and SourceB. There are multiple methods of grayscaling (which in your case means different "color comparison functions"), but you can just go with the default settings of the Desaturate component. Here's an example:
Color Comparison.ffxml |
|||||||
Posted: December 30, 2013 8:11 am | ||||||||
Skybase
![]() |
Umm... hi. Maybe this might be a bit helpful. I'm hoping I read what the problem was exactly, it's a bit hard following up on a conversation. So sorry if didn't contribute. The screenshot shows what the if component would be doing for each channel. The blend node simply generates a color, where each color is broken into R, G, and B channels (example doesn't show alpha but the same thing happens). In this case the operation is A < B. For each channel, if A is < B then it'll output 1 (or white). ![]() |
|||||||
Posted: December 30, 2013 9:39 am | ||||||||
Skybase
![]() |
Here's the example filter. Let me know if this helped explain something. If it didn't or I missed the point of it all... sorry
![]() If - Channelwise.ffxml |
|||||||
Posted: December 30, 2013 9:42 am | ||||||||
Zep Palen |
Yes I already figured out how it Works and also see that it can probably not Work different with channel wise processing. It is just not the way most would expect it to Work.
Especielle the outputs can be confusing because many will see this as a bug since they (and I) will not think about that the output can be a pixel put together from rgba values from both THEN and ELSE. I DO see the logic in that now after reproducing this component with a LUA script) Maybe there should be an option on the component to compare on color integer values per pixel rather than channelwise. |
|||||||
Posted: December 30, 2013 10:01 am | ||||||||
Vladimir Golovin
Administrator |
Zep, I'm glad to hear that you've figured this out. Plus now we have a thread that can serve as a definitive guide for dispelling any IF-related confusion.
You're probably talking about comparing colors as-a-whole, not channelwise. The thing is, there are multiple methods of converting three RGB channels into a single value for comparison, plus you have to factor in the alpha channel somehow. The problem is that this may be confusing, and on the plus side you are free to implement your own 'color value function'. Anyway, here's my version of simplified IF that implements non-channelwise comparison, which is based on my example above, packaged into a group: Simple IF.ffxml |
|||||||
Posted: December 30, 2013 10:47 am | ||||||||
Zep Palen |
Thank you.
Yes I mean color values. Not ARGB values. I made a LUA script for this. The Alpha should not be an issue. Add it as the most significant value and then thats it. In addition just make an option to disregard Alpha values in the sources and it Works. This leads to a wish of some features added to a future version of FF like creating enum input controls. |
|||||||
Posted: December 30, 2013 11:04 am |
Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!
33,711 Registered Users
+18 new in 30 days!
153,531 Posts
+39 new in 30 days!
15,347 Topics
+72 new in year!
17 unregistered users.