Cells for the masses

ZGE Source Code discussion. Ask questions, present your changes, propose patches etc.

Moderator: Moderators

kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

The noise in ZGE is already tileable... in the sense that you can make several different textures that will tile when they are applied let's say on different walls (think about the First person shooter demo, where the walls were the blocks). Since the perlin noise is a "continuous function" you can just use the perlin values of noise2(X,Y) for the first texture and then noise2(X+1,Y) for the second texture for getting two adiacent walls with a continuous noise along the X axis (you scale the noise by doing noise2(5*x,5*Y) for the first and noise2(5*(X+1),5*y) for the second, and so on).
But with the actual implementation you will always need several textures and several models I think...

BTW: I think this is a little off-topic ;) np of course ;)
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=-
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

I finally got the styles working properly. It was really easier than I thought, but I kept working with a wrong local variable instead of a global one, so I was getting strange results :/ It took me a lot to understand what was going wrong! :D
Attachments
Styles: first one inspired by werkkerzug, the other 3 are the Texture Generator ones
Styles: first one inspired by werkkerzug, the other 3 are the Texture Generator ones
Cells.jpg (74.92 KiB) Viewed 22890 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=-
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

WOW :shock: that is looking stellar! Can hardly wait to use this. yeah it is anoying when we over look a simple mistake and madly search for a reason that is right there all a long,. . but you got it in the end. cheers. :wink:
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Yes, it is looking great!

I've merged the code and checked in the latest to svn. I just made some small size-optimizations. I couldn't get the "Werk"-style to work, maybe it was a merge-error. Please take a look at that. Also if you take a look at the more compact tiling-algorithm from BlackPawn then that would be great. You know in ZGE every byte counts :)
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

I found out what broke the Werk style: you removed the
instructions inside the begin-end of this code:

Code: Select all

        if K = 0 then
        begin
          Value.DistFromCenter := Dist;
          Value.CPIndex := K;
        end
But unfortunately that was needed, I can tell you :P
BTW: you can eliminate the comment above that "if K=0". That comment is misleading and is here because of a cut-&-paste error: remove it!

Code: Select all

        //whatever K it is, if the new distance is the max found, do
I hope you enjoyed this little piece of bitmap producer ;)
also I hope to shrink it a little more :/

bye bye!
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=-
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

OOOOOOOPPPPSSS!!!
My fault!
The werk style does not work since I added one thing without testing it again :P
I wanted to write something like "Dist * 1.0" To get the distance integer cast as a float, while I erroneously wrote "Dist * 0.1"... so the scene is a little* darker then one would expect!

Ok you know what to do Ville: track down those three "Dist * 0.1" and write something that makes a float division between "Dist" and whatever else. (I think it's needed because of approximations with low-pixels bitmaps, maybe we can just stick with the integer division, I really don't know...)

I will work no Monday or Tuesday on getting the code optimized on the tileing part.
Bye bye!

*a little means it's completely screwed up.
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=-
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

yes this is great! a couple of ideas,. Nice1 seems too bright,. wheras werk is too dark., (the code is broken?) personaly, I would like to be able to choose the two shading colors in color pickers like with BitmapRect,. i.e color1, color2,. however if that is a pain. we can use expressions,. however i think we can get more variation with the two color settings,. also the borderPixel setting is a cool/usfull idea, and would be even more so if it could anti-alias in such a way as to retain tileablility,. (or the blur component could have a tile opton,.) (and off topic but tileable noise would still be very usfull,. I will post some examples later,. I am being pulled away from the computer now,. . . arrrrgg!)

also; if you do choose to add color settings ALPHA would be great to have on each,. however currently I have found that something like this does yeild interesting results;

Code: Select all

this.pixel.a=this.pixel;
Thanks for this,. very usefull as is!! see the attached! a little .scr for your efforts..,
Attachments
liquid_dendrons.zip
useing the new use screenRez setting! thanks for that too!
(36.57 KiB) Downloaded 773 times
iterationGAMES.com
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

I could implement the "2 colors" feature pretty easily... However, I would prefer to keep it separated from the component itself, and this is because the component is already monster-sized :P (lots of lines of code!) and adding some other stuff that can be easily achieved by just using a BitmapExpression is something I would not like to do... Let's say I would rather like a component to make a color transform/correction, but that would probably be just one of those black-boxes containing a pre-compilated bitmap expression (if we are to implement the blackboxes!) =)
I'm trying to add some presets now, and already checked in the black pawn's code for distance calculus. Sending the code tomorrow or wednesday morning, when some work is done.
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=-
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

