Courtesy of Matt_AufderHeide :

Here is a basic HLSL shader:
Code:

//this is the only matrix you need for this shader.. world*view*projection
float4x4 matWorldViewProj;

here is the vertex shader output
struct VS_OUTPUT
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;
};

//simple vertex shader calculates the vertex position and tex coords
VS_OUTPUT mainVS( float4 Pos : POSITION, float2 Tex : TEXCOORD0 )
{
VS_OUTPUT Out = (VS_OUTPUT) 0;
Out.Pos = mul(Pos,matWorldViewProj );
Out.Tex = Tex;
return Out;
}

texture entSkin1;

//define the sampler for the entity skin
sampler basemap = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = clamp;
AddressV = clamp;
};


// Simple pixel shader samples the entity skin according to Tex.xy coords
float4 mainPS(float2 Tex: TEXCOORD0) : COLOR
{
Color = tex2D( basemap, Tex.xy);
return Color;
}

technique blur
{

pass Object
{
alphablendenable=false;
ZENABLE = TRUE;
VertexShader = compile vs_1_1 mainVS();
PixelShader = compile ps_2_0 mainPS();
}

}



The vertex shader just calculates the vertex position according to the projection matrix and passes the texture coords to the pixel shader. The pixel shader just colors the pixel depending on the texture coords and the ent skin.

This is the about the most basic a shader you can get, and will render an unshaded, textured model. But the structure is what's important here.

If you understand this shader.. then you can simply start adding other effects into it, such as a vertex lighting, and detail mapping. To do detail mapping, simply make another skin (and put into entskin2 in MED)like a greyscale texture of metal rust or something and then add anoter sampler like this:
Code:

sampler detailmap = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap; //you want it wrap because it will be scaled smaller
AddressV = wrap;
};


to add detail mapping coords you can either caluculate them in the vertex shader and pass a second set of tex coords, or you can just multiply the tex.xy in the pixel shader. For simplicity's sake let's do the latter:

Code:

// pixel shader that does detail mapping
float4 mainPS(float2 Tex: TEXCOORD0) : COLOR
{
Color =

//sample base color
tex2D( basemap, Tex.xy) *

//multiply with the detail texture and scale the texture coords
tex2D(detailmap,(Tex.xy*5));

return Color;
}