Skip to content

Commit 1aa8380

Browse files
author
Kamil
committed
2 parents 644fc6e + 3fb6f69 commit 1aa8380

File tree

77 files changed

+1839
-1189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1839
-1189
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, 'release/**' ]
66
pull_request:
7-
branches: [ main ]
7+
branches: [ main, 'release/**' ]
88

99
jobs:
1010
build-windows:

RtxOptions.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Tables below enumerate all the options and their defaults set by RTX Remix. Note
117117
|rtx.debugView.composite.compositeViewIdx|int|0|Index of a composite view to show when Composite Debug View is enabled\. The index must be a a valid value from CompositeDebugView enumeration\. Value of 0 disables Composite Debug View\.|
118118
|rtx.debugView.debugViewIdx|int|0|Index of a debug view to show when Debug View is enabled\. The index must be a valid value from DEBUG\_VIEW\_\* macro defined indices\. Value of 0 disables Debug View\.|
119119
|rtx.debugView.displayType|int|0||
120+
|rtx.debugView.enableGammaCorrection|bool|False|Enables gamma correction of a debug view value\.|
120121
|rtx.debugView.enablePseudoColor|bool|False|Enables RGB color coding of a scalar debug view value\.|
121122
|rtx.debugView.evMaxValue|int|4||
122123
|rtx.debugView.evMinValue|int|-4||
@@ -167,7 +168,11 @@ Tables below enumerate all the options and their defaults set by RTX Remix. Note
167168
|rtx.di.stealBoundaryPixelSamplesWhenOutsideOfScreen|bool|True|Steal screen boundary samples when a hit point is outside the screen\.|
168169
|rtx.displacement.displacementFactor|float|1|Scaling factor for all displacement maps|
169170
|rtx.displacement.enableDirectLighting|bool|True|Whether direct lighting accounts for displacement mapping|
171+
|rtx.displacement.enableIndirectHit|bool|False|Whether indirect ray hits account for displacement mapping \(Enabling this is expensive\. Without it, non\-perfect reflections of displaced objects will not show displacement\.\)|
170172
|rtx.displacement.enableIndirectLighting|bool|True|Whether indirect lighting accounts for displacement mapping|
173+
|rtx.displacement.enableNEECache|bool|True|Whether the NEE cache accounts for displacement mapping|
174+
|rtx.displacement.enablePSR|bool|False|Enable PSR \(perfect reflections\) for materials with displacement\. Rays that have been perfectly reflected off a POM surface will not collide correctly with other parts of that same surface\.|
175+
|rtx.displacement.enableReSTIRGI|bool|True|Whether ReSTIR GI accounts for displacement mapping|
171176
|rtx.dlfg.enable|bool|True|Enables DLSS 3\.0 frame generation which generates interpolated frames to increase framerate at the cost of slightly more latency\.|
172177
|rtx.dlssEnhancementDirectLightMaxValue|float|10|The maximum strength of direct lighting enhancement\.|
173178
|rtx.dlssEnhancementDirectLightPower|float|0.7|The overall strength of direct lighting enhancement\.|
@@ -312,6 +317,7 @@ Tables below enumerate all the options and their defaults set by RTX Remix. Note
312317
|rtx.lightConversionEqualityDirectionThreshold|float|0.99|The lower cosine angle threshold between two directions used to determine if two directional lights as the same light when uniquely identifying legacy lights for conversion\.|
313318
|rtx.lightConversionEqualityDistanceThreshold|float|0.05|The upper distance threshold between two positions used to determine if two positional lights as the same light when uniquely identifying legacy lights for conversion\.|
314319
|rtx.lightConversionSphereLightFixedRadius|float|4|The fixed radius in world units to use for legacy lights converted to sphere lights \(currently point and spot lights will convert to sphere lights\)\. Use caution with large light radii as many legacy lights will be placed close to geometry and intersect it, causing suboptimal light sampling performance or other visual artifacts \(lights clipping through walls, etc\)\.|
320+
|rtx.lights.enableDebugMode|bool|False|Enables light debug visualization\.|
315321
|rtx.localtonemap.boostLocalContrast|bool|False|Boosts contrast on local features\.|
316322
|rtx.localtonemap.displayMip|int|0|Bottom mip level of tone map pyramid\.|
317323
|rtx.localtonemap.exposure|float|0.75|Exposure factor applied on average exposure\.|
@@ -535,7 +541,8 @@ Tables below enumerate all the options and their defaults set by RTX Remix. Note
535541
|rtx.stochasticAlphaBlendShareNeighbors|bool|True|Share result with other pixels to accelerate search\.|
536542
|rtx.stochasticAlphaBlendUseNeighborSearch|bool|True|Get radiance from neighbor opaque pixels\.|
537543
|rtx.stochasticAlphaBlendUseRadianceVolume|bool|True|Get radiance from radiance volume\.|
538-
|rtx.subsurface.enableThinOpaque|bool|True|Enable thin opaque material\. The materials with th in opaque properties will fallback to normal opaque material\.|
544+
|rtx.subsurface.enableThinOpaque|bool|True|Enable thin opaque material\. The materials withthin opaque properties will fallback to normal opaque material\.|
545+
|rtx.subsurface.enableTextureMaps|bool|True|Enable texture maps such as thickness map or scattering albedo map\. The corresponding subsurface properties will fallback to per\-material constants if this is disabled\.|
539546
|rtx.subsurface.surfaceThicknessScale|float|1|Scalar of the subsurface thickness\.|
540547
|rtx.taauPreset|int|1|Adjusts TAA\-U scaling factor, trades quality for performance\.|
541548
|rtx.temporalAA.colorClampingFactor|float|1|A scalar factor to apply to the standard deviation of the neighborhood of pixels in the color signal used for clamping\. Should be in the range 0\-infinity\.<br>This value essentially represents how many standard deviations of tolerance from the current frame's colors around each pixel pixel the temporally accumulated color signal may have\.<br>Higher values will cause more ghosting whereas lower values may reduce ghosting but will impact image quality \(less ability to upscale effectively\) and reduce stability \(more jittering\)\.|

documentation/FoliageSystem.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ User Instructions:
1010
b. [Subsurface Measurement Distance]: The thickness of the foliage surface in the range [0, 16]. Incidence radiance is attenuated proportionally to the thickness. The unit is [mm].
1111
c. [Subsurface Single Scattering Albedo]: The coefficient determines how much energy is scattered when trace through subsurface materials.
1212
d. [Subsurface Volumetric Anisotropy]: The anisotropy of the scattering phase function (-1 being backscattering, 0 being isotropic, 1 being forward scattering).
13+
4. Optional: Setup Foliage Texture Maps:
14+
a. [Subsurface Transmittance Color Map]
15+
b. [Subsurface Measurement Distance Map]
16+
c. [Subsurface Single Scattering Albedo Map]
1317

1418
Real-time debug interface:
1519
1. Debugging View: Enable [Is Thin Opaque](../RtxOptions.md) or [rtx.debugView.debugViewIdx = 800] to verify if thin opaque materials are correctly set up.

packman-external.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<package name="rtx-remix-nv_usd" version="5" />
2121
</dependency>
2222
<dependency name="omni_core_materials" linkPath="external/omni_core_materials">
23-
<package name="rtx-remix-omni_core_materials" version="6" />
23+
<package name="rtx-remix-omni_core_materials" version="8" />
2424
</dependency>
2525
<dependency name="reflex" linkPath="external/reflex">
2626
<package name="rtx-remix-reflex" version="1" />
@@ -41,6 +41,6 @@
4141
<package name="ngx_sdk_dlss" version="dlss_0602_2" />
4242
</dependency>
4343
<dependency name="ngx_sdk_dlfg" linkPath="external/ngx_sdk_dlfg">
44-
<package name="ngx_sdk_dlfg" version="dlfg_0602_2" />
44+
<package name="rtx-remix-ngx_sdk_dlfg" version="1" />
4545
</dependency>
4646
</project>

