Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/coelckers/gzdoom
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed Dec 6, 2016
2 parents 7441521 + a3ae052 commit af330e1
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 27 deletions.
26 changes: 24 additions & 2 deletions src/gl/data/gl_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ long gl_frameCount;

EXTERN_CVAR(Int, gl_lightmode)
EXTERN_CVAR(Bool, gl_brightfog)
EXTERN_CVAR(Bool, gl_lightadditivesurfaces)

CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE|CVAR_SERVERINFO)
{
Expand Down Expand Up @@ -210,6 +211,7 @@ struct FGLROptions : public FOptionalMapinfoData
skyrotatevector = FVector3(0,0,1);
skyrotatevector2 = FVector3(0,0,1);
pixelstretch = 1.2f;
lightadditivesurfaces = false;
}
virtual FOptionalMapinfoData *Clone() const
{
Expand All @@ -224,15 +226,17 @@ struct FGLROptions : public FOptionalMapinfoData
newopt->skyrotatevector = skyrotatevector;
newopt->skyrotatevector2 = skyrotatevector2;
newopt->pixelstretch = pixelstretch;
newopt->lightadditivesurfaces = lightadditivesurfaces;
return newopt;
}
int fogdensity;
int outsidefogdensity;
int skyfog;
int lightmode;
int brightfog;
SBYTE nocoloredspritelighting;
SBYTE notexturefill;
int8_t lightadditivesurfaces;
int8_t nocoloredspritelighting;
int8_t notexturefill;
FVector3 skyrotatevector;
FVector3 skyrotatevector2;
float pixelstretch;
Expand Down Expand Up @@ -306,6 +310,20 @@ DEFINE_MAP_OPTION(notexturefill, false)
}
}

DEFINE_MAP_OPTION(lightadditivesurfaces, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
if (parse.CheckAssign())
{
parse.sc.MustGetNumber();
opt->lightadditivesurfaces = !!parse.sc.Number;
}
else
{
opt->lightadditivesurfaces = true;
}
}

