Skip to content

Commit

Permalink
NRD updated to v4.3.5:
Browse files Browse the repository at this point in the history
- minimal 3rd person camera support
- CMake: infrastructure improvements
- CMake: "_Build" => "_Bin", "_Compiler" => "_Build"
- updated dependencies
  • Loading branch information
dzhdanNV committed Oct 26, 2023
1 parent 47823d4 commit 5942592
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ External/vulkansdk/
External/DXC/

# generated folders
_Bin/
_Build/
_Compiler/
_Data/
_Shaders/
_NRD_SDK/
Expand Down
4 changes: 2 additions & 2 deletions 1-Deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

git submodule update --init --recursive

mkdir "_Compiler"
mkdir "_Build"

cd "_Compiler"
cd "_Build"
cmake .. -A x64
cd ..
4 changes: 2 additions & 2 deletions 1-Deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ chmod +x "2-Build.sh"
chmod +x "3-Prepare NRD SDK.sh"
chmod +x "4-Clean.sh"

mkdir -p "_Compiler"
mkdir -p "_Build"

cd "_Compiler"
cd "_Build"
cmake ..
cd ..
2 changes: 1 addition & 1 deletion 2-Build.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

cd "_Compiler"
cd "_Build"
cmake --build . --config Release -j 4
cmake --build . --config Debug -j 4
cd ..
4 changes: 2 additions & 2 deletions 2-Build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh

mkdir -p "_Compiler"
mkdir -p "_Build"

cd "_Compiler"
cd "_Build"
cmake ..
cmake --build . --config Release -j 4
cmake --build . --config Debug -j 4
Expand Down
24 changes: 12 additions & 12 deletions 3-Prepare NRD SDK.bat
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ mkdir "_NRD_SDK\Shaders\Include"
cd "_NRD_SDK"

copy "..\%NRD_DIR%\Include\*" "Include"
copy "..\_Build\Debug\NRD.dll" "Lib\Debug"
copy "..\_Build\Debug\NRD.lib" "Lib\Debug"
copy "..\_Build\Debug\NRD.pdb" "Lib\Debug"
copy "..\_Build\Release\NRD.dll" "Lib\Release"
copy "..\_Build\Release\NRD.lib" "Lib\Release"
copy "..\_Build\Release\NRD.pdb" "Lib\Release"
copy "..\_Bin\Debug\NRD.dll" "Lib\Debug"
copy "..\_Bin\Debug\NRD.lib" "Lib\Debug"
copy "..\_Bin\Debug\NRD.pdb" "Lib\Debug"
copy "..\_Bin\Release\NRD.dll" "Lib\Release"
copy "..\_Bin\Release\NRD.lib" "Lib\Release"
copy "..\_Bin\Release\NRD.pdb" "Lib\Release"
copy "..\%NRD_DIR%\Shaders\Include\NRD.hlsli" "Shaders\Include"
copy "..\%NRD_DIR%\Shaders\Include\NRDEncoding.hlsli" "Shaders\Include"
copy "..\%NRD_DIR%\LICENSE.txt" "."
Expand Down Expand Up @@ -85,12 +85,12 @@ cd "_NRI_SDK"

copy "..\%NRI_DIR%\Include\*" "Include"
copy "..\%NRI_DIR%\Include\Extensions\*" "Include\Extensions"
copy "..\_Build\Debug\NRI.dll" "Lib\Debug"
copy "..\_Build\Debug\NRI.lib" "Lib\Debug"
copy "..\_Build\Debug\NRI.pdb" "Lib\Debug"
copy "..\_Build\Release\NRI.dll" "Lib\Release"
copy "..\_Build\Release\NRI.lib" "Lib\Release"
copy "..\_Build\Release\NRI.pdb" "Lib\Release"
copy "..\_Bin\Debug\NRI.dll" "Lib\Debug"
copy "..\_Bin\Debug\NRI.lib" "Lib\Debug"
copy "..\_Bin\Debug\NRI.pdb" "Lib\Debug"
copy "..\_Bin\Release\NRI.dll" "Lib\Release"
copy "..\_Bin\Release\NRI.lib" "Lib\Release"
copy "..\_Bin\Release\NRI.pdb" "Lib\Release"
copy "..\%NRI_DIR%\LICENSE.txt" "."

cd ..
Expand Down
8 changes: 4 additions & 4 deletions 3-Prepare NRD SDK.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ mkdir -p "_NRD_SDK/Shaders/Include"
cd "_NRD_SDK"

cp -r ../$NRD_DIR/Include/ "Include"
cp -H ../_Build/Debug/libNRD.so "Lib/Debug"
cp -H ../_Build/Release/libNRD.so "Lib/Release"
cp -H ../_Bin/Debug/libNRD.so "Lib/Debug"
cp -H ../_Bin/Release/libNRD.so "Lib/Release"
cp ../$NRD_DIR/Shaders/Include/NRD.hlsli "Shaders/Include"
cp ../$NRD_DIR/Shaders/Include/NRDEncoding.hlsli "Shaders/Include"
cp ../$NRD_DIR/LICENSE.txt "."
Expand Down Expand Up @@ -50,8 +50,8 @@ then

