summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rwxr-xr-xindra/llimage/llimage.cpp12
-rwxr-xr-xindra/llimage/llimage.h3
2 files changed, 10 insertions, 5 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index da22ed5e5b..d84989f9c8 100755
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -103,7 +103,8 @@ LLImageBase::LLImageBase()
mHistoBlue(NULL),
mHistoBrightness(NULL),
mVignetteMode(VIGNETTE_MODE_NONE),
- mVignetteGamma(1.0)
+ mVignetteGamma(1.0),
+ mVignetteMin(0.0)
{
}
@@ -1280,10 +1281,11 @@ void LLImageRaw::colorCorrect(const U8* lut_red, const U8* lut_green, const U8*
}
}
-void LLImageRaw::setVignette(EVignetteMode mode, F32 gamma)
+void LLImageRaw::setVignette(EVignetteMode mode, F32 gamma, F32 min)
{
mVignetteMode = mode;
mVignetteGamma = gamma;
+ mVignetteMin = llclampf(min);
// We always center the vignette on the image and fits it in the image smallest dimension
mVignetteCenterX = getWidth()/2;
mVignetteCenterY = getHeight()/2;
@@ -1293,9 +1295,11 @@ void LLImageRaw::setVignette(EVignetteMode mode, F32 gamma)
F32 LLImageRaw::getVignetteAlpha(S32 i, S32 j)
{
// alpha is a modified gaussian value, with a center and fading in a circular pattern toward the edges
- // the gamma parameter controls the intensity of the drop down from alpha 1.0 to 0.0
+ // The gamma parameter controls the intensity of the drop down from alpha 1.0 (center) to 0.0
F32 d_center_square = (i - mVignetteCenterX)*(i - mVignetteCenterX) + (j - mVignetteCenterY)*(j - mVignetteCenterY);
- return powf(F_E, -(powf((d_center_square/(mVignetteWidth*mVignetteWidth)),mVignetteGamma)/2.0f));
+ F32 alpha = powf(F_E, -(powf((d_center_square/(mVignetteWidth*mVignetteWidth)),mVignetteGamma)/2.0f));
+ // We rescale alpha between min and 1.0 so to avoid complete fading if so desired.
+ return (mVignetteMin + alpha * (1.0 - mVignetteMin));
}
U32* LLImageRaw::getBrightnessHistogram()
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index b9f6a12bdd..404f1c0769 100755
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -170,6 +170,7 @@ protected:
S32 mVignetteCenterY;
S32 mVignetteWidth;
F32 mVignetteGamma;
+ F32 mVignetteMin;
public:
static void generateMip(const U8 *indata, U8* mipdata, int width, int height, S32 nchannels);
@@ -292,7 +293,7 @@ public:
// Filter Primitives
void colorTransform(const LLMatrix3 &transform);
void colorCorrect(const U8* lut_red, const U8* lut_green, const U8* lut_blue);
- void setVignette(EVignetteMode mode, F32 gamma);
+ void setVignette(EVignetteMode mode, F32 gamma, F32 min);
U32* getBrightnessHistogram();
protected: