Nuke binary plugins 16.1.1
 
Loading...
Searching...
No Matches
DD::Image::GeomOpEngine Class Reference

#include <GeomOp.h>

Inheritance diagram for DD::Image::GeomOpEngine:
DD::Image::ModifyGeomOp::ModifyEngine DD::Image::SourceGeomOp::SourceEngine

Classes

class  KnobBinding
 

Public Types

enum class  InjectionType : int32_t { DownstreamEngineDefault , NextEngineOverride , NumElements }
 
using InjectedPaths = std::array< std::shared_ptr< usg::PathArray >, static_cast< int32_t >(InjectionType::NumElements)>
 

Public Member Functions

std::string name () const override
 
OpfirstOp () const
 
KnobnodeKnob (const char *knobName) const
 Return the raw Knob* from the parent Node.
 
ndk::GraphScopeId graphScopeId () const
 
uint64_t version () const
 Version number of engine, incremented when state changes.
 
KnobBinding knob (const char *knobName) const
 Return a read handle to the named Knob from the engine.
 
template<typename T >
getValue (const KnobBinding &knob) const
 Convenience method to get a value from a KnobBinding, if it's valid.
 
template<typename T >
getValue (const char *knobName) const
 Convenience method to get a value from a named Knob, if it exists.
 
template<typename T >
getValue (const T &defaultValue, const char *knobName, double frame, int view=-1) const
 Convenience method to get a value from a named Knob, if it exists, otherwise return defaultValue.
 
template<typename T >
getValue (const T &defaultValue, const char *knobName) const
 getValue() variant for uniform (non-animating) Knobs, or if the default uiContext() is desired.
 
template<typename T >
void getValue (T &v, const char *knobName, double frame, int view=-1) const
 
template<typename T >
void getValue (T &v, const char *knobName) const
 getValue(&T) variant for uniform (non-animating) Knobs, or if the default uiContext() is desired.
 
template<typename T >
getValue (const T &defaultValue, const KnobBinding &knob, double frame, int view=-1) const
 Convenience method to get a value from a KnobBinding, if it's valid, otherwise return defaultValue.
 
template<typename T >
getValue (const T &defaultValue, const KnobBinding &knob) const
 getValue() variant for uniform (non-animating) Knobs, or if the default uiContext() is desired.
 
OpGraphLocation inputConnection (uint32_t nodeInput)
 
Op::Input inputConnectionAt (uint32_t nodeInput, double frame, const OutputContext &inputCtx, Execute *execute=nullptr)
 
Op::Input inputConnectionAt (uint32_t nodeInput, double frame, int32_t view=-1, Execute *execute=nullptr)
 
OpinputOpAt (uint32_t nodeInput, double frame, const OutputContext &inputCtx, Execute *execute=nullptr)
 
OpinputOpAt (uint32_t nodeInput, double frame, int32_t view=-1, Execute *execute=nullptr)
 
OpinputOp (uint32_t nodeInput) const
 
size_t nInputs () const override
 Return the number of Node input connections. Note that these are NOT Op inputs.
 
GeomEngine * inputEngine (uint32_t nodeInput) const override
 
GeomEngine * inputEngine0 () const override
 
GeomEngine * inputEngine1 () const override
 
void printInputs (std::ostream &, const char *prefix="") const
 Prints the contents of the current input.
 
bool validateState (bool forceUpdate=false)
 
void processScenegraph (usg::GeomSceneContext &context) override
 
void updateStateToContext (const OutputContext &context)
 
const fdk::Hash & lastRequestHash () const
 
virtual usg::Path importShaderOp (bool createMode, usg::GeomSceneContext &context, const Op::InputConnectionContextList &sourceOps, uint32_t materialGroupIndex, const usg::Path &materialLibraryPath)
 
virtual void assignMaterialBinding (usg::GeomSceneContext &context, bool createMode, const usg::Path &materialPath, const usg::PathArray &primPaths)
 
std::shared_ptr< usg::PathArray > getPathsToInjectDownstream (InjectionType type) const
 Returns the prim paths for a particular injection type that should be injected into the downstream engine.
 
void setPathsToInjectDownstream (InjectionType type, std::shared_ptr< usg::PathArray > paths)
 Sets the prim paths for a particular injection type that should be injected into the downstream engine.
 

