I was looking at the other shaders by evolved, and was wondering about his relief shader.
Can it have more than six lights? Like 25 lights? If the lights are just being rendered by the shader then is there any hardware limitation on the number of lights that can be rendered? It seems that I could just make as many rendering passes as I want and have as many lights as I want in the scene.
Here is the code to his relief mapping:
//====================================================
// Relief Mapping
// By EVOLVED
//====================================================
//--------------
// un-tweaks
//--------------
matrix WorldVP:WorldViewProjection;
matrix World:World;
matrix ViewInv:ViewInverse;
//--------------
// tweaks
//--------------
float3 Ambient = {0.05f, 0.05f, 0.05f};
float3 LightPosition_1 = {0.0f, 50.0f, 0.0f};
float3 LightColor_1 = {1.0f, 1.0f, 1.0f};
float LightRange_1 = 55.0f;
float3 LightPosition_2 = {50.0f, 50.0f, 0.0f};
float3 LightColor_2 = {1.0f, 0.0f, 0.0f};
float LightRange_2 = 55.0f;
float3 LightPosition_3 = {100.0f, 50.0f, 0.0f};
float3 LightColor_3 = {0.0f, 1.0f, 0.0f};
float LightRange_3 = 55.0f;
float3 LightPosition_4 = {150.0f, 50.0f, 0.0f};
float3 LightColor_4 = {0.0f, 0.0f, 1.0f};
float LightRange_4 = 55.0f;
float3 LightPosition_5 = {0.0f, 50.0f, 50.0f};
float3 LightColor_5 = {1.0f, 1.0f, 1.0f};
float LightRange_5 = 55.0f;
float3 LightPosition_6 = {50.0f, 50.0f, 50.0f};
float3 LightColor_6 = {1.0f, 0.0f, 0.0f};
float LightRange_6 = 55.0f;
float3 FLightPosition = {150.0f, 150.0f, 0.0f};
float FLightRange = 1000.0f;
float3x3 FLightAngle;
float BrightNess = 1f;
float SpecularPow = 32.0f;
float depth = .1;
float Alpha = 1.0f;
//--------------
// Textures
//--------------
texture BaseTX
<
string Name="";
>;
sampler2D Base = sampler_state
{
texture = <BaseTX>;
};
texture NormalTX
<
string Name="";
>;
sampler2D Normal = sampler_state
{
texture = <NormalTX>;
};
texture CubeLightTX
<
string Name = "";
>;
sampler CubeLight = sampler_state
{
Texture = <CubeLightTX>;
};
//--------------
// structs
//--------------
struct input
{
float4 Pos:POSITION;
float2 UV:TEXCOORD;
float3 Normal:NORMAL;
float3 Tangent:TANGENT;
float3 Binormal:BINORMAL;
};
struct output
{
float4 OPos:POSITION;
float2 Tex:TEXCOORD0;
float3 LightVec:TEXCOORD1;
float3 Attenuation:TEXCOORD2;
float3 ViewVec:TEXCOORD3;
float3 ViewPos:TEXCOORD4;
float3 VNormal:TEXCOORD5;
float3 CubeLight:TEXCOORD6;
float Diffuse:COLOR0;
};
//--------------
// vertex shader
//--------------
output VS(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV;
OUT.LightVec=0;
OUT.Attenuation=0;
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
TBN=transpose(mul(TBN,World));
float3 WPos=mul(IN.Pos,World);
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.ViewVec=mul(ViewPos,TBN);
OUT.ViewPos=-ViewPos;
OUT.VNormal=mul(IN.Normal,World);
OUT.CubeLight=0;
OUT.Diffuse=0;
return OUT;
}
output VS_L1(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV;
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
TBN=transpose(mul(TBN,World));
float3 WPos=mul(IN.Pos,World);
float3 LightPos=LightPosition_1-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/LightRange_1;
OUT.ViewVec=mul(ViewPos,TBN);
OUT.ViewPos=-ViewPos;
OUT.VNormal=mul(IN.Normal,World);
OUT.CubeLight=0;
OUT.Diffuse=saturate(0.02f+mul(mul(IN.Normal,World),LightPos)*0.02f);
return OUT;
}
output VS_L2(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV;
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
TBN=transpose(mul(TBN,World));
float3 WPos=mul(IN.Pos,World);
float3 LightPos=LightPosition_2-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/LightRange_2;
OUT.ViewVec=mul(ViewPos,TBN);
OUT.ViewPos=-ViewPos;
OUT.VNormal=mul(IN.Normal,World);
OUT.CubeLight=0;
OUT.Diffuse=saturate(0.02f+mul(mul(IN.Normal,World),LightPos)*0.02f);
return OUT;
}
output VS_L3(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV;
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
TBN=transpose(mul(TBN,World));
float3 WPos=mul(IN.Pos,World);
float3 LightPos=LightPosition_3-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/LightRange_3;
OUT.ViewVec=mul(ViewPos,TBN);
OUT.ViewPos=-ViewPos;
OUT.VNormal=mul(IN.Normal,World);
OUT.CubeLight=0;
OUT.Diffuse=saturate(0.02f+mul(mul(IN.Normal,World),LightPos)*0.02f);
return OUT;
}
output VS_L4(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV;
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
TBN=transpose(mul(TBN,World));
float3 WPos=mul(IN.Pos,World);
float3 LightPos=LightPosition_4-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/LightRange_4;
OUT.ViewVec=mul(ViewPos,TBN);
OUT.ViewPos=-ViewPos;
OUT.VNormal=mul(IN.Normal,World);
OUT.CubeLight=0;
OUT.Diffuse=saturate(0.02f+mul(mul(IN.Normal,World),LightPos)*0.02f);
return OUT;
}
output VS_L5(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV;
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
TBN=transpose(mul(TBN,World));
float3 WPos=mul(IN.Pos,World);
float3 LightPos=LightPosition_5-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/LightRange_5;
OUT.ViewVec=mul(ViewPos,TBN);
OUT.ViewPos=-ViewPos;
OUT.VNormal=mul(IN.Normal,World);
OUT.CubeLight=0;
OUT.Diffuse=saturate(0.02f+mul(mul(IN.Normal,World),LightPos)*0.02f);
return OUT;
}
output VS_L6(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV;
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
TBN=transpose(mul(TBN,World));
float3 WPos=mul(IN.Pos,World);
float3 LightPos=LightPosition_6-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/LightRange_6;
OUT.ViewVec=mul(ViewPos,TBN);
OUT.ViewPos=-ViewPos;
OUT.VNormal=mul(IN.Normal,World);
OUT.CubeLight=0;
OUT.Diffuse=saturate(0.02f+mul(mul(IN.Normal,World),LightPos)*0.02f);
return OUT;
}
output VS_FL(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV;
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
TBN=transpose(mul(TBN,World));
float3 WPos=mul(IN.Pos,World);
float3 LightPos=FLightPosition-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/FLightRange;
OUT.ViewVec=mul(ViewPos,TBN);
OUT.ViewPos=-ViewPos;
OUT.VNormal=mul(IN.Normal,World);
OUT.CubeLight=mul(FLightAngle,-LightPos);
OUT.Diffuse=0;
return OUT;
}
//--------------
// pixel shader
//--------------
float GetDepth(in float2 Uv,in float2 Displace)
{
float Height=0.0;
float depth=1.0;
float Inc=0.125f;
for( int i=0;i<8;i++ )
{
Height+=Inc;
float HeightTex=tex2D(Normal,Uv+Displace*Height).w;
if (depth>0.995)
if (Height>=HeightTex) depth=Height;
}
Height=depth;
for( int i=0;i<4;i++ )
{
Inc*=0.5;
float HeightTex=tex2D(Normal,Uv+Displace*Height).w;
if (Height>=HeightTex)
{
depth=Height;
Height-=2*Inc;
}
Height=Height+Inc;
}
return depth;
}
float4 PS(output IN) : COLOR
{
float2 Uv=IN.Tex;
float3 View=normalize(IN.ViewVec);
float ViewN=dot(IN.VNormal,normalize(IN.ViewPos));
float2 Displace=(View*depth/ViewN).xy;
float Ray=GetDepth(Uv,Displace);
float2 NewUv=(Uv+Displace*Ray);
float3 Texture=tex2D(Base,NewUv);
return float4(Texture*Ambient,Alpha);
}
float4 PS_L1(output IN) : COLOR
{
float2 Uv=IN.Tex;
float3 View=normalize(IN.ViewVec);
float ViewN=dot(IN.VNormal,normalize(IN.ViewPos));
float2 Displace=(View*depth/ViewN).xy;
float Ray=GetDepth(Uv,Displace);
float2 NewUv=(Uv+Displace*Ray);
float3 Texture=tex2D(Base,NewUv);
float3 NormalMap=tex2D(Normal,NewUv)*2-1; NormalMap.y=-NormalMap.y;
NormalMap=normalize(NormalMap);
float3 LightV=normalize(IN.LightVec);
float Normal=saturate(dot(reflect(-View,NormalMap),LightV));
Normal=pow(Normal,SpecularPow)+saturate(dot(NormalMap,LightV));
float PixelLight=1-saturate(dot(IN.Attenuation,IN.Attenuation));
float3 Light=PixelLight*LightColor_1*IN.Diffuse;
return float4(Texture*((Normal*Light)+Ambient),Alpha);
}
float4 PS_L2(output IN) : COLOR
{
float2 Uv=IN.Tex;
float3 View=normalize(IN.ViewVec);
float ViewN=dot(IN.VNormal,normalize(IN.ViewPos));
float2 Displace=(View*depth/ViewN).xy;
float Ray=GetDepth(Uv,Displace);
float2 NewUv=(Uv+Displace*Ray);
float3 Texture=tex2D(Base,NewUv);
float3 NormalMap=tex2D(Normal,NewUv)*2-1; NormalMap.y=-NormalMap.y;
NormalMap=normalize(NormalMap);
float3 LightV=normalize(IN.LightVec);
float Normal=saturate(dot(reflect(-View,NormalMap),LightV));
Normal=pow(Normal,SpecularPow)+saturate(dot(NormalMap,LightV));
float PixelLight=1-saturate(dot(IN.Attenuation,IN.Attenuation));
float3 Light=PixelLight*LightColor_2*IN.Diffuse;
return float4(Texture*(Normal*Light),Alpha);
}
float4 PS_L3(output IN) : COLOR
{
float2 Uv=IN.Tex;
float3 View=normalize(IN.ViewVec);
float ViewN=dot(IN.VNormal,normalize(IN.ViewPos));
float2 Displace=(View*depth/ViewN).xy;
float Ray=GetDepth(Uv,Displace);
float2 NewUv=(Uv+Displace*Ray);
float3 Texture=tex2D(Base,NewUv);
float3 NormalMap=tex2D(Normal,NewUv)*2-1; NormalMap.y=-NormalMap.y;
NormalMap=normalize(NormalMap);
float3 LightV=normalize(IN.LightVec);
float Normal=saturate(dot(reflect(-View,NormalMap),LightV));
Normal=pow(Normal,SpecularPow)+saturate(dot(NormalMap,LightV));
float PixelLight=1-saturate(dot(IN.Attenuation,IN.Attenuation));
float3 Light=PixelLight*LightColor_3*IN.Diffuse;
return float4(Texture*(Normal*Light),Alpha);
}
float4 PS_L4(output IN) : COLOR
{
float2 Uv=IN.Tex;
float3 View=normalize(IN.ViewVec);
float ViewN=dot(IN.VNormal,normalize(IN.ViewPos));
float2 Displace=(View*depth/ViewN).xy;
float Ray=GetDepth(Uv,Displace);
float2 NewUv=(Uv+Displace*Ray);
float3 Texture=tex2D(Base,NewUv);
float3 NormalMap=tex2D(Normal,NewUv)*2-1; NormalMap.y=-NormalMap.y;
NormalMap=normalize(NormalMap);
float3 LightV=normalize(IN.LightVec);
float Normal=saturate(dot(reflect(-View,NormalMap),LightV));
Normal=pow(Normal,SpecularPow)+saturate(dot(NormalMap,LightV));
float PixelLight=1-saturate(dot(IN.Attenuation,IN.Attenuation));
float3 Light=PixelLight*LightColor_4*IN.Diffuse;
return float4(Texture*(Normal*Light),Alpha);
}
float4 PS_L5(output IN) : COLOR
{
float2 Uv=IN.Tex;
float3 View=normalize(IN.ViewVec);
float ViewN=dot(IN.VNormal,normalize(IN.ViewPos));
float2 Displace=(View*depth/ViewN).xy;
float Ray=GetDepth(Uv,Displace);
float2 NewUv=(Uv+Displace*Ray);
float3 Texture=tex2D(Base,NewUv);
float3 NormalMap=tex2D(Normal,NewUv)*2-1; NormalMap.y=-NormalMap.y;
NormalMap=normalize(NormalMap);
float3 LightV=normalize(IN.LightVec);
float Normal=saturate(dot(reflect(-View,NormalMap),LightV));
Normal=pow(Normal,SpecularPow)+saturate(dot(NormalMap,LightV));
float PixelLight=1-saturate(dot(IN.Attenuation,IN.Attenuation));
float3 Light=PixelLight*LightColor_5*IN.Diffuse;
return float4(Texture*(Normal*Light),Alpha);
}
float4 PS_L6(output IN) : COLOR
{
float2 Uv=IN.Tex;
float3 View=normalize(IN.ViewVec);
float ViewN=dot(IN.VNormal,normalize(IN.ViewPos));
float2 Displace=(View*depth/ViewN).xy;
float Ray=GetDepth(Uv,Displace);
float2 NewUv=(Uv+Displace*Ray);
float3 Texture=tex2D(Base,NewUv);
float3 NormalMap=tex2D(Normal,NewUv)*2-1; NormalMap.y=-NormalMap.y;
NormalMap=normalize(NormalMap);
float3 LightV=normalize(IN.LightVec);
float Normal=saturate(dot(reflect(-View,NormalMap),LightV));
Normal=pow(Normal,SpecularPow)+saturate(dot(NormalMap,LightV));
float PixelLight=1-saturate(dot(IN.Attenuation,IN.Attenuation));
float3 Light=PixelLight*LightColor_6*IN.Diffuse;
return float4(Texture*(Normal*Light),Alpha);
}
float4 PS_FL(output IN) : COLOR
{
float2 Uv=IN.Tex;
float3 View=normalize(IN.ViewVec);
float ViewN=dot(IN.VNormal,normalize(IN.ViewPos));
float2 Displace=(View*depth/ViewN).xy;
float Ray=GetDepth(Uv,Displace);
float2 NewUv=(Uv+Displace*Ray);
float3 Texture=tex2D(Base,NewUv);
float3 NormalMap=tex2D(Normal,NewUv)*2-1; NormalMap.y=-NormalMap.y;
NormalMap=normalize(NormalMap);
float3 LightV=normalize(IN.LightVec);
float Normal=saturate(dot(reflect(-View,NormalMap),LightV));
Normal=pow(Normal,SpecularPow)+saturate(dot(NormalMap,LightV));
float PixelLight=1-saturate(dot(IN.Attenuation,IN.Attenuation));
float3 Light=PixelLight*texCUBE(CubeLight,IN.CubeLight)*BrightNess;
return float4(Texture*(Normal*Light),Alpha);
}
//--------------
// techniques
//--------------
technique Ambient
{
pass p1
{
vertexShader = compile vs_2_0 VS();
pixelShader = compile ps_2_a PS();
}
}
technique Light1
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
}
technique Light2
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light3
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p3
{
vertexShader = compile vs_2_0 VS_L3();
pixelShader = compile ps_2_a PS_L3();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light4
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p3
{
vertexShader = compile vs_2_0 VS_L3();
pixelShader = compile ps_2_a PS_L3();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p4
{
vertexShader = compile vs_2_0 VS_L4();
pixelShader = compile ps_2_a PS_L4();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light5
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p3
{
vertexShader = compile vs_2_0 VS_L3();
pixelShader = compile ps_2_a PS_L3();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p4
{
vertexShader = compile vs_2_0 VS_L4();
pixelShader = compile ps_2_a PS_L4();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p5
{
vertexShader = compile vs_2_0 VS_L5();
pixelShader = compile ps_2_a PS_L5();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light6
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p3
{
vertexShader = compile vs_2_0 VS_L3();
pixelShader = compile ps_2_a PS_L3();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p4
{
vertexShader = compile vs_2_0 VS_L4();
pixelShader = compile ps_2_a PS_L4();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p5
{
vertexShader = compile vs_2_0 VS_L5();
pixelShader = compile ps_2_a PS_L5();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p6
{
vertexShader = compile vs_2_0 VS_L6();
pixelShader = compile ps_2_a PS_L6();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Ambient_FL
{
pass p1
{
vertexShader = compile vs_2_0 VS();
pixelShader = compile ps_2_a PS();
}
pass pFL
{
vertexShader = compile vs_2_0 VS_FL();
pixelShader = compile ps_2_a PS_FL();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light1_FL
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass pFL
{
vertexShader = compile vs_2_0 VS_FL();
pixelShader = compile ps_2_a PS_FL();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light2_FL
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass pFL
{
vertexShader = compile vs_2_0 VS_FL();
pixelShader = compile ps_2_a PS_FL();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light3_FL
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p3
{
vertexShader = compile vs_2_0 VS_L3();
pixelShader = compile ps_2_a PS_L3();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass pFL
{
vertexShader = compile vs_2_0 VS_FL();
pixelShader = compile ps_2_a PS_FL();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light4_FL
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p3
{
vertexShader = compile vs_2_0 VS_L3();
pixelShader = compile ps_2_a PS_L3();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p4
{
vertexShader = compile vs_2_0 VS_L4();
pixelShader = compile ps_2_a PS_L4();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass pFL
{
vertexShader = compile vs_2_0 VS_FL();
pixelShader = compile ps_2_a PS_FL();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light5_FL
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p3
{
vertexShader = compile vs_2_0 VS_L3();
pixelShader = compile ps_2_a PS_L3();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p4
{
vertexShader = compile vs_2_0 VS_L4();
pixelShader = compile ps_2_a PS_L4();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p5
{
vertexShader = compile vs_2_0 VS_L5();
pixelShader = compile ps_2_a PS_L5();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass pFL
{
vertexShader = compile vs_2_0 VS_FL();
pixelShader = compile ps_2_a PS_FL();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
technique Light6_FL
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_a PS_L1();
}
pass p2
{
vertexShader = compile vs_2_0 VS_L2();
pixelShader = compile ps_2_a PS_L2();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p3
{
vertexShader = compile vs_2_0 VS_L3();
pixelShader = compile ps_2_a PS_L3();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p4
{
vertexShader = compile vs_2_0 VS_L4();
pixelShader = compile ps_2_a PS_L4();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p5
{
vertexShader = compile vs_2_0 VS_L5();
pixelShader = compile ps_2_a PS_L5();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass p6
{
vertexShader = compile vs_2_0 VS_L6();
pixelShader = compile ps_2_a PS_L6();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
pass pFL
{
vertexShader = compile vs_2_0 VS_FL();
pixelShader = compile ps_2_a PS_FL();
AlphaBlendEnable = True;
SrcBlend = One;
DestBlend = One;
}
}
As you can see, if I'm not mistaken, he has six lights and a flashlight that uses a cube map for a filter. Then he has different rendering techniques dependent on the number of flashlights the programmer wants in the scene. All I would have to do is make more techniques for more lights. Unless there is a hardware limit to lights even when using a shader.