mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 05:21:16 +00:00
Add Alternate Light Blending Options
This commit is contained in:
parent
aa061562cd
commit
8e7897233e
10 changed files with 77 additions and 4 deletions
|
@ -235,6 +235,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
float uClipHeight;
|
||||
float uClipHeightDirection;
|
||||
int uShadowmapFilter;
|
||||
|
||||
int uLightBlendMode;
|
||||
};
|
||||
|
||||
uniform int uTextureMode;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "hw_renderstate.h"
|
||||
#include "hw_viewpointbuffer.h"
|
||||
#include "hw_cvars.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
static const int INITIAL_BUFFER_SIZE = 100; // 100 viewpoints per frame should nearly always be enough
|
||||
|
||||
|
@ -91,6 +92,7 @@ void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll)
|
|||
matrices.mPalLightLevels = pll;
|
||||
matrices.mClipLine.X = -10000000.0f;
|
||||
matrices.mShadowmapFilter = gl_shadowmap_filter;
|
||||
matrices.mLightBlendMode = (level.info ? (int)level.info->lightblendmode : 0);
|
||||
|
||||
matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f);
|
||||
matrices.CalcDependencies();
|
||||
|
|
|
@ -19,6 +19,8 @@ struct HWViewpointUniforms
|
|||
float mClipHeightDirection = 0.f;
|
||||
int mShadowmapFilter = 1;
|
||||
|
||||
int mLightBlendMode = 0;
|
||||
|
||||
void CalcDependencies()
|
||||
{
|
||||
mNormalViewMatrix.computeNormalMatrix(mViewMatrix);
|
||||
|
|
|
@ -175,6 +175,8 @@ static const char *shaderBindings = R"(
|
|||
float uClipHeight;
|
||||
float uClipHeightDirection;
|
||||
int uShadowmapFilter;
|
||||
|
||||
int uLightBlendMode;
|
||||
};
|
||||
|
||||
layout(set = 1, binding = 1, std140) uniform MatricesUBO {
|
||||
|
|
|
@ -53,4 +53,13 @@ enum class ELightMode : int8_t
|
|||
DoomSoftware = 16
|
||||
};
|
||||
|
||||
enum class ELightBlendMode : uint8_t
|
||||
{
|
||||
CLAMP = 0,
|
||||
CLAMP_COLOR = 1,
|
||||
NOCLAMP = 2,
|
||||
|
||||
DEFAULT = CLAMP,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -302,7 +302,7 @@ void level_info_t::Reset()
|
|||
lightadditivesurfaces = -1;
|
||||
skyrotatevector = FVector3(0, 0, 1);
|
||||
skyrotatevector2 = FVector3(0, 0, 1);
|
||||
|
||||
lightblendmode = ELightBlendMode::DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1496,6 +1496,29 @@ DEFINE_MAP_OPTION(lightmode, false)
|
|||
}
|
||||
}
|
||||
|
||||
DEFINE_MAP_OPTION(lightblendmode, false)
|
||||
{
|
||||
parse.ParseAssign();
|
||||
parse.sc.MustGetString();
|
||||
|
||||
if(strcmp(parse.sc.String,"DEFAULT") == 0 || strcmp(parse.sc.String,"CLAMP") == 0)
|
||||
{
|
||||
info->lightblendmode = ELightBlendMode::DEFAULT;
|
||||
}
|
||||
else if(strcmp(parse.sc.String,"COLOR_CORRECT_CLAMP") == 0)
|
||||
{
|
||||
info->lightblendmode = ELightBlendMode::CLAMP_COLOR;
|
||||
}
|
||||
else if(strcmp(parse.sc.String,"UNCLAMPED") == 0)
|
||||
{
|
||||
info->lightblendmode = ELightBlendMode::NOCLAMP;
|
||||
}
|
||||
else
|
||||
{
|
||||
parse.sc.ScriptMessage("Invalid light blend mode %s", parse.sc.String);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_MAP_OPTION(notexturefill, false)
|
||||
{
|
||||
if (parse.CheckAssign())
|
||||
|
|
|
@ -409,6 +409,7 @@ struct level_info_t
|
|||
FString EDName;
|
||||
FString acsName;
|
||||
bool fs_nocheckposition;
|
||||
ELightBlendMode lightblendmode;
|
||||
|
||||
CutsceneDef intro, outro;
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "a_corona.h"
|
||||
#include "texturemanager.h"
|
||||
#include "actorinlines.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
EXTERN_CVAR(Float, r_visibility)
|
||||
CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE)
|
||||
|
@ -164,6 +165,7 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni
|
|||
}
|
||||
VPUniforms.mClipLine.X = -10000000.0f;
|
||||
VPUniforms.mShadowmapFilter = gl_shadowmap_filter;
|
||||
VPUniforms.mLightBlendMode = (level.info ? (int)level.info->lightblendmode : 0);
|
||||
}
|
||||
mClipper->SetViewpoint(Viewpoint);
|
||||
|
||||
|
|
|
@ -59,7 +59,21 @@ vec3 ProcessMaterialLight(Material material, vec3 color)
|
|||
}
|
||||
}
|
||||
|
||||
vec3 frag = material.Base.rgb * clamp(color + desaturate(dynlight).rgb, 0.0, 1.4);
|
||||
vec3 frag;
|
||||
|
||||
if ( uLightBlendMode == 1 )
|
||||
{ // COLOR_CORRECT_CLAMPING
|
||||
vec3 lightcolor = color + desaturate(dynlight).rgb;
|
||||
frag = material.Base.rgb * ((lightcolor / max(max(max(lightcolor.r, lightcolor.g), lightcolor.b), 1.4) * 1.4));
|
||||
}
|
||||
else if ( uLightBlendMode == 2 )
|
||||
{ // UNCLAMPED
|
||||
frag = material.Base.rgb * (color + desaturate(dynlight).rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
frag = material.Base.rgb * clamp(color + desaturate(dynlight).rgb, 0.0, 1.4);
|
||||
}
|
||||
|
||||
if (uLightIndex >= 0)
|
||||
{
|
||||
|
|
|
@ -66,9 +66,25 @@ vec3 ProcessMaterialLight(Material material, vec3 color)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( uLightBlendMode == 1 )
|
||||
{ // COLOR_CORRECT_CLAMPING
|
||||
dynlight.rgb = color + desaturate(dynlight).rgb;
|
||||
specular.rgb = desaturate(specular).rgb;
|
||||
|
||||
dynlight.rgb = clamp(color + desaturate(dynlight).rgb, 0.0, 1.4);
|
||||
specular.rgb = clamp(desaturate(specular).rgb, 0.0, 1.4);
|
||||
dynlight.rgb = ((dynlight.rgb / max(max(max(dynlight.r, dynlight.g), dynlight.b), 1.4) * 1.4));
|
||||
specular.rgb = ((specular.rgb / max(max(max(specular.r, specular.g), specular.b), 1.4) * 1.4));
|
||||
}
|
||||
else if ( uLightBlendMode == 2 )
|
||||
{ // UNCLAMPED
|
||||
dynlight.rgb = color + desaturate(dynlight).rgb;
|
||||
specular.rgb = desaturate(specular).rgb;
|
||||
}
|
||||
else
|
||||
{
|
||||
dynlight.rgb = clamp(color + desaturate(dynlight).rgb, 0.0, 1.4);
|
||||
specular.rgb = clamp(desaturate(specular).rgb, 0.0, 1.4);
|
||||
}
|
||||
|
||||
vec3 frag = material.Base.rgb * dynlight.rgb + material.Specular * specular.rgb;
|
||||
|
||||
|
|
Loading…
Reference in a new issue