Voronoy cells as a component.
Still needs debugging and improvements (like choosing a random seed in the interface, and so on). But works at a reasonably good speed (about 1 sec for 512x512 pixels.
Sending the code to Ville ASAP.
Bye bye!
Attachments
CellsComponent.png (57.5 KiB) Viewed 29660 times
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
It looks good, it is fast and tileable. As jph suggest we should add more features to make it general-purpose but it is a very nice start!
I'd like to understand the algorithm so we can make it as general, compact and efficient as possible. Did you find some documentation on the web that you started with when writing this implementation? If so then let me know so that I can read it too. And can you please explain the meaning of values 0.33 and 0.66 in the inner-loop?
Attached a file containing a txt and a png for helping with comprehension of the code. I hope this will be usefull.
To JPH: yep that TG-like drawing will be one of the first things to get in place (pretty easy to do even if it seems not), plus you will get some "defaults" points placement (EG: honeycomb, quads, triangles, and so on). Maybe you will also get the possibility of choosing the central points
Read the TXT and open the PNG only when you are requested to do so! :P
(2.85 KiB) Downloaded 1061 times
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
I've made some small changes (just a little clean-up) to your code and checked in to Subversion. Please use that code as a base for further work as that makes it easier for me to integrate your additions.
I made another small change. From you explanation I understood that the IF-statements with 0.66 and 0.33 are an optimization to skip comparisons with centers.
I added a timer to check the difference. You can now read the time taken to calculate the cells in the log-window.
I came to the conclusion that the IF-statements actually ADD 5% cpu time. This is probably because a expression such as "(J > W*0.66-1)" mixes integers and floats and needs expensive conversion operators to execute. So it is faster to just make all comparisons without testing if they are needed.
this is somewhat strange =) but good news to know! When I used this optimization in the old "BitmapExpression" code that optimization was needed... I can tell you I feel that the same would be if I changed the code adding some other kind of optimization... so nevermind I won't try
Now I'm working on different "visual styles" for rendering. When I'm getting something ready, I will send you the code. Bye bye!
BTW: I do understand that integer operations are much more fast then floats&integers ones
Good news that the distance is calculated as an integer and not as a float!
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
Yes it is difficult to make general rules for optimizations, a technique that works in one environment may work in the opposite direction in another.
In this case it is probably that in ZGE array-lookups are much more expensive than in Delphi.
One thing that is cpu-expensive in all environments is mixing float and integer in the same expression, because this is a slow operation on Intel cpu:s.
Looking forward to those visual styles kattle! Thanks for contributing!
Update to the code.
Note this is probably going to change, but the main structure of the code is set, now I will try to add/get better effects.
JPH: I need your help! You must chose the names for the various styles that I will be able to create (I hate to just write down some lazy numbers!!!) =)
Attachments
CellsComponent.png (53.59 KiB) Viewed 29602 times
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
I just need a look at the styles,. is this in the source now? I should really have a crack at building from source, so I can tweek things a bit eventualy,. (was wundering about a few more base sound oscilators) however I am still madly working on Vectro Locust. (want to play along with the compo deadline, another week) Can you send me a build?
I made the following changes:
- property names, these must follow normal identifier-rules (no spaces etc.) so that they can be used inside z-scripting (i.e. "float x=cells.# of central points" won't work) and as attribute names in xml.
- dynamic arrays are nice but doesn't work in runtime-zge because they rely on compiler magic for automatic memory manangement, which takes up lots of exe-space. So I changed the implementation of the "Values" array to getmem/freemem style instead and saved a couple of kb. Unfortunately this broke the "border pixels" handling, but we can add that later again.
I'm going to bed now. What I can tell you, I almost have re-implemented the borders, and have had some good ideas for all the styles of the Black Pawn's Texture Generator styles, as well as for the ones that JPH showed me. I think we will end with 5 different styles. Note that one style in the Pawn's ones will not be implemented since it's a "Color = 1 - Color" formula
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
I can help with the border-pixels so don't work too hard on that, focus on the styles instead. 5 different styles sounds good. Send me the code whenever you have something but no rush.
looking forward to this,. got me wundering about tileable noise? I was hacking about and did a cheap mirroring trick to get this,. however it looses the noise and becomes just more wallpaper,. . however is usefull for some things,. .
any ideas, can it be done? A repeatable noise without loosing the randomness.