Loading...
Searching...
No Matches
taskControllerSceneIndex.h
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HDX_TASK_CONTROLLER_SCENE_INDEX_H
8#define PXR_IMAGING_HDX_TASK_CONTROLLER_SCENE_INDEX_H
9
10#include "pxr/pxr.h"
11
12#include "pxr/imaging/hdx/api.h"
13#include "pxr/imaging/hdx/boundingBoxTask.h"
14#include "pxr/imaging/hdx/colorCorrectionTask.h"
15#include "pxr/imaging/hdx/renderSetupTask.h"
16#include "pxr/imaging/hdx/shadowTask.h"
17
18#include "pxr/imaging/hd/aov.h"
19#include "pxr/imaging/hd/renderIndex.h"
20#include "pxr/imaging/hd/sceneIndex.h"
21#include "pxr/imaging/hd/task.h"
22
23#include "pxr/imaging/cameraUtil/framing.h"
25
27
28PXR_NAMESPACE_OPEN_SCOPE
29
30HDX_API
31extern TfEnvSetting<int> HDX_MSAA_SAMPLE_COUNT;
32
35
48// XXX: This API is transitional. At the least, render/picking/selection
49// APIs should be decoupled.
50//
52{
53public:
54 using AovDescriptorCallback =
55 std::function<HdAovDescriptor(const TfToken &name)>;
56
64 {
65 const SdfPath prefix;
66 const AovDescriptorCallback aovDescriptorCallback;
67 bool isForStorm;
68 bool gpuEnabled;
69 };
70
72 HDX_API
73 static
74 HdxTaskControllerSceneIndexRefPtr
75 New(const Parameters& params);
76
77 HDX_API
79
80 HDX_API
81 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
82
83 HDX_API
84 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
85
88
92 HDX_API
93 SdfPathVector GetRenderingTaskPaths() const;
94
97 HDX_API
98 SdfPathVector GetPickingTaskPaths() const;
99
103 HDX_API
104 SdfPath GetRenderBufferPath(const TfToken &aovName) const;
105
108
110 HDX_API
111 void SetCollection(const HdRprimCollection &collection);
112
117 HDX_API
119
124 HDX_API
125 void SetRenderTags(const TfTokenVector &renderTags);
126
129
133 HDX_API
134 void SetRenderOutputs(const TfTokenVector &aovNames);
135
138 HDX_API
139 void SetViewportRenderOutput(TfToken const &aovName);
140
142 HDX_API
143 void SetRenderOutputSettings(TfToken const& aovName,
144 const HdAovDescriptor &desc);
145
147 HDX_API
149
155 HDX_API
156 void SetPresentationOutput(const TfToken &api, const VtValue &framebuffer);
157
160
164 HDX_API
165 void SetLightingState(GlfSimpleLightingContextPtr const& src);
166
169
173 HDX_API
174 void SetRenderBufferSize(const GfVec2i &size);
175
179 HDX_API
180 void SetFraming(const CameraUtilFraming &framing);
181
185 HDX_API
187 const std::optional<CameraUtilConformWindowPolicy> &policy);
188
191 HDX_API
192 void SetCameraPath(const SdfPath &path);
193
197 HDX_API
198 void SetRenderViewport(const GfVec4d &viewport);
199
203 HDX_API
204 void SetFreeCameraMatrices(const GfMatrix4d &viewMatrix,
205 const GfMatrix4d &projectionMatrix);
208 HDX_API
209 void SetFreeCameraClipPlanes(const std::vector<GfVec4d> &clipPlanes);
210
213
215 HDX_API
216 void SetEnableSelection(bool enable);
217
219 HDX_API
220 void SetSelectionColor(const GfVec4f &color);
221
223 HDX_API
225
228 HDX_API
229 void SetSelectionEnableOutline(bool enableOutline);
230
234 HDX_API
235 void SetSelectionOutlineRadius(unsigned int radius);
236
239
241 HDX_API
242 void SetEnableShadows(bool enable);
243
246 HDX_API
247 void SetShadowParams(const HdxShadowTaskParams &params);
248
251
253 HDX_API
255
258
260 HDX_API
262
265
269 HDX_API
270 void SetEnablePresentation(bool enabled);
271
272private:
274
275 bool _IsForStorm() const;
276 bool _RunGpuAovTasks() const;
277
278 void _CreateStormTasks();
279 void _CreateGenericTasks();
280
281 SdfPathVector _GetRenderingTaskPathsForStorm() const;
282 SdfPathVector _GetRenderingTaskPathsForGenericRenderer() const;
283
284 GfVec3i _RenderBufferDimensions() const;
285
286 void _SetRenderOutputs(const TfTokenVector &aovNames);
287 void _SetCameraFramingForTasks();
288 void _SetRenderBufferSize();
289 void _SetSimpleLightTaskParams(GlfSimpleLightingContextPtr const& src);
290 void _SetLights(const GlfSimpleLightVector &lights);
291
292 const Parameters _params;
293
294 HdRetainedSceneIndexRefPtr const _retainedSceneIndex;
295
296 // All tasks using HdxRenderTaskParams.
297 SdfPathVector _renderTaskPaths;
298 SdfPath _activeCameraId;
299
300 // Generated renderbuffers
301 TfTokenVector _aovNames;
302 TfToken _viewportAov;
303
304 GfVec2i _renderBufferSize;
305 CameraUtilFraming _framing;
306 std::optional<CameraUtilConformWindowPolicy> _overrideWindowPolicy;
307
308 GfVec4d _viewport;
309
310 friend class _Observer;
311 class _Observer : public HdSceneIndexObserver
312 {
313 public:
314 _Observer(HdxTaskControllerSceneIndex * const owner)
315 : _owner(owner) {}
316
317 HDX_API
318 void PrimsAdded(
319 const HdSceneIndexBase &sender,
320 const AddedPrimEntries &entries) override;
321
322 HDX_API
323 void PrimsRemoved(
324 const HdSceneIndexBase &sender,
325 const RemovedPrimEntries &entries) override;
326
327 HDX_API
328 void PrimsDirtied(
329 const HdSceneIndexBase &sender,
330 const DirtiedPrimEntries &entries) override;
331
332 HDX_API
333 void PrimsRenamed(
334 const HdSceneIndexBase &sender,
335 const RenamedPrimEntries &entries) override;
336 private:
337 HdxTaskControllerSceneIndex * const _owner;
338 };
339 _Observer _observer;
340};
341
342PXR_NAMESPACE_CLOSE_SCOPE
343
344#endif // PXR_IMAGING_HDX_TASK_CONTROLLER_SCENE_INDEX_H
Framing information.
Definition: framing.h:63
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Basic type for a vector of 2 int components.
Definition: vec2i.h:44
Basic type for a vector of 3 int components.
Definition: vec3i.h:44
Basic type for a vector of 4 double components.
Definition: vec4d.h:46
Basic type for a vector of 4 float components.
Definition: vec4f.h:46
Concrete scene container which can be externally populated and dirtied.
A named, semantic collection of objects.
Abstract interface to scene data.
Definition: sceneIndex.h:54
Observer of scene data.
Manages tasks necessary to render an image (or perform picking) as well as the related render buffers...
HDX_API void SetRenderViewport(const GfVec4d &viewport)
Set the viewport param on tasks.
HDX_API HdAovDescriptor GetRenderOutputSettings(const TfToken &aovName) const
Get parameters for an AOV.
HDX_API void SetFreeCameraClipPlanes(const std::vector< GfVec4d > &clipPlanes)
Set the free camera clip planes.
HDX_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
Returns the paths of all scene index prims located immediately below primPath.
HDX_API void SetRenderParams(const HdxRenderTaskParams &params)
Set the render params.
HDX_API void SetRenderOutputs(const TfTokenVector &aovNames)
Set the list of outputs to be rendered.
HDX_API SdfPathVector GetPickingTaskPaths() const
Obtain paths to tasks managed by the task controller, for picking.
HDX_API void SetRenderOutputSettings(TfToken const &aovName, const HdAovDescriptor &desc)
Set custom parameters for an AOV.
HDX_API void SetColorCorrectionParams(const HdxColorCorrectionTaskParams &params)
Configure color correction by settings params.
HDX_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...
HDX_API void SetSelectionColor(const GfVec4f &color)
Set the selection color.
HDX_API void SetLightingState(GlfSimpleLightingContextPtr const &src)
Set the lighting state for the scene.
HDX_API SdfPathVector GetRenderingTaskPaths() const
Obtain paths to the tasks managed by the task controller, for image generation.
HDX_API void SetSelectionEnableOutline(bool enableOutline)
Set if the selection highlight should be rendered as an outline around the selected objects or as a s...
HDX_API void SetCameraPath(const SdfPath &path)
– Scene camera – Set the camera param on tasks to a USD camera path.
HDX_API void SetFreeCameraMatrices(const GfMatrix4d &viewMatrix, const GfMatrix4d &projectionMatrix)
– Free camera – Set the view and projection matrices for the free camera.
HDX_API void SetViewportRenderOutput(TfToken const &aovName)
Set which output should be rendered to the viewport.
HDX_API void SetFraming(const CameraUtilFraming &framing)
Determines how the filmback of the camera is mapped into the pixels of the render buffer and what pix...
HDX_API void SetRenderTags(const TfTokenVector &renderTags)
Set the "view" opinion of the scenes render tags.
HDX_API void SetRenderBufferSize(const GfVec2i &size)
Set the size of the render buffers backing the AOVs.
HDX_API void SetCollection(const HdRprimCollection &collection)
Set the collection to be rendered.
HDX_API void SetSelectionLocateColor(const GfVec4f &color)
Set the selection locate (over) color.
HDX_API void SetSelectionOutlineRadius(unsigned int radius)
Set the selection outline radius (thickness) in pixels.
HDX_API void SetEnablePresentation(bool enabled)
Enable / disable presenting the render to bound framebuffer.
HDX_API void SetEnableShadows(bool enable)
Turns the shadow task on or off.
HDX_API void SetPresentationOutput(const TfToken &api, const VtValue &framebuffer)
The destination API (e.g., OpenGL, see hgiInterop for details) and framebuffer that the AOVs are pres...
HDX_API void SetShadowParams(const HdxShadowTaskParams &params)
Set the shadow params.
HDX_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override
Returns a pair of (prim type, datasource).
HDX_API SdfPath GetRenderBufferPath(const TfToken &aovName) const
Get the path to the buffer for a rendered output.
HDX_API void SetBBoxParams(const HdxBoundingBoxTaskParams &params)
Set the bounding box params.
HDX_API void SetEnableSelection(bool enable)
Turns the selection task on or off.
static HDX_API HdxTaskControllerSceneIndexRefPtr New(const Parameters &params)
C'tor.
All prims in this scene index are under prefix.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:152
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:58
A bundle of state describing an AOV ("Arbitrary Output Variable") display channel.
Definition: aov.h:30
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:35
BoundingBoxTask parameters.
ColorCorrectionTask parameters.
RenderTask parameters (renderpass state).
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440