Cells for the masses
Moderator: Moderators
Cells for the masses
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 28696 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=-
-=Hugo Rossi=-
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
nice good to see you working on the source
to make these Voronoy Cells really usefull, perhaps you can add some different drawing styles;
shaded to edge OR shaded to centers,
and with or without random color offset by cell,.
I suppose it should take two colors for the shading as well,. .
here its middle gray and black.
to make these Voronoy Cells really usefull, perhaps you can add some different drawing styles;
shaded to edge OR shaded to centers,
and with or without random color offset by cell,.
I suppose it should take two colors for the shading as well,. .
here its middle gray and black.
- Attachments
-
- some draw styles,. .
- cells_styles.jpg (19.38 KiB) Viewed 28688 times
iterationGAMES.com
I got the source from kattle.
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?
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
Bye bye guys! See you soon
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
Bye bye guys! See you soon
- Attachments
-
- Desktop.zip
- Read the TXT and open the PNG only when you are requested to do so! :P
- (2.85 KiB) Downloaded 1047 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=-
-=Hugo Rossi=-
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
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.
Code then becomes this:
I've checked this in together with a update to zlog-unit for the new timer code.
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.
Code then becomes this:
Code: Select all
Dist := MinVal(Dist, (I-CP[K].Y)*(I-CP[K].Y) + (J-CP[K].X)*(J-CP[K].X));
Dist := MinVal(Dist, (J+W-CP[K].X)*(J+W-CP[K].X) + (I-CP[K].Y)*(I-CP[K].Y));
Dist := MinVal(Dist, (J-W-CP[K].X)*(J-W-CP[K].X) + (I-CP[K].Y)*(I-CP[K].Y));
Dist := MinVal(Dist, (J-CP[K].X)*(J-CP[K].X) + (I+H-CP[K].Y)*(I+H-CP[K].Y));
Dist := MinVal(Dist, (J-CP[K].X)*(J-CP[K].X) + (I-H-CP[K].Y)*(I-H-CP[K].Y));
Dist := MinVal(Dist, (J+W-CP[K].X)*(J+W-CP[K].X) + (I+H-CP[K].Y)*(I+H-CP[K].Y));
Dist := MinVal(Dist, (J+W-CP[K].X)*(J+W-CP[K].X) + (I-H-CP[K].Y)*(I-H-CP[K].Y));
Dist := MinVal(Dist, (J-W-CP[K].X)*(J-W-CP[K].X) + (I+H-CP[K].Y)*(I+H-CP[K].Y));
Dist := MinVal(Dist, (J-W-CP[K].X)*(J-W-CP[K].X) + (I-H-CP[K].Y)*(I-H-CP[K].Y));
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!
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=-
-=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!
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!!!) =)
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 28638 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=-
-=Hugo Rossi=-
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
I will name your babies!
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?
That does look 'freakin' nice'!
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?
That does look 'freakin' nice'!
iterationGAMES.com
Latest code from Kattle is checked in.
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.
Personal wish: Can we have the cool styles that are described here http://www.blackpawn.com/texts/cellular/default.html ?
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.
Personal wish: Can we have the cool styles that are described here http://www.blackpawn.com/texts/cellular/default.html ?
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=-
-=Hugo Rossi=-
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
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.
any ideas, can it be done? A repeatable noise without loosing the randomness.
- Attachments
-
- perlin_tile_Q.zgeproj
- fun to mess with this stuff,.
- (1.11 KiB) Downloaded 976 times
iterationGAMES.com