Home Technical Talk

Smooth Normal Map

Hey guys,

I am working on creating normal maps from black and white images. Here is my source, it is just a test image:

2HrcM.png

Here is the normal that is generated out of it:

gyQuX.png

All good, except for the ridges/lines running around the indent/outdents in the map.

CwnJZ.png

Not looking too good. Is there any way to fix this? I get this problem on generated maps from both nJob and Shadermap 2.

Thanks,
Benton

Replies

  • Kurt Russell Fan Club
    Options
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    Looks like you're taking your initial image (which is a height map) and using nJob's diffuse->height map? That's the problem -- your initial image is the height map so you don't need to process it. That diffuse->height map is probably best saved for photos.

    Take that first image that you're using as an input and just pass it through Heightmap->Normal. It'll look much cleaner. If you want to have a bigger angled area at the edges of your rectangles, blur your height map in Photoshop so the width of the blurred section matches the width of the angle you want.
  • Benton
    Options
    Offline / Send Message
    I tried that. That, and the Nivida Photoshop Normal Filter does this:

    TkNLF.png

    All the heights are the same.
  • Kurt Russell Fan Club
    Options
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    That is correct. That's a normal map.

    Normal maps don't have heights, they have angles.

    If two surfaces are facing me, their normal (angle) is the same, so it doesn't matter if they are both the same distance from me, or if one of them is right in front of my face and the other one's on the other side of the sun -- their normal will be the same.

    If you want to show something other than angle then you can use a displacement map. If you want to show more of an angle near the edges of the two surfaces then you can adjust your height map before you create your normal map (e.g. blurring it)
  • Benton
    Options
    Offline / Send Message
    Ok but now the raised parts are raised the same amount, even though the hightmap had different shades of hight. In Shadermap, I used the normal painting tool to add some more height.

    doIOt.png

    So why won't my heightmap be converted with the different height/angle values that it contains?
  • Benton
    Options
    Offline / Send Message
    Ok so I see now that the bigger the angle the higher it is. But can't normal maps store sharp, but still high angles?

    And on another note, I blurred part of the map in Photoshop, but I still get lines:

    lD3uB.png
  • Kurt Russell Fan Club
    Options
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    Are you increasing the scale without increasing the blur radius? Try increasing blur as well.

    The lines will occur because of banding, so also try changing your height map to use all values from black to white rather than using lots of greys.
  • Benton
    Options
    Offline / Send Message
    I don't understand. The "heightmap" is just a greyscale image...


    And sorry for all the noob questions, I just can't wrap my head around this at midnight.
  • Benton
    Options
    Offline / Send Message
    Alright, I think I understand this more. Normal maps are all about angles. The more of a slope/angle the higher the raised part is.

    I thought I could create a grayscale map in photoshop, and the ligher parts of the grayscale map would be raised more. But now I understand, the more of a blur the parts have, the higher/lower they are, it has nothing to do with shades of gray?

    How do I remove the banding? Make it all black and white, no grey?

    Again, sorry for all the questions. I just don't understand this stuff :\
  • Farfarer
    Options
    Offline / Send Message
    To help the banding, you could try authoring the heightmap to 16 bit before running the plugin then reducing it afterwards.

    Probably won't fix it entirely but may reduce the effect.
  • throttlekitty
    Options
    Offline / Send Message
    No worries about noob questions on this one. Normal maps are a big topic, and have confused many people. Try this for starters:
    http://wiki.polycount.com/NormalMap/

    The big thing about normal maps as you noted is that they are about angles. More specifically, they are about normal vectors; normal maps simply bend the normals of the existing geometry on a pixel level.

    Here's a good example of visualizing normals being bent at extremes (the black spots)
    http://f.hatena.ne.jp/images/fotolife/h/hajimeN/20071004/20071004101303.jpg
    Or in your example using the photoshop plugin, the blue normals are all perpendicular, except at the square borders, where they would be angled like 30-something degrees. And back to 'flat' inside the square, since the shape only indicates a raised bevel.
    The sphere shape would have a smooth transition of normal vectors from one side to the other across the profile.

    For the banding, what are you using to view the results in? I use one program that gives similar results with .tga, but not .dds. You may need to calibrate your monitor, but midrange shouldn't be so affected by that. (could be a problem with this nJob tool? I've never used it)
  • Kurt Russell Fan Club
    Options
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    No worries, it's not always easy to understand how they work. Normal maps are the angle a surface is on, so you can work out the normal using the height but the normal doesn't include the height.

    It's not so much the blur, it's more the gradient. Blurring makes a gradient, but any gradient will do. If you remember from maths, a gradient is the change in height from one value to the next.

    So imagine my height values are 1 2 3 4 5 6 7 8 9, my change in pixel height for each pixel will be 1 1 1 1 1 1 1 1 1. And if my pixel height values are 4 4 5 5 5 5 5 4 4 then my change in pixel height might be 0 1 1 0 0 0 -1 -1 0. That's basically what the red and green channels of normal maps are, though the numbers instead of being 0 for flat surfaces, they're 128.
  • Benton
    Options
    Offline / Send Message
Sign In or Register to comment.