YOUR ACCOUNT

Messages 46 - 90 of 94
First | Prev. | 1 2 3 | Next | Last 
Login or Register to post new topics or replies
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Seems to be going in that direction. Meanwhile, here's the next step on the tree. now I seriously have to optimize the path drawing function, for it takes longer this way than without scripting!

  Details E-Mail
xirja
Idididoll Forcabbage

Posts: 1698
Filters: 8
Oh dear, molasses. I was hoping you were on some old machine. As soon as 'BitMap Buffer' and 'Table Memory Limit' are feasible, then matrix math can be used and then no more 'while' function to step through right?
_____________________________________________________

http://web.archive.org/web/2021062908...rjadesign/
_____________________________________________________
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Well, yes. But first, I have a different issue to deal with, which is that the script does the full math to calculate the distance of every line segment at each point. If I first check whether the current point is within the bounding box of the path segment (including line weight) and skip those that aren't, I should be able to speed up the process considerably.
  Details E-Mail
CFandM
ForgeSmith

Posts: 4761
Filters: 266
Some Great work ThreeDee.. smile:)
Stupid things happen to computers for stupid reasons at stupid times!
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
ThreeDee... FYI:
http://blog.gludion.com/2009/08/dista...curve.html

Btw. I have a 570% faster version of your sine-o-graph running now smile:-) I will publish when ready
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12298
Filters: 35
Quote
Sphinx wrote:
I have a 570% faster version of your sine-o-graph running now I will publish when ready


WOW! this is really a good optimization and good news.
Thanks very much.
  Details E-Mail
Morgantao
Can't script

Posts: 2185
Filters: 20
Mah... Less than 600% is not that fast smile:D
Very nice Sphinx. Is the faster filter done only by optimizing the LUA script, or is there anything else?
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Yes its all in the script. I use several optimization tricks. I will publish later on
  Details E-Mail
Morgantao
Can't script

Posts: 2185
Filters: 20
Actually, if it's all in the script, I won't see the difference...
It's like you'd tell me that now the script is in Cantonese instead of Mandarin smile:D
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12298
Filters: 35
Quote
Morgantao wrote:

Actually, if it's all in the script, I won't see the difference...
It's like you'd tell me that now the script is in Cantonese instead of Mandarin


Exactly the same for me smile:D

BUT I do not care, at least I can use this without knowing how it works.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Quote
ThreeDee... FYI:
http://blog.gludion.com/2009/08/dista...curve.html

Btw. I have a 570% faster version of your sine-o-graph running now smile:-) I will publish when ready


Hi Sphinx,

Filter Optimizer in action!

There are definitely many ways of optimizing it, starting from scripting the sine inputs as slider inputs into the script rather than reading the grayscale images. Although I do like visually seeing (in the Editor) the corrspondence between the input and the result.

And of course the path drawing function as described earlier.

Did you figure out additional ways to optimize it?

Yes, I read that article recently -- although not the linked "solution to 3rd degree equation" that was in French -- and was considering the option of using quadratic curves (rather than cubic) for some future auto-bezier type path drawing filters. Did you already manage to script that solution with lua?

TD
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Actually I posted that link before looking into the actionscript implementation. Just a brief look reveals a very expensive implementation - not suitable to run W*H*Points time..

About the optimizations: I still use the map input, but I use the initialization trick to fetch the points needed for the overall rendering. When you have the points, you can do various precalculations also. The initialization trick used to be even more efficient, but changes in the scripting engine made it slower (now it initializes for each block in each thread, not just once). It is still better than fetching all the points for each sample.

I then made sure that the use of all these expensive math functions were limited to an absolute minimum. Stuff like math.sqrt inside a loop is something you want to avoid. And the algorithm were simplified a bit.. I applied several other optimization tricks - most described in this article:
http://filterforge.com/wiki/index.php...and_Tricks

The attached version renders in 32 sec (vs 7 mins 33 sec original)

Note that it is WIP - I'm currently working on some sort of z input (or scale input) so the gradient might not be 100% identical to your original

Sine-O-Graph One - Sphinxmorphed.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Geez, this is pretty pro programming -- you've definitely read your lua manuals. I had no idea you could do many of these things with this language.

Apart from the overall neatness of the code, I like how you got the minimum distance and took the square root only at the end.

I'll definitely incorporate the improvement into my other attempts along this line.

Thanks!

TD
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Ok, now that I've read the code line by line, I have to admit, I'm not sure I follow it everywhere. As far as I can tell, you are calculating the squared distance first and using it to determine which segment is closest. I'm not sure what you are using the variable "r" for, or the reciprocal of the squared distance for that matter. Is it needed because were in the range of 0 to 1 or more directly in the distance calculation?

At least I can't picture it all in my head. Perhaps I should graph it out.

I get that the az is not really used as yet. I imagine you could use it for either z depth of for variable line weight.

