YOUR ACCOUNT

Login or Register to post new topics or replies
hexagonstar
Posts: 47
Filters: 18
Was wondering if somebody knows a workaround for this (if it's even possible) ...

Let's say you have a group of components in your filter that do a rather CPU-costly operation and the outcome of that filter part is controlled by a slider 0 - 100.
To disable that filter part you could add an additional Switch comp with a checkbox to circumvent it but instead of adding another control to the filter wouldn't it be more elegant if the filter automatically circumvents the CPU-costly filter part if the user sets the slider to 0?
  Details E-Mail
Totte
Übernerd

Posts: 1460
Filters: 107
You could use Lua and write your own Switch or base it on my Megaswitch to do that. Just use the other input if the value is zero.
- I never expected the Spanish inquisition
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Or use a threshold - you might need to hook up your slider to Assemble RGB first to get connection compatibility to the Source input (for some reason FF requires map source here.. makes no sense though)

Check out this article on optimization with thresholds: Clipping

@Totte: I think using a script for this will be slower than the above, even though you can make the actual script very small and simple. This is because the script component alone is somewhat slow itself (even if the script is as simple as "return 1,1,1,1" and no more). Hopefully we will see performance optimizations for this in the future smile:)
  Details E-Mail
hexagonstar
Posts: 47
Filters: 18
Ok, script is the way to go then for this! I had a look at your script and adapted it to switch between two inputs depending whether the provided value is zero or non-zero.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Alright, I just compared a script solution with a threshold solution. Even though the threshold solution theoretically involves more calculations, it is way faster. See attached filter.

I hope FF will be able to reduce the baseline overhead of using the script component.

switching test.ffxml
  Details E-Mail
hexagonstar
Posts: 47
Filters: 18
Hey Sphinx, saw your reply a bit too late. In your test filter the non-script version renders ~0.04 - 0.05 seconds faster. I guess it makes sense to use a threshold depending on the situation. I went with a very simple script now because I'm just using it to bypass some components. When a value is at zero the filter still renders noticeably faster as when not.

Here's my script example...

Zero Value Switch.ffxml
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Ok, I guess my old number crusher here show a bigger difference smile:-D

About your script - you check the slider status for all samples rendered. That is really not necessary:

function prepare()
value = get_slider_input(VALUE)
if (value == 0) then
inp = INPUT1
else
inp = INPUT2
end
end;

function get_sample(x, y)
return get_sample_map(x, y, inp)
end;

(I basically just moved the check to prepare instead of get_sample, see this for more info: Where to put the script parts)
  Details E-Mail
hexagonstar
Posts: 47
Filters: 18
Dooh, you're completely right Sphinx! The condition shouldn't be evaluated on every sample (pixel even?). Thanks for the hint!
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12299
Filters: 35


I do not understand anything smile:D but seems interesting
  Details E-Mail
Morgantao
Can't script

Posts: 2185
Filters: 20
Have to agree with SpaceRay, 100% interesting, 0% I get... smile:D
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12299
Filters: 35
Now I went back to this and now understand it more than before, but although this works and you can disable parts of a filter, it will not disable any control attached to the disabled part, so all the controls linked to any of the controls will appear in settings tab, even if it belongs to a disabled part.
  Details E-Mail

Join Our Community!

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

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

153,534 Posts
+31 new in 30 days!

15,348 Topics
+72 new in year!

Create an Account

Online Users Last minute:

9 unregistered users.