Renderbump

From Mod Wiki

Jump to: navigation, search

The RenderBump tools generate normal maps directly from detailed polygonal geometry.

There are two forms, both integrated into the main ETQW executable. These are RenderBump, used for baking high-poly geometry to low-poly UVW-mapped models, and RenderBumpFlat, used for creating normal maps from high-poly geometry with an overall flat surface (such as a tiling environment texture).


Contents

RenderBump

This command generates normal maps for arbitrary geometry such as characters or vehicles, not just flat surfaces.

Console Commands

Renderbump command line parameters typed in at the console:

renderBump [OPTION] <lowPolyModel>

Options
 -threads <1-10>
 -drawNormals
 -overDrawMap
 -hashBinsPerAxis <8,16,32,64,128>

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

<lowPolyModel> should be the path to the low-detail polygonal model for which the normal maps should be generated.

Optionally the number of threads used by for generating the normal map(s) can be specified after the low detail model. The default number of threads is 2 for use on a dual processor or Hyper Threaded system. Generally the number of threads can be set to the number of logical processors in the system. For instance if the system has two Hyper Threaded processors the number of threads can be set to 4.

-drawNormals can be used to draw the normal mapped triangles as they are calculated during the renderbump process instead of the simple progress bar. Note however that drawing the normal mapped triangles is slower and increases the total renderbump time.

-overDrawMap can be used to output an overdraw map, see below for a more detailed description.

A uniform hash grid is used to speed up the renderbump process. For models with many millions of triangles this hash grid may consume a significant amount of memory causing renderbump to run out of memory at load time. The size of the hash grid may be reduced by specifying the number of hash bins per 3D axis with the -hashBinsPerAxis option. The number of hash bins per axis must be a power of two and can be set to 8, 16, 32, 64, 128 or 256. The number of hash bins per axis defaults to 128. Using less hash bins per axis may reduce performance. However, if the smaller hash grid consumes significantly less memory performance may actually improve.

Material Options

The parameters for renderBump are specified on a per-material basis. When the "renderBump" command is launched, renderBump will analyse the specified low-poly model and take parameters from the materials applied to the surfaces of the low-poly model.

RenderBump [OPTION] <outputLocalMap> <highPolyModel>

Options
 -size <width> <height>
 -aa <0/1/2>
 -trace <0.01 - 1.00>
 -renderTriNormals
 -perfectMirror
 -clampTextureSpace
 -drawNormals
 -outline <width>
 -globalMap
 -colorMap
 -overdrawMap
 -clampOutput <xmin> <ymin> <xmax> <ymax>

-size The '-size' option followed by a width and height specifies the size of the normal map. The default size is 512 x 512.

-aa The '-aa' option specifies the level of anti-aliasing to be used on the normal map. 0 = 1x, 1 = 4x, 2 = 16x. The default setting is 4x anti-aliasing.

-trace The trace setting determines how far off of the low poly surface a ray cast will look for triangles in the high poly surface. It is expressed in fractions of the largest bounding axis of the high poly model. The default setting is 0.05

-renderTriNormals LWO models without smoothed vertex normals across the triangle surface consume a lot of memory because all vertices will be unique (they have a unique combination of position and normal vector). Models without smoothed vertex normals use unique vertices for each triangle where the vertex normals for one triangle are the same as the triangle normal. As such renderbump really renders triangle normals and not interpolated vertex normals. The '-renderTriNormals' option forces renderbump to render high poly surface triangle normals to the normal map instead of interpolated vertex normals. This allows loading an LWO with smoothed vertex normals, which consumes significantly less memory, while still rendering the LWO as if it does not have smoothed vertex normals.

-perfectMirror Some models have 2X triangles and the second X triangles are the exact mirror of the first X triangles. If the texture is also mirrored onto the model the -perfectMirror option can be used to only render the first X triangles to the normal map. This does not only save time but it also makes sure that the normal map is rendered from only one side of the model. Most noticeable is that the global map will be properly rendered for one side of the model.

-clampTextureSpace If the option '-clampTextureSpace' is used only low polygonal model triangles that map to the [0,1] texture space are sampled to calculate the normal map.

