First of all thanks a lot for looking into the code Green.

Yes I was using the Normal Map Shaders of Ninja Matt, the NormalSpecular.fx shader is actually the NormalMap21.fx shader.

No changes have been done.

Concerning the main source code. The program currently loads the diffuse map into stage 0 and the normal map into stage 1. Other stages are not used at the moment.

Our coder implemented this search function which first looks up for the maps and then loads it to the object.

So it first searches for the color map, loads it to stage 0 and then searches for the normal map and loads it to stage 1.

The fx file is being loaded after the application of the texture to stage 0, afterwards the normal map is being loaded. Maybe that's another problem ?

Now the strange thing is that i have this normalmap21.fx shader which is different though from the one which is included in the shader pack.

Take a look

// Normalmap Specular Shader - 2.1
// by Ninja Matt
//------------------------------------
float4x4 WorldViewProj : WorldViewProjection;
float4x4 World : WorldIT;
float4 EyePos : EyePos;
//------------------------------------
float4 Light1Col <> = {1.0f, 1.0f, 1.0f, 1.0f};
float4 Light1Pos <> = {1.0f, -1.0f, 1.0f, 0.0f};
float4 Light2Col <> = {1.0f, 1.0f, 1.0f, 1.0f};
float4 Light2Pos <> = {1.0f, -1.0f, 1.0f, 0.0f};
float4 Light3Col <> = {1.0f, 1.0f, 1.0f, 1.0f};
float4 Light3Pos <> = {1.0f, -1.0f, 1.0f, 0.0f};
float4 Light4Col <> = {1.0f, 1.0f, 1.0f, 1.0f};
float4 Light4Pos <> = {1.0f, -1.0f, 1.0f, 0.0f};
float4 Light5Col <> = {1.0f, 1.0f, 1.0f, 1.0f};
float4 Light5Pos <> = {1.0f, -1.0f, 1.0f, 0.0f};
float4 Light6Col <> = {1.0f, 1.0f, 1.0f, 1.0f};
float4 Light6Pos <> = {1.0f, -1.0f, 1.0f, 0.0f};
float4 Light7Col <> = {1.0f, 1.0f, 1.0f, 1.0f};
float4 Light7Pos <> = {1.0f, -1.0f, 1.0f, 0.0f};
float4 Light8Col <> = {1.0f, 1.0f, 1.0f, 1.0f};
float4 Light8Pos <> = {1.0f, -1.0f, 1.0f, 0.0f};
texture BaseMap
<
string Name="";
>;
sampler2D Base = sampler_state
{
texture = <BaseMap>;
texture NormMap
<
string Name="";
>;
sampler2D Normal = sampler_state
{
texture = <NormMap>;
texture SpecMap
<
string Name="";
>;
sampler2D Normal = sampler_state
{
texture = <SpecMap>;
};
//------------------------------------
technique Lights2
{
pass OneTwo
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light1Pos>;
VertexShaderConstant[12] = <Light1Col>;
VertexShaderConstant[13] = <Light2Pos>;
VertexShaderConstant[14] = <Light2Col>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Scale and Bias Value
def c20, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
mov oT1, v2
// Output Light Colours
mov oD0, c12
mov oD1, c14
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 1
add r0, r0.xyz, -v0
// Normalise Light Vector 1
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 1 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c12.w
rcp oD0.w, r2
// Move Light Vector 1 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 1
add r1, r1, c20.x
mul oT2, r1, c20.y
// Move Light 2 to Object Space
mov r1, c13
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 2
add r0, r0, -v0
// Normalise Light Vector 2
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 2 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c14.w
rcp oD1.w, r2
// Move Light Vector 2 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 2
add r1, r1, c20.x
mul oT3, r1, c20.y
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
tex t1
// Get Per-Pixel Light Vectors
texcoord t2
texcoord t3
// DP3 Light Vector 1 and Colour It
dp3_sat r0, t1_bx2, t2_bx2
mul r0, r0, v0
mul r0, r0, v0.a
// DP3 Light Vector 2 and Colour It
dp3_sat r1, t1_bx2, t3_bx2
mul r1, r1, v1
mul r1, r1, v1.a
// Add Lights Together
add r0, r0, r1
// Multiply Diffuse with Lighting
mul r0, r0, t0
};
Texture[0] = <BaseMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[1] = <NormMap>;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = Linear;
AddressU[1] = Wrap;
AddressV[1] = Wrap;
AddressW[1] = Wrap;
}
pass SpecOne
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light1Pos>;
VertexShaderConstant[12] = <Light1Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
def c22, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecTwo
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light2Pos>;
VertexShaderConstant[12] = <Light2Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
};
//------------------------------------
technique Lights4
{
pass OneTwo
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light1Pos>;
VertexShaderConstant[12] = <Light1Col>;
VertexShaderConstant[13] = <Light2Pos>;
VertexShaderConstant[14] = <Light2Col>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Scale and Bias Value
def c20, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
mov oT1, v2
// Output Light Colours
mov oD0, c12
mov oD1, c14
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 1
add r0, r0.xyz, -v0
// Normalise Light Vector 1
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 1 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c12.w
rcp oD0.w, r2
// Move Light Vector 1 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 1
add r1, r1, c20.x
mul oT2, r1, c20.y
// Move Light 2 to Object Space
mov r1, c13
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 2
add r0, r0, -v0
// Normalise Light Vector 2
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 2 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c14.w
rcp oD1.w, r2
// Move Light Vector 2 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 2
add r1, r1, c20.x
mul oT3, r1, c20.y
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
tex t1
// Get Per-Pixel Light Vectors
texcoord t2
texcoord t3
// DP3 Light Vector 1 and Colour It
dp3_sat r0, t1_bx2, t2_bx2
mul r0, r0, v0
mul r0, r0, v0.a
// DP3 Light Vector 2 and Colour It
dp3_sat r1, t1_bx2, t3_bx2
mul r1, r1, v1
mul r1, r1, v1.a
// Add Lights Together
add r0, r0, r1
// Multiply Diffuse with Lighting
mul r0, r0, t0
};
Texture[0] = <BaseMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[1] = <NormMap>;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = Linear;
AddressU[1] = Wrap;
AddressV[1] = Wrap;
AddressW[1] = Wrap;
}
pass ThreeFour
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light3Pos>;
VertexShaderConstant[12] = <Light3Col>;
VertexShaderConstant[13] = <Light4Pos>;
VertexShaderConstant[14] = <Light4Col>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Scale and Bias Value
def c20, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
mov oT1, v2
// Output Light Colours
mov oD0, c12
mov oD1, c14
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 1
add r0, r0.xyz, -v0
// Normalise Light Vector 1
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 1 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c12.w
rcp oD0.w, r2
// Move Light Vector 1 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 1
add r1, r1, c20.x
mul oT2, r1, c20.y
// Move Light 2 to Object Space
mov r1, c13
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 2
add r0, r0, -v0
// Normalise Light Vector 2
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 2 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c14.w
rcp oD1.w, r2
// Move Light Vector 2 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 2
add r1, r1, c20.x
mul oT3, r1, c20.y
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
tex t1
// Get Per-Pixel Light Vectors
texcoord t2
texcoord t3
// DP3 Light Vector 1 and Colour It
dp3_sat r0, t1_bx2, t2_bx2
mul r0, r0, v0
mul r0, r0, v0.a
// DP3 Light Vector 2 and Colour It
dp3_sat r1, t1_bx2, t3_bx2
mul r1, r1, v1
mul r1, r1, v1.a
// Add Lights Together
add r0, r0, r1
// Multiply Diffuse with Lighting
mul r0, r0, t0
};
Texture[0] = <BaseMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[1] = <NormMap>;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = Linear;
AddressU[1] = Wrap;
AddressV[1] = Wrap;
AddressW[1] = Wrap;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecOne
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light1Pos>;
VertexShaderConstant[12] = <Light1Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
def c22, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecTwo
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light2Pos>;
VertexShaderConstant[12] = <Light2Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecThree
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light3Pos>;
VertexShaderConstant[12] = <Light3Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecFour
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light4Pos>;
VertexShaderConstant[12] = <Light4Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
};
//------------------------------------
technique Lights8
{
pass OneTwo
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light1Pos>;
VertexShaderConstant[12] = <Light1Col>;
VertexShaderConstant[13] = <Light2Pos>;
VertexShaderConstant[14] = <Light2Col>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Scale and Bias Value
def c20, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
mov oT1, v2
// Output Light Colours
mov oD0, c12
mov oD1, c14
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 1
add r0, r0.xyz, -v0
// Normalise Light Vector 1
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 1 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c12.w
rcp oD0.w, r2
// Move Light Vector 1 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 1
add r1, r1, c20.x
mul oT2, r1, c20.y
// Move Light 2 to Object Space
mov r1, c13
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 2
add r0, r0, -v0
// Normalise Light Vector 2
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 2 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c14.w
rcp oD1.w, r2
// Move Light Vector 2 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 2
add r1, r1, c20.x
mul oT3, r1, c20.y
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
tex t1
// Get Per-Pixel Light Vectors
texcoord t2
texcoord t3
// DP3 Light Vector 1 and Colour It
dp3_sat r0, t1_bx2, t2_bx2
mul r0, r0, v0
mul r0, r0, v0.a
// DP3 Light Vector 2 and Colour It
dp3_sat r1, t1_bx2, t3_bx2
mul r1, r1, v1
mul r1, r1, v1.a
// Add Lights Together
add r0, r0, r1
// Multiply Diffuse with Lighting
mul r0, r0, t0
};
Texture[0] = <BaseMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[1] = <NormMap>;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = Linear;
AddressU[1] = Wrap;
AddressV[1] = Wrap;
AddressW[1] = Wrap;
}
pass ThreeFour
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light3Pos>;
VertexShaderConstant[12] = <Light3Col>;
VertexShaderConstant[13] = <Light4Pos>;
VertexShaderConstant[14] = <Light4Col>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Scale and Bias Value
def c20, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
mov oT1, v2
// Output Light Colours
mov oD0, c12
mov oD1, c14
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 1
add r0, r0.xyz, -v0
// Normalise Light Vector 1
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 1 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c12.w
rcp oD0.w, r2
// Move Light Vector 1 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 1
add r1, r1, c20.x
mul oT2, r1, c20.y
// Move Light 2 to Object Space
mov r1, c13
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 2
add r0, r0, -v0
// Normalise Light Vector 2
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 2 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c14.w
rcp oD1.w, r2
// Move Light Vector 2 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 2
add r1, r1, c20.x
mul oT3, r1, c20.y
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
tex t1
// Get Per-Pixel Light Vectors
texcoord t2
texcoord t3
// DP3 Light Vector 1 and Colour It
dp3_sat r0, t1_bx2, t2_bx2
mul r0, r0, v0
mul r0, r0, v0.a
// DP3 Light Vector 2 and Colour It
dp3_sat r1, t1_bx2, t3_bx2
mul r1, r1, v1
mul r1, r1, v1.a
// Add Lights Together
add r0, r0, r1
// Multiply Diffuse with Lighting
mul r0, r0, t0
};
Texture[0] = <BaseMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[1] = <NormMap>;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = Linear;
AddressU[1] = Wrap;
AddressV[1] = Wrap;
AddressW[1] = Wrap;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass FiveSix
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light5Pos>;
VertexShaderConstant[12] = <Light5Col>;
VertexShaderConstant[13] = <Light6Pos>;
VertexShaderConstant[14] = <Light6Col>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Scale and Bias Value
def c20, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
mov oT1, v2
// Output Light Colours
mov oD0, c12
mov oD1, c14
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 1
add r0, r0.xyz, -v0
// Normalise Light Vector 1
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 1 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c12.w
rcp oD0.w, r2
// Move Light Vector 1 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 1
add r1, r1, c20.x
mul oT2, r1, c20.y
// Move Light 2 to Object Space
mov r1, c13
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 2
add r0, r0, -v0
// Normalise Light Vector 2
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 2 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c14.w
rcp oD1.w, r2
// Move Light Vector 2 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 2
add r1, r1, c20.x
mul oT3, r1, c20.y
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
tex t1
// Get Per-Pixel Light Vectors
texcoord t2
texcoord t3
// DP3 Light Vector 1 and Colour It
dp3_sat r0, t1_bx2, t2_bx2
mul r0, r0, v0
mul r0, r0, v0.a
// DP3 Light Vector 2 and Colour It
dp3_sat r1, t1_bx2, t3_bx2
mul r1, r1, v1
mul r1, r1, v1.a
// Add Lights Together
add r0, r0, r1
// Multiply Diffuse with Lighting
mul r0, r0, t0
};
Texture[0] = <BaseMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[1] = <NormMap>;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = Linear;
AddressU[1] = Wrap;
AddressV[1] = Wrap;
AddressW[1] = Wrap;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SevenEight
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light7Pos>;
VertexShaderConstant[12] = <Light7Col>;
VertexShaderConstant[13] = <Light8Pos>;
VertexShaderConstant[14] = <Light8Col>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Scale and Bias Value
def c20, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
mov oT1, v2
// Output Light Colours
mov oD0, c12
mov oD1, c14
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 1
add r0, r0.xyz, -v0
// Normalise Light Vector 1
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 1 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c12.w
rcp oD0.w, r2
// Move Light Vector 1 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 1
add r1, r1, c20.x
mul oT2, r1, c20.y
// Move Light 2 to Object Space
mov r1, c13
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Find Light Vector 2
add r0, r0, -v0
// Normalise Light Vector 2
dp3 r1, r0, r0
rsq r1, r1
mul r0, r0, r1
// Compute Light 2 Quadratic Falloff
rcp r1, r1
mul r2, r1, r1
mul r2, r2, c14.w
rcp oD1.w, r2
// Move Light Vector 2 to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale and Bias Vector 2
add r1, r1, c20.x
mul oT3, r1, c20.y
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
tex t1
// Get Per-Pixel Light Vectors
texcoord t2
texcoord t3
// DP3 Light Vector 1 and Colour It
dp3_sat r0, t1_bx2, t2_bx2
mul r0, r0, v0
mul r0, r0, v0.a
// DP3 Light Vector 2 and Colour It
dp3_sat r1, t1_bx2, t3_bx2
mul r1, r1, v1
mul r1, r1, v1.a
// Add Lights Together
add r0, r0, r1
// Multiply Diffuse with Lighting
mul r0, r0, t0
};
Texture[0] = <BaseMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[1] = <NormMap>;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = Linear;
AddressU[1] = Wrap;
AddressV[1] = Wrap;
AddressW[1] = Wrap;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecOne
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light1Pos>;
VertexShaderConstant[12] = <Light1Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
def c22, 1.0f, 0.5f, 0.0f, 0.0f
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecTwo
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light2Pos>;
VertexShaderConstant[12] = <Light2Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecThree
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light3Pos>;
VertexShaderConstant[12] = <Light3Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecFour
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light4Pos>;
VertexShaderConstant[12] = <Light4Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecFive
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light5Pos>;
VertexShaderConstant[12] = <Light5Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecSix
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light6Pos>;
VertexShaderConstant[12] = <Light6Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecSeven
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light7Pos>;
VertexShaderConstant[12] = <Light7Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass SpecEight
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[11] = <Light8Pos>;
VertexShaderConstant[12] = <Light8Col>;
VertexShaderConstant[20] = <EyePos>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
// Transform Position to Clip
m4x4 oPos, v0, c0
// Output Texture Coordinates
mov oT0, v2
// Move Eye Position to Object Space
mov r1, c20
dp3 r4.x, r1, c4
dp3 r4.y, r1, c5
dp3 r4.z, r1, c6
// Compute Normalised Eye Vector
add r4, r4.xyz, -v0
dp3 r4.w, r4, r4
rsq r4.w, r4.w
mul r4, r4, r4.w
// Move Light 1 to Object Space
mov r1, c11
dp3 r0.x, r1, c4
dp3 r0.y, r1, c5
dp3 r0.z, r1, c6
// Compute Normalised Light Vector
add r0, r0.xyz, -v0
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Compute Normalised Half-Vector
add r1, r0, r4
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
// Move Half-Vector to Texture Space
dp3 r0.x, r1, v3
dp3 r0.y, r1, v4
dp3 r0.z, r1, v1
// Output Half-Vector and Colour
mov oT1, r0
mov oD0, c12
};
PixelShader = asm
{
// Initialise Shader
ps.1.1
// Read Texture Data
tex t0
// Perform DP3 Normal Map
texm3x2pad t1, t0_bx2
texm3x2tex t2, t0_bx2
// Multiply by Specularity Map and Colour
mul r0, t2, t0.a
mul r0, r0, v0
};
Texture[0] = <NormMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
AddressU[0] = Wrap;
AddressV[0] = Wrap;
AddressW[0] = Wrap;
Texture[2] = <SpecMap>;
MinFilter[2] = Linear;
MagFilter[2] = Linear;
MipFilter[2] = Linear;
AddressU[2] = Clamp;
AddressV[2] = Clamp;
AddressW[2] = Clamp;
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
};

This is what I currently have in the FX folder under the name Normalspecular.fx

Now I don't really mind which one will be used, the Shader which I just posted or the NormalMap22.fx Shader.

I just want the program working with Normalmaps and Specular maps.

I've been spending hours over hours the past days trying to get this to work. I'm at the point were I'm really starting to get frustrated since it leads to nowhere and I'm just an GFX Artist and no programmer.

Well...thanks a lot for the time Green. Would be really great if you could work something out.

[MOD EDIT]I've fixed your code tags for you

IanM