mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 15:32:57 +00:00
Some basic fixed light support
This commit is contained in:
parent
1b3d50951a
commit
a092a03c6d
6 changed files with 21 additions and 10 deletions
|
@ -254,7 +254,8 @@ void DrawTriangleCodegen::LoopBlockX(TriDrawVariant variant, bool truecolor)
|
|||
SSAFloat vis = globVis / rcpWTL;
|
||||
SSAFloat shade = 64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f;
|
||||
SSAFloat lightscale = SSAFloat::clamp((shade - SSAFloat::MIN(SSAFloat(24.0f), vis)) / 32.0f, SSAFloat(0.0f), SSAFloat(31.0f / 32.0f));
|
||||
diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false);
|
||||
SSAInt diminishedlight = SSAInt(SSAFloat::clamp((1.0f - lightscale) * 256.0f + 0.5f, SSAFloat(0.0f), SSAFloat(256.0f)), false);
|
||||
currentlight = is_fixed_light.select(light, diminishedlight);
|
||||
|
||||
SetStencilBlock(x / 8 + y / 8 * stencilPitch);
|
||||
|
||||
|
@ -473,7 +474,7 @@ void DrawTriangleCodegen::ProcessPixel(SSAUBytePtr buffer, SSAIntPtr subsectorbu
|
|||
{
|
||||
SSAVec4i fg = texturePixels[uvoffset * 4].load_vec4ub(true);
|
||||
SSAInt fg_alpha = fg[3];
|
||||
fg = (fg * diminishedlight) >> 8;
|
||||
fg = (fg * currentlight) >> 8;
|
||||
fg.insert(3, fg_alpha);
|
||||
|
||||
if (variant == TriDrawVariant::DrawMasked || variant == TriDrawVariant::DrawSubsector)
|
||||
|
@ -625,4 +626,5 @@ void DrawTriangleCodegen::LoadUniforms(SSAValue uniforms)
|
|||
|
||||
is_simple_shade = (flags & TriUniforms::simple_shade) == SSAInt(TriUniforms::simple_shade);
|
||||
is_nearest_filter = (flags & TriUniforms::nearest_filter) == SSAInt(TriUniforms::nearest_filter);
|
||||
is_fixed_light = (flags & TriUniforms::fixed_light) == SSAInt(TriUniforms::fixed_light);
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ private:
|
|||
SSAShadeConstants shade_constants;
|
||||
SSABool is_simple_shade;
|
||||
SSABool is_nearest_filter;
|
||||
SSABool is_fixed_light;
|
||||
|
||||
SSAUBytePtr stencilValues;
|
||||
SSAIntPtr stencilMasks;
|
||||
|
@ -115,7 +116,7 @@ private:
|
|||
|
||||
SSAInt x, y;
|
||||
SSAInt x0, x1, y0, y1;
|
||||
SSAInt diminishedlight;
|
||||
SSAInt currentlight;
|
||||
SSAInt varyingPos[TriVertex::NumVarying];
|
||||
SSAInt varyingStepPos[TriVertex::NumVarying];
|
||||
SSAInt varyingStartStepX[TriVertex::NumVarying];
|
||||
|
|
|
@ -230,7 +230,7 @@ struct TriUniforms
|
|||
{
|
||||
simple_shade = 1,
|
||||
nearest_filter = 2,
|
||||
diminishing_lighting = 4
|
||||
fixed_light = 4
|
||||
};
|
||||
|
||||
TriMatrix objectToClip;
|
||||
|
|
|
@ -82,9 +82,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin
|
|||
TriUniforms uniforms;
|
||||
uniforms.objectToClip = worldToClip;
|
||||
uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f);
|
||||
if (fixedlightlev >= 0)
|
||||
uniforms.light = (uint32_t)(fixedlightlev / 255.0f * 256.0f);
|
||||
else if (fixedcolormap)
|
||||
if (fixedlightlev >= 0 || fixedcolormap)
|
||||
uniforms.light = 256;
|
||||
uniforms.flags = 0;
|
||||
uniforms.subsectorDepth = isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth;
|
||||
|
|
|
@ -111,10 +111,20 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, AActor *thing, subse
|
|||
vertices[i].varying[0] = 1.0f - vertices[i].varying[0];
|
||||
}
|
||||
|
||||
bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
|
||||
|
||||
TriUniforms uniforms;
|
||||
uniforms.objectToClip = worldToClip;
|
||||
uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f);
|
||||
uniforms.flags = 0;
|
||||
if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap)
|
||||
{
|
||||
uniforms.light = 256;
|
||||
uniforms.flags = TriUniforms::fixed_light;
|
||||
}
|
||||
else
|
||||
{
|
||||
uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f);
|
||||
uniforms.flags = 0;
|
||||
}
|
||||
uniforms.subsectorDepth = subsectorDepth;
|
||||
|
||||
PolyDrawArgs args;
|
||||
|
|
|
@ -244,7 +244,7 @@ int RenderPolyWall::GetLightLevel()
|
|||
{
|
||||
bool foggy = false;
|
||||
int actualextralight = foggy ? 0 : extralight << 4;
|
||||
return Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight;
|
||||
return clamp(Line->sidedef->GetLightLevel(foggy, Line->frontsector->lightlevel) + actualextralight, 0, 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue