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

Arnold Denoiser #53

Merged
merged 32 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
31ae294
add StartsWith and EndsWith to CStringUtilities
JenusL Nov 6, 2018
162dcc2
add render options for optix denoiser
JenusL Nov 10, 2018
f02b920
add comment on progressive
JenusL Nov 10, 2018
440affb
add optix denoiser on main
JenusL Nov 10, 2018
eca6968
move progress bar logic
JenusL Nov 10, 2018
342d2a1
cleanup optix denoiser file output logic
JenusL Nov 10, 2018
d7c526c
Merge remote-tracking branch 'origin/feat/optix_display' into develop
JenusL Dec 7, 2018
1d7b957
error message if optix driver can't be created
JenusL Dec 9, 2018
588f9e2
Merge branch 'feat/optix_display' into feat/noice
JenusL Dec 9, 2018
13ab967
add output_denoising_aovs settings
JenusL Dec 15, 2018
29c0569
add button to open denoiser
JenusL Dec 18, 2018
e60398b
exporter for denoising aovs like maxtoa
JenusL Dec 18, 2018
6c4a481
arnold denoiser ui
JenusL Dec 18, 2018
e4a98e7
arnold denoiser ppg enhancements
JenusL Jan 3, 2019
412ad5e
fix bug in last commit
JenusL Jan 4, 2019
ff58ae9
improved denoiser ppg logic and robustness
JenusL Jan 4, 2019
6b470b9
rewrite of denoising aovs output
JenusL Jan 4, 2019
a9c27ee
support softimage sequences with no padding
JenusL Jan 7, 2019
6b4e85c
use default padding from scene render options
JenusL Jan 7, 2019
bb7af79
various padding fixes
JenusL Jan 7, 2019
f4f812f
more padding fixes
JenusL Jan 7, 2019
2c61581
set rename message to severity info
JenusL Jan 8, 2019
c6582a9
little bit of cleanup
JenusL Jan 8, 2019
adbbf7e
check if input file exist
JenusL Jan 8, 2019
ba5c489
check that end > start
JenusL Jan 8, 2019
474e51c
add output suffix
JenusL Jan 8, 2019
23950e7
fix for finding start frame in square sequences
JenusL Jan 8, 2019
4dc7cc9
add linktab support
JenusL Jan 9, 2019
9bcadf8
make denoiser use sitoa loglevel settings
JenusL Jan 23, 2019
cc32d4b
add AddDenoiserProperties command
JenusL Jan 23, 2019
d2e8098
small fix and cleanup
JenusL Jan 23, 2019
bfc3e76
add to same pass as arnold render options if they are local
JenusL Jan 23, 2019
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
470 changes: 470 additions & 0 deletions plugins/helpers/ArnoldDenoiser.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugins/helpers/ArnoldMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ function AddPropertiesSubMenu(in_menu)
in_menu.AddCommandItem("Texture Options", "AddTextureOptionsProperties");
in_menu.AddCommandItem("Camera Options", "AddCameraOptionsProperties");
in_menu.AddCommandItem("Sidedness", "AddSidednessProperties");
in_menu.AddCommandItem("Denoiser", "AddDenoiserProperties");
}


Expand Down
33 changes: 33 additions & 0 deletions plugins/helpers/ArnoldProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function XSILoadPlugin(in_reg)
in_reg.RegisterCommand("AddTextureOptionsProperties", "SITOA_AddTextureOptionsProperties");
in_reg.RegisterCommand("AddCameraOptionsProperties", "SITOA_AddCameraOptionsProperties");
in_reg.RegisterCommand("AddVolumeProperties", "SITOA_AddVolumeProperties");
in_reg.RegisterCommand("AddDenoiserProperties", "SITOA_AddDenoiserProperties");

in_reg.RegisterProperty("arnold_visibility");
in_reg.RegisterProperty("arnold_matte");
Expand Down Expand Up @@ -92,6 +93,9 @@ function CommonAddProperties(in_collection, in_type, in_inspect)
if (prop != null)
volume_collection.Add(in_collection.item(i))
break;
case "Denoiser":
prop = AddDenoiserProperty(in_collection.item(i));
break;
default:
break;
}
Expand Down Expand Up @@ -224,6 +228,16 @@ function AddVolumeProperties_Execute(in_collection, in_inspect)
return CommonAddProperties(in_collection, "Volume", in_inspect);
}

function AddDenoiserProperties_Init(in_ctxt)
{
return CommonAddArguments(in_ctxt);
}

function AddDenoiserProperties_Execute(in_collection, in_inspect)
{
return CommonAddProperties(in_collection, "Denoiser", in_inspect);
}

/////////////////////////////////
// PROPERTY ADDERS
/////////////////////////////////
Expand Down Expand Up @@ -414,6 +428,25 @@ function AddVolumeProperty(in_xsiObj)
return prop;
}


