Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Sky Depth Fixes, Path-Traced Skyboxes Introduction #73

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 81 additions & 44 deletions src/dxvk/imgui/dxvk_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@ namespace dxvk {
{SkyAutoDetectMode::CameraPositionAndDepthFlags, "By Camera Position and Depth Flags"}
} });

static auto SkyScaleCalibrationModeCombo = ImGui::ComboWithKey<SkyScaleCalibrationMode>(
"3D Sky Scale Calibration",
ImGui::ComboWithKey<SkyScaleCalibrationMode>::ComboEntries { {
{SkyScaleCalibrationMode::Fixed, "Always Use Default Scale"},
{SkyScaleCalibrationMode::DeltaAutomatic, "Calculate From Delta (Main vs Sky)"},
{SkyScaleCalibrationMode::SourceEngineAutomatic, "Calculate From Source Engine Approximation"}
} });

static auto SkyScaleOffsetFormulaCombo = ImGui::ComboWithKey<SkyScaleOffsetFormula>(
"3D Sky Offset Formula",
ImGui::ComboWithKey<SkyScaleOffsetFormula>::ComboEntries { {
{SkyScaleOffsetFormula::Origin, "Origin Based"},
{SkyScaleOffsetFormula::Linear, "Linear Based"},
{SkyScaleOffsetFormula::SourceEngine, "Source Engined Based (Hyperbolic)"}
} });

