13 #include <pxr/base/plug/registry.h>
14 #include <pxr/imaging/hd/dirtyList.h>
15 #include <pxr/imaging/hd/renderDelegate.h>
16 #include <pxr/imaging/hd/renderIndex.h>
17 #include <pxr/imaging/hd/rprimCollection.h>
18 #include <pxr/imaging/hd/task.h>
19 #include <pxr/usd/usd/stage.h>
20 #include <pxr/usd/usdGeom/camera.h>
21 #include <pxr/usd/usdGeom/metrics.h>
22 #include <pxr/usdImaging/usdImaging/delegate.h>
30 : HdTask(
id),
tags({HdRenderTagTokens->geometry, HdRenderTagTokens->render})
35 void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits)
override
39 void Prepare(HdTaskContext *ctx, HdRenderIndex *render_index)
override
58 PlugRegistry::GetInstance().RegisterPlugins(
path_get(
"usd"));
61 UsdStageRefPtr
stage = UsdStage::Open(filepath);
63 fprintf(stderr,
"%s read error\n", filepath);
68 SdfPath root_path = SdfPath::AbsoluteRootPath();
69 SdfPath task_path(
"/_hdCycles/DummyHdTask");
72 HdRenderSettingsMap settings_map;
73 settings_map.insert(std::make_pair(HdCyclesRenderSettingsTokens->stageMetersPerUnit,
74 VtValue(UsdGeomGetStageMetersPerUnit(
stage))));
79 unique_ptr<HdRenderIndex> render_index(HdRenderIndex::New(&render_delegate, {}));
80 unique_ptr<UsdImagingDelegate> scene_delegate = make_unique<UsdImagingDelegate>(
81 render_index.get(), root_path);
84 HdRprimCollection collection(HdTokens->geometry, HdReprSelector(HdReprTokens->smoothHull));
85 collection.SetRootPath(root_path);
87 render_index->InsertTask<
DummyHdTask>(scene_delegate.get(), task_path);
89 #if PXR_VERSION < 2111
90 HdDirtyListSharedPtr dirty_list = std::make_shared<HdDirtyList>(collection,
91 *(render_index.get()));
92 render_index->EnqueuePrimsToSync(dirty_list, collection);
94 render_index->EnqueueCollectionToSync(collection);
98 const UsdPrim &stage_root =
stage->GetPseudoRoot();
99 scene_delegate->Populate(stage_root.GetStage()->GetPrimAtPath(root_path), {});
102 HdTaskContext task_context;
103 HdTaskSharedPtrVector tasks;
104 tasks.push_back(render_index->GetTask(task_path));
106 render_index->SyncAll(&tasks, &task_context);
112 for (UsdPrim
const &prim :
stage->Traverse()) {
113 if (prim.IsA<UsdGeomCamera>()) {
114 HdSprim *sprim = render_index->GetSprim(HdPrimTypeTokens->camera, prim.GetPath());
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
const TfTokenVector & GetRenderTags() const override
void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
void Execute(HdTaskContext *ctx) override
void Prepare(HdTaskContext *ctx, HdRenderIndex *render_index) override
DummyHdTask(HdSceneDelegate *delegate, SdfPath const &id)
PXR_NS::HdRenderParam * GetRenderParam() const override
void CommitResources(PXR_NS::HdChangeTracker *tracker) override
static void read(Session *session, const char *filepath, const bool use_camera=true)
#define HDCYCLES_NAMESPACE_CLOSE_SCOPE
string path_get(const string &sub)