Skip to content

Commit

Permalink
Add split texture GUI
Browse files Browse the repository at this point in the history
Added Split Texture GUI (#14)

* dxvk_imgui.cpp - Lightmap/Hide Instance in UI

Added some hidden features to the UI, with a commented-out line for World Space UI Background.

* Description revision, offset drag in texture GUI

Revised the description for World Space Background UI Textures and added the drag float to the split texture GUI, similar to how the legacy cutout texture GUI previously was handled.

* Fix description for worldSpaceUIBackgroundTexture

* Imgui texture interface Rev. 2 (#12)

Incorporated several changes based on the feedback provided in #30 :

    Added an Unindent to every Split Texture category to fully utilize the space
    Corrected some improper min/max bounds on new sliders
    Added scaling float and slider for texture selection thumbnails
    Added indent for clarity in Split Texture List view

* Fix Bounds on Background Offset DragFloat

Quick but significant fix allowing for negative values on World Space UI Background Offset in GUI.

* Incorporate code review

rtxoptions.h:
- Removed redundant getter to use direct value of textureGridThumbnailScale

dxvk_imgui.cpp:
- Preserved intended separation between Unique Object Search Distance and Vertex Color Strength
- Removed additional sliders from Legacy GUI (Force Cutout Alpha is now included in the main GUI's Texture Parameters category)
- Added comment explaining Unindent/Indent workaround applied to legacy GUI

dxvk_imgui_about.cpp:
- Added to Github Contributors credits

#30 (review)

Additional commits (squashed): Restored an option lost to rebase merge conflicts.
  • Loading branch information
anchorlightforge authored and pkristof committed Aug 15, 2023
1 parent 7a3a4d1 commit cda4c28
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 41 deletions.
138 changes: 100 additions & 38 deletions src/dxvk/imgui/dxvk_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ namespace dxvk {
std::vector<RtxTextureOption> rtxTextureOptions = {
{"uitextures", "UI Texture", &RtxOptions::Get()->uiTexturesObject()},
{"worldspaceuitextures", "World Space UI Texture", &RtxOptions::Get()->worldSpaceUiTexturesObject()},
{"worldspaceuibackgroundtextures", "World Space UI Background Texture", &RtxOptions::Get()->worldSpaceUiBackgroundTexturesObject()},
{"skytextures", "Sky Texture", &RtxOptions::Get()->skyBoxTexturesObject()},
{"ignoretextures", "Ignore Texture (optional)", &RtxOptions::Get()->ignoreTexturesObject()},
{"hidetextures", "Hide Texture Instance (optional)", &RtxOptions::Get()->hideInstanceTexturesObject()},
{"lightmaptextures","Lightmap Textures (optional)", &RtxOptions::Get()->lightmapTexturesObject()},
{"ignorelights", "Ignore Lights (optional)", &RtxOptions::Get()->ignoreLightsObject()},
{"particletextures", "Particle Texture (optional)", &RtxOptions::Get()->particleTexturesObject()},
{"beamtextures", "Beam Texture (optional)", &RtxOptions::Get()->beamTexturesObject()},
Expand Down Expand Up @@ -1444,7 +1447,6 @@ namespace dxvk {
break;
}
}

const ImVec2 availableSize = ImGui::GetContentRegionAvail();
const float childWindowHeight = availableSize.y < 600 ? 600 : availableSize.y;
ImGuiWindowFlags window_flags = ImGuiWindowFlags_None;
Expand Down Expand Up @@ -1636,108 +1638,164 @@ namespace dxvk {
void ImGUI::showSetupWindow(const Rc<DxvkContext>& ctx) {
ImGui::PushItemWidth(200);

const float thumbnailSize = 120.f;
const float thumbnailScale = RtxOptions::textureGridThumbnailScale();
const float thumbnailSize = (120.f * thumbnailScale);
const float thumbnailSpacing = ImGui::GetStyle().ItemSpacing.x;
const float thumbnailPadding = ImGui::GetStyle().CellPadding.x;
const uint32_t numThumbnailsPerRow = uint32_t(std::max(1.f, (m_windowWidth - 18.f) / (thumbnailSize + thumbnailSpacing + thumbnailPadding * 2.f)));

ImGui::Checkbox("Preserve discarded textures", &RtxOptions::Get()->keepTexturesForTaggingObject());

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 1: Categorize Textures", collapsingHeaderClosedFlags), "Select texture definitions for Remix")) {

ImGui::Checkbox("Split Texture Category List", &showLegacyTextureGuiObject());

ImGui::DragFloat("Texture Thumbnail Scale", &RtxOptions::Get()->textureGridThumbnailScaleObject(), 0.25f, 0.25f, 3.f, "%.2f", sliderFlags);
ImGui::Separator();
if (!showLegacyTextureGui()) {
showTextureSelectionGrid(ctx, "textures", numThumbnailsPerRow, thumbnailSize);
}
else {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 1: UI Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->uiTexturesDescription())) {
ImGui::Indent();
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("UI Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->uiTexturesDescription())) {
//Legacy GUI: Using indents in this field is causing issues with padding where the rightmost texture is cut off by the scroll bar.
//Unindent and indent around each list to preserve formatting and use full space while keeping headers and other UI indented for organization.
ImGui::Unindent();
showTextureSelectionGrid(ctx, "uitextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();

}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 1.2: Worldspace UI Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->worldSpaceUiTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Worldspace UI Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->worldSpaceUiTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "worldspaceuitextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (ImGui::CollapsingHeader("Step 3: Sky Parameters (optional)", collapsingHeaderClosedFlags)) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Worldspace UI Background Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->worldSpaceUiBackgroundTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "worldspaceuibackgroundtextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Sky Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->skyBoxTexturesDescription())) {
showTextureSelectionGrid(ctx, "skytextures", numThumbnailsPerRow, thumbnailSize);
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Sky Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->skyBoxTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "skytextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 4: Ignore Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->ignoreTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Ignore Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->ignoreTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "ignoretextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Hide Instance Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->hideInstanceTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "hidetextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Lightmap Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->lightmapTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "lightmaptextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 5: Ignore Lights (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->ignoreLightsDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Ignore Lights (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->ignoreLightsDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "ignorelights", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 6: Particle Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->particleTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Particle Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->particleTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "particletextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 6.1: Beam Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->beamTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Beam Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->beamTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "beamtextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 6.2: Add Lights to Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->lightConverterDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Add Lights to Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->lightConverterDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "lightconvertertextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 7: Decal Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->decalTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Decal Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->decalTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "decaltextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 7.1: Dynamic Decal Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->dynamicDecalTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Dynamic Decal Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->dynamicDecalTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "dynamicdecaltextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 7.2: Single Offset Decal Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->singleOffsetDecalTexturesDescription())) {

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Single Offset Decal Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->singleOffsetDecalTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "singleoffsetdecaltextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 7.3: Non-Offset Decal Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->nonOffsetDecalTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Non-Offset Decal Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->nonOffsetDecalTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "nonoffsetdecaltextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 8.1: Legacy Cutout Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->cutoutTexturesDescription())) {
ImGui::DragFloat("Force Cutout Alpha", &RtxOptions::Get()->forceCutoutAlphaObject(), 0.01f, 0.0f, 1.0f, "%.3f", sliderFlags);
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Legacy Cutout Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->cutoutTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "cutouttextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 8.2: Terrain Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->terrainTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Terrain Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->terrainTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "terraintextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 8.3: Water Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->animatedWaterTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Water Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->animatedWaterTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "watertextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (RtxOptions::AntiCulling::Object::enable() &&
IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 8.4: Anti-Culling Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->antiCullingTexturesDescription())) {
showTextureSelectionGrid(ctx, "antiCullingTextures", numThumbnailsPerRow, thumbnailSize);
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Player Model Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->playerModelTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "playermodeltextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 8.5: Motion Blur Mask-Out Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->motionBlurMaskOutTexturesDescription())) {
showTextureSelectionGrid(ctx, "motionBlurMaskOutTextures", numThumbnailsPerRow, thumbnailSize);
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Player Model Body Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->playerModelBodyTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "playermodelbodytextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 9.1: Player Model Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->playerModelTexturesDescription())) {
showTextureSelectionGrid(ctx, "playermodeltextures", numThumbnailsPerRow, thumbnailSize);
if (RtxOptions::AntiCulling::Object::enable() &&
IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Anti-Culling Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->antiCullingTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "antiCullingTextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 9.2: Player Model Body Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->playerModelBodyTexturesDescription())) {
showTextureSelectionGrid(ctx, "playermodelbodytextures", numThumbnailsPerRow, thumbnailSize);
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Motion Blur Mask-Out Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->motionBlurMaskOutTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "motionBlurMaskOutTextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}

if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 10: Opacity Micromap Ignore Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->opacityMicromapIgnoreTexturesDescription())) {
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Opacity Micromap Ignore Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->opacityMicromapIgnoreTexturesDescription())) {
ImGui::Unindent();
showTextureSelectionGrid(ctx, "opacitymicromapignoretextures", numThumbnailsPerRow, thumbnailSize);
ImGui::Indent();
}
ImGui::Unindent();
}
}

Expand All @@ -1748,13 +1806,17 @@ namespace dxvk {
ImGui::Checkbox("Scene Left-Handed", &RtxOptions::Get()->isLHSObject());
fusedWorldViewModeCombo.getKey(&RtxOptions::Get()->fusedWorldViewModeRef());
ImGui::Separator();

ImGui::DragFloat("Unique Object Search Distance", &RtxOptions::Get()->uniqueObjectDistanceObject(), 0.01f, 0.01f, FLT_MAX, "%.3f", sliderFlags);
ImGui::Separator();

ImGui::DragFloat("Vertex Color Strength", &RtxOptions::Get()->vertexColorStrengthObject(), 0.001f, 0.0f, 1.0f);
ImGui::Separator();

if (ImGui::CollapsingHeader("Texture Parameters", collapsingHeaderClosedFlags)) {
ImGui::Indent();
ImGui::DragFloat("Force Cutout Alpha", &RtxOptions::Get()->forceCutoutAlphaObject(), 0.01f, 0.0f, 1.0f, "%.3f", sliderFlags);
ImGui::DragFloat("World Space UI Background Offset", &RtxOptions::Get()->worldSpaceUiBackgroundOffsetObject(), 0.01f, -FLT_MAX, FLT_MAX, "%.3f", sliderFlags);
ImGui::Unindent();
}
if (ImGui::CollapsingHeader("Shader Support (Experimental)", collapsingHeaderClosedFlags)) {
ImGui::Indent();
ImGui::Checkbox("Capture Vertices from Shader", &D3D9Rtx::useVertexCaptureObject());
Expand Down
3 changes: 2 additions & 1 deletion src/dxvk/imgui/dxvk_imgui_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ namespace dxvk {
ImGuiAbout::Credits::Credits()
: m_sections({
{ "Github Contributors",
{ "Leonardo Leotte"}},
{ "Leonardo Leotte",
"Nico Rodrigues-McKenna"}},
{ "Engineering",
{ "Riley Alston",
"Xiangshun Bei",
Expand Down
10 changes: 8 additions & 2 deletions src/dxvk/rtx_render/rtx_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ namespace dxvk {
RW_RTX_OPTION("rtx", fast_unordered_set, worldSpaceUiTextures, {},
"Textures on draw calls that should be treated as worldspace UI elements.\n"
"Unlike typical UI textures this option is useful for improved rendering of UI elements which appear as part of the scene (moving around in 3D space rather than as a screenspace element).");
RW_RTX_OPTION("rtx", fast_unordered_set, worldSpaceUiBackgroundTextures, {}, "");
RW_RTX_OPTION("rtx", fast_unordered_set, worldSpaceUiBackgroundTextures, {},
"Hack/workaround option for dynamic world space UI textures with a coplanar background.\n"
"Apply to backgrounds if the foreground material is a dynamic world texture rendered in UI that is unpredictable and rapidly changing.\n"
"This offsets the background texture backwards.");
RW_RTX_OPTION("rtx", fast_unordered_set, hideInstanceTextures, {},
"Textures on draw calls that should be hidden from rendering, but not totally ignored.\n"
"This is similar to rtx.ignoreTextures but instead of completely ignoring such draw calls they are only hidden from rendering, allowing for the hidden objects to still appear in captures.\n"
Expand Down Expand Up @@ -231,7 +234,10 @@ namespace dxvk {
RTX_OPTION_ENV("rtx", float, timeDeltaBetweenFrames, 0.f, "RTX_FRAME_TIME_DELTA_MS", "Frame time delta to use during scene processing. Setting this to 0 will use actual frame time delta for a given frame. Non-zero value is primarily used for automation to ensure determinism run to run.");

RTX_OPTION_FLAG("rtx", bool, keepTexturesForTagging, false, RtxOptionFlags::NoSave, "A flag to keep all textures in video memory, which can drastically increase VRAM consumption. Intended to assist with tagging textures that are only used for a short period of time (such as loading screens). Use only when necessary!");

RTX_OPTION("rtx.gui", float, textureGridThumbnailScale, 1.f,
"A float to set the scale of thumbnails while selecting textures.\n"
"This will be scaled by the default value of 120 pixels.\n"
"This value must always be greater than zero.");
RTX_OPTION("rtx", bool, skipDrawCallsPostRTXInjection, false, "Ignores all draw calls recorded after RTX Injection, the location of which varies but is currently based on when tagged UI textures begin to draw.");
RTX_OPTION_ENV("rtx", DlssPreset, dlssPreset, DlssPreset::On, "RTX_DLSS_PRESET", "Combined DLSS Preset for quickly controlling Upscaling, Frame Interpolation and Latency Reduction.");
RTX_OPTION("rtx", NisPreset, nisPreset, NisPreset::Balanced, "Adjusts NIS scaling factor, trades quality for performance.");
Expand Down

0 comments on commit cda4c28

Please sign in to comment.