cp -r ../$NRI_DIR/Include/ "Include"
cp -r ../$NRI_DIR/Include/Extensions/ "Include/Extensions"
cp -H ../_Build/Debug/libNRI.so "Lib/Debug"
cp -H ../_Build/Release/libNRI.so "Lib/Release"
cp -H ../_Bin/Debug/libNRI.so "Lib/Debug"
cp -H ../_Bin/Release/libNRI.so "Lib/Release"
cp ../$NRI_DIR/LICENSE.txt "."

cd ..
Expand Down
4 changes: 2 additions & 2 deletions 3-Run NRD sample.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@echo off

set DIR_BIN=%cd%\_Build\Release
set DIR_BIN=%cd%\_Bin\Release

if not exist "%DIR_BIN%" (
set DIR_BIN=%cd%\_Build\Debug
set DIR_BIN=%cd%\_Bin\Debug
)

if not exist "%DIR_BIN%" (
Expand Down
2 changes: 1 addition & 1 deletion 4-Clean.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

if exist "build" rd /q /s "build"

if exist "_Bin" rd /q /s "_Bin"
if exist "_Build" rd /q /s "_Build"
if exist "_Compiler" rd /q /s "_Compiler"
if exist "_Data" rd /q /s "_Data"
if exist "_Shaders" rd /q /s "_Shaders"
if exist "_NRD_SDK" rd /q /s "_NRD_SDK"
Expand Down
2 changes: 1 addition & 1 deletion 4-Clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

rm -rf "build"

rm -rf "_Bin"
rm -rf "_Build"
rm -rf "_Compiler"
rm -rf "_Data"
rm -rf "_Shaders"
rm -rf "_NRD_SDK"
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set (SHADER_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/_Shaders")

# Cached
set (DXC_CUSTOM_PATH "custom/path/to/dxc" CACHE STRING "This DXC will be used if Vulkan SDK is not installed")
set (GLOBAL_BIN_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/_Build" CACHE STRING "")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/_Bin" CACHE STRING "")
set (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "")

# Create project
Expand Down Expand Up @@ -118,7 +118,6 @@ if (UNIX)
target_link_libraries (${PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS} pthread X11)
endif ()

set_target_properties (${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${GLOBAL_BIN_OUTPUT_PATH}/$<CONFIG>")
set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER "Sample")
set_property (TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
set_property (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
Expand Down
2 changes: 1 addition & 1 deletion External/NRIFramework
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ This approach simplifies and accelerates ray tracing, but adds difficulties to B

- Run `3-Run NRD sample` script and answer the cmdline questions to set the runtime parameters
- If [Smart Command Line Arguments extension for Visual Studio](https://marketplace.visualstudio.com/items?itemName=MBulli.SmartCommandlineArguments) is installed, all command line arguments will be loaded into corresponding window
- The executables can be found in `_Build`. The executable loads resources from `_Data`, therefore please run the samples with working directory set to the project root folder (needed pieces of the command line can be found in `3-Run NRD sample` script)
- The executables can be found in `_Bin`. The executable loads resources from `_Data`, therefore please run the samples with working directory set to the project root folder (needed pieces of the command line can be found in `3-Run NRD sample` script)

### REQUIREMENTS

Expand Down
24 changes: 13 additions & 11 deletions Source/NRDSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ constexpr auto TLAS_BUILD_BITS = nri::AccelerationStructure
constexpr float ACCUMULATION_TIME = 0.5f; // seconds
constexpr float NEAR_Z = 0.001f; // m
constexpr float GLASS_THICKNESS = 0.002f; // m
constexpr float CAMERA_BACKWARD_OFFSET = 0.0f; // m, 3rd person camera offset
constexpr bool CAMERA_RELATIVE = true;
constexpr bool ALLOW_BLAS_MERGING = true;
constexpr bool NRD_ALLOW_DESCRIPTOR_CACHING = true;
Expand Down Expand Up @@ -501,7 +502,7 @@ class Sample : public SampleBase
{
public:
Sample() :
m_NRD(BUFFERED_FRAME_MAX_NUM, "NRD")
m_NRD(BUFFERED_FRAME_MAX_NUM, NRD_ALLOW_DESCRIPTOR_CACHING, "NRD")
{}

~Sample();
Expand Down Expand Up @@ -1685,11 +1686,11 @@ void Sample::PrepareFrame(uint32_t frameIndex)
int result = 0;
#ifdef _WIN32 // TODO: can be made Linux friendly too
#ifdef _DEBUG
std::string sampleShaders = "_Build\\Debug\\ShaderMake.exe";
std::string nrdShaders = "_Build\\Debug\\ShaderMake.exe";
std::string sampleShaders = "_Bin\\Debug\\ShaderMake.exe";
std::string nrdShaders = "_Bin\\Debug\\ShaderMake.exe";
#else
std::string sampleShaders = "_Build\\Release\\ShaderMake.exe";
std::string nrdShaders = "_Build\\Release\\ShaderMake.exe";
std::string sampleShaders = "_Bin\\Release\\ShaderMake.exe";
std::string nrdShaders = "_Bin\\Release\\ShaderMake.exe";
#endif

sampleShaders +=
Expand Down Expand Up @@ -1962,6 +1963,7 @@ void Sample::PrepareFrame(uint32_t frameIndex)
desc.isPositiveZ = m_PositiveZ;
desc.isReversedZ = m_ReversedZ;
desc.orthoRange = m_Settings.ortho ? Tan( DegToRad( m_Settings.camFov ) * 0.5f ) * 3.0f * m_Settings.meterToUnitsMultiplier : 0.0f;
desc.backwardOffset = CAMERA_BACKWARD_OFFSET;
GetCameraDescFromInputDevices(desc);

const float animationSpeed = m_Settings.pauseAnimation ? 0.0f : (m_Settings.animationSpeed < 0.0f ? 1.0f / (1.0f + Abs(m_Settings.animationSpeed)) : (1.0f + m_Settings.animationSpeed));
Expand Down Expand Up @@ -4058,7 +4060,7 @@ void Sample::UpdateConstantBuffer(uint32_t frameIndex, uint32_t maxAccumulatedFr
data->gCameraFrustum = frustum;
data->gSunDirection_gExposure = sunDirection;
data->gSunDirection_gExposure.w = m_Settings.exposure;
data->gCameraOrigin_gMipBias = m_Camera.state.position;
data->gCameraOrigin_gMipBias = m_Camera.state.position + m_Camera.state.mViewToWorld.GetCol3().xmm;
data->gCameraOrigin_gMipBias.w = baseMipBias + log2f(renderSize.x / outputSize.x);
data->gViewDirection_gOrthoMode = float4(viewDir.x, viewDir.y, viewDir.z, orthoMode);
data->gHairBaseColorOverride = m_HairBaseColorOverride;
Expand Down Expand Up @@ -4258,7 +4260,7 @@ void Sample::RenderFrame(uint32_t frameIndex)
commonSettings.isBaseColorMetalnessAvailable = true;
commonSettings.enableValidation = m_DebugNRD && m_ShowValidationOverlay;

m_NRD.NewFrame(frameIndex);
m_NRD.NewFrame();
m_NRD.SetCommonSettings(commonSettings);

// NRD user pool
Expand Down Expand Up @@ -4558,7 +4560,7 @@ void Sample::RenderFrame(uint32_t frameIndex)
nrd::Identifier denoiser = NRD_ID(SIGMA_SHADOW_TRANSLUCENCY);

m_NRD.SetDenoiserSettings(denoiser, &shadowSettings);
m_NRD.Denoise(&denoiser, 1, commandBuffer, userPool, NRD_ALLOW_DESCRIPTOR_CACHING);
m_NRD.Denoise(&denoiser, 1, commandBuffer, userPool);

//RestoreBindings(commandBuffer, frame); // Bindings will be restored in the next section
}
Expand Down Expand Up @@ -4620,7 +4622,7 @@ void Sample::RenderFrame(uint32_t frameIndex)
for (uint32_t i = 0; i < helper::GetCountOf(denoisers); i++)
m_NRD.SetDenoiserSettings(denoisers[i], &settings);

m_NRD.Denoise(denoisers, helper::GetCountOf(denoisers), commandBuffer, userPool, NRD_ALLOW_DESCRIPTOR_CACHING);
m_NRD.Denoise(denoisers, helper::GetCountOf(denoisers), commandBuffer, userPool);
}
else if (m_Settings.denoiser == DENOISER_RELAX)
{
Expand Down Expand Up @@ -4712,7 +4714,7 @@ void Sample::RenderFrame(uint32_t frameIndex)
m_NRD.SetDenoiserSettings(denoisers[1], &specularSettings);
#endif

m_NRD.Denoise(denoisers, helper::GetCountOf(denoisers), commandBuffer, userPool, NRD_ALLOW_DESCRIPTOR_CACHING);
m_NRD.Denoise(denoisers, helper::GetCountOf(denoisers), commandBuffer, userPool);
}

RestoreBindings(commandBuffer, frame);
Expand Down Expand Up @@ -4785,7 +4787,7 @@ void Sample::RenderFrame(uint32_t frameIndex)

m_NRD.SetCommonSettings(commonSettings);
m_NRD.SetDenoiserSettings(denoiser, &m_ReferenceSettings);
m_NRD.Denoise(&denoiser, 1, commandBuffer, userPool, NRD_ALLOW_DESCRIPTOR_CACHING);
m_NRD.Denoise(&denoiser, 1, commandBuffer, userPool);

RestoreBindings(commandBuffer, frame);
}
Expand Down

0 comments on commit 5942592

Please sign in to comment.