Implement EFF_FOGBOUNDARY

This commit is contained in:
Magnus Norddahl 2019-12-15 17:33:49 +01:00
parent 0fd964ec4f
commit b44c40a63d
1 changed files with 13 additions and 4 deletions

View File

@ -46,13 +46,22 @@ static uint32_t SampleTexture(uint32_t u, uint32_t v, const void* texPixels, int
static void EffectFogBoundary(int x0, int x1, PolyTriangleThreadData* thread)
{
float uFogDensity = thread->PushConstants->uFogDensity;
uint32_t fogcolor = MAKEARGB(
0,
static_cast<int>(clamp(thread->mainVertexShader.Data.uFogColor.r, 0.0f, 1.0f) * 255.0f),
static_cast<int>(clamp(thread->mainVertexShader.Data.uFogColor.g, 0.0f, 1.0f) * 255.0f),
static_cast<int>(clamp(thread->mainVertexShader.Data.uFogColor.b, 0.0f, 1.0f) * 255.0f));
uint32_t* fragcolor = thread->scanline.FragColor;
for (int x = x0; x < x1; x++)
{
/*float fogdist = pixelpos.w;
float fogfactor = exp2(uFogDensity * fogdist);
FragColor = vec4(uFogColor.rgb, 1.0 - fogfactor);*/
fragcolor[x] = 0;
float fogdist = thread->scanline.W[x];
float fogfactor = std::exp2(uFogDensity * fogdist);
// FragColor = vec4(uFogColor.rgb, 1.0 - fogfactor):
uint32_t alpha = static_cast<int>(clamp(1.0f - (1.0f / 255.0f), 0.0f, 1.0f) * 255.0f);
fragcolor[x] = fogcolor | alpha;
}
}