-drawNormals Draw the normal mapped triangles onscreen as they are calculated during the renderbump process.

-outline The normals at the edges of areas in the normal map that map to geometry are duplicated outwards to areas that do not directly map to geometry. The '-outline' option followed by a number specifies the number of normals that are duplicated outwards. The default setting is 8.

-globalMap If the '-globalMap' option is used a <outputLocalMap>_global.tga is written with normals in global model space (not surface space)

-colorMap If the '-colorMap' option is used a <outputLocalMap>_color.tga is written with sampled vertex colors.

-overdrawMap When multiple triangles of the low polygonal model map to the same texture space, these triangles may be rendered in any order by renderbump. Based on the order in which these triangles are rendered the normal map may be different. To get a consistent result from renderbump it is important to avoid such overdraw. When the model is mirrored the -perfectMirror option may be used to avoid overdraw. If individual triangles cause overdraw these triangles should be mapped to outside the [0,1] texture space by adding 1 to the texture coordinates and the option '-clampTextureSpace' should be used. If the '-overdrawMap' option is used a <outputLocalMap>_overdraw.tga is written which shows the renderbump overdraw. In this image the texture space used by triangles is drawn in white and all overdraw is drawn in red.

-clampOutput Stops renderbump from wrapping texture coordinates around back into the 0 - 1 range. For example, if you have a model that has a texture coordinate max at ( 1.5, 1.50 ) and you specify "-clampOutput 0 0 1 1" (ie, a normal range) anything past ( 1, 1 ) will be thrown away and won't be seen on the final output. This can be handy for renderbumping only a certain part of a terrain mesh, for example.

Notes

  • As a result of the multithreading, renderbump is really sensitive to UV re-use. Make sure there only ever is one UV triangle stacked on a single pixel in the 0,0 to 1,1 space. Anything that re-uses data, move it outside of the region by an offset of 1 (let's standardise by an offset of 1 to the right). Then when renderbumping, use clamped output.
  • The tangent space during renderbumping has to be identical to the one in game, do not split meshes in case of mirroring and remove half of the data. This will cause smoothing to be different during renderbumping and give visual artifacts.
  • Use the shortest trace distance you can away with without getting renderbump errors. 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.
  • The lowPolyModel must have 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.
  • The alpha channel of the normal map will contain a mask if there were areas in the map that did not directly map to geometry. This can be copied to a diffuse map to use with the alphatest material option for per-pixel opacity.
  • If you use the normal map as a template for the specular map, you should explicitly clear or remove the alpha channel, because it will prevent more efficient texture compression from being used.
  • The generated image will be saved relative to the game's base path.

RenderBumpFlat

This version of renderBump generates normal maps suitable for mapping on surfaces like standard textures. The model file should contain geometry which forms a generally 2D surface. The model file does not need to have texture coordinates, but you should save it with normals if you don’t want the entire thing to be smooth shaded. The generated normal map will be saved to "<modelFile>_local.tga". To use the following command should be run in the console:

RenderBumpFlat [OPTION] modelFile

Options
 -size <width> <height>
 -heightmap
 -floatHeightmap
  • -size sets output resolution, (defaults to 256 by 256 if not specified).
  • -heightmap writes out a grayscale heightmap TGA.
  • -floatHeightmap writes out a 32-bit floating point RAW heightmap file (more accurate than a TGA).


For example, to render a 1024x1024 normal map, you would use this command:

renderbumpFlat -size 1024 1024 models/mymodel.lwo

This would output to ETQW base folder/models/mymodel_local.tga

Notes
  • In Lightwave the Back viewport (XY) is the direction of the renderbump traces.
  • In Max it is the Front viewport (pointing in negative Y)
  • RenderBumpFlat supports the ability to render at higher resolutions then you would normally be limited to through your screen resolution, so 2048x2048 or 4096x4096 are now possible (depending on video card).
  • RenderBumpFlat automatically performs 16x oversampling, so the resulting image should be sufficiently anti-aliased, it also generates a color map by default.


RenderBump Tutorial

For a simple example of how to get started using renderBump, see the tutorial on Making A Normal Map.

Personal tools