From 049fc419d1d1f41ac05e424d599a89366cee7ca7 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 9 Sep 2022 03:28:12 -0700 Subject: SL-17701: PBR: WIP Alpha Blending --- indra/newview/llviewershadermgr.cpp | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'indra/newview/llviewershadermgr.cpp') diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 0d9670d9ca..8ec51b3856 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -265,6 +265,7 @@ LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredPBROpaqueProgram; LLGLSLShader gDeferredSkinnedPBROpaqueProgram; +LLGLSLShader gDeferredPBRAlphaProgram[2]; // not skinned, skinned //helper for making a rigged variant of a given shader bool make_rigged_variant(LLGLSLShader& shader, LLGLSLShader& riggedShader) @@ -1283,6 +1284,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPBROpaqueProgram.unload(); gDeferredSkinnedPBROpaqueProgram.unload(); + gDeferredPBRAlphaProgram[0].unload(); + gDeferredPBRAlphaProgram[1].unload(); return TRUE; } @@ -1616,6 +1619,80 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() } llassert(success); } + + if (success) + { + for (int rigged = 0; rigged < 2 && success; ++rigged) + { + LLGLSLShader* shader = &gDeferredPBRAlphaProgram[rigged]; + shader->mName = rigged + ? "Skinned Deferred PBR Alpha Shader" + : "Deferred PBR Alpha Shader"; + shader->mRiggedVariant = rigged + ? &gDeferredPBRAlphaProgram[1] + : nullptr; + shader->mFeatures.hasObjectSkinning = (bool)rigged; + shader->mFeatures.calculatesLighting = false; + shader->mFeatures.hasLighting = false; + shader->mFeatures.isAlphaLighting = true; + shader->mFeatures.hasSrgb = true; + shader->mFeatures.encodesNormal = true; + shader->mFeatures.calculatesAtmospherics = true; + shader->mFeatures.hasAtmospherics = true; + shader->mFeatures.hasGamma = true; + shader->mFeatures.hasTransport = true; + shader->mFeatures.hasShadows = use_sun_shadow; + shader->mFeatures.isDeferred = true; // include deferredUtils + shader->mFeatures.hasReflectionProbes = mShaderLevel[SHADER_DEFERRED]; + + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaV.glsl", GL_VERTEX_SHADER_ARB)); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + + shader->clearPermutations(); + + U32 alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; + shader->addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode)); + shader->addPermutation("HAS_NORMAL_MAP", "1"); + shader->addPermutation("HAS_SPECULAR_MAP", "1"); // PBR: Packed: Occlusion, Metal, Roughness + shader->addPermutation("HAS_EMISSIVE_MAP", "1"); + shader->addPermutation("USE_VERTEX_COLOR", "1"); + if (use_sun_shadow) + { + shader->addPermutation("HAS_SHADOW", "1"); + } + + if (ambient_kill) + { + shader->addPermutation("AMBIENT_KILL", "1"); + } + + if (sunlight_kill) + { + shader->addPermutation("SUNLIGHT_KILL", "1"); + } + + if (local_light_kill) + { + shader->addPermutation("LOCAL_LIGHT_KILL", "1"); + } + + if (rigged) + { + shader->addPermutation("HAS_SKIN", "1"); + } + + shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + + success = shader->createShader(NULL, NULL); + llassert(success); + + // Alpha Shader Hack + shader->mFeatures.calculatesLighting = true; + shader->mFeatures.hasLighting = true; + } + } + if (success) { -- cgit v1.2.3