Reference

Home Reference Index Editor Scenery Tab

NL2MAT Editor



Introduction

The NL2Mat Editor allows the creation of special material files that replace and extend the material definitions used inside a 3D model file. The following list shows an incomplete number of features that are possible:

The material settings control the vertex and pixel pipeline of rendered polygons. There are different units responsible for creating and modifying vertex and pixel data to produce the final pixels on screen:

These units are linked together. The Deform Vertices unit, the color units, the TCGEN unit, and the TCMOD unit are vertex based. They produce the vertex attributes that are further used for the pixel based shader core unit, lighting, and reflection units. The TCMOD unit directly works on the data from the TCGEN unit. Some units like the Deform Vertices unit and the TCMOD units can have multiple stages, that are linked together. The output of an upper stage is forwarded to the input of a lower stage. Lots of interesting effects are possible.

Main Buttons

New...

Select a file path and file name for a new NL2MAT file.

Open...

Open an existing NL2MAT file.

Save

Save the current setting to the NL2MAT selected by New... or Open....

Save As...

Save the current setting to another NL2MAT file and will use this file path from now on for upcoming Save commands.

Close

Close the currently opened NL2MAT file.


General Tab




Deform Vertices Tab

Here you can add, remove or configure Deform Vertices stages. The Deform Vertices Unit is responsible for processing and modifying the original 3D vertex data from the 3D model file to achieve a vertex based dynamic movement effect. If no Deform Vertices stages are specified, the original vertex data will be processed without changes and the geometry will appear static. Multiple Deform Vertices stages can be specified. Multiple stages will be executed in order. The first stage receives the original vertex data as input. The second stage will receive the output of the first stage as input and so on. The last stage's output will be used for further rendering operations inside the material pipeline. Not that some Deform Vertices modes, such as the Autosprite mode, do not allow multiple stages. Note that all Deform Vertices modes are visible effects only. They do not affect the collision detection used for other parts of the 3D engine. It is meant for effects only. For realistic movements of scene objects, the scripting engine should be used instead.


Basic Tab

Here you can override the basic material properties of the 3D model file's material.


RGB Color Tab

You can select the lighting type or type of RGB color generation here. Lighting mode will use the basic material settings to generate brightness and colors. Others color modes will generate color values to be used inside the shader core unit to further process and create the final pixels.


Alpha Color Tab

You can select how the initial alpha component of the color should generated here.


Textures Tab

You can setup up to 4 textures here. Read the Texture Unit Setup documentation for more information.


Shading Tab

Here you specify how the textures and colors are combined using the Shader Core Language. Default mode will simply modulate all used textures and the color from the color units (Modulate = Multiply).


Reflections Tab

Here you can add a faked reflection effect. By using a custom Cube-Map, you can bypass the internal global reflection map and use a custom reflection map instead. This can be used to create local reflections.


Transparency Tab

Mode

This sets the transparency mode. Depending on the mode the material will be rendered differently with optional transparency effects.

Z-Feather Alpha

This will apply a fading effect to the alpha channel, based on the distance to the underlaying pixels in the frame buffer. Can be used with Autosprites and Fade mode to smoothly fade objects near the lines of intersection with other objects (e.g. soft smoke effects).

Blending Parameters

In Custom mode, the Src Factor and Dst Factor control how the incomming (Src) pixels of the material will be blended with the existing (Dst) pixels of the frame buffer.

Typical blending operations:



Advanced Tab

Here you can configure advanced properties


Occlusion Culling

Polygons that use materials with the Occluder option enabled will give the engine a hint where possible occlusion occurs. The engine tries to prevent objects from being drawn that are behind occluder polygons. Less objects to draw can improve the frame rates. This is called Occlusion Culling. Note that Occlusion Culling comes with a high extra overhead. If not used with great care, the overhead might be higher than the benefit. The following text will provide information about the internal process and possible pitfalls.

Single/Double Sided

The polygons marked as occluders are only double sided when the original mesh material was marked as double sided, otherwise occluder faces are single sided. There is no separate double sided option. Single sided occluder faces will only occlude other objects from one side.

Quad and Triangle Primitives

The occluder mesh can be made up of any shape of triangle mesh. Internally, the engine tries to detect quads (two triangles that share 2 vertices and together form a convex polygon with 4 corners) which are quite common for walls and such. For best performance, it is recommended to use quads. The bigger the quads, the better. At least lots of small triangles should be avoided. If the occluding mesh is highly detailed, it might make sense to create an invisible and simplified mesh for the occluders only.

Holes in the Geometry

Whenever the occluder mesh is made up of multiple polygons, great care should be taken to make sure there are no required holes between polygons. Even the smallest hole of one pixel on the screen can result in not working occlusion detection. For best performance the occluder mesh should therefore use as many shared vertices as possible without any holes at the borders of adjacent triangles. A typical problem found in poorly designed meshes are the so called T-junctions. T-junctions should be avoided at all costs because they can make the occlusion culling completely useless.

Position

For best performance, the occluder meshes should be as large as possible, and the distance to the objects that should be culled should be as large as possible. The larger the occluders and the larger the distance to the other objects, the more likely it is that the other objects are completely behind the occluders. Only when the other objects are completely behind all the occluders, they can be skipped from rendering.

Object Definition

The culling works on a per object basis. One object is either a terrain tile, a short piece of track, one support beam, one car, one tree or one scene object element (sub object). The smaller these objects are, the more likely it is that one such object lies behind occluders. The object gets culled when the bounding box of the object is behind the occluders. The bounding box can be much larger than the object itself. Occlusion culling makes only sense when the bounding boxes of objects are as tight as possible. For scene objects it might make sense to split up large objects into smaller localized elements (sub objects).

GPU vs. CPU

The Occlusion Culling system runs on the CPU in separated threads. For single core CPUs, the OC might not be of any benefit at all. For systems having a slow GPU and a modern CPU with multiple cores (such as modern laptops), the OC can be a great benefit. When designing occluders, it is recommended to try out different scenarios (slow or fast GPU/CPU combinations).




DDS files in NL2MAT materials

DDS files can be used for textures. They might make sense when you want to supply special color formats or mipmaps, or when you want to use cube maps stored inside a single DDS file. Not all possible formats are supported, only the most common:

Supported Pixelformats

DXT1 (Compressed to 4Bit per pixel)
DXT3 (Compressed to 8Bit per pixel)
DXT5 (Compressed to 8Bit per pixel)
ARGB 8:8:8:8 (32Bit per pixel)
RGB 8:8:8 (24Bit per pixel)
RGB 8:8:8 (32Bit per pixel)
ARGB 4:4:4:4 (16Bit per pixel)
RGB 5:6:5 (16Bit per pixel)
RGB 5:5:5 (16Bit per pixel)
ARGB 1:5:5:5 (16Bit per pixel)

Guide for choosing the best DXT format

Image has no alpha information: Choose DXT1
DXT1 has best quality and smallest size for images without alpha information

Image has 1bit alpha information: Choose DXT1 or DXT3
DXT1 saves 1Bit alpha information, DXT3 saves alpha information with 4Bits per pixel.
DXT1 has a smaller file size than DXT3 but pixels near transparent pixels tend to blur to black. This is caused by texture filtering and the fact that the color channels of transparent pixels in DXT1 are always black.

Image has alpha information with different shades: Choose DXT3 or DXT5
Both formats have the same file size and the color channels are identical. Both formats only differ in the way they handle alpha information. DXT3 saves the alpha information using 4Bits for each pixel (16 shades), while DXT5 compresses and interpolates the alpha information based on two 8Bit gray levels. Therefore DXT5 might be able to reproduce an alpha channel with 256 gray levels, a much higher resolution compared to the 16 gray levels of DXT3, but because of the compression, some artefacts in the alpha channel might be introduced, similar to the artefacts in the color channels of a DXT compressed image.