mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-14 16:40:56 +00:00
- add 'sublighttype' for Subtractive dynamic lights to change the colour formula.
This commit is contained in:
parent
1455111ddc
commit
c69941a9e9
3 changed files with 44 additions and 6 deletions
|
@ -46,6 +46,13 @@ enum LightFlag
|
|||
LF_SPOT = 64
|
||||
};
|
||||
|
||||
enum SubLightFormula
|
||||
{
|
||||
SLF_ZDOOMGL = 1,
|
||||
SLF_PRECISE = 2,
|
||||
SLF_RAW = 3,
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Light definitions
|
||||
|
@ -72,6 +79,8 @@ public:
|
|||
void SetSpot(bool spot) { m_spot = spot; }
|
||||
void SetSpotInnerAngle(double angle) { m_spotInnerAngle = angle; }
|
||||
void SetSpotOuterAngle(double angle) { m_spotOuterAngle = angle; }
|
||||
uint8_t GetSubLightType() { return m_sublighttype; }
|
||||
void SetSubLightType(uint8_t val) { m_sublighttype = val; }
|
||||
|
||||
void OrderIntensities()
|
||||
{
|
||||
|
@ -98,6 +107,7 @@ protected:
|
|||
bool m_spot = false;
|
||||
double m_spotInnerAngle = 10.0;
|
||||
double m_spotOuterAngle = 25.0;
|
||||
uint8_t m_sublighttype = 1;
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
@ -203,6 +213,8 @@ public:
|
|||
bool IsSubtractive() { return !!(lightflags & LF_SUBTRACTIVE); }
|
||||
bool IsAdditive() { return !!(lightflags & LF_ADDITIVE); }
|
||||
bool IsSpot() { return !!(lightflags & LF_SPOT); }
|
||||
uint8_t GetSubLightType();
|
||||
void SetSubLightType(uint8_t Val);
|
||||
FState *targetState;
|
||||
FLightNode * touching_sides;
|
||||
FLightNode * touching_subsectors;
|
||||
|
|
|
@ -97,11 +97,14 @@ void FDynLightData::AddLightToList(int group, ADynamicLight * light, bool forceA
|
|||
if (light->IsSubtractive())
|
||||
{
|
||||
DVector3 v(r, g, b);
|
||||
float length = (float)v.Length();
|
||||
|
||||
r = length - r;
|
||||
g = length - g;
|
||||
b = length - b;
|
||||
float length = (light->GetSubLightType() == 1) ? ((float)v.Length()) : (r + g + b - clamp(r, g, b));
|
||||
|
||||
if (light->GetSubLightType() != 3)
|
||||
{
|
||||
r = length - r;
|
||||
g = length - g;
|
||||
b = length - b;
|
||||
}
|
||||
i = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,6 +136,7 @@ static const char *LightTags[]=
|
|||
"attenuate",
|
||||
"dontlightactors",
|
||||
"spot",
|
||||
"sublighttype",
|
||||
nullptr
|
||||
};
|
||||
|
||||
|
@ -158,7 +159,8 @@ enum {
|
|||
LIGHTTAG_DONTLIGHTSELF,
|
||||
LIGHTTAG_ATTENUATE,
|
||||
LIGHTTAG_DONTLIGHTACTORS,
|
||||
LIGHTTAG_SPOT
|
||||
LIGHTTAG_SPOT,
|
||||
LIGHTTAG_SUBLIGHTTYPE,
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
@ -463,6 +465,10 @@ class GLDefsParser
|
|||
defaults->SetSpotOuterAngle(outerAngle);
|
||||
}
|
||||
break;
|
||||
case LIGHTTAG_SUBLIGHTTYPE:
|
||||
intVal = clamp<int>(ParseInt(sc), 1, 3);
|
||||
defaults->SetSubLightType(intVal);
|
||||
break;
|
||||
default:
|
||||
sc.ScriptError("Unknown tag: %s\n", sc.String);
|
||||
}
|
||||
|
@ -556,6 +562,10 @@ class GLDefsParser
|
|||
defaults->SetSpotOuterAngle(outerAngle);
|
||||
}
|
||||
break;
|
||||
case LIGHTTAG_SUBLIGHTTYPE:
|
||||
intVal = clamp<int>(ParseInt(sc), 1, 3);
|
||||
defaults->SetSubLightType(intVal);
|
||||
break;
|
||||
default:
|
||||
sc.ScriptError("Unknown tag: %s\n", sc.String);
|
||||
}
|
||||
|
@ -652,6 +662,10 @@ class GLDefsParser
|
|||
defaults->SetSpotOuterAngle(outerAngle);
|
||||
}
|
||||
break;
|
||||
case LIGHTTAG_SUBLIGHTTYPE:
|
||||
intVal = clamp<int>(ParseInt(sc), 1, 3);
|
||||
defaults->SetSubLightType(intVal);
|
||||
break;
|
||||
default:
|
||||
sc.ScriptError("Unknown tag: %s\n", sc.String);
|
||||
}
|
||||
|
@ -747,6 +761,10 @@ class GLDefsParser
|
|||
defaults->SetSpotOuterAngle(outerAngle);
|
||||
}
|
||||
break;
|
||||
case LIGHTTAG_SUBLIGHTTYPE:
|
||||
intVal = clamp<int>(ParseInt(sc), 1, 3);
|
||||
defaults->SetSubLightType(intVal);
|
||||
break;
|
||||
default:
|
||||
sc.ScriptError("Unknown tag: %s\n", sc.String);
|
||||
}
|
||||
|
@ -777,6 +795,7 @@ class GLDefsParser
|
|||
int type;
|
||||
float floatVal;
|
||||
float floatTriple[3];
|
||||
int intVal;
|
||||
FLightDefaults *defaults;
|
||||
|
||||
// get name
|
||||
|
@ -839,6 +858,10 @@ class GLDefsParser
|
|||
defaults->SetSpotOuterAngle(outerAngle);
|
||||
}
|
||||
break;
|
||||
case LIGHTTAG_SUBLIGHTTYPE:
|
||||
intVal = clamp<int>(ParseInt(sc), 1, 3);
|
||||
defaults->SetSubLightType(intVal);
|
||||
break;
|
||||
default:
|
||||
sc.ScriptError("Unknown tag: %s\n", sc.String);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue