mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
Fix sunlight not working on models
This commit is contained in:
parent
c23a109105
commit
d97f9f3055
4 changed files with 19 additions and 10 deletions
|
@ -155,8 +155,15 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f
|
|||
data[15] = 0.0f; // unused
|
||||
}
|
||||
|
||||
void AddSunLightToList(FDynLightData& dld, float x, float y, float z, float r, float g, float b)
|
||||
void AddSunLightToList(FDynLightData& dld, float x, float y, float z, const FVector3& sundir, const FVector3& suncolor)
|
||||
{
|
||||
// Cheap way of faking a directional light
|
||||
float dist = 100000.0f;
|
||||
float radius = 100000000.0f;
|
||||
x += sundir.X * dist;
|
||||
y += sundir.Y * dist;
|
||||
z += sundir.Z * dist;
|
||||
|
||||
int i = 0;
|
||||
float lightType = 0.0f;
|
||||
float spotInnerAngle = 0.0f;
|
||||
|
@ -170,10 +177,10 @@ void AddSunLightToList(FDynLightData& dld, float x, float y, float z, float r, f
|
|||
data[0] = float(x);
|
||||
data[1] = float(z);
|
||||
data[2] = float(y);
|
||||
data[3] = 100000.0f;
|
||||
data[4] = r;
|
||||
data[5] = g;
|
||||
data[6] = b;
|
||||
data[3] = radius;
|
||||
data[4] = suncolor.X;
|
||||
data[5] = suncolor.Y;
|
||||
data[6] = suncolor.Z;
|
||||
data[7] = shadowIndex;
|
||||
data[8] = spotDirX;
|
||||
data[9] = spotDirY;
|
||||
|
|
|
@ -441,5 +441,5 @@ struct FDynLightData;
|
|||
struct FDynamicLight;
|
||||
bool GetLight(FDynLightData& dld, int group, Plane& p, FDynamicLight* light, bool checkside);
|
||||
void AddLightToList(FDynLightData &dld, int group, FDynamicLight* light, bool forceAttenuate);
|
||||
void AddSunLightToList(FDynLightData& dld, float x, float y, float z, float r, float g, float b);
|
||||
void AddSunLightToList(FDynLightData& dld, float x, float y, float z, const FVector3& sundir, const FVector3& suncolor);
|
||||
void SetSplitPlanes(FRenderState& state, const secplane_t& top, const secplane_t& bottom);
|
||||
|
|
|
@ -197,10 +197,7 @@ void hw_GetDynModelLight(AActor *self, FDynLightData &modellightdata)
|
|||
|
||||
if (TraceSunVisibility(x, y, z))
|
||||
{
|
||||
const FVector3& sundir = self->Level->SunDirection;
|
||||
const FVector3& suncolor = self->Level->SunColor;
|
||||
float dist = 100000.0f; // Cheap way of faking a directional light
|
||||
AddSunLightToList(modellightdata, x - sundir.X * dist, y - sundir.Y * dist, z - sundir.Z * dist, suncolor.X, suncolor.Y, suncolor.Z);
|
||||
AddSunLightToList(modellightdata, x, y, z, self->Level->SunDirection, self->Level->SunColor);
|
||||
}
|
||||
|
||||
BSPWalkCircle(self->Level, x, y, radiusSquared, [&](subsector_t *subsector) // Iterate through all subsectors potentially touched by actor
|
||||
|
|
|
@ -74,6 +74,8 @@ float traceShadow(vec4 lightpos, int quality)
|
|||
|
||||
float shadowAttenuation(vec4 lightpos, float lightcolorA)
|
||||
{
|
||||
if (lightpos.w > 1000000.0)
|
||||
return 1.0; // Sunlight
|
||||
return traceShadow(lightpos, uShadowmapFilter);
|
||||
}
|
||||
|
||||
|
@ -206,6 +208,9 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
|
|||
|
||||
float shadowAttenuation(vec4 lightpos, float lightcolorA)
|
||||
{
|
||||
if (lightpos.w > 1000000.0)
|
||||
return 1.0; // Sunlight
|
||||
|
||||
float shadowIndex = abs(lightcolorA) - 1.0;
|
||||
if (shadowIndex >= 1024.0)
|
||||
return 1.0; // No shadowmap available for this light
|
||||
|
|
Loading…
Reference in a new issue