Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: At on October 29, 2006, 12:15:04 am

Title: Midnight Muse Strikes Again! Normal maps!
Post by: At on October 29, 2006, 12:15:04 am
[Edit] Seems the HLP fora don't like nested lists...

Hokay, I ended up editing this over the past few days in a text editor.  Hopefully everything I wrote while in a sleep deprived stupor is coherent...

...

For the most part, I think people have been doing normal maps manually, painting each color on as they go.  I just came up with a nifty way of doing this with out having to think about slope.  As much.

It's probably easier to make bump maps, ja?  After all, you just draw shades of grey to indicate about how high the stuff goes.  Unfortunately, real time graphics can't usually handle bump maps, so to make all the pretty little details, we turn to normal maps.  (Normal maps actually give you better latitude, not having to worry about height...)

But making normal maps is hard.  However, there's a way to make something that's close as makes no odds using Photoshop.  (Well, just one filter...)

(The following instructions will assume an okay level of acquaintance with Photoshop.  I'm using CS2.)

First, if you can, switch Photoshop to 16 bits/channel.  This will make things look less lumpy if/when you get to adjusting things later.  Not necessary, but if you really up the contrast or severely level things off, this will save at least some of the image quality.

Now,
Now you have two grey layers.  Whoopdey doo.

For the Z/Blue channel, things get a little fun.  We have no way of generating something useable for the Z channel with straight filters, but we do know that in general, when there's non-0 X and Y values (IE Red and/or Blue != 50% grey), that Z is less than 100%.  There are two methodes of doing this, both of which you can mess around with a lot.  The easier/shorter way is to use curves.  The longer way is to use levels.  The problem with the latter is that you have to remember to do a bunch of steps, though it could be automated.  Then again, so could the curves one.

For the curves way, you

Et voila, you now have something that you can pass off as a normal map.  The vectors prolly aren't unit vectors, but it's as close as makes no odds.

The way I've explained here is much easier, I think, than when I first did this.  Originally, I used quick mask work to paste the color channels in solid colors with varying opacity (Essentially, take gray layer, copy, new layer, paste into quick mask, fill layer with color, set layer to screen.)  This required an additional black background layer, and made editing the grays substantially harder.

...

As to why the Z values have to be greater than 128/50%: The RGB values made here are taken with very little translation as XYZ values for the normal.  Essentially, every point now has a normal detirmined by its color.
RGB values are on the domain [0.0, 1.0] (or [0, 255] for 8 bit channels.  Basically, any RG or B values can be between 0 and 255.), while the normals' coords are on [-1.0, 1.0].  (This might vary with implementation.  Normally, though, they oughta be [-1.0, 1.0].  ... Normally.  Hah.  I R SO FUN E)  The point is that 50% in RGB becomes 0 for the normal's coordinates.  Having Z values less than 0, IE Blue less than 50%, means the normal is facing in to the mesh.  And that would look silly.  I guess you could have a light inside the mesh and...

Also, the levels thing... Whooo, that was fuuuun.  If you really wanna know how that went, (Starting at where I mentioned the Levels aproach in the instructions.)
And that's why the curves method is better. :P

This levels technique also makes harsher edges by default, where the curves method makes somewhat softer ones.  The curves one is easier to adjust if you want to change how 'round' the Z values are.

And yes, I know I used both grey and gray in there.  I bet I used both color and colour, too.  These things are random...

...

So, any other thoughts, ideas?  Besides baking in ${FavouriteModelerHere}?  Been doing normal maps a different though easier/easy-as way?  You've read this and concluded that I am a horrible teacher|writer?



Title: Re: Midnight Muse Strikes Again! Normal maps!
Post by: Scooby_Doo on October 29, 2006, 12:49:43 am
Too bad Max doesn't seem to do normal maps right :-(
Title: Re: Midnight Muse Strikes Again! Normal maps!
Post by: DaBrain on October 29, 2006, 03:17:57 am
Huh? Of course it does. It's just a setup thing.


I create normal maps this way:

I just create a simple height map (no colors).
Then I use the Nvidia normal map plugin to convert it to a normal map. ;)

(http://img95.imageshack.us/img95/3483/normalheightos4.jpg)

I'm curious though... could you give me an example shot of your technique?
Title: Re: Midnight Muse Strikes Again! Normal maps!
Post by: Scooby_Doo on October 29, 2006, 04:14:24 am
Remember I had this problem before:
This was the result:
(http://img.photobucket.com/albums/v356/Shodan_AI/base1result.jpg)
This was the topic: http://www.hard-light.net/forums/index.php/topic,42457.msg870910.html#msg870910 (http://www.hard-light.net/forums/index.php/topic,42457.msg870910.html#msg870910)

It was something about normal shader being "cheap"
Title: Re: Midnight Muse Strikes Again! Normal maps!
Post by: Flipside on October 29, 2006, 10:30:01 pm
Not cheap, different type of shader, there's displacement map and Normal map, displacement map physically divides up the surface into the size of the image and moves them accordingly, so it was recoverting your Bumpmaps into Heightmaps, as it were, and because the background of Normal map is normally cyan, that's pretty high in saturation, hence the surface 'starts' very offset from the surface of the mesh :)

Hope that makes more sense to you than me....
Title: Re: Midnight Muse Strikes Again! Normal maps!
Post by: Scooby_Doo on October 29, 2006, 10:52:17 pm
Well your the one that said "cheap" in the first place  :P

It just not doing the normal maps in the way you think of normal maps.  And I could never figure out the Direct X Shader Material.