mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-07 17:11:17 +00:00
Fix sprite dynlight distance check
This commit is contained in:
parent
548aec01ec
commit
92e6f070b4
1 changed files with 5 additions and 14 deletions
|
@ -238,24 +238,15 @@ namespace swrenderer
|
||||||
ADynamicLight *light = node->lightsource;
|
ADynamicLight *light = node->lightsource;
|
||||||
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != thing))
|
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != thing))
|
||||||
{
|
{
|
||||||
double lightX = light->X() - ViewPos.X;
|
float lx = (float)(light->X() - pos.X);
|
||||||
double lightY = light->Y() - ViewPos.Y;
|
float ly = (float)(light->Y() - pos.Y);
|
||||||
double lightZ = light->Z() - ViewPos.Z;
|
float lz = (float)(light->Z() - pos.Z);
|
||||||
|
|
||||||
float lx = (float)(lightX * ViewSin - lightY * ViewCos - pos.X);
|
|
||||||
float ly = (float)(lightX * ViewTanCos + lightY * ViewTanSin - pos.Y);
|
|
||||||
float lz = (float)(lightZ - pos.Z);
|
|
||||||
|
|
||||||
// Attenuated lights disabled for sprites for now to keep consistency with the GL renderer
|
|
||||||
//bool is_point_light = (node->lightsource->flags4 & MF4_ATTENUATE) != 0;
|
|
||||||
float LdotL = lx * lx + ly * ly + lz * lz;
|
float LdotL = lx * lx + ly * ly + lz * lz;
|
||||||
float NdotL = 1.0f;//is_point_light ? -ly : 1.0f;
|
|
||||||
|
|
||||||
float radius = node->lightsource->GetRadius();
|
float radius = node->lightsource->GetRadius();
|
||||||
if (radius * radius >= LdotL && NdotL > 0.0f)
|
if (radius * radius >= LdotL)
|
||||||
{
|
{
|
||||||
float distance = sqrt(LdotL);
|
float distance = sqrt(LdotL);
|
||||||
float attenuation = (1.0f - distance / radius) * NdotL;
|
float attenuation = 1.0f - distance / radius;
|
||||||
if (attenuation > 0.0f)
|
if (attenuation > 0.0f)
|
||||||
{
|
{
|
||||||
float red = light->GetRed() * (1.0f / 255.0f);
|
float red = light->GetRed() * (1.0f / 255.0f);
|
||||||
|
|
Loading…
Reference in a new issue