From 15fd13f83036ff781160957a21bb2d59771044bc Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 29 May 2024 16:56:39 -0500 Subject: #1530 Increase joint limit for GLTF Assets (#1582) * Migrate GLTF scene rendering to its own shaders * Add support for ambient occlusion map separate from metallic roughness map (or absent) * Use UBO's for GLTF joints * Better error handling of downloading GLTF assets --- indra/newview/llviewershadermgr.cpp | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'indra/newview/llviewershadermgr.cpp') diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 0ca05b3460..e53e90b703 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -249,7 +249,7 @@ static bool make_rigged_variant(LLGLSLShader& shader, LLGLSLShader& riggedShader } -static bool make_gltf_variant(LLGLSLShader& shader, LLGLSLShader& variant, bool alpha_blend, bool rigged) +static bool make_gltf_variant(LLGLSLShader& shader, LLGLSLShader& variant, bool alpha_blend, bool rigged, bool use_sun_shadow) { variant.mName = shader.mName.c_str(); variant.mFeatures = shader.mFeatures; @@ -259,20 +259,50 @@ static bool make_gltf_variant(LLGLSLShader& shader, LLGLSLShader& variant, bool variant.mDefines = shader.mDefines; // NOTE: Must come before addPermutation + variant.addPermutation("MAX_JOINTS_PER_GLTF_OBJECT", std::to_string(LLSkinningUtil::getMaxGLTFJointCount())); + + if (rigged) + { + variant.addPermutation("HAS_SKIN", "1"); + } + if (alpha_blend) { variant.addPermutation("ALPHA_BLEND", "1"); + + variant.mFeatures.calculatesLighting = false; + variant.mFeatures.hasLighting = false; + variant.mFeatures.isAlphaLighting = true; + variant.mFeatures.hasSrgb = true; + variant.mFeatures.calculatesAtmospherics = true; + variant.mFeatures.hasAtmospherics = true; + variant.mFeatures.hasGamma = true; + variant.mFeatures.hasShadows = use_sun_shadow; + variant.mFeatures.isDeferred = true; // include deferredUtils + variant.mFeatures.hasReflectionProbes = true; + + if (use_sun_shadow) + { + variant.addPermutation("HAS_SUN_SHADOW", "1"); + } + + bool success = variant.createShader(NULL, NULL); + llassert(success); + + // Alpha Shader Hack + // See: LLRender::syncMatrices() + variant.mFeatures.calculatesLighting = true; + variant.mFeatures.hasLighting = true; + + return success; } - if (rigged) + else { - variant.addPermutation("HAS_SKIN", "1"); - variant.mFeatures.hasObjectSkinning = true; + return variant.createShader(NULL, NULL); } - - return variant.createShader(NULL, NULL); } -static bool make_gltf_variants(LLGLSLShader& shader) +static bool make_gltf_variants(LLGLSLShader& shader, bool use_sun_shadow) { shader.mFeatures.mGLTF = true; shader.mGLTFVariants.resize(LLGLSLShader::NUM_GLTF_VARIANTS); @@ -282,7 +312,7 @@ static bool make_gltf_variants(LLGLSLShader& shader) bool alpha_blend = i & 1; bool rigged = i & 2; - if (!make_gltf_variant(shader, shader.mGLTFVariants[i], alpha_blend, rigged)) + if (!make_gltf_variant(shader, shader.mGLTFVariants[i], alpha_blend, rigged, use_sun_shadow)) { return false; } @@ -1269,7 +1299,7 @@ bool LLViewerShaderMgr::loadShadersDeferred() gGLTFPBRMetallicRoughnessProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gGLTFPBRMetallicRoughnessProgram.clearPermutations(); - success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram); + success = make_gltf_variants(gGLTFPBRMetallicRoughnessProgram, use_sun_shadow); llassert(success); } -- cgit v1.2.3