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
65 HDX_API
66 static
67 HdxTaskControllerSceneIndexRefPtr
68 New(const SdfPath &prefix,
69 const TfToken &rendererPluginName,
70 const AovDescriptorCallback &aovDescriptorCallback,
71 bool gpuEnabled = true);
72
73 HDX_API
75
76 HDX_API
77 HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
78
79 HDX_API
80 SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
81
84
88 HDX_API
89 SdfPathVector GetRenderingTaskPaths() const;
90
93 HDX_API
94 SdfPathVector GetPickingTaskPaths() const;
95
99 HDX_API
100 SdfPath GetRenderBufferPath(const TfToken &aovName) const;
101
104
106 HDX_API
107 void SetCollection(const HdRprimCollection &collection);
108
113 HDX_API
115
120 HDX_API
121 void SetRenderTags(const TfTokenVector &renderTags);
122
125
129 HDX_API
130 void SetRenderOutputs(const TfTokenVector &aovNames);
131
134 HDX_API
135 void SetViewportRenderOutput(TfToken const &aovName);
136
138 HDX_API
139 void SetRenderOutputSettings(TfToken const& aovName,
140 const HdAovDescriptor &desc);
141
143 HDX_API
145
151 HDX_API
152 void SetPresentationOutput(const TfToken &api, const VtValue &framebuffer);
153
156
160 HDX_API
161 void SetLightingState(GlfSimpleLightingContextPtr const& src);
162
165
169 HDX_API
170 void SetRenderBufferSize(const GfVec2i &size);
171
175 HDX_API
176 void SetFraming(const CameraUtilFraming &framing);
177
181 HDX_API
183 const std::optional<CameraUtilConformWindowPolicy> &policy);
184
187 HDX_API
188 void SetCameraPath(const SdfPath &path);
189
193 HDX_API
194 void SetRenderViewport(const GfVec4d &viewport);
195
199 HDX_API
200 void SetFreeCameraMatrices(const GfMatrix4d &viewMatrix,
201 const GfMatrix4d &projectionMatrix);
204 HDX_API
205 void SetFreeCameraClipPlanes(const std::vector<GfVec4d> &clipPlanes);
206
209
211 HDX_API
212 void SetEnableSelection(bool enable);
213
215 HDX_API
216 void SetSelectionColor(const GfVec4f &color);
217
219 HDX_API
221
224 HDX_API
225 void SetSelectionEnableOutline(bool enableOutline);
226
230 HDX_API
231 void SetSelectionOutlineRadius(unsigned int radius);
232
235
237 HDX_API
238 void SetEnableShadows(bool enable);
239
242 HDX_API
243 void SetShadowParams(const HdxShadowTaskParams &params);
244
247
249 HDX_API
251
254
256 HDX_API
258
261
265 HDX_API
266 void SetEnablePresentation(bool enabled);
267
268private:
270 const SdfPath &prefix,
271 const TfToken &rendererPluginName,
272 const AovDescriptorCallback &aovDescriptorCallback,
273 bool gpuEnabled);
274
275 bool _IsForStorm() const;
276
277 void _CreateStormTasks();
278 void _CreateGenericTasks();
279
280 SdfPathVector _GetRenderingTaskPathsForStorm() const;
281 SdfPathVector _GetRenderingTaskPathsForGenericRenderer() const;
282
283 GfVec3i _RenderBufferDimensions() const;
284
285 void _SetRenderOutputs(const TfTokenVector &aovNames);
286 void _SetCameraFramingForTasks();
287 void _SetRenderBufferSize();
288 void _SetSimpleLightTaskParams(GlfSimpleLightingContextPtr const& src);
289 void _SetLights(const GlfSimpleLightVector &lights);
290
291 const SdfPath _prefix;
292 const bool _isForStorm;
293 const AovDescriptorCallback _aovDescriptorCallback;
294 const bool _runGpuAovTasks;
295
296 HdRetainedSceneIndexRefPtr const _retainedSceneIndex;
297
298 // All tasks using HdxRenderTaskParams.
299 SdfPathVector _renderTaskPaths;
300 SdfPath _activeCameraId;
301
302 // Generated renderbuffers
303 TfTokenVector _aovNames;
304 TfToken _viewportAov;
305
306 GfVec2i _renderBufferSize;
307 CameraUtilFraming _framing;
308 std::optional<CameraUtilConformWindowPolicy> _overrideWindowPolicy;
309
310 GfVec4d _viewport;
311
312 friend class _Observer;
313 class _Observer : public HdSceneIndexObserver
314 {
315 public:
316 _Observer(HdxTaskControllerSceneIndex * const owner)
317 : _owner(owner) {}
318
319 HDX_API
320 void PrimsAdded(
321 const HdSceneIndexBase &sender,
322 const AddedPrimEntries &entries) override;
323
324 HDX_API
325 void PrimsRemoved(
326 const HdSceneIndexBase &sender,
327 const RemovedPrimEntries &entries) override;
328
329 HDX_API
330 void PrimsDirtied(
331 const HdSceneIndexBase &sender,
332 const DirtiedPrimEntries &entries) override;
333
334 HDX_API
335 void PrimsRenamed(
336 const HdSceneIndexBase &sender,
337 const RenamedPrimEntries &entries) override;
338 private:
339 HdxTaskControllerSceneIndex * const _owner;
340 };
341 _Observer _observer;
342};
343
344PXR_NAMESPACE_CLOSE_SCOPE
345
346#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:48
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.
static HDX_API HdxTaskControllerSceneIndexRefPtr New(const SdfPath &prefix, const TfToken &rendererPluginName, const AovDescriptorCallback &aovDescriptorCallback, bool gpuEnabled=true)
C'tor.
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) for the object at primPath.
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.
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:147
#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