TD
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Now, you're using a rather large table here. I was scared off table usage by the "table memory limit" thread. Is there a safe upper limit to a table size you can recommend?
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
That flash implementation of distance to a quadratic bezier curve is, by the way, wrong -- it doesn't find the closest point, just the closest point that is at 90 degree angle fr om the curve segment, which becomes rapidly apparent when you test it with the included flash app.

For instance, it gives the below solution, wh ere the yellow dot on the curve is supposedly the point on the curve that is closest to the red circled dot.

  Details E-Mail
xirja
Idididoll Forcabbage

Posts: 1698
Filters: 8
Wow, nice to see voronoi here. What the two of you can do with this one, I'm excited!
_____________________________________________________

http://web.archive.org/web/2021062908...rjadesign/
_____________________________________________________
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Heh, yeah the downside of the optimization is that the script is a lot harder to read.
Variable r is simply used to determine the segment length: if inside 0..1 range we're between a and b (I think you used a similar approach?). Actually the ramp btwn a and b (the value of r) could be useful as an additional output.

About the table: no that one is not big - its only a 1D table with up to 1000 entries. The table size debate is about w*h sized tables :-S I can't say what is the recommended size limit. I'd keep an eye on the memory usage and performance and then as a general rule of thumb: as long as you're dealing with 1D arrays with a few variables per entry, don't worry about the size.

The reciprocal variable is simply to avoid expensive divisions inside main inner loops, i.e. use a*(1/x) instead of a/x, where 1/x is precalculated.

Btw. check out this script http://forums.codeguru.com/showthread.php?t=194400 I used it as reference implementation, and it is not "ruined" by too many optimizations.

About the bezier stuff.. yeah its no good. I'm afraid there is no continuous solution and we need to generate the whole point series and check one by one. Bye bye performance...
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Yeah, I know. I can rarely even understand my own scripts coming back to them after a few months. And as to optimization... let's say I have plenty of room for improvement there.

It is definitely good to have a few solutions to compare. Actually it could be a fun and useful optimization challenge to come up with a certain bezier-curve related objective and challenge all resident scripters to come up with the fastest implementation.

How about a challenge for the best optimized cubic bezier curve with variable line weight and variable quality setting (flatness value, i.e. number of line segments that make up the curve)? For proper comparison we would also need a reference set of values for the four points, the line weight and quality setting (number of line segments).

TD
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Here's another thought I woke up with this morning. What if we approximated the bezier curve with arc segments instead of straight lines? It is not much more calculation, but we would get very smooth curves at low quality settings. Even 8 segments would give a very nice result if they were done as arcs instead of lines.

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
In my estimate this would require calculating three lines for each point pair: the normals for the two points (call these A and B) and a line (call it C) that was equidistant from the two points. The center of the circle would have to be on line C, and a good solution for its location would probably be the average of the crossing points of (A and C) and (B and C). What do you think?

The largest deviation from the actual bezier path would be at the sharpest turns which would be somewhat rounded off.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Interesting idea - That could greatly limit the number of points needed to inspect.

As you say we would get an infinite number of possible center points on the perpendicular bisector, but with three points from the bezier segment it might be possible. I.e. instead of finding circle center C from A,B, we find circle center D from A,B,C (circumcircle of a triangle, http://local.wasp.uwa.edu.au/~pbourke...clefrom3/).

Since the bezier path generation itself can take place in an initialization section, we don't have to worry too much about generating some extra points..

Right now I'm a bit worried about what comes after... i.e. how to get a continuous line rendering from the circle distances
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12298
Filters: 35
what happened to this ?

Is there any further development and possible examples?

I am not personally interest in this myself as I do not understand it and can´t use it, but I think that anyway is interesting and cool to see about this and what can be done
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Real bezier in polynomial time smile:D

Render time under one minute. It's a beautiful day!

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Here's the filter (or Script, really). It runs relatively fast, but if anyone comes up with optimization ideas, they are welcome.

Bezier Draw Scrippet 5.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Next two challenges:

1) Filled shape

2) Helper application for Bezier curve input so that it is possible for humans to input the anchor and control points
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
smile:bunny:

No significant increase in render time.

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Oh boy, this might become exciting! How about making a vector drawing with variable line weight? Or animating the bezier anchor and control points randomly over time?

Here's the filled-shape version you can play with.

Bezier Draw Scrippet 6.ffxml
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
The optimization scheme for this kind of stuff is rather complex, but I can try to explain the concept (and probably fail too smile:-D).

Imagine you cut the minimum area of the path into two equal parts (i.e. "split the image in two") - then the segments either belong to one half, the other or both. The sample you are about to render belongs to one half or the other too. You only need to pay attention to segments belonging to that half or belonging to both.

This "simple" measure should effectively cut down render time about 50%.

Now instead of halfs, go for quaters etc.. and at some point it becomes reasonable to stop sub dividing, or rather: you will start to introduce rendering overhead again, because the optimization scheme itself costs.

