Hi i was wondering if anyone could help me out with this, ive tried a lot of stuff and just cant get it to work.

Im trying to convert this normal map shader that jcl posted to include cubic environment mapping with an alpha channel.

#include <transform>
#include <fog>
#include <pos>
#include <normal>
#include <tangent>
// #define INDOOR
#ifdef INDOOR
#include <light>
#else
float4 vecSunDir;
float4 vecSunColor;
#endif
float4 vecLight;

texture entSkin1; // texture
texture entSkin2; // normal map
texture mtlSkin1;

// const float facAmbient = 1.0; // factors to play with
// const float facBump = 3.4;
// const float facSpecular = 2.3;
float4 vecSkill1;

sampler sBaseTex = sampler_state { Texture = <entSkin1>; };
sampler sBump = sampler_state { Texture = <entSkin2>; };

struct out_specular
{
float4 Pos: POSITION;
float Fog: FOG;
float4 Color: COLOR0;
float4 Ambient: COLOR1;
float2 Tex: TEXCOORD0;
float2 Bump: TEXCOORD1;
float3 Light: TEXCOORD2;
float3 Halfway:TEXCOORD3;
};

out_specular vs_specular(
in float4 inPos: POSITION,
in float3 inNormal: NORMAL,
in float2 inTex: TEXCOORD0,
in float3 inTangent: TEXCOORD2)
{
out_specular Out;

Out.Pos = DoTransform(inPos);
Out.Tex = inTex;
Out.Bump = inTex; // different coordinate sets required for ps_1_1
Out.Ambient = vecSkill1.x*vecLight;
Out.Fog = DoFog(inPos);

float3 P = DoPos(inPos);
#ifdef INDOOR
float3 LDir = normalize(vecLightPos[0].xyz - P);
float fDist = length(vecLightPos[0].xyz - P)/vecLightPos[0].w;
if (fDist < 1.f)
fDist = 1.f - fDist;
else
fDist = 0.f;
Out.Color = vecSkill1.z*fDist*vecLightColor[0];
#else
float3 LDir = -vecSunDir;
Out.Color = vecSkill1.z*vecSunColor;
#endif

CreateTangents(inNormal,inTangent);

// transform the output values into the 0..1 range
Out.Light = vecSkill1.y*DoTangent(LDir) * 0.5 + 0.5;

float3 EyeDir = normalize(vecViewPos - P) + LDir;
Out.Halfway = DoTangent(EyeDir) * 0.5 + 0.5;

return Out;
}


float4 ps_specular(out_specular In): COLOR
{
float4 base = tex2D(sBaseTex,In.Tex);
float3 bumpNormal = tex2D(sBump,In.Bump);
float light = saturate(dot(In.Halfway*2 - 1,bumpNormal*2 - 1));
light *= light;
light *= light;
light *= light;
light *= light;
light += saturate(dot(In.Light*2 - 1,bumpNormal*2 - 1));
return base * (In.Ambient + light*In.Color);
}

technique specular
{
pass One
{
VertexShader = compile vs_1_1 vs_specular();
PixelShader = compile ps_1_1 ps_specular();
}
}

If anyone has any tips or anything that could help i would greatly appreciate it, thanks in advance.