YOUR ACCOUNT

Login or Register to post new topics or replies
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
I have the loop set up to e.g. 20 iterations.
Let us say I find the result I want at iteration 5..

How do I most efficiently "exit" the loop so I don't waste time on another 15 iterations?

I know we can't do a real exit yet, so it has to be a creative solution smile;-)

Some process is repeated/looped. At any iteration the result of that process may be acceptable as result and the loop should "stop" and return that.

I have tried using the accumulated value in a threshold to check if the acc. value is good enough and if so bypass the process and use the accumulated value. But that is slow as hell.. as if the full process is always rendered smile:-(

HELP.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Here is a test filter on the described approach - I'm probably missing some cruel branching issue..

Loop Exit Test.ffxml
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
  Details E-Mail
Indigo Ray
Adam

Posts: 1442
Filters: 82
I don't think that test works. For every iteration, you call get_sample(Accumulated) once to check the threshold, and then certain pixels again for the High input. This is less efficient than not having the threshold check in the first place. For example, try replacing the threshold with a blend component. Now, Accumulated is called only once (for the Foreground input). The blend is faster.

Anyway, I don't have a creative solution, but feature request +1
I would like a sample-based (green) exit check, probably a slave component of the loop that looks something like the If component. That's how everyone renders those pretty Mandelbrot sets in other programs, right?
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12298
Filters: 35
Sorry that I can help on this, but I wonder if there could be possible in some way to make a LUA script that could manually add each iteration by pressing a key, so each time you press that key, another new iteration is added, until you get the result wanted, or instead of a key, a click from mouse button. Maybe I am telling a silly thing, as I do not if this would be possible
  Details E-Mail
Skybase
2D/3D Generalist

Posts: 4025
Filters: 76
I thought this was one of those requested features, especially not just for LUA script but for the internal loop component as well.

SR, there's no key input for the current LUA component. There's a numerical input however that can link to a iteration count.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Quote
Indigo Ray wrote:
I don't think that test works. For every iteration, you call get_sample(Accumulated) once to check the threshold, and then certain pixels again for the High input. This is less efficient than not having the threshold check in the first place. For example, try replacing the threshold with a blend component. Now, Accumulated is called only once (for the Foreground input). The blend is faster.


The whole point is to reuse the accumulated sample from previous iteration for the remaining iterations.

The Accumulated components initial value is an invalid one, forcing the Low input of the threshold to be called. When (and if) a value is produced that is above the threshold i.e. a valid sample, the high input, i.e. the accumulated value, will be returned. With that in mind, take a look at the filter or the attached image.

I'm starting to think something is broken with the loop or the threshold or the combination..

IIRC the blend will always fetch both background and foreground, regardless of the opacity setting (I have to retest this.. it was a long time ago I checked last). So this will not work. That it performs better compared to the threshold is because something weird, yet unexplained is going on - a nasty bug I fear.

  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Quote
SpaceRay wrote:
Sorry that I can help on this, but I wonder if there could be possible in some way to make a LUA script that could manually add each iteration by pressing a key, so each time you press that key, another new iteration is added, until you get the result wanted, or instead of a key, a click from mouse button. Maybe I am telling a silly thing, as I do not if this would be possible


Nah, we don't have that kind of flexibility (also it wouldn't be right for this problem). Using a script would work in some cases - the problem is that you can't have slaves with Script and the script itself is a slow fart from start (just using a blank script is equal to 10-15 lightweight standard components..)

Quote
Skybase wrote:
I thought this was one of those requested features, especially not just for LUA script but for the internal loop component as well.


Well, scripting exit conditions with loops is no problem at all - most of the fractal scripts that has been around do this ("bail out checks"). The problem is really that you can't make slaves with scripts.
  Details E-Mail

Join Our Community!

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
+36 new in 30 days!

15,347 Topics
+72 new in year!

Create an Account

Online Users Last minute:

21 unregistered users.