Detailmapping for Models

From GameStudio Wiki

Jump to: navigation, search

(under this one is a version using a lightmap and a second UV set through ventilators plugin)

Your model needs 2 textures:

  1. the models diffuse texture
  2. the detailmap to use
material detailmapping_mtl
{
	effect=
	"
	texture entSkin1;
	texture entSkin2;

	technique t0
	{
		pass p0
		{
			Texture[0] = <entSkin1>;
			Texture[1] = <entSkin2>;
			
			colorarg1[0] = Texture;  // color map
			colorop[0] = selectarg1;
			texcoordindex[0] = 0;
			
			colorarg1[1] = Texture;  // detail map
			colorarg2[1] = current;  // color map
			colorop[1] = addsigned;  // add detail map to color map
			texcoordindex[1] = 0;
			texturetransformflags[1] = count2;
			texturetransform[1] = { 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[1]=linear;
			minfilter[1]=linear;
			mipfilter[1]=linear;

			colorarg1[2] = Diffuse;    // (shadow map + vertex lighting)
			colorarg2[2] = current; // (color map + detail map)
			colorop[2] = modulate;	// modulate (color map + detail map) with (shadow map + vertex lighting)
			magfilter[2] = linear;
			minfilter[2] = linear;
			mipfilter[2] = linear;
		}
	}
	";
}


This version with lightmap needs a model with a second UV set. This can be realised using the plugin written by ventilator [1].

The model needs three skins:

  1. the diffuse texture
  2. the lightmap
  3. the detailmap
material detailmapping_mtl
{
	effect=
	"
	texture entSkin1;
	texture entSkin2;
	texture entSkin3;

	technique t0
	{
		pass p0
		{
			Texture[0] = <entSkin2>;
			Texture[1] = <entSkin1>;
			Texture[2] = <entSkin3>;
			
			
			// mix light map with dynamic lighting 
			TexCoordIndex[0] = 1;
			ColorArg1[0] = Texture;
			ColorOp[0] = AddSigned;
			ColorArg2[0] = Diffuse;
			resultarg[0] = temp;     // output to temp register
			
			
			colorarg1[1] = Texture;  // color map
			colorop[1] = selectarg1;
			texcoordindex[1] = 0;


			colorarg1[2] = Texture;  // detail map
			colorarg2[2] = current;  // color map
			colorop[2] = addsigned;  // add detail map to color map
			texcoordindex[2] = 0;
			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] = modulate; // modulate (color map + detail map) with (shadow map + vertex lighting)
			magfilter[3] = linear;
			minfilter[3] = linear;
			mipfilter[3] = linear;
		}
	}
	";
}
Personal tools