Fixed extra post-process shaders. Cleaned up and no longer using deprecated functions.

This commit is contained in:
Shyotl
2011-12-16 01:46:20 -06:00
parent a53e08032f
commit 0030ca3af7
12 changed files with 227 additions and 508 deletions

View File

@@ -5,13 +5,13 @@
* $License$
*/
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
#endif
#extension GL_ARB_texture_rectangle : enable
uniform sampler2DRect RenderTexture;
uniform sampler2DRect tex0;
uniform float brightness;
uniform float contrast;
uniform vec3 contrastBase;
@@ -24,7 +24,7 @@ VARYING vec2 vary_texcoord0;
void main(void)
{
vec3 color = vec3(texture2DRect(RenderTexture, vary_texcoord0.st));
vec3 color = vec3(texture2DRect(tex0, vary_texcoord0.st));
/// Apply gamma
color = pow(color, vec3(1.0/gamma));

View File

@@ -0,0 +1,35 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
#endif
uniform sampler2DRect tex0;
uniform int horizontalPass;
VARYING vec2 vary_texcoord0;
vec2 offset = vec2( 1.3846153846, 3.2307692308 );
vec3 weight = vec3( 0.2270270270, 0.3162162162, 0.0702702703 );
void main(void)
{
vec3 color = vec3(texture2DRect(tex0, vary_texcoord0))*weight.x;
if(horizontalPass == 1)
{
color += weight.y * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s+offset.s,vary_texcoord0.t)));
color += weight.y * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s-offset.s,vary_texcoord0.t)));
color += weight.z * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s+offset.t,vary_texcoord0.t)));
color += weight.z * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s-offset.t,vary_texcoord0.t)));
}
else
{
color += weight.y * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s,vary_texcoord0.t+offset.s)));
color += weight.y * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s,vary_texcoord0.t-offset.s)));
color += weight.z * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s,vary_texcoord0.t+offset.t)));
color += weight.z * vec3(texture2DRect(tex0, vec2(vary_texcoord0.s,vary_texcoord0.t-offset.t)));
}
gl_FragColor = vec4(color.xyz,1.0);
}

View File

