- add warp2 shader to softpoly2

This commit is contained in:
Rachael Alexanderson 2020-03-24 14:05:39 -04:00
parent 175b697ba2
commit ecb3ff0977

View file

@ -434,6 +434,33 @@ static void WriteVaryingWarp1(float posU, float posV, float stepU, float stepV,
}
}
static void WriteVaryingWarp2(float posU, float posV, float stepU, float stepV, int x0, int x1, PolyTriangleThreadData* thread)
{
float pi2 = 3.14159265358979323846f * 2.0f;
float timer = thread->mainVertexShader.Data.timer;
const float* w = thread->scanline.W;
uint16_t* scanlineU = thread->scanline.U;
uint16_t* scanlineV = thread->scanline.V;
for (int x = x0; x < x1; x++)
{
float u = posU * w[x];
float v = posV * w[x];
v += (0.5f + sin(pi2 * (v + timer * 0.61f + 900.f/8192.f)) + sin(pi2 * (u * 2.0f + timer * 0.36f + 300.0f/8192.0f))) * 0.025f;
u += (0.5f + sin(pi2 * (v + timer * 0.49f + 700.f/8192.f)) + sin(pi2 * (u * 2.0f + timer * 0.49f + 1200.0f/8192.0f))) * 0.025f;
u = u - std::floor(u);
v = v - std::floor(v);
scanlineU[x] = static_cast<uint32_t>(static_cast<int32_t>(u * static_cast<float>(0x1000'0000)) << 4) >> 16;
scanlineV[x] = static_cast<uint32_t>(static_cast<int32_t>(v * static_cast<float>(0x1000'0000)) << 4) >> 16;
posU += stepU;
posV += stepV;
}
}
#ifdef NO_SSE
static void WriteVaryingColor(float pos, float step, int x0, int x1, const float* w, uint8_t* varying)
{
@ -475,9 +502,16 @@ void WriteVaryings(int y, int x0, int x1, const TriDrawTriangleArgs* args, PolyT
float startX = x0 + (0.5f - args->v1->x);
float startY = y + (0.5f - args->v1->y);
if (thread->EffectState == SHADER_Warp1 || thread->EffectState == SHADER_Warp2)
void (*useShader)(float posU, float posV, float stepU, float stepV, int x0, int x1, PolyTriangleThreadData* thread) = nullptr;
if (thread->EffectState == SHADER_Warp1)
useShader = &WriteVaryingWarp1;
else if (thread->EffectState == SHADER_Warp2)
useShader = &WriteVaryingWarp2;
if (useShader)
{
WriteVaryingWarp1(
useShader(
args->v1->u * args->v1->w + args->gradientX.U * startX + args->gradientY.U * startY,
args->v1->v * args->v1->w + args->gradientX.V * startX + args->gradientY.V * startY,
args->gradientX.U,