From 817f1629bdafd6c28efa2a868a7aad75eb8a9514 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 3 Apr 2012 02:52:34 -0500 Subject: Pathfinding visualization WIP -- add many controls for x-ray render, add lighting, and better combat z-fighting and noise from wireframes and overlays --- indra/newview/app_settings/settings.xml | 84 +++++++++++++++--- .../shaders/class1/interface/pathfindingV.glsl | 18 +++- indra/newview/llfloaterpathfindingconsole.cpp | 22 +++++ indra/newview/llfloaterpathfindingconsole.h | 5 ++ indra/newview/pipeline.cpp | 99 ++++++++++++++-------- .../default/xui/en/floater_pathfinding_console.xml | 8 ++ 6 files changed, 187 insertions(+), 49 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 8e2d69ea9b..ed9bcb0380 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -13519,7 +13519,7 @@ PathfindingNavMeshClear Comment - yay! + Background color Persist 1 Type @@ -13535,7 +13535,7 @@ PathfindingWalkable Comment - yay! + Walkable color Persist 1 Type @@ -13551,7 +13551,7 @@ PathfindingObstacle Comment - yay! + Obstacle color Persist 1 Type @@ -13567,7 +13567,7 @@ PathfindingMaterial Comment - yay! + Material volume color Persist 1 Type @@ -13583,7 +13583,7 @@ PathfindingExclusion Comment - yay! + Exclusion volume color Persist 1 Type @@ -13599,7 +13599,7 @@ PathfindingConnectedEdge Comment - yay! + Connected edge color Persist 1 Type @@ -13615,7 +13615,7 @@ PathfindingBoundaryEdge Comment - yay! + Boundary edge color Persist 1 Type @@ -13631,7 +13631,7 @@ PathfindingHeatColorBase Comment - yay! + Least walkable heat map color Persist 1 Type @@ -13647,7 +13647,7 @@ PathfindingHeatColorMax Comment - yay! + Most walkable heat map color Persist 1 Type @@ -13663,7 +13663,7 @@ PathfindingFaceColor Comment - yay! + Nav mesh color? Persist 1 Type @@ -13724,6 +13724,66 @@ 1.0 + PathfindingAmbiance + + Comment + Ambiance of lit pathfinding displays. + Persist + 0 + Type + F32 + Value + 0.5 + + + PathfindingXRayTint + + Comment + Amount to darken/lighten x-ray lines in pathfinding display + Persist + 0 + Type + F32 + Value + 0.8 + + + PathfindingXRayOpacity + + Comment + Opacity of xray lines in pathfinding display. + Persist + 0 + Type + F32 + Value + 0.25 + + + PathfindingLineWidth + + Comment + Width of volume outlines in pathfinding display. + Persist + 0 + Type + F32 + Value + 2.0 + + + PathfindingLineOffset + + Comment + Depth offset of volume outlines in pathfinding display. + Persist + 0 + Type + F32 + Value + 1.6 + + PathfindingDisablePermanentObjects Comment @@ -13746,5 +13806,7 @@ Value 0 - + + + diff --git a/indra/newview/app_settings/shaders/class1/interface/pathfindingV.glsl b/indra/newview/app_settings/shaders/class1/interface/pathfindingV.glsl index dc9fefd156..31e878ebc6 100644 --- a/indra/newview/app_settings/shaders/class1/interface/pathfindingV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/pathfindingV.glsl @@ -27,14 +27,28 @@ uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec3 normal; VARYING vec4 vertex_color; uniform float tint; - +uniform float ambiance; +uniform float alpha_scale; + void main() { gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - vertex_color = diffuse_color * tint; + + vec3 l1 = vec3(-0.75, 1, 1.0); + vec3 l2 = vec3(0.5, -0.6, 0.4)*0.25; + vec3 l3 = vec3(0.5, -0.8, 0.3)*0.5; + + float lit = max(dot(normal, l1), 0.0); + lit += max(dot(normal, l2), 0.0); + lit += max(dot(normal, l3), 0.0); + + lit = clamp(lit, ambiance, 1.0); + + vertex_color = vec4(diffuse_color.rgb * tint * lit, diffuse_color.a*alpha_scale); } diff --git a/indra/newview/llfloaterpathfindingconsole.cpp b/indra/newview/llfloaterpathfindingconsole.cpp index a274251fb8..c981ca6c5d 100644 --- a/indra/newview/llfloaterpathfindingconsole.cpp +++ b/indra/newview/llfloaterpathfindingconsole.cpp @@ -96,6 +96,10 @@ BOOL LLFloaterPathfindingConsole::postBuild() llassert(mShowWorldCheckBox != NULL); mShowWorldCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingConsole::onShowWorldToggle, this)); + mShowXRayCheckBox = findChild("x-ray"); + llassert(mShowXRayCheckBox != NULL); + mShowXRayCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingConsole::onShowXRayToggle, this)); + mViewCharactersButton = findChild("view_characters_floater"); llassert(mViewCharactersButton != NULL); mViewCharactersButton->setCommitCallback(boost::bind(&LLFloaterPathfindingConsole::onViewCharactersClicked, this)); @@ -219,6 +223,7 @@ void LLFloaterPathfindingConsole::onClose(bool pIsAppQuitting) mShowStaticObstaclesCheckBox->set( false ); mShowExclusionVolumesCheckBox->set( false ); mShowWorldCheckBox->set( false ); + mShowXRayCheckBox->set(false); } BOOL LLFloaterPathfindingConsole::handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down) @@ -340,6 +345,17 @@ void LLFloaterPathfindingConsole::setRenderWorld(BOOL pIsRenderWorld) mShowWorldCheckBox->set(pIsRenderWorld); } +BOOL LLFloaterPathfindingConsole::isRenderXRay() const +{ + return mShowXRayCheckBox->get(); +} + +void LLFloaterPathfindingConsole::setRenderXRay(BOOL pIsRenderXRay) +{ + mShowXRayCheckBox->set(pIsRenderXRay); +} + + LLFloaterPathfindingConsole::ERenderHeatmapType LLFloaterPathfindingConsole::getRenderHeatmapType() const { ERenderHeatmapType renderHeatmapType; @@ -593,6 +609,12 @@ void LLFloaterPathfindingConsole::onShowWorldToggle() } } +void LLFloaterPathfindingConsole::onShowXRayToggle() +{ + //nothing to do (xray parameter not stored in pathing lib +} + + void LLFloaterPathfindingConsole::onCharacterWidthSet() { generatePath(); diff --git a/indra/newview/llfloaterpathfindingconsole.h b/indra/newview/llfloaterpathfindingconsole.h index d63b69abd4..7633bce9be 100644 --- a/indra/newview/llfloaterpathfindingconsole.h +++ b/indra/newview/llfloaterpathfindingconsole.h @@ -96,6 +96,9 @@ public: BOOL isRenderWorld() const; void setRenderWorld(BOOL pIsRenderWorld); + + BOOL isRenderXRay() const; + void setRenderXRay(BOOL pIsRenderXRay); BOOL isRenderAnyShapes() const; U32 getRenderShapeFlags(); @@ -135,6 +138,7 @@ private: void onShowWalkabilitySet(); void onShowWorldToggle(); + void onShowXRayToggle(); void onCharacterWidthSet(); void onCharacterTypeSwitch(); void onViewCharactersClicked(); @@ -167,6 +171,7 @@ private: LLCheckBoxCtrl *mShowMaterialVolumesCheckBox; LLCheckBoxCtrl *mShowExclusionVolumesCheckBox; LLCheckBoxCtrl *mShowWorldCheckBox; + LLCheckBoxCtrl *mShowXRayCheckBox; LLTextBase *mPathfindingViewerStatus; LLTextBase *mPathfindingSimulatorStatus; LLButton *mViewCharactersButton; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d46dc242be..c1b0e6736f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4322,6 +4322,10 @@ void LLPipeline::renderDebug() if (LLGLSLShader::sNoFixedFunction) { gPathfindingProgram.bind(); + + gPathfindingProgram.uniform1f("tint", 1.f); + gPathfindingProgram.uniform1f("ambiance", 1.f); + gPathfindingProgram.uniform1f("alpha_scale", 1.f); } @@ -4338,11 +4342,10 @@ void LLPipeline::renderDebug() LLFloaterPathfindingConsole *pathfindingConsole = pathfindingConsoleHandle.get(); //NavMesh if ( pathfindingConsole->isRenderNavMesh() ) - { - gPathfindingProgram.uniform1f("tint", 1.f); + { gGL.flush(); glLineWidth(2.0f); LLGLEnable cull(GL_CULL_FACE); - LLGLEnable blend(GL_BLEND); + LLGLDisable blend(GL_BLEND); if ( pathfindingConsole->isRenderWorld() ) { glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); @@ -4354,54 +4357,78 @@ void LLPipeline::renderDebug() glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); } + int materialIndex = pathfindingConsole->getHeatMapType(); llPathingLibInstance->renderNavMesh( materialIndex ); + gGL.flush(); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); glLineWidth(1.0f); gGL.flush(); } //physics/exclusion shapes if ( pathfindingConsole->isRenderAnyShapes() ) - { - gPathfindingProgram.uniform1f("tint", 1.f); - gGL.flush(); - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - //render to depth first to avoid blending artifacts - gGL.setColorMask(false, false); - llPathingLibInstance->renderNavMeshShapesVBO( pathfindingConsole->getRenderShapeFlags() ); - gGL.setColorMask(true, false); - - LLGLEnable blend(GL_BLEND); + { + gGL.flush(); + glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - { //get rid of some z-fighting LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(-1.0f, -1.0f); + glPolygonOffset(1.0f, 1.0f); - { //draw solid overlay - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_LEQUAL); - llPathingLibInstance->renderNavMeshShapesVBO( pathfindingConsole->getRenderShapeFlags() ); - gGL.flush(); - } + //render to depth first to avoid blending artifacts + gGL.setColorMask(false, false); + llPathingLibInstance->renderNavMeshShapesVBO( pathfindingConsole->getRenderShapeFlags() ); + gGL.setColorMask(true, false); + + //get rid of some z-fighting + glPolygonOffset(0.f, 0.f); + + LLGLEnable blend(GL_BLEND); - glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + { + F32 ambiance = gSavedSettings.getF32("PathfindingAmbiance"); - { //draw hidden wireframe as darker and less opaque - gPathfindingProgram.uniform1f("tint", 0.25f); - LLGLEnable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER); - llPathingLibInstance->renderNavMeshShapesVBO( pathfindingConsole->getRenderShapeFlags() ); - } + gPathfindingProgram.uniform1f("ambiance", ambiance); - { //draw visible wireframe as brighter and more opaque - gPathfindingProgram.uniform1f("tint", 1.f); - LLGLDisable blendOut(GL_BLEND); - llPathingLibInstance->renderNavMeshShapesVBO( pathfindingConsole->getRenderShapeFlags() ); - gGL.flush(); - } + { //draw solid overlay + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_LEQUAL); + llPathingLibInstance->renderNavMeshShapesVBO( pathfindingConsole->getRenderShapeFlags() ); + gGL.flush(); + } - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - } + LLGLEnable lineOffset(GL_POLYGON_OFFSET_LINE); + glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + + F32 offset = gSavedSettings.getF32("PathfindingLineOffset"); + + if (pathfindingConsole->isRenderXRay()) + { + { //draw hidden wireframe as darker and less opaque + glPolygonOffset(offset, -offset); + gPathfindingProgram.uniform1f("tint", gSavedSettings.getF32("PathfindingXRayTint")); + gPathfindingProgram.uniform1f("alpha_scale", gSavedSettings.getF32("PathfindingXRayOpacity")); + gPathfindingProgram.uniform1f("ambiance", 1.f); + LLGLEnable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER); + llPathingLibInstance->renderNavMeshShapesVBO( pathfindingConsole->getRenderShapeFlags() ); + } + } + + { //draw visible wireframe as brighter, thicker and more opaque + glPolygonOffset(offset, offset); + gPathfindingProgram.uniform1f("ambiance", 1.f); + gPathfindingProgram.uniform1f("tint", 1.f); + gPathfindingProgram.uniform1f("alpha_scale", 1.f); + + glLineWidth(gSavedSettings.getF32("PathfindingLineWidth")); + LLGLDisable blendOut(GL_BLEND); + llPathingLibInstance->renderNavMeshShapesVBO( pathfindingConsole->getRenderShapeFlags() ); + gGL.flush(); + glLineWidth(1.f); + } + + glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + } } //User designated path if ( pathfindingConsole->isRenderPath() ) @@ -4414,7 +4441,7 @@ void LLPipeline::renderDebug() gGL.flush(); if (LLGLSLShader::sNoFixedFunction) { - gUIProgram.unbind(); + gPathfindingProgram.unbind(); } } diff --git a/indra/newview/skins/default/xui/en/floater_pathfinding_console.xml b/indra/newview/skins/default/xui/en/floater_pathfinding_console.xml index adcd7f0fbf..f64349f47e 100644 --- a/indra/newview/skins/default/xui/en/floater_pathfinding_console.xml +++ b/indra/newview/skins/default/xui/en/floater_pathfinding_console.xml @@ -139,6 +139,14 @@ name="show_world" top_pad="4" width="90" /> +