summaryrefslogtreecommitdiff
path: root/indra
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
parenta2f9aea3b471f86bc3f86036f3a0fae16560fa3b (diff)
ACME-1236 : Add lines as a new type of vignette and Brightscan as an example
Diffstat (limited to 'indra')
-rwxr-xr-xindra/integration_tests/llimage_libtest/llimage_libtest.cpp12
-rwxr-xr-xindra/llimage/llimage.cpp21
-rwxr-xr-xindra/llimage/llimage.h9
-rwxr-xr-xindra/newview/app_settings/filters/Brightscan.xml23
4 files changed, 55 insertions, 10 deletions
diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp
index 90a7c09442..2447e00028 100755
--- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp
+++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp
@@ -158,11 +158,15 @@ void execute_filter(const LLSD& filter_data, LLPointer<LLImageRaw> raw_image)
// Execute the filter described on this line
if (filter_name == "blend")
{
- raw_image->setVignette(VIGNETTE_MODE_BLEND,(float)(filter_data[i][1].asReal()),(float)(filter_data[i][2].asReal()));
+ raw_image->setVignette(VIGNETTE_MODE_BLEND,VIGNETTE_TYPE_CENTER,(float)(filter_data[i][1].asReal()),(float)(filter_data[i][2].asReal()));
}
else if (filter_name == "fade")
{
- raw_image->setVignette(VIGNETTE_MODE_FADE,(float)(filter_data[i][1].asReal()),(float)(filter_data[i][2].asReal()));
+ raw_image->setVignette(VIGNETTE_MODE_FADE,VIGNETTE_TYPE_CENTER,(float)(filter_data[i][1].asReal()),(float)(filter_data[i][2].asReal()));
+ }
+ else if (filter_name == "lines")
+ {
+ raw_image->setVignette(VIGNETTE_MODE_BLEND,VIGNETTE_TYPE_LINES,(float)(filter_data[i][1].asReal()),(float)(filter_data[i][2].asReal()));
}
else if (filter_name == "sepia")
{
@@ -780,11 +784,11 @@ int main(int argc, char** argv)
// Set the vignette if any
if (vignette_name == "blend")
{
- raw_image->setVignette(VIGNETTE_MODE_BLEND,(float)(vignette_param_1),(float)(vignette_param_2));
+ raw_image->setVignette(VIGNETTE_MODE_BLEND,VIGNETTE_TYPE_CENTER,(float)(vignette_param_1),(float)(vignette_param_2));
}
else if (vignette_name == "fade")
{
- raw_image->setVignette(VIGNETTE_MODE_FADE,(float)(vignette_param_1),(float)(vignette_param_2));
+ raw_image->setVignette(VIGNETTE_MODE_FADE,VIGNETTE_TYPE_CENTER,(float)(vignette_param_1),(float)(vignette_param_2));
}
// Apply filter if any
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:
diff --git a/indra/newview/app_settings/filters/Brightscan.xml b/indra/newview/app_settings/filters/Brightscan.xml
new file mode 100755
index 0000000000..8b10687ef5
--- /dev/null
+++ b/indra/newview/app_settings/filters/Brightscan.xml
@@ -0,0 +1,23 @@
+<llsd>
+ <array>
+ <array>
+ <string>linearize</string>
+ <real>0.01</real>
+ <real>1.0</real>
+ <real>1.0</real>
+ <real>1.0</real>
+ </array>
+ <array>
+ <string>lines</string>
+ <real>10.0</real>
+ <real>0.0</real>
+ </array>
+ <array>
+ <string>brighten</string>
+ <real>100.0</real>
+ <real>1.0</real>
+ <real>1.0</real>
+ <real>1.0</real>
+ </array>
+ </array>
+</llsd>