Protected Types

using InputList = std::vector< Input >
 

Protected Member Functions

 GeomOpEngine (GeomOpNode *parent)
 
void _printInput (std::ostream &o, const GeomOpEngine::Input &b) const
 
void setOwnerNode ()
 Sets the owner node data in the edit layer to point to the owning node.
 
void _updateState (ndk::GraphScopeId nodeGraphScopeId, fdk::TimeValueSet &sampleTimes, std::set< int32_t > &sampleViews)
 
virtual void _updatePathsToInjectFromInput ()
 

Protected Attributes

GeomOpNode * _geomNode
 Owner node.
 
ndk::GraphScopeId _graphScopeId
 Node graph context hash identifier, unique to the GraphScope.
 
usg::ShaderDescGroupPtrMap _shaderDescGroups
 Groups of locally-created ShaderDescs.
 
InjectedPaths _pathsToInjectDownstreamByType
 Array of prim path arrays to be injected downstream where the array is indexed by the injection type.
 

Friends

class GeomOp
 
class GeomOpNodeImpl
 

Detailed Description

Scenegraph processing engine node that can build a usg::Stage. One of these is created and shared between all GeomOps generated from the same Nuke Node.

Member Enumeration Documentation

◆ InjectionType

enum class DD::Image::GeomOpEngine::InjectionType : int32_t
strong

Enumeration that defines the propogation and precedence for the injected prim paths. If the next engine has multiple inputs that engine must decide how to combine/use the input injections.

Enumerator
NextEngineOverride 

Inject into downstream engines and use these as the injected paths for the engine if no override.

NumElements 

Inject into the next downstream engine only and use these as the injected paths for that engine.

Member Function Documentation

◆ name()

std::string GeomOpEngine::name ( ) const
override

Returns nodeName() from _geomNode. Since the name of the Nuke Node can change dynamically we don't save this string locally.

References _geomNode.

Referenced by _updateState(), importShaderOp(), and validateState().

◆ firstOp()

Op * GeomOpEngine::firstOp ( ) const

Use this to access values that ALL GeomOp instances would share, ie non-animating, non-viewsplit values, or to access Nuke Node methods.

References _geomNode.

Referenced by _updateState(), DD::Image::MaterialBindingOpI::SubEngine::apply(), inputConnection(), inputConnectionAt(), DD::Image::SourceGeomOp::SourceEngine::processScenegraph(), and setOwnerNode().

◆ graphScopeId()

ndk::GraphScopeId DD::Image::GeomOpEngine::graphScopeId ( ) const
inline

GraphScope context the GeomEngine is configured for. This must be used when retrieving KnobBinding values to access the correct Knob state for this engine.

Referenced by DD::Image::GeomOpEngine::KnobBinding::getContext().

◆ inputConnection()

OpGraphLocation GeomOpEngine::inputConnection ( uint32_t  nodeInput)

Returns a generic Op location for input nodeInput. Warning, the returned location should only be used for Op typing, Node/Knob queries or Node input info. Similar to using Op::nodeInputConnection() with ANY_CONTEXT.

Use inputConnectionAt() to get a input Op connection at a specific context.

References DD::Image::Op::ANY_CONTEXT, firstOp(), and DD::Image::Op::nodeInputConnection().

◆ inputConnectionAt() [1/2]

Op::Input GeomOpEngine::inputConnectionAt ( uint32_t  nodeInput,
double  frame,
const OutputContext inputCtx,
Execute execute = nullptr 
)

Returns an Op connection for input nodeInput at a specific frame and OutputContext. GraphScope in inputCtx is used for the evaluation context.

Note that the frame number in inputCtx arg is always replaced by the frame arg.

References DD::Image::Op::EXECUTABLE_INPUT, firstOp(), DD::Image::Execute::generateOp(), and DD::Image::OutputContext::setView().

Referenced by DD::Image::MaterialBindingOpI::SubEngine::apply(), inputConnectionAt(), and inputOpAt().

◆ inputConnectionAt() [2/2]

Op::Input GeomOpEngine::inputConnectionAt ( uint32_t  nodeInput,
double  frame,
int32_t  view = -1,
Execute execute = nullptr 
)

