diff --git a/src/rendering/polyrenderer/drawers/screen_shader.cpp b/src/rendering/polyrenderer/drawers/screen_shader.cpp index ed446ad2ae..1d6a7defa8 100644 --- a/src/rendering/polyrenderer/drawers/screen_shader.cpp +++ b/src/rendering/polyrenderer/drawers/screen_shader.cpp @@ -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(clamp(thread->mainVertexShader.Data.uFogColor.r, 0.0f, 1.0f) * 255.0f), + static_cast(clamp(thread->mainVertexShader.Data.uFogColor.g, 0.0f, 1.0f) * 255.0f), + static_cast(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(clamp(1.0f - (1.0f / 255.0f), 0.0f, 1.0f) * 255.0f); + fragcolor[x] = fogcolor | alpha; } }