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

#include <engine.h>

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)
 Support for batched drawing. More...
 
USDIMAGINGGL_API void Render (const UsdPrim &root, const UsdImagingGLRenderParams &params)
 Entry point for kicking off a render. More...
 
USDIMAGINGGL_API void InvalidateBuffers ()
 Support for batched drawing. More...
 
USDIMAGINGGL_API bool IsConverged () const
 
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)
 
USDIMAGINGGL_API void SetWindowPolicy (CameraUtilConformWindowPolicy policy)
 
USDIMAGINGGL_API void SetCameraPath (SdfPath const &id)
 
USDIMAGINGGL_API void SetCameraState (const GfMatrix4d &viewMatrix, const GfMatrix4d &projectionMatrix)
 
USDIMAGINGGL_API void SetCameraStateFromOpenGL ()
 
Light State
USDIMAGINGGL_API void SetLightingStateFromOpenGL ()
 
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)
 
Selection Highlighting
USDIMAGINGGL_API void SetSelected (SdfPathVector const &paths)
 
USDIMAGINGGL_API void ClearSelected ()
 
USDIMAGINGGL_API void AddSelected (SdfPath const &path, int instanceIndex)
 
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 ()
 
USDIMAGINGGL_API bool ResumeRenderer ()
 
Color Correction
USDIMAGINGGL_API void SetColorCorrectionSettings (TfToken const &id, GfVec2i const &framebufferResolution)
 
Render Statistics
USDIMAGINGGL_API VtDictionary GetRenderStats () const
 

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
 
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
 

Friends

class UsdImagingGL_UnitTestGLDrawing
 Open some protected methods for whitebox testing. More...
 

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)
 
USDIMAGINGGL_API SdfPath GetRprimPathFromPrimId (int primId) const
 
USDIMAGINGGL_API SdfPath GetPrimPathFromPrimIdColor (GfVec4i const &primIdColor, GfVec4i const &instanceIdColor, int *instanceIndexOut=NULL)
 
USDIMAGINGGL_API SdfPath GetPrimPathFromInstanceIndex (const SdfPath &protoRprimId, int protoIndex, int *instancerIndex=NULL, SdfPath *masterCachePath=NULL, SdfPathVector *instanceContext=NULL)
 

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)
 

Detailed Description

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

Definition at line 81 of file engine.h.

Constructor & Destructor Documentation

USDIMAGINGGL_API UsdImagingGLEngine::UsdImagingGLEngine ( )
USDIMAGINGGL_API UsdImagingGLEngine::UsdImagingGLEngine ( const SdfPath rootPath,
const SdfPathVector excludedPaths,
const SdfPathVector invisedPaths = SdfPathVector(),
const SdfPath delegateID = SdfPath::AbsoluteRootPath() 
)
UsdImagingGLEngine::UsdImagingGLEngine ( const UsdImagingGLEngine )
delete
USDIMAGINGGL_API UsdImagingGLEngine::~UsdImagingGLEngine ( )

Member Function Documentation

USDIMAGINGGL_API bool UsdImagingGLEngine::_CanPrepareBatch ( const UsdPrim root,
const UsdImagingGLRenderParams params 
)
protected
static USDIMAGINGGL_API void UsdImagingGLEngine::_ComputeRenderTags ( UsdImagingGLRenderParams const params,
TfTokenVector renderTags 
)
staticprotected
USDIMAGINGGL_API void UsdImagingGLEngine::_DeleteHydraResources ( )
protected
USDIMAGINGGL_API void UsdImagingGLEngine::_Execute ( const UsdImagingGLRenderParams params,
HdTaskSharedPtrVector  tasks 
)
protected
static USDIMAGINGGL_API TfToken UsdImagingGLEngine::_GetDefaultRendererPluginId ( )
staticprotected
USDIMAGINGGL_API HdRenderIndex* UsdImagingGLEngine::_GetRenderIndex ( ) const
protected

Returns the render index of the engine, if any. This is only used for whitebox testing.

static USDIMAGINGGL_API HdxRenderTaskParams UsdImagingGLEngine::_MakeHydraUsdImagingGLRenderParams ( UsdImagingGLRenderParams const params)
staticprotected
USDIMAGINGGL_API void UsdImagingGLEngine::_PostSetTime ( const UsdPrim root,
const UsdImagingGLRenderParams params 
)
protected
USDIMAGINGGL_API void UsdImagingGLEngine::_PreSetTime ( const UsdPrim root,
const UsdImagingGLRenderParams params 
)
protected
static USDIMAGINGGL_API bool UsdImagingGLEngine::_UpdateHydraCollection ( HdRprimCollection collection,
SdfPathVector const roots,
UsdImagingGLRenderParams const params 
)
staticprotected
USDIMAGINGGL_API void UsdImagingGLEngine::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 UsdImagingGLEngine::ClearSelected ( )

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

static int UsdImagingGLEngine::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 UsdImagingGLEngine::GetCurrentRendererId ( ) const

Return the id of the currently used renderer plugin.

USDIMAGINGGL_API SdfPath UsdImagingGLEngine::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 UsdImagingGLEngine::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 UsdImagingGLEngine::GetRendererAovs ( ) const

Return the vector of available renderer AOV settings.

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

Return the user-friendly description of a renderer plugin.

static USDIMAGINGGL_API TfTokenVector UsdImagingGLEngine::GetRendererPlugins ( )
static

Return the vector of available render-graph delegate plugins.

USDIMAGINGGL_API VtValue UsdImagingGLEngine::GetRendererSetting ( TfToken const id) const

