diff options
Diffstat (limited to 'indra/newview/llviewershadermgr.cpp')
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 101 |
1 files changed, 76 insertions, 25 deletions
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 12d0aa4f8e..6b0fc4f5e8 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -100,6 +100,7 @@ LLGLSLShader gBenchmarkProgram; LLGLSLShader gReflectionProbeDisplayProgram; LLGLSLShader gCopyProgram; LLGLSLShader gCopyDepthProgram; +LLGLSLShader gPBRTerrainBakeProgram; //object shaders LLGLSLShader gObjectPreviewProgram; @@ -226,7 +227,7 @@ LLGLSLShader gDeferredSkinnedPBROpaqueProgram; LLGLSLShader gHUDPBRAlphaProgram; LLGLSLShader gDeferredPBRAlphaProgram; LLGLSLShader gDeferredSkinnedPBRAlphaProgram; -LLGLSLShader gDeferredPBRTerrainProgram; +LLGLSLShader gDeferredPBRTerrainProgram[TERRAIN_PAINT_TYPE_COUNT]; LLGLSLShader gGLTFPBRMetallicRoughnessProgram; @@ -432,7 +433,10 @@ void LLViewerShaderMgr::finalizeShaderList() mShaderList.push_back(&gGLTFPBRMetallicRoughnessProgram); mShaderList.push_back(&gDeferredAvatarProgram); mShaderList.push_back(&gDeferredTerrainProgram); - mShaderList.push_back(&gDeferredPBRTerrainProgram); + for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type) + { + mShaderList.push_back(&gDeferredPBRTerrainProgram[paint_type]); + } mShaderList.push_back(&gDeferredDiffuseAlphaMaskProgram); mShaderList.push_back(&gDeferredNonIndexedDiffuseAlphaMaskProgram); mShaderList.push_back(&gDeferredTreeProgram); @@ -495,8 +499,6 @@ void LLViewerShaderMgr::setShaders() mShaderList.clear(); - LLShaderMgr::sMirrorsEnabled = LLPipeline::RenderMirrors; - if (!gGLManager.mHasRequirements) { // Viewer will show 'hardware requirements' warning later @@ -755,6 +757,8 @@ std::string LLViewerShaderMgr::loadBasicShaders() bool ssr = gSavedSettings.getBOOL("RenderScreenSpaceReflections"); + bool mirrors = gSavedSettings.getBOOL("RenderMirrors"); + bool has_reflection_probes = gSavedSettings.getBOOL("RenderReflectionsEnabled") && gGLManager.mGLVersion > 3.99f; S32 probe_level = llclamp(gSavedSettings.getS32("RenderReflectionProbeLevel"), 0, 3); @@ -782,6 +786,11 @@ std::string LLViewerShaderMgr::loadBasicShaders() attribs["REF_SAMPLE_COUNT"] = "32"; } + if (mirrors) + { + attribs["HERO_PROBES"] = "1"; + } + { // PBR terrain const S32 mapping = clamp_terrain_mapping(gSavedSettings.getS32("RenderTerrainPBRPlanarSampleCount")); attribs["TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT"] = llformat("%d", mapping); @@ -1124,7 +1133,10 @@ bool LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedPBROpaqueProgram.unload(); gDeferredPBRAlphaProgram.unload(); gDeferredSkinnedPBRAlphaProgram.unload(); - gDeferredPBRTerrainProgram.unload(); + for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type) + { + gDeferredPBRTerrainProgram[paint_type].unload(); + } return true; } @@ -1324,7 +1336,14 @@ bool LLViewerShaderMgr::loadShadersDeferred() success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow); - llassert(success); + //llassert(success); + if (!success) + { + LL_WARNS() << "Failed to create GLTF PBR Metallic Roughness Shader, disabling!" << LL_ENDL; + gSavedSettings.setBOOL("RenderCanUseGLTFPBROpaqueShaders", false); + // continue as if this shader never happened + success = true; + } } if (success) @@ -1438,25 +1457,31 @@ bool LLViewerShaderMgr::loadShadersDeferred() S32 detail = gSavedSettings.getS32("RenderTerrainPBRDetail"); detail = llclamp(detail, TERRAIN_PBR_DETAIL_MIN, TERRAIN_PBR_DETAIL_MAX); const S32 mapping = clamp_terrain_mapping(gSavedSettings.getS32("RenderTerrainPBRPlanarSampleCount")); - gDeferredPBRTerrainProgram.mName = llformat("Deferred PBR Terrain Shader %d %s", - detail, - (mapping == 1 ? "flat" : "triplanar")); - gDeferredPBRTerrainProgram.mFeatures.hasSrgb = true; - gDeferredPBRTerrainProgram.mFeatures.isAlphaLighting = true; - gDeferredPBRTerrainProgram.mFeatures.calculatesAtmospherics = true; - gDeferredPBRTerrainProgram.mFeatures.hasAtmospherics = true; - gDeferredPBRTerrainProgram.mFeatures.hasGamma = true; - gDeferredPBRTerrainProgram.mFeatures.hasTransport = true; - gDeferredPBRTerrainProgram.mFeatures.isPBRTerrain = true; - - gDeferredPBRTerrainProgram.mShaderFiles.clear(); - gDeferredPBRTerrainProgram.mShaderFiles.push_back(make_pair("deferred/pbrterrainV.glsl", GL_VERTEX_SHADER)); - gDeferredPBRTerrainProgram.mShaderFiles.push_back(make_pair("deferred/pbrterrainF.glsl", GL_FRAGMENT_SHADER)); - gDeferredPBRTerrainProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - gDeferredPBRTerrainProgram.addPermutation("TERRAIN_PBR_DETAIL", llformat("%d", detail)); - gDeferredPBRTerrainProgram.addPermutation("TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT", llformat("%d", mapping)); - success = gDeferredPBRTerrainProgram.createShader(); - llassert(success); + for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type) + { + LLGLSLShader* shader = &gDeferredPBRTerrainProgram[paint_type]; + shader->mName = llformat("Deferred PBR Terrain Shader %d %s %s", + detail, + (paint_type == TERRAIN_PAINT_TYPE_PBR_PAINTMAP ? "paintmap" : "heightmap-with-noise"), + (mapping == 1 ? "flat" : "triplanar")); + shader->mFeatures.hasSrgb = true; + shader->mFeatures.isAlphaLighting = true; + shader->mFeatures.calculatesAtmospherics = true; + shader->mFeatures.hasAtmospherics = true; + shader->mFeatures.hasGamma = true; + shader->mFeatures.hasTransport = true; + shader->mFeatures.isPBRTerrain = true; + + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("deferred/pbrterrainV.glsl", GL_VERTEX_SHADER)); + shader->mShaderFiles.push_back(make_pair("deferred/pbrterrainF.glsl", GL_FRAGMENT_SHADER)); + shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + shader->addPermutation("TERRAIN_PBR_DETAIL", llformat("%d", detail)); + shader->addPermutation("TERRAIN_PAINT_TYPE", llformat("%d", paint_type)); + shader->addPermutation("TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT", llformat("%d", mapping)); + success = success && shader->createShader(); + llassert(success); + } } if (success) @@ -2954,6 +2979,32 @@ bool LLViewerShaderMgr::loadShadersInterface() if (success) { + LLGLSLShader* shader = &gPBRTerrainBakeProgram; + U32 bit_depth = gSavedSettings.getU32("TerrainPaintBitDepth"); + // LLTerrainPaintMap currently uses an RGB8 texture internally + bit_depth = llclamp(bit_depth, 1, 8); + shader->mName = llformat("Terrain Bake Shader RGB%o", bit_depth); + shader->mFeatures.isPBRTerrain = true; + + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeV.glsl", GL_VERTEX_SHADER)); + shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeF.glsl", GL_FRAGMENT_SHADER)); + shader->mShaderLevel = mShaderLevel[SHADER_INTERFACE]; + const U32 value_range = (1 << bit_depth) - 1; + shader->addPermutation("TERRAIN_PAINT_PRECISION", llformat("%d", value_range)); + success = success && shader->createShader(); + //llassert(success); + if (!success) + { + LL_WARNS() << "Failed to create shader '" << shader->mName << "', disabling!" << LL_ENDL; + gSavedSettings.setBOOL("RenderCanUseTerrainBakeShaders", false); + // continue as if this shader never happened + success = true; + } + } + + if (success) + { gAlphaMaskProgram.mName = "Alpha Mask Shader"; gAlphaMaskProgram.mShaderFiles.clear(); gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskV.glsl", GL_VERTEX_SHADER)); |