@@ -5,14 +5,14 @@
* $License$
*/
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
#endif
#extension GL_ARB_texture_rectangle : enable
uniform sampler2DRect RenderTexture;
uniform sampler2D NoiseTexture;
uniform sampler2DRect tex0;
uniform sampler2D tex1;
uniform float brightMult;
uniform float noiseStrength;
@@ -30,7 +30,7 @@ float luminance(vec3 color)
void main(void)
{
/// Get scene color
vec3 color = vec3(texture2DRect(RenderTexture, vary_texcoord0));
vec3 color = vec3(texture2DRect(tex0, vary_texcoord0));
/// Extract luminance and scale up by night vision brightness
float lum = luminance(color) * brightMult;
@@ -40,7 +40,7 @@ void main(void)
vec3 outColor = (lum * vec3(0.91, 1.21, 0.9)) + vec3(-0.07, 0.1, -0.12);
/// Add noise
float noiseValue = texture2D(NoiseTexture, vary_texcoord1).r;
float noiseValue = texture2D(tex1, vary_texcoord1).r;
noiseValue = (noiseValue - 0.5) * noiseStrength;
/// Older NVG colors (more muted)

View File

@@ -1,36 +0,0 @@
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
#endif
#extension GL_ARB_texture_rectangle : enable
uniform sampler2DRect RenderTexture;
uniform int horizontalPass;
VARYING vec2 vary_texcoord0;
vec2 offset = vec2( 1.3846153846, 3.2307692308 );
vec3 weight = vec3( 0.2270270270, 0.3162162162, 0.0702702703 );
void main(void)
{
vec3 color = vec3(texture2DRect(RenderTexture, vary_texcoord0))*weight.x;
if(horizontalPass == 1)
{
color += weight.y * vec3(texture2DRect(RenderTexture, vec2(vary_texcoord0.s+offset.s,vary_texcoord0.t)));
color += weight.y * vec3(texture2DRect(RenderTexture, vec2(vary_texcoord0.s-offset.s,vary_texcoord0.t)));
color += weight.z * vec3(texture2DRect(RenderTexture, vec2(vary_texcoord0.s+offset.t,vary_texcoord0.t)));
color += weight.z * vec3(texture2DRect(RenderTexture, vec2(vary_texcoord0.s-offset.t,vary_texcoord0.t)));
}
else
{
color += weight.y * vec3(texture2DRect(RenderTexture, vec2(vary_texcoord0.s,vary_texcoord0.t+offset.s)));
color += weight.y * vec3(texture2DRect(RenderTexture, vec2(vary_texcoord0.s,vary_texcoord0.t-offset.s)));
color += weight.z * vec3(texture2DRect(RenderTexture, vec2(vary_texcoord0.s,vary_texcoord0.t+offset.t)));
color += weight.z * vec3(texture2DRect(RenderTexture, vec2(vary_texcoord0.s,vary_texcoord0.t-offset.t)));
}
gl_FragColor = vec4(color.xyz,1.0);
}

View File

@@ -70,12 +70,6 @@ LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater(std::string("Post-Proce
childSetCommitCallback("NightVisionNoiseSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_size");
childSetCommitCallback("NightVisionNoiseStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"noise_strength");
/// Bloom Callbacks
/*childSetCommitCallback("BloomToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_bloom");
childSetCommitCallback("BloomExtract", &LLFloaterPostProcess::onFloatControlMoved, (char*)"extract_low");
childSetCommitCallback("BloomSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_width");
childSetCommitCallback("BloomStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_strength");*/
// Gauss Blur Callbacks
childSetCommitCallback("GaussBlurToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_gauss_blur");
childSetCommitCallback("GaussBlurPasses", &LLFloaterPostProcess::onFloatControlMoved, (char*)"gauss_blur_passes");
@@ -117,7 +111,7 @@ void LLFloaterPostProcess::onBoolToggle(LLUICtrl* ctrl, void* userData)
// check the bool
LLCheckBoxCtrl* cbCtrl = static_cast<LLCheckBoxCtrl*>(ctrl);
gPostProcess->tweaks[boolVariableName] = cbCtrl->getValue();
LLPostProcess::getInstance()->tweaks[boolVariableName] = cbCtrl->getValue();
}
// Float Moved
@@ -125,7 +119,7 @@ void LLFloaterPostProcess::onFloatControlMoved(LLUICtrl* ctrl, void* userData)
{
char const * floatVariableName = (char const *)userData;
LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
gPostProcess->tweaks[floatVariableName] = sldrCtrl->getValue();
LLPostProcess::getInstance()->tweaks[floatVariableName] = sldrCtrl->getValue();
}
// Color Moved
@@ -133,7 +127,7 @@ void LLFloaterPostProcess::onColorControlRMoved(LLUICtrl* ctrl, void* userData)
{
char const * floatVariableName = (char const *)userData;
LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
gPostProcess->tweaks[floatVariableName][0] = sldrCtrl->getValue();
LLPostProcess::getInstance()->tweaks[floatVariableName][0] = sldrCtrl->getValue();
}
// Color Moved
@@ -141,7 +135,7 @@ void LLFloaterPostProcess::onColorControlGMoved(LLUICtrl* ctrl, void* userData)
{
char const * floatVariableName = (char const *)userData;
LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
gPostProcess->tweaks[floatVariableName][1] = sldrCtrl->getValue();
LLPostProcess::getInstance()->tweaks[floatVariableName][1] = sldrCtrl->getValue();
}
// Color Moved
@@ -149,7 +143,7 @@ void LLFloaterPostProcess::onColorControlBMoved(LLUICtrl* ctrl, void* userData)
{
char const * floatVariableName = (char const *)userData;
LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
gPostProcess->tweaks[floatVariableName][2] = sldrCtrl->getValue();
LLPostProcess::getInstance()->tweaks[floatVariableName][2] = sldrCtrl->getValue();
}
// Color Moved
@@ -157,7 +151,7 @@ void LLFloaterPostProcess::onColorControlIMoved(LLUICtrl* ctrl, void* userData)
{
char const * floatVariableName = (char const *)userData;
LLSliderCtrl* sldrCtrl = static_cast<LLSliderCtrl*>(ctrl);
gPostProcess->tweaks[floatVariableName][3] = sldrCtrl->getValue();
LLPostProcess::getInstance()->tweaks[floatVariableName][3] = sldrCtrl->getValue();
}
void LLFloaterPostProcess::onLoadEffect(void* userData)
@@ -166,7 +160,7 @@ void LLFloaterPostProcess::onLoadEffect(void* userData)
LLSD::String effectName(comboBox->getSelectedValue().asString());
gPostProcess->setSelectedEffect(effectName);
LLPostProcess::getInstance()->setSelectedEffect(effectName);
sPostProcess->syncMenu();
}
@@ -177,7 +171,7 @@ void LLFloaterPostProcess::onSaveEffect(void* userData)
std::string effectName(editBox->getValue().asString());
if (gPostProcess->mAllEffects.has(effectName))
if (LLPostProcess::getInstance()->mAllEffects.has(effectName))
{
LLSD payload;
payload["effect_name"] = effectName;
@@ -185,7 +179,7 @@ void LLFloaterPostProcess::onSaveEffect(void* userData)
}
else
{
gPostProcess->saveEffect(effectName);
LLPostProcess::getInstance()->saveEffect(effectName);
sPostProcess->syncMenu();
}
}
@@ -207,7 +201,7 @@ bool LLFloaterPostProcess::saveAlertCallback(const LLSD& notification, const LLS
// if they choose save, do it. Otherwise, don't do anything
if (option == 0)
{
gPostProcess->saveEffect(notification["payload"]["effect_name"].asString());
LLPostProcess::getInstance()->saveEffect(notification["payload"]["effect_name"].asString());
sPostProcess->syncMenu();
}
@@ -241,39 +235,34 @@ void LLFloaterPostProcess::syncMenu()
comboBox->removeall();
LLSD::map_const_iterator currEffect;
for(currEffect = gPostProcess->mAllEffects.beginMap();
currEffect != gPostProcess->mAllEffects.endMap();
for(currEffect = LLPostProcess::getInstance()->mAllEffects.beginMap();
currEffect != LLPostProcess::getInstance()->mAllEffects.endMap();
++currEffect)
{
comboBox->add(currEffect->first);
}
// set the current effect as selected.
comboBox->selectByValue(gPostProcess->getSelectedEffect());
comboBox->selectByValue(LLPostProcess::getInstance()->getSelectedEffect());
/// Sync Color Filter Menu
childSetValue("ColorFilterToggle", gPostProcess->tweaks.useColorFilter());
childSetValue("ColorFilterGamma", gPostProcess->tweaks.getGamma());
childSetValue("ColorFilterBrightness", gPostProcess->tweaks.brightness());
childSetValue("ColorFilterSaturation", gPostProcess->tweaks.saturation());
childSetValue("ColorFilterContrast", gPostProcess->tweaks.contrast());
childSetValue("ColorFilterBaseR", gPostProcess->tweaks.contrastBaseR());
childSetValue("ColorFilterBaseG", gPostProcess->tweaks.contrastBaseG());
childSetValue("ColorFilterBaseB", gPostProcess->tweaks.contrastBaseB());
childSetValue("ColorFilterBaseI", gPostProcess->tweaks.contrastBaseIntensity());
childSetValue("ColorFilterToggle", LLPostProcess::getInstance()->tweaks.useColorFilter());
childSetValue("ColorFilterGamma", LLPostProcess::getInstance()->tweaks.getGamma());
childSetValue("ColorFilterBrightness", LLPostProcess::getInstance()->tweaks.brightness());
childSetValue("ColorFilterSaturation", LLPostProcess::getInstance()->tweaks.saturation());
childSetValue("ColorFilterContrast", LLPostProcess::getInstance()->tweaks.contrast());
childSetValue("ColorFilterBaseR", LLPostProcess::getInstance()->tweaks.contrastBaseR());
childSetValue("ColorFilterBaseG", LLPostProcess::getInstance()->tweaks.contrastBaseG());
childSetValue("ColorFilterBaseB", LLPostProcess::getInstance()->tweaks.contrastBaseB());
childSetValue("ColorFilterBaseI", LLPostProcess::getInstance()->tweaks.contrastBaseIntensity());
/// Sync Night Vision Menu
childSetValue("NightVisionToggle", gPostProcess->tweaks.useNightVisionShader());
childSetValue("NightVisionBrightMult", gPostProcess->tweaks.brightMult());
childSetValue("NightVisionNoiseSize", gPostProcess->tweaks.noiseSize());
childSetValue("NightVisionNoiseStrength", gPostProcess->tweaks.noiseStrength());
childSetValue("NightVisionToggle", LLPostProcess::getInstance()->tweaks.useNightVisionShader());
childSetValue("NightVisionBrightMult", LLPostProcess::getInstance()->tweaks.brightMult());
childSetValue("NightVisionNoiseSize", LLPostProcess::getInstance()->tweaks.noiseSize());
childSetValue("NightVisionNoiseStrength", LLPostProcess::getInstance()->tweaks.noiseStrength());
/// Sync Bloom Menu
/*childSetValue("BloomToggle", LLSD(gPostProcess->tweaks.useBloomShader()));
childSetValue("BloomExtract", gPostProcess->tweaks.extractLow());
childSetValue("BloomSize", gPostProcess->tweaks.bloomWidth());
childSetValue("BloomStrength", gPostProcess->tweaks.bloomStrength());*/
childSetValue("GaussBlurToggle", gPostProcess->tweaks.useGaussBlurFilter());
childSetValue("GaussBlurPasses", gPostProcess->tweaks.getGaussBlurPasses());
/// Sync Gaussian Blur Menu
childSetValue("GaussBlurToggle", LLPostProcess::getInstance()->tweaks.useGaussBlurFilter());
childSetValue("GaussBlurPasses", LLPostProcess::getInstance()->tweaks.getGaussBlurPasses());
}

View File

@@ -1937,7 +1937,6 @@ bool idle_startup()
LLDrawable::initClass();
// init the shader managers
LLPostProcess::initClass();
AscentDayCycleManager::initClass();
// RN: don't initialize VO classes in drone mode, they are too closely tied to rendering

View File

@@ -1225,7 +1225,7 @@ void render_ui(F32 zoom_factor, int subfield, bool tiling)
/// and then display it again with compositor effects.
/// Using render to texture would be faster/better, but I don't have a
/// grasp of their full display stack just yet.
gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight());
LLPostProcess::getInstance()->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight());
render_hud_elements();
render_hud_attachments();

