Sign in to follow this  
OrangyTang

Tools for manually creating normal maps?

Recommended Posts

OrangyTang    1298
I have some 2d art for which I need to create some associated normal maps. The art is reasonably simple (cartoon style) so theres not too much internal detail. At the moment I'm drawing a greyscale heightmap and then using this to generate a normal map, but it gives very bad results. Gradients which look smooth to the eye end up giving very bumpy and noisy normal maps, and it's difficult to get things precise. Blurring the heightmaps helps a little, but the result is still pretty bad. Ideally I'd like something like Gradient meshes, so I could specify the general shape as a bunch of polys and let the computer do the hard work of generating nice smooth gradients. However inkscape, paint shop pro and Flash all seem to be limited to simple linear and radial gradients, which aren't suitable for this stuff. Surely this must be a solved problem, but I can't seem to find anything on the 'net about this. How does everybody else generate their normal maps? Cheers

Share this post


Link to post
Share on other sites
noisecrime    817
Although I don't think it would help in this case from your description, have you tired creating your heightmaps at x2 or higher dimension and then scaling it down to the correct size? This should smooth out samples as well as allowing for subpixel detail.

Mind you I didn't think running greyscale gradients through standard normalmap generators (e.g. Nvidia photoshop plugin) produced any normals?

Perhaps you could post a sample of a heightmap and its normalmap so we can see the problem.

Share this post


Link to post
Share on other sites
OrangyTang    1298
I'm already drawing at double the resolution and scaling down before actual use, but it doesn't seem to help much in this case. The preprocessing to generate the normal map is just a bit of my own code, but it doesn't do anything unusual - just generating normals based on the differences in heights.

Heres my current test data:

As you can see the heightmap initially looks reasonable, it's pretty smooth and seems to follow the shape ok. However the generated normal map is horrible - even slight flaws in the heightmap get magnified and the end result has lots of stair-steps where the heightmap gradients aren't perfectly smooth (and remember that the heightmap has already had a gaussian blur run over it various times).

Share this post


Link to post
Share on other sites
JohnBSmall    881
Edit: I've been talking about dealing with completely the wrong problem, so most of this is kind of useless, I'm afraid. But anyway... I guess you could either make your own gradient mesh system, or make a filter that will try to further smooth areas that are already smooth, while preserving the sharpness of actual edges. Another approach (very heavyweight and difficult though) would be to go get a 3D package that can output normal maps (the latest Blender can), model your stuff (no need to model it fully, just the relief), turn on subsurf division to smooth things a bit and then render the normal map. You might be able to write a loader to turn a heightmap into a model for you and then tweak it, although I'm not sure how much time that would actually save you.

Are you scaling down the heightmap before you pass it through your normal map generator? I would have thought it makes more sense to use the higher resolution heightmap as input, and modify your normal map generator so the scaling down happens as part of the normal map generation process.

Other than that, you could probably get better results by using more samples from the heightmap for each pixel in the normal map, but you'd have to be clever about how you use the extra samples to make it much better.

Maybe something along the lines of the hq3x magnification filter which is doing a fairly similar job in that it has to correctly judge the slope of edges in the low-res input map, which is the thing you're having problems with. Having said that, the hq3x filter is working with low-colour input images rather than inputs that already have smooth gradients and anti-aliasing, so I guess it probably wouldn't work after all.

John B

[Edited by - JohnBSmall on May 11, 2007 2:31:37 PM]

Share this post


Link to post
Share on other sites
OrangyTang    1298
I don't think fancy filters is the way to go really - it's fundamentally difficult to draw a good enough heightmap, and I don't think any filter will be able to do anything useful with such bad input data (garbage in, garbage out, as they say).

Using a 3d app to model the shape is a possibility, but it does seem very heavyweight. I suspect I'd have a lot of trouble making the output match up pixel-for-pixel with the original artwork too.

So the last option seems to be making a suitable tool myself, which frankly is something I'd hoped to avoid. It seems like it should be a common problem so I'm surprised that there isn't an existing tool already that I could just use. I suppose if I kept it down to the bare minimum of features I could probably have something working in a couple of weeks or so, but it's time I'd really not waste. [sad]

Any other suggestions much appreciated.

Share this post


Link to post
Share on other sites
mattnewport    1038
A lot of games generate the normal maps for their 3D models now by having a low detail and a super high detail model with details added in something like ZBrush and raytrace from the low detail to the high detail to generate the normals. Our artists sometimes use a different approach though of unwrapping the geometry onto a flat plane (basically a unique UV mapping) and then modelling surface detail on the plane using a 3D app before generating a normal map from the flattened geometry and wrapping it back around the model. According to them this approach can be quicker than creating the geometry in full 3D for some models. Either of these approaches is quicker and easier for them than painting a heightmap by hand and using it to generate a normal map and it also produces much nicer looking normal maps.

Although you're working in 2D I think you'll find that you can produce the best results in the shortest amount of time by actually creating 3D geometry and generating the normal map off that rather than trying to hand paint a height map and using that to generate normals. You could rough out the basic shape by using a hand drawn height map as a displacement map on a reasonably highly tesselated plane in a 3D app and then smoothing it out and adding details in 3D.

ZBrush would probably be great for this kind of work as it's designed to operate on a 2D canvas with 3D elements. It's somewhat expensive though.

Share this post


Link to post
Share on other sites
noisecrime    817
Ok, well after seeing the images a few thoughts.

Have you considered scaling down the source image instead of using a blur? I ran the bitmap you supplied above through my normalmap generator and got much smoother results, without almost any of the artifacts that are visible on yours.

The big step in the middle of the hair is not a 'bad result' but expected behaviour. As I mentioned previously and have since double checked (using nVidia's photoshop plugin), a greyscale gradient is unlikely to produce any changes to the normal. I'm guessing (never really thought about it before) its the fact that normalmap generation is localised around each pixel and cannot take into acount gradual changes.

How are you generating the normalmaps? Some tool or your own code? I only ask because the results I get in my own tool and nvidia's plugin are quite different to yours. Obviously this might be due to some factor such as light position or using the small image you posted, but still something doesn't look right - not that i'm an authority on the subject. If you want to post a full size image of your heightmap I can give it a try and see what comes out.

Ultimately i'd have to agree with the others though that in this case modelling the shapes is probably the only way to get a good normalmap. It will be a real pain, but i'm not sure its worth trying to write a tool to do it.

I did consider suggesting trying Bryce, since you could import and then scuplt the heightmap in 3D in realtime, but whilst it was great in its day I don't remember it being a whole lot of fun to use, or indeed if it would help you make better heightmaps from which to build the normalmap from.

BTW exactly what type of heightmap effect are you aiming for on the shapes? I actually imported your heightmap into Bryce and the results were not what I expected. I had assumed you were aiming for something that was simialr to half a head, but you heightmap suggests more a kind of embossing like you get on coins. Either way I'm not entirely convinced the heightmap you have is right, but its hard to say since I don't know the exact results you're after.



[Edited by - noisecrime on May 12, 2007 5:32:18 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this