DEFINE_MAP_OPTION(skyrotate, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
Expand Down Expand Up @@ -360,6 +378,7 @@ void InitGLRMapinfoData()
{
gl_SetFogParams(opt->fogdensity, level.info->outsidefog, opt->outsidefogdensity, opt->skyfog);
glset.map_lightmode = opt->lightmode;
glset.map_lightadditivesurfaces = opt->lightadditivesurfaces;
glset.map_brightfog = opt->brightfog;
glset.map_nocoloredspritelighting = opt->nocoloredspritelighting;
glset.map_notexturefill = opt->notexturefill;
Expand All @@ -371,6 +390,7 @@ void InitGLRMapinfoData()
{
gl_SetFogParams(0, level.info->outsidefog, 0, 0);
glset.map_lightmode = -1;
glset.map_lightadditivesurfaces = -1;
glset.map_brightfog = -1;
glset.map_nocoloredspritelighting = -1;
glset.map_notexturefill = -1;
Expand All @@ -387,6 +407,8 @@ void InitGLRMapinfoData()
else glset.notexturefill = !!glset.map_notexturefill;
if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog;
else glset.brightfog = !!glset.map_brightfog;
if (glset.map_lightadditivesurfaces == -1) glset.brightfog = gl_brightfog;
else glset.lightadditivesurfaces = !!glset.map_lightadditivesurfaces;
}

CCMD(gl_resetmap)
Expand Down
10 changes: 6 additions & 4 deletions src/gl/data/gl_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ struct GLRenderSettings
bool nocoloredspritelighting;
bool notexturefill;
bool brightfog;
bool lightadditivesurfaces;

SBYTE map_lightmode;
SBYTE map_nocoloredspritelighting;
SBYTE map_notexturefill;
SBYTE map_brightfog;
int8_t map_lightmode;
int8_t map_nocoloredspritelighting;
int8_t map_notexturefill;
int8_t map_brightfog;
int8_t map_lightadditivesurfaces;

FVector3 skyrotatevector;
FVector3 skyrotatevector2;
Expand Down
21 changes: 12 additions & 9 deletions src/gl/dynlights/a_dynlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "templates.h"
#include "doomdata.h"
#include "r_utility.h"
#include "p_local.h"
#include "portal.h"
#include "doomstat.h"
#include "serializer.h"
Expand Down Expand Up @@ -192,6 +193,7 @@ void ADynamicLight::BeginPlay()

m_Radius[0] = args[LIGHT_INTENSITY];
m_Radius[1] = args[LIGHT_SECONDARY_INTENSITY];
specialf1 = DAngle(double(SpawnAngle)).Normalized360().Degrees;
visibletoplayer = true;
}

Expand Down Expand Up @@ -228,7 +230,7 @@ void ADynamicLight::Activate(AActor *activator)

if (lighttype == PulseLight)
{
float pulseTime = Angles.Yaw.Degrees / TICRATE;
float pulseTime = specialf1 / TICRATE;

m_lastUpdate = level.maptime;
m_cycler.SetParams(float(m_Radius[1]), float(m_Radius[0]), pulseTime);
Expand Down Expand Up @@ -293,7 +295,7 @@ void ADynamicLight::Tick()
case FlickerLight:
{
BYTE rnd = randLight();
float pct = Angles.Yaw.Degrees / 360.f;
float pct = specialf1 / 360.f;

m_currentRadius = float(m_Radius[rnd >= pct * 255]);
break;
Expand All @@ -304,13 +306,14 @@ void ADynamicLight::Tick()
int flickerRange = m_Radius[1] - m_Radius[0];
float amt = randLight() / 255.f;

m_tickCount++;

if (m_tickCount > Angles.Yaw.Degrees)
if (m_tickCount > specialf1)
{
m_currentRadius = float(m_Radius[0] + (amt * flickerRange));
m_tickCount = 0;
}
if (m_tickCount++ == 0 || m_currentRadius > m_Radius[1])
{
m_currentRadius = float(m_Radius[0] + (amt * flickerRange));
}
break;
}

Expand All @@ -319,7 +322,7 @@ void ADynamicLight::Tick()
case ColorFlickerLight:
{
BYTE rnd = randLight();
float pct = Angles.Yaw.Degrees/360.f;
float pct = specialf1/360.f;

m_currentRadius = m_Radius[rnd >= pct * 255];
break;
Expand All @@ -332,7 +335,7 @@ void ADynamicLight::Tick()

m_tickCount++;

if (m_tickCount > Angles.Yaw.Degrees)
if (m_tickCount > specialf1)
{
m_currentRadius = m_Radius[0] + (amt * flickerRange);
m_tickCount = 0;
Expand All @@ -359,7 +362,6 @@ void ADynamicLight::Tick()
m_currentRadius = float(m_Radius[0]);
break;
}

UpdateLocation();
}

Expand Down Expand Up @@ -416,6 +418,7 @@ void ADynamicLight::UpdateLocation()
intensity = m_currentRadius;
}
radius = intensity * 2.0f;
assert(radius >= m_currentRadius * 2);

if (X() != oldx || Y() != oldy || radius != oldradius)
{
Expand Down
13 changes: 11 additions & 2 deletions src/gl/dynlights/gl_dynlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ FLightDefaults::FLightDefaults(FName name, ELightType type)
void FLightDefaults::ApplyProperties(ADynamicLight * light) const
{
light->lighttype = m_type;
light->Angles.Yaw.Degrees = m_Param;
light->specialf1 = m_Param;
light->SetOffset(m_Pos);
light->halo = m_halo;
for (int a = 0; a < 3; a++) light->args[a] = clamp<int>((int)(m_Args[a]), 0, 255);
Expand All @@ -174,6 +174,7 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const
if (m_subtractive) light->flags4 |= MF4_SUBTRACTIVE;
if (m_additive) light->flags4 |= MF4_ADDITIVE;
if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF;
light->m_tickCount = 0;
}


Expand Down Expand Up @@ -431,6 +432,14 @@ void gl_ParsePulseLight(FScanner &sc)
sc.ScriptError("Unknown tag: %s\n", sc.String);
}
}
if (defaults->GetArg(LIGHT_INTENSITY) > defaults->GetArg(LIGHT_SECONDARY_INTENSITY))
{
auto i = defaults->GetArg(LIGHT_INTENSITY);
auto j = defaults->GetArg(LIGHT_SECONDARY_INTENSITY);
defaults->SetArg(LIGHT_INTENSITY, j);
defaults->SetArg(LIGHT_SECONDARY_INTENSITY, i);
}

