All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsdImagingGLEngine Class Reference

The UsdImagingGLEngine is the main entry point API for rendering USD scenes. More...

Public Member Functions

Construction
USDIMAGINGGL_API UsdImagingGLEngine ()
 
USDIMAGINGGL_API UsdImagingGLEngine (const SdfPath &rootPath, const SdfPathVector &excludedPaths, const SdfPathVector &invisedPaths=SdfPathVector(), const SdfPath &delegateID=SdfPath::AbsoluteRootPath())
 
 UsdImagingGLEngine (const UsdImagingGLEngine &)=delete
 
UsdImagingGLEngineoperator= (const UsdImagingGLEngine &)=delete
 
USDIMAGINGGL_API ~UsdImagingGLEngine ()
 
Rendering
USDIMAGINGGL_API void PrepareBatch (const UsdPrim &root, const UsdImagingGLRenderParams &params)
 Support for batched drawing. More...
 
USDIMAGINGGL_API void RenderBatch (const SdfPathVector &paths, const UsdImagingGLRenderParams &params)
 
USDIMAGINGGL_API void Render (const UsdPrim &root, const UsdImagingGLRenderParams &params)
 Entry point for kicking off a render. More...
 
USDIMAGINGGL_API void InvalidateBuffers ()
 
USDIMAGINGGL_API bool IsConverged () const
 Returns true if the resulting image is fully converged. More...
 
Root Transform and Visibility
USDIMAGINGGL_API void SetRootTransform (GfMatrix4d const &xf)
 Sets the root transform. More...
 
USDIMAGINGGL_API void SetRootVisibility (bool isVisible)
 Sets the root visibility. More...
 
Camera State
USDIMAGINGGL_API void SetRenderViewport (GfVec4d const &viewport)
 Set the viewport to use for rendering as (x,y,w,h), where (x,y) represents the lower left corner of the viewport rectangle, and (w,h) is the width and height of the viewport in pixels. More...
 
USDIMAGINGGL_API void SetWindowPolicy (CameraUtilConformWindowPolicy policy)
 Set the window policy to use. More...
 
USDIMAGINGGL_API void SetCameraPath (SdfPath const &id)
 Scene camera API Set the scene camera path to use for rendering. More...
 
USDIMAGINGGL_API void SetCameraState (const GfMatrix4d &viewMatrix, const GfMatrix4d &projectionMatrix)
 Free camera API Set camera framing state directly (without pointing to a camera on the USD stage). More...
 
USDIMAGINGGL_API void SetCameraStateFromOpenGL ()
 Helper function to extract camera and viewport state from opengl and then call SetCameraState and SetRenderViewport. More...
 
Light State
USDIMAGINGGL_API void SetLightingStateFromOpenGL ()
 Helper function to extract lighting state from opengl and then call SetLights. More...
 
USDIMAGINGGL_API void SetLightingState (GlfSimpleLightingContextPtr const &src)
 Copy lighting state from another lighting context. More...
 
USDIMAGINGGL_API void SetLightingState (GlfSimpleLightVector const &lights, GlfSimpleMaterial const &material, GfVec4f const &sceneAmbient)
 Set lighting state Derived classes should ensure that passing an empty lights vector disables lighting. More...
 
Selection Highlighting
USDIMAGINGGL_API void SetSelected (SdfPathVector const &paths)
 Sets (replaces) the list of prim paths that should be included in selection highlighting. More...
 
USDIMAGINGGL_API void ClearSelected ()
 Clear the list of prim paths that should be included in selection highlighting. More...
 
USDIMAGINGGL_API void AddSelected (SdfPath const &path, int instanceIndex)
 Add a path with instanceIndex to the list of prim paths that should be included in selection highlighting. More...
 
USDIMAGINGGL_API void SetSelectionColor (GfVec4f const &color)
 Sets the selection highlighting color. More...
 
AOVs and Renderer Settings
USDIMAGINGGL_API TfTokenVector GetRendererAovs () const
 Return the vector of available renderer AOV settings. More...
 
USDIMAGINGGL_API bool SetRendererAov (TfToken const &id)
 Set the current renderer AOV to id. More...
 
USDIMAGINGGL_API
UsdImagingGLRendererSettingsList 
GetRendererSettingsList () const
 Returns the list of renderer settings. More...
 
USDIMAGINGGL_API VtValue GetRendererSetting (TfToken const &id) const
 Gets a renderer setting's current value. More...
 
USDIMAGINGGL_API void SetRendererSetting (TfToken const &id, VtValue const &value)
 Sets a renderer setting's value. More...
 
Control of background rendering threads.
USDIMAGINGGL_API bool IsPauseRendererSupported () const
 Query the renderer as to whether it supports pausing and resuming. More...
 
