change light strength to light linearity 0.0 = inverse square, 1.0 = linear

This commit is contained in:
Ricardo Luís Vaz Silva 2024-10-10 16:51:09 -03:00 committed by Magnus Norddahl
commit 74a49ca919
13 changed files with 54 additions and 56 deletions

View file

@ -120,7 +120,7 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f
// Store attenuate flag in the sign bit of the float.
if (light->IsAttenuated() || forceAttenuate) shadowIndex = -shadowIndex;
float lightType = 0.0f;
bool lightType = false;
float spotInnerAngle = 0.0f;
float spotOuterAngle = 0.0f;
float spotDirX = 0.0f;
@ -128,7 +128,7 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f
float spotDirZ = 0.0f;
if (light->IsSpot())
{
lightType = 1.0f;
lightType = true;
spotInnerAngle = (float)light->pSpotInnerAngle->Cos();
spotOuterAngle = (float)light->pSpotOuterAngle->Cos();
@ -139,15 +139,19 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f
spotDirY = float(-negPitch.Sin());
spotDirZ = float(-Angle.Sin() * xzLen);
}
float softShadowRadius = light->GetSoftShadowRadius();
float linearity = light->GetLinearity();
float strength = light->GetStrength();
float *data = &dld.arrays[i][dld.arrays[i].Reserve(16)];
data[0] = float(pos.X);
data[1] = float(pos.Z);
data[2] = float(pos.Y);
data[3] = radius;
data[3] = lightType ? -radius : radius;
data[4] = r;
data[5] = g;
data[6] = b;
@ -155,7 +159,7 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f
data[8] = spotDirX;
data[9] = spotDirY;
data[10] = spotDirZ;
data[11] = lightType;
data[11] = std::clamp(linearity, 0.0f, 1.0f);
data[12] = spotInnerAngle;
data[13] = spotOuterAngle;
data[14] = softShadowRadius;
@ -172,7 +176,6 @@ void AddSunLightToList(FDynLightData& dld, float x, float y, float z, const FVec
z += sundir.Z * dist;
int i = 0;
float lightType = 0.0f;
float spotInnerAngle = 0.0f;
float spotOuterAngle = 0.0f;
float spotDirX = 0.0f;
@ -194,7 +197,7 @@ void AddSunLightToList(FDynLightData& dld, float x, float y, float z, const FVec
data[8] = spotDirX;
data[9] = spotDirY;
data[10] = spotDirZ;
data[11] = lightType;
data[11] = 0.0f; // unused
data[12] = spotInnerAngle;
data[13] = spotOuterAngle;
data[14] = 0.0f; // unused