summaryrefslogtreecommitdiff
path: root/indra/newview/pipeline.cpp
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2024-08-07 20:56:10 +0200
committerGuru <alexandrgproductengine@lindenlab.com>2024-08-08 13:40:23 +0200
commit17f7b439d617bfdf4c865f1478ade662e86b61d2 (patch)
tree87ce6eaf3691e8ce14c98364fc81fa27e3e1eb1f /indra/newview/pipeline.cpp
parente20e387d481513e4e7eed570d224da19aa532fb8 (diff)
#1922 Make PBR scale and offset crosshair work like Texture crosshair do
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r--indra/newview/pipeline.cpp159
1 files changed, 83 insertions, 76 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 2a461ca84b..1b2cffa6c9 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3580,9 +3580,12 @@ void LLPipeline::postSort(LLCamera &camera)
{
mSelectedFaces.clear();
+ bool tex_index_changed = false;
if (!gNonInteractive)
{
- LLPipeline::setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit());
+ LLRender::eTexIndex tex_index = sRenderHighlightTextureChannel;
+ setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit());
+ tex_index_changed = sRenderHighlightTextureChannel != tex_index;
}
// Draw face highlights for selected faces.
@@ -3604,6 +3607,24 @@ void LLPipeline::postSort(LLCamera &camera)
}
} func;
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func);
+
+ if (tex_index_changed)
+ {
+ // Rebuild geometry for all selected faces with PBR textures
+ for (const LLFace* face : gPipeline.mSelectedFaces)
+ {
+ if (const LLViewerObject* vobj = face->getViewerObject())
+ {
+ if (const LLTextureEntry* tep = vobj->getTE(face->getTEOffset()))
+ {
+ if (tep->getGLTFRenderMaterial())
+ {
+ gPipeline.markRebuild(face->getDrawable(), LLDrawable::REBUILD_VOLUME);
+ }
+ }
+ }
+ }
+ }
}
}
@@ -3656,28 +3677,31 @@ void render_hud_elements()
gUIProgram.unbind();
}
-void LLPipeline::renderHighlights()
+static inline void bindHighlightProgram(LLGLSLShader& program)
{
- assertInitialized();
-
- // Draw 3D UI elements here (before we clear the Z buffer in POOL_HUD)
- // Render highlighted faces.
- LLGLSPipelineAlpha gls_pipeline_alpha;
- LLColor4 color(1.f, 1.f, 1.f, 0.5f);
- disableLights();
-
if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0))
{
- gHighlightProgram.bind();
- gGL.diffuseColor4f(1,1,1,0.5f);
+ program.bind();
+ gGL.diffuseColor4f(1, 1, 1, 0.5f);
}
+}
- if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && !mFaceSelectImagep)
- {
- mFaceSelectImagep = LLViewerTextureManager::getFetchedTexture(IMG_FACE_SELECT);
- }
+static inline void unbindHighlightProgram(LLGLSLShader& program)
+{
+ if (LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)
+ {
+ program.unbind();
+ }
+}
- if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::DIFFUSE_MAP))
+void LLPipeline::renderSelectedFaces(const LLColor4& color)
+{
+ if (!mFaceSelectImagep)
+ {
+ mFaceSelectImagep = LLViewerTextureManager::getFetchedTexture(IMG_FACE_SELECT);
+ }
+
+ if (mFaceSelectImagep)
{
// Make sure the selection image gets downloaded and decoded
mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA);
@@ -3693,81 +3717,61 @@ void LLPipeline::renderHighlights()
facep->renderSelected(mFaceSelectImagep, color);
}
}
+}
- if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED))
- {
- // Paint 'em red!
- color.setVec(1.f, 0.f, 0.f, 0.5f);
-
- for (auto facep : mHighlightFaces)
- {
- facep->renderSelected(LLViewerTexture::sNullImagep, color);
- }
- }
+void LLPipeline::renderHighlights()
+{
+ assertInitialized();
- // Contains a list of the faces of objects that are physical or
- // have touch-handlers.
- mHighlightFaces.clear();
+ // Draw 3D UI elements here (before we clear the Z buffer in POOL_HUD)
+ // Render highlighted faces.
+ LLGLSPipelineAlpha gls_pipeline_alpha;
+ disableLights();
- if (LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)
+ if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED))
{
- gHighlightProgram.unbind();
- }
-
+ bindHighlightProgram(gHighlightProgram);
- if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::NORMAL_MAP))
- {
- color.setVec(1.0f, 0.5f, 0.5f, 0.5f);
- if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0))
+ if (sRenderHighlightTextureChannel == LLRender::DIFFUSE_MAP ||
+ sRenderHighlightTextureChannel == LLRender::BASECOLOR_MAP ||
+ sRenderHighlightTextureChannel == LLRender::METALLIC_ROUGHNESS_MAP ||
+ sRenderHighlightTextureChannel == LLRender::GLTF_NORMAL_MAP ||
+ sRenderHighlightTextureChannel == LLRender::EMISSIVE_MAP ||
+ sRenderHighlightTextureChannel == LLRender::NUM_TEXTURE_CHANNELS)
{
- gHighlightNormalProgram.bind();
- gGL.diffuseColor4f(1,1,1,0.5f);
+ static const LLColor4 highlight_selected_color(1.f, 1.f, 1.f, 0.5f);
+ renderSelectedFaces(highlight_selected_color);
}
- mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA);
-
- for (auto facep : mSelectedFaces)
+ // Paint 'em red!
+ static const LLColor4 highlight_face_color(1.f, 0.f, 0.f, 0.5f);
+ for (auto facep : mHighlightFaces)
{
- if (!facep || facep->getDrawable()->isDead())
- {
- LL_ERRS() << "Bad face on selection" << LL_ENDL;
- return;
- }
-
- facep->renderSelected(mFaceSelectImagep, color);
+ facep->renderSelected(LLViewerTexture::sNullImagep, highlight_face_color);
}
- if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0))
- {
- gHighlightNormalProgram.unbind();
- }
+ unbindHighlightProgram(gHighlightProgram);
}
- if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::SPECULAR_MAP))
- {
- color.setVec(0.0f, 0.3f, 1.0f, 0.8f);
- if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0))
- {
- gHighlightSpecularProgram.bind();
- gGL.diffuseColor4f(1,1,1,0.5f);
- }
-
- mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA);
+ // Contains a list of the faces of objects that are physical or
+ // have touch-handlers.
+ mHighlightFaces.clear();
- for (auto facep : mSelectedFaces)
+ if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED))
+ {
+ if (sRenderHighlightTextureChannel == LLRender::NORMAL_MAP)
{
- if (!facep || facep->getDrawable()->isDead())
- {
- LL_ERRS() << "Bad face on selection" << LL_ENDL;
- return;
- }
-
- facep->renderSelected(mFaceSelectImagep, color);
+ static const LLColor4 highlight_normal_color(1.0f, 0.5f, 0.5f, 0.5f);
+ bindHighlightProgram(gHighlightNormalProgram);
+ renderSelectedFaces(highlight_normal_color);
+ unbindHighlightProgram(gHighlightNormalProgram);
}
-
- if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0))
+ else if (sRenderHighlightTextureChannel == LLRender::SPECULAR_MAP)
{
- gHighlightSpecularProgram.unbind();
+ static const LLColor4 highlight_specular_color(0.0f, 0.3f, 1.0f, 0.8f);
+ bindHighlightProgram(gHighlightSpecularProgram);
+ renderSelectedFaces(highlight_specular_color);
+ unbindHighlightProgram(gHighlightSpecularProgram);
}
}
}
@@ -6256,7 +6260,10 @@ bool LLPipeline::getRenderHighlights()
// static
void LLPipeline::setRenderHighlightTextureChannel(LLRender::eTexIndex channel)
{
- sRenderHighlightTextureChannel = channel;
+ if (channel != sRenderHighlightTextureChannel)
+ {
+ sRenderHighlightTextureChannel = channel;
+ }
}
LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, const LLVector4a& end, LLVector4a* intersection,