USDIMAGINGGL_API bool PauseRenderer ()
 Pause the renderer. More...
 
USDIMAGINGGL_API bool ResumeRenderer ()
 Resume the renderer. More...
 
Color Correction
USDIMAGINGGL_API void SetColorCorrectionSettings (TfToken const &id, GfVec2i const &framebufferResolution)
 Set id to one of the HdxColorCorrectionTokens. More...
 
Render Statistics
USDIMAGINGGL_API VtDictionary GetRenderStats () const
 Returns render statistics. More...
 

Static Public Member Functions

static USDIMAGINGGL_API bool IsColorCorrectionCapable ()
 Returns true if the platform is color correction capable. More...
 
Global State
static USDIMAGINGGL_API bool IsHydraEnabled ()
 Returns true if Hydra is enabled for GL drawing. More...
 

Protected Member Functions

USDIMAGINGGL_API HdRenderIndex_GetRenderIndex () const
 Returns the render index of the engine, if any. More...
 
USDIMAGINGGL_API void _Execute (const UsdImagingGLRenderParams &params, HdTaskSharedPtrVector tasks)
 
USDIMAGINGGL_API bool _CanPrepareBatch (const UsdPrim &root, const UsdImagingGLRenderParams &params)
 
USDIMAGINGGL_API void _PreSetTime (const UsdPrim &root, const UsdImagingGLRenderParams &params)
 
USDIMAGINGGL_API void _PostSetTime (const UsdPrim &root, const UsdImagingGLRenderParams &params)
 
USDIMAGINGGL_API void _DeleteHydraResources ()
 

Static Protected Member Functions

static USDIMAGINGGL_API bool _UpdateHydraCollection (HdRprimCollection *collection, SdfPathVector const &roots, UsdImagingGLRenderParams const &params)
 
static USDIMAGINGGL_API
HdxRenderTaskParams 
_MakeHydraUsdImagingGLRenderParams (UsdImagingGLRenderParams const &params)
 
static USDIMAGINGGL_API void _ComputeRenderTags (UsdImagingGLRenderParams const &params, TfTokenVector *renderTags)
 
static USDIMAGINGGL_API TfToken _GetDefaultRendererPluginId ()
 

Protected Attributes

HdEngine _engine
 
HdRenderIndex_renderIndex
 
HdxSelectionTrackerSharedPtr _selTracker
 
HdRprimCollection _renderCollection
 
HdRprimCollection _intersectCollection
 
SdfPath const _delegateID
 
UsdImagingDelegate_delegate
 
HdRendererPlugin_rendererPlugin
 
TfToken _rendererId
 
HdxTaskController * _taskController
 
GlfSimpleLightingContextRefPtr _lightingContextForOpenGLState
 
GfVec4f _selectionColor
 
SdfPath _rootPath
 
SdfPathVector _excludedPrimPaths
 
SdfPathVector _invisedPrimPaths
 
bool _isPopulated
 
std::unique_ptr
< UsdImagingGLLegacyEngine > 
_legacyImpl
 

Picking

static int DecodeIDRenderColor (unsigned char const idColor[4])
 Resolves a 4-byte pixel from an id render to an int32 prim ID. More...
 
USDIMAGINGGL_API bool TestIntersection (const GfMatrix4d &viewMatrix, const GfMatrix4d &projectionMatrix, const GfMatrix4d &worldToLocalSpace, const UsdPrim &root, const UsdImagingGLRenderParams &params, GfVec3d *outHitPoint, SdfPath *outHitPrimPath=NULL, SdfPath *outHitInstancerPath=NULL, int *outHitInstanceIndex=NULL, int *outHitElementIndex=NULL)
 Finds closest point of intersection with a frustum by rendering. More...
 
USDIMAGINGGL_API SdfPath GetRprimPathFromPrimId (int primId) const
 Using an Id extracted from an Id render, returns the associated rprim path. More...
 
USDIMAGINGGL_API SdfPath GetPrimPathFromPrimIdColor (GfVec4i const &primIdColor, GfVec4i const &instanceIdColor, int *instanceIndexOut=NULL)
 Using colors extracted from an Id render, returns the associated prim path and optional instance index. More...
 
USDIMAGINGGL_API SdfPath GetPrimPathFromInstanceIndex (const SdfPath &protoRprimId, int protoIndex, int *instancerIndex=NULL, SdfPath *masterCachePath=NULL, SdfPathVector *instanceContext=NULL)
 Returns the rprim id path of the instancer being rendered by this engine that corresponds to the instance index generated by the specified instanced prototype rprim id. More...
 

Renderer Plugin Management

static USDIMAGINGGL_API
TfTokenVector 
GetRendererPlugins ()
 Return the vector of available render-graph delegate plugins. More...
 
