Skip to content

Commit 4dc7ba8

Browse files
authored
Merge pull request #299 from Devsh-Graphics-Programming/erfan_cubemap_render
Merge Erfan work
2 parents 185ca5c + 2ba38fe commit 4dc7ba8

File tree

11 files changed

+351
-168
lines changed

11 files changed

+351
-168
lines changed

examples_tests/22.RaytracedAO/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ You can switch between those sensors using `PAGE UP/DOWN` Keys defined in more d
5656
| bloomIntensity | Denoiser Bloom Intensity | float | 0.1 |
5757
| bloomFilePath | Lens Flare File Path | string | "../../media/kernels/physical_flare_512.exr" |
5858
| tonemapper | Tonemapper Settings for Denoiser | string | "ACES=0.4,0.8" |
59+
| highQualityEdges | Number in pixels (prevously was bool) to add to borders for more accurate denoising | integer| 0 |
5960

6061
### Example of a sensor using all new properties described above.
6162
```xml

examples_tests/22.RaytracedAO/Renderer.cpp

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ void Renderer::resetSampleAndFrameCounters()
14851485
m_prevCamTform = nbl::core::matrix4x3();
14861486
}
14871487

1488-
void Renderer::takeAndSaveScreenShot(const std::filesystem::path& screenshotFilePath, const DenoiserArgs& denoiserArgs)
1488+
void Renderer::takeAndSaveScreenShot(const std::filesystem::path& screenshotFilePath, bool denoise, const DenoiserArgs& denoiserArgs)
14891489
{
14901490
auto commandQueue = m_rrManager->getCLCommandQueue();
14911491
ocl::COpenCLHandler::ocl.pclFinish(commandQueue);
@@ -1500,35 +1500,39 @@ void Renderer::takeAndSaveScreenShot(const std::filesystem::path& screenshotFile
15001500
filename_wo_ext.replace_extension();
15011501
if (m_tonemapOutput)
15021502
ext::ScreenShot::createScreenShot(m_driver,m_assetManager,m_tonemapOutput.get(),filename_wo_ext.string()+".exr",format);
1503-
if (m_albedoRslv)
1504-
ext::ScreenShot::createScreenShot(m_driver,m_assetManager,m_albedoRslv.get(),filename_wo_ext.string()+"_albedo.exr",format);
1505-
if (m_normalRslv)
1506-
ext::ScreenShot::createScreenShot(m_driver,m_assetManager,m_normalRslv.get(),filename_wo_ext.string()+"_normal.exr",format);
1507-
1508-
const std::string defaultBloomFile = "../../media/kernels/physical_flare_512.exr";
1509-
const std::string defaultTonemapperArgs = "ACES=0.4,0.8";
1510-
constexpr auto defaultBloomScale = 0.1f;
1511-
constexpr auto defaultBloomIntensity = 0.1f;
1512-
auto bloomFilePathStr = (denoiserArgs.bloomFilePath.string().empty()) ? defaultBloomFile : denoiserArgs.bloomFilePath.string();
1513-
auto bloomScale = (denoiserArgs.bloomScale == 0.0f) ? defaultBloomScale : denoiserArgs.bloomScale;
1514-
auto bloomIntensity = (denoiserArgs.bloomIntensity == 0.0f) ? defaultBloomIntensity : denoiserArgs.bloomIntensity;
1515-
auto tonemapperArgs = (denoiserArgs.tonemapperArgs.empty()) ? defaultTonemapperArgs : denoiserArgs.tonemapperArgs;
1516-
1517-
std::ostringstream denoiserCmd;
1518-
// 1.ColorFile 2.AlbedoFile 3.NormalFile 4.BloomPsfFilePath(STRING) 5.BloomScale(FLOAT) 6.BloomIntensity(FLOAT) 7.TonemapperArgs(STRING)
1519-
denoiserCmd << "call ../denoiser_hook.bat";
1520-
denoiserCmd << " " << filename_wo_ext.string() << ".exr";
1521-
denoiserCmd << " " << filename_wo_ext.string() << "_albedo.exr";
1522-
denoiserCmd << " " << filename_wo_ext.string() << "_normal.exr";
1523-
denoiserCmd << " " << bloomFilePathStr;
1524-
denoiserCmd << " " << bloomScale;
1525-
denoiserCmd << " " << bloomIntensity;
1526-
denoiserCmd << " " << "\"" << tonemapperArgs << "\"";
1527-
// NOTE/TODO/FIXME : Do as I say, not as I do
1528-
// https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152177
1529-
std::cout << "\n---[DENOISER_BEGIN]---" << std::endl;
1530-
std::system(denoiserCmd.str().c_str());
1531-
std::cout << "\n---[DENOISER_END]---" << std::endl;
1503+
1504+
if(denoise)
1505+
{
1506+
if (m_albedoRslv)
1507+
ext::ScreenShot::createScreenShot(m_driver,m_assetManager,m_albedoRslv.get(),filename_wo_ext.string()+"_albedo.exr",format);
1508+
if (m_normalRslv)
1509+
ext::ScreenShot::createScreenShot(m_driver,m_assetManager,m_normalRslv.get(),filename_wo_ext.string()+"_normal.exr",format);
1510+
1511+
const std::string defaultBloomFile = "../../media/kernels/physical_flare_512.exr";
1512+
const std::string defaultTonemapperArgs = "ACES=0.4,0.8";
1513+
constexpr auto defaultBloomScale = 0.1f;
1514+
constexpr auto defaultBloomIntensity = 0.1f;
1515+
auto bloomFilePathStr = (denoiserArgs.bloomFilePath.string().empty()) ? defaultBloomFile : denoiserArgs.bloomFilePath.string();
1516+
auto bloomScale = (denoiserArgs.bloomScale == 0.0f) ? defaultBloomScale : denoiserArgs.bloomScale;
1517+
auto bloomIntensity = (denoiserArgs.bloomIntensity == 0.0f) ? defaultBloomIntensity : denoiserArgs.bloomIntensity;
1518+
auto tonemapperArgs = (denoiserArgs.tonemapperArgs.empty()) ? defaultTonemapperArgs : denoiserArgs.tonemapperArgs;
1519+
1520+
std::ostringstream denoiserCmd;
1521+
// 1.ColorFile 2.AlbedoFile 3.NormalFile 4.BloomPsfFilePath(STRING) 5.BloomScale(FLOAT) 6.BloomIntensity(FLOAT) 7.TonemapperArgs(STRING)
1522+
denoiserCmd << "call ../denoiser_hook.bat";
1523+
denoiserCmd << " \"" << filename_wo_ext.string() << ".exr" << "\"";
1524+
denoiserCmd << " \"" << filename_wo_ext.string() << "_albedo.exr" << "\"";
1525+
denoiserCmd << " \"" << filename_wo_ext.string() << "_normal.exr" << "\"";
1526+
denoiserCmd << " \"" << bloomFilePathStr << "\"";
1527+
denoiserCmd << " " << bloomScale;
1528+
denoiserCmd << " " << bloomIntensity;
1529+
denoiserCmd << " " << "\"" << tonemapperArgs << "\"";
1530+
// NOTE/TODO/FIXME : Do as I say, not as I do
1531+
// https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152177
1532+
std::cout << "\n---[DENOISER_BEGIN]---" << std::endl;
1533+
std::system(denoiserCmd.str().c_str());
1534+
std::cout << "\n---[DENOISER_END]---" << std::endl;
1535+
}
15321536
}
15331537

15341538
// one day it will just work like that

examples_tests/22.RaytracedAO/Renderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
5050

5151
void resetSampleAndFrameCounters();
5252

53-
void takeAndSaveScreenShot(const std::filesystem::path& screenshotFilePath, const DenoiserArgs& denoiserArgs);
53+
void takeAndSaveScreenShot(const std::filesystem::path& screenshotFilePath, bool denoise = false, const DenoiserArgs& denoiserArgs = {});
5454

5555
bool render(nbl::ITimer* timer, const bool beauty=true);
5656

examples_tests/22.RaytracedAO/denoiser_hook.bat

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,28 @@ if NOT EXIST %denoiser_dir%/denoisertonemapper.exe (
1111
REM 1.ColorFile 2.AlbedoFile 3.NormalFile 4.BloomPsfFilePath(STRING) 5.BloomScale(FLOAT) 6.BloomIntensity(FLOAT) 7.TonemapperArgs(STRING)
1212
call :denoise %1 %2 %3 %4 %5 %6 %7
1313

14+
1415
EXIT /B %ERRORLEVEL%
1516

1617
:denoise
17-
if NOT EXIST %~dpn1.exr (
18-
echo BatchScriptError: Denoiser input file doesn't exist. ^(at %~dpn1.exr^)
18+
19+
set color_file="%~dpn1.exr"
20+
set albedo_file="%~dpn2.exr"
21+
set normal_file="%~dpn3.exr"
22+
set output_file="%~dpn1_denoised.exr"
23+
24+
if NOT EXIST %color_file% (
25+
echo BatchScriptError: Denoiser input file doesn't exist. ^(at %color_file%^)
1926
EXIT /B 0
2027
)
21-
if NOT EXIST %~dpn2.exr (
22-
echo BatchScriptError: Denoiser input file doesn't exist. ^(at %~dpn2.exr^)
28+
if NOT EXIST %albedo_file% (
29+
echo BatchScriptError: Denoiser input file doesn't exist. ^(at %albedo_file%^)
2330
EXIT /B 0
2431
)
25-
if NOT EXIST %~dpn3.exr (
26-
echo BatchScriptError: Denoiser input file doesn't exist. ^(at %~dpn3.exr^)
32+
if NOT EXIST %normal_file% (
33+
echo BatchScriptError: Denoiser input file doesn't exist. ^(at %normal_file%^)
2734
EXIT /B 0
2835
)
29-
set color_file=%~dpn1.exr
30-
set albedo_file=%~dpn2.exr
31-
set normal_file=%~dpn3.exr
32-
set output_file=%~dpn1_denoised.exr
3336
set bloom_file=%~f4
3437
set bloom_scale=%~5
3538
set bloom_intensity=%~6

0 commit comments

Comments
 (0)