diff options
author | Merov Linden <merov@lindenlab.com> | 2014-01-09 21:58:30 -0800 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2014-01-09 21:58:30 -0800 |
commit | 0c7cab771cb7972ed44eedf0c16133ef082eb9e1 (patch) | |
tree | b4974ed537878185afca3a9ffa529357a75a15d2 /indra/llimage | |
parent | a2f9aea3b471f86bc3f86036f3a0fae16560fa3b (diff) |
ACME-1236 : Add lines as a new type of vignette and Brightscan as an example
Diffstat (limited to 'indra/llimage')
-rwxr-xr-x | indra/llimage/llimage.cpp | 21 | ||||
-rwxr-xr-x | indra/llimage/llimage.h | 9 |
2 files changed, 24 insertions, 6 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)); } diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index f2bb91a329..a600f2e4a6 100755 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -95,6 +95,12 @@ typedef enum e_vignette_mode VIGNETTE_MODE_FADE = 2 } EVignetteMode; +typedef enum e_vignette_type +{ + VIGNETTE_TYPE_CENTER = 0, + VIGNETTE_TYPE_LINES = 1 +} EVignetteType; + typedef enum e_screen_mode { SCREEN_MODE_2DSINE = 0, @@ -173,6 +179,7 @@ protected: // Vignette filtering EVignetteMode mVignetteMode; + EVignetteType mVignetteType; S32 mVignetteCenterX; S32 mVignetteCenterY; S32 mVignetteWidth; @@ -306,7 +313,7 @@ public: void colorTransform(const LLMatrix3 &transform); void colorCorrect(const U8* lut_red, const U8* lut_green, const U8* lut_blue); void filterScreen(EScreenMode mode, const S32 wave_length, const F32 angle); - void setVignette(EVignetteMode mode, F32 gamma, F32 min); + void setVignette(EVignetteMode mode, EVignetteType type, F32 gamma, F32 min); U32* getBrightnessHistogram(); protected: |