Ok, thx
I have a soultion, very fastidious but I see only it for my level.
float3 position_1;
float3 color_1;
float invRadius_1;
float3 position_2;
float3 color_2;
float invRadius_2;1
float4 ambientColor;
int screenWidth;
int screenHeight;
sampler ColorMap : register(s0);
sampler NormalMap : register(s1)
{
Texture = <normaltexture>;
};
float4 DeferredNormalPS(float4 Position : SV_Position, float4 Color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 base = tex2D(ColorMap, texCoord);
float3 normal = normalize(tex2D(NormalMap, texCoord) * 2.0f - 1.0f);
float3 PixelPosition = float3(screenWidth * texCoord.x, screenHeight * texCoord.y,0);
float3 finalresult = 0;
float3 Direction_1;
float Distance_1;
float3 Direction_2;
float Distance_2;
Direction_1 = position_1 - PixelPosition;
float lenght_1 = length(Direction_1);
Direction_1 /= lenght_1;
lenght_1 *= invRadius_1;
float modifer_1 = max((1 - lenght_1), 0);
float amount_1 = max(dot(normal, Direction_1), 0);
invRadius_1 = 1 / invRadius_1;
Distance_1 = saturate(length(Direction_1) * invRadius_1);
finalresult = (color_1 * amount_1 * modifer_1 * Distance_1);
//////////////////////////////////////////////////////////////////////////////////
Direction_2 = position_2 - PixelPosition;
float lenght_2 = length(Direction_2);
Direction_2 /= lenght_2;
lenght_2 *= invRadius_2;
float modifer_2 = max((1 - lenght_2), 0);
float amount_2 = max(dot(normal, Direction_2), 0);
//Direction *= normal;
invRadius_2 = 1 / invRadius_2;
Distance_2= saturate(length(Direction_2) * invRadius_2);
finalresult += (color_2 * amount_2 * modifer_2 * Distance_2);
return float4(((ambientColor * 1) + finalresult) * base.rgb ,base.a);
}
technique Deferred
{
pass Pass0
{
PixelShader = compile ps_4_0_level_9_1 DeferredNormalPS();
}
}
For 2 light source its not a problem, but with 50 light source its nonsense
Can you help me to use array in fx file ?
Thx