From b8ee9be3fcb51a4c223a15237d1542ead780d176 Mon Sep 17 00:00:00 2001 From: Beq Date: Thu, 20 Feb 2025 00:07:38 +0000 Subject: [PATCH] FIRE-32023 Show DoF focal point Draw a small crosshair at the focal point. Red when focus is locked. --- indra/newview/app_settings/settings.xml | 11 ++++ indra/newview/pipeline.cpp | 59 +++++++++++++++++-- indra/newview/pipeline.h | 4 +- .../default/xui/en/floater_phototools.xml | 31 +++++++--- .../skins/default/xui/en/menu_viewer.xml | 11 ++++ 5 files changed, 100 insertions(+), 16 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index afe9ae3baa..ec148fdc33 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11572,6 +11572,17 @@ Change of this parameter will affect the layout of buttons in notification toast Value 0 + FSFocusPointRender + + Comment + Draw a small crosshair where the DoF focus is + Persist + 1 + Type + Boolean + Value + 0 + CameraDoFResScale diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 90e0ea2019..07197fffcf 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -354,6 +354,9 @@ bool LLPipeline::sReflectionProbesEnabled = false; S32 LLPipeline::sVisibleLightCount = 0; bool LLPipeline::sRenderingHUDs; F32 LLPipeline::sDistortionWaterClipPlaneMargin = 1.0125f; +LLVector3 LLPipeline::sLastFocusPoint={};// FIRE-16728 focus point lock & free focus DoF +bool LLPipeline::sDoFEnabled = false; + F32 LLPipeline::sVolumeSAFrame = 0.f; // ZK LBG bool LLPipeline::sRenderParticles; // flag to hold correct, user selected, status of particles @@ -4445,6 +4448,48 @@ void LLPipeline::recordTrianglesDrawn() add(LLStatViewer::TRIANGLES_DRAWN, LLUnits::Triangles::fromValue(count)); } +// FIRE-32023 Focus Point Rendering +void LLPipeline::renderFocusPoint() +{ + + static LLCachedControl render_focus_point_crosshair(gSavedSettings, "FSFocusPointRender", false); + if ( sDoFEnabled && render_focus_point_crosshair && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) + { + gDebugProgram.bind(); + LLVector3 focus_point = sLastFocusPoint; + F32 size = 0.02f; + LLGLDepthTest gls_depth(GL_FALSE); + gGL.pushMatrix(); + gGL.translatef(focus_point.mV[VX], focus_point.mV[VY], focus_point.mV[VZ]); + + gGL.begin(LLRender::LINES); + if (LLPipeline::FSFocusPointLocked) + { + gGL.color4f(1.0f, 0.0f, 0.0f, 0.5f); + } + else + { + gGL.color4f(1.0f, 1.0f, 0.0f, 0.5f); + } + gGL.vertex3f(-size, 0.0f, 0.0f); + gGL.vertex3f(size, 0.0f, 0.0f); + + // Y-axis (Green) + gGL.vertex3f(0.0f, -size, 0.0f); + gGL.vertex3f(0.0f, size, 0.0f); + + // Z-axis (Blue) + gGL.vertex3f(0.0f, 0.0f, -size); + gGL.vertex3f(0.0f, 0.0f, size); + + gGL.end(); + + gGL.popMatrix(); + gGL.flush(); + gDebugProgram.unbind(); + } +} +// void LLPipeline::renderPhysicsDisplay() { if (!hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) @@ -8070,14 +8115,14 @@ bool LLPipeline::renderSnapshotFrame(LLRenderTarget* src, LLRenderTarget* dst) void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { { - bool dof_enabled = + sDoFEnabled = // // FIRE-32023 Render focus point (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && RenderDepthOfField && !gCubeSnapshot; gViewerWindow->setup3DViewport(); - if (dof_enabled) + if (sDoFEnabled) // // FIRE-32023 Render focus point { LL_PROFILE_GPU_ZONE("dof"); LLGLDisable blend(GL_BLEND); @@ -8090,10 +8135,10 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) LLVector3 focus_point; // FIRE-16728 focus point lock & free focus DoF - based on a feature developed by NiranV Dean - static LLVector3 last_focus_point{}; - if (LLPipeline::FSFocusPointLocked && !last_focus_point.isExactlyZero()) + + if (LLPipeline::FSFocusPointLocked && !sLastFocusPoint.isExactlyZero()) { - focus_point = last_focus_point; + focus_point = sLastFocusPoint; } else { @@ -8140,7 +8185,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) } // FIRE-16728 Add free aim mouse and focus lock - last_focus_point = focus_point; + sLastFocusPoint = focus_point; // LLVector3 eye = LLViewerCamera::getInstance()->getOrigin(); F32 target_distance = 16.f; @@ -8438,6 +8483,8 @@ void LLPipeline::renderFinalize() gDeferredPostNoDoFNoiseProgram.unbind(); gGL.setSceneBlendType(LLRender::BT_ALPHA); + + renderFocusPoint(); // FIRE-32023 render focus point if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 5343dccfba..2681718e0e 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -291,6 +291,7 @@ public: void renderGLTFObjects(U32 type, bool texture = true, bool rigged = false); void renderAlphaObjects(bool rigged = false); + void renderFocusPoint(); // FIRE-32023 Add focus point rendering void renderMaskedObjects(U32 type, bool texture = true, bool batch_texture = false, bool rigged = false); void renderFullbrightMaskedObjects(U32 type, bool texture = true, bool batch_texture = false, bool rigged = false); @@ -694,7 +695,8 @@ public: // [SL:KB] - Patch: Render-TextureToggle (Catznip-4.0) static bool sRenderTextures; // [/SL:KB] - + static LLVector3 sLastFocusPoint;// FIRE-16728 focus point lock & free focus DoF + static bool sDoFEnabled;// FIRE-32023 focus point render static LLTrace::EventStatHandle sStatBatchSize; class RenderTargetPack diff --git a/indra/newview/skins/default/xui/en/floater_phototools.xml b/indra/newview/skins/default/xui/en/floater_phototools.xml index ccedd1a9bb..d9f0819e92 100644 --- a/indra/newview/skins/default/xui/en/floater_phototools.xml +++ b/indra/newview/skins/default/xui/en/floater_phototools.xml @@ -1860,15 +1860,28 @@ top_pad="5" width="280"/> + control_name="FSFocusPointFollowsPointer" + enabled_control="RenderDepthOfField" + height="16" + label="Depth of Field focus follows pointer" + layout="topleft" + name="FSFocusPointFollowsPointer" + tool_tip="Allows the DoF focus point to follow your mouse cursor, similar to flycam behavior. Useful when combined with DoF focus lock for dynamic focus adjustments." + top_pad="0" + width="256"/> +