Results 1 to 10 of 58

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

Hybrid View

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

    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. #2
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,201
    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 Thumbnails Attached Thumbnails Click image for larger version. 

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

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

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

Name:	normal_3.png 
Views:	81 
Size:	9.4 KB 
ID:	8283  
    Last edited by Redrobes; 12-09-2008 at 08: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
  •