From a44d633bc8364ea7ad525ffb514ee55257773d05 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 9 Feb 2011 19:21:31 -0600 Subject: [PATCH] Enabled post-processing features. Todo: Fix bloom Fixed avatar shadows on AMD (and any other sane GLSL compiler) Fixed windows compile: -curl version was updated after running develop.py. Not sure if applicable to linux/darwin -new llqtwebkit version on windows, since the old url is now invalid. --- LICENSES/c-ares.txt | 25 ++- LICENSES/curl.txt | 3 +- indra/llmessage/llares.cpp | 6 +- indra/llrender/llpostprocess.cpp | 159 +++++++++--------- .../class1/deferred/avatarShadowF.glsl | 3 +- .../shaders/class1/effects/glowF.glsl | 14 +- indra/newview/llviewerdisplay.cpp | 16 +- indra/newview/llviewershadermgr.cpp | 2 +- .../xui/en-us/floater_post_process.xml | 90 +++++----- .../skins/default/xui/en-us/menu_viewer.xml | 4 + install.xml | 7 +- 11 files changed, 166 insertions(+), 163 deletions(-) diff --git a/LICENSES/c-ares.txt b/LICENSES/c-ares.txt index ad4be41ac..136107bd6 100644 --- a/LICENSES/c-ares.txt +++ b/LICENSES/c-ares.txt @@ -1,16 +1,11 @@ -http://daniel.haxx.se/projects/c-ares/license.html - - c-ares license - - Copyright 1998 by the Massachusetts Institute of Technology. - - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose and without fee is hereby granted, provided that - the above copyright notice appear in all copies and that both that copyright - notice and this permission notice appear in supporting documentation, and that - the name of M.I.T. not be used in advertising or publicity pertaining to - distribution of the software without specific, written prior permission. - M.I.T. makes no representations about the suitability of this software for any - purpose. It is provided "as is" without express or implied warranty. - +Copyright 1998 by the Massachusetts Institute of Technology. + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that +the above copyright notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting documentation, and that +the name of M.I.T. not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior permission. +M.I.T. makes no representations about the suitability of this software for any +purpose. It is provided "as is" without express or implied warranty. diff --git a/LICENSES/curl.txt b/LICENSES/curl.txt index edfff428c..163b299ae 100644 --- a/LICENSES/curl.txt +++ b/LICENSES/curl.txt @@ -1,6 +1,6 @@ COPYRIGHT AND PERMISSION NOTICE -Copyright (c) 1996 - 2002, Daniel Stenberg, . +Copyright (c) 1996 - 2010, Daniel Stenberg, . All rights reserved. @@ -19,4 +19,3 @@ OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. - diff --git a/indra/llmessage/llares.cpp b/indra/llmessage/llares.cpp index fe37fe814..34dfc9bdb 100644 --- a/indra/llmessage/llares.cpp +++ b/indra/llmessage/llares.cpp @@ -42,6 +42,7 @@ #include "apr_poll.h" #include "llapr.h" +#define CARES_STATICLIB #include "llares.h" #if defined(LL_WINDOWS) @@ -104,7 +105,8 @@ void LLAres::QueryResponder::queryError(int code) LLAres::LLAres() : chan_(NULL), mInitSuccess(false) { - if (ares_init(&chan_) != ARES_SUCCESS) + if (ares_library_init(ARES_LIB_INIT_ALL) != ARES_SUCCESS || + ares_init(&chan_) != ARES_SUCCESS) { llwarns << "Could not succesfully initialize ares!" << llendl; return; @@ -468,7 +470,7 @@ bool LLAres::process(U64 timeout) ll_init_apr(); } - int socks[ARES_GETSOCK_MAXNUM]; + ares_socket_t socks[ARES_GETSOCK_MAXNUM]; apr_pollfd_t aprFds[ARES_GETSOCK_MAXNUM]; apr_int32_t nsds = 0; int nactive = 0; diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index 7f4be6a86..86e77b7bc 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -37,6 +37,9 @@ #include "llsdserialize.h" #include "llrender.h" +#include "lldir.h" +extern LLGLSLShader gPostColorFilterProgram; +extern LLGLSLShader gPostNightVisionProgram; LLPostProcess * gPostProcess = NULL; @@ -60,7 +63,7 @@ LLPostProcess::LLPostProcess(void) : mNoiseTexture = NULL ; mTempBloomTexture = NULL ; - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + /* 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)); LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; @@ -108,7 +111,7 @@ LLPostProcess::LLPostProcess(void) : } setSelectedEffect("default"); - */ + //*/ } LLPostProcess::~LLPostProcess(void) @@ -145,7 +148,7 @@ 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. + /* 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)); @@ -156,7 +159,7 @@ void LLPostProcess::saveEffect(std::string const & effectName) LLPointer formatter = new LLSDXMLFormatter(); formatter->format(mAllEffects, effectsXML); - */ + //*/ } void LLPostProcess::invalidate() { @@ -228,13 +231,13 @@ void LLPostProcess::applyShaders(void) void LLPostProcess::applyColorFilterShader(void) { - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + /* 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)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mSceneRenderTexture.get()->getTexName()); getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); @@ -256,7 +259,7 @@ void LLPostProcess::applyColorFilterShader(void) /// Draw a screen space quad drawOrthoQuad(screenW, screenH, QUAD_NORMAL); gPostColorFilterProgram.unbind(); - */ + //*/ } void LLPostProcess::createColorFilterShader(void) @@ -272,20 +275,20 @@ void LLPostProcess::createColorFilterShader(void) void LLPostProcess::applyNightVisionShader(void) { - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + /* 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, sceneRenderTexture); + 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, noiseTexture); + gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseTexture.get()->getTexName()); glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); @@ -305,7 +308,7 @@ void LLPostProcess::applyNightVisionShader(void) drawOrthoQuad(screenW, screenH, QUAD_NOISE); gPostNightVisionProgram.unbind(); gGL.getTexUnit(0)->activate(); - */ + //*/ } void LLPostProcess::createNightVisionShader(void) @@ -392,79 +395,79 @@ void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned 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 0 - float noiseX = 0.f; - float noiseY = 0.f; - float screenRatio = 1.0f; +#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]; - if (type == QUAD_NOISE){ - noiseX = ((float) rand() / (float) RAND_MAX); - noiseY = ((float) rand() / (float) RAND_MAX); - screenRatio = (float) width / (float) height; + //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); - glBegin(GL_QUADS); - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height * 2.0f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - noiseX, - noiseTextureScale + noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, (GLfloat) height * 0.5f); - } - glVertex2f(0.f, (GLfloat) screenH - height); + //Render + glDrawArrays(GL_QUADS, 0, sizeof(verts)/sizeof(verts[0])); - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - noiseX, - noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, 0.f); - } - glVertex2f(0.f, (GLfloat) height + (screenH - height)); - - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, 0.f); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, 0.f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - screenRatio * noiseTextureScale + noiseX, - noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, 0.f); - } - glVertex2f((GLfloat) width, (GLfloat) height + (screenH - height)); - - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, (GLfloat) height); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, (GLfloat) height * 2.0f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - screenRatio * noiseTextureScale + noiseX, - noiseTextureScale + noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, (GLfloat) height * 0.5f); - } - glVertex2f((GLfloat) width, (GLfloat) screenH - height); - glEnd(); + //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 } @@ -473,7 +476,7 @@ void LLPostProcess::viewOrthogonal(unsigned int width, unsigned int height) glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glOrtho( 0.f, (GLdouble) width , (GLdouble) height , 0.f, -1.f, 1.f ); + glOrtho( 0.f, (GLdouble) width, 0.f, (GLdouble) height, -1.f, 1.f ); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl index 27c09db92..3f60d4a71 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl @@ -10,6 +10,7 @@ uniform sampler2D diffuseMap; void main() { - gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy)); + //gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy)); //This should not compile! + gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a); } diff --git a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl index 21c7ad765..f81867be6 100644 --- a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl @@ -8,24 +8,20 @@ uniform sampler2D diffuseMap; uniform float glowStrength; +float kern[4] = float[4](.25,.5,.8,1.0); //Initialize the correct (non nVidia cg) way void main() { vec4 col = vec4(0.0, 0.0, 0.0, 0.0); - // ATI compiler falls down on array initialization. - float kern[8]; - kern[0] = 0.25; kern[1] = 0.5; kern[2] = 0.8; kern[3] = 1.0; - kern[4] = 1.0; kern[5] = 0.8; kern[6] = 0.5; kern[7] = 0.25; - col += kern[0] * texture2D(diffuseMap, gl_TexCoord[0].xy); col += kern[1] * texture2D(diffuseMap, gl_TexCoord[1].xy); col += kern[2] * texture2D(diffuseMap, gl_TexCoord[2].xy); col += kern[3] * texture2D(diffuseMap, gl_TexCoord[3].xy); - col += kern[4] * texture2D(diffuseMap, gl_TexCoord[0].zw); - col += kern[5] * texture2D(diffuseMap, gl_TexCoord[1].zw); - col += kern[6] * texture2D(diffuseMap, gl_TexCoord[2].zw); - col += kern[7] * texture2D(diffuseMap, gl_TexCoord[3].zw); + col += kern[3] * texture2D(diffuseMap, gl_TexCoord[0].zw); + col += kern[2] * texture2D(diffuseMap, gl_TexCoord[1].zw); + col += kern[1] * texture2D(diffuseMap, gl_TexCoord[2].zw); + col += kern[0] * texture2D(diffuseMap, gl_TexCoord[3].zw); gl_FragColor = vec4(col.rgb * glowStrength, col.a); } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 09aef8a22..82fe8afd3 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -914,12 +914,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gPipeline.mScreen.flush(); } } - - /// We copy the frame buffer straight into a texture here, - /// 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()); if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) { @@ -933,7 +927,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { gFrameStats.start(LLFrameStats::RENDER_UI); render_ui(); - } + } LLSpatialGroup::sNoDelete = FALSE; } @@ -1131,8 +1125,14 @@ void render_ui(F32 zoom_factor, int subfield) if (to_texture) { gPipeline.renderBloom(gSnapshot, zoom_factor, subfield); + gPipeline.mScreen.flush(); //blit, etc. } - + /// We copy the frame buffer straight into a texture here, + /// 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()); + render_hud_elements(); render_hud_attachments(); } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index b5bd2f93a..40f49c894 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -754,7 +754,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects() } } -#if 0 +#if 1 // disabling loading of postprocess shaders until we fix // ATI sampler2DRect compatibility. 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 31691a85d..7e24601bb 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 @@ -8,157 +8,157 @@ width="400"> - + + left="14" mouse_opaque="true" name="ColorFilterToggle" width="200" /> Brightness Saturation + name="ColorFilterSaturation" show_text="true" value="1.0" width="200" /> Contrast - Contrast Base Color - - - - - + + left="14" mouse_opaque="true" name="NightVisionToggle" width="200" /> Light Amplification Multiple + name="NightVisionBrightMult" show_text="true" value="0.7" width="200" /> Noise Size - Noise Strength + name="NightVisionNoiseStrength" show_text="true" value="1.0" width="200" /> - + + left="14" mouse_opaque="true" name="BloomToggle" width="200" /> Luminosity Extraction - + left="10" mouse_opaque="true" name="BloomSizeText" v_pad="0" width="355"> Bloom Size - Bloom Strength - + + + windows md5sum - fa5041874761895a06a20782b8ba34a2 + b678c4d18ea8e4fab42b20f8d0b2629a + url - http://liny-odell.users.sourceforge.net/llqtwebkit-windows-qt4.6-20101122.tar.bz2 + http://viewer-source-downloads.s3.amazonaws.com/install_pkgs/llqtwebkit-windows-qt4.7.1-20101221.tar.bz2 + +