Skip to content

Commit

Permalink
Merge pull request #5983 from johnhaddon/purposeVisualiser
Browse files Browse the repository at this point in the history
Viewer config : Add diagnostic shading mode for usd:purpose
  • Loading branch information
johnhaddon authored Aug 7, 2024
2 parents 6f94c7b + d165d29 commit 1ba35c0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
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
51 changes: 50 additions & 1 deletion startup/gui/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,56 @@ def __createXRayShader() :

return xray

GafferSceneUI.SceneView.registerShadingMode( "X-Ray", functools.partial( __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 ) :

Expand Down

0 comments on commit 1ba35c0

Please sign in to comment.