jph_wacheski wrote:also the borderPixel setting is a cool/usfull idea, and would be even more so if it could anti-alias in such a way as to retain tileablility,. (or the blur component could have a tile opton,.)
It hasn't occurred to me that the blur-component isn't wrapping, I should be able to fix that easily with a new property.

Kattle: look forward to your additions.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

Ville, about the blur, what about a little refreshing of that component? I can try something about it if you want. Let's say something like the TG one, with an option for blur over a direction (X, Y) and also to amplify the color! [Very important if you do start with some pixels (Another component I will work on as soon as I end with this)]
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=-
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

The Blur-component was just the simplest version I could find and I can see the need for a more general component for this. Yes, please see what you can come up with! Beware though that a blur-algorithm can also be very advanced and we don't need photoshop-style quality here. So it is important to find a balance between code-size/complexity and quality (as everything in ZGE).

If you start on other component then please create new forum-threads so that we can keep the discussion of each feature separate.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

Sending a patch to Ville with some updates... Sorry for being a little late but:
1- I rented a server for some L4D fun and had a terrible time fixing a bunch of weird settings.
2- Didn't want JPH to be distracted from the turrets on VectorLocust ;)

Changes:
-removed a no-more needed function and shortened the texture tileing code.
-Now there's a 30 CentralPoints limit. It was 25 before. I choosed 30 since it takes 1 second on my PC to render a 1024x1024 texture with 30 points :)
-added presets for points displacement: Random (the one working like before), Honeycomb or Squares point displacement. When using honeycomb or squares, the random seed is used only for coloring with the standard style.
-Changed the Nice1 style: now colour is not scaled. If you want the same effect as before, just add a bitmapExpression right after the cell component containing:

Code: Select all

this.Pixel.R = this.Pixel.R * 0.5 + 0.25;
this.Pixel.G = this.Pixel.R;
this.Pixel.B = this.Pixel.R;
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=-
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Nice! The new code is both smaller and got more features than the last version so that is real progress!

I've checked in your code and just made a couple of small changes for readability.

A question about this part of the code (I want to understand it all :) ):

Code: Select all

      if (CellStyle = cstTG2) then
      begin
        Pixel.R := (sqrt(Value.DistSecondCenter) - sqrt(Dist))/sqrt(GlobalMax);
        if (PlacementStyle = pstSquares) then
          Pixel.R := Pixel.R / 1.414;
        if (PlacementStyle = pstHoneycomb) then
          Pixel.R := Pixel.R / 1.732;
        if IsBorder then
          Pixel.R := 0;
      end;
Why do you need to special-case the different placementstyles here? I noticed that the bitmap turns out too bright without it but shouldn't the first R-assignment with the squareroots guarantee that the color gets an even distribution?

Sound fun with the L4D-server! I also been distracted with other matters so I've got no progress to report yet on the new gui-stuff.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

for what regarding that style, it's a special case: if you are planning to normalize the intensity, you should really use something like a "second global max distance" (in the sense of the global max of the "second nearest point" distance) but I really don't like adding something like that mainly for size increase. So I made this modification in order to:
-Stick with the black pawn's styles (the random one is not modified)
-One of the possible uses for the presets is heightmaps, so I think that people will be far more comfortable if I normalized that particular style. This said, I just guessed what we needed was a sqrt(2) and a sqrt(3) :P

If I will be able to, I might also be able to re-use part of the border-finding code to make the blur tile (if requested :P)
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=-
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

Uhm... Ok guys. I need to came up with a solution to this problem:
actually, I was able to get a "strip" metric (as you can imagine with random displacement it just creates "strips") that combined with a preset like squares could create "non-regular" or "regular" bricks. Actually, the only drawback is that you won't get the "shift" bar like TG or Werk has (I won't add another parameter just for this!). BUT we will be able to get a really nice "cobblestone" effect like this: http://www.suttonbrick.com/images/used-cobblestone4.jpg

So you decide... New component or add to the Cells one? Plus, what should I do? The best may be adding a preset (what about calling it cobblestone?)
to get it cobblestone-regular or changing the actual squares preset. :) you guys decide.
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=-
Post Reply