Same as inputConnectionAt() but for a single view. If view is -1 (invalid) then the 'main' view (view index 1) is used instead. GraphScope in engine is used for the evaluation context.

References _graphScopeId, and inputConnectionAt().

◆ inputOpAt() [1/2]

Op * GeomOpEngine::inputOpAt ( uint32_t  nodeInput,
double  frame,
const OutputContext inputCtx,
Execute execute = nullptr 
)

Returns an Op for input nodeInput at a specific frame and OutputContext. GraphScope in inputCtx is used for the evaluation context.

Note that the frame number in inputCtx arg is always replaced by the frame arg.

References inputConnectionAt(), and DD::Image::OpGraphLocation::op.

Referenced by _updateState().

◆ inputOpAt() [2/2]

Op * GeomOpEngine::inputOpAt ( uint32_t  nodeInput,
double  frame,
int32_t  view = -1,
Execute execute = nullptr 
)

Same as inputOpAt() but for a single view. If view is -1 (invalid) then the 'main' view (view index 1) is used instead. GraphScope in engine is used for the evaluation context.

References _graphScopeId, inputConnectionAt(), and DD::Image::OpGraphLocation::op.

◆ inputOp()

Op * GeomOpEngine::inputOp ( uint32_t  nodeInput) const

Returns the Op::firstOp() pointer from the nodeInput Input. Warning, the firstOp may not be valid for a specific OutputContext that the engine is processing. It is ok to use for generic Node or Knob queries and Node input info - see the Op::firstOp() method for more info.

Use inputOpAt() and inputOpAtContext() to get a specific valid input Op.

Referenced by processScenegraph().

◆ inputEngine()

usg::GeomEngine * GeomOpEngine::inputEngine ( uint32_t  nodeInput) const
override

Returns the GeomOpEngine pointer from nodeInput, if input is another GeomEngine. Returns null if the input is not a GeomOp Node or is an 'empty' GeomOpEngine (a NullGeomOp) if the input is disconnected.

Referenced by processScenegraph(), and DD::Image::SourceGeomOp::SourceEngine::processScenegraph().

◆ validateState()

bool GeomOpEngine::validateState ( bool  forceUpdate = false)

Fast check if the engine needs to rebuild its states. This is cheap to call for repeat visits. Returns false if no change.

If the fast check determines the engine needs to update then the engine's _version number will be incremented. The changed version indicates the need to call the more expensive _updateState() which we want to defer until the engine is asked to provide state hashes or output data, and only pay the cost once. If forceUpdate is true then _version will always be incremented.

References name(), and DD::Image::Op::treeVersion().

Referenced by DD::Image::GeomOp::geometryComposeState(), DD::Image::GeomOp::geometryEditVersionState(), and DD::Image::GeomOp::geometryStateVaries().

◆ processScenegraph()

void GeomOpEngine::processScenegraph ( usg::GeomSceneContext &  context)
override

Default engine implemenation which sets the nuke:node data on the edit layer so we can go back from the Layer to the Node that created it.

References _updatePathsToInjectFromInput(), inputEngine(), inputOp(), and setOwnerNode().

Referenced by DD::Image::ModifyGeomOp::ModifyEngine::processScenegraph(), and DD::Image::SourceGeomOp::SourceEngine::processScenegraph().

◆ updateStateToContext()

void GeomOpEngine::updateStateToContext ( const OutputContext context)

Update the state of the GeomOpEngine to the provided OutputContext's GraphScope. If configuring from a single GeomOp pass in that GeomOp's outputContext(). This can be used for configuring a standalone GeomOpEngine.

References _updateState(), and DD::Image::OutputContext::graphScopeId().

◆ lastRequestHash()

const fdk::Hash & DD::Image::GeomOpEngine::lastRequestHash ( ) const
inline

The 'request' hash is used to track the evaluation or configuration state of the GeomEngine by the GeomOp network, it does not indicate the geometry state of the engine.

The request hash is built in GeomOp::buildGeometryStage(), passed to _buildStage() and if unchanged then the state of the GeomEngine and its input network is assumed to be unchanged.

◆ importShaderOp()

usg::Path GeomOpEngine::importShaderOp ( bool  createMode,
usg::GeomSceneContext &  context,
const Op::InputConnectionContextList &  sourceOps,
uint32_t  materialGroupIndex,
const usg::Path &  materialLibraryPath 
)
virtual

