10 #ifndef PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H 11 #define PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H 14 #include "pxr/usdImaging/usdImaging/legacyRenderSettingsSceneIndex.h" 15 #include "pxr/usdImaging/usdImagingGL/api.h" 16 #include "pxr/usdImaging/usdImagingGL/version.h" 17 #include "pxr/usdImaging/usdImaging/version.h" 20 #include "pxr/usdImaging/usdImagingGL/rendererSettings.h" 22 #include "pxr/imaging/cameraUtil/conformWindow.h" 24 #include "pxr/imaging/hd/driver.h" 25 #include "pxr/imaging/hd/noticeBatchingSceneIndex.h" 26 #include "pxr/imaging/hd/rprimCollection.h" 27 #include "pxr/imaging/hd/pluginRendererUniqueHandle.h" 29 #include "pxr/imaging/hdx/selectionTracker.h" 30 #include "pxr/imaging/hdx/renderSetupTask.h" 32 #include "pxr/imaging/hgi/hgi.h" 37 #include "pxr/imaging/hgi/hgi.h" 39 #include "pxr/usd/sdf/path.h" 40 #include "pxr/usd/usd/timeCode.h" 52 PXR_NAMESPACE_OPEN_SCOPE
74 namespace UsdImagingGLEngine_Impl
76 using _AppSceneIndicesSharedPtr = std::shared_ptr<struct _AppSceneIndices>;
90 SdfPathVector excludedPaths;
91 SdfPathVector invisedPaths;
135 bool gpuEnabled =
true);
139 const SdfPathVector& excludedPaths,
140 const SdfPathVector& invisedPaths = SdfPathVector(),
141 const SdfPath& sceneDelegateID =
145 const bool gpuEnabled =
true,
146 const bool displayUnloadedPrimsWithBounds =
false,
147 const bool allowAsynchronousSceneProcessing =
false,
148 const bool enableUsdDrawModes =
true);
169 void RenderBatch(
const SdfPathVector& paths,
226 const std::optional<CameraUtilConformWindowPolicy> &policy);
273 GlfSimpleMaterial
const &material,
346 using IntersectionResultVector = std::vector<IntersectionResult>;
380 IntersectionResultVector* outResults);
386 unsigned char const primIdColor[4],
387 unsigned char const instanceIdColor[4],
388 SdfPath *outHitPrimPath = NULL,
389 SdfPath *outHitInstancerPath = NULL,
390 int *outHitInstanceIndex = NULL,
391 HdInstancerContext *outInstancerContext = NULL);
399 SdfPath *outHitPrimPath = NULL,
400 SdfPath *outHitInstancerPath = NULL,
401 int *outHitInstanceIndex = NULL,
402 HdInstancerContext *outInstancerContext = NULL);
408 HdInstancerContext instancerContext;
411 using DecodeResultVector = std::vector<DecodeResult>;
419 using PickIdVector = std::vector<PickId>;
458 SdfPath *outHitPrimPath = NULL,
459 SdfPath *outHitInstancerPath = NULL,
460 int *outHitInstanceIndex = NULL,
461 HdInstancerContext *outInstancerContext = NULL);
679 TfToken const& ocioDisplay = {},
681 TfToken const& ocioColorSpace = {},
747 friend class UsdImagingGL_UnitTestGLDrawing;
751 const SdfPathVector &taskPaths);
754 bool _CanPrepare(
const UsdPrim& root);
764 void _SetActiveRenderSettingsPrimFromStageMetadata(UsdStageWeakPtr stage);
767 void _SetSceneGlobalsCurrentFrame(
UsdTimeCode const &time);
770 void _UpdateDomeLightCameraVisibility();
772 using BBoxVector = std::vector<GfBBox3d>;
776 const BBoxVector& bboxes,
778 float bboxLineDashSize);
784 SdfPathVector
const& roots,
797 static TfToken _GetDefaultRendererPluginId();
812 HdContainerDataSourceHandle
813 _GetSceneIndexCreateArgs(
817 HdContainerDataSourceHandle
818 _GetSceneIndexCreateArgsFromLegacyRenderControl();
822 HdSceneIndexBaseRefPtr
823 _CreateUsdImagingSceneIndices(HdContainerDataSourceHandle
const &inputArgs);
829 _CreateSceneIndexChainAndRenderer(
830 HdContainerDataSourceHandle
const &sceneIndexCreateArgs,
843 HgiUniquePtr _defaultHgi;
848 bool _displayUnloadedPrimsWithBounds;
852 HdxTaskControllerSceneIndexRefPtr _taskControllerSceneIndex;
854 SdfPath const _sceneDelegateId;
856 HdxSelectionTrackerSharedPtr _selTracker;
860 GlfSimpleLightingContextRefPtr _lightingContextForOpenGLState;
864 bool _domeLightCameraVisibility;
867 SdfPathVector _excludedPrimPaths;
868 SdfPathVector _invisedPrimPaths;
872 HdSceneIndexBaseRefPtr _GetTerminalSceneIndex()
const;
879 HdsiApplicationRenderSettingsSceneIndexRefPtr
880 _GetApplicationRenderSettingsSceneIndex()
const;
882 SdfPath _GetSceneIndexPrimPathFromPrimId(
int primId)
const;
884 HdSceneIndexBaseRefPtr
885 _AppendOverridesSceneIndices(
886 HdSceneIndexBaseRefPtr
const &inputScene,
887 HdContainerDataSourceHandle
const &sceneIndexCreateArgs);
889 UsdImagingGLEngine_Impl::_AppSceneIndicesSharedPtr _appSceneIndices;
891 HdSceneIndexBaseRefPtr
892 _CreateExecSceneIndices(
const HdSceneIndexBaseRefPtr &inputScene);
894 bool _CreateSceneIndicesAndRenderer(
898 void _DestroyHydraObjects();
900 SdfPath _GetInstancerForPrim(
const SdfPath &sceneIndexPath)
const;
904 UsdImagingStageSceneIndexInterfaceRefPtr _execStageSceneIndex;
905 HdNoticeBatchingSceneIndexRefPtr _noticeBatchingStageSceneIndex;
906 UsdImagingRootOverridesSceneIndexRefPtr _rootOverridesSceneIndex;
907 UsdImagingLegacyRenderSettingsSceneIndexRefPtr _legacyRenderSettingsSceneIndex;
908 HdsiLegacyDisplayStyleOverrideSceneIndexRefPtr _displayStyleSceneIndex;
909 HdsiPrimTypeAndPathPruningSceneIndexRefPtr _lightPruningSceneIndex;
911 bool _lightPruningSceneIndexEnableSceneLights;
913 UsdImagingSceneIndexRefPtr _usdImagingSceneIndex;
915 HdMergingSceneIndexRefPtr _mergingSceneIndex;
916 HdCachingSceneIndexRefPtr _cachingSceneIndex;
917 HdSceneIndexBaseRefPtr _terminalSceneIndex;
922 HdContainerDataSourceHandle _sceneIndexCreateArgs;
925 std::unique_ptr<UsdImagingDelegate> _sceneDelegate;
927 bool _allowAsynchronousSceneProcessing =
false;
928 bool _enableUsdDrawModes =
true;
943 bool _setActiveRenderSettingsPrimPathCalled =
false;
946 PXR_NAMESPACE_CLOSE_SCOPE
948 #endif // PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H Overrides some data sources on the root prim.
USDIMAGINGGL_API HdCommandDescriptors GetRendererCommandDescriptors() const
Return command deescriptors for commands supported by the active render delegate.
A filtering scene index that lets an application inject a single, authoritative render settings prim ...
USDIMAGINGGL_API bool TestIntersection(const PickParams &pickParams, const GfMatrix4d &viewMatrix, const GfMatrix4d &projectionMatrix, const UsdPrim &root, const UsdImagingGLRenderParams ¶ms, IntersectionResultVector *outResults)
Perform picking by finding the intersection of objects in the scene with a given frustum.
static USDIMAGINGGL_API bool IsColorCorrectionCapable()
Returns true if the platform is color correction capable.
A scene index that caches the prim data source and child prim paths.
USDIMAGINGGL_API void SetRendererSetting(TfToken const &id, VtValue const &value)
Sets a renderer setting's value.
Basic type for a vector of 2 int components.
Standard pointer typedefs.
Result of a batch DecodeIntersection call.
USDIMAGINGGL_API void SetCameraPath(SdfPath const &id)
Scene camera API Set the scene camera path to use for rendering.
USDIMAGINGGL_API TfTokenVector GetRendererAovs() const
Return the vector of available renderer AOV settings.
USDIMAGINGGL_API UsdImagingDelegate * _GetSceneDelegate() const
Get a direct pointer to the scene delegate.
USDIMAGINGGL_API UsdImagingGLRendererSettingsList GetRendererSettingsList() const
Returns the list of renderer settings.
USDIMAGINGGL_API VtValue GetRendererSetting(TfToken const &id) const
Gets a renderer setting's current value.
A map with string keys and VtValue values.
An interface for initial scene indices that populate the Hydra scene with prims and data sources from...
USDIMAGINGGL_API TfToken GetCurrentRendererId() const
Return the id of the currently used renderer plugin.
bool displayUnloadedPrimsWithBounds
displayUnloadedPrimsWithBounds draws bounding boxes for unloaded prims if they have extents/extentsHi...
static USDIMAGINGGL_API TfTokenVector GetRendererPlugins()
Return the vector of available render-graph delegate plugins.
USDIMAGINGGL_API Hgi * GetHgi()
Returns the HGI interface.
Basic type for a vector of 4 double components.
USDIMAGINGGL_API bool RestartRenderer()
Restart the renderer.
USDIMAGINGGL_API HdSelectionSharedPtr _GetSelection() const
USDIMAGINGGL_API void SetActiveRenderPassPrimPath(SdfPath const &)
Set active render pass prim to use to drive rendering.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
USDIMAGINGGL_API void SetPresentationOutput(TfToken const &api, VtValue const &framebuffer)
The destination API (e.g., OpenGL, see hgiInterop for details) and framebuffer that the AOVs are pres...
static USDIMAGINGGL_API SdfPathVector GetAvailableRenderSettingsPrimPaths(UsdPrim const &root)
Utility method to query available render settings prims.
Pointer storage with deletion detection.
bool allowAsynchronousSceneProcessing
allowAsynchronousSceneProcessing indicates to constructed hydra scene indices that asynchronous proce...
GfVec3d hitPoint
Intersection point in world space (that is, given projectionMatrix and viewMatrix are factored out of...
USDIMAGINGGL_API void SetFraming(CameraUtilFraming const &framing)
Determines how the filmback of the camera is mapped into the pixels of the render buffer and what pix...
Merges multiple scenes together.
USDIMAGINGGL_API bool GetGPUEnabled() const
Return if the GPU is enabled and can be used for any rendering tasks.
USDIMAGINGGL_API DecodeResultVector DecodeIntersections(const PickIdVector &pickIds)
Batch version of DecodeIntersection.
USDIMAGINGGL_API bool StopRenderer()
Stop the renderer.
Token for efficient comparison, assignment, and hashing of known strings.
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 t...
USDIMAGINGGL_API void SetWindowPolicy(CameraUtilConformWindowPolicy policy)
Set the window policy to use.
HdDriver represents a device object, commonly a render device, that is owned by the application and p...
GfVec3d hitNormal
Normal at intersection point in world space.
RenderTask parameters (renderpass state).
A handle for HdRendererPlugin also storing the plugin id.
Parameters to construct UsdImagingGLEngine.
USDIMAGINGGL_API void SetRenderBufferSize(GfVec2i const &size)
Set the size of the render buffers baking the AOVs.
USDIMAGINGGL_API void SetSelected(SdfPathVector const &paths)
Sets (replaces) the list of prim paths that should be included in selection highlighting.
Stores a 4x4 matrix of double elements.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
USDIMAGINGGL_API bool IsConverged() const
Returns true if the resulting image is fully converged.
A scene index providing override fallback values for the legacy display style for each prim.
Abstract interface to scene data.
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).
bool gpuEnabled
The gpuEnabled argument determines if this instance will allow Hydra to use the GPU to produce images...
TfToken rendererPluginId
The rendererPluginId argument indicates the renderer plugin that Hydra should use.
Arguments to HdRendererPlugin::IsSupported and CreateRenderer.
USDIMAGINGGL_API std::string GetRendererHgiDisplayName() const
Return the user-friendly name of the Hgi implementation.
HdDriver driver
An HdDriver, containing the Hgi of your choice, can be optionally passed in during construction.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
USDIMAGINGGL_API bool SetRendererAovs(TfTokenVector const &ids)
Set the current renderer AOVs to a list of ids.
USDIMAGINGGL_API HgiTextureHandle GetAovTexture(TfToken const &name) const
Returns an AOV texture handle for the given token.
std::vector< TfToken > TfTokenVector
Convenience types.
SdfPath hitPrimPath
Path to picked gprim on the USD stage.
HdInstancerContext instancerContext
Paths to nested point instancers and instance indices identifying the picked instance.
A named, semantic collection of objects.
A path value used to locate objects in layers or scenegraphs.
USDIMAGINGGL_API VtDictionary GetRenderStats() const
Returns render statistics.
USDIMAGINGGL_API void PrepareBatch(const UsdPrim &root, const UsdImagingGLRenderParams ¶ms)
Support for batched drawing.
USDIMAGINGGL_API bool ResumeRenderer()
Resume the renderer.
USDIMAGINGGL_API void SetOverrideWindowPolicy(const std::optional< CameraUtilConformWindowPolicy > &policy)
Specifies whether to force a window policy when conforming the frustum of the camera to match the dis...
static USDIMAGINGGL_API bool UseUsdImagingSceneIndex()
Returns true if using the UsdImaging scene index.
Basic type for a vector of 4 float components.
USDIMAGINGGL_API bool InvokeRendererCommand(const TfToken &command, const HdCommandArgs &args=HdCommandArgs()) const
Invokes command on the active render delegate.
Hydra Graphics Interface.
Used as an arguments class for various methods in UsdImagingGLEngine.
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 highligh...
USDIMAGINGGL_API void SetActiveRenderSettingsPrimPath(SdfPath const &)
Set active render settings prim to use to drive rendering.
Transitory Hydra-1.0-like API for HdRenderer.
static SDF_API const SdfPath & AbsoluteRootPath()
The absolute path representing the top of the namespace hierarchy.
USDIMAGINGGL_API bool PauseRenderer()
Pause the renderer.
A handle for a renderer that was created by a renderer plugin.
Scene index that populates the "sceneGlobals" data source as modeled by HdSceneGlobalsSchema and prov...
Basic type for a vector of 3 double components.
USDIMAGINGGL_API void SetSelectionColor(GfVec4f const &color)
Sets the selection highlighting color.
A render buffer is a handle to a data resource that can be rendered into, such as a 2d image for a dr...
USDIMAGINGGL_API bool IsStopRendererSupported() const
Query the renderer as to whether it supports stopping and restarting.
USDIMAGINGGL_API void SetColorCorrectionSettings(TfToken const &ccType, TfToken const &ocioDisplay={}, TfToken const &ocioView={}, TfToken const &ocioColorSpace={}, TfToken const &ocioLook={})
Set ccType to one of the HdxColorCorrectionTokens: {disabled, sRGB, openColorIO}.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
USDIMAGINGGL_API void ClearSelected()
Clear the list of prim paths that should be included in selection highlighting.
USDIMAGINGGL_API void SetRootVisibility(bool isVisible)
Sets the root visibility.
static USDIMAGINGGL_API std::string GetRendererDisplayName(TfToken const &id)
Return the user-friendly name of a renderer plugin.
USDIMAGINGGL_API void SetEnablePresentation(bool enabled)
Enable / disable presenting the render to bound framebuffer.
Scene Index that prunes prims if its type is in a given list and its path matches a given predicate.
USDIMAGINGGL_API SdfPath GetActiveRenderPassPrimPath() const
Returns the active render pass prim path by querying the terminal scene index.
USDIMAGINGGL_API bool SetRendererAov(TfToken const &id)
Set the current renderer AOV to id.
The UsdImagingGLEngine is the main entry point API for rendering USD scenes.
USDIMAGINGGL_API void SetLightingState(GlfSimpleLightingContextPtr const &src)
Copy lighting state from another lighting context.
USDIMAGINGGL_API void Render(const UsdPrim &root, const UsdImagingGLRenderParams ¶ms)
Entry point for kicking off a render.
bool enableUsdDrawModes
enableUsdDrawModes enables the UsdGeomModelAPI draw mode feature.
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
USDIMAGINGGL_API void SetRootTransform(GfMatrix4d const &xf)
Sets the root transform.
TfToken resolveMode
Resolve mode.
Manages tasks necessary to render an image (or perform picking) as well as the related render buffers...
USDIMAGINGGL_API SdfPath GetActiveRenderSettingsPrimPath() const
Returns the active render settings prim path by querying the terminal scene index.
USDIMAGINGGL_API bool PollForAsynchronousUpdates() const
If allowAsynchronousSceneProcessing is true within the Parameters provided to the UsdImagingGLEngine ...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
A scene index encapsulating the chain of scene indices (resolving, e.g., USD native instancing) that ...
USDIMAGINGGL_API bool IsPauseRendererSupported() const
Query the renderer as to whether it supports pausing and resuming.
USDIMAGINGGL_API bool DecodeIntersection(unsigned char const primIdColor[4], unsigned char const instanceIdColor[4], SdfPath *outHitPrimPath=NULL, SdfPath *outHitInstancerPath=NULL, int *outHitInstanceIndex=NULL, HdInstancerContext *outInstancerContext=NULL)
Decodes a pick result given hydra prim ID/instance ID (like you'd get from an ID render),...
USDIMAGINGGL_API bool SetRendererPlugin(TfToken const &id)
Set the current render-graph delegate to id.
USDIMAGINGGL_API HdRenderBuffer * GetAovRenderBuffer(TfToken const &name) const
Returns the AOV render buffer for the given token.