diff options
Diffstat (limited to 'indra/newview/llviewershadermgr.cpp')
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 199 |
1 files changed, 165 insertions, 34 deletions
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index d1dea16bc0..873a59e6f6 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -194,15 +194,20 @@ LLGLSLShader gDeferredSkinnedEmissiveProgram; LLGLSLShader gDeferredPostProgram; LLGLSLShader gDeferredCoFProgram; LLGLSLShader gDeferredDoFCombineProgram; +LLGLSLShader gDeferredPostTonemapProgram; +LLGLSLShader gNoPostTonemapProgram; LLGLSLShader gDeferredPostGammaCorrectProgram; -LLGLSLShader gNoPostGammaCorrectProgram; LLGLSLShader gLegacyPostGammaCorrectProgram; LLGLSLShader gExposureProgram; LLGLSLShader gExposureProgramNoFade; LLGLSLShader gLuminanceProgram; -LLGLSLShader gFXAAProgram; +LLGLSLShader gFXAAProgram[4]; +LLGLSLShader gSMAAEdgeDetectProgram[4]; +LLGLSLShader gSMAABlendWeightsProgram[4]; +LLGLSLShader gSMAANeighborhoodBlendProgram[4]; LLGLSLShader gCASProgram; LLGLSLShader gDeferredPostNoDoFProgram; +LLGLSLShader gDeferredPostNoDoFNoiseProgram; LLGLSLShader gDeferredWLSkyProgram; LLGLSLShader gEnvironmentMapProgram; LLGLSLShader gDeferredWLCloudProgram; @@ -427,8 +432,9 @@ void LLViewerShaderMgr::finalizeShaderList() mShaderList.push_back(&gDeferredWLSunProgram); mShaderList.push_back(&gDeferredPBRAlphaProgram); mShaderList.push_back(&gHUDPBRAlphaProgram); + mShaderList.push_back(&gDeferredPostTonemapProgram); + mShaderList.push_back(&gNoPostTonemapProgram); mShaderList.push_back(&gDeferredPostGammaCorrectProgram); // for gamma - mShaderList.push_back(&gNoPostGammaCorrectProgram); mShaderList.push_back(&gLegacyPostGammaCorrectProgram); mShaderList.push_back(&gDeferredDiffuseProgram); mShaderList.push_back(&gDeferredBumpProgram); @@ -1102,9 +1108,17 @@ bool LLViewerShaderMgr::loadShadersDeferred() gExposureProgramNoFade.unload(); gLuminanceProgram.unload(); gDeferredPostGammaCorrectProgram.unload(); - gNoPostGammaCorrectProgram.unload(); gLegacyPostGammaCorrectProgram.unload(); - gFXAAProgram.unload(); + gDeferredPostTonemapProgram.unload(); + gNoPostTonemapProgram.unload(); + for (auto i = 0; i < 4; ++i) + { + gFXAAProgram[i].unload(); + gSMAAEdgeDetectProgram[i].unload(); + gSMAABlendWeightsProgram[i].unload(); + gSMAANeighborhoodBlendProgram[i].unload(); + } + gCASProgram.unload(); gEnvironmentMapProgram.unload(); gDeferredWLSkyProgram.unload(); gDeferredWLCloudProgram.unload(); @@ -2309,21 +2323,6 @@ bool LLViewerShaderMgr::loadShadersDeferred() if (success) { - gNoPostGammaCorrectProgram.mName = "No Post Gamma Correction Post Process"; - gNoPostGammaCorrectProgram.mFeatures.hasSrgb = true; - gNoPostGammaCorrectProgram.mFeatures.isDeferred = true; - gNoPostGammaCorrectProgram.mShaderFiles.clear(); - gNoPostGammaCorrectProgram.clearPermutations(); - gNoPostGammaCorrectProgram.addPermutation("NO_POST", "1"); - gNoPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); - gNoPostGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredGammaCorrect.glsl", GL_FRAGMENT_SHADER)); - gNoPostGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - success = gNoPostGammaCorrectProgram.createShader(); - llassert(success); - } - - if (success) - { gLegacyPostGammaCorrectProgram.mName = "Legacy Gamma Correction Post Process"; gLegacyPostGammaCorrectProgram.mFeatures.hasSrgb = true; gLegacyPostGammaCorrectProgram.mFeatures.isDeferred = true; @@ -2337,27 +2336,143 @@ bool LLViewerShaderMgr::loadShadersDeferred() llassert(success); } + if (success) + { + gDeferredPostTonemapProgram.mName = "Deferred Tonemap Post Process"; + gDeferredPostTonemapProgram.mFeatures.hasSrgb = true; + gDeferredPostTonemapProgram.mFeatures.isDeferred = true; + gDeferredPostTonemapProgram.mShaderFiles.clear(); + gDeferredPostTonemapProgram.clearPermutations(); + gDeferredPostTonemapProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); + gDeferredPostTonemapProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredTonemap.glsl", GL_FRAGMENT_SHADER)); + gDeferredPostTonemapProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gDeferredPostTonemapProgram.createShader(); + llassert(success); + } + + if (success) + { + gNoPostTonemapProgram.mName = "No Post Tonemap Post Process"; + gNoPostTonemapProgram.mFeatures.hasSrgb = true; + gNoPostTonemapProgram.mFeatures.isDeferred = true; + gNoPostTonemapProgram.mShaderFiles.clear(); + gNoPostTonemapProgram.clearPermutations(); + gNoPostTonemapProgram.addPermutation("NO_POST", "1"); + gNoPostTonemapProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); + gNoPostTonemapProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredTonemap.glsl", GL_FRAGMENT_SHADER)); + gNoPostTonemapProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gNoPostTonemapProgram.createShader(); + llassert(success); + } if (success && gGLManager.mGLVersion > 3.9f) { - gFXAAProgram.mName = "FXAA Shader"; - gFXAAProgram.mFeatures.isDeferred = true; - gFXAAProgram.mShaderFiles.clear(); - gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER)); - gFXAAProgram.mShaderFiles.push_back(make_pair("deferred/fxaaF.glsl", GL_FRAGMENT_SHADER)); - - if (gGLManager.mGLVersion > 3.9) + std::vector<std::pair<std::string, std::string>> quality_levels = { {"12", "Low"}, + {"23", "Medium"}, + {"28", "High"}, + {"39", "Ultra"} }; + int i = 0; + for (const auto& quality_pair : quality_levels) { - gFXAAProgram.addPermutation("FXAA_GLSL_400", "1"); + if (success) + { + gFXAAProgram[i].mName = llformat("FXAA Shader (%s)", quality_pair.second.c_str()); + gFXAAProgram[i].mFeatures.isDeferred = true; + gFXAAProgram[i].mShaderFiles.clear(); + gFXAAProgram[i].mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER)); + gFXAAProgram[i].mShaderFiles.push_back(make_pair("deferred/fxaaF.glsl", GL_FRAGMENT_SHADER)); + + gFXAAProgram[i].clearPermutations(); + gFXAAProgram[i].addPermutation("FXAA_QUALITY__PRESET", quality_pair.first); + if (gGLManager.mGLVersion > 3.9) + { + gFXAAProgram[i].addPermutation("FXAA_GLSL_400", "1"); + } + else + { + gFXAAProgram[i].addPermutation("FXAA_GLSL_130", "1"); + } + + gFXAAProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gFXAAProgram[i].createShader(); + llassert(success); + } + ++i; } - else + } + + if (success) + { + std::vector<std::pair<std::string, std::string>> quality_levels = { {"SMAA_PRESET_LOW", "Low"}, + {"SMAA_PRESET_MEDIUM", "Medium"}, + {"SMAA_PRESET_HIGH", "High"}, + {"SMAA_PRESET_ULTRA", "Ultra"} }; + int i = 0; + for (const auto& smaa_pair : quality_levels) { - gFXAAProgram.addPermutation("FXAA_GLSL_130", "1"); - } + std::map<std::string, std::string> defines; + if (gGLManager.mGLVersion >= 4.f) + defines.emplace("SMAA_GLSL_4", "1"); + else if (gGLManager.mGLVersion >= 3.1f) + defines.emplace("SMAA_GLSL_3", "1"); + else + defines.emplace("SMAA_GLSL_2", "1"); + defines.emplace("SMAA_PREDICATION", "0"); + defines.emplace("SMAA_REPROJECTION", "0"); + defines.emplace(smaa_pair.first, "1"); - gFXAAProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - success = gFXAAProgram.createShader(); - llassert(success); + if (success) + { + gSMAAEdgeDetectProgram[i].mName = llformat("SMAA Edge Detection (%s)", smaa_pair.second.c_str()); + gSMAAEdgeDetectProgram[i].mFeatures.isDeferred = true; + + gSMAAEdgeDetectProgram[i].clearPermutations(); + gSMAAEdgeDetectProgram[i].addPermutations(defines); + + gSMAAEdgeDetectProgram[i].mShaderFiles.clear(); + gSMAAEdgeDetectProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAAEdgeDetectF.glsl", GL_FRAGMENT_SHADER_ARB)); + gSMAAEdgeDetectProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAAEdgeDetectV.glsl", GL_VERTEX_SHADER_ARB)); + gSMAAEdgeDetectProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_FRAGMENT_SHADER_ARB)); + gSMAAEdgeDetectProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_VERTEX_SHADER_ARB)); + gSMAAEdgeDetectProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gSMAAEdgeDetectProgram[i].createShader(); + } + + if (success) + { + gSMAABlendWeightsProgram[i].mName = llformat("SMAA Blending Weights (%s)", smaa_pair.second.c_str()); + gSMAABlendWeightsProgram[i].mFeatures.isDeferred = true; + + gSMAABlendWeightsProgram[i].clearPermutations(); + gSMAABlendWeightsProgram[i].addPermutations(defines); + + gSMAABlendWeightsProgram[i].mShaderFiles.clear(); + gSMAABlendWeightsProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAABlendWeightsF.glsl", GL_FRAGMENT_SHADER_ARB)); + gSMAABlendWeightsProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAABlendWeightsV.glsl", GL_VERTEX_SHADER_ARB)); + gSMAABlendWeightsProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_FRAGMENT_SHADER_ARB)); + gSMAABlendWeightsProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_VERTEX_SHADER_ARB)); + gSMAABlendWeightsProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gSMAABlendWeightsProgram[i].createShader(); + } + + if (success) + { + gSMAANeighborhoodBlendProgram[i].mName = llformat("SMAA Neighborhood Blending (%s)", smaa_pair.second.c_str()); + gSMAANeighborhoodBlendProgram[i].mFeatures.isDeferred = true; + + gSMAANeighborhoodBlendProgram[i].clearPermutations(); + gSMAANeighborhoodBlendProgram[i].addPermutations(defines); + + gSMAANeighborhoodBlendProgram[i].mShaderFiles.clear(); + gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAANeighborhoodBlendF.glsl", GL_FRAGMENT_SHADER_ARB)); + gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAANeighborhoodBlendV.glsl", GL_VERTEX_SHADER_ARB)); + gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_FRAGMENT_SHADER_ARB)); + gSMAANeighborhoodBlendProgram[i].mShaderFiles.push_back(make_pair("deferred/SMAA.glsl", GL_VERTEX_SHADER_ARB)); + gSMAANeighborhoodBlendProgram[i].mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gSMAANeighborhoodBlendProgram[i].createShader(); + } + ++i; + } } if (success) @@ -2421,6 +2536,22 @@ bool LLViewerShaderMgr::loadShadersDeferred() if (success) { + gDeferredPostNoDoFNoiseProgram.mName = "Deferred Post NoDoF Noise Shader"; + gDeferredPostNoDoFNoiseProgram.mFeatures.isDeferred = true; + gDeferredPostNoDoFNoiseProgram.mShaderFiles.clear(); + gDeferredPostNoDoFNoiseProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); + gDeferredPostNoDoFNoiseProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoDoFF.glsl", GL_FRAGMENT_SHADER)); + + gDeferredPostNoDoFNoiseProgram.clearPermutations(); + gDeferredPostNoDoFNoiseProgram.addPermutation("HAS_NOISE", "1"); + + gDeferredPostNoDoFNoiseProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gDeferredPostNoDoFNoiseProgram.createShader(); + llassert(success); + } + + if (success) + { gEnvironmentMapProgram.mName = "Environment Map Program"; gEnvironmentMapProgram.mShaderFiles.clear(); gEnvironmentMapProgram.mFeatures.calculatesAtmospherics = true; |