function AddDenoiserProperty(in_xsiObj)
{
var prop = null;
// is in_xsiObj capable of hosting properties ?
var classOk = in_xsiObj.IsClassOf(siSceneItemID);

var type = in_xsiObj.type;
if (classOk && (type == "Pass"))
{
if (!CommonHasProperty(in_xsiObj, "arnold_denoiser"))
prop = in_xsiObj.AddProperty("arnold_denoiser", false, "Arnold Denoiser");
}
else
logmessage("[sitoa] Cannot add Denoiser property to " + in_xsiObj.FullName + ". It can only be assigned to Passes", siErrorMsg);

return prop;
}

/////////////////////////////////
/////////////////////////////////
/////////////////////////////////
Expand Down
27 changes: 27 additions & 0 deletions plugins/sitoa/common/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,33 @@ CString CStringUtilities::GetMasterBaseNodeName(CString &in_name)
return splits[count-1];
}


// Return true or false if string starts with substring
//
// @param in_string The input string
// @param in_subString The start string
//
// @return true or false
//
bool CStringUtilities::StartsWith(CString in_string, CString in_subString)
{
return (in_string.FindString(in_subString) == 0);
}


// Return true or false if string ends with substring
//
// @param in_string The input string
// @param in_subString The end string
//
// @return true or false
//
bool CStringUtilities::EndsWith(CString in_string, CString in_subString)
{
return (in_string.ReverseFindString(in_subString) == (in_string.Length() - in_subString.Length()));
}


////////////////////////////////////////////////////
////////////////////////////////////////////////////
////////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions plugins/sitoa/common/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ class CStringUtilities
CString GetSoftimageNameFromSItoAName(CString &in_nane);
// Return the name of the master node of a ginstance or a cloned light
CString GetMasterBaseNodeName(CString &in_name);
// Checks if string starts with substring
bool StartsWith(CString in_string, CString in_subString);
// Checks if string ends with substring
bool EndsWith(CString in_string, CString in_subString);

private:
// Build the name for an Arnold node (overload for a CString input type)
Expand Down
111 changes: 107 additions & 4 deletions plugins/sitoa/loader/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,20 @@ bool LoadFilters()

CNodeUtilities().SetName(closestFilterNode, "sitoa_closest_filter");

// if we're outputting denoising aovs we need a variance filter
// https://github.com/Autodesk/sitoa/issues/34
if (GetRenderOptions()->m_output_denoising_aovs && !(filterType.IsEqualNoCase(L"variance") || filterType.IsEqualNoCase(L"contour")))
{
// create a variance filter
AtNode* varianceFilterNode = AiNode("variance_filter");
if (!varianceFilterNode)
return false;
CNodeUtilities().SetName(varianceFilterNode, "sitoa_variance_filter");
CNodeSetter::SetFloat(varianceFilterNode, "width", GetRenderOptions()->m_output_filter_width); // width of output_filter
CNodeSetter::SetBoolean(varianceFilterNode, "scalar_mode", false);
CNodeSetter::SetString(varianceFilterNode, "filter_weights", filterType.GetAsciiString()); // type of output_filter
}

// optix denoise filters are added in the LoadDrivers() function because they have to be unique for each AOV

