Loading...
Searching...
No Matches
volume.h
1//
2// Copyright 2019 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef EXT_RMANPKG_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_VOLUME_H
8#define EXT_RMANPKG_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_VOLUME_H
9
10#include "pxr/pxr.h"
11#include "hdPrman/gprim.h"
12#include "pxr/imaging/hd/field.h"
13#include "pxr/imaging/hd/volume.h"
14
15#include "Riley.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
19class HdPrman_Field final : public HdField
20{
21public:
22 HdPrman_Field(TfToken const& typeId, SdfPath const& id);
23 void Sync(HdSceneDelegate *sceneDelegate,
24 HdRenderParam *renderParam,
25 HdDirtyBits *dirtyBits) override;
26 void Finalize(HdRenderParam *renderParam) override;
27 HdDirtyBits GetInitialDirtyBitsMask() const override;
28private:
29 TfToken const _typeId;
30};
31
32class HdPrman_Volume final : public HdPrman_Gprim<HdVolume>
33{
34public:
35 using BASE = HdPrman_Gprim<HdVolume>;
36public:
37
38 HF_MALLOC_TAG_NEW("new HdPrman_Volume");
39
40 HdPrman_Volume(SdfPath const& id, const bool isMeshLight);
41
43 void Sync(HdSceneDelegate *sceneDelegate,
44 HdRenderParam *renderParam,
45 HdDirtyBits *dirtyBits,
46 TfToken const &reprToken) override;
47
48 void Finalize(HdRenderParam *renderParam) override;
49
50 HdDirtyBits GetInitialDirtyBitsMask() const override;
51
69 using HdPrman_VolumeTypeEmitter =
70 void (*)(HdSceneDelegate *sceneDelegate,
71 SdfPath const& id,
72 HdVolumeFieldDescriptorVector const& fields,
73 RtPrimVarList* primvars);
74
78 static bool AddVolumeTypeEmitter(TfToken const& fieldPrimType,
79 HdPrman_VolumeTypeEmitter emitterFunc,
80 bool overrideExisting = false);
81
83 enum FieldType {
84 FloatType = 0,
85 IntType,
86 Float2Type,
87 Int2Type,
88 Float3Type,
89 Int3Type,
90 ColorType,
91 PointType,
92 NormalType,
93 VectorType,
94 Float4Type,
95 MatrixType,
96 StringType
97 };
98
100 static void DeclareFieldPrimvar(RtPrimVarList* primvars,
101 RtUString const& fieldName,
102 FieldType type);
103
104protected:
105 bool _ConvertGeometry(
106 HdPrman_RenderParam *renderParam,
107 HdSceneDelegate *sceneDelegate,
108 const SdfPath &id,
109 RtUString *primType,
110 RtPrimVarList *primvars,
111 std::vector<HdGeomSubset> *geomSubsets,
112 std::vector<RtPrimVarList> *geomSubsetPrimvars) override;
113
114 void _AddPrimvars(RtPrimVarList*) const override;
115
116 const std::vector<riley::CoordinateSystemId>&
117 _GetAdditionalCoordSysIds() const override;
118
119 riley::MaterialId
120 _GetFallbackMaterial(HdPrman_RenderParam *renderParam) override {
121 return renderParam->GetFallbackVolumeMaterialId();
122 }
123
124 bool _PrototypeOnly() override;
125
126 using _VolumeEmitterMap = std::map<TfToken, HdPrman_VolumeTypeEmitter>;
127 static _VolumeEmitterMap& _GetVolumeEmitterMap();
128
129private:
130 bool _isMeshLight;
131 SdfPathVector _volumeFilterPaths;
132 std::vector<RtUString> _volumeFilterNodeNames;
133 std::vector<riley::VolumeFilterId> _volumeFilterIds;
134 std::vector<riley::CoordinateSystemId> _volumeFilterCoordSysIds;
135};
136
137PXR_NAMESPACE_CLOSE_SCOPE
138
139#endif // EXT_RMANPKG_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_VOLUME_H
virtual HD_API void Finalize(HdRenderParam *renderParam)
Finalizes object resources.
virtual HdDirtyBits GetInitialDirtyBitsMask() const =0
Returns the minimal set of dirty bits to place in the change tracker for use in the first sync of thi...
virtual void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits)=0
Synchronizes state from the delegate to this object.
Hydra schema for a USD field primitive.
Definition: field.h:34
A mix-in template that adds shared gprim behavior to support various HdRprim types.
Definition: gprim.h:30
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:281
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71