static USDIMAGINGGL_API std::string GetRendererDisplayName (TfToken const &id)
 Return the user-friendly description of a renderer plugin. More...
 
USDIMAGINGGL_API TfToken GetCurrentRendererId () const
 Return the id of the currently used renderer plugin. More...
 
USDIMAGINGGL_API bool SetRendererPlugin (TfToken const &id)
 Set the current render-graph delegate to id. More...
 

Detailed Description

The UsdImagingGLEngine is the main entry point API for rendering USD scenes.

Definition at line 81 of file engine.h.

Member Function Documentation

USDIMAGINGGL_API HdRenderIndex* _GetRenderIndex ( ) const
protected

Returns the render index of the engine, if any.

This is only used for whitebox testing.

USDIMAGINGGL_API void AddSelected ( SdfPath const &  path,
int  instanceIndex 
)

Add a path with instanceIndex to the list of prim paths that should be included in selection highlighting.

UsdImagingDelegate::ALL_INSTANCES can be used for highlighting all instances if path is an instancer.

USDIMAGINGGL_API void ClearSelected ( )

Clear the list of prim paths that should be included in selection highlighting.

static int DecodeIDRenderColor ( unsigned char const  idColor[4])
inlinestatic

Resolves a 4-byte pixel from an id render to an int32 prim ID.

Definition at line 336 of file engine.h.

USDIMAGINGGL_API TfToken GetCurrentRendererId ( ) const

Return the id of the currently used renderer plugin.

USDIMAGINGGL_API SdfPath GetPrimPathFromInstanceIndex ( const SdfPath protoRprimId,
int  protoIndex,
int *  instancerIndex = NULL,
SdfPath masterCachePath = NULL,
SdfPathVector *  instanceContext = NULL 
)

Returns the rprim id path of the instancer being rendered by this engine that corresponds to the instance index generated by the specified instanced prototype rprim id.

Returns an empty path if no such instance prim exists.

instancerIndex is also returned, which is an instance index of all instances in the top-level instancer. Note that if the instancer instances heterogeneously, or there are multiple levels of hierarchy, protoIndex of the prototype rprim doesn't match the instancerIndex in the instancer (see usdImaging/delegate.h)

If masterCachePath is not NULL, and the input rprim is an instance resulting from an instanceable reference (and not from a PointInstancer), then it will be set to the cache path of the corresponding instance master prim. Otherwise, it will be set to null.

If instanceContext is not NULL, it is populated with the list of instance roots that must be traversed to get to the rprim. If this list is non-empty, the last prim is always the forwarded rprim.

USDIMAGINGGL_API SdfPath GetPrimPathFromPrimIdColor ( GfVec4i const &  primIdColor,
GfVec4i const &  instanceIdColor,
int *  instanceIndexOut = NULL 
)

Using colors extracted from an Id render, returns the associated prim path and optional instance index.

Note that this function doesn't resolve instancer relationship. returning prim can be a prototype mesh which may not exist in usd stage. It can be resolved to the actual usd prim and corresponding instance index by GetPrimPathFromInstanceIndex().

XXX: consider renaming to GetRprimPathFromPrimIdColor

USDIMAGINGGL_API TfTokenVector GetRendererAovs ( ) const

Return the vector of available renderer AOV settings.

static USDIMAGINGGL_API std::string GetRendererDisplayName ( TfToken const &  id)
static

Return the user-friendly description of a renderer plugin.

static USDIMAGINGGL_API TfTokenVector GetRendererPlugins ( )
static

Return the vector of available render-graph delegate plugins.

USDIMAGINGGL_API VtValue GetRendererSetting ( TfToken const &  id) const

Gets a renderer setting's current value.

USDIMAGINGGL_API UsdImagingGLRendererSettingsList GetRendererSettingsList ( ) const

Returns the list of renderer settings.

USDIMAGINGGL_API VtDictionary GetRenderStats ( ) const

Returns render statistics.

The contents of the dictionary will depend on the current render delegate.

USDIMAGINGGL_API SdfPath GetRprimPathFromPrimId ( int  primId) const

Using an Id extracted from an Id render, returns the associated rprim path.

Note that this function doesn't resolve instancer relationship. returning prim can be a prototype mesh which may not exist in usd stage. It can be resolved to the actual usd prim and corresponding instance index by GetPrimPathFromInstanceIndex().

static USDIMAGINGGL_API bool IsColorCorrectionCapable ( )
static

Returns true if the platform is color correction capable.

USDIMAGINGGL_API bool IsConverged ( ) const

Returns true if the resulting image is fully converged.

(otherwise, caller may need to call Render() again to refine the result)

