mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-12 05:11:45 +00:00
- fix fill color and translucency
This commit is contained in:
parent
eff38393af
commit
be5ecce598
5 changed files with 32 additions and 10 deletions
|
@ -86,9 +86,29 @@ void PolyVertexInputAssembly::Load(PolyTriangleThreadData *thread, const void *v
|
|||
const uint8_t *vertex = static_cast<const uint8_t*>(vertices) + mStride * index;
|
||||
const float *attrVertex = reinterpret_cast<const float*>(vertex + mOffsets[VATTR_VERTEX]);
|
||||
const float *attrTexcoord = reinterpret_cast<const float*>(vertex + mOffsets[VATTR_TEXCOORD]);
|
||||
const uint8_t *attrColor = reinterpret_cast<const uint8_t*>(vertex + mOffsets[VATTR_COLOR]);
|
||||
|
||||
thread->mainVertexShader.aPosition = { attrVertex[0], attrVertex[1], attrVertex[2], 1.0f };
|
||||
thread->mainVertexShader.aTexCoord = { attrTexcoord[0], attrTexcoord[1] };
|
||||
|
||||
if (UseVertexData)
|
||||
{
|
||||
uint32_t r = attrColor[0];
|
||||
uint32_t g = attrColor[1];
|
||||
uint32_t b = attrColor[2];
|
||||
uint32_t a = attrColor[3];
|
||||
thread->mainVertexShader.aColor = MAKEARGB(a, r, g, b);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto &c = thread->mainVertexShader.Data.uVertexColor;
|
||||
thread->mainVertexShader.aColor = MAKEARGB(
|
||||
static_cast<uint32_t>(c.W * 255.0f + 0.5f),
|
||||
static_cast<uint32_t>(c.X * 255.0f + 0.5f),
|
||||
static_cast<uint32_t>(c.Y * 255.0f + 0.5f),
|
||||
static_cast<uint32_t>(c.Z * 255.0f + 0.5f)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -330,12 +330,7 @@ void PolyTriangleThreadData::PushStreamData(const StreamData &data, const PolyPu
|
|||
case SHADER_Paletted:
|
||||
break;
|
||||
case SHADER_NoTexture:
|
||||
drawargs.SetStyle(TriBlendMode::Fill);
|
||||
drawargs.SetColor(MAKEARGB(
|
||||
static_cast<uint32_t>(mainVertexShader.Data.uVertexColor.W * 255.0f + 0.5f),
|
||||
static_cast<uint32_t>(mainVertexShader.Data.uVertexColor.X * 255.0f + 0.5f),
|
||||
static_cast<uint32_t>(mainVertexShader.Data.uVertexColor.Y * 255.0f + 0.5f),
|
||||
static_cast<uint32_t>(mainVertexShader.Data.uVertexColor.Z * 255.0f + 0.5f)), 0);
|
||||
drawargs.SetStyle(TriBlendMode::FillTranslucent);
|
||||
return;
|
||||
case SHADER_BasicFuzz:
|
||||
case SHADER_SmoothFuzz:
|
||||
|
@ -346,7 +341,6 @@ void PolyTriangleThreadData::PushStreamData(const StreamData &data, const PolyPu
|
|||
case SHADER_SmoothNoiseFuzz:
|
||||
case SHADER_SoftwareFuzz:
|
||||
drawargs.SetStyle(TriBlendMode::Fuzzy);
|
||||
drawargs.SetColor(0xff000000, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -431,7 +425,7 @@ void PolyTriangleThreadData::SetDepthRange(float min, float max)
|
|||
|
||||
void PolyTriangleThreadData::SetDepthBias(float depthBiasConstantFactor, float depthBiasSlopeFactor)
|
||||
{
|
||||
depthbias = (float)(depthBiasConstantFactor / 65536.0);
|
||||
depthbias = (float)(depthBiasConstantFactor / 2500.0);
|
||||
}
|
||||
|
||||
void PolyTriangleThreadData::SetColorMask(bool r, bool g, bool b, bool a)
|
||||
|
@ -659,6 +653,8 @@ void PolyTriangleThreadData::DrawShadedTriangle(const ShadedTriVertex *const* ve
|
|||
if (IsDegenerate(vert))
|
||||
return;
|
||||
|
||||
drawargs.SetColor(vert[0]->vColor, 0);
|
||||
|
||||
// Cull, clip and generate additional vertices as needed
|
||||
ScreenTriVertex clippedvert[max_additional_vertices];
|
||||
int numclipvert = ClipEdge(vert);
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
Vec4f gl_Position;
|
||||
float gl_ClipDistance[5];
|
||||
Vec4f vTexCoord;
|
||||
uint32_t vColor;
|
||||
Vec4f pixelpos;
|
||||
};
|
||||
|
||||
|
@ -24,13 +25,12 @@ public:
|
|||
// Input
|
||||
Vec4f aPosition;
|
||||
Vec2f aTexCoord;
|
||||
Vec4f aColor;
|
||||
uint32_t aColor;
|
||||
Vec4f aVertex2;
|
||||
Vec4f aNormal;
|
||||
Vec4f aNormal2;
|
||||
|
||||
// Output
|
||||
Vec4f vColor;
|
||||
Vec3f glowdist;
|
||||
Vec3f gradientdist;
|
||||
Vec4f vWorldNormal;
|
||||
|
@ -243,6 +243,8 @@ public:
|
|||
pixelpos = (*objectToWorld) * objpos;
|
||||
}
|
||||
|
||||
vColor = drawargs->Color();
|
||||
|
||||
// Calculate gl_ClipDistance[i]
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
|
|
|
@ -2128,6 +2128,7 @@ void(*ScreenTriangle::SpanDrawers8[])(int, int, int, const TriDrawTriangleArgs *
|
|||
&DrawSpan8<TriScreenDrawerModes::StyleFogBoundary>,
|
||||
&DrawSpan8<TriScreenDrawerModes::StyleSrcColor>,
|
||||
&DrawSpan8<TriScreenDrawerModes::StyleFill>,
|
||||
&DrawSpan8<TriScreenDrawerModes::StyleFillTranslucent>,
|
||||
&DrawSpan8<TriScreenDrawerModes::StyleNormal>,
|
||||
&DrawSpan8<TriScreenDrawerModes::StyleFuzzy>,
|
||||
&DrawSpan8<TriScreenDrawerModes::StyleStencil>,
|
||||
|
@ -2160,6 +2161,7 @@ void(*ScreenTriangle::SpanDrawers32[])(int, int, int, const TriDrawTriangleArgs
|
|||
&DrawSpan32<TriScreenDrawerModes::StyleFogBoundary>,
|
||||
&DrawSpan32<TriScreenDrawerModes::StyleSrcColor>,
|
||||
&DrawSpan32<TriScreenDrawerModes::StyleFill>,
|
||||
&DrawSpan32<TriScreenDrawerModes::StyleFillTranslucent>,
|
||||
&DrawSpan32<TriScreenDrawerModes::StyleNormal>,
|
||||
&DrawSpan32<TriScreenDrawerModes::StyleFuzzy>,
|
||||
&DrawSpan32<TriScreenDrawerModes::StyleStencil>,
|
||||
|
|
|
@ -104,6 +104,7 @@ enum class TriBlendMode
|
|||
FogBoundary,
|
||||
SrcColor,
|
||||
Fill,
|
||||
FillTranslucent,
|
||||
Normal,
|
||||
Fuzzy,
|
||||
Stencil,
|
||||
|
@ -162,6 +163,7 @@ namespace TriScreenDrawerModes
|
|||
struct StyleFogBoundary { static const int BlendOp = STYLEOP_Add, BlendSrc = STYLEALPHA_One, BlendDest = STYLEALPHA_Zero, Flags = STYLEF_Alpha1, SWFlags = SWSTYLEF_FogBoundary; };
|
||||
struct StyleSrcColor { static const int BlendOp = STYLEOP_Add, BlendSrc = STYLEALPHA_Src, BlendDest = STYLEALPHA_InvSrc, Flags = STYLEF_Alpha1, SWFlags = SWSTYLEF_SrcColorOneMinusSrcColor; };
|
||||
struct StyleFill { static const int BlendOp = STYLEOP_Add, BlendSrc = STYLEALPHA_One, BlendDest = STYLEALPHA_Zero, Flags = STYLEF_Alpha1, SWFlags = SWSTYLEF_Fill; };
|
||||
struct StyleFillTranslucent { static const int BlendOp = STYLEOP_Add, BlendSrc = STYLEALPHA_Src, BlendDest = STYLEALPHA_InvSrc, Flags = STYLEF_Alpha1, SWFlags = SWSTYLEF_Fill; };
|
||||
|
||||
struct StyleNormal { static const int BlendOp = STYLEOP_Add, BlendSrc = STYLEALPHA_Src, BlendDest = STYLEALPHA_InvSrc, Flags = STYLEF_Alpha1, SWFlags = 0; };
|
||||
struct StyleFuzzy { static const int BlendOp = STYLEOP_Fuzz, BlendSrc = STYLEALPHA_Src, BlendDest = STYLEALPHA_InvSrc, Flags = 0, SWFlags = 0; };
|
||||
|
|
Loading…
Reference in a new issue