mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +00:00
- added an ATTENUATE flag to dynamic lights, this is set by default for attached lights. For placed lights this is off, because it'd interfere with many existing maps that depend on unattenuated lights.
This commit is contained in:
parent
fbe2b76705
commit
bea625a42c
4 changed files with 13 additions and 8 deletions
|
@ -1082,6 +1082,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;
|
||||
actor->dynamiclights.Push(light);
|
||||
}
|
||||
light->flags2&=~MF2_DORMANT;
|
||||
|
|
|
@ -50,6 +50,7 @@ enum
|
|||
#define MF4_SUBTRACTIVE MF4_MISSILEEVENMORE
|
||||
#define MF4_ADDITIVE MF4_MISSILEMORE
|
||||
#define MF4_DONTLIGHTSELF MF4_SEESDAGGERS
|
||||
#define MF4_ATTENUATE MF4_INCOMBAT
|
||||
|
||||
enum ELightType
|
||||
{
|
||||
|
|
|
@ -116,7 +116,7 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FD
|
|||
data[4] = r;
|
||||
data[5] = g;
|
||||
data[6] = b;
|
||||
data[7] = 0;
|
||||
data[7] = !!(light->flags4 & MF4_ATTENUATE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,16 +142,19 @@ float diffuseContribution(vec3 lightDirection, vec3 normal)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
float pointLightAttenuation(vec4 lightpos)
|
||||
float pointLightAttenuation(vec4 lightpos, float attenuate)
|
||||
{
|
||||
float attenuation = max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w;
|
||||
#if 0
|
||||
if (attenuate == 0.0)
|
||||
{
|
||||
return attenuation;
|
||||
#else
|
||||
}
|
||||
else
|
||||
{
|
||||
vec3 lightDirection = normalize(lightpos.xyz - pixelpos.xyz);
|
||||
float diffuseAmount = diffuseContribution(lightDirection, normalize(vWorldNormal.xyz));
|
||||
return attenuation * diffuseAmount;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -229,7 +232,7 @@ vec4 getLightColor(float fogdist, float fogfactor)
|
|||
vec4 lightpos = lights[i];
|
||||
vec4 lightcolor = lights[i+1];
|
||||
|
||||
lightcolor.rgb *= pointLightAttenuation(lightpos);
|
||||
lightcolor.rgb *= pointLightAttenuation(lightpos, lightcolor.a);
|
||||
dynlight.rgb += lightcolor.rgb;
|
||||
}
|
||||
//
|
||||
|
@ -240,7 +243,7 @@ vec4 getLightColor(float fogdist, float fogfactor)
|
|||
vec4 lightpos = lights[i];
|
||||
vec4 lightcolor = lights[i+1];
|
||||
|
||||
lightcolor.rgb *= pointLightAttenuation(lightpos);
|
||||
lightcolor.rgb *= pointLightAttenuation(lightpos, lightcolor.a);
|
||||
dynlight.rgb -= lightcolor.rgb;
|
||||
}
|
||||
}
|
||||
|
@ -322,7 +325,7 @@ void main()
|
|||
vec4 lightpos = lights[i];
|
||||
vec4 lightcolor = lights[i+1];
|
||||
|
||||
lightcolor.rgb *= pointLightAttenuation(lightpos);
|
||||
lightcolor.rgb *= pointLightAttenuation(lightpos, lightcolor.a);
|
||||
addlight.rgb += lightcolor.rgb;
|
||||
}
|
||||
frag.rgb = clamp(frag.rgb + desaturate(addlight).rgb, 0.0, 1.0);
|
||||
|
|
Loading…
Reference in a new issue