diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index 9820b2029..85fb1c29a 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -36,15 +36,13 @@ #include "llglslshader.h" #include "llsdserialize.h" #include "llrender.h" +#include "llvertexbuffer.h" #include "lldir.h" extern LLGLSLShader gPostColorFilterProgram; extern LLGLSLShader gPostNightVisionProgram; extern LLGLSLShader gPostGaussianBlurProgram; -LLPostProcess * gPostProcess = NULL; - - static const unsigned int NOISE_SIZE = 512; /// CALCULATING LUMINANCE (Using NTSC lum weights) @@ -56,13 +54,12 @@ static const float LUMINANCE_B = 0.114f; static const char * const XML_FILENAME = "postprocesseffects.xml"; LLPostProcess::LLPostProcess(void) : - initialized(false), + mVBO(NULL), mAllEffects(LLSD::emptyMap()), - screenW(1), screenH(1) + mScreenWidth(1), mScreenHeight(1) { mSceneRenderTexture = NULL ; mNoiseTexture = NULL ; - mTempBloomTexture = NULL ; /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.*/ std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); @@ -82,7 +79,6 @@ LLPostProcess::LLPostProcess(void) : LLSD & defaultEffect = (mAllEffects["default"] = LLSD::emptyMap()); /*defaultEffect["enable_night_vision"] = LLSD::Boolean(false); - defaultEffect["enable_bloom"] = LLSD::Boolean(false); defaultEffect["enable_color_filter"] = LLSD::Boolean(false);*/ /// NVG Defaults @@ -91,13 +87,7 @@ LLPostProcess::LLPostProcess(void) : defaultEffect["noise_strength"] = 0.4; // TODO BTest potentially add this to tweaks? - noiseTextureScale = 1.0f; - - /// Bloom Defaults - defaultEffect["extract_low"] = 0.95; - defaultEffect["extract_high"] = 1.0; - defaultEffect["bloom_width"] = 2.25; - defaultEffect["bloom_strength"] = 1.5; + mNoiseTextureScale = 1.0f; /// Color Filter Defaults defaultEffect["gamma"] = 1.0; @@ -123,25 +113,10 @@ LLPostProcess::~LLPostProcess(void) invalidate() ; } -// static -void LLPostProcess::initClass(void) +/*static*/void LLPostProcess::cleanupClass() { - //this will cause system to crash at second time login - //if first time login fails due to network connection --- bao - //***llassert_always(gPostProcess == NULL); - //replaced by the following line: - if(gPostProcess) - return ; - - - gPostProcess = new LLPostProcess(); -} - -// static -void LLPostProcess::cleanupClass() -{ - delete gPostProcess; - gPostProcess = NULL; + if(instanceExists()) + getInstance()->invalidate() ; } void LLPostProcess::setSelectedEffect(std::string const & effectName) @@ -152,7 +127,6 @@ void LLPostProcess::setSelectedEffect(std::string const & effectName) void LLPostProcess::saveEffect(std::string const & effectName) { - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.*/ mAllEffects[effectName] = tweaks; std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); @@ -163,38 +137,57 @@ void LLPostProcess::saveEffect(std::string const & effectName) LLPointer formatter = new LLSDXMLFormatter(); formatter->format(mAllEffects, effectsXML); - //*/ } void LLPostProcess::invalidate() { mSceneRenderTexture = NULL ; mNoiseTexture = NULL ; - mTempBloomTexture = NULL ; - initialized = FALSE ; + mVBO = NULL ; } void LLPostProcess::apply(unsigned int width, unsigned int height) { - if (!initialized || width != screenW || height != screenH){ - initialize(width, height); - } - if (shadersEnabled()){ + if(shadersEnabled()) + { + if (mVBO.isNull() || width != mScreenWidth || height != mScreenHeight) + { + initialize(width, height); + } doEffects(); } } void LLPostProcess::initialize(unsigned int width, unsigned int height) { - screenW = width; - screenH = height; - createTexture(mSceneRenderTexture, screenW, screenH); - initialized = true; + invalidate(); + mScreenWidth = width; + mScreenHeight = height; + + createScreenTexture(); + + //Setup our VBO. + { + mVBO = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1,3); + mVBO->allocateBuffer(4,0,TRUE); + + LLStrider v; + LLStrider uv1; + LLStrider uv2; + + mVBO->getVertexStrider(v); + mVBO->getTexCoord0Strider(uv1); + mVBO->getTexCoord1Strider(uv2); + + v[0] = LLVector3( uv2[0] = uv1[0] = LLVector2(0, 0) ); + v[1] = LLVector3( uv2[1] = uv1[1] = LLVector2(0, mScreenHeight) ); + v[2] = LLVector3( uv2[2] = uv1[2] = LLVector2(mScreenWidth, 0) ); + v[3] = LLVector3( uv2[3] = uv1[3] = LLVector2(mScreenWidth, mScreenHeight) ); + + mVBO->flush(); + } checkError(); - createNightVisionShader(); - //createBloomShader(); - createColorFilterShader(); - createGaussBlurShader(); + createNoiseTexture(); checkError(); } @@ -202,9 +195,7 @@ inline bool LLPostProcess::shadersEnabled(void) { return (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean() || - /*tweaks.useBloomShader().asBoolean() ||*/ tweaks.useGaussBlurFilter().asBoolean() ); - } void LLPostProcess::applyShaders(void) @@ -220,7 +211,7 @@ void LLPostProcess::applyShaders(void) { /// If any of the above shaders have been called update the frame buffer; if (copy_buffer) - copyFrameBuffer(mSceneRenderTexture->getTexName(), screenW, screenH); + copyFrameBuffer(); applyGaussBlurShader(); checkError(); copy_buffer = true; @@ -229,143 +220,65 @@ void LLPostProcess::applyShaders(void) { /// If any of the above shaders have been called update the frame buffer; if (copy_buffer) - copyFrameBuffer(mSceneRenderTexture->getTexName(), screenW, screenH); + copyFrameBuffer(); applyNightVisionShader(); checkError(); copy_buffer = true; } - /*if (tweaks.useBloomShader()) - { - /// If any of the above shaders have been called update the frame buffer; - if (copy_buffer) - copyFrameBuffer(mSceneRenderTexture->getTexName(), screenW, screenH); - applyBloomShader(); - checkError(); - copy_buffer = true; - }*/ } void LLPostProcess::applyColorFilterShader(void) { if(gPostColorFilterProgram.mProgramObject == 0) return; - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.*/ + gPostColorFilterProgram.bind(); - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); + gGL.getTexUnit(0)->bind(mSceneRenderTexture); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mSceneRenderTexture.get()->getTexName()); - - getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); - glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); - glUniform1fARB(colorFilterUniforms["gamma"], tweaks.getGamma()); - glUniform1fARB(colorFilterUniforms["brightness"], tweaks.getBrightness()); - glUniform1fARB(colorFilterUniforms["contrast"], tweaks.getContrast()); + gPostColorFilterProgram.uniform1f("gamma", tweaks.getGamma()); + gPostColorFilterProgram.uniform1f("brightness", tweaks.getBrightness()); + gPostColorFilterProgram.uniform1f("contrast", tweaks.getContrast()); float baseI = (tweaks.getContrastBaseR() + tweaks.getContrastBaseG() + tweaks.getContrastBaseB()) / 3.0f; baseI = tweaks.getContrastBaseIntensity() / ((baseI < 0.001f) ? 0.001f : baseI); float baseR = tweaks.getContrastBaseR() * baseI; float baseG = tweaks.getContrastBaseG() * baseI; float baseB = tweaks.getContrastBaseB() * baseI; - glUniform3fARB(colorFilterUniforms["contrastBase"], baseR, baseG, baseB); - glUniform1fARB(colorFilterUniforms["saturation"], tweaks.getSaturation()); - glUniform3fARB(colorFilterUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); + gPostColorFilterProgram.uniform3fv("contrastBase", 1, LLVector3(baseR, baseG, baseB).mV); + gPostColorFilterProgram.uniform1f("saturation", tweaks.getSaturation()); + gPostColorFilterProgram.uniform3fv("lumWeights", 1, LLVector3(LUMINANCE_R, LUMINANCE_G, LUMINANCE_B).mV); LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_REPLACE); LLGLDepthTest depth(GL_FALSE); /// Draw a screen space quad - drawOrthoQuad(screenW, screenH, QUAD_NORMAL); + drawOrthoQuad(QUAD_NORMAL); gPostColorFilterProgram.unbind(); - //*/ -} - -void LLPostProcess::createColorFilterShader(void) -{ - /// Define uniform names - colorFilterUniforms["RenderTexture"] = 0; - colorFilterUniforms["gamma"] = 0; - colorFilterUniforms["brightness"] = 0; - colorFilterUniforms["contrast"] = 0; - colorFilterUniforms["contrastBase"] = 0; - colorFilterUniforms["saturation"] = 0; - colorFilterUniforms["lumWeights"] = 0; } void LLPostProcess::applyNightVisionShader(void) { if(gPostNightVisionProgram.mProgramObject == 0) return; - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.*/ + gPostNightVisionProgram.bind(); - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); - - getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mSceneRenderTexture.get()->getTexName()); - glUniform1iARB(nightVisionUniforms["RenderTexture"], 0); - - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - - gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseTexture.get()->getTexName()); - glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); - + gGL.getTexUnit(0)->bind(mSceneRenderTexture); + gGL.getTexUnit(1)->bind(mNoiseTexture); - glUniform1fARB(nightVisionUniforms["brightMult"], tweaks.getBrightMult()); - glUniform1fARB(nightVisionUniforms["noiseStrength"], tweaks.getNoiseStrength()); - noiseTextureScale = 0.01f + ((101.f - tweaks.getNoiseSize()) / 100.f); - noiseTextureScale *= (screenH / NOISE_SIZE); + gPostNightVisionProgram.uniform1f("brightMult", tweaks.getBrightMult()); + gPostNightVisionProgram.uniform1f("noiseStrength", tweaks.getNoiseStrength()); + mNoiseTextureScale = 0.001f + ((100.f - tweaks.getNoiseSize()) / 100.f); + mNoiseTextureScale *= (mScreenHeight / NOISE_SIZE); - - glUniform3fARB(nightVisionUniforms["lumWeights"], LUMINANCE_R, LUMINANCE_G, LUMINANCE_B); - LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_REPLACE); LLGLDepthTest depth(GL_FALSE); /// Draw a screen space quad - drawOrthoQuad(screenW, screenH, QUAD_NOISE); + drawOrthoQuad(QUAD_NOISE); gPostNightVisionProgram.unbind(); - gGL.getTexUnit(0)->activate(); - //*/ -} - -void LLPostProcess::createNightVisionShader(void) -{ - /// Define uniform names - nightVisionUniforms["RenderTexture"] = 0; - nightVisionUniforms["NoiseTexture"] = 0; - nightVisionUniforms["brightMult"] = 0; - nightVisionUniforms["noiseStrength"] = 0; - nightVisionUniforms["lumWeights"] = 0; - - createNoiseTexture(mNoiseTexture); -} - -void LLPostProcess::applyBloomShader(void) -{ - -} - -void LLPostProcess::createBloomShader(void) -{ - //createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); - - /// Create Bloom Extract Shader - bloomExtractUniforms["RenderTexture"] = 0; - bloomExtractUniforms["extractLow"] = 0; - bloomExtractUniforms["extractHigh"] = 0; - bloomExtractUniforms["lumWeights"] = 0; - - /// Create Bloom Blur Shader - bloomBlurUniforms["RenderTexture"] = 0; - bloomBlurUniforms["bloomStrength"] = 0; - bloomBlurUniforms["texelSize"] = 0; - bloomBlurUniforms["blurDirection"] = 0; - bloomBlurUniforms["blurWidth"] = 0; } void LLPostProcess::applyGaussBlurShader(void) @@ -374,56 +287,33 @@ void LLPostProcess::applyGaussBlurShader(void) if(!pass_count || gPostGaussianBlurProgram.mProgramObject == 0) return; - getShaderUniforms(gaussBlurUniforms, gPostGaussianBlurProgram.mProgramObject); gPostGaussianBlurProgram.bind(); - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mSceneRenderTexture.get()->getTexName()); + + gGL.getTexUnit(0)->bind(mSceneRenderTexture); + LLGLEnable blend(GL_BLEND); LLGLDepthTest depth(GL_FALSE); gGL.setSceneBlendType(LLRender::BT_REPLACE); - glUniform1iARB(gaussBlurUniforms["RenderTexture"], 0); - GLint horiz_pass = gaussBlurUniforms["horizontalPass"]; + GLint horiz_pass = gPostGaussianBlurProgram.getUniformLocation("horizontalPass"); for(int i = 0;igetTexName(), screenW, screenH); + copyFrameBuffer(); glUniform1iARB(horiz_pass, j); - drawOrthoQuad(screenW, screenH, QUAD_NORMAL); - + drawOrthoQuad(QUAD_NORMAL); } } gPostGaussianBlurProgram.unbind(); - -} - -void LLPostProcess::createGaussBlurShader(void) -{ - gaussBlurUniforms["RenderTexture"] = 0; - gaussBlurUniforms["horizontalPass"] = 0; -} - -void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog) -{ - /// Find uniform locations and insert into map - std::map::iterator i; - for (i = uniforms.begin(); i != uniforms.end(); ++i){ - i->second = glGetUniformLocationARB(prog, i->first); - } } void LLPostProcess::doEffects(void) { - /// Save GL State - glPushAttrib(GL_ALL_ATTRIB_BITS); - glPushClientAttrib(GL_ALL_ATTRIB_BITS); + LLVertexBuffer::unbind(); /// Copy the screen buffer to the render texture - { - copyFrameBuffer(mSceneRenderTexture->getTexName(), screenW, screenH); - } + copyFrameBuffer(); /// Clear the frame buffer. glClearColor(0.0f, 0.0f, 0.0f, 1.0f); @@ -431,146 +321,73 @@ void LLPostProcess::doEffects(void) LLGLDisable(GL_DEPTH_TEST); /// Change to an orthogonal view - viewOrthogonal(screenW, screenH); - - checkError(); - applyShaders(); - - LLGLSLShader::bindNoShader(); - checkError(); - - /// Change to a perspective view - viewPerspective(); - - /// Reset GL State - glPopClientAttrib(); - glPopAttrib(); - checkError(); -} - -void LLPostProcess::copyFrameBuffer(LLGLuint texture, unsigned int width, unsigned int height) -{ - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); - glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0); -} - -inline void InitQuadArray(F32 *arr, const F32 x, const F32 y, const F32 width, const F32 height) -{ - //Lower left - *(arr++)=x; - *(arr++)=y; - //Upper left - *(arr++)=x; - *(arr++)=y+height; - //Upper right - *(arr++)=x+width; - *(arr++)=y+height; - //Lower right - *(arr++)=x+width; - *(arr++)=y; -} -void LLPostProcess::drawOrthoQuad(unsigned int width, unsigned int height, QuadType type) -{ -#if 1 - //Redid the logic here. Less cases. No longer using immediate mode. - bool second_tex = true; - //Vertex array used for all post-processing effects - static F32 verts[8]; - //Texture coord array used for all post-processing effects - static F32 tex0[8]; - //Texture coord array used for relevant post processing effects - static F32 tex1[8]; - - //Set up vertex array - InitQuadArray(verts, 0.f, 0.f, width, height); - - //Set up first texture coords - if(type == QUAD_BLOOM_EXTRACT) - { - InitQuadArray(tex0, 0.f, 0.f, width*2.f, height*2.f); - second_tex = false; - } - else - { - InitQuadArray(tex0, 0.f, 0.f, width, height); - //Set up second texture coords - if( type == QUAD_BLOOM_COMBINE) - InitQuadArray(tex1, 0.f, 0.f, width*.5, height*.5); - else if( type == QUAD_NOISE ) - InitQuadArray(tex1, ((float) rand() / (float) RAND_MAX), ((float) rand() / (float) RAND_MAX), - width * noiseTextureScale / height, noiseTextureScale); - else - second_tex = false; - } - - //Prepare to render - glEnableClientState( GL_VERTEX_ARRAY ); - glVertexPointer(2, GL_FLOAT, sizeof(F32)*2, verts); - if(second_tex) //tex1 setup - { - glClientActiveTextureARB(GL_TEXTURE1); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer(2, GL_FLOAT, sizeof(F32)*2, tex1); - } - glClientActiveTextureARB(GL_TEXTURE0); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer(2, GL_FLOAT, sizeof(F32)*2, tex0); - - //Render - glDrawArrays(GL_QUADS, 0, sizeof(verts)/sizeof(verts[0])); - - //Cleanup - glDisableClientState( GL_VERTEX_ARRAY ); - glDisableClientState( GL_TEXTURE_COORD_ARRAY ); //for tex0 - if(second_tex) - { - glClientActiveTextureARB(GL_TEXTURE1); - glDisableClientState( GL_TEXTURE_COORD_ARRAY ); //for tex1 - } -#endif -} - -void LLPostProcess::viewOrthogonal(unsigned int width, unsigned int height) -{ gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); - gGL.ortho( 0.f, (GLdouble) width, 0.f, (GLdouble) height, -1.f, 1.f ); + gGL.ortho( 0.f, (GLdouble) mScreenWidth, 0.f, (GLdouble) mScreenHeight, -1.f, 1.f ); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); gGL.loadIdentity(); -} + + applyShaders(); + checkError(); -void LLPostProcess::viewPerspective(void) -{ + LLGLSLShader::bindNoShader(); + + /// Change to a perspective view + gGL.flush(); gGL.matrixMode( LLRender::MM_PROJECTION ); gGL.popMatrix(); gGL.matrixMode( LLRender::MM_MODELVIEW ); gGL.popMatrix(); + + gGL.getTexUnit(1)->disable(); + checkError(); } -void LLPostProcess::changeOrthogonal(unsigned int width, unsigned int height) +void LLPostProcess::copyFrameBuffer() { - viewPerspective(); - viewOrthogonal(width, height); + gGL.getTexUnit(0)->bindManual(mSceneRenderTexture->getTarget(), mSceneRenderTexture->getTexName()); + glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, mScreenWidth, mScreenHeight, 0); } -void LLPostProcess::createTexture(LLPointer& texture, unsigned int width, unsigned int height) +void LLPostProcess::drawOrthoQuad(QuadType type) { - std::vector data(width * height * 4, 0) ; - - texture = new LLImageGL(FALSE) ; - if(texture->createGLTexture()) + if(type == QUAD_NOISE) { - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture->getTexName()); - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); + //This could also be done through uniforms. + LLStrider uv2; + mVBO->getTexCoord1Strider(uv2); + + float offs[2] = {(float) rand() / (float) RAND_MAX, (float) rand() / (float) RAND_MAX}; + float scale[2] = {mScreenWidth * mNoiseTextureScale / mScreenHeight, mNoiseTextureScale}; + uv2[0] = LLVector2(offs[0],offs[1]); + uv2[1] = LLVector2(offs[0],offs[1]+scale[1]); + uv2[2] = LLVector2(offs[0]+scale[0],offs[1]); + uv2[3] = LLVector2(uv2[2].mV[0],uv2[1].mV[1]); + mVBO->flush(); + } + + U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | (type == QUAD_NOISE ? LLVertexBuffer::MAP_TEXCOORD1 : 0); + mVBO->setBuffer(mask); + mVBO->drawArrays(LLRender::TRIANGLE_STRIP, 0, 4); +} + +void LLPostProcess::createScreenTexture() +{ + std::vector data(mScreenWidth * mScreenHeight * 3, 0) ; + + mSceneRenderTexture = new LLImageGL(FALSE) ; + if(mSceneRenderTexture->createGLTexture()) + { + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mSceneRenderTexture->getTexName()); + LLImageGL::setManualImage(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, mScreenWidth, mScreenHeight, GL_RGB, GL_UNSIGNED_BYTE, &data[0]); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); } } -void LLPostProcess::createNoiseTexture(LLPointer& texture) +void LLPostProcess::createNoiseTexture() { std::vector buffer(NOISE_SIZE * NOISE_SIZE); for (unsigned int i = 0; i < NOISE_SIZE; i++){ @@ -579,10 +396,10 @@ void LLPostProcess::createNoiseTexture(LLPointer& texture) } } - texture = new LLImageGL(FALSE) ; - if(texture->createGLTexture()) + mNoiseTexture = new LLImageGL(FALSE) ; + if(mNoiseTexture->createGLTexture()) { - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName()); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseTexture->getTexName()); LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP); @@ -617,30 +434,3 @@ bool LLPostProcess::checkError(void) return retCode; } -void LLPostProcess::checkShaderError(GLhandleARB shader) -{ - GLint infologLength = 0; - GLint charsWritten = 0; - GLchar *infoLog; - - checkError(); // Check for OpenGL errors - - glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength); - - checkError(); // Check for OpenGL errors - - if (infologLength > 0) - { - infoLog = (GLchar *)malloc(infologLength); - if (infoLog == NULL) - { - /// Could not allocate infolog buffer - return; - } - glGetInfoLogARB(shader, infologLength, &charsWritten, infoLog); - // shaderErrorLog << (char *) infoLog << std::endl; - mShaderErrorString = (char *) infoLog; - free(infoLog); - } - checkError(); // Check for OpenGL errors -} diff --git a/indra/llrender/llpostprocess.h b/indra/llrender/llpostprocess.h index 8eadaf224..459fa6851 100644 --- a/indra/llrender/llpostprocess.h +++ b/indra/llrender/llpostprocess.h @@ -38,19 +38,17 @@ #include "llgl.h" #include "llglheaders.h" -class LLPostProcess +class LLPostProcess : public LLSingleton { public: typedef enum _QuadType { QUAD_NORMAL, - QUAD_NOISE, - QUAD_BLOOM_EXTRACT, - QUAD_BLOOM_COMBINE + QUAD_NOISE } QuadType; /// GLSL Shader Encapsulation Struct - typedef std::map glslUniforms; + //typedef std::map glslUniforms; struct PostProcessTweaks : public LLSD { inline PostProcessTweaks() : LLSD(LLSD::emptyMap()) @@ -69,22 +67,6 @@ public: return (*this)["noise_size"]; } - inline LLSD & extractLow() { - return (*this)["extract_low"]; - } - - inline LLSD & extractHigh() { - return (*this)["extract_high"]; - } - - inline LLSD & bloomWidth() { - return (*this)["bloom_width"]; - } - - inline LLSD & bloomStrength() { - return (*this)["bloom_strength"]; - } - inline LLSD & brightness() { return (*this)["brightness"]; } @@ -117,10 +99,6 @@ public: return (*this)["enable_night_vision"]; } - /*inline LLSD & useBloomShader() { - return (*this)["enable_bloom"]; - }*/ - inline LLSD & useColorFilter() { return (*this)["enable_color_filter"]; } @@ -141,22 +119,6 @@ public: return F32((*this)["noise_size"].asReal()); } - inline F32 getExtractLow() const { - return F32((*this)["extract_low"].asReal()); - } - - inline F32 getExtractHigh() const { - return F32((*this)["extract_high"].asReal()); - } - - inline F32 getBloomWidth() const { - return F32((*this)["bloom_width"].asReal()); - } - - inline F32 getBloomStrength() const { - return F32((*this)["bloom_strength"].asReal()); - } - inline F32 getGamma() const { return F32((*this)["gamma"].asReal()); } @@ -193,17 +155,16 @@ public: return (*this)["gauss_blur_passes"]; } }; - - bool initialized; + PostProcessTweaks tweaks; // the map of all availible effects LLSD mAllEffects; private: + LLPointer mVBO; LLPointer mSceneRenderTexture ; LLPointer mNoiseTexture ; - LLPointer mTempBloomTexture ; public: LLPostProcess(void); @@ -213,9 +174,6 @@ public: void apply(unsigned int width, unsigned int height); void invalidate() ; - /// Perform global initialization for this class. - static void initClass(void); - // Cleanup of global data that's only inited once per class. static void cleanupClass(); @@ -230,18 +188,11 @@ public: private: /// read in from file std::string mShaderErrorString; - unsigned int screenW; - unsigned int screenH; + unsigned int mScreenWidth; + unsigned int mScreenHeight; - float noiseTextureScale; + float mNoiseTextureScale; - /// Shader Uniforms - glslUniforms nightVisionUniforms; - glslUniforms bloomExtractUniforms; - glslUniforms bloomBlurUniforms; - glslUniforms colorFilterUniforms; - glslUniforms gaussBlurUniforms; - // the name of currently selected effect in mAllEffects // invariant: tweaks == mAllEffects[mSelectedEffectName] std::string mSelectedEffectName; @@ -253,35 +204,19 @@ private: bool shadersEnabled(void); /// Night Vision Functions - void createNightVisionShader(void); void applyNightVisionShader(void); - /// Bloom Functions - void createBloomShader(void); - void applyBloomShader(void); - /// Color Filter Functions - void createColorFilterShader(void); void applyColorFilterShader(void); /// Gaussian blur Filter Functions - void createGaussBlurShader(void); void applyGaussBlurShader(void); /// OpenGL Helper Functions - void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); - void createTexture(LLPointer& texture, unsigned int width, unsigned int height); - void copyFrameBuffer(LLGLuint texture, unsigned int width, unsigned int height); - void createNoiseTexture(LLPointer& texture); + void copyFrameBuffer(); + void createScreenTexture(); + void createNoiseTexture(); bool checkError(void); - void checkShaderError(GLhandleARB shader); - void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type); - void viewOrthogonal(unsigned int width, unsigned int height); - void changeOrthogonal(unsigned int width, unsigned int height); - void viewPerspective(void); + void drawOrthoQuad(QuadType type); }; - -extern LLPostProcess * gPostProcess; - - #endif // LL_POSTPROCESS_H diff --git a/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl b/indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl similarity index 87% rename from indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl rename to indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl index 2426af0d0..cf0dbee8d 100644 --- a/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl @@ -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)); diff --git a/indra/newview/app_settings/shaders/class1/effects/gaussBlurF.glsl b/indra/newview/app_settings/shaders/class1/effects/gaussBlurF.glsl new file mode 100644 index 000000000..1bb7046c2 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/effects/gaussBlurF.glsl @@ -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); +} \ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl b/indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl similarity index 84% rename from indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl rename to indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl index 053079b0e..793ff201a 100644 --- a/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl @@ -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) diff --git a/indra/newview/app_settings/shaders/class2/effects/gaussBlurF.glsl b/indra/newview/app_settings/shaders/class2/effects/gaussBlurF.glsl deleted file mode 100644 index 6e701d28c..000000000 --- a/indra/newview/app_settings/shaders/class2/effects/gaussBlurF.glsl +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/indra/newview/llfloaterpostprocess.cpp b/indra/newview/llfloaterpostprocess.cpp index 19346c19b..095e23050 100644 --- a/indra/newview/llfloaterpostprocess.cpp +++ b/indra/newview/llfloaterpostprocess.cpp @@ -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(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(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(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(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(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(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()); } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7c000984e..a396782c0 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -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 diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 510b63e75..f4aa4305b 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -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(); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index a4a871c1f..3d124b20a 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -830,8 +830,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects() //if (success) { vector 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 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 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; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 9d984cc09..9682308a1 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -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); diff --git a/indra/newview/skins/default/xui/en-us/floater_post_process.xml b/indra/newview/skins/default/xui/en-us/floater_post_process.xml index ea330660e..58d538205 100644 --- a/indra/newview/skins/default/xui/en-us/floater_post_process.xml +++ b/indra/newview/skins/default/xui/en-us/floater_post_process.xml @@ -134,7 +134,7 @@