mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 15:02:54 +08:00
Fixed light falloff exponents
This commit is contained in:
parent
f22826ea94
commit
21ed53e00f
@ -114,7 +114,7 @@ PS_OUTPUT main(VS_Output input)
|
|||||||
if (ldist <= 0) discard;
|
if (ldist <= 0) discard;
|
||||||
|
|
||||||
float4 rgbi = Unpack4x8UNF(lodlight.Colour).gbar;
|
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;
|
float3 ldir = srpos / ldist;
|
||||||
float pclit = saturate(dot(ldir, norm));
|
float pclit = saturate(dot(ldir, norm));
|
||||||
@ -122,7 +122,7 @@ PS_OUTPUT main(VS_Output input)
|
|||||||
|
|
||||||
if (LightType == 1)//point (sphere)
|
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)
|
else if (LightType == 2)//spot (cone)
|
||||||
{
|
{
|
||||||
@ -131,11 +131,11 @@ PS_OUTPUT main(VS_Output input)
|
|||||||
float oang = lodlight.OuterAngleOrCapExt * 0.01745329 * 0.5;
|
float oang = lodlight.OuterAngleOrCapExt * 0.01745329 * 0.5;
|
||||||
if (ang > oang) discard;
|
if (ang > oang) discard;
|
||||||
lamt *= saturate(1 - ((ang - iang) / (oang - iang)));
|
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
|
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;
|
pclit *= lamt;
|
||||||
|
@ -1420,7 +1420,7 @@ namespace CodeWalker.Rendering
|
|||||||
light.TangentX = new Vector4(Vector3.Normalize(light.Direction.GetPerpVec()), 0.0f);
|
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.TangentY = new Vector4(Vector3.Cross(light.Direction, light.TangentX.XYZ()), 0.0f);
|
||||||
light.Falloff = ll.falloff[i];
|
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.InnerAngle = ll.coneInnerAngle[i];
|
||||||
light.OuterAngleOrCapExt = ll.coneOuterAngleOrCapExt[i];
|
light.OuterAngleOrCapExt = ll.coneOuterAngleOrCapExt[i];
|
||||||
var type = (LightType)((light.TimeAndStateFlags >> 26) & 7);
|
var type = (LightType)((light.TimeAndStateFlags >> 26) & 7);
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user