Skip to content
Permalink
Browse files

- add warp2 shader to softpoly2

  • Loading branch information
madame-rachelle committed Mar 24, 2020
1 parent 175b697 commit ecb3ff09772ab58e43a1e2ebb97bbf48eb14d691
Showing with 36 additions and 2 deletions.
  1. +36 −2 src/rendering/polyrenderer/drawers/screen_scanline_setup.cpp
@@ -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,

0 comments on commit ecb3ff0

Please sign in to comment.
You can’t perform that action at this time.