Page 1 of 5 123 ... LastLast
Results 1 to 10 of 58

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

Hybrid View

  1. #1
    Software Dev/Rep Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    4,807
    Blog Entries
    4

    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 Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Demo_height.png 
Views:	125 
Size:	45.9 KB 
ID:	3418   Click image for larger version. 

Name:	Demo_light0.png 
Views:	91 
Size:	52.3 KB 
ID:	3419   Click image for larger version. 

Name:	Demo_light2.png 
Views:	89 
Size:	48.6 KB 
ID:	3420   Click image for larger version. 

Name:	Demo_thatch.png 
Views:	767 
Size:	581.1 KB 
ID:	3421   Click image for larger version. 

Name:	Demo_thatch2.png 
Views:	149 
Size:	674.2 KB 
ID:	3422  


  2. #2
    Software Dev/Rep Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    4,807
    Blog Entries
    4

    Post

    And the final image since I reached my 5 image limit...
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Demo_final.png 
Views:	170 
Size:	1.41 MB 
ID:	3423  

  3. #3
    Software Dev/Rep Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    4,807
    Blog Entries
    4

    Post

    Hah hah... yes, we're cookin now.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Demo_cottage.png 
Views:	145 
Size:	827.9 KB 
ID:	3424  

  4. #4

    Post

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

  5. #5
    Community Leader Gracious Donor ravells's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    10,926

    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
    Software Dev/Rep Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    4,807
    Blog Entries
    4

    Post

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

  7. #7
    Software Dev/Rep Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    4,807
    Blog Entries
    4

    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
    Software Dev/Rep Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    4,807
    Blog Entries
    4

    Post

    While I am posting, heres a bit of the town using them...
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	tmp.jpg 
Views:	123 
Size:	131.8 KB 
ID:	3446  

  9. #9
    Administrator RobA's Avatar
    Join Date
    Apr 2007
    Location
    Niagara, Canada
    Posts
    5,567

    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
    Software Dev/Rep Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    4,807
    Blog Entries
    4

    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 Thumbnails Attached Thumbnails Click image for larger version. 

Name:	normal_1.png 
Views:	57 
Size:	286.8 KB 
ID:	8273   Click image for larger version. 

Name:	normal_2.png 
Views:	48 
Size:	8.3 KB 
ID:	8278   Click image for larger version. 

Name:	Demo_Normals.png 
Views:	47 
Size:	164.0 KB 
ID:	8282   Click image for larger version. 

Name:	normal_3.png 
Views:	51 
Size:	9.4 KB 
ID:	8283  
    Last edited by Redrobes; 12-09-2008 at 09:37 PM.

Posting Permissions

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