Skip to content

Commit

Permalink
Merge pull request #5672 from murraystevenson/renderPassCreation
Browse files Browse the repository at this point in the history
RenderPassEditor : Render pass creation and deletion
  • Loading branch information
johnhaddon authored Feb 22, 2024
2 parents 3de846f + 30a9d84 commit 0bcab20
Show file tree
Hide file tree
Showing 9 changed files with 573 additions and 6 deletions.
12 changes: 12 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Improvements

- SceneReader : Added basic loding of UsdGeomNurbsCurves, converting them to CurvesPrimitives (basis curves).
- Console output : Every line is now prefixed with the message level.
- RenderPasses : Added validation of render pass names entered in the `names` plug.
- RenderPassEditor :
- Added support for adding a new render pass to an EditScope by clicking the plus button at the bottom of the editor.
- Added support for deleting selected render passes by clicking the minus button at the bottom of the editor, or by right-clicking one of the names and selecting 'Delete Selected Render Passes'.

Fixes
-----
Expand All @@ -25,6 +29,14 @@ Documentation
- Added Render Pass Editor shortcuts to the "Controls and Shortcuts" section.
- Added Render Pass Editor (Arnold) example demonstrating use of the Render Pass Editor, as well as the RenderPasses and RenderPassWedge nodes.

API
---

- EditScopeAlgo : Added support for creating render passes.
- RenderPasses : Added `registerRenderPassNameWidget()` and `createRenderPassNameWidget()` methods for registration and creation of the widget used for editing render pass names.
- RenderPassEditor : Added `addRenderPassButtonMenuSignal()` to allow customisation of the add render pass button behaviour.
- ConfirmationDialogue : The cancel button may now be omitted by passing `cancelLabel = None` to the constructor.

Build
-----

Expand Down
2 changes: 2 additions & 0 deletions include/GafferScene/EditScopeAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ GAFFERSCENE_API Gaffer::TweakPlug *acquireRenderPassOptionEdit( Gaffer::EditScop
GAFFERSCENE_API void removeRenderPassOptionEdit( Gaffer::EditScope *scope, const std::string &renderPass, const std::string &option );
GAFFERSCENE_API const Gaffer::GraphComponent *renderPassOptionEditReadOnlyReason( const Gaffer::EditScope *scope, const std::string &renderPass, const std::string &option );

GAFFERSCENE_API const Gaffer::GraphComponent *renderPassesReadOnlyReason( const Gaffer::EditScope *scope );

} // namespace EditScopeAlgo

} // namespace GafferScene
55 changes: 55 additions & 0 deletions python/GafferSceneTest/EditScopeAlgoTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,5 +1653,60 @@ def testOptionEditFromDefaultValueMetadata( self ) :
self.assertIsNotNone( GafferScene.EditScopeAlgo.acquireOptionEdit( editScope, "test:bogus" ) )
self.assertNotEqual( editScope.keys(), emptyKeys )

def testRenderPassesReadOnlyReason( self ) :

s = Gaffer.ScriptNode()

s["cube"] = GafferScene.Cube()

s["scope"] = Gaffer.EditScope()
s["scope"].setup( s["cube"]["out"] )
s["scope"]["in"].setInput( s["cube"]["out"] )

s["box"] = Gaffer.Box.create( s, Gaffer.StandardSet( [ s["cube"], s["scope"] ] ) )

self.assertIsNone( GafferScene.EditScopeAlgo.renderPassesReadOnlyReason( s["box"]["scope"] ) )

for component in ( s["box"], s["box"]["scope"] ):
Gaffer.MetadataAlgo.setReadOnly( component, True )
self.assertEqual( GafferScene.EditScopeAlgo.renderPassesReadOnlyReason( s["box"]["scope"] ), s["box"] )

Gaffer.MetadataAlgo.setReadOnly( s["box"], False )
self.assertEqual( GafferScene.EditScopeAlgo.renderPassesReadOnlyReason( s["box"]["scope"] ), s["box"]["scope"] )

Gaffer.MetadataAlgo.setReadOnly( s["box"]["scope"], False )
renderPasses = s["box"]["scope"].acquireProcessor( "RenderPasses", createIfNecessary = True )
renderPasses["names"].setValue( IECore.StringVectorData( [ "renderPassA" ] ) )

self.assertIsNone( GafferScene.EditScopeAlgo.renderPassesReadOnlyReason( s["box"]["scope"] ) )

for component in (
s["box"]["scope"]["RenderPasses"]["names"],
s["box"]["scope"]["RenderPasses"],
s["box"]["scope"],
s["box"]
) :
Gaffer.MetadataAlgo.setReadOnly( component, True )
self.assertEqual( GafferScene.EditScopeAlgo.renderPassesReadOnlyReason( s["box"]["scope"] ), component )

def testRenderPassesSerialisation( self ) :

s = Gaffer.ScriptNode()

s["plane"] = GafferScene.Plane()

s["editScope"] = Gaffer.EditScope()
s["editScope"].setup( s["plane"]["out"] )

renderPasses = s["editScope"].acquireProcessor( "RenderPasses", createIfNecessary = True )
renderPasses["names"].setValue( IECore.StringVectorData( [ "renderPassA" ] ) )

self.assertEqual( s["editScope"]["out"]["globals"].getValue().get( "option:renderPass:names" ), IECore.StringVectorData( [ "renderPassA" ] ) )

s2 = Gaffer.ScriptNode()
s2.execute( s.serialise() )

self.assertEqual( s2["editScope"]["out"]["globals"].getValue().get( "option:renderPass:names" ), IECore.StringVectorData( [ "renderPassA" ] ) )

if __name__ == "__main__":
unittest.main()
Loading

0 comments on commit 0bcab20

Please sign in to comment.