Zum Inhalt springen

Benutzer:SoylentGreen/ Tangent Space Normal Map

Aus Wikibooks
Diese Seite bezieht sich auf Blender v2.43
Abbildung 1: Ein gering aufgelöstes Mesh (mitte) sieht mit Normalmap (rechts) fast so gut aus, wie das hochaufgelöste Mesh (links).

Eine Normalmap erzeugt die Illusion einer dreidimensionalen Oberfläche duch ein Bild. Das ist insbesondere für Spiele sehr wichtig, da die Zahl an Vertices möglichst niedrig gehalten werden muss. Aber auch Objekte in einer "normalen" Blenderszene profitieren sehr von einer Normalmap, damit in komplexen Szenen die Zahl der Vertices überschaubar bleibt.

Blender selbst kann zur Zeit nur sog. Object-Space Normalmaps erstellen, das bedeutet im wesentlichen, dass das Objekt mehr oder weniger flach sein muss, damit die Textur richtig angewendet werden kann. Einen Effekt wie den in Abbildung 1 gezeigten lässt sich aber nur mit einer Tangent-Space Normalmap erzeugen. Dafür benötigen wir ein Hilfsprogramm. Außerdem benötigen Sie eine vollständige Python-Installation, damit das Export-Skript arbeitet.

DenNormGen

[Bearbeiten]

Das einzige mir bekannte Programm, das auch unter Linux lauffähig ist und Normalmaps aus einem hochaufgelösten Mesh erzeugen kann, ist das OpenSource-Programm DeNormGen.

Entweder ist das von ihnen heruntergeladene Programm direkt lauffähig, oder:

  • Für Windows benötigen Sie die Dateien libpng13.dll und zlib1.dll. Diese erhalten Sie z.B. von dll-files.com and dll files. Kopieren Sie diese Dateien einfach in den Programmordner von DeNormGen.
  • Unter Linux können Sie DeNormGen relativ problemlos selbst kompilieren.


The DENormGen is a tool designed to help you create Geometry Normal Maps. Such maps are used in high-end Games to fool the Player into believing that a Low Resolution Mesh does have much more detail than it actually does. Those kind of Normal Maps are best generated using a High Resolution Mesh from which the Normal Informations is extracted and projected onto the Low Resolution Mesh. This tool provides exactly this functionality. A known tool to do the same is ORB but it is windows only and impracticable to use for developing a game on a Linux system.

Besides generating a Geometry Normal Map this tool can also apply a Detail Normal Map onto of the generated Geometry Normal Map. Such Normal Maps are easily created using Normal-Plugins for 2D Graphic Applications like The GIMP. Those Normal Informations are then used to enhance the generated Normal Map. This process can be repeated many times.

Also generated is a Displacement or Height Map. Those maps can be used for Offset Mapping or with never Pixel Shader version to render a Low Resolution Mesh with much more detail by creating Vertices and Faces on the fly during rendering displacing them using such a Displacement Map. This map can also be used as a pure Height Map for Terrain Generators. Usage: Blender3D Script

3D-Modelle vorbereiten

[Bearbeiten]

Name.low und Name.hi. Beide Meshes brauchen ein Material. Low-Res Mesh muss geunwrappt sein, und eine Image-Texture haben. Das High-Res Mesh muss einen SubSurface Modifier haben.

Exportscript

[Bearbeiten]

The Blender3D Script is used to export models into the *.dim format for usage with the Normal Map Generator. To export a model you create a *.blend file which contains two distinct meshes. One of the meshes is the low resolution mesh. It has to have no subdivision turned on (which marks this mesh as the low resolution mesh) and needs UV-coordinates. Each material is considered to be one texture of the final mesh and has to have a disc texture image as its first texture channel. The size for the texture is taken from this texture image. All texture coordinates have to reside inside the boundaries of the texture. The model is considered to have normals smoothed no matter if it is activated or not. For the high resolution mesh activate subdivision even if you do not need it (in which case you set it to 0). In this mesh all material and texture coordinates are ignored. You can have them if you need them for other scripts or projects and the script will not throw and error. To export the model select both the low resolution mesh and the high resolution one and select 'export' under the file option and the script. Specify a *.dim file and save. Usage: Normal Map Generator

DeNormGen starten

[Bearbeiten]

Das Programm starten, *.dim-Datei laden. Texture-Maps->Generate. Richtigen Typ auswählen, hier Tangent-Space. Es kann ziemlich lange dauern, bis die Normalmap fertig ist.

To generate the normal maps just load the *.dim file in the normal generator. You can use different views to look at the meshes and maps. To orbit around the current view simply click and drag. To move closer or further away press and hold the shift key while dragging. To change the light direction press and hold the control key while dragging. The light is a directional light orbiting around the center of the object. The Low-Res-Mesh view does already apply the normal map (by default planar) and requires a Pixel-Shader aware graphic card to work. Otherwise no live-preview is done. If you want your high resolution model to be subdivided go to the Hi-Res Mesh Options and select the sub-division level. The offset parameter is experimental and moves all vertices along the normal by the given distance (in 1/10 mm steps) before subdivision is carried out. This could be used if the model is slightly too small. The voxel-count is an advanced parameter influencing the speed-up algorithme. A value of 50-100 is good enough (with many small faces a higher value can lead faster results). By default the texture is sized to the dimensions stored in the *.dim file. You can change them though with the Texture Size command if you need a different value. it is not mandatory but using dimensions of powers of 2 are highly recommanded. Done so you use the Generate Texture Maps command to generate a normal and displacement map for one selected texture. Repeat this process for all textures you need a normal and displacement map for. Once done you can preview your normal map in the Low-Res-Mesh view. You can also refine your normal map by applying a detail-normal map from file with the Apply Detail Normal Map command which is then merged onto the current normal map. This process can be repeated many times. Finally save your normal and displacement maps one by one to disc.