mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00
Remove branching from ShaderLight as well
This commit is contained in:
parent
d6cf25f16e
commit
2ee37ea7de
1 changed files with 15 additions and 21 deletions
|
@ -428,31 +428,25 @@ float3 CombineLights(float3 ambient, float3 vertex, float3 tex, float3 pos, floa
|
||||||
|
|
||||||
for (int i = 0; i < numLights; i++)
|
for (int i = 0; i < numLights; i++)
|
||||||
{
|
{
|
||||||
int lightType = lights[i].Type;
|
float isPoint = step(0.5f, float(lights[i].Type == LT_POINT));
|
||||||
|
float isShadow = step(0.5f, float(lights[i].Type == LT_SHADOW));
|
||||||
|
float isSun = step(0.5f, float(lights[i].Type == LT_SUN));
|
||||||
|
float isSpot = step(0.5f, float(lights[i].Type == LT_SPOT));
|
||||||
|
|
||||||
if (lightType == LT_POINT)
|
diffuse += isPoint * DoPointLight(pos, normal, lights[i]);
|
||||||
{
|
spec += isPoint * DoSpecularPoint(pos, normal, lights[i], sheen);
|
||||||
diffuse += DoPointLight(pos, normal, lights[i]);
|
|
||||||
spec += DoSpecularPoint(pos, normal, lights[i], sheen);
|
shadow += isShadow * DoShadowLight(pos, normal, lights[i]);
|
||||||
}
|
|
||||||
else if (lightType == LT_SHADOW)
|
diffuse += isSun * DoDirectionalLight(pos, normal, lights[i]);
|
||||||
{
|
spec += isSun * DoSpecularSun(normal, lights[i], sheen);
|
||||||
shadow += DoShadowLight(pos, normal, lights[i]);
|
|
||||||
}
|
diffuse += isSpot * DoSpotLight(pos, normal, lights[i]);
|
||||||
else if (lightType == LT_SUN)
|
spec += isSpot * DoSpecularSpot(pos, normal, lights[i], sheen);
|
||||||
{
|
|
||||||
diffuse += DoDirectionalLight(pos, normal, lights[i]);
|
|
||||||
spec += DoSpecularSun(normal, lights[i], sheen);
|
|
||||||
}
|
|
||||||
else if (lightType == LT_SPOT)
|
|
||||||
{
|
|
||||||
diffuse += DoSpotLight(pos, normal, lights[i]);
|
|
||||||
spec += DoSpecularSpot(pos, normal, lights[i], sheen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shadow = saturate(shadow);
|
shadow = saturate(shadow);
|
||||||
diffuse.xyz *= tex.xyz;
|
diffuse *= tex;
|
||||||
|
|
||||||
float3 ambTex = saturate(ambient - shadow) * tex;
|
float3 ambTex = saturate(ambient - shadow) * tex;
|
||||||
float3 combined = ambTex + diffuse + spec;
|
float3 combined = ambTex + diffuse + spec;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue