Results 1 to 10 of 58

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Post

    I was so impressed I had to try to see if I could do something similar with Gimp:
    Attachment 3442

    I created a set layers of rotated thatch images, then set the layer mask for each as a bump mapped version of the heightfield with the light coming from the same direction as the thatch was rotated. I think I had the lighting elevation too low, and I only went with 45 degree rotations, cause I was just playing.

    I realized afterward that I should have scaled the thatch down a bit, but I think the basics are there.

    How did you blend the rotated layers to get the non-direction version?

    I think this might be worth scripting...

    -Rob A>

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

    Post

    Well done for having a go. I'll note some more tech details...

    What I ended up doing was to add a whole bunch of light sources in a line going vertical. Like a vertical fluorescent strip light in the direction of thatching and I created a single image render made from the brightest parts of those light renders. I used directional light sources not point or spot. Then I clamped the lighting so that only the very brightest parts of the image stayed white and all else went black. That basically made only the parts of the model which faced in the exact horizontal (X-Z plane) direction of the thatch white but at any vertical angle (Y angle). So for example a ball like an orange would have a segment lit white and all else black.

    So I had 8 image masks and an extra non directional thatch texture. The masking and compositing is done with a compositor that I have as part of GTS but the order I used was as follows.

    Start with an image which is all floor color - say black.
    Mask in the non directional thatch where the object is not floor only. That is to say if the height map is not black then render the non directional thatch.

    Then multiply LightMask7 (157.5deg) with Thatch7 and add in.
    Then multiply LightMask6 (135.0deg) with Thatch6 and add in.
    ...

    Then multiply LightMask0 (0.0deg) with Thatch0 and add in.

    And that should be it. So Thatch at 0.0 deg is the highest priority and the non directional thatch is least. I tried doing odd angled first like 22.5, 67.5 and then the 45's and then the 90's and then 0 but that didn't come out as well as doing them in rotation order. You could end up with small patches of one angle where everything around it was another completely different. By doing them in rotation order it seems to blend the angles better but the down side is that if you get the light clamping wrong then the bits of thatch which would be 90deg and well lit by the 90deg light mask could be wiped out by the overlap from the 22.5 Then when you get the final render all the angles are a bit out.

    I accept that this is not the easiest thing to set up but once you have it it seems to work time and time again.

    To get the non directed thatch I merely took 0 & 90 deg and put it in two layers in the bitmap editor and blended 50:50. I was hoping that I wouldn't have too much of that showing really. You cant have thatch pointing straight up as it would let the water in ! I don't know what real thatching does on the top of houses. I guess they put some flat thatching across. Sometimes you see these great bits like topiary with a thatched peacock or something very clever.
    Last edited by Redrobes; 05-05-2008 at 07:26 AM.

  3. #3
    Community Leader Torq's Avatar
    Join Date
    Jun 2007
    Location
    Cape Town, South Africa
    Posts
    894

    Post

    Great post Redrobes. I'm definately going to try to implement it in my next city map.

    Torq
    The internet! It\'ll never catch on.

    Software Used: Terranoise, Wilbur, Terragen, The Gimp, Inkscape, Mojoworld

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

    Default

    The lighting on your buildings seems a little disarrayed. It looks like you need to create your thatch texture unshaded, and then apply your shading in situ.

    So if I get what you are doing here, you are using your differently lit versions of the object to index the various thatch images by orientation.

    Using a Sobel algorithm(I think) to calculate the partial derivatives of the HF in the vertical direction and then calculating atan(∂y/∂x). You can use the result, truncated to [0, 7] to select thatch images by index. This could be quicker than running a full 3d render eight times. I will leave the implementation as an exercise for smarter people than myself(you).

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

    Post

    Quote Originally Posted by su_liam View Post
    The lighting on your buildings seems a little disarrayed. It looks like you need to create your thatch texture unshaded, and then apply your shading in situ.

    So if I get what you are doing here, you are using your differently lit versions of the object to index the various thatch images by orientation.

    Using a Sobel algorithm(I think) to calculate the partial derivatives of the HF in the vertical direction and then calculating atan(∂y/∂x). You can use the result, truncated to [0, 7] to select thatch images by index. This could be quicker than running a full 3d render eight times. I will leave the implementation as an exercise for smarter people than myself(you).
    Your right in that the shadows are in all directions. I try and avoid shadows and if I have them then I light stuff straight down. It looks a little fake but you can reuse bitmaps that have captured the lighting in them over and over.

    Buildings tho don't ever look like buildings without some shadow. Its the same with terrain hills, humps, ditches and so on. You cant adequately show them without some shading or else they look flat.

    So I could render them without the shading and use the height maps in place of the houses in VDale and render out a full height map of the whole town, then shade that and apply that to the flat color icons and it would look great but it would use one image for lighting for the whole town but each house would have its own color image. So the resolution of the shading would be much much less than the color. Probably not a big issue and it would also allow shadows from the houses too but its not ideal.

    When rendering out the lightmaps in GTS I already have the normal vector for the height map so I don't need to do any more partial diff calcs. I could do a max of dot products for the 8 X-Z planar directions and get the index and your right I could add code to output an index image or even write some bigger code to take in 8 images and pick one. But this way is very similar and it has a little advantage of allowing some blending across two indexes - but I guess you could interpolate between two indexes too.

    It takes about 30 secs from start to finish to generate the final shaded thatched model from the 8 bit gray-scale height map. Its not a huge wait thats worth coding up something special for.

    Your points are all very valid tho.

  6. #6

    Post

    Quote Originally Posted by su_liam View Post
    Using a Sobel algorithm(I think) to calculate the partial derivatives of the HF in the vertical direction and then calculating atan(∂y/∂x). You can use the result, truncated to [0, 7] to select thatch images by index.
    I hate to disagree with you, Su Liam, but for my part, I prefer the third integral Myneesie flux density theorem as I find it gives a better finish, particularly when used in conjuction with a Loople Cadmaflow projection with a little bit of cheese cake at the end.

  7. #7

    Post

    Artists...
    Bryan Ray, visual effects artist
    http://www.bryanray.name

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

    Default

    I like artists. I'd like to be one someday when I grow up.

    I have to say Ravells, most of what you said went straight over my head, but I completely agree with you about the cheesecake. Mmmm, cheesecake!

Posting Permissions

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