Page 3 of 6 FirstFirst 123456 LastLast
Results 21 to 30 of 58

Thread: [Award Winner] Thatching for dummies...

  1. #21

    Default

    I'm trying to script this in GIMP, and running into issues with the angle lighting calculations.

    I have tried using the bumpmap filter. adjusting the azimuth for each of the angle steps, then performing some thresholding. Unfortunately this doesn't give me the control I need to select only the surface angle I want without a tremendous amount of trial and error...

    I have found a normalmap plugin for gimp that seems to do alot of the heavy lifting, converting a greyscale heightmap into a RGB normal map (nvidia standard?) with R as the X, G as the Y and B as the Z vector component. I'm thinking that I could use tehse as base components to determine my thatch angle. The "problem" is that I can think how to do this mathematically (i.e. calculating for each pixel) but this will be REALLY slow. Can anyone suggest an image processing way to accomplish this?

    TIA-

    -Rob A>

  2. #22
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,257
    Blog Entries
    8

    Post

    First thoughts is to basically ignore blue for most of it cos thats Z and we wanted the angle. For the top down only we could use that blue tho.

    You will have to elaborate on nVidia standard. I guess the 128,0,0 is no X component and 0,0,0 is full -X and 255,0,0 is full right yeah ? Well to pick off a certain angle you would need to get the red in a certain range and the green in a certain range. So where red is say 80 - 100 and green is 120 - 140 or something like that is one angle. If we go for 8 directions then you need - in clock wise order:

    R G
    128 255
    192 192
    255 128
    192 64
    128 0
    64 64
    0 128
    64 192

    all these +/- somewhere between 32 and 64. Better if you can fade down so for first angle it would be 128,255 for white fading down to 64,255 or 192,255 as black or 128,192 also as black.

    So you would need to separate the RGB into 3 greyscales - in PSP thats a color split. Then take R&G and apply 8 pairs of color curves multiplying the resultant pairs together to give 8 greyscale images for the angles.

    Then finally theres the blue multiplied by one curve to get the top image.

    B
    192 +/- 64

    Ok ? Difficult to explain. I searched on the web and found this blender demo normal map man and did the curves and it came out ok. The first row is normal map, R,G and B. Second row is R * curve and G * curve. Third rown is second row mult together. Result is white where pointing north only. Do that 8 times in a script and get 8 directions.

    Hope that works out ok.

    Edit -- I have added the image for the last one with some contrast added to boost those angles like I did in my script. The result looks more like that which I get. Notice on the monkeys stomach that we have a cone and that north is the only place bright so I think it works ok.

    Edit2 -- Just updated GTS to ouput normals so heres the normal dummy.

    Edit3 -- Yeah then doing second angle - north east so it works ok.
    Attached Images Attached Images
    Last edited by Redrobes; 12-09-2008 at 09:37 PM.

  3. #23
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,257
    Blog Entries
    8

    Post

    This is PSP adjust color -> curves dialog.

    If you want to emulate that curve then just use a windowed triangle and forget trig. If you have to use trig then a windowed cos*cos function is approximate. Anything like this in Gimp ?

    edit -- http://docs.gimp.org/en/gimp-tool-curves.html this is suggesting you have the same dialog. Can you program it from the scripting language ?
    Attached Images Attached Images
    Last edited by Redrobes; 12-10-2008 at 09:24 AM.

  4. #24

    Post

    Thanks for the extra description on the curves dialog. That seems to work now that I figured it out.

    I manually ran through the steps using the results of each multiply as a layer mask for the appropriately rotated thatch pattern, and put a random oriented thatch (made by cloud masking horizontal, vertical and the two 45 degree angles) at the bottom of the stack:
    thatchtest1.png

    Masked out the waterline, and multiplied with the "z" (blue) layer from the normal map (i.e. "directionless"):
    thatchtest1_z.png

    And finally with a lighting effect bump map applied using the original heightfield:
    thatchtest1_z_bump.png

    Now the real question is it worth scripting, or just writing up as a tutorial

    -Rob A>

  5. #25
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,257
    Blog Entries
    8

    Post

    What would be cool would be if you can make a B&W mask for a city and then it blurs it a bit to round off the corners and assumes thats the height map. Then thatch it. Also at the same time use the mask as a source to get a shadow map for all of the houses too. So then you just block in all the houses and it generates you a village with shadow. Right now I create those images as tokens and put them into a map so the shadows are all wrong as you rotate them. I dont know whether the village thatching would have the res to do it justice compared to a high res token per house. Its only a small step then to get something that you define the outline of a village and get it to put some paths in, fill in the areas inside the paths with a collection of random squares or circles and then thatch and shade it.

    There was a discussion with Torstan I think about trying to get Gimp to make up random city textures but I think thats pretty hard stuff. Whats really needed is an app or out of script which has a collection of house shapes and picks random ones and randomly rotates them to try and fit it into as yet unused ground. So it wont put a house over a path or over an existing placed house area. If you could get that bit then we have techniques to fill in from there to fully rendered villages. All randomly created.

    One of the things I was trying way back in the pirate lighthouse challenge of Dec07 was to try and make height map tokens and spray them down - which did work really well. If you could 'spray' these house shaped down intelligently and keep the height map info in the bitmap then you could then thatch shade the result.

    Theres just not enough time in the world to try out all the ideas I would like to see done.

  6. #26

    Post

    Redrobe's post in the other thread on city tiles reminded me to get back to this....

    I am getting quite close to a finished script.

    Here are some sample images using his funky face heightfield...

    Straw:
    thatch1.png

    Shingles:
    thatch2.png

    Wood:
    thatch3.png

    Bark (90 degrees off):
    thatch4.png

    -Rob A>

  7. #27

    Post

    And a few more using my test image (first one).

    The problems are still fairly evident...

    -Rob A>
    Attached Images Attached Images

  8. #28
    Community Leader Facebook Connected Steel General's Avatar
    Join Date
    Jun 2008
    Location
    Ft. Wayne, IN
    Posts
    9,531

    Default

    Probelms or not...this is still pretty neat stuff.
    My Finished Maps | My Challenge Maps | Still poking around occasionally...

    Unless otherwise stated by me in the post, all work is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.



  9. #29
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,257
    Blog Entries
    8

    Post

    Yeah thats working real well. The blue half round tiles look good. All we need to do now is find a way to put down those base height maps into regions between all the roads and we could auto gen a city. I'm gonna play with that side of things shortly - when I get time. Post any ideas you have for that tho.

  10. #30
    Guild Artisan su_liam's Avatar
    Join Date
    Aug 2007
    Location
    Port Alberta, Regina(IRL: Eugene, OR)
    Posts
    798

    Default

    I think the thatch and the shingles rock. The wood and the blue things still seem... odd. Still, I am in serious want of your script just for the thatch and the shingles! Good work, technical problems or no.

Page 3 of 6 FirstFirst 123456 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •