Tiago,
I am using the same model that comes with the book that has the example shader in it so I am assuming it' tangents are all OK. If you can think of any other reason why the behavior of this shader should change when neither the shader the model or the assets have not altered I would appreciate it

I think I know why it is playing up now and that is down to the way i is currently calculating the Specular, I think the next chapter holds the answer....
EclipsE,
The bumpmap shader is already here, but this is the parallax bumpmap.
float4x4 wvp;
float4x4 world;
float3 LightPosition;
float3 EyePosition;
struct VS_OUTPUT
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;
float3 Light : TEXCOORD1;
float3 View : TEXCOORD2;
};
VS_OUTPUT VS(float4 Pos : POSITION,float2 Tex : TEXCOORD,float3 Normal : NORMAL,float3 Tangent : TANGENT)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
Out.Pos = mul(Pos,wvp);
float3x3 worldToTangentSpace;
worldToTangentSpace[0] = mul(Tangent,world);
worldToTangentSpace[1] = mul(cross(Tangent,Normal),world);
worldToTangentSpace[2] = mul(Normal,world);
Out.Tex = Tex;
float4 PosWorld = mul(Pos,world);
Out.Light = mul(worldToTangentSpace,LightPosition);
Out.View = mul(worldToTangentSpace,EyePosition - PosWorld);
return Out;
}
texture ColorMap;
sampler ColorMapSampler = sampler_state
{
Texture = <ColorMap>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
texture BumpMap;
sampler BumpMapSampler = sampler_state
{
Texture = <BumpMap>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
texture HeightMap;
sampler HeightMapSampler = sampler_state
{
Texture = <HeightMap>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
float4 PS(float2 Tex : TEXCOORD0,float3 Light : TEXCOORD1,float3 View : TEXCOORD2) : COLOR
{
const float scale = {0.04f};
const float bias = {0.02};
float3 LightDir = normalize(-Light);
float3 ViewDir = normalize(View);
float Height = scale * tex2D(HeightMapSampler,Tex) - bias;
float2 TexCorrected = Height * ViewDir + Tex;
float4 Color;
float3 Normal;
Color = tex2D(ColorMapSampler,TexCorrected);
Normal = (2 * (tex2D(BumpMapSampler,TexCorrected))) - 1.0;
float Diff = saturate(dot(Normal,LightDir));
return 0.2 * Color + Color * Diff;
}
technique BumpMapShader
{
pass P0
{
Sampler[0] = (ColorMapSampler);
Sampler[1] = (BumpMapSampler);
VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_2_0 PS();
}
}
In both shaders, please forgive my lack of Semantics and comments, I am writing them then testing them as I go and will tidy them up later. Just thought, I just said I am writing them, I'm not, I am doing the examples from the book and then getting them to fit my engine... How my ego keeps trying to build me up :

Also, your model needs the UV image of the ColorMap for some reason, I will alter the shader at a later date so this can be passed to the shader rather than it relying on the model having it loaded.
Mike/Chr0n1x,
I think I should have put this thread in the code section now, any chance you guys can move it? Unless you think it is OK here...