Gets a renderer setting's current value.

USDIMAGINGGL_API UsdImagingGLRendererSettingsList UsdImagingGLEngine::GetRendererSettingsList ( ) const

Returns the list of renderer settings.

USDIMAGINGGL_API VtDictionary UsdImagingGLEngine::GetRenderStats ( ) const

Returns render statistics.

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

USDIMAGINGGL_API SdfPath UsdImagingGLEngine::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().

USDIMAGINGGL_API void UsdImagingGLEngine::InvalidateBuffers ( )

Support for batched drawing.

static USDIMAGINGGL_API bool UsdImagingGLEngine::IsColorCorrectionCapable ( )
static

Returns true if the platform is color correction capable.

USDIMAGINGGL_API bool UsdImagingGLEngine::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 UsdImagingGLEngine::IsHydraEnabled ( )
static

Returns true if Hydra is enabled for GL drawing.

USDIMAGINGGL_API bool UsdImagingGLEngine::IsPauseRendererSupported ( ) const

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

UsdImagingGLEngine& UsdImagingGLEngine::operator= ( const UsdImagingGLEngine )
delete
USDIMAGINGGL_API bool UsdImagingGLEngine::PauseRenderer ( )

Pause the renderer.

Returns true if successful.

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

Support for batched drawing.

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

Entry point for kicking off a render.

USDIMAGINGGL_API void UsdImagingGLEngine::RenderBatch ( const SdfPathVector paths,
const UsdImagingGLRenderParams params 
)

Support for batched drawing.

USDIMAGINGGL_API bool UsdImagingGLEngine::ResumeRenderer ( )

Resume the renderer.

Returns true if successful.

USDIMAGINGGL_API void UsdImagingGLEngine::SetCameraPath ( SdfPath const id)

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

USDIMAGINGGL_API void UsdImagingGLEngine::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 UsdImagingGLEngine::SetCameraStateFromOpenGL ( )

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

USDIMAGINGGL_API void UsdImagingGLEngine::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 UsdImagingGLEngine::SetLightingState ( GlfSimpleLightingContextPtr const src)

Copy lighting state from another lighting context.

USDIMAGINGGL_API void UsdImagingGLEngine::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 UsdImagingGLEngine::SetLightingStateFromOpenGL ( )

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

USDIMAGINGGL_API bool UsdImagingGLEngine::SetRendererAov ( TfToken const id)

Set the current renderer AOV to id.

USDIMAGINGGL_API bool UsdImagingGLEngine::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 UsdImagingGLEngine::SetRendererSetting ( TfToken const id,
VtValue const value 
)

Sets a renderer setting's value.

USDIMAGINGGL_API void UsdImagingGLEngine::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 UsdImagingGLEngine::SetRootTransform ( GfMatrix4d const xf)

Sets the root transform.

USDIMAGINGGL_API void UsdImagingGLEngine::SetRootVisibility ( bool  isVisible)

Sets the root visibility.

USDIMAGINGGL_API void UsdImagingGLEngine::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 UsdImagingGLEngine::SetSelectionColor ( GfVec4f const color)

Sets the selection highlighting color.

USDIMAGINGGL_API void UsdImagingGLEngine::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 UsdImagingGLEngine::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).

Friends And Related Function Documentation

friend class UsdImagingGL_UnitTestGLDrawing
friend

Open some protected methods for whitebox testing.

Definition at line 456 of file engine.h.

Member Data Documentation

UsdImagingDelegate* UsdImagingGLEngine::_delegate
protected

Definition at line 509 of file engine.h.

SdfPath const UsdImagingGLEngine::_delegateID
protected

Definition at line 508 of file engine.h.

HdEngine UsdImagingGLEngine::_engine
protected

Definition at line 500 of file engine.h.

SdfPathVector UsdImagingGLEngine::_excludedPrimPaths
protected

Definition at line 521 of file engine.h.

HdRprimCollection UsdImagingGLEngine::_intersectCollection
protected

Definition at line 506 of file engine.h.

SdfPathVector UsdImagingGLEngine::_invisedPrimPaths
protected

Definition at line 522 of file engine.h.

bool UsdImagingGLEngine::_isPopulated
protected

Definition at line 523 of file engine.h.

std::unique_ptr<UsdImagingGLLegacyEngine> UsdImagingGLEngine::_legacyImpl
protected

Definition at line 530 of file engine.h.

GlfSimpleLightingContextRefPtr UsdImagingGLEngine::_lightingContextForOpenGLState
protected

Definition at line 515 of file engine.h.

HdRprimCollection UsdImagingGLEngine::_renderCollection
protected

Definition at line 505 of file engine.h.

TfToken UsdImagingGLEngine::_rendererId
protected

Definition at line 512 of file engine.h.

HdRendererPlugin* UsdImagingGLEngine::_rendererPlugin
protected

Definition at line 511 of file engine.h.

HdRenderIndex* UsdImagingGLEngine::_renderIndex
protected

Definition at line 502 of file engine.h.

SdfPath UsdImagingGLEngine::_rootPath
protected

Definition at line 520 of file engine.h.

GfVec4f UsdImagingGLEngine::_selectionColor
protected

Definition at line 518 of file engine.h.

HdxSelectionTrackerSharedPtr UsdImagingGLEngine::_selTracker
protected

Definition at line 504 of file engine.h.

HdxTaskController* UsdImagingGLEngine::_taskController
protected

Definition at line 513 of file engine.h.


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