mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-04-25 00:41:15 +00:00
Fixed all lighting modes except 16 for GLES2
This commit is contained in:
parent
84e85c3a24
commit
b57085c49e
4 changed files with 65 additions and 2 deletions
|
@ -161,6 +161,9 @@ bool FGLRenderState::ApplyShader()
|
|||
|
||||
flavour.useColorMap = (mColorMapSpecial >= CM_FIRSTSPECIALCOLORMAP) || (mColorMapFlash != 1);
|
||||
|
||||
flavour.buildLighting = (mHwUniforms->mPalLightLevels >> 16) == 5; // Build engine mode
|
||||
flavour.bandedSwLight = !!(mHwUniforms->mPalLightLevels & 0xFF);
|
||||
|
||||
#ifdef NPOT_EMULATION
|
||||
flavour.npotEmulation = (mStreamData.uNpotEmulation.Y != 0);
|
||||
#endif
|
||||
|
|
|
@ -716,6 +716,8 @@ bool FShader::Bind(ShaderFlavourData& flavour)
|
|||
variantConfig.AppendFormat("#define DEF_USE_GLOW_BOTTOM_COLOR %d\n", flavour.useGlowBottomColor);
|
||||
|
||||
variantConfig.AppendFormat("#define DEF_USE_COLOR_MAP %d\n", flavour.useColorMap);
|
||||
variantConfig.AppendFormat("#define DEF_BUILD_LIGHTING %d\n", flavour.buildLighting);
|
||||
variantConfig.AppendFormat("#define DEF_BANDED_SW_LIGHTING %d\n", flavour.bandedSwLight);
|
||||
|
||||
variantConfig.AppendFormat("#define USE_GLSL_V100 %d\n", gles.forceGLSLv100);
|
||||
|
||||
|
|
|
@ -268,6 +268,10 @@ public:
|
|||
bool useGlowTopColor;
|
||||
bool useGlowBottomColor;
|
||||
bool useColorMap;
|
||||
|
||||
bool buildLighting;
|
||||
bool bandedSwLight;
|
||||
|
||||
#ifdef NPOT_EMULATION
|
||||
bool npotEmulation;
|
||||
#endif
|
||||
|
@ -407,8 +411,11 @@ public:
|
|||
tag |= (flavour.useGlowTopColor & 1) << 17;
|
||||
tag |= (flavour.useGlowBottomColor & 1) << 18;
|
||||
tag |= (flavour.useColorMap & 1) << 19;
|
||||
tag |= (flavour.buildLighting & 1) << 20;
|
||||
tag |= (flavour.bandedSwLight & 1) << 21;
|
||||
|
||||
#ifdef NPOT_EMULATION
|
||||
tag |= (flavour.npotEmulation & 1) << 20;
|
||||
tag |= (flavour.npotEmulation & 1) << 22;
|
||||
#endif
|
||||
return tag;
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ vec4 getTexel(vec2 st)
|
|||
|
||||
#define DOOMLIGHTFACTOR 232.0
|
||||
|
||||
float R_DoomLightingEquation(float light)
|
||||
float R_DoomLightingEquation_OLD(float light)
|
||||
{
|
||||
// z is the depth in view space, positive going into the screen
|
||||
float z = pixelpos.w;
|
||||
|
@ -254,6 +254,57 @@ float R_DoomLightingEquation(float light)
|
|||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// zdoom colormap equation
|
||||
//
|
||||
//===========================================================================
|
||||
float R_ZDoomColormap(float light, float z)
|
||||
{
|
||||
float L = light * 255.0;
|
||||
float vis = min(uGlobVis / z, 24.0 / 32.0);
|
||||
float shade = 2.0 - (L + 12.0) / 128.0;
|
||||
float lightscale = shade - vis;
|
||||
return lightscale * 31.0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Doom software lighting equation
|
||||
//
|
||||
//===========================================================================
|
||||
float R_DoomLightingEquation(float light)
|
||||
{
|
||||
// z is the depth in view space, positive going into the screen
|
||||
float z;
|
||||
|
||||
#if (DEF_FOG_RADIAL == 1)
|
||||
z = distance(pixelpos.xyz, uCameraPos.xyz);
|
||||
#else
|
||||
z = pixelpos.w;
|
||||
#endif
|
||||
|
||||
#if (DEF_BUILD_LIGHTING == 1) // gl_lightmode 5: Build software lighting emulation.
|
||||
{
|
||||
// This is a lot more primitive than Doom's lighting...
|
||||
float numShades = 32.0;
|
||||
float curshade = (1.0 - light) * (numShades - 1.0);
|
||||
float visibility = max(uGlobVis * uLightFactor * z, 0.0);
|
||||
float shade = clamp((curshade + visibility), 0.0, numShades - 1.0);
|
||||
return clamp(shade * uLightDist, 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
float colormap = R_ZDoomColormap(light, z); // ONLY Software mode, vanilla not yet working
|
||||
|
||||
#if (DEF_BANDED_SW_LIGHTING == 1)
|
||||
colormap = floor(colormap) + 0.5;
|
||||
#endif
|
||||
|
||||
// Result is the normalized colormap index (0 bright .. 1 dark)
|
||||
return clamp(colormap, 0.0, 31.0) / 32.0;
|
||||
}
|
||||
|
||||
|
||||
float shadowAttenuation(vec4 lightpos, float lightcolorA)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue