Normal mapping

Blitz3D Forums/Blitz3D Programming/Normal mapping

Azaratur(Posted 2008) [#1]
Can anyone explan what is normal map and what can i do it?
Can blitz3d support it (i really don't know what is it!!)

Aza


Gabriel(Posted 2008) [#2]
I just answered this the first time you asked.


mtnhome3d(Posted 2008) [#3]
http://blitzbasic.com/Community/posts.php?topic=78019
try the example in this post


mtnhome3d(Posted 2008) [#4]
ok heres a program I just found http://www.xnormal.net/
it is able to take a high poly mesh and a low poly mesh and make a normal map. it also can do other things like image to normal and such.


Axel Wheeler(Posted 2008) [#5]
As I understand it (no doubt wrongly):

Normals are needed to determine how bright to make a pixel based on the direction the object is facing - that is, how direct the light sources are shining on it. This info cannot be calculated every frame because it takes too long. Thus, every mesh has normal data built in to each vertex to tell Blitz what direction the adjacent triangle is facing.

This information is relative to the object itself; so there is no need to update it when moving or rotating an object, but you do need to update the normals when you change its shape. Always run the UpdateNormals() command on a mesh after scaling it (if the scaling was not proportional i.e. x,y, and z were changed by the same proportion then the normals won't change, I think...)

Now, as to normal maps:

Normal maps allow you to create better shading variation than the mesh itself has, in the same way textures allow greater detail than just coloring vertexes. In fact normal maps are really just textures (i.e. image files) in which the red and blue color data is used to specify up/down and left/right direction information rather than color. When viewed in image viewers they appear as purplish caricatures of the object. Do a google image search on "normal map" and you'll see.

Some people define normal mapping and bump mapping as the same thing, others see them as different (but I'm not sure how).

It is called normal because it makes the object look ... normal. That is, more realistic.

They have two main purposes (I'm out on a limb here, correct me if I'm wrong); one is to defeat the crude triangle shadowing you get with a low-poly mesh and a rich texture. That is, the triangles are still visible via the shading underneath the texture. A normal map that is the same size as the texture will give each pixel in the texture its own facing for lighting purposes.

The other purpose is to add additional texture (in the literal sense) to the object, so that as it turns in the light the shading adjusts automatically, which is very cool. In the CG world of animation this is especially important, but exists in some games too.

I believe some normal map generators are just for the first purpose. They take a mesh and create the normal map to smooth over the triangles. Others take the texture and create a map based on color variations in the image. For games you would normally (ha!) want the first type.

Ok, how far off was I?

Axel


chwaga(Posted 2008) [#6]
Normal mapping and Bump mapping are two very different things. A bump map is a greyscale image where each pixel shows the height of the specific point on the mesh (relative to UV maps, of course). A normal map uses color channels to show left/right, up/down, etc. Use of a normal map involves lighting the normal mapped mesh using both the triangle normals and the normals derived from the map. If done right, if gives the appearence that the mesh was tesselated, and each vertex normal was transformed relative to the vertex's pixel position on the normal map. This is generally done in reverse (as mtnhome3d said), where a DENSE mesh (multi-million-polygon) is reduced to a lower resolution, and the lost detail is stored into a normal map. Basically, you can get almost the same render using a 4M poly mesh w/o a normal map, and a 4k poly mesh with a normal map (except that the outer edges will be more obviously polygonal, and shaders will be affected).

Hope that helped!


Yahfree(Posted 2008) [#7]
http://en.wikipedia.org/wiki/Surface_normal


mtnhome3d(Posted 2008) [#8]
a bump map perturbs the normals while a normal map remaps the normals.
In 3D computer graphics, normal mapping is an application of the technique known as bump mapping. Normal mapping is sometimes referred to as "Dot3 bump mapping". While bump mapping perturbs the existing normal (the way the surface is facing) of a model, normal mapping replaces the normal entirely. Like bump mapping, it is used to add details to shading without using more polygons. But where a bump map is usually calculated based on a single-channel (interpreted as grayscale) image, the source for the normals in normal mapping is usually a multichannel image (x, y and z channels) derived from a set of more detailed versions of the objects. The values of each channel usually represent the xyz coordinates of the normal in the point corresponding to that texel.
--wikipedia http://en.wikipedia.org/wiki/Normal_map




Axel Wheeler(Posted 2008) [#9]
Yes thanks for the correction chwaga. Also I was wrong about which RGB colors mean what.

Wasn't there a program posted at one point that could take a low poly mesh and generate a smoothed normal map by interpolation? Helpful when you don't have a high-poly version of the mesh and don't know how to create one.

Aza, here are your take-aways:

First decide whether you are just trying to smooth the triangle shading on your mesh or adding roughness/detail not in the original mesh. If the former, you can even use a generic rough looking normal map if you don't care about aligning the "bumps" to features in the texture.

Once you have your normal map, use the TextureBlend() command with the DOT3 option (option 4) to tell Blitz the texture is a normal map.

I would say download some generic rough looking normal maps and try experimenting on cubes and such.

Good luck!