YOUR ACCOUNT

ThreeDee
Lost in Space

Posts: 1672
Filters: 112
The Script basically does a Lookup of the value from point (x,y) from source image with the intent of doing so once for every loop.

However, when the accumulated is Blended with the new loop result with Darken mode, the Blend does something funky, it outputs as if both branches inside the loop had been put through the same Tone Curve although only one of them has been.

(This can be seen first at iteration 4 with this varioation setting.)

If you switch the foreground and background inputs, the Blend now appears like NEITHER of the branches was put through the Tone Curve.

Unless I've inadvertently used some internal reserved variable in the script, I can't figure out what might cause this. Changing variable names didn't seem to change anything.

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
The filter in question.

Non-overlapping Circles.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
It also crashes if I try to change the Script identifier for Script Component "Y" input, on pressing OK in Input editor after changing name.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Replacing the Script with Lookup works correctly (but awfully slowly).

Non-overlapping Circles 2.ffxml
  Details E-Mail
Dave S

Posts: 23
Filters: 1
ThreeDee, a question if I may... that section in the filter with the lookup, subtract and linear that feed into the curve in the ToneCurve... is that intended to make the new circles smaller if they end up close to existing circles?

Dave.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Indeed yes, to make the circles non-overlapping. So if they are too close, the radius is decreased.
  Details E-Mail
Dave S

Posts: 23
Filters: 1
Great example. Learned some nice looping stuff from it. One of these days, I'll actually feel like I know what's up in FF. You guys, keep posting these nice examples, they are great to learn from.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Hmm.. I experienced some strange things similar to this myself, but its not like we're getting a crash or anything..

What happens if you use the faster alternative Min from the RGB Math category?
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Quote
What happens if you use the faster alternative Min from the RGB Math category?


I get the same problem but the inputs "switched", Source A works like Background, Source B like Foreground.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
It could be the same problem as I have in the Julia filter (take a look at the one I posted in the beta gallery thread) - I can't use the Iteration slave node as it seems to stick at the max iteration value during the real rendering. I'll see if I can make a simple bug example.

You can try my temporary solution from the Julia filter. I basically just use one of the channels to keep track of the iteration (initialize with the value 0 and then add 1 in each iteration)

Btw, not sure it is related to what you're doing, but here is an ultra simple loop based cells

Cells (Loop).ffxml
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
What happens if you only run FF on 1 core / single threaded?
  Details E-Mail
Vladimir Golovin
Administrator
Posts: 3446
Filters: 55
ThreeDee, I'm trying to understand the bug you posted in the original post. I took a screenshot of Tone Curve and Accumulated and tried to blend them via Darken in Photoshop. This is what I got -- is this what you expected from the Blend in question?

(I also tried to replicate Darken with Min, and they look identical, just as they should.)

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Quote
What happens if you only run FF on 1 core / single threaded?


Nothing different.

The problem SEEMS very simple:

I'm trying to make non-overlapping circles with a loop. I just need to sample one point of the accumulated image (the center point of the next circle to be placed) and use it to determine the radius of the next circle. But just adding this one branch of coordinate sampling (which I have to do with Lookup in order it to work) makes the filter grind to a halt after about 7 iterations.

The script attempts to overcome that by sampling the same exact point when the iteration count changes. However, then I am met with this new problem which seems to relate to loop sample caching that makes the Accumulator result not work as expected.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Quote
I took a screenshot of Tone Curve and Accumulated and tried to blend them via Darken in Photoshop. This is what I got -- is this what you expected from the Blend in question?


Hi Vlad. Yes, exactly. That is what it is supposed to look like. Only ONE branch goes through the Tone Curve but the result is as if BOTH branches went through it.

You get the right result if you replace the Script with Lookup with the same X and Y inputs (The "Step" input is not needed for Lookup, it just checks whether a new loop iteration has been entered).
  Details E-Mail
Vladimir Golovin
Administrator
Posts: 3446
Filters: 55
ThreeDee, speaking of the filter you posted in the first post, could you try to remove as much stuff as possible while retaining the bug?

