Overhaul depth preview rendering:
* Replace Jet color map with grayscale * Added Shift + \ hotkey to toggle preview * Added Shift + [, Shift + ] hotkeys to change contrast * Added Shift + ;, Shift + ' hotkeys to change offset
This commit is contained in:
@@ -226,9 +226,10 @@ namespace OpenRA.Graphics
|
|||||||
shader.SetVec("DepthTextureScale", 128 * depthScale / height);
|
shader.SetVec("DepthTextureScale", 128 * depthScale / height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthPreviewEnabled(bool enabled)
|
public void SetDepthPreview(bool enabled, float contrast, float offset)
|
||||||
{
|
{
|
||||||
shader.SetBool("EnableDepthPreview", enabled);
|
shader.SetBool("EnableDepthPreview", enabled);
|
||||||
|
shader.SetVec("DepthPreviewParams", contrast, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAntialiasingPixelsPerTexel(float pxPerTx)
|
public void SetAntialiasingPixelsPerTexel(float pxPerTx)
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
readonly List<IRenderable> renderablesBuffer = new List<IRenderable>();
|
readonly List<IRenderable> renderablesBuffer = new List<IRenderable>();
|
||||||
|
|
||||||
bool lastDepthPreviewEnabled;
|
|
||||||
|
|
||||||
internal WorldRenderer(ModData modData, World world)
|
internal WorldRenderer(ModData modData, World world)
|
||||||
{
|
{
|
||||||
World = world;
|
World = world;
|
||||||
@@ -256,11 +254,7 @@ namespace OpenRA.Graphics
|
|||||||
if (World.WorldActor.Disposed)
|
if (World.WorldActor.Disposed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (debugVis.Value != null && lastDepthPreviewEnabled != debugVis.Value.DepthBuffer)
|
debugVis.Value?.UpdateDepthBuffer();
|
||||||
{
|
|
||||||
lastDepthPreviewEnabled = debugVis.Value.DepthBuffer;
|
|
||||||
Game.Renderer.WorldSpriteRenderer.SetDepthPreviewEnabled(lastDepthPreviewEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
var bounds = Viewport.GetScissorBounds(World.Type != WorldType.Editor);
|
var bounds = Viewport.GetScissorBounds(World.Type != WorldType.Editor);
|
||||||
Game.Renderer.EnableScissor(bounds);
|
Game.Renderer.EnableScissor(bounds);
|
||||||
|
|||||||
@@ -20,7 +20,51 @@ namespace OpenRA.Traits
|
|||||||
public bool CombatGeometry;
|
public bool CombatGeometry;
|
||||||
public bool RenderGeometry;
|
public bool RenderGeometry;
|
||||||
public bool ScreenMap;
|
public bool ScreenMap;
|
||||||
public bool DepthBuffer;
|
|
||||||
public bool ActorTags;
|
public bool ActorTags;
|
||||||
|
|
||||||
|
// The depth buffer may have been left enabled by the previous world
|
||||||
|
// Initializing this as dirty forces us to reset the default rendering before the first render
|
||||||
|
bool depthBufferDirty = true;
|
||||||
|
bool depthBuffer;
|
||||||
|
public bool DepthBuffer
|
||||||
|
{
|
||||||
|
get => depthBuffer;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
depthBuffer = value;
|
||||||
|
depthBufferDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float depthBufferContrast = 1f;
|
||||||
|
public float DepthBufferContrast
|
||||||
|
{
|
||||||
|
get => depthBufferContrast;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
depthBufferContrast = value;
|
||||||
|
depthBufferDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float depthBufferOffset;
|
||||||
|
public float DepthBufferOffset
|
||||||
|
{
|
||||||
|
get => depthBufferOffset;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
depthBufferOffset = value;
|
||||||
|
depthBufferDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateDepthBuffer()
|
||||||
|
{
|
||||||
|
if (depthBufferDirty)
|
||||||
|
{
|
||||||
|
Game.Renderer.WorldSpriteRenderer.SetDepthPreview(DepthBuffer, DepthBufferContrast, DepthBufferOffset);
|
||||||
|
depthBufferDirty = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
92
OpenRA.Mods.Common/Widgets/Logic/DepthPreviewHotkeysLogic.cs
Normal file
92
OpenRA.Mods.Common/Widgets/Logic/DepthPreviewHotkeysLogic.cs
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2021 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Mods.Common.Lint;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||||
|
{
|
||||||
|
[ChromeLogicArgsHotkeys("ToggleDepthPreviewKey",
|
||||||
|
"IncreaseDepthPreviewContrastKey", "DecreaseDepthPreviewContrastKey",
|
||||||
|
"IncreaseDepthPreviewOffsetKey", "DecreaseDepthPreviewOffsetKey")]
|
||||||
|
public class DepthPreviewHotkeysLogic : ChromeLogic
|
||||||
|
{
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
public DepthPreviewHotkeysLogic(Widget widget, World world, ModData modData, Dictionary<string, MiniYaml> logicArgs)
|
||||||
|
{
|
||||||
|
var debugVis = world.WorldActor.TraitOrDefault<DebugVisualizations>();
|
||||||
|
|
||||||
|
var toggleKey = new HotkeyReference();
|
||||||
|
if (logicArgs.TryGetValue("ToggleDepthPreviewKey", out var yaml))
|
||||||
|
toggleKey = modData.Hotkeys[yaml.Value];
|
||||||
|
|
||||||
|
var increaseContrastKey = new HotkeyReference();
|
||||||
|
if (logicArgs.TryGetValue("IncreaseDepthPreviewContrastKey", out yaml))
|
||||||
|
increaseContrastKey = modData.Hotkeys[yaml.Value];
|
||||||
|
|
||||||
|
var decreaseContrastKey = new HotkeyReference();
|
||||||
|
if (logicArgs.TryGetValue("DecreaseDepthPreviewContrastKey", out yaml))
|
||||||
|
decreaseContrastKey = modData.Hotkeys[yaml.Value];
|
||||||
|
|
||||||
|
var increaseOffsetKey = new HotkeyReference();
|
||||||
|
if (logicArgs.TryGetValue("IncreaseDepthPreviewOffsetKey", out yaml))
|
||||||
|
increaseOffsetKey = modData.Hotkeys[yaml.Value];
|
||||||
|
|
||||||
|
var decreaseOffsetKey = new HotkeyReference();
|
||||||
|
if (logicArgs.TryGetValue("DecreaseDepthPreviewOffsetKey", out yaml))
|
||||||
|
decreaseOffsetKey = modData.Hotkeys[yaml.Value];
|
||||||
|
|
||||||
|
var keyhandler = widget.Get<LogicKeyListenerWidget>("DEPTHPREVIEW_KEYHANDLER");
|
||||||
|
keyhandler.AddHandler(e =>
|
||||||
|
{
|
||||||
|
if (e.Event != KeyInputEvent.Down)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (toggleKey.IsActivatedBy(e))
|
||||||
|
{
|
||||||
|
debugVis.DepthBuffer ^= true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!debugVis.DepthBuffer)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (decreaseOffsetKey.IsActivatedBy(e))
|
||||||
|
{
|
||||||
|
debugVis.DepthBufferOffset -= 0.05f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (increaseOffsetKey.IsActivatedBy(e))
|
||||||
|
{
|
||||||
|
debugVis.DepthBufferOffset += 0.05f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (increaseContrastKey.IsActivatedBy(e))
|
||||||
|
{
|
||||||
|
debugVis.DepthBufferContrast += 0.1f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decreaseContrastKey.IsActivatedBy(e))
|
||||||
|
{
|
||||||
|
debugVis.DepthBufferContrast -= 0.1f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ uniform sampler2D Palette;
|
|||||||
uniform sampler2D ColorShifts;
|
uniform sampler2D ColorShifts;
|
||||||
|
|
||||||
uniform bool EnableDepthPreview;
|
uniform bool EnableDepthPreview;
|
||||||
|
uniform vec2 DepthPreviewParams;
|
||||||
uniform float DepthTextureScale;
|
uniform float DepthTextureScale;
|
||||||
uniform float AntialiasPixelsPerTexel;
|
uniform float AntialiasPixelsPerTexel;
|
||||||
|
|
||||||
@@ -55,21 +56,6 @@ in vec4 vTint;
|
|||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float jet_r(float x)
|
|
||||||
{
|
|
||||||
return x < 0.7 ? 4.0 * x - 1.5 : -4.0 * x + 4.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
float jet_g(float x)
|
|
||||||
{
|
|
||||||
return x < 0.5 ? 4.0 * x - 0.5 : -4.0 * x + 3.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
float jet_b(float x)
|
|
||||||
{
|
|
||||||
return x < 0.3 ? 4.0 * x + 0.5 : -4.0 * x + 2.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 rgb2hsv(vec3 c)
|
vec3 rgb2hsv(vec3 c)
|
||||||
{
|
{
|
||||||
// From http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
|
// From http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
|
||||||
@@ -289,14 +275,12 @@ void main()
|
|||||||
|
|
||||||
if (EnableDepthPreview)
|
if (EnableDepthPreview)
|
||||||
{
|
{
|
||||||
float x = 1.0 - gl_FragDepth;
|
float intensity = 1.0 - clamp(DepthPreviewParams.x * depth - 0.5 * DepthPreviewParams.x - DepthPreviewParams.y + 0.5, 0.0, 1.0);
|
||||||
float r = clamp(jet_r(x), 0.0, 1.0);
|
|
||||||
float g = clamp(jet_g(x), 0.0, 1.0);
|
|
||||||
float b = clamp(jet_b(x), 0.0, 1.0);
|
|
||||||
#if __VERSION__ == 120
|
#if __VERSION__ == 120
|
||||||
gl_FragColor = vec4(r, g, b, 1.0);
|
gl_FragColor = vec4(vec3(intensity), 1.0);
|
||||||
#else
|
#else
|
||||||
fragColor = vec4(r, g, b, 1.0);
|
fragColor = vec4(vec3(intensity), 1.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -2,6 +2,13 @@ Container@PLAYER_WIDGETS:
|
|||||||
Logic: LoadIngameChatLogic
|
Logic: LoadIngameChatLogic
|
||||||
Children:
|
Children:
|
||||||
Container@CHAT_ROOT:
|
Container@CHAT_ROOT:
|
||||||
|
LogicKeyListener@DEPTHPREVIEW_KEYHANDLER:
|
||||||
|
Logic: DepthPreviewHotkeysLogic
|
||||||
|
ToggleDepthPreviewKey: ToggleDepthPreview
|
||||||
|
IncreaseDepthPreviewContrastKey: IncreaseDepthPreviewContrast
|
||||||
|
DecreaseDepthPreviewContrastKey: DecreaseDepthPreviewContrast
|
||||||
|
IncreaseDepthPreviewOffsetKey: IncreaseDepthPreviewOffset
|
||||||
|
DecreaseDepthPreviewOffsetKey: DecreaseDepthPreviewOffset
|
||||||
LogicKeyListener@CONTROLGROUP_KEYHANDLER:
|
LogicKeyListener@CONTROLGROUP_KEYHANDLER:
|
||||||
Logic: ControlGroupLogic
|
Logic: ControlGroupLogic
|
||||||
LogicTicker@SIDEBAR_TICKER:
|
LogicTicker@SIDEBAR_TICKER:
|
||||||
|
|||||||
169
mods/ts/chrome/settings-hotkeys.yaml
Normal file
169
mods/ts/chrome/settings-hotkeys.yaml
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
Container@HOTKEYS_PANEL:
|
||||||
|
Logic: HotkeysSettingsLogic
|
||||||
|
HotkeyGroups:
|
||||||
|
Game Commands:
|
||||||
|
Template: TWO_COLUMN
|
||||||
|
Types: OrderGenerator, World, Menu
|
||||||
|
Viewport Commands:
|
||||||
|
Template: TWO_COLUMN
|
||||||
|
Types: Viewport
|
||||||
|
Observer / Replay Commands:
|
||||||
|
Template: TWO_COLUMN
|
||||||
|
Types: Observer, Replay
|
||||||
|
Unit Commands:
|
||||||
|
Template: THREE_COLUMN
|
||||||
|
Types: Unit
|
||||||
|
Unit Stance Commands:
|
||||||
|
Template: TWO_COLUMN
|
||||||
|
Types: Stance
|
||||||
|
Production Commands:
|
||||||
|
Template: THREE_COLUMN
|
||||||
|
Types: Production, ProductionSlot
|
||||||
|
Support Power Commands:
|
||||||
|
Template: THREE_COLUMN
|
||||||
|
Types: SupportPower
|
||||||
|
Music Commands:
|
||||||
|
Template: TWO_COLUMN
|
||||||
|
Types: Music
|
||||||
|
Chat Commands:
|
||||||
|
Template: TWO_COLUMN
|
||||||
|
Types: Chat
|
||||||
|
Depth Preview Debug:
|
||||||
|
Template: TWO_COLUMN
|
||||||
|
Types: DepthDebug
|
||||||
|
Width: PARENT_RIGHT - 10
|
||||||
|
Height: PARENT_BOTTOM
|
||||||
|
Children:
|
||||||
|
ScrollPanel@HOTKEY_LIST:
|
||||||
|
X: 15
|
||||||
|
Y: 40
|
||||||
|
Width: PARENT_RIGHT - 30
|
||||||
|
TopBottomSpacing: 4
|
||||||
|
ItemSpacing: 4
|
||||||
|
Height: 190
|
||||||
|
Children:
|
||||||
|
ScrollItem@HEADER:
|
||||||
|
BaseName: scrollheader
|
||||||
|
Width: 528
|
||||||
|
Height: 13
|
||||||
|
Visible: false
|
||||||
|
Children:
|
||||||
|
Label@LABEL:
|
||||||
|
Font: TinyBold
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 10
|
||||||
|
Align: Center
|
||||||
|
ScrollItem@HEADER:
|
||||||
|
Width: 528
|
||||||
|
Height: 13
|
||||||
|
Visible: false
|
||||||
|
Children:
|
||||||
|
Label@LABEL:
|
||||||
|
Font: TinyBold
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 10
|
||||||
|
Align: Center
|
||||||
|
Container@TEMPLATES:
|
||||||
|
Children:
|
||||||
|
Container@TWO_COLUMN:
|
||||||
|
Width: 262
|
||||||
|
Height: 25
|
||||||
|
Visible: false
|
||||||
|
Children:
|
||||||
|
Label@FUNCTION:
|
||||||
|
Y: 0 - 1
|
||||||
|
Width: PARENT_RIGHT - 85
|
||||||
|
Height: 25
|
||||||
|
Align: Right
|
||||||
|
Button@HOTKEY:
|
||||||
|
X: PARENT_RIGHT - WIDTH
|
||||||
|
Width: 80
|
||||||
|
Height: 25
|
||||||
|
Align: Left
|
||||||
|
TooltipContainer: SETTINGS_TOOLTIP_CONTAINER
|
||||||
|
Container@THREE_COLUMN:
|
||||||
|
Width: 173
|
||||||
|
Height: 25
|
||||||
|
Visible: false
|
||||||
|
Children:
|
||||||
|
Label@FUNCTION:
|
||||||
|
Y: 0 - 1
|
||||||
|
Width: PARENT_RIGHT - 84
|
||||||
|
Height: 25
|
||||||
|
Align: Right
|
||||||
|
Button@HOTKEY:
|
||||||
|
X: PARENT_RIGHT - WIDTH + 1
|
||||||
|
Width: 80
|
||||||
|
Height: 25
|
||||||
|
Align: Left
|
||||||
|
TooltipContainer: SETTINGS_TOOLTIP_CONTAINER
|
||||||
|
Background@HOTKEY_DIALOG_ROOT:
|
||||||
|
X: 15
|
||||||
|
Y: 230
|
||||||
|
Width: PARENT_RIGHT - 30
|
||||||
|
Height: 65
|
||||||
|
Background: dialog3
|
||||||
|
Children:
|
||||||
|
Label@HOTKEY_LABEL:
|
||||||
|
X: 15
|
||||||
|
Y: 19
|
||||||
|
Width: 219 - 15 - 10
|
||||||
|
Height: 25
|
||||||
|
Font: Bold
|
||||||
|
Align: Right
|
||||||
|
HotkeyEntry@HOTKEY_ENTRY:
|
||||||
|
X: 219
|
||||||
|
Y: 20
|
||||||
|
Width: 170
|
||||||
|
Height: 25
|
||||||
|
Container@NOTICES:
|
||||||
|
X: 219
|
||||||
|
Y: 42
|
||||||
|
Width: 170
|
||||||
|
Height: 25
|
||||||
|
Children:
|
||||||
|
Label@DEFAULT_NOTICE:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: PARENT_BOTTOM
|
||||||
|
Font: Tiny
|
||||||
|
Align: Left
|
||||||
|
Text: This is the default
|
||||||
|
Label@ORIGINAL_NOTICE:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: PARENT_BOTTOM
|
||||||
|
Font: Tiny
|
||||||
|
Align: Left
|
||||||
|
Text: The default is "{0}"
|
||||||
|
Label@DUPLICATE_NOTICE:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: PARENT_BOTTOM
|
||||||
|
Font: Tiny
|
||||||
|
Align: Left
|
||||||
|
Text: This is already used for "{0}"
|
||||||
|
Button@OVERRIDE_HOTKEY_BUTTON:
|
||||||
|
X: PARENT_RIGHT - 3 * WIDTH - 30
|
||||||
|
Y: 20
|
||||||
|
Width: 70
|
||||||
|
Height: 25
|
||||||
|
Text: Override
|
||||||
|
Font: Bold
|
||||||
|
Button@CLEAR_HOTKEY_BUTTON:
|
||||||
|
X: PARENT_RIGHT - 2 * WIDTH - 30
|
||||||
|
Y: 20
|
||||||
|
Width: 65
|
||||||
|
Height: 25
|
||||||
|
Text: Clear
|
||||||
|
Font: Bold
|
||||||
|
TooltipText: Unbind the hotkey
|
||||||
|
TooltipContainer: SETTINGS_TOOLTIP_CONTAINER
|
||||||
|
TooltipTemplate: SIMPLE_TOOLTIP
|
||||||
|
Button@RESET_HOTKEY_BUTTON:
|
||||||
|
X: PARENT_RIGHT - WIDTH - 20
|
||||||
|
Y: 20
|
||||||
|
Width: 65
|
||||||
|
Height: 25
|
||||||
|
Text: Reset
|
||||||
|
Font: Bold
|
||||||
|
TooltipText: Reset to default
|
||||||
|
TooltipContainer: SETTINGS_TOOLTIP_CONTAINER
|
||||||
|
TooltipTemplate: SIMPLE_TOOLTIP
|
||||||
@@ -21,3 +21,23 @@ ProductionTypeAircraft: U
|
|||||||
PowerDown: X
|
PowerDown: X
|
||||||
Description: Power-down mode
|
Description: Power-down mode
|
||||||
Types: OrderGenerator, Player
|
Types: OrderGenerator, Player
|
||||||
|
|
||||||
|
DecreaseDepthPreviewContrast: LEFTBRACKET SHIFT
|
||||||
|
Description: Decrease Contrast
|
||||||
|
Types: DepthDebug
|
||||||
|
|
||||||
|
IncreaseDepthPreviewContrast: RIGHTBRACKET SHIFT
|
||||||
|
Description: Increase Contrast
|
||||||
|
Types: DepthDebug
|
||||||
|
|
||||||
|
DecreaseDepthPreviewOffset: SEMICOLON SHIFT
|
||||||
|
Description: Decrease Offset
|
||||||
|
Types: DepthDebug
|
||||||
|
|
||||||
|
IncreaseDepthPreviewOffset: QUOTE SHIFT
|
||||||
|
Description: Increase Offset
|
||||||
|
Types: DepthDebug
|
||||||
|
|
||||||
|
ToggleDepthPreview: BACKSLASH SHIFT
|
||||||
|
Description: Toggle Preview
|
||||||
|
Types: DepthDebug
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ ChromeLayout:
|
|||||||
common|chrome/settings-display.yaml
|
common|chrome/settings-display.yaml
|
||||||
common|chrome/settings-audio.yaml
|
common|chrome/settings-audio.yaml
|
||||||
common|chrome/settings-input.yaml
|
common|chrome/settings-input.yaml
|
||||||
common|chrome/settings-hotkeys.yaml
|
ts|chrome/settings-hotkeys.yaml
|
||||||
common|chrome/settings-advanced.yaml
|
common|chrome/settings-advanced.yaml
|
||||||
common|chrome/credits.yaml
|
common|chrome/credits.yaml
|
||||||
common|chrome/lobby.yaml
|
common|chrome/lobby.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user