@@ -1506,6 +1506,9 @@ namespace dxvk {
1506
1506
namespace texture_popup {
1507
1507
constexpr char POPUP_NAME[] = " rtx_texture_selection_popup" ;
1508
1508
1509
+ bool lastOpenCategoryActive = false ;
1510
+ std::string lastOpenCategoryId = {};
1511
+
1509
1512
// need to keep a reference to a texture that was passed to 'open()',
1510
1513
// as 'open()' is called only once, but popup needs to reference that texture throughout open-close
1511
1514
std::atomic<XXH64_hash_t> g_holdingTexture {};
@@ -1602,7 +1605,7 @@ namespace dxvk {
1602
1605
}
1603
1606
} // anonymous namespace
1604
1607
1605
- void ImGUI::showTextureSelectionGrid (const Rc<DxvkContext>& ctx, const char * uniqueId, const uint32_t texturesPerRow, const float thumbnailSize) {
1608
+ void ImGUI::showTextureSelectionGrid (const Rc<DxvkContext>& ctx, const char * uniqueId, const uint32_t texturesPerRow, const float thumbnailSize, const float minChildHeight ) {
1606
1609
ImGui::PushID (uniqueId);
1607
1610
auto common = ctx->getCommonObjects ();
1608
1611
uint32_t cnt = 0 ;
@@ -1623,7 +1626,8 @@ namespace dxvk {
1623
1626
}
1624
1627
1625
1628
const ImVec2 availableSize = ImGui::GetContentRegionAvail ();
1626
- const float childWindowHeight = availableSize.y < 600 ? 600 : availableSize.y ;
1629
+ const float childWindowHeight = minChildHeight <= 600 .0f ? minChildHeight
1630
+ : availableSize.y < 600 ? 600 .0f : availableSize.y ;
1627
1631
ImGuiWindowFlags window_flags = ImGuiWindowFlags_None;
1628
1632
ImGui::BeginChild (str::format (" Child" , uniqueId).c_str (), ImVec2 (availableSize.x , childWindowHeight), false , window_flags);
1629
1633
@@ -1650,7 +1654,17 @@ namespace dxvk {
1650
1654
}
1651
1655
}
1652
1656
}
1653
-
1657
+
1658
+ if (legacyTextureGuiShowAssignedOnly ()) {
1659
+ if (std::string_view (uniqueId) != " textures" ) {
1660
+ if (!textureHasSelection) {
1661
+ continue ; // Texture is not assigned to this category -> skip
1662
+ }
1663
+ } else if (textureHasSelection) {
1664
+ continue ; // Currently handling the uncategorized texture tab and current texture is assigned to a category -> skip
1665
+ }
1666
+ }
1667
+
1654
1668
if (texHash == textureInPopup || texHash == g_jumpto.load ()) {
1655
1669
const auto blueColor = ImGui::GetStyleColorVec4 (ImGuiCol_Button);
1656
1670
const auto nvidiaColor = ImVec4 (0 .462745f , 0 .725490f , 0 .f , 1 .f );
@@ -1689,7 +1703,8 @@ namespace dxvk {
1689
1703
ImGui::SetCursorPosY (y + (thumbnailSize - extent.y ) / 2 .f );
1690
1704
1691
1705
if (ImGui::ImageButton (texImgui.texID , extent)) {
1692
- if (isListFiltered) {
1706
+ // Legacy list = no popup // Legacy list + show assigned only = popup
1707
+ if (isListFiltered && !legacyTextureGuiShowAssignedOnly ()) {
1693
1708
toggleTextureSelection (texHash, uniqueId, listRtxOption.textureSetOption ->getValue ());
1694
1709
} else {
1695
1710
clickedOnTextureButton = true ;
@@ -1723,6 +1738,9 @@ namespace dxvk {
1723
1738
if (ImGui::IsMouseReleased (ImGuiMouseButton_Middle)) {
1724
1739
ImGui::SetClipboardText (hashToString (texHash).c_str ());
1725
1740
}
1741
+ if (std::string_view (uniqueId) != texture_popup::lastOpenCategoryId) {
1742
+ texture_popup::lastOpenCategoryId = uniqueId;
1743
+ }
1726
1744
}
1727
1745
}
1728
1746
@@ -1738,7 +1756,8 @@ namespace dxvk {
1738
1756
}
1739
1757
1740
1758
// popup for texture selection from world / ui
1741
- {
1759
+ // Only the "active" category is allowed to control the texture popup and highlighting logic
1760
+ if (std::string_view (uniqueId) == texture_popup::lastOpenCategoryId) {
1742
1761
const bool wasUIClick =
1743
1762
!texture_popup::isOpened () &&
1744
1763
clickedOnTextureButton;
@@ -1769,6 +1788,10 @@ namespace dxvk {
1769
1788
});
1770
1789
}
1771
1790
1791
+ if (wasUIClick || wasWorldClick) {
1792
+ texture_popup::lastOpenCategoryId = uniqueId;
1793
+ }
1794
+
1772
1795
auto texHashToHighlight = std::optional<XXH64_hash_t>{};
1773
1796
1774
1797
// top priority for what's inside a currently open texture popup
@@ -1791,6 +1814,9 @@ namespace dxvk {
1791
1814
common->metaDebugView ().Highlighting .requestHighlighting (XXH64_hash_t { kEmptyHash }, HighlightColor::UI, ctx->getDevice ()->getCurrentFrameId ());
1792
1815
}
1793
1816
}
1817
+
1818
+ // checked after the last 'showTextureSelectionGrid' call to see if saved category is still active
1819
+ texture_popup::lastOpenCategoryActive = true ;
1794
1820
}
1795
1821
1796
1822
ImGui::EndChild ();
@@ -1846,6 +1872,8 @@ namespace dxvk {
1846
1872
void ImGUI::showSetupWindow (const Rc<DxvkContext>& ctx) {
1847
1873
ImGui::PushItemWidth (200 );
1848
1874
1875
+ texture_popup::lastOpenCategoryActive = false ;
1876
+
1849
1877
const float thumbnailScale = RtxOptions::textureGridThumbnailScale ();
1850
1878
const float thumbnailSize = (120 .f * thumbnailScale);
1851
1879
const float thumbnailSpacing = ImGui::GetStyle ().ItemSpacing .x ;
@@ -1856,6 +1884,11 @@ namespace dxvk {
1856
1884
1857
1885
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Step 1: Categorize Textures" , collapsingHeaderClosedFlags), " Select texture definitions for Remix" )) {
1858
1886
ImGui::Checkbox (" Split Texture Category List" , &showLegacyTextureGuiObject ());
1887
+
1888
+ if (showLegacyTextureGui ()) {
1889
+ ImGui::Checkbox (" Only Show Assigned Textures in Category Lists" , &legacyTextureGuiShowAssignedOnlyObject ());
1890
+ }
1891
+
1859
1892
ImGui::DragFloat (" Texture Thumbnail Scale" , &RtxOptions::Get ()->textureGridThumbnailScaleObject (), 0 .25f , 0 .25f , 3 .f , " %.2f" , sliderFlags);
1860
1893
ImGui::Separator ();
1861
1894
@@ -1867,136 +1900,164 @@ namespace dxvk {
1867
1900
showTextureSelectionGrid (ctx, " textures" , numThumbnailsPerRow, thumbnailSize);
1868
1901
}
1869
1902
else {
1903
+ // Wrapper function that controls childheight and logic specific to 'showTextureSelectionGrid'
1904
+ const auto & showTextureSelectionGridWrapper = [&](const char * uniqueId) {
1905
+ const bool isUncategorized = std::string_view (uniqueId) == " textures" ;
1906
+ float childHeight = 600 .0f ;
1907
+ uint32_t textureCount = 0 ;
1908
+ uint32_t rowCount = 1 ;
1909
+
1910
+ // Count textures that are assigned to the current category to calculate childheight for ImGui::BeginChild in 'showTextureSelectionGrid'
1911
+ if (legacyTextureGuiShowAssignedOnly () && !isUncategorized) {
1912
+ RtxTextureOption listRtxOption;
1913
+
1914
+ for (auto rtxOption : rtxTextureOptions) {
1915
+ if (strcmp (rtxOption.uniqueId , uniqueId) == 0 ) {
1916
+ listRtxOption = rtxOption;
1917
+ break ;
1918
+ }
1919
+ }
1920
+
1921
+ for (auto & [texHash, texImgui] : g_imguiTextureMap) {
1922
+ auto & textureSet = listRtxOption.textureSetOption ->getValue ();
1923
+ bool textureHasSelection = textureSet.find (texHash) != textureSet.end ();
1924
+
1925
+ if (!textureHasSelection) {
1926
+ continue ;
1927
+ }
1928
+
1929
+ textureCount++;
1930
+
1931
+ if (textureCount > numThumbnailsPerRow * rowCount) {
1932
+ rowCount++;
1933
+ }
1934
+
1935
+ childHeight = static_cast <float >(rowCount) * thumbnailSize + 16 .0f ;
1936
+
1937
+ if (childHeight >= 600 .0f ) {
1938
+ break ;
1939
+ }
1940
+ }
1941
+ }
1942
+
1943
+ if (textureCount || isUncategorized || !legacyTextureGuiShowAssignedOnly ()) {
1944
+ if (ImGui::IsItemToggledOpen () || texture_popup::lastOpenCategoryId.empty ()) {
1945
+ // Update last opened category ID if texture category (ImGui::CollapsingHeader) was just toggled open or if ID is empty
1946
+ texture_popup::lastOpenCategoryId = uniqueId;
1947
+ }
1948
+
1949
+ // Legacy GUI: Using indents in this field is causing issues with padding where the rightmost texture is cut off by the scroll bar.
1950
+ // Unindent and indent around each list to preserve formatting and use full space while keeping headers and other UI indented for organization.
1951
+ ImGui::Unindent ();
1952
+ showTextureSelectionGrid (ctx, uniqueId, numThumbnailsPerRow, thumbnailSize, childHeight);
1953
+ ImGui::Indent ();
1954
+ }
1955
+ else {
1956
+ ImGui::Spacing ();
1957
+ ImGui::SetCursorPosX ((ImGui::GetWindowWidth () - ImGui::CalcTextSize (" Empty" ).x ) * 0 .5f );
1958
+ ImGui::Text (" Empty" );
1959
+ ImGui::Spacing ();
1960
+ }
1961
+ };
1962
+
1870
1963
ImGui::Indent ();
1871
1964
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" UI Textures" , collapsingHeaderClosedFlags), RtxOptions::Get ()->uiTexturesDescription ())) {
1872
- // Legacy GUI: Using indents in this field is causing issues with padding where the rightmost texture is cut off by the scroll bar.
1873
- // Unindent and indent around each list to preserve formatting and use full space while keeping headers and other UI indented for organization.
1874
- ImGui::Unindent ();
1875
- showTextureSelectionGrid (ctx, " uitextures" , numThumbnailsPerRow, thumbnailSize);
1876
- ImGui::Indent ();
1965
+ showTextureSelectionGridWrapper (" uitextures" );
1877
1966
}
1878
1967
1879
1968
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Worldspace UI Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->worldSpaceUiTexturesDescription ())) {
1880
- ImGui::Unindent ();
1881
- showTextureSelectionGrid (ctx, " worldspaceuitextures" , numThumbnailsPerRow, thumbnailSize);
1882
- ImGui::Indent ();
1969
+ showTextureSelectionGridWrapper (" worldspaceuitextures" );
1883
1970
}
1884
1971
1885
1972
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Worldspace UI Background Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->worldSpaceUiBackgroundTexturesDescription ())) {
1886
- ImGui::Unindent ();
1887
- showTextureSelectionGrid (ctx, " worldspaceuibackgroundtextures" , numThumbnailsPerRow, thumbnailSize);
1888
- ImGui::Indent ();
1973
+ showTextureSelectionGridWrapper (" worldspaceuibackgroundtextures" );
1889
1974
}
1890
1975
1891
1976
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Sky Textures" , collapsingHeaderClosedFlags), RtxOptions::Get ()->skyBoxTexturesDescription ())) {
1892
- ImGui::Unindent ();
1893
- showTextureSelectionGrid (ctx, " skytextures" , numThumbnailsPerRow, thumbnailSize);
1894
- ImGui::Indent ();
1977
+ showTextureSelectionGridWrapper (" skytextures" );
1895
1978
}
1896
1979
1897
1980
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Ignore Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->ignoreTexturesDescription ())) {
1898
- ImGui::Unindent ();
1899
- showTextureSelectionGrid (ctx, " ignoretextures" , numThumbnailsPerRow, thumbnailSize);
1900
- ImGui::Indent ();
1981
+ showTextureSelectionGridWrapper (" ignoretextures" );
1901
1982
}
1902
1983
1903
1984
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Hide Instance Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->hideInstanceTexturesDescription ())) {
1904
- ImGui::Unindent ();
1905
- showTextureSelectionGrid (ctx, " hidetextures" , numThumbnailsPerRow, thumbnailSize);
1906
- ImGui::Indent ();
1985
+ showTextureSelectionGridWrapper (" hidetextures" );
1907
1986
}
1908
1987
1909
1988
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Lightmap Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->lightmapTexturesDescription ())) {
1910
- ImGui::Unindent ();
1911
- showTextureSelectionGrid (ctx, " lightmaptextures" , numThumbnailsPerRow, thumbnailSize);
1912
- ImGui::Indent ();
1989
+ showTextureSelectionGridWrapper (" lightmaptextures" );
1913
1990
}
1914
1991
1915
1992
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Ignore Lights (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->ignoreLightsDescription ())) {
1916
- ImGui::Unindent ();
1917
- showTextureSelectionGrid (ctx, " ignorelights" , numThumbnailsPerRow, thumbnailSize);
1918
- ImGui::Indent ();
1993
+ showTextureSelectionGridWrapper (" ignorelights" );
1919
1994
}
1920
1995
1921
1996
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Particle Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->particleTexturesDescription ())) {
1922
- ImGui::Unindent ();
1923
- showTextureSelectionGrid (ctx, " particletextures" , numThumbnailsPerRow, thumbnailSize);
1924
- ImGui::Indent ();
1997
+ showTextureSelectionGridWrapper (" particletextures" );
1925
1998
}
1926
1999
1927
2000
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Beam Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->beamTexturesDescription ())) {
1928
- ImGui::Unindent ();
1929
- showTextureSelectionGrid (ctx, " beamtextures" , numThumbnailsPerRow, thumbnailSize);
1930
- ImGui::Indent ();
2001
+ showTextureSelectionGridWrapper (" beamtextures" );
1931
2002
}
1932
2003
1933
2004
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Add Lights to Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->lightConverterDescription ())) {
1934
- ImGui::Unindent ();
1935
- showTextureSelectionGrid (ctx, " lightconvertertextures" , numThumbnailsPerRow, thumbnailSize);
1936
- ImGui::Indent ();
2005
+ showTextureSelectionGridWrapper (" lightconvertertextures" );
1937
2006
}
1938
2007
1939
2008
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Decal Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->decalTexturesDescription ())) {
1940
- ImGui::Unindent ();
1941
- showTextureSelectionGrid (ctx, " decaltextures" , numThumbnailsPerRow, thumbnailSize);
1942
- ImGui::Indent ();
2009
+ showTextureSelectionGridWrapper (" decaltextures" );
1943
2010
}
1944
2011
1945
2012
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Legacy Cutout Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->cutoutTexturesDescription ())) {
1946
- ImGui::Unindent ();
1947
- showTextureSelectionGrid (ctx, " cutouttextures" , numThumbnailsPerRow, thumbnailSize);
1948
- ImGui::Indent ();
2013
+ showTextureSelectionGridWrapper (" cutouttextures" );
1949
2014
}
1950
2015
1951
2016
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Terrain Textures" , collapsingHeaderClosedFlags), RtxOptions::Get ()->terrainTexturesDescription ())) {
1952
- ImGui::Unindent ();
1953
- showTextureSelectionGrid (ctx, " terraintextures" , numThumbnailsPerRow, thumbnailSize);
1954
- ImGui::Indent ();
2017
+ showTextureSelectionGridWrapper (" terraintextures" );
1955
2018
}
1956
2019
1957
2020
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Water Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->animatedWaterTexturesDescription ())) {
1958
- ImGui::Unindent ();
1959
- showTextureSelectionGrid (ctx, " watertextures" , numThumbnailsPerRow, thumbnailSize);
1960
- ImGui::Indent ();
2021
+ showTextureSelectionGridWrapper (" watertextures" );
1961
2022
}
1962
2023
1963
2024
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Player Model Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->playerModelTexturesDescription ())) {
1964
- ImGui::Unindent ();
1965
- showTextureSelectionGrid (ctx, " playermodeltextures" , numThumbnailsPerRow, thumbnailSize);
1966
- ImGui::Indent ();
2025
+ showTextureSelectionGridWrapper (" playermodeltextures" );
1967
2026
}
1968
2027
1969
2028
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Player Model Body Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->playerModelBodyTexturesDescription ())) {
1970
- ImGui::Unindent ();
1971
- showTextureSelectionGrid (ctx, " playermodelbodytextures" , numThumbnailsPerRow, thumbnailSize);
1972
- ImGui::Indent ();
2029
+ showTextureSelectionGridWrapper (" playermodelbodytextures" );
1973
2030
}
1974
2031
1975
2032
if (RtxOptions::AntiCulling::Object::enable () &&
1976
2033
IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Anti-Culling Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->antiCullingTexturesDescription ())) {
1977
- ImGui::Unindent ();
1978
- showTextureSelectionGrid (ctx, " antiCullingTextures" , numThumbnailsPerRow, thumbnailSize);
1979
- ImGui::Indent ();
2034
+ showTextureSelectionGridWrapper (" antiCullingTextures" );
1980
2035
}
1981
2036
1982
2037
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Motion Blur Mask-Out Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->motionBlurMaskOutTexturesDescription ())) {
1983
- ImGui::Unindent ();
1984
- showTextureSelectionGrid (ctx, " motionBlurMaskOutTextures" , numThumbnailsPerRow, thumbnailSize);
1985
- ImGui::Indent ();
2038
+ showTextureSelectionGridWrapper (" motionBlurMaskOutTextures" );
1986
2039
}
1987
2040
1988
2041
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Opacity Micromap Ignore Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->opacityMicromapIgnoreTexturesDescription ())) {
1989
- ImGui::Unindent ();
1990
- showTextureSelectionGrid (ctx, " opacitymicromapignoretextures" , numThumbnailsPerRow, thumbnailSize);
1991
- ImGui::Indent ();
2042
+ showTextureSelectionGridWrapper (" opacitymicromapignoretextures" );
1992
2043
}
1993
2044
1994
2045
if (IMGUI_ADD_TOOLTIP (ImGui::CollapsingHeader (" Ignore Baked Lighting Textures (optional)" , collapsingHeaderClosedFlags), RtxOptions::Get ()->ignoreBakedLightingTexturesDescription ())) {
1995
- ImGui::Unindent ();
1996
- showTextureSelectionGrid (ctx, " ignorebakedlightingtextures" , numThumbnailsPerRow, thumbnailSize);
1997
- ImGui::Indent ();
2046
+ showTextureSelectionGrid (ctx, " ignorebakedlightingtextures" );
2047
+ }
2048
+
2049
+ if (legacyTextureGuiShowAssignedOnly ())
2050
+ {
2051
+ if (ImGui::CollapsingHeader (" Uncategorized" , collapsingHeaderClosedFlags)) {
2052
+ showTextureSelectionGridWrapper (" textures" );
2053
+ }
1998
2054
}
1999
2055
ImGui::Unindent ();
2056
+
2057
+ // Check if last saved category was closed this frame
2058
+ if (!texture_popup::lastOpenCategoryActive) {
2059
+ texture_popup::lastOpenCategoryId.clear ();
2060
+ }
2000
2061
}
2001
2062
}
2002
2063
0 commit comments