A little bit of postprocess shader tinkering.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @file colorFilterF.glsl
|
||||
*
|
||||
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
#extension GL_ARB_texture_rectangle : enable
|
||||
|
||||
#ifdef DEFINE_GL_FRAGCOLOR
|
||||
out vec4 frag_color;
|
||||
#else
|
||||
#define frag_color gl_FragColor
|
||||
#endif
|
||||
|
||||
uniform sampler2DRect tex0;
|
||||
uniform float vignette_strength; //0 - 1
|
||||
uniform float vignette_radius; //0 - 8
|
||||
uniform float vignette_darkness; //0 - 1
|
||||
uniform float vignette_desaturation; //0 - 10
|
||||
uniform float vignette_chromatic_aberration; //0 - .1
|
||||
uniform vec2 screen_res;
|
||||
|
||||
VARYING vec2 vary_texcoord0;
|
||||
|
||||
float luminance(vec3 color)
|
||||
{
|
||||
/// CALCULATING LUMINANCE (Using NTSC lum weights)
|
||||
/// http://en.wikipedia.org/wiki/Luma_%28video%29
|
||||
return dot(color, vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 color = texture2DRect(tex0, vary_texcoord0).rgb;
|
||||
vec2 norm_texcood = (vary_texcoord0/screen_res);
|
||||
vec2 offset = norm_texcood-vec2(.5);
|
||||
float vignette = clamp(pow(1 - dot(offset,offset),vignette_radius) + 1-vignette_strength, 0.0, 1.0);
|
||||
float inv_vignette = 1-vignette;
|
||||
|
||||
//vignette chromatic aberration (g
|
||||
vec2 shift = screen_res * offset * vignette_chromatic_aberration * inv_vignette;
|
||||
float g = texture2DRect(tex0,vary_texcoord0-shift).g;
|
||||
float b = texture2DRect(tex0,vary_texcoord0-2*shift).b;
|
||||
color.gb = vec2(g,b);
|
||||
|
||||
//vignette 'black' overlay.
|
||||
color = mix(color * vignette, color, 1-vignette_darkness);
|
||||
|
||||
//vignette desaturation
|
||||
color = mix(vec3(luminance(color)), color, clamp(1-inv_vignette*vignette_desaturation,0,1));
|
||||
|
||||
frag_color = vec4(color,1.0);
|
||||
}
|
||||
@@ -25,6 +25,13 @@ uniform float gamma;
|
||||
|
||||
VARYING vec2 vary_texcoord0;
|
||||
|
||||
float luminance(vec3 color)
|
||||
{
|
||||
/// CALCULATING LUMINANCE (Using NTSC lum weights)
|
||||
/// http://en.wikipedia.org/wiki/Luma_%28video%29
|
||||
return dot(color, vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 color = vec3(texture2DRect(tex0, vary_texcoord0.st));
|
||||
@@ -39,7 +46,7 @@ void main(void)
|
||||
color = mix(contrastBase, color, contrast);
|
||||
|
||||
/// Modulate saturation
|
||||
color = mix(vec3(dot(color, lumWeights)), color, saturation);
|
||||
color = mix(vec3(luminance(color)), color, saturation);
|
||||
|
||||
frag_color = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -177,6 +177,8 @@
|
||||
<key>enable_posterize</key>
|
||||
<boolean>0</boolean>
|
||||
<key>enable_motionblur</key>
|
||||
<boolean>0</boolean>
|
||||
<key>enable_vignette</key>
|
||||
<boolean>0</boolean>
|
||||
<key>gauss_blur_passes</key>
|
||||
<integer>2</integer>
|
||||
@@ -194,6 +196,16 @@
|
||||
<real>10</real>
|
||||
<key>blur_strength</key>
|
||||
<real>10</real>
|
||||
<key>vignette_strength</key>
|
||||
<real>0.85</real>
|
||||
<key>vignette_radius</key>
|
||||
<real>0.7</real>
|
||||
<key>vignette_darkness</key>
|
||||
<real>1.0</real>
|
||||
<key>vignette_desaturation</key>
|
||||
<real>1.0</real>
|
||||
<key>vignette_chromatic_aberration</key>
|
||||
<real>0.01</real>
|
||||
</map>
|
||||
</map>
|
||||
</llsd>
|
||||
@@ -172,7 +172,8 @@ LLGLSLShader gPostNightVisionProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not
|
||||
LLGLSLShader gPostGaussianBlurProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList
|
||||
LLGLSLShader gPostPosterizeProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList
|
||||
LLGLSLShader gPostMotionBlurProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList
|
||||
|
||||
LLGLSLShader gPostVignetteProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList
|
||||
|
||||
// Deferred rendering shaders
|
||||
LLGLSLShader gDeferredImpostorProgram(LLViewerShaderMgr::SHADER_DEFERRED);
|
||||
LLGLSLShader gDeferredWaterProgram(LLViewerShaderMgr::SHADER_DEFERRED); //calculatesAtmospherics
|
||||
@@ -908,7 +909,6 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
|
||||
shaderUniforms.push_back("contrast");
|
||||
shaderUniforms.push_back("contrastBase");
|
||||
shaderUniforms.push_back("saturation");
|
||||
shaderUniforms.push_back("lumWeights");
|
||||
|
||||
gPostColorFilterProgram.mName = "Color Filter Shader (Post)";
|
||||
gPostColorFilterProgram.mShaderFiles.clear();
|
||||
@@ -929,7 +929,6 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
|
||||
shaderUniforms.reserve(3);
|
||||
shaderUniforms.push_back("brightMult");
|
||||
shaderUniforms.push_back("noiseStrength");
|
||||
shaderUniforms.push_back("lumWeights");
|
||||
|
||||
gPostNightVisionProgram.mName = "Night Vision Shader (Post)";
|
||||
gPostNightVisionProgram.mShaderFiles.clear();
|
||||
@@ -998,6 +997,26 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
|
||||
gPostMotionBlurProgram.uniform1i("tex1", 1);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
vector<string> shaderUniforms;
|
||||
shaderUniforms.reserve(3);
|
||||
shaderUniforms.push_back("vignette_darkness");
|
||||
shaderUniforms.push_back("vignette_radius");
|
||||
shaderUniforms.push_back("screen_res");
|
||||
|
||||
gPostVignetteProgram.mName = "Vignette Shader (Post)";
|
||||
gPostVignetteProgram.mShaderFiles.clear();
|
||||
gPostVignetteProgram.mShaderFiles.push_back(make_pair("effects/VignetteF.glsl", GL_FRAGMENT_SHADER_ARB));
|
||||
gPostVignetteProgram.mShaderFiles.push_back(make_pair("interface/onetexturenocolorV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gPostVignetteProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT];
|
||||
if(gPostVignetteProgram.createShader(NULL, &shaderUniforms))
|
||||
{
|
||||
gPostVignetteProgram.bind();
|
||||
gPostVignetteProgram.uniform1i("tex0", 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return success;
|
||||
|
||||
@@ -184,6 +184,73 @@
|
||||
max_val="30" min_val="1" mouse_opaque="true"
|
||||
name="blur_strength" show_text="true" value="0.7" width="200" />
|
||||
</panel>
|
||||
<panel border="true" bottom="-180" follows="left|top|right|bottom" height="400"
|
||||
label="Vignette" left="1" mouse_opaque="false"
|
||||
name="VignettePanel" width="398">
|
||||
<check_box follows="left|top"
|
||||
font="SansSerifSmall" height="16" initial_value="false" label="Enable"
|
||||
left="4" mouse_opaque="true" name="enable_vignette" width="200" />
|
||||
<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
||||
bottom_delta="-21" drop_shadow_visible="true" follows="left|top|right"
|
||||
font="SansSerif" h_pad="0" halign="left" height="16"
|
||||
left="10" mouse_opaque="true" name="VignetteStrengthText" v_pad="0"
|
||||
width="355">
|
||||
Strength
|
||||
</text>
|
||||
<slider bottom_delta="-35" can_edit_text="true"
|
||||
decimal_digits="3" follows="left"
|
||||
height="18" increment=".005" initial_val=".85" label="" left="14"
|
||||
max_val="1" min_val="0" mouse_opaque="true"
|
||||
name="vignette_strength" show_text="true" value="0" width="200" />
|
||||
<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
||||
bottom_delta="-21" drop_shadow_visible="true" follows="left|top|right"
|
||||
font="SansSerif" h_pad="0" halign="left" height="16"
|
||||
left="10" mouse_opaque="true" name="VignetteRadiusText" v_pad="0"
|
||||
width="355">
|
||||
Radius
|
||||
</text>
|
||||
<slider bottom_delta="-35" can_edit_text="true"
|
||||
decimal_digits="3" follows="left"
|
||||
height="18" increment=".01" initial_val=".7" label="" left="14"
|
||||
max_val="8" min_val=".1" mouse_opaque="true"
|
||||
name="vignette_radius" show_text="true" value="0" width="200" />
|
||||
<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
||||
bottom_delta="-21" drop_shadow_visible="true" follows="left|top|right"
|
||||
font="SansSerif" h_pad="0" halign="left" height="16"
|
||||
left="10" mouse_opaque="true" name="VignetteDarknessText" v_pad="0"
|
||||
width="355">
|
||||
Darkness
|
||||
</text>
|
||||
<slider bottom_delta="-35" can_edit_text="true"
|
||||
decimal_digits="3" follows="left"
|
||||
height="18" increment=".005" initial_val=".85" label="" left="14"
|
||||
max_val="1" min_val="0" mouse_opaque="true"
|
||||
name="vignette_darkness" show_text="true" value="0" width="200" />
|
||||
<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
||||
bottom_delta="-21" drop_shadow_visible="true" follows="left|top|right"
|
||||
font="SansSerif" h_pad="0" halign="left" height="16"
|
||||
left="10" mouse_opaque="true" name="VignetteDesaturateText" v_pad="0"
|
||||
width="355">
|
||||
Desaturation Strength
|
||||
</text>
|
||||
<slider bottom_delta="-35" can_edit_text="true"
|
||||
decimal_digits="3" follows="left"
|
||||
height="18" increment=".05" initial_val="1" label="" left="14"
|
||||
max_val="10" min_val="0" mouse_opaque="true"
|
||||
name="vignette_desaturation" show_text="true" value="0" width="200" />
|
||||
<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
||||
bottom_delta="-21" drop_shadow_visible="true" follows="left|top|right"
|
||||
font="SansSerif" h_pad="0" halign="left" height="16"
|
||||
left="10" mouse_opaque="true" name="VignetteChormaticAberrationText" v_pad="0"
|
||||
width="355">
|
||||
Chromatic Aberration
|
||||
</text>
|
||||
<slider bottom_delta="-35" can_edit_text="true"
|
||||
decimal_digits="3" follows="left"
|
||||
height="18" increment="0.0005" initial_val=".01" label="" left="14"
|
||||
max_val=".1" min_val="0" mouse_opaque="true"
|
||||
name="vignette_chromatic_aberration" show_text="true" value="0" width="200" />
|
||||
</panel>
|
||||
<!--<panel border="true" bottom="-180" follows="left|top|right|bottom" height="400"
|
||||
label="Bloom" left="1" mouse_opaque="true"
|
||||
name="BloomPanel" width="398">
|
||||
|
||||
Reference in New Issue
Block a user