Fixed light falloff exponents

This commit is contained in:
dexy 2019-12-04 02:47:20 +11:00
parent f22826ea94
commit 21ed53e00f
3 changed files with 5 additions and 5 deletions

View File

@ -114,7 +114,7 @@ PS_OUTPUT main(VS_Output input)
if (ldist <= 0) discard;
float4 rgbi = Unpack4x8UNF(lodlight.Colour).gbar;
float3 lcol = rgbi.rgb * rgbi.a * 5.0f;
float3 lcol = rgbi.rgb * rgbi.a * 10.0f;
float3 ldir = srpos / ldist;
float pclit = saturate(dot(ldir, norm));
@ -122,7 +122,7 @@ PS_OUTPUT main(VS_Output input)
if (LightType == 1)//point (sphere)
{
lamt *= saturate(1 - (ldist / lodlight.Falloff));
lamt *= pow(saturate(1 - (ldist / lodlight.Falloff)), lodlight.FalloffExponent);
}
else if (LightType == 2)//spot (cone)
{
@ -131,11 +131,11 @@ PS_OUTPUT main(VS_Output input)
float oang = lodlight.OuterAngleOrCapExt * 0.01745329 * 0.5;
if (ang > oang) discard;
lamt *= saturate(1 - ((ang - iang) / (oang - iang)));
lamt *= saturate(1 - (ldist / lodlight.Falloff));
lamt *= pow(saturate(1 - (ldist / lodlight.Falloff)), lodlight.FalloffExponent);
}
else if (LightType == 4)//capsule
{
lamt *= saturate(1 - (ldist / lodlight.Falloff)); //TODO! proper capsule lighting... (use point-line dist!)
lamt *= pow(saturate(1 - (ldist / lodlight.Falloff)), lodlight.FalloffExponent); //TODO! proper capsule lighting... (use point-line dist!)
}
pclit *= lamt;

View File

@ -1420,7 +1420,7 @@ namespace CodeWalker.Rendering
light.TangentX = new Vector4(Vector3.Normalize(light.Direction.GetPerpVec()), 0.0f);
light.TangentY = new Vector4(Vector3.Cross(light.Direction, light.TangentX.XYZ()), 0.0f);
light.Falloff = ll.falloff[i];
light.FalloffExponent = ll.falloffExponent[i];
light.FalloffExponent = Math.Max(ll.falloffExponent[i]*0.01f, 0.5f);//is this right?
light.InnerAngle = ll.coneInnerAngle[i];
light.OuterAngleOrCapExt = ll.coneOuterAngleOrCapExt[i];
var type = (LightType)((light.TimeAndStateFlags >> 26) & 7);

Binary file not shown.