diff --git a/OpenRA.Game/Graphics/SpriteRenderer.cs b/OpenRA.Game/Graphics/SpriteRenderer.cs index 4712661ead..a1a8d7436d 100644 --- a/OpenRA.Game/Graphics/SpriteRenderer.cs +++ b/OpenRA.Game/Graphics/SpriteRenderer.cs @@ -119,5 +119,10 @@ namespace OpenRA.Graphics shader.SetVec("r1", zoom * 2f / screen.Width, -zoom * 2f / screen.Height); shader.SetVec("r2", -1, 1); } + + public void SetDepthPreviewEnabled(bool enabled) + { + shader.SetBool("EnableDepthPreview", enabled); + } } } diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 71baf6350f..d39113a935 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -132,6 +132,9 @@ namespace OpenRA.Graphics if (World.WorldActor.Disposed) return; + if (devTrait.Value != null) + Game.Renderer.WorldSpriteRenderer.SetDepthPreviewEnabled(devTrait.Value.ShowDepthPreview); + RefreshPalette(); if (World.Type == WorldType.Shellmap && !Game.Settings.Game.ShowShellmap) diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index f28e8a4862..5a8d8a9c44 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -23,6 +23,7 @@ namespace OpenRA.Traits public bool BuildAnywhere; public bool ShowCombatGeometry; public bool ShowDebugGeometry; + public bool ShowDepthPreview; public object Create(ActorInitializer init) { return new DeveloperMode(this); } } @@ -41,6 +42,8 @@ namespace OpenRA.Traits // Client side only public bool ShowCombatGeometry; public bool ShowDebugGeometry; + public bool ShowDepthPreview; + public bool EnableAll; public DeveloperMode(DeveloperModeInfo info) @@ -54,6 +57,7 @@ namespace OpenRA.Traits BuildAnywhere = info.BuildAnywhere; ShowCombatGeometry = info.ShowCombatGeometry; ShowDebugGeometry = info.ShowDebugGeometry; + ShowDepthPreview = info.ShowDepthPreview; } public void ResolveOrder(Actor self, Order order) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugMenuLogic.cs index 66dca231cf..4c86e13c98 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugMenuLogic.cs @@ -81,6 +81,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic showTerrainGeometryCheckbox.OnClick = () => terrainGeometryTrait.Enabled ^= true; } + var showDepthPreviewCheckbox = widget.GetOrNull("SHOW_DEPTH_PREVIEW"); + if (showDepthPreviewCheckbox != null) + { + showDepthPreviewCheckbox.IsChecked = () => devTrait.ShowDepthPreview; + showDepthPreviewCheckbox.OnClick = () => devTrait.ShowDepthPreview ^= true; + } + var allTechCheckbox = widget.GetOrNull("ENABLE_TECH"); if (allTechCheckbox != null) { diff --git a/glsl/shp.frag b/glsl/shp.frag index 1f5d378a69..43972d45b6 100644 --- a/glsl/shp.frag +++ b/glsl/shp.frag @@ -1,5 +1,7 @@ uniform sampler2D DiffuseTexture, Palette; +uniform bool EnableDepthPreview; + varying vec4 TexCoord; varying vec4 ChannelMask; varying vec4 DepthMask; @@ -8,5 +10,17 @@ void main() { vec4 x = texture2D(DiffuseTexture, TexCoord.st); vec2 p = vec2(dot(x, ChannelMask), TexCoord.p); - gl_FragColor = texture2D(Palette, p); + vec4 c = texture2D(Palette, p); + + // Discard any transparent fragments (both color and depth) + if (c.a == 0.0) + discard; + + if (EnableDepthPreview && length(DepthMask) > 0.0) + { + float depth = dot(x, DepthMask); + gl_FragColor = vec4(depth, depth, depth, 1); + } + else + gl_FragColor = c; } diff --git a/mods/ts/chrome/ingame-debug.yaml b/mods/ts/chrome/ingame-debug.yaml new file mode 100644 index 0000000000..a54b0c9757 --- /dev/null +++ b/mods/ts/chrome/ingame-debug.yaml @@ -0,0 +1,130 @@ +Container@DEBUG_PANEL: + Logic: DebugMenuLogic + Y: 10 + Width: PARENT_RIGHT + Height: PARENT_BOTTOM + Children: + Label@LABLE_TITLE: + Y: 25 + Font: Bold + Text: Debug Options + Align: Center + Width: PARENT_RIGHT + Checkbox@INSTANT_BUILD: + X: 45 + Y: 45 + Width: 200 + Height: 20 + Font: Regular + Text: Instant Build Speed + Checkbox@ENABLE_TECH: + X: 45 + Y: 75 + Width: 200 + Height: 20 + Font: Regular + Text: Build Everything + Checkbox@BUILD_ANYWHERE: + X: 45 + Y: 105 + Width: 200 + Height: 20 + Font: Regular + Text: Build Anywhere + Checkbox@UNLIMITED_POWER: + X: 290 + Y: 45 + Width: 200 + Height: 20 + Font: Regular + Text: Unlimited Power + Checkbox@INSTANT_CHARGE: + X: 290 + Y: 75 + Width: 200 + Height: 20 + Font: Regular + Text: Instant Charge Time + Checkbox@DISABLE_VISIBILITY_CHECKS: + X: 290 + Y: 105 + Height: 20 + Width: 200 + Font: Regular + Text: Disable visibility checks + Button@GIVE_CASH: + X: 90 + Y: 150 + Width: 140 + Height: 30 + Font: Bold + Text: Give $20,000 + Button@GROW_RESOURCES: + X: 271 + Y: 150 + Width: 140 + Height: 30 + Font: Bold + Text: Grow Resources + Button@GIVE_EXPLORATION: + X: 90 + Y: 200 + Width: 140 + Height: 30 + Font: Bold + Text: Clear Shroud + Button@RESET_EXPLORATION: + X: 271 + Y: 200 + Width: 140 + Height: 30 + Font: Bold + Text: Reset Shroud + Label@VISUALIZATIONS_TITLE: + Y: 255 + Font: Bold + Text: Visualizations + Align: Center + Width: PARENT_RIGHT + Checkbox@SHOW_UNIT_PATHS: + X: 45 + Y: 275 + Width: 200 + Height: 20 + Font: Regular + Text: Show Unit Paths + Checkbox@SHOW_ASTAR: + X: 45 + Y: 305 + Height: 20 + Width: 200 + Font: Regular + Text: Show A* Cost + Checkbox@SHOW_DEPTH_PREVIEW: + X: 45 + Y: 335 + Height: 20 + Width: 200 + Font: Regular + Text: Show Depth Data + Checkbox@SHOW_COMBATOVERLAY: + X: 290 + Y: 275 + Height: 20 + Width: 200 + Font: Regular + Text: Show Combat Geometry + Checkbox@SHOW_GEOMETRY: + X: 290 + Y: 305 + Height: 20 + Width: 200 + Font: Regular + Text: Show Render Geometry + Checkbox@SHOW_TERRAIN_OVERLAY: + X: 290 + Y: 335 + Height: 20 + Width: 200 + Font: Regular + Text: Show Terrain Geometry diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index 1286af45f0..58d1bf983e 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.yaml @@ -145,7 +145,7 @@ ChromeLayout: ./mods/ts/chrome/ingame-observerstats.yaml ./mods/ts/chrome/ingame-player.yaml ./mods/ra/chrome/ingame-perf.yaml - ./mods/ra/chrome/ingame-debug.yaml + ./mods/ts/chrome/ingame-debug.yaml ./mods/ra/chrome/mainmenu.yaml ./mods/ra/chrome/settings.yaml ./mods/ra/chrome/credits.yaml