   Problems converting vertex lighting assembly to per pixel lighting HLSL
  Hi, i'm doing some modifications to Halo Custom Edition (PC) to add some new things to the graphics engine, and currently i'm trying to get normals maps onto the game objects such as vehicles and scenery. But i'm having a few problems.The game uses vertex lighting for its ingame models and I need to move that lighting into the pixel shader, but the vertex shaders are written in assembly and my attempts to convert them haven't been giving the correct results.The light attenuation code in the vertex shader is like so:add r4.xyz, c[15], -r0dp3 r4.w, r4, r4rsq r10.w, r4.wmul r4.xyz, r4, r10.wmad r8.x, r4.w, -c[15].w, v4.wdp3 r9.x, r4, r1 dp3 r10.w, r4, -c[16]mul r10.w, r10.w, c[16].wadd r8.z, r10.w, c[17].wr0 has the vertex world position, r1 has the vertex normal and v4 is texture coordinate 0.I don't know alot about lighting so i'm unsure as to what all of the constants contain, but my current conversion looks like this:sampler TexSampler4 : register(s4);struct PS_INPUT{float3 PositionWorld: COLOR0; float4 DiffuseMultiUV: TEXCOORD0; float3 Normal : TEXCOORD2; float3 BiNormal : TEXCOORD3; float3 Tangent : TEXCOORD4;};float4 c_object_point_light0_position : register(c[15]);float4 c_object_point_light0_rotation : register(c[16]);float4 c_object_point_light0_colour : register(c[17]);void Lighting(in PS_INPUT IN, out float4 Lighting){Lighting = 0;float3x3 WorldToTangentSpace;WorldToTangentSpace[0] = normalize(IN.Tangent);WorldToTangentSpace[1] = normalize(IN.BiNormal);WorldToTangentSpace[2] = normalize(IN.Normal);float4 PointLight0Vector = float4(mul(WorldToTangentSpace, c_object_point_light0_position.xyz - IN.PositionWorld), c_object_point_light0_position.w);float4 PointLight0Rotation = float4(mul(WorldToTangentSpace, c_object_point_light0_rotation.xyz), c_object_point_light0_rotation.w);float3 NormalBump = (2.0 * (tex2D( TexSampler4, IN.DiffuseMultiUV.xy ).xyz)) - 1.0;float3 VectorNorm;float2 PointAttenuation;//--VS Conversion--////dp3 r4.w, r4, r4//rsq r10.w, r4.w//mul r4.xyz, r4, r10.wVectorNorm = normalize(PointLight0Vector.xyz);//Distance attenuation?//mad r8.x, r4.w, -c[15+0].w, v4.wPointAttenuation.x = (dot(PointLight0Vector.xyz, PointLight0Vector.xyz) * -PointLight0Vector.w) + IN.DetailUV.w;    //Diffuse//dp3 r9.x, r4, r1PointAttenuation.x *= dot(NormalBump, VectorNorm);//Spotlight falloff//dp3 r10.w, r4, -c[15+1]//mul r10.w, r10.w, c[15+1].w//add r8.z, r10.w, c[15+2].wPointAttenuation.x *= (dot(VectorNorm, PointLight0Rotation.xyz) * PointLight0Rotation.w) + c_object_point_light0_colour.w;//--VS Conversion--//PointAttenuation = clamp(PointAttenuation, 0, 1);Lighting.xyz += (PointAttenuation.x * c_object_point_light0_colour.xyz);}I've cut out some code from this for multiple lights/reflections and such but I think the posted code is valid.The problems i've been having are better seen in pictures :).Spotlight pointing from the players left shoulder to the vehicle:Point Light from the end of the weapon:So i'm hoping someone can see where i've messed up and set me on the right track :).   