mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
Capped sky rendering
This commit is contained in:
parent
ff063a33b5
commit
dbacb75617
6 changed files with 56 additions and 28 deletions
|
@ -107,6 +107,7 @@ extern "C"
|
|||
void TriDrawNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawNormal8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawNormal8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
|
@ -121,6 +122,7 @@ extern "C"
|
|||
void TriDrawNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawNormal32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawNormal32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
|
@ -135,6 +137,7 @@ extern "C"
|
|||
void TriFillNormal8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
|
@ -149,6 +152,7 @@ extern "C"
|
|||
void TriFillNormal32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillNormal32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
|
@ -163,6 +167,7 @@ extern "C"
|
|||
void TriDrawSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
|
@ -177,6 +182,7 @@ extern "C"
|
|||
void TriDrawSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriDrawSubsector32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector8_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector8_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector8_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
|
@ -191,6 +197,7 @@ extern "C"
|
|||
void TriFillSubsector8_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector8_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector8_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector8_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector32_0_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector32_1_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector32_2_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
|
@ -205,6 +212,7 @@ extern "C"
|
|||
void TriFillSubsector32_11_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector32_12_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector32_13_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriFillSubsector32_14_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriStencil_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
void TriStencilClose_SSE2(const TriDrawTriangleArgs *, WorkerThreadData *);
|
||||
}
|
||||
|
@ -289,6 +297,7 @@ Drawers::Drawers()
|
|||
TriDrawNormal8.push_back(TriDrawNormal8_11_SSE2);
|
||||
TriDrawNormal8.push_back(TriDrawNormal8_12_SSE2);
|
||||
TriDrawNormal8.push_back(TriDrawNormal8_13_SSE2);
|
||||
TriDrawNormal8.push_back(TriDrawNormal8_14_SSE2);
|
||||
TriDrawNormal32.push_back(TriDrawNormal32_0_SSE2);
|
||||
TriDrawNormal32.push_back(TriDrawNormal32_1_SSE2);
|
||||
TriDrawNormal32.push_back(TriDrawNormal32_2_SSE2);
|
||||
|
@ -303,6 +312,7 @@ Drawers::Drawers()
|
|||
TriDrawNormal32.push_back(TriDrawNormal32_11_SSE2);
|
||||
TriDrawNormal32.push_back(TriDrawNormal32_12_SSE2);
|
||||
TriDrawNormal32.push_back(TriDrawNormal32_13_SSE2);
|
||||
TriDrawNormal32.push_back(TriDrawNormal32_14_SSE2);
|
||||
TriFillNormal8.push_back(TriFillNormal8_0_SSE2);
|
||||
TriFillNormal8.push_back(TriFillNormal8_1_SSE2);
|
||||
TriFillNormal8.push_back(TriFillNormal8_2_SSE2);
|
||||
|
@ -317,6 +327,7 @@ Drawers::Drawers()
|
|||
TriFillNormal8.push_back(TriFillNormal8_11_SSE2);
|
||||
TriFillNormal8.push_back(TriFillNormal8_12_SSE2);
|
||||
TriFillNormal8.push_back(TriFillNormal8_13_SSE2);
|
||||
TriFillNormal8.push_back(TriFillNormal8_14_SSE2);
|
||||
TriFillNormal32.push_back(TriFillNormal32_0_SSE2);
|
||||
TriFillNormal32.push_back(TriFillNormal32_1_SSE2);
|
||||
TriFillNormal32.push_back(TriFillNormal32_2_SSE2);
|
||||
|
@ -331,6 +342,7 @@ Drawers::Drawers()
|
|||
TriFillNormal32.push_back(TriFillNormal32_11_SSE2);
|
||||
TriFillNormal32.push_back(TriFillNormal32_12_SSE2);
|
||||
TriFillNormal32.push_back(TriFillNormal32_13_SSE2);
|
||||
TriFillNormal32.push_back(TriFillNormal32_14_SSE2);
|
||||
TriDrawSubsector8.push_back(TriDrawSubsector8_0_SSE2);
|
||||
TriDrawSubsector8.push_back(TriDrawSubsector8_1_SSE2);
|
||||
TriDrawSubsector8.push_back(TriDrawSubsector8_2_SSE2);
|
||||
|
@ -345,6 +357,7 @@ Drawers::Drawers()
|
|||
TriDrawSubsector8.push_back(TriDrawSubsector8_11_SSE2);
|
||||
TriDrawSubsector8.push_back(TriDrawSubsector8_12_SSE2);
|
||||
TriDrawSubsector8.push_back(TriDrawSubsector8_13_SSE2);
|
||||
TriDrawSubsector8.push_back(TriDrawSubsector8_14_SSE2);
|
||||
TriDrawSubsector32.push_back(TriDrawSubsector32_0_SSE2);
|
||||
TriDrawSubsector32.push_back(TriDrawSubsector32_1_SSE2);
|
||||
TriDrawSubsector32.push_back(TriDrawSubsector32_2_SSE2);
|
||||
|
@ -359,6 +372,7 @@ Drawers::Drawers()
|
|||
TriDrawSubsector32.push_back(TriDrawSubsector32_11_SSE2);
|
||||
TriDrawSubsector32.push_back(TriDrawSubsector32_12_SSE2);
|
||||
TriDrawSubsector32.push_back(TriDrawSubsector32_13_SSE2);
|
||||
TriDrawSubsector32.push_back(TriDrawSubsector32_14_SSE2);
|
||||
TriFillSubsector8.push_back(TriFillSubsector8_0_SSE2);
|
||||
TriFillSubsector8.push_back(TriFillSubsector8_1_SSE2);
|
||||
TriFillSubsector8.push_back(TriFillSubsector8_2_SSE2);
|
||||
|
@ -373,6 +387,7 @@ Drawers::Drawers()
|
|||
TriFillSubsector8.push_back(TriFillSubsector8_11_SSE2);
|
||||
TriFillSubsector8.push_back(TriFillSubsector8_12_SSE2);
|
||||
TriFillSubsector8.push_back(TriFillSubsector8_13_SSE2);
|
||||
TriFillSubsector8.push_back(TriFillSubsector8_14_SSE2);
|
||||
TriFillSubsector32.push_back(TriFillSubsector32_0_SSE2);
|
||||
TriFillSubsector32.push_back(TriFillSubsector32_1_SSE2);
|
||||
TriFillSubsector32.push_back(TriFillSubsector32_2_SSE2);
|
||||
|
@ -387,6 +402,7 @@ Drawers::Drawers()
|
|||
TriFillSubsector32.push_back(TriFillSubsector32_11_SSE2);
|
||||
TriFillSubsector32.push_back(TriFillSubsector32_12_SSE2);
|
||||
TriFillSubsector32.push_back(TriFillSubsector32_13_SSE2);
|
||||
TriFillSubsector32.push_back(TriFillSubsector32_14_SSE2);
|
||||
TriStencil = TriStencil_SSE2;
|
||||
TriStencilClose = TriStencilClose_SSE2;
|
||||
}
|
||||
|
|
|
@ -254,10 +254,11 @@ enum class TriBlendMode
|
|||
TranslateAdd, // blend_add(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
|
||||
TranslateSub, // blend_sub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
|
||||
TranslateRevSub,// blend_revsub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
|
||||
AddSrcColorOneMinusSrcColor // glBlendMode(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) used by GZDoom's fullbright additive sprites
|
||||
AddSrcColorOneMinusSrcColor, // glBlendMode(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) used by GZDoom's fullbright additive sprites
|
||||
Skycap // Fade to sky color when the V texture coordinate go beyond the [-1, 1] range
|
||||
};
|
||||
|
||||
inline int NumTriBlendModes() { return (int)TriBlendMode::AddSrcColorOneMinusSrcColor + 1; }
|
||||
inline int NumTriBlendModes() { return (int)TriBlendMode::Skycap + 1; }
|
||||
|
||||
class Drawers
|
||||
{
|
||||
|
|
|
@ -66,20 +66,24 @@ void PolySkyDome::Render(const TriMatrix &worldToClip)
|
|||
RenderCapColorRow(args, frontskytex, 0, false);
|
||||
RenderCapColorRow(args, frontskytex, rc, true);
|
||||
|
||||
uint32_t topcapcolor = frontskytex->GetSkyCapColor(false);
|
||||
uint32_t bottomcapcolor = frontskytex->GetSkyCapColor(true);
|
||||
|
||||
for (int i = 1; i <= mRows; i++)
|
||||
{
|
||||
RenderRow(args, i);
|
||||
RenderRow(args, rc + i);
|
||||
RenderRow(args, i, topcapcolor);
|
||||
RenderRow(args, rc + i, bottomcapcolor);
|
||||
}
|
||||
}
|
||||
|
||||
void PolySkyDome::RenderRow(PolyDrawArgs &args, int row)
|
||||
void PolySkyDome::RenderRow(PolyDrawArgs &args, int row, uint32_t capcolor)
|
||||
{
|
||||
args.vinput = &mVertices[mPrimStart[row]];
|
||||
args.vcount = mPrimStart[row + 1] - mPrimStart[row];
|
||||
args.mode = TriangleDrawMode::Strip;
|
||||
args.ccw = false;
|
||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Copy);
|
||||
args.uniforms.color = capcolor;
|
||||
PolyTriangleDrawer::draw(args, TriDrawVariant::DrawNormal, TriBlendMode::Skycap);
|
||||
}
|
||||
|
||||
void PolySkyDome::RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap)
|
||||
|
@ -129,18 +133,6 @@ void PolySkyDome::CreateSkyHemisphere(bool zflip)
|
|||
}
|
||||
}
|
||||
|
||||
TriVertex PolySkyDome::SetVertex(float xx, float yy, float zz, float uu, float vv)
|
||||
{
|
||||
TriVertex v;
|
||||
v.x = xx;
|
||||
v.y = yy;
|
||||
v.z = zz;
|
||||
v.w = 1.0f;
|
||||
v.varying[0] = uu;
|
||||
v.varying[1] = vv;
|
||||
return v;
|
||||
}
|
||||
|
||||
TriVertex PolySkyDome::SetVertexXYZ(float xx, float yy, float zz, float uu, float vv)
|
||||
{
|
||||
TriVertex v;
|
||||
|
@ -166,7 +158,6 @@ void PolySkyDome::SkyVertex(int r, int c, bool zflip)
|
|||
float z = (!zflip) ? scale * height : -scale * height;
|
||||
|
||||
float u, v;
|
||||
//uint32_t color = r == 0 ? 0xffffff : 0xffffffff;
|
||||
|
||||
// And the texture coordinates.
|
||||
if (!zflip) // Flipped Y is for the lower hemisphere.
|
||||
|
@ -184,6 +175,6 @@ void PolySkyDome::SkyVertex(int r, int c, bool zflip)
|
|||
|
||||
// And finally the vertex.
|
||||
TriVertex vert;
|
||||
vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v * 1.2f + 0.5f/*, color*/);
|
||||
vert = SetVertexXYZ(-pos.X, z - 1.f, pos.Y, u * 4.0f, v * 1.2f - 0.5f);
|
||||
mVertices.Push(vert);
|
||||
}
|
||||
|
|
|
@ -38,9 +38,8 @@ private:
|
|||
void SkyVertex(int r, int c, bool yflip);
|
||||
void CreateSkyHemisphere(bool zflip);
|
||||
void CreateDome();
|
||||
void RenderRow(PolyDrawArgs &args, int row);
|
||||
void RenderRow(PolyDrawArgs &args, int row, uint32_t capcolor);
|
||||
void RenderCapColorRow(PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap);
|
||||
|
||||
TriVertex SetVertex(float xx, float yy, float zz, float uu = 0, float vv = 0);
|
||||
TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0);
|
||||
};
|
||||
|
|
|
@ -333,8 +333,6 @@ void DrawTriangleCodegen::SetupAffineBlock()
|
|||
{
|
||||
AffineVaryingPosX[i] = SSAInt(AffineVaryingPosY[i] * rcpW0, false);
|
||||
AffineVaryingStepX[i] = (SSAInt((AffineVaryingPosY[i] + gradVaryingX[i]) * rcpW1, false) - AffineVaryingPosX[i]) / q;
|
||||
AffineVaryingPosX[i] = AffineVaryingPosX[i] << 8;
|
||||
AffineVaryingStepX[i] = AffineVaryingStepX[i] << 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -780,8 +778,8 @@ SSAInt DrawTriangleCodegen::Shade8(SSAInt c)
|
|||
|
||||
SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying)
|
||||
{
|
||||
SSAInt ufrac = varying[0];
|
||||
SSAInt vfrac = varying[1];
|
||||
SSAInt ufrac = varying[0] << 8;
|
||||
SSAInt vfrac = varying[1] << 8;
|
||||
|
||||
SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16;
|
||||
SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16;
|
||||
|
@ -848,6 +846,10 @@ SSAVec4i DrawTriangleCodegen::ProcessPixel32(SSAVec4i bg, SSAInt *varying)
|
|||
fg = Sample32(uvoffset);
|
||||
output = blend_add_srccolor_oneminussrccolor(shade_bgra_simple(fg, currentlight), bg);
|
||||
break;
|
||||
case TriBlendMode::Skycap:
|
||||
fg = Sample32(uvoffset);
|
||||
output = FadeOut(varying[1], fg);
|
||||
break;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -867,8 +869,8 @@ SSAInt DrawTriangleCodegen::ToPal8(SSAVec4i c)
|
|||
|
||||
SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying)
|
||||
{
|
||||
SSAInt ufrac = varying[0];
|
||||
SSAInt vfrac = varying[1];
|
||||
SSAInt ufrac = varying[0] << 8;
|
||||
SSAInt vfrac = varying[1] << 8;
|
||||
|
||||
SSAInt upos = ((ufrac >> 16) * textureWidth) >> 16;
|
||||
SSAInt vpos = ((vfrac >> 16) * textureHeight) >> 16;
|
||||
|
@ -955,11 +957,28 @@ SSAInt DrawTriangleCodegen::ProcessPixel8(SSAInt bg, SSAInt *varying)
|
|||
output = ToPal8(blend_add_srccolor_oneminussrccolor(fg, ToBgra(bg)));
|
||||
output = (palindex == SSAInt(0)).select(bg, output);
|
||||
break;
|
||||
case TriBlendMode::Skycap:
|
||||
fg = ToBgra(Sample8(uvoffset));
|
||||
output = ToPal8(FadeOut(varying[1], fg));
|
||||
break;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
SSAVec4i DrawTriangleCodegen::FadeOut(SSAInt frac, SSAVec4i fg)
|
||||
{
|
||||
int start_fade = 2; // How fast it should fade out
|
||||
|
||||
SSAInt alpha_top = SSAInt::MAX(SSAInt::MIN(frac.ashr(16 - start_fade), SSAInt(256)), SSAInt(0));
|
||||
SSAInt alpha_bottom = SSAInt::MAX(SSAInt::MIN(((2 << 24) - frac).ashr(16 - start_fade), SSAInt(256)), SSAInt(0));
|
||||
SSAInt alpha = SSAInt::MIN(alpha_top, alpha_bottom);
|
||||
SSAInt inv_alpha = 256 - alpha;
|
||||
|
||||
fg = (fg * alpha + SSAVec4i::unpack(color) * inv_alpha) / 256;
|
||||
return fg.insert(3, 255);
|
||||
}
|
||||
|
||||
void DrawTriangleCodegen::SetStencilBlock(SSAInt block)
|
||||
{
|
||||
StencilBlock = stencilValues[block * 64];
|
||||
|
|
|
@ -58,6 +58,8 @@ private:
|
|||
SSAVec4i ToBgra(SSAInt index);
|
||||
SSAInt ToPal8(SSAVec4i c);
|
||||
|
||||
SSAVec4i FadeOut(SSAInt frac, SSAVec4i color);
|
||||
|
||||
void SetStencilBlock(SSAInt block);
|
||||
void StencilClear(SSAUByte value);
|
||||
SSAUByte StencilGetSingle();
|
||||
|
|
Loading…
Reference in a new issue