gl_AddLightDefaults(defaults);
}
else
Expand Down Expand Up @@ -1082,7 +1091,7 @@ void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lig
light->target = actor;
light->owned = true;
light->ObjectFlags |= OF_Transient;
light->flags4 |= MF4_ATTENUATE;
//light->flags4 |= MF4_ATTENUATE;
actor->dynamiclights.Push(light);
}
light->flags2&=~MF2_DORMANT;
Expand Down
7 changes: 1 addition & 6 deletions src/gl/dynlights/gl_dynlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ class ADynamicLight : public AActor
protected:
DVector3 m_off;
float m_currentRadius;
int m_tickCount;
unsigned int m_lastUpdate;
FCycler m_cycler;
subsector_t * subsector;

public:
int m_tickCount;
int m_Radius[2];
BYTE lightflags;
BYTE lighttype;
Expand All @@ -143,11 +143,6 @@ class ADynamicLight : public AActor
bool visibletoplayer;
int bufferindex;

// intermediate texture coordinate data
// this is stored in the light object to avoid recalculating it
// several times during rendering of a flat
Vector nearPt, up, right;
float scale;

};

Expand Down
1 change: 1 addition & 0 deletions src/gl/renderer/gl_lightdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL)
}
}
CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE);
CVAR(Bool, lightadditivesurfaces, false, CVAR_ARCHIVE);



Expand Down
2 changes: 1 addition & 1 deletion src/gl/scene/gl_flats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli)
{
Plane p;

if (renderstyle == STYLE_Add) return; // no lights on additively blended surfaces.
if (renderstyle == STYLE_Add && !glset.lightadditivesurfaces) return; // no lights on additively blended surfaces.

if (dli != NULL && *dli != -1)
{
Expand Down
8 changes: 8 additions & 0 deletions src/gl/scene/gl_sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ void GLSprite::CalculateVertices(FVector3 *v)
v[1] = mat * FVector3(x1, z, y2);
v[2] = mat * FVector3(x2, z, y1);
v[3] = mat * FVector3(x1, z, y1);

glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
return;
}

Expand Down Expand Up @@ -445,6 +448,11 @@ void GLSprite::Draw(int pass)
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gl_RenderState.BlendEquation(GL_FUNC_ADD);
gl_RenderState.SetTextureMode(TM_MODULATE);
if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
{
glPolygonOffset(0.0f, 0.0f);
glDisable(GL_POLYGON_OFFSET_FILL);
}
}
else if (modelframe == nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion src/gl/scene/gl_walls_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ FDynLightData lightdata;

void GLWall::SetupLights()
{
if (RenderStyle == STYLE_Add) return; // no lights on additively blended surfaces.
if (RenderStyle == STYLE_Add && !glset.lightadditivesurfaces) return; // no lights on additively blended surfaces.

// check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.)
switch (type)
Expand Down
2 changes: 0 additions & 2 deletions src/gl/scene/gl_weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ static bool isBright(DPSprite *psp)
//
//==========================================================================

EXTERN_CVAR(Bool, gl_brightfog)

void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
{
bool brightflash = false;
Expand Down

0 comments on commit af330e1

Please sign in to comment.