Creating LOD Models: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Tels (talk | contribs)
stub
 
Tels (talk | contribs)
add images and material
Line 6: Line 6:


== Creating the model ==
== Creating the model ==
[[Image:Cattails 4 model.png|thump|240px|right]]


=== Start with a suitable model ===
=== Start with a suitable model ===
I used the cattails4.low model, as I am using it in a map of my own, and it is a very detailed model that is still compact and thus promises a good speedup with a simple process:
{{clear}}


=== Create screenshots from DR ===
=== Create screenshots from DR ===
I put the model into a map, removing everything that was visible behind it, and then create a simple patch mesh behind it, and texture it with '''textures/sfx/white'''. When you select this patch in DR, it gives a nice uniform brown color, which we can later use to sep. the background from the model itself:
Then I used the screen capture program from KDE to create screenshots and open them up in Gimp. One shot from the front, one from the side. Try to align the camera as level and at the center of the model as possible. The exact alignment isn't nec, but it simplifies things somewhat.


=== The texture ===
=== The texture ===


=== The material defintition ===
=== The material defintition ===
Here is an example:
<pre>
textures/darkmod/decals/vegetation/cattails_green4_side
{
    qer_editorimage textures/darkmod/decals/vegetation/cattail_flat_side
    surftype15
    description "foliage"
    twosided
    nonsolid
    {
        blend diffusemap
        map textures/darkmod/decals/vegetation/cattail_flat_side
        alphatest 0.5
    }
    // TDM Ambient Method Related
    {
        if (global5 == 1)
        blend add
        map            textures/darkmod/decals/vegetation/cattail_flat_side
        scale          1, 1
        red        global2
        green          global3
        blue            global4
    }
    {
        if (global5 == 2)
        blend add
        program ambientEnvironment.vfp
        vertexParm      0      1, 1, 1, 1      // UV Scales for Diffuse and Bump
        vertexParm      1      1, 1, 1, 1  // (X,Y) UV Scale for specular, Z: ambient reflection scale
        vertexParm      2      global2, global3, global4, 1
        vertexParm      3      0
        fragmentMap    0      cubeMap env/gen1
        fragmentMap    1      _black                                              // Bump
        fragmentMap    2      textures/darkmod/decals/vegetation/cattail_flat_side  // Diffuse
        fragmentMap    3      _black          // Specular
    }
}
</pre>


=== Create the patches, export as ASE ===
=== Create the patches, export as ASE ===

Revision as of 10:22, 24 September 2010

Introduction

TDN v1.03 will have a LOD system, where the engine can replace models that are far away with simpler versions. The same technique can also be applied manually, by placing decals at some distance to create the illusion of more details.

This article details how to create models that can be used for such purposes and what the performance gains are.

Creating the model

thump
thump

Start with a suitable model

I used the cattails4.low model, as I am using it in a map of my own, and it is a very detailed model that is still compact and thus promises a good speedup with a simple process:

Create screenshots from DR

I put the model into a map, removing everything that was visible behind it, and then create a simple patch mesh behind it, and texture it with textures/sfx/white. When you select this patch in DR, it gives a nice uniform brown color, which we can later use to sep. the background from the model itself:

Then I used the screen capture program from KDE to create screenshots and open them up in Gimp. One shot from the front, one from the side. Try to align the camera as level and at the center of the model as possible. The exact alignment isn't nec, but it simplifies things somewhat.

The texture

The material defintition

Here is an example:

textures/darkmod/decals/vegetation/cattails_green4_side
{
    qer_editorimage textures/darkmod/decals/vegetation/cattail_flat_side
    surftype15
    description "foliage"

    twosided
    nonsolid

    {
        blend diffusemap
        map textures/darkmod/decals/vegetation/cattail_flat_side
        alphatest 0.5
    }

    // TDM Ambient Method Related
    {
        if (global5 == 1)
        blend add
        map             textures/darkmod/decals/vegetation/cattail_flat_side
        scale           1, 1
        red         global2
        green           global3
        blue            global4
    }
    {
        if (global5 == 2)
        blend add
        program ambientEnvironment.vfp
        vertexParm      0       1, 1, 1, 1      // UV Scales for Diffuse and Bump
        vertexParm      1       1, 1, 1, 1  // (X,Y) UV Scale for specular, Z: ambient reflection scale
        vertexParm      2       global2, global3, global4, 1
        vertexParm      3       0
        fragmentMap     0       cubeMap env/gen1
        fragmentMap     1       _black                                              // Bump
        fragmentMap     2       textures/darkmod/decals/vegetation/cattail_flat_side  // Diffuse
        fragmentMap     3       _black          // Specular
    }
}

Create the patches, export as ASE

The model in game

Optimizing

Texture atlas

Result in game

  • Comparisation
  • Performance test with entities

See also