engine.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 
9 
10 #ifndef PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H
11 #define PXR_USD_IMAGING_USD_IMAGING_GL_ENGINE_H
12 
13 #include "pxr/pxr.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"
18 
20 #include "pxr/usdImaging/usdImagingGL/rendererSettings.h"
21 
22 #include "pxr/imaging/cameraUtil/conformWindow.h"
23 
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"
28 
29 #include "pxr/imaging/hdx/selectionTracker.h"
30 #include "pxr/imaging/hdx/renderSetupTask.h"
31 
32 #include "pxr/imaging/hgi/hgi.h"
33 
36 
37 #include "pxr/imaging/hgi/hgi.h"
38 
39 #include "pxr/usd/sdf/path.h"
40 #include "pxr/usd/usd/timeCode.h"
41 
42 #include "pxr/base/gf/frustum.h"
43 #include "pxr/base/gf/matrix4d.h"
44 #include "pxr/base/gf/vec4d.h"
45 #include "pxr/base/gf/vec4f.h"
46 #include "pxr/base/gf/vec4i.h"
47 
48 #include "pxr/base/vt/dictionary.h"
49 
51 
52 PXR_NAMESPACE_OPEN_SCOPE
53 
54 class UsdPrim;
55 class UsdImagingDelegate;
58 
59 TF_DECLARE_WEAK_AND_REF_PTRS(GlfSimpleLightingContext);
71 
72 using UsdStageWeakPtr = TfWeakPtr<class UsdStage>;
73 
74 namespace UsdImagingGLEngine_Impl
75 {
76  using _AppSceneIndicesSharedPtr = std::shared_ptr<struct _AppSceneIndices>;
77 }
78 
84 {
85 public:
87  struct Parameters
88  {
90  SdfPathVector excludedPaths;
91  SdfPathVector invisedPaths;
92  SdfPath sceneDelegateID = SdfPath::AbsoluteRootPath();
103  bool gpuEnabled = true;
113  bool enableUsdDrawModes = true;
114  };
115 
116  // ---------------------------------------------------------------------
119  // ---------------------------------------------------------------------
120 
121  USDIMAGINGGL_API
122  UsdImagingGLEngine(const Parameters &params);
123 
132  USDIMAGINGGL_API
133  UsdImagingGLEngine(const HdDriver& driver = HdDriver(),
134  const TfToken& rendererPluginId = TfToken(),
135  bool gpuEnabled = true);
136 
137  USDIMAGINGGL_API
138  UsdImagingGLEngine(const SdfPath& rootPath,
139  const SdfPathVector& excludedPaths,
140  const SdfPathVector& invisedPaths = SdfPathVector(),
141  const SdfPath& sceneDelegateID =
143  const HdDriver& driver = HdDriver(),
144  const TfToken& rendererPluginId = TfToken(),
145  const bool gpuEnabled = true,
146  const bool displayUnloadedPrimsWithBounds = false,
147  const bool allowAsynchronousSceneProcessing = false,
148  const bool enableUsdDrawModes = true);
149 
150  // Disallow copies
151  UsdImagingGLEngine(const UsdImagingGLEngine&) = delete;
152  UsdImagingGLEngine& operator=(const UsdImagingGLEngine&) = delete;
153 
154  USDIMAGINGGL_API
156 
158 
159  // ---------------------------------------------------------------------
162  // ---------------------------------------------------------------------
163 
165  USDIMAGINGGL_API
166  void PrepareBatch(const UsdPrim& root,
167  const UsdImagingGLRenderParams& params);
168  USDIMAGINGGL_API
169  void RenderBatch(const SdfPathVector& paths,
170  const UsdImagingGLRenderParams& params);
171 
173  USDIMAGINGGL_API
174  void Render(const UsdPrim& root,
175  const UsdImagingGLRenderParams &params);
176 
179  USDIMAGINGGL_API
180  bool IsConverged() const;
181 
183 
184  // ---------------------------------------------------------------------
187  // ---------------------------------------------------------------------
188 
190  USDIMAGINGGL_API
191  void SetRootTransform(GfMatrix4d const& xf);
192 
194  USDIMAGINGGL_API
195  void SetRootVisibility(bool isVisible);
196 
198 
199  // ---------------------------------------------------------------------
202  // ---------------------------------------------------------------------
203 
206  USDIMAGINGGL_API
207  void SetCameraPath(SdfPath const& id);
208 
212  USDIMAGINGGL_API
213  void SetFraming(CameraUtilFraming const& framing);
214 
224  USDIMAGINGGL_API
226  const std::optional<CameraUtilConformWindowPolicy> &policy);
227 
231  USDIMAGINGGL_API
232  void SetRenderBufferSize(GfVec2i const& size);
233 
239  USDIMAGINGGL_API
240  void SetRenderViewport(GfVec4d const& viewport);
241 
245  USDIMAGINGGL_API
246  void SetWindowPolicy(CameraUtilConformWindowPolicy policy);
247 
252  USDIMAGINGGL_API
253  void SetCameraState(const GfMatrix4d& viewMatrix,
254  const GfMatrix4d& projectionMatrix);
255 
257 
258  // ---------------------------------------------------------------------
261  // ---------------------------------------------------------------------
262 
264  USDIMAGINGGL_API
265  void SetLightingState(GlfSimpleLightingContextPtr const &src);
266 
271  USDIMAGINGGL_API
272  void SetLightingState(GlfSimpleLightVector const &lights,
273  GlfSimpleMaterial const &material,
274  GfVec4f const &sceneAmbient);
275 
277 
278  // ---------------------------------------------------------------------
281  // ---------------------------------------------------------------------
282 
286  USDIMAGINGGL_API
287  void SetSelected(SdfPathVector const& paths);
288 
291  USDIMAGINGGL_API
292  void ClearSelected();
293 
297  USDIMAGINGGL_API
298  void AddSelected(SdfPath const &path, int instanceIndex);
299 
301  USDIMAGINGGL_API
302  void SetSelectionColor(GfVec4f const& color);
303 
305 
306  // ---------------------------------------------------------------------
309  // ---------------------------------------------------------------------
310 
324  {
343  HdInstancerContext instancerContext;
344  };
345 
346  using IntersectionResultVector = std::vector<IntersectionResult>;
347 
349  struct PickParams
350  {
365  };
366 
373  USDIMAGINGGL_API
374  bool TestIntersection(
375  const PickParams& pickParams,
376  const GfMatrix4d& viewMatrix,
377  const GfMatrix4d& projectionMatrix,
378  const UsdPrim& root,
379  const UsdImagingGLRenderParams& params,
380  IntersectionResultVector* outResults);
381 
384  USDIMAGINGGL_API
385  bool DecodeIntersection(
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);
392 
395  USDIMAGINGGL_API
396  bool DecodeIntersection(
397  int primIdx,
398  int instanceIdx,
399  SdfPath *outHitPrimPath = NULL,
400  SdfPath *outHitInstancerPath = NULL,
401  int *outHitInstanceIndex = NULL,
402  HdInstancerContext *outInstancerContext = NULL);
403 
406  {
407  SdfPath primPath;
408  HdInstancerContext instancerContext;
409  };
410 
411  using DecodeResultVector = std::vector<DecodeResult>;
412 
413  struct PickId
414  {
415  int primId;
416  int instanceId;
417  };
418 
419  using PickIdVector = std::vector<PickId>;
420 
427  USDIMAGINGGL_API
428  DecodeResultVector DecodeIntersections(const PickIdVector& pickIds);
429 
450  USDIMAGINGGL_API
451  bool TestIntersection(
452  const GfMatrix4d &viewMatrix,
453  const GfMatrix4d &projectionMatrix,
454  const UsdPrim& root,
455  const UsdImagingGLRenderParams &params,
456  GfVec3d *outHitPoint,
457  GfVec3d *outHitNormal,
458  SdfPath *outHitPrimPath = NULL,
459  SdfPath *outHitInstancerPath = NULL,
460  int *outHitInstanceIndex = NULL,
461  HdInstancerContext *outInstancerContext = NULL);
462 
464 
465  // ---------------------------------------------------------------------
468  // ---------------------------------------------------------------------
469 
471  USDIMAGINGGL_API
473 
475  USDIMAGINGGL_API
476  static std::string GetRendererDisplayName(TfToken const &id);
477 
481  USDIMAGINGGL_API
482  std::string GetRendererHgiDisplayName() const;
483 
485  USDIMAGINGGL_API
486  bool GetGPUEnabled() const;
487 
489  USDIMAGINGGL_API
491 
494  USDIMAGINGGL_API
495  bool SetRendererPlugin(TfToken const &id);
496 
498 
499  // ---------------------------------------------------------------------
502  // ---------------------------------------------------------------------
503 
505  USDIMAGINGGL_API
507 
509  USDIMAGINGGL_API
510  bool SetRendererAov(TfToken const& id);
511 
513  USDIMAGINGGL_API
514  bool SetRendererAovs(TfTokenVector const &ids);
515 
517  USDIMAGINGGL_API
518  HgiTextureHandle GetAovTexture(TfToken const& name) const;
519 
521  USDIMAGINGGL_API
522  HdRenderBuffer* GetAovRenderBuffer(TfToken const& name) const;
523 
524  // ---------------------------------------------------------------------
527  // ---------------------------------------------------------------------
528 
530  USDIMAGINGGL_API
531  UsdImagingGLRendererSettingsList GetRendererSettingsList() const;
532 
534  USDIMAGINGGL_API
535  VtValue GetRendererSetting(TfToken const& id) const;
536 
538  USDIMAGINGGL_API
539  void SetRendererSetting(TfToken const& id,
540  VtValue const& value);
541 
543 
544  // ---------------------------------------------------------------------
548  // ---------------------------------------------------------------------
549 
552  USDIMAGINGGL_API
554 
557  USDIMAGINGGL_API
559 
561  USDIMAGINGGL_API
562  static SdfPathVector
564 
566  USDIMAGINGGL_API
567  void SetActiveRenderPassPrimPath(SdfPath const &);
568 
570  USDIMAGINGGL_API
572 
573 
575 
576  // ---------------------------------------------------------------------
579  // ---------------------------------------------------------------------
580 
584  USDIMAGINGGL_API
585  void SetEnablePresentation(bool enabled);
586 
592  USDIMAGINGGL_API
593  void SetPresentationOutput(TfToken const &api, VtValue const &framebuffer);
594 
596 
597  // ---------------------------------------------------------------------
600  // ---------------------------------------------------------------------
601 
605  USDIMAGINGGL_API
606  HdCommandDescriptors GetRendererCommandDescriptors() const;
607 
613  USDIMAGINGGL_API
615  const TfToken &command,
616  const HdCommandArgs &args = HdCommandArgs()) const;
617 
618  // ---------------------------------------------------------------------
621  // ---------------------------------------------------------------------
622 
624  USDIMAGINGGL_API
625  bool IsPauseRendererSupported() const;
626 
630  USDIMAGINGGL_API
631  bool PauseRenderer();
632 
636  USDIMAGINGGL_API
637  bool ResumeRenderer();
638 
640  USDIMAGINGGL_API
641  bool IsStopRendererSupported() const;
642 
646  USDIMAGINGGL_API
647  bool StopRenderer();
648 
652  USDIMAGINGGL_API
653  bool RestartRenderer();
654 
656 
657  // ---------------------------------------------------------------------
660  // ---------------------------------------------------------------------
661 
676  USDIMAGINGGL_API
678  TfToken const& ccType,
679  TfToken const& ocioDisplay = {},
680  TfToken const& ocioView = {},
681  TfToken const& ocioColorSpace = {},
682  TfToken const& ocioLook = {});
683 
685 
687  USDIMAGINGGL_API
688  static bool IsColorCorrectionCapable();
689 
690  // ---------------------------------------------------------------------
693  // ---------------------------------------------------------------------
694 
700  USDIMAGINGGL_API
702 
704 
705  // ---------------------------------------------------------------------
708  // ---------------------------------------------------------------------
709 
712  USDIMAGINGGL_API
713  Hgi* GetHgi();
714 
716 
717  // ---------------------------------------------------------------------
720  // ---------------------------------------------------------------------
721 
728  USDIMAGINGGL_API
729  bool PollForAsynchronousUpdates() const;
730 
732 
733 
734  // ---------------------------------------------------------------------
737  // ---------------------------------------------------------------------
738 
740  USDIMAGINGGL_API
741  static bool UseUsdImagingSceneIndex();
743 
744 protected:
745 
747  friend class UsdImagingGL_UnitTestGLDrawing;
748 
749  USDIMAGINGGL_API
750  void _Execute(const UsdImagingGLRenderParams &params,
751  const SdfPathVector &taskPaths);
752 
753  USDIMAGINGGL_API
754  bool _CanPrepare(const UsdPrim& root);
755  USDIMAGINGGL_API
756  void _PreSetTime(const UsdImagingGLRenderParams& params);
757  USDIMAGINGGL_API
758  void _PostSetTime(const UsdImagingGLRenderParams& params);
759 
760  USDIMAGINGGL_API
761  void _PrepareRender(const UsdImagingGLRenderParams& params);
762 
763  USDIMAGINGGL_API
764  void _SetActiveRenderSettingsPrimFromStageMetadata(UsdStageWeakPtr stage);
765 
766  USDIMAGINGGL_API
767  void _SetSceneGlobalsCurrentFrame(UsdTimeCode const &time);
768 
769  USDIMAGINGGL_API
770  void _UpdateDomeLightCameraVisibility();
771 
772  using BBoxVector = std::vector<GfBBox3d>;
773 
774  USDIMAGINGGL_API
775  void _SetBBoxParams(
776  const BBoxVector& bboxes,
777  const GfVec4f& bboxLineColor,
778  float bboxLineDashSize);
779 
780  // Create a hydra collection given root paths and render params.
781  // Returns true if the collection was updated.
782  USDIMAGINGGL_API
783  static bool _UpdateHydraCollection(HdRprimCollection *collection,
784  SdfPathVector const& roots,
785  UsdImagingGLRenderParams const& params);
786  USDIMAGINGGL_API
787  static HdxRenderTaskParams _MakeHydraUsdImagingGLRenderParams(
788  UsdImagingGLRenderParams const& params);
789  USDIMAGINGGL_API
790  static void _ComputeRenderTags(UsdImagingGLRenderParams const& params,
791  TfTokenVector *renderTags);
792 
793  USDIMAGINGGL_API
794  SdfPath _ComputeControllerPath(const TfToken &pluginId);
795 
796  USDIMAGINGGL_API
797  static TfToken _GetDefaultRendererPluginId();
798 
804  USDIMAGINGGL_API
806 
808  USDIMAGINGGL_API
809  HdSelectionSharedPtr _GetSelection() const;
810 
811  USDIMAGINGGL_API
812  HdContainerDataSourceHandle
813  _GetSceneIndexCreateArgs(
814  HdRendererPluginHandle const &plugin);
815 
816  USDIMAGINGGL_API
817  HdContainerDataSourceHandle
818  _GetSceneIndexCreateArgsFromLegacyRenderControl();
819 
820  // Create UsdImagingStageSceneIndex and subsequent scene indices.
821  USDIMAGINGGL_API
822  HdSceneIndexBaseRefPtr
823  _CreateUsdImagingSceneIndices(HdContainerDataSourceHandle const &inputArgs);
824 
825  // Create the merging scene index and all subsequent filtering scene index
826  // and the renderer fed by those.
827  USDIMAGINGGL_API
828  void
829  _CreateSceneIndexChainAndRenderer(
830  HdContainerDataSourceHandle const &sceneIndexCreateArgs,
831  HdRendererPluginHandle const &plugin,
832  const HdRendererCreateArgsSchema &rendererCreateArgs);
833 
834  Hgi *
835  _GetOrCreateHgi();
836 
837 protected:
838  // The Hgi used by the renderer.
839  // It is either provided by the user or the Hgi::CreatePlatformDefaultHgi().
840  Hgi * _hgi;
841 
842  // Result of Hgi::CreatePlatformDefaultHgi() if needed.
843  HgiUniquePtr _defaultHgi;
844 
845  VtValue _userFramebuffer;
846 
847 protected:
848  bool _displayUnloadedPrimsWithBounds;
849  bool _gpuEnabled;
850 
851  HdPluginRendererUniqueHandle _renderer; // Hydra 2.0
852  HdxTaskControllerSceneIndexRefPtr _taskControllerSceneIndex; // Hydra 2.0
853 
854  SdfPath const _sceneDelegateId;
855 
856  HdxSelectionTrackerSharedPtr _selTracker; // Hydra 1.0
857  HdRprimCollection _renderCollection;
858  HdRprimCollection _intersectCollection;
859 
860  GlfSimpleLightingContextRefPtr _lightingContextForOpenGLState;
861 
862  // Data we want to live across render plugin switches:
863  GfVec4f _selectionColor;
864  bool _domeLightCameraVisibility;
865 
866  SdfPath _rootPath;
867  SdfPathVector _excludedPrimPaths;
868  SdfPathVector _invisedPrimPaths;
869  bool _isPopulated;
870 
871 private:
872  HdSceneIndexBaseRefPtr _GetTerminalSceneIndex() const;
873 
874  HdLegacyRenderControlInterface * _GetLegacyRenderControl() const;
875 
876  // The application-managed render settings scene index, if the renderer
877  // advertised render setting descriptors (the Hydra 2.0 path). Null
878  // otherwise (in which case callers fall back to the legacy render control).
879  HdsiApplicationRenderSettingsSceneIndexRefPtr
880  _GetApplicationRenderSettingsSceneIndex() const;
881 
882  SdfPath _GetSceneIndexPrimPathFromPrimId(int primId) const;
883 
884  HdSceneIndexBaseRefPtr
885  _AppendOverridesSceneIndices(
886  HdSceneIndexBaseRefPtr const &inputScene,
887  HdContainerDataSourceHandle const &sceneIndexCreateArgs);
888 
889  UsdImagingGLEngine_Impl::_AppSceneIndicesSharedPtr _appSceneIndices;
890 
891  HdSceneIndexBaseRefPtr
892  _CreateExecSceneIndices(const HdSceneIndexBaseRefPtr &inputScene);
893 
894  bool _CreateSceneIndicesAndRenderer(
895  HdRendererPluginHandle const &plugin,
896  const HdRendererCreateArgsSchema &rendererCreateArgs);
897 
898  void _DestroyHydraObjects();
899 
900  SdfPath _GetInstancerForPrim(const SdfPath &sceneIndexPath) const;
901 
902  // Note that we'll only ever use one of _sceneIndex/_sceneDelegate
903  // at a time.
904  UsdImagingStageSceneIndexInterfaceRefPtr _execStageSceneIndex;
905  HdNoticeBatchingSceneIndexRefPtr _noticeBatchingStageSceneIndex;
906  UsdImagingRootOverridesSceneIndexRefPtr _rootOverridesSceneIndex;
907  UsdImagingLegacyRenderSettingsSceneIndexRefPtr _legacyRenderSettingsSceneIndex;
908  HdsiLegacyDisplayStyleOverrideSceneIndexRefPtr _displayStyleSceneIndex;
909  HdsiPrimTypeAndPathPruningSceneIndexRefPtr _lightPruningSceneIndex;
910  // State of the _lightPruningSceneIndex.
911  bool _lightPruningSceneIndexEnableSceneLights;
912 
913  UsdImagingSceneIndexRefPtr _usdImagingSceneIndex;
914 
915  HdMergingSceneIndexRefPtr _mergingSceneIndex;
916  HdCachingSceneIndexRefPtr _cachingSceneIndex;
917  HdSceneIndexBaseRefPtr _terminalSceneIndex;
918 
919  // Create-args container data source returned by the renderer plugin
920  // (see HdRendererPlugin::GetSceneIndexCreateArgs). Retained so that
921  // GetRendererSettingsList() can source the render settings from it.
922  HdContainerDataSourceHandle _sceneIndexCreateArgs;
923 
924  /* Hydra 1.0 */
925  std::unique_ptr<UsdImagingDelegate> _sceneDelegate;
926 
927  bool _allowAsynchronousSceneProcessing = false;
928  bool _enableUsdDrawModes = true;
929 
930  /* Hydra 1.0 */
931  // A flag indicating whether the active render pass prim path
932  // on the scene globals scene index was set.
933  //
934  // Explanation: The active render passs prim path can be set by a
935  // client of UsdImagingGLEngine through SetActiveRenderSettingsPrimPath
936  // and or by reading the stage metadata when using the UsdImagingDelegate.
937  //
938  // Thus, we could get into a situation where a user explicitly sets it
939  // through the UsdImagingGLEngine API first and then we wrongfully change
940  // it later by reading the stage metadata.
941  //
942  // This flag is here to prevent this.
943  bool _setActiveRenderSettingsPrimPathCalled = false;
944 };
945 
946 PXR_NAMESPACE_CLOSE_SCOPE
947 
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 &params, 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.
Definition: vec2i.h:43
Standard pointer typedefs.
Result of a batch DecodeIntersection call.
Definition: engine.h:405
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.
Definition: dictionary.h:52
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...
Definition: engine.h:106
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.
Definition: vec4d.h:47
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.
Definition: declarePtrs.h:72
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.
Definition: refBase.h:23
bool allowAsynchronousSceneProcessing
allowAsynchronousSceneProcessing indicates to constructed hydra scene indices that asynchronous proce...
Definition: engine.h:110
GfVec3d hitPoint
Intersection point in world space (that is, given projectionMatrix and viewMatrix are factored out of...
Definition: engine.h:328
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.
Definition: token.h:80
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...
Definition: driver.h:23
GfVec3d hitNormal
Normal at intersection point in world space.
Definition: engine.h:330
RenderTask parameters (renderpass state).
A handle for HdRendererPlugin also storing the plugin id.
Parameters to construct UsdImagingGLEngine.
Definition: engine.h:87
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.
Definition: matrix4d.h:70
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:73
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.
Definition: sceneIndex.h:54
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...
Definition: engine.h:103
TfToken rendererPluginId
The rendererPluginId argument indicates the renderer plugin that Hydra should use.
Definition: engine.h:100
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.
Definition: engine.h:96
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:116
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.
Definition: token.h:489
SdfPath hitPrimPath
Path to picked gprim on the USD stage.
Definition: engine.h:333
HdInstancerContext instancerContext
Paths to nested point instancers and instance indices identifying the picked instance.
Definition: engine.h:343
A named, semantic collection of objects.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
USDIMAGINGGL_API VtDictionary GetRenderStats() const
Returns render statistics.
USDIMAGINGGL_API void PrepareBatch(const UsdPrim &root, const UsdImagingGLRenderParams &params)
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.
Definition: vec4f.h:47
USDIMAGINGGL_API bool InvokeRendererCommand(const TfToken &command, const HdCommandArgs &args=HdCommandArgs()) const
Invokes command on the active render delegate.
Hydra Graphics Interface.
Definition: hgi.h:94
Used as an arguments class for various methods in UsdImagingGLEngine.
Definition: renderParams.h:56
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.
Definition: vec3d.h:46
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...
Definition: renderBuffer.h:32
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.
Definition: declarePtrs.h:58
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.
Definition: engine.h:83
USDIMAGINGGL_API void SetLightingState(GlfSimpleLightingContextPtr const &src)
Copy lighting state from another lighting context.
USDIMAGINGGL_API void Render(const UsdPrim &root, const UsdImagingGLRenderParams &params)
Entry point for kicking off a render.
bool enableUsdDrawModes
enableUsdDrawModes enables the UsdGeomModelAPI draw mode feature.
Definition: engine.h:113
The primary translation layer between the Hydra (Hd) core and the Usd scene graph.
Definition: delegate.h:67
USDIMAGINGGL_API void SetRootTransform(GfMatrix4d const &xf)
Sets the root transform.
TfToken resolveMode
Resolve mode.
Definition: engine.h:364
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...
Definition: value.h:89
A scene index encapsulating the chain of scene indices (resolving, e.g., USD native instancing) that ...
Definition: sceneIndex.h:36
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.
Framing information.
Definition: framing.h:62