(This looks similar to http://www.filterforge.com/forum/read...age118756).
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Yes, it appears similar -- although there is no Grouping involved here, rather a Script.

This is the simplest I can make it. If you go to Iteration 3 of the Accumulated, you can see that in the Blend the Radius of the Free Polygon (or Ellipse) is funky, it is unaffected by the Script result, although the Free Polygon itself is affected by it ... smile:?:

Again, if you connect the Lookup instead of the Script, all is well.

Script Loop Bug.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Looks like this:

  Details E-Mail
Vladimir Golovin
Administrator
Posts: 3446
Filters: 55
Here's my attempt at reproducing a stripped-down version of the "bug". When you adjust the Gamma slider, all ellipses change, as if they all have been processed by the gamma -- which is precisely what's going on! Every single ellipse that went through the Loop was indeed processed by the same Gamma curve, and that's why they all change when you adjust Gamma.

Is this example comparable to your case?

All_As_One.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
No. Let me try and make another one.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Hmm.. I think there is a problem with the Script configuration: it should have HDR enabled on the inputs (at least on the step input). The lack of HDR support will result in the same lookup value, the same tone curve settings and hence the similar tone adjustment.

Btw I encountered a bug related to this HDR change..
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Here's where the bug comes in:

All_As_One_Script_Bug.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
The same Gamma is added to the Accumulated output before (or during) Blending. The Accumulated clearly doesn't have the Gamma applied, only the branch that goes through the Script.

  Details E-Mail
Vladimir Golovin
Administrator
Posts: 3446
Filters: 55
Quote
No. Let me try and make another one.


ThreeDee, could you try to reproduce it without the script?
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Guys.. disconnect the script, enable HDR on the step input and reconnect
  Details E-Mail
Vladimir Golovin
Administrator
Posts: 3446
Filters: 55
This is what I see after enabling HDR. Looks correct. ThreeDee?

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Well, I'll be damned. That was the problem! Never noticed that little checkbox on the inputs, only the "can output HDR" option.... smile:blush:

My only remaining question then is: Why on Earth is it still so slow? Can I make some sort of "initialize trick" for the Script for every beginning loop to speed this up? Looking up one additional sample per loop should not slow things down this much.
  Details E-Mail
GMM
Moderator
Filter Forge, Inc
Posts: 3491
(A sidenote: a bug point goes to ThreeDee for crashing the Input Editor)
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
You're not alone .. that default setting has fooled me so many times now. I really wish the default setting was the other way around, i.e. HDR enabled by default - that would allow both HDR and non HDR pipelines.

About the speed - from what I see you're branching x2 in each iteration. The cache you implement is not really working because (I think) each iteration has its own scope, so you can't cache v across iterations.. is that right Vlad?

Btw. there was a mistake in my old Julia sample cache, I fixed that and added an even smarter approach to the cache setup. There might be something for inspiration smile:-)

Native Julia Set (1).ffxml
  Details E-Mail
Vladimir Golovin
Administrator
Posts: 3446
Filters: 55
Quote
About the speed - from what I see you're branching x2 in each iteration. The cache you implement is not really working because (I think) each iteration has its own scope, so you can't cache v across iterations.. is that right Vlad?


If the samples hit Accumulated at different coordinates, then the cache won't help at all and you'll get an exponential recursion.

If the samples hit Accumulated at the same coordinates, it's a matter of dumb luck. The cache may work for some arrangements or components, but for others it won't. We'll need to refactor all components to get that in order.
  Details E-Mail
Vladimir Golovin
Administrator
Posts: 3446
Filters: 55
Quote
It also crashes if I try to change the Script identifier for Script Component "Y" input, on pressing OK in Input editor after changing name.


We've fixed that, to be released in the next hotfix.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Would it be possible to initialize, that is to run the Prepare function newly for each loop? As far as I can tell, it is only run once, for the first loop iteration. Otherwise it would be very simple to construct a Script that picked the value of a single point fr om an image (once for each iteration).

If I do that now, pick the value and then use the initialization trick to output the same initial value, it is retained through all iterations. My script tried to overcome that lim itation, but I've had no success in making it work any faster.

Maybe I'm missing something basic, but I really don't seem to be able to make it happen.
  Details E-Mail
Vladimir Golovin
Administrator
Posts: 3446
Filters: 55
Quote
Would it be possible to initialize, that is to run the Prepare function newly for each loop? As far as I can tell, it is only run once, for the first loop iteration.


The Prepare() function runs once, before the rendering (i.e. the sampling process).

Quote
Otherwise it would be very simple to construct a Script that picked the value of a single point from an image (once for each iteration).


Shouldn't this code be placed into script's GetSample() then?
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Yes, that's what I tried. This script gives me the value of the image for point (X,Y) that is different for each step. I have to use the STEP (which gets it input from Loop Iteration) to detect a new iteration value.

Even if I sample the same exact point (.5,.5), there is no speed gain.


Code
function prepare()
   current_iter = 0
   v = 0
end;

function get_sample(x, y)
   iter_value = get_sample_grayscale(.5, .5, STEP)
      if (iter_value ~=current_iter) then
         local x1 = get_sample_grayscale(.5, .5, X)
         local y1 = get_sample_grayscale(.5, .5, Y)
         v = get_sample_grayscale(x1, y1, SOURCE)
         current_iter = iter_value
      end
   return v,v,v, 1
end;


This is why I asked if there could be built-in a Unit component that did this sort of thing. Almost all of my loop attempts fail on this one issue, and become "exponentially recursive" (in quotes, as they really aren't). Picking one sample should not be slow.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Ah, I recall the annoying change to the scripting engine that was introduced to "fix" multi-threading issues: Each rendering tile (the small incremental blocks we see during rendering) has its own scripting scope.

This means that even with a single lookup based on a fixed coordinate, the cache script will be initialized blockCount^2 times. That is 64 for the default resolution. This means that we essentially can think of this as a forced non cached 8x8 pixel rendering. Taking the branching at 10 iterations into consideration that ends up being (8 * (2^10))^2 or 8192x8192 samples just to cover the render tile "resolution", i.e. the initialization of render tile scripting scopes. smile:cry:

This is just speculation of course - it would be nice if Vlad or Egret could shed some light on this.
  Details E-Mail
Vladimir Golovin
Administrator
Posts: 3446
Filters: 55
Quote
Each rendering tile (the small incremental blocks we see during rendering) has its own scripting scope.


Yes, this is correct.
  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,533 Posts
+38 new in 30 days!

15,348 Topics
+73 new in year!

Create an Account

Online Users Last minute:

33 unregistered users.

Recent Forum Posts: