i'm trying to add dynamic lights to a static light shader, i want to include support for all 8 lights, but how do i do it? i started working on being able to move through each light, but i don't know how to set it to use all of the lights around you:
Code:
float4 SpecularIntensity = {2.0f, 2.0f, 2.0f, 2.0f};
// Application fed data:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matWorldInv;
float4 vecAmbient;
float4 vecLightPos[8];
float4 vecLight[8];
float vecLightColor[8];
float3 vecViewDir;
float3 vecViewPos;
texture entSkin1;
texture entSkin2;
samplerCUBE CubeMapSampler = sampler_state
{
Texture=<entSkin2>;
};
sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
AddressU = Clamp;
AddressV = Clamp;
};
void SpecularCubeVS(in float4 InPos : POSITION,
in float3 InNormal : NORMAL,
in float2 InTex : TEXCOORD0,
out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0,
out float3 OutTexCube : TEXCOORD1,
out float3 OutNormal: TEXCOORD2,
out float3 OutViewDir: TEXCOORD3)
{
OutPos = mul(InPos, matWorldViewProj);
OutNormal = normalize(mul(InNormal,matWorld));
OutViewDir = mul(InPos, matWorld);
OutTex = InTex;
float3 V = normalize(vecViewDir);
float3 N = normalize(mul(InNormal, matWorld));
OutTexCube = reflect(V,N);
}
float number;
float4 SpecularCubePS( in float2 InTex : TEXCOORD0,
in float3 InTexCube : TEXCOORD1,
in float3 InNormal : TEXCOORD2,
in float4 InViewDir : TEXCOORD3) : COLOR
{
number = 1;
InNormal = normalize(InNormal);
float4 Ambient = vecLight[number];
float4 Diffuse = saturate(dot(vecLightColor[1], InNormal));
float4 texColor = tex2D(ColorMapSampler, InTex);
float4 cubeColor = texCUBE(CubeMapSampler, InTexCube);
float4 Color = lerp(texColor, cubeColor, 1 - texColor.a);
float3 R = normalize(2 * dot(InNormal, vecLightColor[number] + SpecularIntensity) * InNormal - SpecularIntensity);
InViewDir = vecLightPos[number] + SpecularIntensity *vecLight[number];
float Specular = saturate(dot(R, InViewDir));
return (Ambient + Diffuse + Specular) * Color;
}
technique SpecularCubeTechnique
{
pass P0
{
AlphaBlendEnable = False;
ZWriteEnable = True;
VertexShader = compile vs_2_0 SpecularCubeVS();
PixelShader = compile ps_2_0 SpecularCubePS();
}
}
as you can see i can set it to 1 light, but no more...i can set the number of the light it uses, but that's all...