scripts-common/generate_max_mip.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a
4+
# copy of this software and associated documentation files (the "Software"),
5+
# to deal in the Software without restriction, including without limitation
6+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
# and/or sell copies of the Software, and to permit persons to whom the
8+
# Software is furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
# DEALINGS IN THE SOFTWARE.
20+
21+
import numpy as np
22+
from PIL import Image
23+
import os
24+
import math
25+
from pathlib import Path
26+
import argparse
27+
28+
parser = argparse.ArgumentParser(
29+
description="Script to calculate mipmaps using the maximum value instead of the average value.\nOutput will be `<inputTexture>_maxmip.dds`"
30+
)
31+
parser.add_argument('inputTexture', help="A PNG or DDS file to be processed. DDS files will be re-compressed, so it's better to use the original source png.")
32+
parser.add_argument(
33+
'--nvttPath',
34+
help="If Nvtt_export is installed to a non-default location, the path to it can be passed in here.",
35+
default='"C:/Program Files/NVIDIA Corporation/NVIDIA Texture Tools/nvtt_export.exe"'
36+
)
37+
parser.add_argument(
38+
'-o', '--outputTexture',
39+
help="Output dds path. Defaults to inputTexture + `_mipmap.dds`",
40+
default=""
41+
)
42+
args = parser.parse_args()
43+
NVTTPath = args.nvttPath
44+
inputPath = Path(args.inputTexture)
45+
outputDds = args.outputTexture
46+
47+
48+
# adapted from https://stackoverflow.com/questions/14549696/mipmap-of-image-in-numpy
49+
def generate_max_mip_level(image):
50+
rows, cols, channel = image.shape
51+
if rows == 1:
52+
image = image.reshape(rows, cols // 2, 2, channel)
53+
image = image.max(axis=2)
54+
elif cols == 1:
55+
image = image.reshape(rows // 2, 2, cols, channel)
56+
image = image.max(axis=1)
57+
else:
58+
image = image.reshape(rows // 2, 2, cols // 2, 2, channel)
59+
image = image.max(axis=3).max(axis=1)
60+
return image.astype('uint8')
61+
62+
63+
def generate_max_mip(image):
64+
img = image.copy()
65+
rows, cols, channel = image.shape
66+
result = np.zeros((rows, cols * 2 - 1, channel), dtype='uint8')
67+
result[:, :cols, :] = img
68+
col = cols
69+
while rows > 1 or cols > 1:
70+
img = generate_max_mip_level(img)
71+
rows = img.shape[0]
72+
cols = img.shape[1]
73+
result[0:rows, col:col + cols, :] = img
74+
col += cols
75+
return result
76+
77+
78+
inputAsPng = inputPath
79+
if inputPath.suffix == ".dds":
80+
inputAsPng = Path(inputPath).with_suffix(".png")
81+
82+
ddsToPngCommand = f'{NVTTPath} --no-mips -o {inputAsPng} {inputPath}'
83+
print("running: " + ddsToPngCommand)
84+
os.system(ddsToPngCommand)
85+
86+
outputPng = inputPath.with_stem(inputPath.stem + "_maxmip").with_suffix(".png")
87+
88+
if outputDds is None or outputDds == "":
89+
outputDds = inputPath.with_stem(inputPath.stem + "_maxmip").with_suffix(".dds")
90+
91+
img = np.asarray(Image.open(inputAsPng))
92+
print(f"processing texture with dimensions {img.shape}")
93+
Image.fromarray(generate_max_mip(img)).save(outputPng)
94+
rows, cols, channel = img.shape
95+
levels = int(max(math.log2(rows), math.log2(cols)))+1
96+
97+
PngToDdsCommand = f'{NVTTPath} -f bc4 --no-mip-gamma-correct --mip-extract-from-atlas --no-mips --atlas-mips {levels} -o {outputDds} {outputPng}'
98+
print("running: " + PngToDdsCommand)
99+
os.system(PngToDdsCommand)
100+
print(f"generated file {outputDds}")

src/dxvk/imgui/dxvk_imgui.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,7 +2600,7 @@ namespace dxvk {
26002600
ImGui::Checkbox("Enable Volumetric Lighting", &RtxOptions::Get()->enableVolumetricLightingObject());
26012601

26022602
if (RtxOptions::Get()->enableVolumetricLighting()) {
2603-
ImGui::DragFloat3("Transmittance Color", &RtxOptions::Get()->volumetricTransmittanceColorObject(), 0.01f, 0.0f, 1.0f, "%.3f");
2603+
ImGui::DragFloat3("Transmittance Color", &RtxOptions::Get()->volumetricTransmittanceColorObject(), 0.01f, 0.0f, VolumeManager::MaxTransmittanceValue, "%.3f");
26042604
ImGui::DragFloat("Transmittance Measurement Distance", &RtxOptions::Get()->volumetricTransmittanceMeasurementDistanceObject(), 0.25f, 0.0f, FLT_MAX, "%.2f", sliderFlags);
26052605
ImGui::DragFloat3("Single Scattering Albedo", &RtxOptions::Get()->volumetricSingleScatteringAlbedoObject(), 0.01f, 0.0f, 1.0f, "%.3f");
26062606
ImGui::DragFloat("Anisotropy", &RtxOptions::Get()->volumetricAnisotropyObject(), 0.01f, -1.0f, 1.0f, "%.3f", sliderFlags);
@@ -2647,6 +2647,14 @@ namespace dxvk {
26472647

26482648
ImGui::Checkbox("Enable Thin Opaque", &RtxOptions::SubsurfaceScattering::enableThinOpaqueObject());
26492649

2650+
if (RtxOptions::SubsurfaceScattering::enableThinOpaque()) {
2651+
ImGui::Indent();
2652+
2653+
ImGui::Checkbox("Enable Texture Maps", &RtxOptions::SubsurfaceScattering::enableTextureMapsObject());
2654+
2655+
ImGui::Unindent();
2656+
}
2657+
26502658
ImGui::Unindent();
26512659
}
26522660

@@ -2818,14 +2826,16 @@ namespace dxvk {
28182826

28192827
if (ImGui::CollapsingHeader("Displacement [Experimental]", collapsingHeaderClosedFlags)) {
28202828
ImGui::Indent();
2821-
ImGui::TextWrapped("Warning: This is currently implemented using POM with a simple height map, displacing inwards. The implementation may change in the future, which could include changes to the texture format or displacing outwards. We're also aware of several visual quality bugs with the current implementation.");
2829+
ImGui::TextWrapped("Warning: This is currently implemented using POM with a simple height map, displacing inwards. The implementation may change in the future, which could include changes to the texture format or displacing outwards.\nRaymarched POM will use a simple raymarch algorithm, and will show artifacts on thin features and at oblique angles.\nQuadtree POM depends on custom mipmaps with maximums instead of averages, which can be generated using `generate_max_mip.py`.");
2830+
ImGui::Combo("Mode", &RtxOptions::Displacement::modeObject(), "Off\0Raymarched POM\0Quadtree POM\0");
28222831
ImGui::Checkbox("Enable Direct Lighting", &RtxOptions::Displacement::enableDirectLightingObject());
28232832
ImGui::Checkbox("Enable Indirect Lighting", &RtxOptions::Displacement::enableIndirectLightingObject());
28242833
ImGui::Checkbox("Enable Indirect Hit", &RtxOptions::Displacement::enableIndirectHitObject());
28252834
ImGui::Checkbox("Enable NEE Cache", &RtxOptions::Displacement::enableNEECacheObject());
28262835
ImGui::Checkbox("Enable ReSTIR_GI", &RtxOptions::Displacement::enableReSTIRGIObject());
28272836
ImGui::Checkbox("Enable PSR", &RtxOptions::Displacement::enablePSRObject());
28282837
ImGui::DragFloat("Global Displacement Factor", &RtxOptions::Displacement::displacementFactorObject(), 0.01f, 0.0f, 20.0f);
2838+
ImGui::DragInt("Max Iterations", &RtxOptions::Displacement::maxIterationsObject(), 1.f, 1, 256, "%d", sliderFlags);
28292839
ImGui::Unindent();
28302840
}
28312841

src/dxvk/rtx_render/rtx_accel_manager.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ namespace dxvk {
222222
}
223223
}
224224

225+
int AccelManager::getCurrentFramePrimitiveIDPrefixSumBufferID() const {
226+
return m_device->getCurrentFrameId() & 0x1;
227+
}
228+
225229
void AccelManager::createAndBuildIntersectionBlas(Rc<DxvkContext> ctx, DxvkBarrierSet& execBarriers) {
226230
if (m_intersectionBlas.ptr())
227231
return;
@@ -595,6 +599,7 @@ namespace dxvk {
595599

596600
// Build prefix sum array
597601
// Collect primitive count for each surface object
602+
m_reorderedSurfacesPrimitiveIDPrefixSumLastFrame = m_reorderedSurfacesPrimitiveIDPrefixSum;
598603
m_reorderedSurfacesPrimitiveIDPrefixSum.resize(m_reorderedSurfaces.size());
599604
for (uint32_t i = 0; i < m_reorderedSurfaces.size(); i++) {
600605
auto surface = m_reorderedSurfaces[i];
@@ -894,11 +899,20 @@ namespace dxvk {
894899
}
895900

896901
// Create and upload the primitive id prefix sum buffer
897-
info.size = align(m_reorderedSurfacesPrimitiveIDPrefixSum.size() * sizeof(m_reorderedSurfacesPrimitiveIDPrefixSum[0]), kBufferAlignment);
898-
if (m_primitiveIDPrefixSumBuffer == nullptr || info.size > m_primitiveIDPrefixSumBuffer->info().size) {
899-
m_primitiveIDPrefixSumBuffer = m_device->createBuffer(info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, DxvkMemoryStats::Category::RTXAccelerationStructure);
900-
}
901-
ctx->updateBuffer(m_primitiveIDPrefixSumBuffer, 0, m_reorderedSurfacesPrimitiveIDPrefixSum.size() * sizeof(m_reorderedSurfacesPrimitiveIDPrefixSum[0]), m_reorderedSurfacesPrimitiveIDPrefixSum.data());
902+
auto updatePrefixSumBuffer = [&info, this, ctx](std::vector<uint32_t>& prefixSumList, Rc<DxvkBuffer>& prefixSumBuffer) {
903+
info.size = std::max(prefixSumList.size(), 1llu) * sizeof(prefixSumList[0]);
904+
905+
if (prefixSumBuffer == nullptr || info.size > prefixSumBuffer->info().size) {
906+
prefixSumBuffer = m_device->createBuffer(info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, DxvkMemoryStats::Category::RTXAccelerationStructure);
907+
}
908+
909+
if (prefixSumList.size() > 0) {
910+
ctx->updateBuffer(prefixSumBuffer, 0, prefixSumList.size() * sizeof(prefixSumList[0]), prefixSumList.data());
911+
}
912+
};
913+
914+
updatePrefixSumBuffer(m_reorderedSurfacesPrimitiveIDPrefixSum, m_primitiveIDPrefixSumBuffer);
915+
updatePrefixSumBuffer(m_reorderedSurfacesPrimitiveIDPrefixSumLastFrame, m_primitiveIDPrefixSumBufferLastFrame);
902916

903917
// Create and upload the surface mapping buffer
904918
if (!surfaceIndexMapping.empty()) {

src/dxvk/rtx_render/rtx_accel_manager.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ class AccelManager : public CommonDeviceObject {
7878

7979
const Rc<DxvkBuffer> getSurfaceMappingBuffer() const { return m_surfaceMappingBuffer; }
8080

81-
const Rc<DxvkBuffer> getPrimitiveIDPrefixSumBuffer() const { return m_primitiveIDPrefixSumBuffer; }
81+
const Rc<DxvkBuffer> getCurrentFramePrimitiveIDPrefixSumBuffer() const {
82+
return m_primitiveIDPrefixSumBuffer;
83+
}
84+
85+
const Rc<DxvkBuffer> getLastFramePrimitiveIDPrefixSumBuffer() const {
86+
return m_primitiveIDPrefixSumBufferLastFrame;
87+
}
8288

8389
const Rc<DxvkBuffer> getBillboardsBuffer() const { return m_billboardsBuffer; }
8490

@@ -123,6 +129,7 @@ class AccelManager : public CommonDeviceObject {
123129
std::vector<RtInstance*> m_reorderedSurfaces;
124130
std::vector<uint32_t> m_reorderedSurfacesFirstIndexOffset;
125131
std::vector<uint32_t> m_reorderedSurfacesPrimitiveIDPrefixSum;
132+
std::vector<uint32_t> m_reorderedSurfacesPrimitiveIDPrefixSumLastFrame;
126133
std::vector<VkAccelerationStructureInstanceKHR> m_mergedInstances[Tlas::Count];
127134
std::vector<Rc<PooledBlas>> m_blasPool;
128135

@@ -131,6 +138,9 @@ class AccelManager : public CommonDeviceObject {
131138
Rc<DxvkBuffer> m_surfaceMappingBuffer;
132139
Rc<DxvkBuffer> m_transformBuffer;
133140
Rc<DxvkBuffer> m_primitiveIDPrefixSumBuffer;
141+
Rc<DxvkBuffer> m_primitiveIDPrefixSumBufferLastFrame;
142+
143+
int getCurrentFramePrimitiveIDPrefixSumBufferID() const;
134144

135145
Rc<PooledBlas> m_intersectionBlas;
136146
Rc<DxvkBuffer> m_aabbBuffer;

0 commit comments

Comments
 (0)