summaryrefslogtreecommitdiff
path: root/indra/llimage/llimage.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2014-01-09 21:58:30 -0800
committerMerov Linden <merov@lindenlab.com>2014-01-09 21:58:30 -0800
commit0c7cab771cb7972ed44eedf0c16133ef082eb9e1 (patch)
treeb4974ed537878185afca3a9ffa529357a75a15d2 /indra/llimage/llimage.cpp
parenta2f9aea3b471f86bc3f86036f3a0fae16560fa3b (diff)
ACME-1236 : Add lines as a new type of vignette and Brightscan as an example
Diffstat (limited to 'indra/llimage/llimage.cpp')
-rwxr-xr-xindra/llimage/llimage.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 14fa71d828..3105fe3746 100755
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -1372,9 +1372,10 @@ void LLImageRaw::filterScreen(EScreenMode mode, const S32 wave_length, const F32
}
}
-void LLImageRaw::setVignette(EVignetteMode mode, F32 gamma, F32 min)
+void LLImageRaw::setVignette(EVignetteMode mode, EVignetteType type, F32 gamma, F32 min)
{
mVignetteMode = mode;
+ mVignetteType = type;
mVignetteGamma = gamma;
mVignetteMin = llclampf(min);
// We always center the vignette on the image and fits it in the image smallest dimension
@@ -1385,10 +1386,20 @@ void LLImageRaw::setVignette(EVignetteMode mode, F32 gamma, F32 min)
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 (center) to 0.0
- F32 d_center_square = (i - mVignetteCenterX)*(i - mVignetteCenterX) + (j - mVignetteCenterY)*(j - mVignetteCenterY);
- F32 alpha = powf(F_E, -(powf((d_center_square/(mVignetteWidth*mVignetteWidth)),mVignetteGamma)/2.0f));
+ F32 alpha = 1.0;
+ if (mVignetteType == VIGNETTE_TYPE_CENTER)
+ {
+ // 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 (center) to 0.0
+ F32 d_center_square = (i - mVignetteCenterX)*(i - mVignetteCenterX) + (j - mVignetteCenterY)*(j - mVignetteCenterY);
+ alpha = powf(F_E, -(powf((d_center_square/(mVignetteWidth*mVignetteWidth)),mVignetteGamma)/2.0f));
+ }
+ else if (mVignetteType == VIGNETTE_TYPE_LINES)
+ {
+ // alpha varies according to a squared sine function vertically.
+ // gamma is interpreted as the wavelength (in pixels) of the sine in that case.
+ alpha = (sinf(2*F_PI*j/mVignetteGamma) > 0.0 ? 1.0 : 0.0);
+ }
// We rescale alpha between min and 1.0 so to avoid complete fading if so desired.
return (mVignetteMin + alpha * (1.0 - mVignetteMin));
}