return true;
Expand Down Expand Up @@ -343,6 +357,7 @@ bool LoadDrivers(AtNode *in_optionsNode, Pass &in_pass, double in_frame, bool in
{
Framebuffer frameBuffer(in_pass.GetFramebuffers().GetItem(L"Main"));
CString mainFormat(ParAcc_GetValue(frameBuffer, L"Format", in_frame));
CFrameBuffer mainFb(frameBuffer, in_frame, false);

CRefArray frameBuffers = in_pass.GetFramebuffers();
LONG nbBuffers = frameBuffers.GetCount();
Expand All @@ -365,6 +380,13 @@ bool LoadDrivers(AtNode *in_optionsNode, Pass &in_pass, double in_frame, bool in
// vector of the drivers, each with theirs layers
vector <CDeepExrLayersDrivers> deepExrLayersDrivers;

// vars to hold if and how to create AOVs for noice
// it's a string because it can be added in two ways.
// recognised values are "add", "add_rename" and "exist"
CString noiceDA = L"add";
CString noiceN = L"add";
CString noiceZ = L"add";

unsigned int activeBuffer = 0;
for (LONG i = 0; i<nbBuffers; i++)
{
Expand Down Expand Up @@ -490,25 +512,106 @@ bool LoadDrivers(AtNode *in_optionsNode, Pass &in_pass, double in_frame, bool in
}

// if layerName ends with "_denoise", we add a denoise filter named after the layer and then add the output
if (thisFb.m_layerName.ReverseFindString(L"_denoise") == (thisFb.m_layerName.Length() - CString(L"_denoise").Length()))
if (CStringUtilities().EndsWith(thisFb.m_layerName, L"_denoise"))
{
// OptiX denoise needs a separete filter for each AOV, so we create them here instad of in LoadFilters()
CString optixFilterName = L"sitoa_" + thisFb.m_layerName + L"_optix_filter";
AtNode* optixFilterNode = AiNode("denoise_optix_filter");
if (!optixFilterNode)
{
GetMessageQueue()->LogMsg(L"[sitoa] Couldn't create denoise_optix_filter for layer " + thisFb.m_layerName, siErrorMsg);
continue;
CNodeUtilities().SetName(optixFilterNode, CString(L"sitoa_" + thisFb.m_layerName + L"_optix_filter").GetAsciiString());
AiArraySetStr(outputs, activeBuffer, CString(thisFb.m_layerName + L" " + thisFb.m_layerDataType + L" sitoa_" + thisFb.m_layerName + L"_optix_filter " + masterFb.m_fullName).GetAsciiString());
}
CNodeUtilities().SetName(optixFilterNode, optixFilterName.GetAsciiString());
AiArraySetStr(outputs, activeBuffer, CString(thisFb.m_layerName + L" " + thisFb.m_layerDataType + L" " + optixFilterName + L" " + masterFb.m_fullName).GetAsciiString());
}
// Adding to outputs. masterFb differs from thisFb if they are both exr and share the same filename
else if (thisFb.m_layerDataType.IsEqualNoCase(L"RGB") || thisFb.m_layerDataType.IsEqualNoCase(L"RGBA"))
AiArraySetStr(outputs, activeBuffer, CString(thisFb.m_layerName + L" " + thisFb.m_layerDataType + L" " + colorFilter + " " + masterFb.m_fullName).GetAsciiString());
else
AiArraySetStr(outputs, activeBuffer, CString(thisFb.m_layerName + L" " + thisFb.m_layerDataType + L" " + numericFilter + " " + masterFb.m_fullName).GetAsciiString());

// Do checks if Arnold Denoising AOVs already exist and if they have the right filter if they do
if (masterFb.m_fullName == mainFb.m_fullName) // only check if it's a layer in the same exr as main (multilayer-exr)
{
if (thisFb.m_layerName == L"diffuse_albedo")
noiceDA = L"exist";

if (thisFb.m_layerName == L"N")
{
if (numericFilter == colorFilter)
noiceN = L"exist";
else
noiceN = L"add_rename";
}

if (thisFb.m_layerName == L"Z")
{
if (numericFilter == colorFilter)
noiceZ = L"exist";
else
noiceZ = L"add_rename";
}
}

activeBuffer++;
}

// Setting outpus array only if there is at least one active framebuffer
// Setup the AOVs for Arnold Denoising (noice)
// https://github.com/Autodesk/sitoa/issues/34
if (GetRenderOptions()->m_output_denoising_aovs)
{
if (mainFb.m_driverName.IsEqualNoCase(L"driver_exr"))
{
// pre-calc number of additional framebuffers to add and resize output array
int nbNoiceBuffers = 4;
if (noiceDA == L"exist")
nbNoiceBuffers -= 1;
if (noiceN == L"exist")
nbNoiceBuffers -= 1;
if (noiceZ == L"exist")
nbNoiceBuffers -= 1;
AiArrayResize(outputs, activeBuffers + nbNoiceBuffers, 1);

// Set the name and issue a warning if it's renamed
CString nameN = L"";
CString nameZ = L"";
if (noiceN == L"add_rename")
{
nameN = L" N_noice";
GetMessageQueue()->LogMsg(L"[sitoa] Arnold Denoising AOV \"N\" has been renamed to \"N_noice\" because \"N\" already exist with \"closest_filter\".", siInfoMsg);
}
if (noiceZ == L"add_rename")
{
nameZ = L" Z_noice";
GetMessageQueue()->LogMsg(L"[sitoa] Arnold Denoising AOV \"Z\" has been renamed to \"Z_noice\" because \"Z\" already exist with \"closest_filter\".", siInfoMsg);
}

// add the denoising aovs
int i = 0;
if (noiceDA != L"exist")
{
AiArraySetStr(outputs, activeBuffers+i, CString(L"diffuse_albedo RGB " + colorFilter + L" " + mainFb.m_fullName).GetAsciiString());
i++;
}
if (noiceN != L"exist")
{
AiArraySetStr(outputs, activeBuffers+i, CString(L"N VECTOR " + colorFilter + L" " + mainFb.m_fullName + nameN).GetAsciiString());
i++;
}
if (noiceZ != L"exist")
{
AiArraySetStr(outputs, activeBuffers+i, CString(L"Z FLOAT " + colorFilter + L" " + mainFb.m_fullName + nameZ).GetAsciiString());
i++;
}

AiArraySetStr(outputs, activeBuffers+i, CString(L"RGB RGB sitoa_variance_filter " + mainFb.m_fullName + L" variance").GetAsciiString());
}
else
GetMessageQueue()->LogMsg(L"[sitoa] Arnold Denoising AOVs can only be output to exr.", siWarningMsg);
}

// Setting outputs array only if there is at least one active framebuffer
if (activeBuffer > 0)
{
AiNodeSetArray(in_optionsNode, "outputs", outputs);
Expand Down
Loading