Skip to content

Commit

Permalink
Viewer config : Add diagnostic shading mode for usd:purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Aug 6, 2024
1 parent 02ed515 commit d165d29
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Improvements
- ArnoldShader :
- Added a UI layout for the new `openpbr_surface` shader.
- Moved Arnold 7.3.3.0's new `standard_volume.scatter_diffusion` parameters to a "Scatter Diffusion" section of the UI.
- Viewer : Added diagnostic shading mode for visualising the values of the `usd:purpose` attribute as colours :
- White : Default
- Green : Render
- Blue : Proxy
- Red : Guide

Fixes
-----
Expand Down
49 changes: 49 additions & 0 deletions startup/gui/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,55 @@ def __createXRayShader() :

GafferSceneUI.SceneView.registerShadingMode( "X-Ray", __createXRayShader )

def __createPurposeShadingMode() :

result = GafferScene.SceneProcessor( "PurposeVisualiser" )

result["attributeQuery"] = GafferScene.AttributeQuery()
result["attributeQuery"].setup( Gaffer.StringPlug() )
result["attributeQuery"]["scene"].setInput( result["in"] )
result["attributeQuery"]["location"].setValue( "${scene:path}" )
result["attributeQuery"]["attribute"].setValue( "usd:purpose" )
result["attributeQuery"]["default"].setValue( "default" )
result["attributeQuery"]["inherit"].setValue( True )

result["customAttributes"] = GafferScene.CustomAttributes()
result["customAttributes"]["in"].setInput( result["in"] )

result["spreadsheet"] = Gaffer.Spreadsheet()
result["spreadsheet"]["selector"].setInput( result["attributeQuery"]["value"] )
result["spreadsheet"]["rows"].addColumn( result["customAttributes"]["extraAttributes"] )

result["customAttributes"]["extraAttributes"].setInput( result["spreadsheet"]["out"]["extraAttributes"] )

for purpose, color in {
"render" : imath.Color3f( 0, 1, 0 ),
"proxy" : imath.Color3f( 0, 0, 1 ),
"guide" : imath.Color3f( 1, 0, 0 ),
"default" : imath.Color3f( 1, 1, 1 )
}.items() :
row = result["spreadsheet"]["rows"].addRow()
row["name"].setValue( purpose )
row["cells"]["extraAttributes"]["value"].setValue(
IECore.CompoundObject( {
"gl:surface" : IECoreScene.ShaderNetwork(
shaders = {
"surface" : IECoreScene.Shader(
"FacingRatio", "gl:surface",
{ "facingColor" : color },
)
},
output = "surface",
)
} )
)

result["out"].setInput( result["customAttributes"]["out"] )

return result

GafferSceneUI.SceneView.registerShadingMode( "Diagnostic/USD/Purpose", __createPurposeShadingMode )

def __loadRendererSettings( fileName ) :

script = Gaffer.ScriptNode()
Expand Down

0 comments on commit d165d29

Please sign in to comment.