And this is the basic concept - and it is too good to be true of course: when a segment in the other "half" is closer than the ones in the current half. To get around that, you need to think in cells instead, and inspect the neighbour cells too.
  Details E-Mail
SpaceRay
SpaceRay

Posts: 12298
Filters: 35
Quote
ThreeDee

Here's the filled-shape version you can play with.


Amazing work, and what I like much more is the showing of the bezier control points!

And as they show in a light and soft way, I have made rendered it in FF and then after went to Photoshop and used the "Shadows & Highlights" tools increasing the highlights about 90% and then all the control points appear sharp and defined smile:)

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Quote
Sphinx wrote: The optimization scheme for this kind of stuff....


Ok, I see, that makes sense. A slight issue is that my shape-filling algorithm is based on even-odd number of paths crossed over from the left edge. Maybe I can still devide the image area into horizontal slices, so I can retain the fill.

What I need to do then is to split the original tables into tables for the individual image slices and select based on y-coordinate which slice tables to use. Just need to make sure that any and all elements I want to render are included in the respective tables. It could definitely work.

I'll likely address the input issue first. While the script is not ideal, it is fast enough for now, the bigger issue is to be able to input something manually. Programmatically would a piece of cake now.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
SpaceRay, here's a new version where you can change the colors.

Bezier Draw Scrippet 6A.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
I accidentally found out that edges-only anti-aliasing works just fine in the last version, so you can turn that on for smoother output.

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
I submitted that version to the library as well under the name Random Bezier Curve, will be easier to find there. Besides, the library is a pretty good place to back up filters -- would have lost many of them over the years had I not had them there. smile:D

  Details E-Mail
SpaceRay
SpaceRay

Posts: 12298
Filters: 35
The filter is already available in the library

Random Bezier Curve by Threedee

Thanks really very much for making this, and for sharing it in the library, I love it.
  Details E-Mail
xirja
Idididoll Forcabbage

Posts: 1698
Filters: 8
Quote
Render time under one minute. It's a beautiful day!


Truly! ...and with that filling method, ya man! smile:)

Quote
the library is a pretty good place to back up filters -- would have lost many of them over the years had I not had them there.


Aha, so that's what the lightning in your Avatar is all about. Damn EMP zappers!
_____________________________________________________

http://web.archive.org/web/2021062908...rjadesign/
_____________________________________________________
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Yes, the FF library is the one thing I never remember to back up, so I manage to lose it about once a year with hardware upgrades and other blowups.

Here's variable line weight implementation. That's something slightly different from your run-off-the-mill bezier curves. Unfortunately, the crappiness of my line drawing method is starting to manifest, so I should probably fix that. Sphinx gave a better method for this with his optimized version for Sine-O-Graph which should do the trick.

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
An unsurprising development

  Details E-Mail
SpaceRay
SpaceRay

Posts: 12298
Filters: 35
Quote
ThreeDee
Here's variable line weight implementation. That's something slightly different from your run-off-the-mill bezier curves.


OH!! This is very good, original and unusual, instead of have all same line width would be good to have the option of variable lines and surely is something good and different.

Quote
ThreeDee
An unsurprising development


A beautiful and artistic development smile:)
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
It is insanely difficult to draw anything with it, but here I have used color inputs for position control. There are 30 color inputs (for 10 bezier anchors and 20 controls points) to get something like this. In other words, this shape was actually "drawn" with FF. (Which took about 15 minutes this way as opposed to about 15 seconds with Illustrator.)

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
After some deliberation and study, it turns out it would be possible to import SVG files into FF, either with an external helper application or possibly (haven't actually checked this out yet) with an unsafe LUA script. SVG files are XML files, which makes understanding the drawing instructions easy. It would still be quite some work to make an app that reads SVG and turns them into something FF (or an FF LUA Script) can use.

I don't know that I will pursue that route, but at least it is within possibilities.

I did attempt to make a Flash-based drawing app that would output the bezier points as FF bezier control points, that turned out to be quite a lot of work as well, so I don't know when and if it will ever be completed.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Oh yes, and one more idea to be investigated: An unsafe LUA script that saves the selected point information in an external file array of points. This way you would only need 3 color inputs (1 anchor, 2 control points), all points would be read from the external file into the filter each time the controls were moved and the current point would be changed and written to the external file (on checkbox selection, or some such action).

(That is, if LUA can read and write to the local file system.)
  Details E-Mail
Skybase
2D/3D Generalist

Posts: 4025
Filters: 76
haha... oh man you just won everything.
  Details E-Mail
Sharandra
Filter Forge Addict

Posts: 863
Filters: 26
Woah!!! smile:eek: Mind blown smile:D
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Inspired by Ken's image embedding Flower filter which demonstrated writing to the local file system quite nicely, I think I will build the Bezier Draw with an unsafe LUA script. It has been all worked out in theory, now I just have to program it.
  Details E-Mail

Messages 46 - 90 of 94
First | Prev. | 1 2 3 | Next | Last 

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:

18 unregistered users.