Converts the input Op(s) to surface shader and material Prims, defined in the edit Layer anchored under materialLibraryPath.

When createMode is false this method will update any existing overrides for the shader and material prims that were created during the create_mode=true phase. Overrides are only written if the shader/material parameters are not at their inital default.

sourceOps is the list of input Ops to be imported and the OutputContext they are being referenced at. If sampleOps is empty nothing will be done and an empty path returned. Important note - the OutputContext's time is when time samples are being written into attributes vs. the input Op::outputContext() time which may be different due to time modifier nodes like FrameHold and TimeOffset.

If the supplied Ops are ShaderOps (have a MaterialOpI interface) then the shaders are created through that interface. If the input is an Iop then it is treated as a texture source to a default constant (albedo only) shader. Legacy Material ops are NOT supported and will be ignored.

The materialGroupIndex is used to track the 'output' ShaderDesc from each material graph in the _shaderDescGroups map, but it doesn't need to match an actual GeomOpEngine input number. Typically there will be only one input material graph so materialGroupIndex will usually be 0.

Returns the path to the created or updated MaterialPrim, if successful.

References _shaderDescGroups, DD::Image::OutputContext::append(), DD::Image::MaterialOpI::clearShaderInstanceOverride(), DD::Image::MaterialOpI::createShaderGraph(), DD::Image::OpGraphLocation::editVersionHash(), DD::Image::MaterialOpI::getAppliedApiSchemas(), DD::Image::MaterialOpI::getMaterialFamilies(), DD::Image::MaterialOpI::getNodeInstanceSuffix(), DD::Image::MaterialOpI::getOutputType(), DD::Image::Op::inputsValid(), DD::Image::MaterialOpI::isCustomNukeMaterial(), name(), DD::Image::OpGraphLocation::node, DD::Image::Op::nodeFullPath(), DD::Image::OpGraphLocation::nodeName(), DD::Image::OpGraphLocation::op, DD::Image::OpGraphLocation::opHash(), DD::Image::OpGraphLocation::opHashAnimates(), DD::Image::MaterialOpI::OUTPUT_TYPE_COSHADER, DD::Image::MaterialOpI::OUTPUT_TYPE_LIGHTSHADER, DD::Image::MaterialOpI::OUTPUT_TYPE_SURFACESHADER, DD::Image::MaterialOpI::OUTPUT_TYPE_VOLUMESHADER, DD::Image::Op::outputContext(), DD::Image::MaterialOpI::setShaderInstanceOverride(), DD::Image::MaterialOpI::MaterialContext::shaderFamily, DD::Image::OpGraphLocation::topologyHash(), and DD::Image::MaterialOpI::updateShaderGraphOverrides().

Referenced by DD::Image::MaterialBindingOpI::SubEngine::apply().

◆ assignMaterialBinding()

void GeomOpEngine::assignMaterialBinding ( usg::GeomSceneContext &  context,
bool  createMode,
const usg::Path &  materialPath,
const usg::PathArray &  primPaths 
)
virtual

Assign the material to a list of Prims. Companion method to importShaderOp() usually called after it to assign the created material to a list of previously-created Prims.

When create_mode is true each Prim is retrieved from the engine's editLayer() and a Relationship created on the Prim. When create_mode is false each Prim is retrieved from the composed stage flowing through this node, and a Relationship matching material_path is searched for and updated.

Referenced by DD::Image::MaterialBindingOpI::SubEngine::apply().

◆ _updateState()

void GeomOpEngine::_updateState ( ndk::GraphScopeId  nodeGraphScopeId,
fdk::TimeValueSet &  sampleTimes,
std::set< int32_t > &  sampleViews 
)
protected

◆ _updatePathsToInjectFromInput()

void GeomOpEngine::_updatePathsToInjectFromInput ( )
protectedvirtual

Updates the paths that should be injected downstream from this engine by checking the injected paths from the previous engine. The default implementation just ensures the injected paths from input 0 with a DownstreamEngineDefault type are added to the _pathsToInjectDownstreamByType array. Called by processScenegraph()

References _pathsToInjectDownstreamByType, getPathsToInjectDownstream(), and setPathsToInjectDownstream().

Referenced by processScenegraph().



©2026 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.foundry.com