Meshes from Lightwave to D3 with Normal Maps

From The DarkMod Wiki
Jump to navigationJump to search

Originally written by oDDity on

General RenderBump

renderBump <lowPolyModel>

The renderbump command is used to generate a normal map for a non-flat surface like the surface of a character model in the game. �

The parameters for renderbump are specified in the materials applied to the surfaces of the low detail model

renderBump [-size <width> <height>] [-aa <0/1/2>][-trace <0.01 - 1.0>] <normalMapImage> <highPolyModel>

Size defaults to 256 by 256 if not specified.

AA defaults to 1 if not specified.

Trace defaults to 0.05 if not specified.

The AA setting determines how much anti-aliasing will be done. The default level of one gives 4x anti-aliasing, while level 2 gives 16x and level 0 gives 1x.

The trace setting determines how far off of the low poly surface that a ray cast will look for triangles in the high poly surface. It is expressed in fractions of the largest bounding axis. Tracing speed goes down rapidly as this is increased, but if your high poly geometry isn’t showing up in the normal map, you may need to increase this to 0.1 or more. The best solution is to try very hard to have the low poly version be a very close match to the high poly version.

Note that you must also make sure the low poly and high poly occupy the same basic space (ie, their origins are the same). Otherwise the rays won't reach your highpoly model.

Both models must be triangulated.

The lowPolyModel must have uv texture coordinates on it, and care should be taken to make sure the mapping is as good as possible. Before doing a RenderBump, test the model in the game with "r_showTexturePolarity 1" and "r_showEdges 1". Make sure that there aren’t any texture seams that aren’t absolutely necessary, and that there are no overlapped texture projections.

  • Create a shader definition containing the renderbump keyword:
	renderbump -size 1024 1024 -aa 2 -trace 0.5 -colorMap textures/darkmod/test_local.tga models/test_hi.ase
  • Run DEdit or Doom3 and type this in the console:
renderbump models/test.ase
  • This will take some time (up to ten minutes) and will create the textures/darkmod/test_local.tga.

Note: After 1.08, folder structure changes resulted in my file being saved to darkmod/fms/darkmod/textures/darkmod/test_local.tga. Something to try if you can't find your texture file.

Out of Date Method

You will need:

SO, you have you high and low res versions of your model - the high res version doesn't need a UV map or to be triangles, the low res version certainly does need a UV map, and you can triple the low res mesh before or after the normal map creation in LW, it doesn't matter)

  • Create a U/V map for your low-poly mesh and take care that no face is sharing the same texture space.
  • Put you low res model in layer 1, put your high res model in layer 2 as a background template
  • Start the normal map create plugin from the construct/ additional tab
  • Make sure the name of the UV map you select is the same you put on you low res object
  • The only other things you have to change on the plugin interface is what size you want the image to be and to press the 'tangent' button at the bottom since 'local' is selected by default.
  • The surface name you give you object should be the same as the folder you keep your object, so if the model is called 'chair' and goes in '...base/models/mymodels/chair' folder, name the surface of the chair 'models\mymodels\chair\chair'
  • It's also best to put your normal map, your diffuse map and you spec map in this folder before opening Lightwave's surface editor so you can browse to this folder for whatever you called the normal map image ('chair_local.tga' would be conventional). Put this in the colour channel with the appropiate UV map.

- Save the Lightwave file directly to this 'models/mymodels/chair' folder Then you write a new shader and put it in the materials folder, call the shader with this text inside it:

    bumpmap models/mymodels/chair/chair_local.tga
    diffusemap models/mymodels/chair/chair_d.tga
    specularmap models/mymodels/chair/chair_s.tga

That's it, you should now be able to browse to it and see it in the entities window of the doom editor. I'm not sure if all of those steps were absolutely necessary, but it works.

Note from Fingernail: "Don't use this plugin. D3 uses a different configuration of normals in the vertical...use D3's own RENDERBUMP and RENDERBUMPFLAT tools.

Note from Springheel: Renderbumpflat is used to generate normalmaps for 2d textures. Renderbump is the correct command to use for high poly models.