Page 1 of 5 12345 LastLast
Results 1 to 10 of 58

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,256
    Blog Entries
    8

    Tutorial [Award Winner] Thatching for dummies...

    Been having a ball tonight playing with a new idea I have had. It worked so well I just had to share it. Working on the community mapping I have some towns and were gonna need a lot of buildings and there is no way I am going to draw each and every one of them. So a long time ago I figured that I could make bits of building and use them as stamps in ViewingDale or any other kind of stamp based drawing package like DungeonForge I guess. Did that pretty successfully with tiled houses but when I tried thatching it was a lot harder because thatched houses have a lot of curved surfaces and whilst tiled roofs have defined gutters, thatch does not. Basically it didn't work and I gave up.

    That was a while ago and things have moved on. This tutorial is going to use some pretty advanced techniques in 3D and I don't know what package you might use for this and its going to be tough going unless you can automate the process too. But its the only way I have managed to get good results so far. Apologies in that I am not going to intimately describe key by key steps as all of the software I am using will be custom but the idea should apply to any 3D package that can do lighting with a paint package that can do alpha masking - gimp, PS, PSP etc all can for example.

    So how to create fast thatch for curved surfaces.

    The object to be thatched needs to be in 3D so as stated that this is for dummies here is one

    What you need to do now is get that object in your 3D app. This could be a house object of course so making that might be a bit easier. The point here is to show that its good for curved surfaces.

    You now need to set up two lights opposite the object, north and south and render it to give the first light image. Then you need to set it up so that the lights move around the object in steps. I am using 8 steps so that it goes :- 0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5 and 180 is the same as 0 so no need. You need one more which is lit from above too. You can do that as an 9 frame scene and render all of the frames out in the scene at once.

    Right you have 9 mask renders. You need to get some thatch and I got mine from a composite of several at CGTextures.com as usual.

    Make one with thatch going north south. Then make another with a 22.5 rotation, then another at 45 etc all the way to 157.5

    For the top down mask I used several of the rotated thatches blended together to give a no-particular-direction thatch.

    Now multiply all of the thatches by the masks and add them up. You should get something like that of the final render.

    I have this scripted now so for any height map I can generate them thatched in no time. It could in theory do more than one house at the same time - maybe a whole village... The nice bit tho is that you now are freed from having to texture each part of every 3D object saving hours if not days of time.

    Hope that is useful to somebody daring enough to try. I will of course be adapting this for all sorts of roof materials so I am on the hunt for non-copyrighted 3D houses now. If you wanna build them then I can thatch them for you.

    Attached Images Attached Images

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

    Post

    And the final image since I reached my 5 image limit...
    Attached Images Attached Images

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

    Post

    Hah hah... yes, we're cookin now.
    Attached Images Attached Images

  4. #4

    Post

    Nice! And no need for particle effects, kinda nifty.

  5. #5

    Default

    That is beautiful...time consuming, for the likes of me but beautiful (but not as time consuming as really thatching a roof).

    If I make a bunch of houses will you thatch them for me using your magic script?

  6. #6
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,256
    Blog Entries
    8

    Post

    Sure thing if I can use them in my co-op tile !

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

    Post

    Quote Originally Posted by Arandil View Post
    Nice! And no need for particle effects, kinda nifty.
    Hey Arandil, didn't see your post there ! Welcome to the guild. I'm looking forward to seeing Seers GMaps

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

    Post

    While I am posting, heres a bit of the town using them...
    Attached Images Attached Images

  9. #9

    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>

  10. #10
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,256
    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.

Page 1 of 5 12345 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
  •