YOUR ACCOUNT

Login or Register to post new topics or replies
scriptorum
Fella

Posts: 35
Filters: 7
I'm having trouble getting the IF component to produce expected results when colors are involved. Specifically, colors other than the THEN and other than the ELSE are showing up in the result.

The attached example shows some color bands fed into SOURCE A and the color purple (1, 0, 1, 1) fed into SOURCE B. It successfully turns the purple area into the grey specified by THEN, however, the non-purples are turned into a strange mix of SOURCE A, THEN and ELSE rather than just the ELSE color.

If you alter the gradient to use only grey colors and change SOURCE B to a matching grey, the IF works as expected -- for the most part. However, even in this case, the alpha on the ELSE will be ignored, and the alpha on the THEN will affect the alpha of the whole output, not just the matching color.

  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Initially I also thought that was a bug, but actually..
Quote
The If component performs the channel-wise conditional operation on the colors supplied by the Source A and Source B inputs. The alpha channel is not processed in a channel-wise manner – the resulting alpha channel is taken from the Source A input.

.. help
  Details E-Mail
scriptorum
Fella

Posts: 35
Filters: 7
Ah, thanks for the clarification. Although I can see some uses for the IF component as it is implemented, I think one that worked the way we both expected would be more useful. It would be nice if there was a checkbox to allow us to use either behavior. This seems like an easy Map Script to whip up.
  Details E-Mail
scriptorum
Fella

Posts: 35
Filters: 7
Here is a map script performing the per-pixel behavior I was expecting from the RGB Math: IF component. If SOURCE A and SOURCE B have the same color pixel, it outputs THEN otherwise it outputs ELSE. It does this on the whole pixel color, not per-channel. Alpha channels are implemented. It only supports an A = B operation, but that is easily modifiable in the code.

Quote
function prepare()
end;

function get_sample(x, y)
local r1, g1, b1, a1 = get_sample_map(x, y, SOURCE_A)
local r2, g2, b2, a2 = get_sample_map(x, y, SOURCE_B)
local r, g, b, a

if r1 == r2 and g1 == g2 and b1 == b2 and a1 == a2 then
r, g, b, a = get_sample_map(x, y, THEN)
else
r, g, b, a = get_sample_map(x, y, ELSE)
end

return r, g, b, a
end;


Per-Color IF Component.ffxml
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,713 Registered Users
+19 new in 30 days!

153,537 Posts
+6 new in 7 days!

15,348 Topics
+72 new in year!

Create an Account

Online Users Last minute:

27 unregistered users.