Skip to content

Commit

Permalink
3Delight : Add additional outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Sep 25, 2023
1 parent 4ce2612 commit 40f4be6
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 16 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Features
- Added support for `vdbVolume` shader.
- Added support for `volumeshader` and `displacementshader` attributes.
- Added support for spline parameters in shaders.
- Added additional output presets.

Improvements
------------
Expand Down
44 changes: 44 additions & 0 deletions contrib/scripts/3delightOutputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#! /usr/bin/env python

# Prints out handy parsing of the 3Delight for Houdini outputs ready for
# 3Delight entries in `outputs.py`.


import urllib.request
import shlex

url = "https://gitlab.com/3Delight/3delight-for-houdini/-/raw/master/ui/aov.cpp"

outputsRaw = []

with urllib.request.urlopen( url ) as f :
lines = f.read().decode( "utf-8" ).split("\n")
for i in range( 0, len( lines ) ) :
line = lines[i]
if line.strip() == "std::vector<aov::description> descriptions =" :
i += 1 # Skip `{`
line = lines[i]
while line.strip() != "};" :
outputsRaw.append( line.strip()[1:-2].strip() ) # Remove leading `{` and trailing `},`
i += 1
line = lines[i]
break

outputs = []
print("for name, displayName, source, dataType in [")
for o in outputsRaw :
if o == "" :
continue
m_type, m_ui_name, m_filename_token, m_variable_name, m_variable_source, m_layer_type, m_with_alpha, m_support_mutlilight = shlex.split( o )

m_layer_type = { "vector": "point", "scalar": "float" }.get( m_layer_type.rstrip( "," ), m_layer_type )

print(
' ( "{}", "{}", "{}", "{}" ),'.format(
m_variable_name.rstrip( "," ),
m_ui_name.rstrip( "," ),
m_variable_source.rstrip( "," ),
m_layer_type.rstrip( "," )
)
)
print( "] :\n\n" )
7 changes: 6 additions & 1 deletion src/IECoreDelight/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "IECoreScene/ShaderNetwork.h"
#include "IECoreScene/ShaderNetworkAlgo.h"

#include "IECore/CamelCase.h"
#include "IECore/MessageHandler.h"
#include "IECore/SearchPath.h"
#include "IECore/SimpleTypedData.h"
Expand Down Expand Up @@ -319,7 +320,11 @@ class DelightOutput : public IECore::RefCounted
variableName = nameTokens[1];
variableSource = nameTokens[0];
}
layerName = variableName;

// Remove the `.` character and use camel case
vector<string> layerTokens;
IECore::StringAlgo::tokenize( variableName, '.', layerTokens );
layerName = IECore::CamelCase::join( layerTokens.begin(), layerTokens.end(), IECore::CamelCase::AllExceptFirst);
}

ParameterList layerParams;
Expand Down
64 changes: 49 additions & 15 deletions startup/gui/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,56 @@
# and we won't add any unnecessary output definitions.
import GafferDelight

for aov in [
"diffuse",
"subsurface",
"reflection",
"refraction",
"incandescence",
# Should be kept up to date with
# https://gitlab.com/3Delight/3delight-for-houdini/-/blob/master/ui/aov.cpp
# See `contrib/scripts/3delightOutputs.py` in this repository for a helper script.

for name, displayName, source, dataType in [
( "Ci", "Ci", "shader", "color" ),
( "Ci.direct", "Ci (direct)", "shader", "color" ),
( "Ci.indirect", "Ci (indirect)", "shader", "color" ),
( "diffuse", "Diffuse", "shader", "color" ),
( "diffuse.direct", "Diffuse (direct)", "shader", "color" ),
( "diffuse.indirect", "Diffuse (indirect)", "shader", "color" ),
( "hair", "Hair and Fur", "shader", "color" ),
( "subsurface", "Subsurface Scattering", "shader", "color" ),
( "reflection", "Reflection", "shader", "color" ),
( "reflection.direct", "Reflection (direct)", "shader", "color" ),
( "reflection.indirect", "Reflection (indirect)", "shader", "color" ),
( "refraction", "Refraction", "shader", "color" ),
( "volume", "Volume Scattering", "shader", "color" ),
( "volume.direct", "Volume Scattering (direct)", "shader", "color" ),
( "volume.indirect", "Volume Scattering (indirect)", "shader", "color" ),
( "incandescence", "Incandescence", "shader", "color" ),
( "toon_base", "Toon Base", "shader", "color" ),
( "toon_diffuse", "Toon Diffuse", "shader", "color" ),
( "toon_specular", "Toon Specular", "shader", "color" ),
( "toon_matte", "Toon Matte", "shader", "color" ),
( "toon_tint", "Toon Tint", "shader", "color" ),
( "outlines", "Outlines", "shader", "quad" ),
( "albedo", "Albedo", "shader", "color" ),
( "z", "Z (depth)", "builtin", "float" ),
( "P.camera", "Camera Space Position", "builtin", "point" ),
( "N.camera", "Camera Space Normal", "builtin", "point" ),
( "P.world", "World Space Position", "builtin", "point" ),
( "N.world", "World Space Normal", "builtin", "point" ),
( "Pref", "Reference Position", "attribute", "point" ),
( "shadow_mask", "Shadow Mask", "shader", "color" ),
( "st", "UV", "attribute", "point" ),
( "id.geometry", "Geometry Cryptomatte", "builtin", "float" ),
( "id.scenepath", "Scene Path Cryptomatte", "builtin", "float" ),
( "id.surfaceshader", "Surface Shader Cryptomatte", "builtin", "float" ),
( "relighting_multiplier", "Relighting Multiplier", "shader", "color" ),
( "relighting_reference", "Relighting Reference", "shader", "color" ),
( "motionvector", "Motion Vector", "builtin", "point" ),
( "occlusion", "Ambient Occlusion", "shader", "color" ),
] :

label = aov.title()

GafferScene.Outputs.registerOutput(
"Interactive/3Delight/" + label,
"Interactive/3Delight/{}/{}".format( source.capitalize(), displayName ),
IECoreScene.Output(
aov,
name,
"ieDisplay",
"color " + aov,
"{} {}:{}".format( dataType, source, name ),
{
"driverType" : "ClientDisplayDriver",
"displayHost" : "localhost",
Expand All @@ -195,11 +229,11 @@
)

GafferScene.Outputs.registerOutput(
"Batch/3Delight/" + label,
"Batch/3Delight/{}/{}".format( source.capitalize(), displayName ),
IECoreScene.Output(
"${project:rootDirectory}/renders/${script:name}/%s/%s.####.exr" % ( aov, aov ),
"${project:rootDirectory}/renders/${script:name}/%s/%s.####.exr" % ( name, name ),
"exr",
"color " + aov,
"{} {}:{}".format( dataType, source, name ),
)
)

Expand Down

0 comments on commit 40f4be6

Please sign in to comment.