Howto:Use the normal map effect in aircraft: Difference between revisions

m
Robot: Cosmetic changes
m (small cleanup)
m (Robot: Cosmetic changes)
Line 5: Line 5:
The latest documentation on the FlightGear effects system is to be found in [http://gitorious.org/fg/fgdata/blobs/master/Docs/README.effects $FG_ROOT/Docs/README.effects]
The latest documentation on the FlightGear effects system is to be found in [http://gitorious.org/fg/fgdata/blobs/master/Docs/README.effects $FG_ROOT/Docs/README.effects]


==Creating the normal map==
== Creating the normal map ==
To create the normal map, there are two options.
To create the normal map, there are two options.
*We can use a plugin that can convert a 2D texture representing height to a set of normals. There is a good [http://registry.gimp.org/node/69 normalmap plugin] for [[GIMP]] available. Those on Ubuntu should be able to install it directly from the package manager.
* We can use a plugin that can convert a 2D texture representing height to a set of normals. There is a good [http://registry.gimp.org/node/69 normalmap plugin] for [[GIMP]] available. Those on Ubuntu should be able to install it directly from the package manager.
*On the other hand, we can create a high polygon density model of the object in a 3D editor, and generate the normal map from this model. You can find more informations on this approach , applied to blender, [http://wiki.blender.org/index.php/Doc:Manual/Textures/Maps/Bump_and_Normal_Maps here]
* On the other hand, we can create a high polygon density model of the object in a 3D editor, and generate the normal map from this model. You can find more informations on this approach , applied to blender, [http://wiki.blender.org/index.php/Doc:Manual/Textures/Maps/Bump_and_Normal_Maps here]


=== Lets see the 2D approach first: ===
=== Lets see the 2D approach first: ===
Line 17: Line 17:
# Open the texture in GIMP and create a new layer with black as the background color. We'll use the existing texture as a guide to creating the normalmap.
# Open the texture in GIMP and create a new layer with black as the background color. We'll use the existing texture as a guide to creating the normalmap.
# Adjust the opacity of the new layer so you can see the texture underneath. This layer will be a height map, with black representing low points, and white representing very raised points. So, at the moment the entire height map is at sea level.
# Adjust the opacity of the new layer so you can see the texture underneath. This layer will be a height map, with black representing low points, and white representing very raised points. So, at the moment the entire height map is at sea level.
# Now use whatever painting technique you wish to draw the height. If you want well-defined edges, draw using a sharp-edged tool.[[Image:normalmap1.png|thumb|Height Map with original texture]]
# Now use whatever painting technique you wish to draw the height. If you want well-defined edges, draw using a sharp-edged tool.[[File:normalmap1.png|thumb|Height Map with original texture]]
# Once you are satisfied with your height map, delete the background layer, increase the opacity back to 100% and save it as a new file.
# Once you are satisfied with your height map, delete the background layer, increase the opacity back to 100% and save it as a new file.
# Now we need to convert the height map to a normal map. To do this, use Filters->Map->Normalmap. If this is not present, you haven't installed the normalmap plugin as described above.
# Now we need to convert the height map to a normal map. To do this, use Filters->Map->Normalmap. If this is not present, you haven't installed the normalmap plugin as described above.
Line 32: Line 32:
# Add details to the "high poly" model, where needed. ( don't MOVE the new copy ! This methods needs that both copies share the same center to work. You could use layers to clarify the viewport when working). You could use "multires", or subsurf modifiers, or you could even do the job by hand. The sculpture tools of blender can be handy too. The workflow depends only on your habits !
# Add details to the "high poly" model, where needed. ( don't MOVE the new copy ! This methods needs that both copies share the same center to work. You could use layers to clarify the viewport when working). You could use "multires", or subsurf modifiers, or you could even do the job by hand. The sculpture tools of blender can be handy too. The workflow depends only on your habits !


Once you are satisfied with the detail level of the "high poly" copy, it is time to create the normal map from this copy, and to transfer it to the "low poly" copy. Blender's powerful interface allows to do this in a single operation :
Once you are satisfied with the detail level of the "high poly" copy, it is time to create the normal map from this copy, and to transfer it to the "low poly" copy. Blender's powerful interface allows to do this in a single operation :


# In object mode, FIRST select the "high poly" object, THEN "SHIFT-select" the "low poly" object to add it to the selection.
# In object mode, FIRST select the "high poly" object, THEN "SHIFT-select" the "low poly" object to add it to the selection.
Line 50: Line 50:
Despite it is more complex, this method allows to generate complicated displacement effects, in a much more accurate way than using converted relief maps. This way it is possible to work on 3 axes, to simulate folds, concave zones, etc...etc, all this keeping total control on the desired effect amount, just be sculpting the high poly model accordingly. You can see an image tutorial of this technique [http://vi-wer.de.tl/Normalmap-Tutorial.htm here]
Despite it is more complex, this method allows to generate complicated displacement effects, in a much more accurate way than using converted relief maps. This way it is possible to work on 3 axes, to simulate folds, concave zones, etc...etc, all this keeping total control on the desired effect amount, just be sculpting the high poly model accordingly. You can see an image tutorial of this technique [http://vi-wer.de.tl/Normalmap-Tutorial.htm here]


[[Image:normalmap2.png|thumb|Final normal map]]
[[File:normalmap2.png|thumb|Final normal map]]


==Creating the normal map Effect==
== Creating the normal map Effect ==
Now we have our normal map, we need to apply it to the aircraft. To do this, we need to create a new effect, based on the existing Effect/bumpspec.eff, and then apply it to the correct object in the model.
Now we have our normal map, we need to apply it to the aircraft. To do this, we need to create a new effect, based on the existing Effect/bumpspec.eff, and then apply it to the correct object in the model.


# Open <tt>[[$FG_ROOT]]/Effect/bumpspec.eff</tt>. You'll find some instructions at the top of the file.
# Open <tt>[[$FG ROOT]]/Effect/bumpspec.eff</tt>. You'll find some instructions at the top of the file.
# Copy the first set of XML (between the <PropertyList> and </PropertyList> tags) into a new .eff file in your aircraft directory (e.g. if you want to apply the effect to wings, create the file bumpspec-wing.eff in aircraft-name/Models/Effects/)
# Copy the first set of XML (between the <PropertyList> and </PropertyList> tags) into a new .eff file in your aircraft directory (e.g. if you want to apply the effect to wings, create the file bumpspec-wing.eff in aircraft-name/Models/Effects/)
# Edit the new file so that it has an appropriate <name> entry and an <image> entry that matches the normal map you created above. For example, in this case we've created the effect Aircraft/c172p/Models/Effects/bumpspec-wing, and are using the normal map Aircraft/c172p/Models/Liveries/wing-normal.png.
# Edit the new file so that it has an appropriate <name> entry and an <image> entry that matches the normal map you created above. For example, in this case we've created the effect Aircraft/c172p/Models/Effects/bumpspec-wing, and are using the normal map Aircraft/c172p/Models/Liveries/wing-normal.png.
Line 77: Line 77:
Now we have a new effect, which is based on the original Effects/bumpspec.eff, but which uses our own normalmap.
Now we have a new effect, which is based on the original Effects/bumpspec.eff, but which uses our own normalmap.


==Applying the effect to the model==
== Applying the effect to the model ==
Finally, we need to apply the effect to the model. This is very straightforward. Simply add a section to the model .xml file indicating the effect you want to use and the object it should apply to.
Finally, we need to apply the effect to the model. This is very straightforward. Simply add a section to the model .xml file indicating the effect you want to use and the object it should apply to.


Line 90: Line 90:
Now load your model and admire the effect:
Now load your model and admire the effect:


[[Image:normalmap3.png|thumb|Cessna with normal map]]
[[File:normalmap3.png|thumb|Cessna with normal map]]


==Final notes==
== Final notes ==
* The normal map uses the same texture coordinates as the original texture. However, the normal map does not need to be the same dimensions, so you can use a smaller or larger normal map if you need to.  
* The normal map uses the same texture coordinates as the original texture. However, the normal map does not need to be the same dimensions, so you can use a smaller or larger normal map if you need to.  
* You'll need to define a different Effect for each normal map you use. Effectively this means that if you have two objects using different textures, they will need separate effects.
* You'll need to define a different Effect for each normal map you use. Effectively this means that if you have two objects using different textures, they will need separate effects.