Home Technical Talk

Getting good height from Nvidia-filter normalizing grayscale height

polycounter lvl 13
Offline / Send Message
GarageBay9 polycounter lvl 13
My workflow on some smaller objects right now involves creating minor details (electrical sockets, small switches, bumps) as a 0-255 grayscale height map with a 128 midpoint that I normalize with the Nvidia filter and overlay on a baked normal from max that I use to capture general surface curvature.

Right now I'm fighting with the Nvidia filter. I can get good red and green channels for my left-right and up-down tangents, but I'm trying to figure out how to either make it read the grayscale height and process it into the blue depth channel, or to add it manually afterwords.

Been looking at Ben Mathias' workflow from his site and it's been helpful on some parts, but he builds his heighmaps from a 0 base layer instead of 128 mid (I'm going both up and down in my heighmaps, so I need the gray midpoint).

Am I missing a setting in the Nvidia filter, or is there a good process for taking the original grayscale and copy-pasting it into the blue channel of the normalized map to get better height data?

Replies

  • Ben Apuna
    Options
    Offline / Send Message
    I think you are misunderstanding what the blue channel does in a tangent space normal map.

    Red and Green indicate changes in light direction which will give the impression of the surface going up or down. If you invert these two channels details will also appear to invert from going inward to outward and from outward to inward.

    Blue is just there to indicate a change in surface direction from flat to not flat. The blue channel is not supposed to look like a full range grayscale bump map, it's white where the surface is flat and gray to black where the surface is not flat, black would indicate a surface at a 90° angle from flat.

    I hope that helps.

    EDIT:

    Here's what I'm talking about.

    NormalMapChannels.jpg

    EDIT2:

    On some geometry.

    NormalMapChannels2.jpg
  • chronic
    Options
    Offline / Send Message
    chronic polycounter lvl 10
    the real question is why you are using the nvidia filter. If you cant afford a copy of crazybump, there is shadermap and also xnormal has a height to normals tool and photoshop integration to boot.

    if you want to layer detail I suggest you do it manually instead of using a tool where you have limited adjustability.
    http://www.cgbootcamp.com/tutorials/2009/12/9/photoshop-combine-normal-maps.html

    when converting 'surface detail' to a normal map, you dont really have to worry about if you are considering 0 or 128 as the starting point (flat). after converting you will always have the 'impression' of up or down because the normal map does not store height information. that information is lost - you only get 'surface change' information.
  • GarageBay9
    Options
    Offline / Send Message
    GarageBay9 polycounter lvl 13
    Ah, thanks Ben. That makes more sense. I just noticed that my blue channel always ends up pure white when I use the Nvidia filter.

    Thanks for the pointer, chronic, I'll take a look at that.
  • Ben Apuna
    Options
    Offline / Send Message
    Also if you're looking to create really bumpy normal maps with the Nvidia filter here's a fairly good method.

    http://www.cgtextures.com/content.php?action=tutorial&name=normalmap

    Making an action in Photoshop for something like this is really easy.

    EDIT:

    Oh I almost forgot about njob, that's a pretty good tool too.
  • [HP]
    Options
    Offline / Send Message
    [HP] polycounter lvl 13
    Why not using XNornal PS plugin?

    Sorry if I'm preaching to the choir here, maybe I'm not understanding your question but how I do it is, I just put my xnormal high frequency detail normal map result on top of the baked normal map, make it a overlay and do this:
    1zgaxbb.jpg



    Edit, oh shit, chronic basicaly beat me to it! :) And judging by the tut he posted, I've been doing it wrong?! :O
  • Ryan Clark
    Options
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    Hey all,

    Here's a comparison between three methods for mixing normal maps.

    To me, CGBootcamp's method actually looks worse than just overlaying and darkening the blue channel 50%... but both methods look pretty bad to me. The added details look flat because they aren't oriented correctly.


    NewComparison.jpg


    Blending normalmaps is a 3D operation. It's not something that can be done correctly with a 2D image editor like Photoshop.


    Here are the source images I used:
    http://crazybump.com/images/composite/
  • Ryan Clark
    Options
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    Ben Apuna wrote: »
    The blue channel is not supposed to look like a full range grayscale bump map, it's white where the surface is flat and gray to black where the surface is not flat, black would indicate a surface at a 90° angle from flat.


    Actually, a 50% value in the blue channel indicates a surface 90° from flat.

    A black value in the blue channel would indicate a surface 180° from flat: a back-facing surface. But that doesn't really happen in a tangent-space map. In practice, blue values are always at 50% or higher.
  • Farfarer
    Options
    Offline / Send Message
    Ben Apuna wrote: »
    Also if you're looking to create really bumpy normal maps with the Nvidia filter here's a fairly good method.

    http://www.cgtextures.com/content.php?action=tutorial&name=normalmap

    Making an action in Photoshop for something like this is really easy.
    Eh, I disagree. That method may give you big overblown normal maps... but they're totally inaccurate. The normal maps look nothing like what's in the diffuse texture.
  • Ben Apuna
    Options
    Offline / Send Message
    @Ryan

    Cool, thanks for correcting me :)

    I did not know that, I was just trying to interpret what I remembered seeing from baking high poly meshes to a flat plane.

    You're right! they don't get darker than 50% I must've remembered wrong about getting black in the blue channel... or baking incorrectly :poly136:
  • Ryan Clark
    Options
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    It does seem weird that half of the blue channel's range would go to waste... but object-space and world-space maps actually do use the whole range, since they aren't surface-relative.
  • Ben Apuna
    Options
    Offline / Send Message
    @Talon:

    You're right that method isn't the best, or what I would use personally. I was just too lazy to write a full on tutorial. :poly136:

    What I would do if I only had Photoshop and the Nvidia filter is:

    EDIT2: IMPORTANT! Do this whole process in a new document, the conversion back from 16 Bit per channel to 8 Bit per channel isn't as lossless as it might seem. It will introduce noise like artifacts as some pixels get pushed up or down a notch in value. Sorry if that caused trouble for anyone, I really shouldn't post tech stuff late at night...

    1. Make a real heightmap instead of just using the diffuse. Tile the image if necessary.

    2. Change the editing mode to 16 bits per channel to avoid stair stepping artifacts in the final result.

    - Image -> Mode -> 16 Bits/Channel

    3. Copy the heightmap to a new layer.

    4. Gaussian Blur it with a value of maybe 10 pixels.

    5. Run that layer through the Nvidia Filter with the following settings.
    - Add Height to Normal Map checked on.
    - Height Generation Filter Type set to 4 sample.
    - Min Z = 0.
    - Scale = 100.
    - Height Source set to Average RGB.
    - Alpha Field = Set to 1.0

    6. Repeat steps 3, 4, 5 around 4 or 5 more times, but reduce the Gaussian Blur and Scale values by 1/2 each time.

    So the next step after repeating step 3 would be a Gaussian Blue value of 5 pixels followed by Nvidia filter with a scale of 50.

    7. Change the mode back to 8 Bits/Channel.

    - Image -> Mode -> 8 Bits/Channel

    8. Blend and combine the resulting normal map layers together, using your method of choice.

    Crazy Bump would be the best for this, though if you had Crazy Bump you'd be using that instead of this convoluted method to get bumpy normal maps anyway...

    So as a free alternative I recommend this action by one of the Project Offset guys in that I found in this thread about combining normal maps. It seems to be better than the 50% blue overlay method though not as good as Crazy Bump.

    Also at this time you now have 5 or 6 different normal map layers each made with different blur/scale values. You can selectively erase parts of or hide the layers you don't want to get different height results throughout the texture. For example the 10 pixel blur/100 scale layer might be too much so just delete that layer and use the rest.

    9. Normalize the final combined normal map layers.

    Done

    Well anyway that's what I'd do for bumpier normal maps with only Photoshop and the Nvidia filter at my disposal. It makes for a pretty good Photoshop action.

    If there's a better method for any part or all of this I'd love to hear about it, as a pro license of Crazy Bump is currently out of my price range :(

    EDIT:

    I'm currently trying this process out with xNormals Height2Normals filter and so far it seems to offer more control and be easier to use with actions.
  • chronic
    Options
    Offline / Send Message
    chronic polycounter lvl 10
    I've been playing around with different methods for combining normal maps and I'm personally convinced that the method described here is the best - http://www.rodgreen.com/?p=4
    It might not be 100% correct as crazybump might provide but it looks almost the same and has the ability to keep things in photoshop. To have multiple layers you can tune interactivly makes it much better and more useful to the artist. there is nothing i hate more than destructive processes so having a non-destructive method you can use in a multilayer psd is a major selling point for me.
  • Ryan Clark
    Options
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    @Chronic:

    That method is definitely nicer than an overlay, though it still leaves details looking flat, and not lighting from the right direction.

    Here's an animated comparison:

    CompareAnimated.gif


    CrazyBump's mixer is also somewhat nicer to the artist, because it lets you adjust each layer's strength with a realtime 3D preview. Alas, it does require alt-tabbing out of Photoshop.


    @Ben: Out-of-work artists can use CrazyBump free-of-charge... I think I announced that on polycount awhile back. If that applies to you (just guessing based on your .sig), then drop me a PM!
  • Eric Chadwick
    Options
    Offline / Send Message
    Your offer is outstanding Ryan, much appreciated when I was laid off in 2008.

    I added the different methods to the wiki as well.
    http://wiki.polycount.net/Normal_Map#BlendingNormalMapsTogether
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Very interesting discussion, one thing that strikes me odd is how in EricChadwick's comparisson on the Wiki the CB and Rod Green method don't differ that much except for a bit more punch in texture B in the Rod Green one.

    But in Ryans post above the Rod Green version seems to differ a whole lot. Especially the lighting direction.

    How did you two (Ryan and Eric) manage to get such different results? ^^

    Oh and thanks for adding all this knowledge on the wiki, loving it.
  • Eric Chadwick
    Options
    Offline / Send Message
    I used Ryan's source textures to make the Rod Green normalmap in Photoshop. The other three normalmaps are Ryan's results. I put them on a plane in 3ds Max 2010, using the StandardFX shader that ships with Max, with my own diffuse IBL cubemap, then swapped out each normalmap.

    I imagine Ryan's difference is in using CrazyBump to render them? Maybe also CrazyBump has different results because it allows you to fine-tune the strengths of each map. Rod Green's is a one-off, though I imagine you could duplicate the resulting layers and/or mask them if you wanted more strength.
  • Ryan Clark
    Options
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    Hmm... Eric's blended map looks the same as mine.

    I did normalize mine before rendering, while Eric's looks non-normalized. But I don't think that accounts for the differences between the renders.

    I rendered my examples using two simple dot3 lights, with diffuse and specular components.

    Eric's rendering looks like it has some sort of environment map on it? It's harder for me to tell what's going on there.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    I used Ryan's source textures to make the Rod Green normalmap in Photoshop. The other three normalmaps are Ryan's results. I put them on a plane in 3ds Max 2010, using the StandardFX shader that ships with Max, with my own diffuse IBL cubemap, then swapped out each normalmap.

    I imagine Ryan's difference is in using CrazyBump to render them? Maybe also CrazyBump has different results because it allows you to fine-tune the strengths of each map. Rod Green's is a one-off, though I imagine you could duplicate the resulting layers and/or mask them if you wanted more strength.

    Not criticizing or anything, trying to wrap my mind around it and form my own opinion. I was sold on CB for a while there when viewing Ryan's animated GIF. Then when later viewing the wiki I was convinced that the CB example and Rod Green example were similar, so had to layer on top of each other in Photoshop to compare.

    Now I'm just confused. Think I'll do some testing myself tomorrow. :)
  • Eric Chadwick
    Options
    Offline / Send Message
    Yeah I should probably do a more thorough test. I would welcome a test image from someone else though, so I can replace the one that's there on the wiki now.
  • chronic
    Options
    Offline / Send Message
    chronic polycounter lvl 10
    I'm a little confused myself, reading through Rod Greens method, it seems to be a pretty basic mimic of vector math in photoshop, so what is crazybump doing differently, and why?
  • Ryan Clark
    Options
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    Here's a new comparison render, as simple as I can make it.

    Single diffuse light. No specularity. No color. Nothing happening but a plain dot3 operation.

    For conveying the shape of a normal map, I think simple lighting is best. Eric's cubemap looks cool, but it's harder to tell the shape of the underlying normals.


    AnimatedComparisonSimple.gif


    The images I used are here: http://crazybump.com/images/composite/
  • Ryan Clark
    Options
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    Here's an animation with all four blends rendered using a plain dot3 operation. You're welcome to use it for the wiki if ya like.

    http://crazybump.com/images/AnimatedAll.gif

    (Disclaimer: I'm not an objective party. The renderings are as plain-and-unadorend as I can make 'em though.)
  • chronic
    Options
    Offline / Send Message
    chronic polycounter lvl 10
    Its a very interesting comparison image (between crazybump and Rod Green).

    some observations:

    I'm left wondering about how the lighting 'falls off' on the shadowed side of the sphere. the crazybump version is overall very intense (the flowers) while the RG version (ron green) seems more natural, significantly less illumination on the flowers in away facing directions.
    the intensity of the normal mapping effect is about the same on the center of the sphere in both versions where there is very even lighting - then in the crazybump version, as you hit more glancing view angles the intensity/'depth' effect seems to increase.
    i would expect the intensity/depth to stay the same on all angles of the surface, and only the shading/lighting information (directionality) to change.

    I'm interested in the math behind all this if anyone can enlighten us.
  • Ben Apuna
    Options
    Offline / Send Message
    It really helps to compare the methods by actually loading the different textures into a 3d app and panning the camera or moving some lights around. That's when the differences between the different blending methods become very apparent.

    Once I did that (and spent a whole day trying to reproduce Crazy Bump's results) I totally understood what Crazy Bump's mixer was doing vs. the limitations of any Photoshop based operations.

    I can't explain the math behind it but it's very easy to understand visually once you load those normal maps onto a plane in 3d and see the results for yourself. A truly successful normal map blend will combine the actual light directions (vectors?) from two maps together. It's not really a color based blend like what you can do with Photoshop but a recalculation of light directions, which I think is what Crazy Bump is doing.
  • Vrav
    Options
    Offline / Send Message
    Vrav polycounter lvl 11
    Can't say I've used tangent space as much as object space in game art - I know, I'm bad, and need to do more character work - but the example being used here seems kind of extreme. If you've got a big spherical bubble like that in your normal map, you probably need to include it in your geometry instead.

    In tangent space normal maps where the lowpoly matches the high, most of the pixels are at or around 50%, 50%, 100%... and in the example being used, the only places that really change are where the extreme angles of the sphere exist.. unless of course it only looks that way in static images, and I need to load up a model and check it out as Brian says.

    Nonetheless, I feel that while clearly the weaker, inferior method, using 2D image editors to blend normal maps doesn't seem all that bad if your lowpoly matches the major forms you're reaching for sufficiently well.
  • Ryan Clark
    Options
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    @Chronic:

    RG's technique works by adding detail normals to existing ones. It's kinda similar to embossing. New normals are stamped down on top of your old ones, but their orientation isn't changed. That's as good a job as I can imagine doing with Photoshop!

    CB's approach is more like baking from a 3D model... details end up reoriented, because they've been transformed into your base map's tangent space. This avoids the "embossed" look, but the math is too complicated to mimic in photoshop.
  • Ben Apuna
    Options
    Offline / Send Message
    @Ryan:

    Thank you very much for your offer of free-of-charge Crazy Bump for out of work artists, not sure if I qualify... I PMed you anyway.
  • NAIMA
    Options
    Offline / Send Message
    NAIMA polycounter lvl 14
    Sorry if I dont read the whole thread but have you tried Njob ? Is a new tool I tried the other day and I like much more than the nvidia filter ...
  • Eric Chadwick
    Options
    Offline / Send Message
    In the interest of fairness, for the wiki I'd like to do tests with all the blending tools, so that would include Overlay, Chronic, Rod Green, CrazyBump, ShaderMap, and I guess Njob (haven't looked at this one yet, does it blend multiple maps together?).
  • Ben Apuna
    Options
    Offline / Send Message
    I don't think njob has any normal map blending capabilities.

    It's a normal, heightmap, and ambient occlusion maker/converter.
  • Eric Chadwick
    Options
    Offline / Send Message
    OK, updated the images in the wiki with some new tests.
    http://wiki.polycount.net/Normal_Map#BlendingNormalMapsTogether

    I created a new "dome" base normalmap, baked from geometry, but re-used Ryan's detail normalmap.
Sign In or Register to comment.