static auto upscalerNoDLSSCombo = ImGui::ComboWithKey<UpscalerType>(
"Upscaler Type",
{ {
Expand Down Expand Up @@ -444,7 +460,7 @@ namespace dxvk {
ImPlot::DestroyContext(m_plotContext);
ImGui::DestroyContext(m_context);
}

void ImGUI::AddTexture(const XXH64_hash_t hash, const Rc<DxvkImageView>& imageView) {
if (g_imguiTextureMap.find(hash) == g_imguiTextureMap.end()) {
ImGuiTexture texture;
Expand All @@ -458,7 +474,7 @@ namespace dxvk {
if (RtxOptions::Get()->keepTexturesForTagging()) {
return;
}

if (g_imguiTextureMap.find(hash) != g_imguiTextureMap.end())
g_imguiTextureMap.erase(hash);
}
Expand Down Expand Up @@ -556,7 +572,7 @@ namespace dxvk {
type != UIType::None ? 1 : 0, 0);
}
}

void ImGUI::showMaterialOptions() {
if (ImGui::CollapsingHeader("Material Options (optional)", collapsingHeaderClosedFlags)) {
ImGui::Indent();
Expand Down Expand Up @@ -696,7 +712,7 @@ namespace dxvk {
m_splash->update(m_largeFont);

m_about->update(ctx);

m_capture->update(ctx);

showDebugVisualizations(ctx);
Expand Down Expand Up @@ -800,7 +816,7 @@ namespace dxvk {
ImGui::NextColumn();

ImGui::Checkbox("Always Developer Menu", &RtxOptions::Get()->defaultToAdvancedUIObject());

ImGui::EndColumns();

ImGui::Separator();
Expand Down Expand Up @@ -1059,7 +1075,7 @@ namespace dxvk {
if (dlss.supportsDLSS()) {
m_userGraphicsSettingChanged |= getUpscalerCombo(dlss, rayReconstruction).getKey(&RtxOptions::Get()->upscalerTypeObject());
}

ImGui::PushItemWidth(static_cast<float>(subItemWidth));
ImGui::Indent(static_cast<float>(subItemIndent));

Expand All @@ -1078,7 +1094,7 @@ namespace dxvk {


switch (RtxOptions::Get()->upscalerType()) {
case UpscalerType::DLSS:
case UpscalerType::DLSS:
if (RtxOptions::Get()->enableRayReconstruction() == false) {
m_userGraphicsSettingChanged |= ImGui::Combo("DLSS Mode", &RtxOptions::Get()->qualityDLSSObject(), "Ultra Performance\0Performance\0Balanced\0Quality\0Auto\0");

Expand All @@ -1104,29 +1120,29 @@ namespace dxvk {
}
break;
case UpscalerType::NIS: {
m_userGraphicsSettingChanged |= ImGui::Combo("NIS Preset", &RtxOptions::Get()->nisPresetObject(), "Performance\0Balanced\0Quality\0Fullscreen\0");
RtxOptions::Get()->updateUpscalerFromNisPreset();
m_userGraphicsSettingChanged |= ImGui::Combo("NIS Preset", &RtxOptions::Get()->nisPresetObject(), "Performance\0Balanced\0Quality\0Fullscreen\0");
RtxOptions::Get()->updateUpscalerFromNisPreset();

// Display NIS Upscaling Information
// Display NIS Upscaling Information

auto resolutionScale = RtxOptions::Get()->getResolutionScale();
auto resolutionScale = RtxOptions::Get()->getResolutionScale();

ImGui::TextWrapped(str::format("NIS Resolution Scale: ", resolutionScale).c_str());
ImGui::TextWrapped(str::format("NIS Resolution Scale: ", resolutionScale).c_str());

break;
}
break;
}
case UpscalerType::TAAU: {
m_userGraphicsSettingChanged |= ImGui::Combo("TAA-U Preset", &RtxOptions::Get()->taauPresetObject(), "Performance\0Balanced\0Quality\0Fullscreen\0");
RtxOptions::Get()->updateUpscalerFromTaauPreset();
m_userGraphicsSettingChanged |= ImGui::Combo("TAA-U Preset", &RtxOptions::Get()->taauPresetObject(), "Performance\0Balanced\0Quality\0Fullscreen\0");
RtxOptions::Get()->updateUpscalerFromTaauPreset();

// Display TAA-U Upscaling Information
// Display TAA-U Upscaling Information

auto resolutionScale = RtxOptions::Get()->getResolutionScale();
auto resolutionScale = RtxOptions::Get()->getResolutionScale();

ImGui::TextWrapped(str::format("TAA-U Resolution Scale: ", resolutionScale).c_str());
ImGui::TextWrapped(str::format("TAA-U Resolution Scale: ", resolutionScale).c_str());

break;
}
break;
}
}

ImGui::Unindent(static_cast<float>(subItemIndent));
Expand Down Expand Up @@ -1228,7 +1244,7 @@ namespace dxvk {
m_userGraphicsSettingChanged |= denoiserQualityCombo.getKey(&RtxOptions::Get()->denoiseDirectAndIndirectLightingSeparatelyObject());
ImGui::EndDisabled();
}

m_userGraphicsSettingChanged |= textureQualityCombo.getKey(&RtxOptions::Get()->minReplacementTextureMipMapLevelObject());
m_userGraphicsSettingChanged |= indirectLightingParticlesCombo.getKey(&indirectLightParticlesLevel);
ImGui::SetTooltipToLastWidgetOnHover("Controls the quality of particles in indirect (reflection/GI) rays.");
Expand Down Expand Up @@ -1345,7 +1361,7 @@ namespace dxvk {

ImGuiWindowFlags hud_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove;
if (ImGui::Begin("HUD", nullptr, hud_flags)) {

for (auto&& message : hudMessages) {
ImGui::Text(message.c_str());
}
Expand All @@ -1365,7 +1381,7 @@ namespace dxvk {

ImGui::SameLine(200.f);
ImGui::Checkbox("Include G-Buffer", &RtxOptions::Get()->captureDebugImageObject());

{ // Recompile Shaders button and its status message
using namespace std::chrono;
static enum { None, OK, Error } shaderMessage = None;
Expand Down Expand Up @@ -1552,7 +1568,7 @@ namespace dxvk {
str << (isRT ? "Render Target " : "Texture ") << imageInfo.extent.width << 'x' << imageInfo.extent.height << '\n';
str << formatName << '\n';
str << "Hash: " << hashToString(texHash) << '\n';

return str.str();
}

Expand Down Expand Up @@ -1603,8 +1619,8 @@ namespace dxvk {
// don't show popup window and toggle the list directly,
// if was a left mouse click in the splitted lists
bool toggleWithoutPopup = ImGUI::showLegacyTextureGui() &&
g_wasLeftClick &&
!lastOpenCategoryId.empty();
g_wasLeftClick &&
!lastOpenCategoryId.empty();
g_wasLeftClick = false;

if (toggleWithoutPopup) {
Expand Down Expand Up @@ -1644,7 +1660,7 @@ namespace dxvk {
g_openWhenAvailable = false;
}
}

if (ImGui::BeginPopup(POPUP_NAME)) {
const XXH64_hash_t texHash = g_holdingTexture.load();
if (texHash != kEmptyHash) {
Expand Down Expand Up @@ -1733,7 +1749,7 @@ namespace dxvk {

const ImVec2 availableSize = ImGui::GetContentRegionAvail();
const float childWindowHeight = minChildHeight <= 600.0f ? minChildHeight
: availableSize.y < 600 ? 600.0f : availableSize.y;
: availableSize.y < 600 ? 600.0f : availableSize.y;
ImGuiWindowFlags window_flags = ImGuiWindowFlags_None;
ImGui::BeginChild(str::format("Child", uniqueId).c_str(), ImVec2(availableSize.x, childWindowHeight), false, window_flags);

Expand Down Expand Up @@ -1870,14 +1886,14 @@ namespace dxvk {
// popup for texture selection from world / ui
// Only the "active" category is allowed to control the texture popup and highlighting logic
if (!showLegacyTextureGui() || uniqueId == texture_popup::lastOpenCategoryId) {
const bool wasUIClick =
!texture_popup::isOpened() &&
const bool wasUIClick =
!texture_popup::isOpened() &&
clickedOnTextureButton;

const bool wasWorldClick =
isWorldTextureSelectionAllowed() &&
!texture_popup::isOpened() &&
!clickedOnTextureButton &&
!clickedOnTextureButton &&
(ImGui::IsMouseClicked(ImGuiMouseButton_Left) || ImGui::IsMouseClicked(ImGuiMouseButton_Right));

if (wasUIClick) {
Expand Down Expand Up @@ -1942,14 +1958,14 @@ namespace dxvk {
ImGui::PushItemWidth(200);

m_capture->show(ctx);

if(ImGui::CollapsingHeader("Enhancements", collapsingHeaderFlags | ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Indent();
showEnhancementsTab(ctx);
ImGui::Unindent();
}
}

void ImGUI::showEnhancementsTab(const Rc<DxvkContext>& ctx) {
if (!ctx->getCommonObjects()->getSceneManager().areReplacementsLoaded()) {
ImGui::Text("No USD enhancements detected, the following options have been disabled. See documentation for how to use enhancements with Remix.");
Expand Down Expand Up @@ -2210,6 +2226,27 @@ namespace dxvk {
ImGui::SliderFloat("Sky Min Z Threshold", &RtxOptions::Get()->skyMinZThresholdObject(), 0.0f, 1.0f);
skyAutoDetectCombo.getKey(&RtxOptions::Get()->skyAutoDetectObject());

if (ImGui::CollapsingHeader("3D Skybox Settings [Experimental]", collapsingHeaderClosedFlags)) {
ImGui::Checkbox("Enable Shared Depth", &RtxOptions::skySharedDepthObject());
ImGui::Checkbox("Enable 3D Skybox Pathtracing ", &RtxOptions::skyBoxPathTracingObject());

if (RtxOptions::skyBoxPathTracing()) {
ImGui::InputInt("Default Scale", &RtxOptions::Get()->skyDefaultScaleObject(), 1, 1, 1);
SkyScaleCalibrationModeCombo.getKey(&RtxOptions::Get()->skyScaleCalibrationModeObject());
SkyScaleOffsetFormulaCombo.getKey(&RtxOptions::Get()->skyScaleOffsetFormulaObject());

ImGui::Separator();
auto& cameraManager = ctx->getCommonObjects()->getSceneManager().getCameraManager();
auto cam = cameraManager.isCameraValid(CameraType::Sky) ? &cameraManager.getCamera(CameraType::Sky) : nullptr;
if (cam){
ImGui::Text("Sky Offset: %.2f %.2f %.2f", cam->m_skyOffset.x, cam->m_skyOffset.y, cam->m_skyOffset.z);
ImGui::Text("Sky Scale: %i", cam->m_skyScale);
}
ImGui::Separator();
}

};

if (ImGui::CollapsingHeader("Advanced", collapsingHeaderClosedFlags)) {
ImGui::Indent();

Expand Down Expand Up @@ -2261,7 +2298,7 @@ namespace dxvk {
void ImGUI::showVsyncOptions(bool enableDLFGGuard) {
// we should never get here without a swapchain, so we must have latched the vsync value already
assert(RtxOptions::Get()->enableVsync() != EnableVsync::WaitingForImplicitSwapchain);

if (enableDLFGGuard && DxvkDLFG::enable()) {
ImGui::BeginDisabled();
}
Expand All @@ -2275,7 +2312,7 @@ namespace dxvk {
ImGui::TextWrapped("This setting overrides the native game's V-Sync setting.");
ImGui::Unindent();
ImGui::EndDisabled();

if (enableDLFGGuard && DxvkDLFG::enable()) {
ImGui::Indent();
ImGui::TextWrapped("When Frame Generation is active, V-Sync is automatically disabled.");
Expand Down Expand Up @@ -2548,7 +2585,7 @@ namespace dxvk {
ImGui::Separator();

ImGui::Checkbox("Allow Full Screen Exclusive?", &RtxOptions::Get()->allowFSEObject());

ImGui::Unindent();
}

Expand Down Expand Up @@ -2636,7 +2673,7 @@ namespace dxvk {

ImGui::DragFloat("1st bounce: Min Continue Probability", &RtxOptions::Get()->russianRoulette1stBounceMinContinueProbabilityObject(), 0.01f, 0.0f, 1.0f, "%.3f", sliderFlags);
ImGui::DragFloat("1st bounce: Max Continue Probability", &RtxOptions::Get()->russianRoulette1stBounceMaxContinueProbabilityObject(), 0.01f, 0.0f, 1.0f, "%.3f", sliderFlags);

secondPlusRussianRouletteModeCombo.getKey(&RtxOptions::Get()->russianRouletteModeObject());
if (RtxOptions::Get()->russianRouletteMode() == RussianRouletteMode::ThroughputBased)
{
Expand All @@ -2648,18 +2685,18 @@ namespace dxvk {
ImGui::DragFloat("2nd+ bounce: Specular Continue Probability", &RtxOptions::Get()->russianRouletteSpecularContinueProbabilityObject(), 0.01f, 0.0f, 1.0f, "%.3f", sliderFlags);
ImGui::DragFloat("2nd+ bounce: Distance Factor", &RtxOptions::Get()->russianRouletteDistanceFactorObject(), 0.01f, 0.0f, 1.0f, "%.3f", sliderFlags);
}

ImGui::Unindent();
}
ImGui::Unindent();
}

if (RtxOptions::Get()->getIsOpacityMicromapSupported() &&
if (RtxOptions::Get()->getIsOpacityMicromapSupported() &&
ImGui::CollapsingHeader("Opacity Micromap", collapsingHeaderClosedFlags)) {
ImGui::Indent();

ImGui::Checkbox("Enable Opacity Micromap", &RtxOptions::Get()->opacityMicromap.enableObject());

if (common->getOpacityMicromapManager())
common->getOpacityMicromapManager()->showImguiSettings();

Expand Down Expand Up @@ -2912,7 +2949,7 @@ namespace dxvk {
ImGui::Unindent();
}
}

if (useNRD)
{
if (useDoubleDenoisers) {
Expand Down Expand Up @@ -2982,7 +3019,7 @@ namespace dxvk {

if (ImGui::CollapsingHeader("Post FX", collapsingHeaderClosedFlags))
common->metaPostFx().showImguiSettings();

ImGui::Unindent();
}

Expand Down Expand Up @@ -3194,7 +3231,7 @@ namespace dxvk {
ImGuiIO& io = ImGui::GetIO();
ImGui_ImplVulkan_Data* bd = (ImGui_ImplVulkan_Data*)io.BackendRendererUserData;
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;

// Range of characters we want to use the primary font
ImVector<ImWchar> characterRange;
{
Expand Down
17 changes: 15 additions & 2 deletions src/dxvk/rtx_render/rtx_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace dxvk
Unknown, // Unset camera state, used mainly for state tracking. Its camera object is aliased
// with the Main camera object, so on access it retrieves the Main camera

Count
Count
};
}

Expand Down Expand Up @@ -199,6 +199,10 @@ namespace dxvk
uint32_t flags;
};

uint32_t m_skyScale = 1;
uint32_t m_lastSkyScale = 1;
Vector3 m_skyOffset;

// Note: All camera matricies stored as double precision. While this does not do much for some matricies (which were provided
// by the application in floating point precision), it does help for preserving matrix stability on those which have been inverted,
// as well as in code using these matrices which may do further inversions or combination operations. If such precision is not needed
Expand Down Expand Up @@ -330,6 +334,15 @@ namespace dxvk

const RtCameraSetting& getSetting();

void setSkyOffset(const Vector3& skyOffset) {
m_skyOffset = skyOffset;
};

void setSkyScale(int scale) {
m_lastSkyScale = m_skyScale;
m_skyScale = scale;
};

private:
Matrix4d getShakenViewToWorldMatrix(Matrix4d& viewToWorld, uint32_t flags);
Matrix4d updateFreeCamera(uint32_t flags);
Expand Down Expand Up @@ -392,7 +405,7 @@ namespace dxvk
RTX_OPTION_ENV("rtx.cameraSequence", bool, autoLoad, false, "DXVK_CAMERA_SEQUENCE_AUTO_LOAD", "Load camera sequence automatically.");
RTX_OPTION("rtx.cameraSequence", int, currentFrame, 0, "Current Frame.");
RTX_OPTION_ENV("rtx.cameraSequence", Mode, mode, Mode::None, "DXVK_CAMERA_SEQUENCE_MODE", "Current mode.");

std::vector<RtCamera::RtCameraSetting> m_settings;
static RtCameraSequence* s_instance;
};
Expand Down
Loading
Loading