Show texture dimensions in AsserViewer

- fixed color picker for background
This commit is contained in:
Simon Lübeß
2026-07-22 21:25:16 +02:00
parent 3095c8f0bb
commit ab39386b27
+27 -19
View File
@@ -258,7 +258,7 @@ class TextureViewer
if (_backgroundMode == .CustomColor) if (_backgroundMode == .CustomColor)
{ {
ImGui.ColorPicker3("Color", ref _backgroundColor); ImGui.ColorEdit3("Color", ref _backgroundColor);
_backgroundColor.A = 1.0f; _backgroundColor.A = 1.0f;
} }
} }
@@ -269,16 +269,18 @@ class TextureViewer
ImGui.Combo("Sampler", (.)&_sampleMode, items.Ptr, (.)items.Count); ImGui.Combo("Sampler", (.)&_sampleMode, items.Ptr, (.)items.Count);
ImGui.SliderInt("Mip Level", &_mipLevel, 0, (int32)maxMips); ImGui.SliderInt("Mip Level", &_mipLevel, 0, (int32)maxMips - 1);
ImGui.SliderInt("Array Slice", &_arraySlice, 0, (int32)arraySize);
ImGui.BeginDisabled(rtGroup == null);
ImGui.SliderInt("Group Target", &_groupIndex, (rtGroup?.HasDepth == true) ? -1 : 0, (int32)(rtGroup?.ColorTargetCount ?? 1) - 1);
ImGui.TextUnformatted(scope $"Target name: {(rtGroup?.GetTargetDescription(_groupIndex).DebugName ?? "???")}");
ImGui.BeginDisabled(arraySize <= 1);
ImGui.SliderInt("Array Slice", &_arraySlice, 0, (int32)arraySize - 1);
ImGui.EndDisabled(); ImGui.EndDisabled();
if (rtGroup != null)
{
ImGui.SliderInt("Group Target", &_groupIndex, (rtGroup?.HasDepth == true) ? -1 : 0, (int32)(rtGroup?.ColorTargetCount ?? 1) - 1);
ImGui.TextUnformatted(scope $"Target name: {(rtGroup?.GetTargetDescription(_groupIndex).DebugName ?? "???")}");
}
} }
if (ImGui.CollapsingHeader("Color and Transparency")) if (ImGui.CollapsingHeader("Color and Transparency"))
@@ -370,6 +372,18 @@ class TextureViewer
ImGui.EndTable(); ImGui.EndTable();
} }
} }
if (ImGui.CollapsingHeader("Info"))
{
ImGui.Text($"Resolution: {width} x {height}");
ImGui.Text($"Array Size: {arraySize}");
ImGui.Text($"Mip Levels: {maxMips}");
if (rtGroup != null)
{
ImGui.Text($"Group Size: {rtGroup.TargetCount}");
}
}
} }
private void SwizzleCombo(StringView text, ref ColorChannelSwizzle swizzle) private void SwizzleCombo(StringView text, ref ColorChannelSwizzle swizzle)
@@ -414,9 +428,9 @@ class TextureViewer
} }
} }
public void ViewTexture(RenderTargetGroup texture) public void ViewTexture(RenderTargetGroup textureGroup)
{ {
ShowSettings(texture.Width, texture.Height, texture.MipLevels - 1, texture.ArraySize - 1, texture); ShowSettings(textureGroup.Width, textureGroup.Height, textureGroup.MipLevels, textureGroup.ArraySize, textureGroup);
if (ImGui.BeginChild("imageChild")) if (ImGui.BeginChild("imageChild"))
{ {
@@ -434,7 +448,7 @@ class TextureViewer
RenderBackground(); RenderBackground();
RenderTexture(texture); RenderTexture(textureGroup);
ImGui.Image(_targets.GetViewBinding(0), viewportSize); ImGui.Image(_targets.GetViewBinding(0), viewportSize);
@@ -446,7 +460,7 @@ class TextureViewer
public void ViewTexture(Texture texture) public void ViewTexture(Texture texture)
{ {
ShowSettings(texture.Width, texture.Height, texture.MipLevels - 1, texture.ArraySize - 1, null); ShowSettings(texture.Width, texture.Height, texture.MipLevels, texture.ArraySize, null);
if (ImGui.BeginChild("imageChild")) if (ImGui.BeginChild("imageChild"))
{ {
@@ -477,13 +491,10 @@ class TextureViewer
float lastWheel; float lastWheel;
float2 _lastPreviewTopLeft; float2 _lastPreviewTopLeft;
float2 _isTheCursorRight;
private void UpdateInput() private void UpdateInput()
{ {
var windowPos = ImGui.GetWindowPos();
var mousePos = ImGui.GetIO().MousePos; var mousePos = ImGui.GetIO().MousePos;
float2 mouseInWindow = .(mousePos.x - windowPos.x, mousePos.y - windowPos.y);
bool windowHovered = ImGui.IsWindowHovered(); bool windowHovered = ImGui.IsWindowHovered();
@@ -503,7 +514,6 @@ class TextureViewer
float delta = mouseWheel - lastWheel; float delta = mouseWheel - lastWheel;
float2 mousePosInObject = .(mousePos.x, mousePos.y) - _lastPreviewTopLeft; float2 mousePosInObject = .(mousePos.x, mousePos.y) - _lastPreviewTopLeft;
_isTheCursorRight = mousePosInObject;
float2 mouseOffsetFromCenter = mousePosInObject - float2(_targets.Width, _targets.Height) / 2.0f; float2 mouseOffsetFromCenter = mousePosInObject - float2(_targets.Width, _targets.Height) / 2.0f;
@@ -582,8 +592,6 @@ class TextureViewer
} }
break; break;
} }
Renderer2D.DrawQuad(float3(_isTheCursorRight * .(1, -1), 2), 4, 0, .Red);
Renderer2D.EndScene(); Renderer2D.EndScene();
} }