L3DT users' wiki
Large 3D terrain generator

 

Differences

This shows you the differences between two versions of the page.

tutorials:l3dt:bumpmap [2017/08/31 06:39] (current)
Line 1: Line 1:
 +====== Making and using bump-maps in L3DT ======
  
 +^  Author | Aaron Torpy. |
 +^  Last updated | 3rd of Jan, '08. |
 +
 +
 +===== Introduction =====
 +
 +With L3DT's support for [[bundydocs>l3dt:algorithms:lm#bump-mapping|bump-mapped lighting]], is has naturally been asked how one goes about making the bump map images used for this algorithm. This tutorial will explain how to generate bump maps from texture images using L3DT and how to set up materials and climates to use these bump-maps. 
 +
 +But first, we'll briefly discuss what bump maps are and why they are useful:
 +
 +
 +===== What's and why's =====
 +
 +==== What is a bump-map? ====
 +
 +Firstly, this is what one looks like:
 +
 +{{ tutorials:l3dt:bumpmap:rock2_bump.jpg }}
 +
 +You'll notice that the bump-map appears to be lit by a red-light in the positive //x//-direction (located to the right), by a green light in the positive //y//-direction (located above the screen), and a blue light in the positive //z//-direction (located out of the screen). There is a good reason for this colour scheme, and it's purely mathematical:
 +
 +//A bump-map is an image in which the {x,y,z} components of the normal-vectors to some 3-dimensional surface are mapped, directly, to the {r,g,b} colour-space.//
 +
 +Ah, I feel better having said that.
 +
 +
 +==== Why is such a map useful? ====
 +
 +Well, to use [[bundydocs>l3dt:algorithms:lm#calculating_light_intensity|bilinear lighting]], as L3DT does, you need to know the surface normal vectors. The map of normal vectors for a heightmap can of course be calculated by L3DT ([[bundydocs>l3dt:reference:maps:tn|see here]]), and these are used for standard-resolution lighting. For fancy lighting, an extra set of land-type dependent bump-maps are used to distort the terrain normals to give greater apparent detail (see the [[bundydocs>l3dt:algorithms:lm#bump_mapping|light-mapping algorithms page]] for more info). 
 +
 +
 +===== How do we make a bump-map? =====
 +
 +
 +
 +==== The trick ====
 +
 +To make the above bump-map, I imported the texture shown below as a heightfield into L3DT (//'File->Import->Heightfield'//).
 +
 +{{ tutorials:l3dt:bumpmap:rock2.jpg }}
 +
 +You can use the default settings in the [[bundydocs>l3dt:userguide:io:import:hf#importing_from_images|heightfield import options]] wizard, except that you must remember to select the //'wrap edges'// check-box. This ensures the bump-map will be seamless (assuming, of course, that the texture was seamless). 
 +
 +Anyhoo, when the texture has been imported as a heightfield, generate the normals map using //'Operations->Terrain normals->Generate map'// function. This normals map is your bump map. Finally, save the normals map using the //'File->Export->Active map...'// menu option. 
 +
 +<note tip>
 +Bump map data is highly susceptible to JPEG and DDS compression artefacts. It is therefore recommended you use either **BMP** or **PNG** image formats for you bump-maps, or else JPEG with quality set to 100 (95 is __//not//__ enough.)
 +</note>
 +
 +
 +==== Denunciation ====
 +
 +But wait! Before proceeding go I should mention that this technique for generating bump maps for textures is //complete hack//. It implicitly assumes that the brightest parts of the texture are the points displaced furthest from the surface. This is not necessarily true, as the texture colour depends strongly on the lighting conditions and the material colour. However, at least for the rock textures provided with L3DT, the results appear passably believable.
 +
 +===== Using your bump-map in L3DT =====
 +
 +
 +==== Where to put you bump-maps ====
 +
 +Bump-map images are stored in the climate resources directory, which for a standard installation will be:
 +
 +<code>
 +C:\Program Files\Bundysoft\L3DT [version]\Resources\Climates
 +</code>
 +
 +Place the bump-map image in this directory, or a subdirectory thereof.
 +
 +
 +
 +
 +
 +
 +
 +==== Adding bump-maps to materials ====
 +
 +To use your new bump-map in L3DT you must add it to a //material//. To do this, open the material manager using the '//Materials->Material manager//' menu option. This will open the material manager, shown below:
 +
 +{{ :tutorials:l3dt:common:matmanager.png |:tutorials:l3dt:common:matmanager.png}}
 +
 +In the material manager, select the material to which you will add the new bump-map. You have three options here:
 +  * Create a new material by double-clicking on the '<< new material >>' entry, or;
 +  * copy an existing material by selecting it and pressing the 'copy' button, or;
 +  * modify an existing material by selecting it and pressing the 'edit' button.
 +Whichever option you choose, L3DT will then open the material editor, shown below:
 +
 +{{ :tutorials:l3dt:common:matedit.png |:tutorials:l3dt:common:matedit.png}}
 +
 +In the material editor you can now create or edit the 'texture/bump-map layer' that will contain the bump-map. If you have created a new material, this list will be empty and you will need to press the 'create' button. If you are copying or editing a material, this list should contain one or more layers (as above). To edit these layers to add your bump-map, select a layer and press the 'edit' button. This will open the layer editor dialog box, shown below:
 +
 +{{ :tutorials:l3dt:common:texlayer.png |:tutorials:l3dt:common:texlayer.png}}
 +
 +To use your bump-map in this layer, enter the filename of your bump-map image in the 'Bump-map settings' area, or use the '...' button to browse for the file. You might also want to set the texture image file name to the name of the image from which you generated the bump-map. This ensures that the lighting on the texture matches the appearance of the ground textures.
 +
 +You may use the //weighting// value to set the relative strength of this bump map versus the other bump-map layers in the material (if any). The default value is 1.
 +
 +Once you have finished with editing the layer, click OK to return to the material editor. If your material contains other layers, you may also wish to set the new bump-map in those layers too. Note that the different layers in a material may use different textures and bump-maps to provide greater variation and detail at different scales. If you would like to see an example of this, please edit the 'std_cliffs' material to see how it is done.
 +
 +Before you close the material editor, you should remember to check the 'Enable bump-mapping' checkbox, and set the bump-mapping strength to a value greater than 0. Normally the strength value would range between about 0.3 and 0.7, depending on how strong you want the bump-mapping effect to be. For some materials, the value may be as high as 2.5 (this is used in the materials for [[http://spring.clan-sy.com/|Spring maps]]).
 +
 +
 +
 +
 +
 +
 +
 +==== Applying your material to a land type ====
 +
 +Your material will not be used by L3DT unless it is associated with a //land type//. Land types are what you see in the [[bundydocs>l3dt:reference:maps:am|attributes map]], and control which materials are displayed where. 
 +
 +If you added your bump-map to an existing material, then the bump-map will most likely be associated with one or more land types already. For example, the 'std_cliffs' material is associated with the 'cliffs' and the 'coastal rock' land types in the temperate and tropical climates. If you did edit an existing material, then don't need to follow the remaining steps in this section, as they describe how to associate your material with a land type.
 +
 +If you have created a new material for you bump-map, you will now need to associate the material with a land type. To do this, open the climate manager using the '//Climates->Climate manager//' menu option:
 +
 +{{ :tutorials:l3dt:common:climanager.png |:tutorials:l3dt:common:climanager.png}}
 +
 +Creating a new climate is outside the scope of this tutorial, so I will recommend you edit an existing cimate to use with your material. To do this, double-click on a climate in the list. This will open the climate editor dialog box, shown below:
 +
 +{{ :tutorials:l3dt:common:clieditor.png |:tutorials:l3dt:common:clieditor.png}}
 +
 +In the climate editor, select the land type that will use your new material and press the 'edit' button. This will open the land type editor. In this dialog box, select the 'appearance' tab, and select your material from the //material// drop-list (shown below):
 +
 +{{ :tutorials:l3dt:common:ltedit_pane3.png |:tutorials:l3dt:common:ltedit_pane3.png}}
 +
 +Click OK to close the land type editor, climate editor and climate manager. You bump-map is now loaded in a material attached to a land type, and is ready to use.
 +
 +===== The End =====
 +
 +This is the end of the tutorial. If you would like tips on how to actually generate a bump-mapped light map or texture, please consult the relevant sections of the user-guide ([[bundydocs>l3dt:userguide:ops:lm|light map]],[[bundydocs>l3dt:userguide:ops:tx|texture]]). If you have any other questions, please feel free to ask them in the [[http://www.bundysoft.com/phpBB2/|community forum]].
 +
 +Cheerio,
 +Aaron.
 
tutorials/l3dt/bumpmap.txt · Last modified: 2017/08/31 06:39 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki