Detailmapping for Levelgeometrie

From GameStudio Wiki

Jump to: navigation, search

With this material you can add detail maps to level textures. (at the end of this tutorial are some tips for creating detail maps -> http://www.gamasutra.com/features/20010523/hajba_01.htm)

var d3d_automaterial=1;

bmap b_detail1=<detail1.tga>;

function init_detail_mapping
{
  bmap_to_mipmap(mtl.skin1);
}

material checker1 // material name = level surface texture name
{
  event=init_detail_mapping;
  skin1=b_detail1;
  effect=
  "
    texture entSkin1;
    texture entSkin2;
    texture mtlSkin1;
    technique detail_mapping
    {
      pass p0
      {
        Texture[0] = <entSkin2>;
        Texture[1] = <entSkin1>;
        Texture[2] = <mtlSkin1>;


        ColorArg1[0] = Texture;  // shadow map
        ColorArg2[0] = Diffuse;  // vertex lighting
        ColorOp[0] = Add;        // add vertex lighting to shadow map
        ResultArg[0] = temp;     // output to temp register


        ColorArg1[1] = Texture;  // color map
        ColorOp[1] = SelectArg1;


        ColorArg1[2] = Texture;  // detail map
        ColorArg2[2] = Current;  // color map
        ColorOp[2] = AddSigned;  // add detail map to color map
        TexcoordIndex[2] = 1;
        TextureTransformFlags[2] = count2;
        TextureTransform[2] = {8.0,0.0,0.0,0.0, // detail map u scale
                             0.0,8.0,0.0,0.0, // detail map v scale
                             0.0,0.0,0.0,0.0,
                             0.0,0.0,0.0,0.0};
        magfilter[2] = linear;
        minfilter[2] = linear;
        mipfilter[2] = linear;


        ColorArg1[3] = temp;     // (shadow map + vertex lighting)
        ColorArg2[3] = Current;  // (color map + detail map)
        ColorOp[3] = Modulate2x; // modulate (color map + detail map) with (shadow map + vertex lighting)
        magfilter[3] = linear;
        minfilter[3] = linear;
        mipfilter[3] = linear;
      }
    }
  ";
}

in some distance the detail map can be a bit noisy. i found no way to fix this. maybe it happens because a6 only uses 4 mipmap stages instead of going down to one pixel?

Personal tools