@@ -137,6 +137,39 @@ IECORESCENE_API void expandRamps( ShaderNetwork *network, std::string targetPref
137137// / Used when dealing with SCC files written before Cortex 10.7, which used Spline*Data instead of Ramp*Data
138138IECORESCENE_API void convertDeprecatedSplines ( ShaderNetwork *network );
139139
140+ // / Render Adaptors
141+ // / ===============
142+ // /
143+ // / Render adaptors are functions called to make "just in time" modifications to
144+ // / shader networks prior to rendering. They have access to a fully resolved
145+ // / attribute state, which can be used to drive the modifications. There is currently
146+ // / a single built-in adaptor, which uses `ShaderNetworkAlgo::applySubstitutions()`
147+ // / to allow strings such as texture paths to be substituted in from attributes that
148+ // / define them.
149+ // /
150+ // / Adaptors are performance critical, so are deliberately not available via
151+ // / the Python API. They must be implemented in C++ only.
152+
153+ // / A function that adapts the shader network for rendering, given the full
154+ // / inherited `attributes` for an object. Must be threadsafe.
155+ using RenderAdaptorFunction = void (*)( ShaderNetwork *shaderNetwork, IECore::InternedString attributeName, const IECore::CompoundObject *attributes );
156+ // / A function that appends to `hash` to uniquely identify the work that will be
157+ // / performed by an AdaptorFunction. Particular attention must be paid to
158+ // / the performance of any such function, as it will be called frequently. If an
159+ // / adaptor will be a no-op, then nothing should be appended to the hash.
160+ // / Must be threadsafe.
161+ using RenderAdaptorHashFunction = void (*)( const ShaderNetwork *shaderNetwork, IECore::InternedString attributeName, const IECore::CompoundObject *attributes, IECore::MurmurHash &hash );
162+
163+ // / Registers an adaptor.
164+ IECORESCENE_API void registerRenderAdaptor ( const std::string &name, RenderAdaptorHashFunction hashFunction, RenderAdaptorFunction adaptorFunction );
165+ // / Removes a previously registered adaptor with the specified name.
166+ IECORESCENE_API void deregisterRenderAdaptor ( const std::string &name );
167+
168+ // / Hashes all the currently registered adaptors for `shaderNetwork`.
169+ IECORESCENE_API void hashRenderAdaptors ( const ShaderNetwork *shaderNetwork, IECore::InternedString attributeName, const IECore::CompoundObject *attributes, IECore::MurmurHash &hash );
170+ // / Applies all the currently registered adaptors to `shaderNetwork`.
171+ IECORESCENE_API void applyRenderAdaptors ( ShaderNetwork *shaderNetwork, IECore::InternedString attributeName, const IECore::CompoundObject *attributes );
172+
140173} // namespace ShaderNetworkAlgo
141174
142175} // namespace IECoreScene
0 commit comments