View File

@@ -830,8 +830,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
//if (success)
{
vector<string> shaderUniforms;
shaderUniforms.reserve(7);
shaderUniforms.push_back("RenderTexture");
shaderUniforms.reserve(6);
shaderUniforms.push_back("gamma");
shaderUniforms.push_back("brightness");
shaderUniforms.push_back("contrast");
@@ -842,18 +841,20 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
gPostColorFilterProgram.mName = "Color Filter Shader (Post)";
gPostColorFilterProgram.mShaderFiles.clear();
gPostColorFilterProgram.mShaderFiles.push_back(make_pair("effects/colorFilterF.glsl", GL_FRAGMENT_SHADER_ARB));
gPostColorFilterProgram.mShaderFiles.push_back(make_pair("effects/onetexturenocolor.glsl", GL_VERTEX_SHADER_ARB));
gPostColorFilterProgram.mShaderFiles.push_back(make_pair("interface/onetexturenocolorV.glsl", GL_VERTEX_SHADER_ARB));
gPostColorFilterProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT];
/*success = */gPostColorFilterProgram.createShader(NULL, &shaderUniforms);
if(gPostColorFilterProgram.createShader(NULL, &shaderUniforms))
{
gPostColorFilterProgram.bind();
gPostColorFilterProgram.uniform1i("tex0", 0);
}
}
//load Night Vision Shader
//if (success)
{
vector<string> shaderUniforms;
shaderUniforms.reserve(5);
shaderUniforms.push_back("RenderTexture");
shaderUniforms.push_back("NoiseTexture");
shaderUniforms.reserve(3);
shaderUniforms.push_back("brightMult");
shaderUniforms.push_back("noiseStrength");
shaderUniforms.push_back("lumWeights");
@@ -861,27 +862,33 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
gPostNightVisionProgram.mName = "Night Vision Shader (Post)";
gPostNightVisionProgram.mShaderFiles.clear();
gPostNightVisionProgram.mShaderFiles.push_back(make_pair("effects/nightVisionF.glsl", GL_FRAGMENT_SHADER_ARB));
gPostNightVisionProgram.mShaderFiles.push_back(make_pair("interface/twotextureadd.glsl", GL_VERTEX_SHADER_ARB));
gPostNightVisionProgram.mShaderFiles.push_back(make_pair("interface/twotextureaddV.glsl", GL_VERTEX_SHADER_ARB));
gPostNightVisionProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT];
/*success = */gPostNightVisionProgram.createShader(NULL, &shaderUniforms);
if(gPostNightVisionProgram.createShader(NULL, &shaderUniforms))
{
gPostNightVisionProgram.bind();
gPostNightVisionProgram.uniform1i("tex0", 0);
gPostNightVisionProgram.uniform1i("tex1", 1);
}
}
//if (success)
{
vector<string> shaderUniforms;
shaderUniforms.reserve(2);
shaderUniforms.push_back("RenderTexture");
shaderUniforms.reserve(1);
shaderUniforms.push_back("horizontalPass");
gPostGaussianBlurProgram.mName = "Gaussian Blur Shader (Post)";
gPostGaussianBlurProgram.mShaderFiles.clear();
gPostGaussianBlurProgram.mShaderFiles.push_back(make_pair("effects/gaussBlurF.glsl", GL_FRAGMENT_SHADER_ARB));
gPostGaussianBlurProgram.mShaderFiles.push_back(make_pair("interface/onetexturenocolor.glsl", GL_VERTEX_SHADER_ARB));
gPostGaussianBlurProgram.mShaderFiles.push_back(make_pair("interface/onetexturenocolorV.glsl", GL_VERTEX_SHADER_ARB));
gPostGaussianBlurProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT];
/*success = */gPostGaussianBlurProgram.createShader(NULL, &shaderUniforms);
if(gPostGaussianBlurProgram.createShader(NULL, &shaderUniforms))
{
gPostGaussianBlurProgram.bind();
gPostGaussianBlurProgram.uniform1i("tex0", 0);
}
}
#endif
return success;

View File

@@ -4763,9 +4763,9 @@ void LLViewerWindow::stopGL(BOOL save_state)
gBox.cleanupGL();
if(gPostProcess)
if(LLPostProcess::instanceExists())
{
gPostProcess->invalidate();
LLPostProcess::getInstance()->invalidate();
}
gTextureList.destroyGL(save_state);

View File

@@ -134,7 +134,7 @@
</text>
<slider bottom_delta="-30" can_edit_text="true" control_name="NightVisionNoiseSize"
decimal_digits="3" follows="left" height="18" increment="0.1"
initial_val="1" label="" left="14" max_val="100" min_val="1"
initial_val="1" label="" left="14" max_val="100" min_val=".1"
mouse_opaque="true" name="NightVisionNoiseSize" show_text="true"
value="1.0" width="200" />
<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"