Normal Maps

Started by
10 comments, last by deavik 17 years, 10 months ago
How do you generate normal maps, the RGB ones, from a standard texture?
A wiseman once said nothing, but no one was there to hear it.
Advertisement

Well, practically, you won't get very good normal maps from standard textures, since the colors don't really carry any height information.

You can use the NVidia DDS plugin or some other Photoshop plugin to create a normal map.

Usually normal maps are created from hi-res 3d-model.
actualy if you mean somthing like creating brick wall normals fro ma standard texture, for walls and not for characters and such. then you want to use a greyscale bumpmap texture. then use the nvidia normalmap filter
Indy to Pro: Journeyhttp://phiendstudios.blogspot.com
I'm using the dot3, in the pipeline of directx 9, no shaders, i have a sample c++ file on the normal mapping, and it was color rather than greyscale, because of the different way of handling it(dot3) i suspect.

And yeah, i want some sort of brick wall/cracks in the floor type bumps.


is it like red is x, and green is y, blue is z?
A wiseman once said nothing, but no one was there to hear it.
Are there any tools that create normal maps from hi res models to your low res model?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
No, i want to try do it myself.

i don't need the bitmap info
just the the technique behind creating normal maps.


Thanx!
A wiseman once said nothing, but no one was there to hear it.
Calculate a greyscale.
Then take the dot product of the red and green values, the blue value is always 255.

I think that's all you need to create the normal map.

Adding depth to the image the way the Nvidia plugin does is beyond me, unless it's just the normal map being embossed or something.
I ask for help and you give me a book? I hate book. Book is stupid.Also known as Yellow at the Dark Basic forums.
Now when you say, take the dot of red and green, what do take the dot against, is it across the surface?

A wiseman once said nothing, but no one was there to hear it.
It depends on how you want to use it. If you just want to use the color by itself as a normal, it will look strange. To do this, though, it's ((COLOR * 2.0f) - 1.0f), so you need to scale from 0to1 to -1to1 (this is inside your pixel program). The problem is that color information isn't necesarily direction, so you need to prepare a texture instead.

The basic approach is to treat the image as a height map (and having an actual height map works even better). You then filter it, sampling each pixel and it's neighbor, to find the normal of that pixel. This is simple considering each pixel is a height, you just calculate the normal from one height to the other, averaging from all it's neighbors. This makes a normal map facing up (you're calculating the delta height in the XY of the image, and you assume a Z of 1), with that normal (values of -1to1), scale it to 0to255 (((Normal + 1.0f) / 2.0f) * 255.0f), and store it in your normal map texture. Inside your pixel program, convert back to -1to1 (since it's still color information here), and use the normal however you want.

Offhand, I don't have any links, but a quick search and you should be able to find some code that actually does that (that's mostly how the NVidia filter for Photoshop does it, too).
I don't remember, which tutorial i got this from but here's a sample of what i want to be able to do:



It was from some Bummapping tutorial or something.
Here is some of the code that came with it:
        g_pd3dDevice->SetTexture( 0, g_pNormalMapTexture );        g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );        g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3 ); // Perform a Dot3 operation...        g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );    // between the N (of N.L) which is stored in a normal map texture...        g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );    // with the L (of N.L) which is stored in the vertex's diffuse color.        //        // STAGE 1        //        // Modulate the base texture by N.L calculated in STAGE 0.        //        g_pd3dDevice->SetTexture( 1, g_pTexture );        g_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1 );        g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE ); // Modulate...        g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); // the texture for this stage with...        g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT ); // the current argument passed down from stage 0    
A wiseman once said nothing, but no one was there to hear it.

This topic is closed to new replies.

Advertisement