summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2019-02-05 22:14:35 +0200
committerandreykproductengine <andreykproductengine@lindenlab.com>2019-02-05 22:14:35 +0200
commita19d7c92b51fa0272e1387d916a7fa4cfad61a26 (patch)
treeb7426571cab642369e1ded2e03edf060fd95b52f
parentb5a7874ba522089cf942fb9ad6fcd35383f69a88 (diff)
temp fog
-rw-r--r--indra/newview/lldrawpoolwater.cpp71
1 files changed, 68 insertions, 3 deletions
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 23749d7adb..66d8306f97 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -59,6 +59,65 @@ BOOL LLDrawPoolWater::sNeedsReflectionUpdate = TRUE;
BOOL LLDrawPoolWater::sNeedsDistortionUpdate = TRUE;
F32 LLDrawPoolWater::sWaterFogEnd = 0.f;
+
+class LLFastLn
+{
+public:
+ LLFastLn()
+ {
+ mTable[0] = 0;
+ for (S32 i = 1; i < 257; i++)
+ {
+ mTable[i] = log((F32)i);
+ }
+ }
+
+ F32 ln(F32 x)
+ {
+ const F32 OO_255 = 0.003921568627450980392156862745098f;
+ const F32 LN_255 = 5.5412635451584261462455391880218f;
+
+ if (x < OO_255)
+ {
+ return log(x);
+ }
+ else
+ if (x < 1)
+ {
+ x *= 255.f;
+ S32 index = llfloor(x);
+ F32 t = x - index;
+ F32 low = mTable[index];
+ F32 high = mTable[index + 1];
+ return low + t * (high - low) - LN_255;
+ }
+ else
+ if (x <= 255)
+ {
+ S32 index = llfloor(x);
+ F32 t = x - index;
+ F32 low = mTable[index];
+ F32 high = mTable[index + 1];
+ return low + t * (high - low);
+ }
+ else
+ {
+ return log(x);
+ }
+ }
+
+ F32 pow(F32 x, F32 y)
+ {
+ return (F32)LL_FAST_EXP(y * ln(x));
+ }
+
+
+private:
+ F32 mTable[257]; // index 0 is unused
+};
+
+static LLFastLn gFastLn;
+
LLDrawPoolWater::LLDrawPoolWater() : LLFacePool(POOL_WATER)
{
}
@@ -536,17 +595,23 @@ void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& li
shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
+ F32 density = pwater->getWaterFogDensity();
+ F32 density_2 = gFastLn.pow(2.f, density);
shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR, 1, pwater->getWaterFogColor().mV);
- shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, pwater->getWaterFogDensity());
+ shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, density_2);
// bind reflection texture from RenderTarget
S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);
gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis);
if (mShaderLevel == 1)
- {
+ {
+ density = llclamp(density, 0.f, 10.f);
+ density /= 10.0f;
+ density = 1.0f - density;
+ density *= density * density;
LLColor4 fog_color(pwater->getWaterFogColor(), 0.f);
- fog_color[3] = pwater->getWaterFogDensity();
+ fog_color[3] = density;
shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, fog_color.mV);
}