This is a simple shader I needed for my current scene. It is a detail mapping shader, which tiles an entity skin2 over entity skin1. In addition, a cubemap will be projected over it, to make it shiny/icy/whatever.

This is how it looks like in my scene. The white environment is using this shader (it has a shadowmap plus the snow as detailmap plus a cubemap to make it "icy"). The floes use the environmental mapping part without the tiling and the water is Slin's NVidia oceanshader. The water depth are stacked slight transparent planes to simulate water depth. The snow is a particle effect.



Copy this functional code into your shader file (or create a new shader.c/.h file for it):

Code:
void mtl_detailShiny_init();
void mtl_detailShiny_func();

char* MTL_DETAILSHINY_CUBEMAP = "detailShiny+6.tga";

MATERIAL* mtl_detailShiny = {
event = mtl_detailShiny_init;
flags = enable_view;
effect = "detailShiny.fx";
}

void mtl_detailShiny_init ()
{
//load cubemap
mtl.skin1 = bmap_create(MTL_DETAILSHINY_CUBEMAP);
bmap_to_cubemap(mtl.skin1);

mtl.event = mtl_detailShiny_func;
}

void mtl_detailShiny_func ()
{
mat_set(mtl.matrix, matViewInv);

mtl.matrix41 = 0;
mtl.matrix42 = 0;
mtl.matrix43 = 0;
}



Create a new textfile which is called "detailShiny.fx" and paste this code into it:

Code:
extern texture entSkin1;
extern texture entSkin2;
extern texture mtlSkin1;

extern float4x4 matMtl;

technique detailShiny
{
pass p0
{
Lighting = true;

//render model with skin1

Texture[0] = <entSkin1>;
ColorArg1[0] = Texture;
texcoordindex[0] = 0;

//tile skin2 over it

Texture[1] = <entSkin2>;
colorarg1[1] = Texture;
colorarg2[1] = current;
colorop[1] = modulate;
texcoordindex[1] = 0;
texturetransformflags[1] = count2;
texturetransform[1] = { 15.0,0.0,0.0,0.0, // tiles u
0.0,15.0,0.0,0.0, // tiles v
0.0,0.0,0.0,0.0,
0.0,0.0,0.0,0.0};

//apply transparent cubemap

texture[2]=<mtlSkin1>;
colorArg1[2]=Texture;

colorOp[2]=blendFactorAlpha;
textureFactor=0x25FFFFFF; //~15% cubemap alpha
//textureFactor=0x75FFFFFF; //~75%
//textureFactor=0x80FFFFFF; //~50%
//textureFactor=0x40FFFFFF; //~25%

addressU[2]=Clamp;
addressV[2]=Clamp;
texCoordIndex[2]=cameraSpaceReflectionVector;
textureTransformFlags[2]=Count3;
textureTransform[2]=<matMtl>;
}
};



Put into your modelfile (which should be rendered with the shader) the texture into skin1 and the detail texture into skin2. To use another cubemap, replace the char definition.

Because of the usage of both detail map and cubemap, the model could get slightly darker - you can troubleshoot it by raising the emmissive values of the material (I suggest to do this modelwise in the DirectX material definition).

Have fun with this!
Cheers, Christian