Add sunlight trace
This commit is contained in:
parent
187b7f0956
commit
34d2b2e440
5 changed files with 51 additions and 13 deletions
|
|
@ -155,3 +155,32 @@ 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)
|
||||
{
|
||||
int i = 0;
|
||||
float lightType = 0.0f;
|
||||
float spotInnerAngle = 0.0f;
|
||||
float spotOuterAngle = 0.0f;
|
||||
float spotDirX = 0.0f;
|
||||
float spotDirY = 0.0f;
|
||||
float spotDirZ = 0.0f;
|
||||
float shadowIndex = -1025.f; // Note: 1025 disables shadowmap and the attenuate flag is in the sign bit of the float
|
||||
|
||||
float* data = &dld.arrays[i][dld.arrays[i].Reserve(16)];
|
||||
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[7] = shadowIndex;
|
||||
data[8] = spotDirX;
|
||||
data[9] = spotDirY;
|
||||
data[10] = spotDirZ;
|
||||
data[11] = lightType;
|
||||
data[12] = spotInnerAngle;
|
||||
data[13] = spotOuterAngle;
|
||||
data[14] = 0.0f; // unused
|
||||
data[15] = 0.0f; // unused
|
||||
}
|
||||
|
|
|
|||
|
|
@ -441,4 +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 SetSplitPlanes(FRenderState& state, const secplane_t& top, const secplane_t& bottom);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ static bool TraceLightVisbility(FLightNode* node, const FVector3& L, float dist)
|
|||
|
||||
static bool TraceSunVisibility(float x, float y, float z)
|
||||
{
|
||||
return level.levelMesh->TraceSky(FVector3(x, y, z), FVector3(0.0f, 0.0, 1.0f), 10000.0f);
|
||||
return level.LMTextureCount != 0 && level.levelMesh->TraceSky(FVector3(x, y, z), level.SunDirection, 10000.0f);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -80,7 +80,9 @@ void HWDrawInfo::GetDynSpriteLight(AActor *self, float x, float y, float z, FLig
|
|||
|
||||
if (TraceSunVisibility(x, y, z))
|
||||
{
|
||||
//out[0] = 1.0f;
|
||||
out[0] = Level->SunColor.X;
|
||||
out[1] = Level->SunColor.Y;
|
||||
out[2] = Level->SunColor.Z;
|
||||
}
|
||||
|
||||
// Go through both light lists
|
||||
|
|
@ -195,7 +197,10 @@ void hw_GetDynModelLight(AActor *self, FDynLightData &modellightdata)
|
|||
|
||||
if (TraceSunVisibility(x, y, z))
|
||||
{
|
||||
//AddSunLightToList(modellightdata);
|
||||
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);
|
||||
}
|
||||
|
||||
BSPWalkCircle(self->Level, x, y, radiusSquared, [&](subsector_t *subsector) // Iterate through all subsectors potentially touched by actor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue