summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolalpha.cpp
diff options
context:
space:
mode:
authorPtolemy <ptolemy@lindenlab.com>2022-09-09 03:28:12 -0700
committerPtolemy <ptolemy@lindenlab.com>2022-09-09 03:28:12 -0700
commit049fc419d1d1f41ac05e424d599a89366cee7ca7 (patch)
treeea2f275d9f35346cac4e14f9e11ff954d6a9ce58 /indra/newview/lldrawpoolalpha.cpp
parenta3dff0db26c5faa1613b29721498baf530f12fed (diff)
SL-17701: PBR: WIP Alpha Blending
Diffstat (limited to 'indra/newview/lldrawpoolalpha.cpp')
-rw-r--r--indra/newview/lldrawpoolalpha.cpp161
1 files changed, 111 insertions, 50 deletions
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 89b8ec1ba2..883ba72c3c 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -50,6 +50,8 @@
#include "llglcommonfunc.h"
#include "llvoavatar.h"
+#include "llenvironment.h"
+
BOOL LLDrawPoolAlpha::sShowDebugAlpha = FALSE;
#define current_shader (LLGLSLShader::sCurBoundShaderPtr)
@@ -602,65 +604,74 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged)
}
}
- LLRenderPass::applyModelMatrix(params);
+ LLRenderPass::applyModelMatrix(params);
- LLMaterial* mat = NULL;
+ LLMaterial* mat = NULL;
+ LLGLTFMaterial *gltf_mat = params.mGLTFMaterial; // Also see: LLPipeline::getPoolTypeFromTE()
+ bool is_pbr = LLPipeline::sRenderPBR && gltf_mat;
- if (deferred_render)
- {
- mat = params.mMaterial;
- }
-
- if (params.mFullbright)
- {
- // Turn off lighting if it hasn't already been so.
- if (light_enabled || !initialized_lighting)
- {
- initialized_lighting = TRUE;
- target_shader = fullbright_shader;
+ if (is_pbr && gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND)
+ {
+ target_shader = &gDeferredPBRAlphaProgram[rigged];
+ }
+ else
+ {
+ if (deferred_render)
+ {
+ mat = params.mMaterial;
+ }
- light_enabled = FALSE;
- }
- }
- // Turn on lighting if it isn't already.
- else if (!light_enabled || !initialized_lighting)
- {
- initialized_lighting = TRUE;
- target_shader = simple_shader;
- light_enabled = TRUE;
- }
+ if (params.mFullbright)
+ {
+ // Turn off lighting if it hasn't already been so.
+ if (light_enabled || !initialized_lighting)
+ {
+ initialized_lighting = TRUE;
+ target_shader = fullbright_shader;
- if (deferred_render && mat)
- {
- U32 mask = params.mShaderMask;
+ light_enabled = FALSE;
+ }
+ }
+ // Turn on lighting if it isn't already.
+ else if (!light_enabled || !initialized_lighting)
+ {
+ initialized_lighting = TRUE;
+ target_shader = simple_shader;
+ light_enabled = TRUE;
+ }
- llassert(mask < LLMaterial::SHADER_COUNT);
- target_shader = &(gDeferredMaterialProgram[mask]);
+ if (deferred_render && mat)
+ {
+ U32 mask = params.mShaderMask;
- if (LLPipeline::sUnderWaterRender)
- {
- target_shader = &(gDeferredMaterialWaterProgram[mask]);
- }
+ llassert(mask < LLMaterial::SHADER_COUNT);
+ target_shader = &(gDeferredMaterialProgram[mask]);
- if (params.mAvatar != nullptr)
+ if (LLPipeline::sUnderWaterRender)
+ {
+ target_shader = &(gDeferredMaterialWaterProgram[mask]);
+ }
+
+ if (params.mAvatar != nullptr)
+ {
+ llassert(target_shader->mRiggedVariant != nullptr);
+ target_shader = target_shader->mRiggedVariant;
+ }
+
+ if (current_shader != target_shader)
+ {
+ gPipeline.bindDeferredShader(*target_shader);
+ }
+ }
+ else if (!params.mFullbright)
{
- llassert(target_shader->mRiggedVariant != nullptr);
- target_shader = target_shader->mRiggedVariant;
+ target_shader = simple_shader;
}
-
- if (current_shader != target_shader)
- {
- gPipeline.bindDeferredShader(*target_shader);
- }
- }
- else if (!params.mFullbright)
- {
- target_shader = simple_shader;
- }
- else
- {
- target_shader = fullbright_shader;
- }
+ else
+ {
+ target_shader = fullbright_shader;
+ }
+ }
if (params.mAvatar != nullptr)
{
@@ -673,6 +684,56 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged)
target_shader->bind();
}
+ if (is_pbr)
+ {
+ if (params.mTexture.notNull())
+ {
+ gGL.getTexUnit(0)->bindFast(params.mTexture); // diffuse
+ }
+ else
+ {
+ gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sWhiteImagep);
+ }
+
+ if (params.mNormalMap)
+ {
+ target_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap);
+ }
+ else
+ {
+ target_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep);
+ }
+
+ if (params.mSpecularMap)
+ {
+ target_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, params.mSpecularMap); // PBR linear packed Occlusion, Roughness, Metal.
+ }
+ else
+ {
+ target_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep);
+ }
+
+ if (params.mEmissiveMap)
+ {
+ target_shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, params.mEmissiveMap); // PBR sRGB Emissive
+ }
+ else
+ {
+ target_shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, LLViewerFetchedTexture::sWhiteImagep);
+ }
+
+ target_shader->uniform1f(LLShaderMgr::ROUGHNESS_FACTOR, params.mGLTFMaterial->mRoughnessFactor);
+ target_shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, params.mGLTFMaterial->mMetallicFactor);
+ target_shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, params.mGLTFMaterial->mEmissiveColor.mV);
+
+ LLEnvironment& environment = LLEnvironment::instance();
+ target_shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0);
+
+ // TODO? prepare_alpha_shader( target_shader, false, true );
+ target_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, gPipeline.mTransformedSunDir.mV);
+ target_shader->uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, gPipeline.mTransformedMoonDir.mV);
+ }
+
LLVector4 spec_color(1, 1, 1, 1);
F32 env_intensity = 0.0f;
F32 brightness = 1.0f;