static USDIMAGINGGL_API bool IsHydraEnabled ( )
static

Returns true if Hydra is enabled for GL drawing.

USDIMAGINGGL_API bool IsPauseRendererSupported ( ) const

Query the renderer as to whether it supports pausing and resuming.

USDIMAGINGGL_API bool PauseRenderer ( )

Pause the renderer.

Returns true if successful.

USDIMAGINGGL_API void PrepareBatch ( const UsdPrim root,
const UsdImagingGLRenderParams params 
)

Support for batched drawing.

USDIMAGINGGL_API void Render ( const UsdPrim root,
const UsdImagingGLRenderParams params 
)

Entry point for kicking off a render.

USDIMAGINGGL_API bool ResumeRenderer ( )

Resume the renderer.

Returns true if successful.

USDIMAGINGGL_API void SetCameraPath ( SdfPath const &  id)

Scene camera API Set the scene camera path to use for rendering.

USDIMAGINGGL_API void SetCameraState ( const GfMatrix4d viewMatrix,
const GfMatrix4d projectionMatrix 
)

Free camera API Set camera framing state directly (without pointing to a camera on the USD stage).

The projection matrix is expected to be pre-adjusted for the window policy.

USDIMAGINGGL_API void SetCameraStateFromOpenGL ( )

Helper function to extract camera and viewport state from opengl and then call SetCameraState and SetRenderViewport.

USDIMAGINGGL_API void SetColorCorrectionSettings ( TfToken const &  id,
GfVec2i const &  framebufferResolution 
)

Set id to one of the HdxColorCorrectionTokens.

framebufferResolution should be the size of the bound framebuffer that will be color corrected. It is recommended that a 16F or higher AOV is bound for color correction.

USDIMAGINGGL_API void SetLightingState ( GlfSimpleLightingContextPtr const &  src)

Copy lighting state from another lighting context.

USDIMAGINGGL_API void SetLightingState ( GlfSimpleLightVector const &  lights,
GlfSimpleMaterial const &  material,
GfVec4f const &  sceneAmbient 
)

Set lighting state Derived classes should ensure that passing an empty lights vector disables lighting.

Parameters
lightsis the set of lights to use, or empty to disable lighting.
USDIMAGINGGL_API void SetLightingStateFromOpenGL ( )

Helper function to extract lighting state from opengl and then call SetLights.

USDIMAGINGGL_API bool SetRendererAov ( TfToken const &  id)

Set the current renderer AOV to id.

USDIMAGINGGL_API bool SetRendererPlugin ( TfToken const &  id)

Set the current render-graph delegate to id.

the plugin will be loaded if it's not yet.

USDIMAGINGGL_API void SetRendererSetting ( TfToken const &  id,
VtValue const &  value 
)

Sets a renderer setting's value.

USDIMAGINGGL_API void SetRenderViewport ( GfVec4d const &  viewport)

Set the viewport to use for rendering as (x,y,w,h), where (x,y) represents the lower left corner of the viewport rectangle, and (w,h) is the width and height of the viewport in pixels.

USDIMAGINGGL_API void SetRootTransform ( GfMatrix4d const &  xf)

Sets the root transform.

USDIMAGINGGL_API void SetRootVisibility ( bool  isVisible)

Sets the root visibility.

USDIMAGINGGL_API void SetSelected ( SdfPathVector const &  paths)

Sets (replaces) the list of prim paths that should be included in selection highlighting.

These paths may include root paths which will be expanded internally.

USDIMAGINGGL_API void SetSelectionColor ( GfVec4f const &  color)

Sets the selection highlighting color.

USDIMAGINGGL_API void SetWindowPolicy ( CameraUtilConformWindowPolicy  policy)

Set the window policy to use.

XXX: This is currently used for scene cameras set via SetCameraPath. See comment in SetCameraState for the free cam.

USDIMAGINGGL_API bool TestIntersection ( const GfMatrix4d viewMatrix,
const GfMatrix4d projectionMatrix,
const GfMatrix4d worldToLocalSpace,
const UsdPrim root,
const UsdImagingGLRenderParams params,
GfVec3d outHitPoint,
SdfPath outHitPrimPath = NULL,
SdfPath outHitInstancerPath = NULL,
int *  outHitInstanceIndex = NULL,
int *  outHitElementIndex = NULL 
)

Finds closest point of intersection with a frustum by rendering.

This method uses a PickRender and a customized depth buffer to find an approximate point of intersection by rendering. This is less accurate than implicit methods or rendering with GL_SELECT, but leverages any data already cached in the renderer.

Returns whether a hit occurred and if so, outHitPoint will contain the intersection point in world space (i.e. projectionMatrix and viewMatrix factored back out of the result).


The documentation for this class was generated from the following file: