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 "hdPrman/gprim.h"
11
12#include "pxr/imaging/hd/field.h"
13#include "pxr/imaging/hd/version.h"
14#include "pxr/imaging/hd/volume.h"
15
16#include "pxr/pxr.h"
17
18#include <prmanapi.h>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22class HdPrman_Field final : public HdField
23{
24public:
25 HdPrman_Field(TfToken const& typeId, SdfPath const& id);
26 void Sync(HdSceneDelegate *sceneDelegate,
27 HdRenderParam *renderParam,
28 HdDirtyBits *dirtyBits) override;
29 void Finalize(HdRenderParam *renderParam) override;
30 HdDirtyBits GetInitialDirtyBitsMask() const override;
31private:
32 TfToken const _typeId;
33};
34
35class HdPrman_Volume final : public HdPrman_Gprim<HdVolume>
36{
37public:
38 using BASE = HdPrman_Gprim<HdVolume>;
39public:
40
41 HF_MALLOC_TAG_NEW("new HdPrman_Volume");
42
43 HdPrman_Volume(SdfPath const& id, const bool isMeshLight);
44
46 void Sync(HdSceneDelegate *sceneDelegate,
47 HdRenderParam *renderParam,
48 HdDirtyBits *dirtyBits,
49 TfToken const &reprToken) override;
50
51 void Finalize(HdRenderParam *renderParam) override;
52
53 HdDirtyBits GetInitialDirtyBitsMask() const override;
54
72 using HdPrman_VolumeTypeEmitter =
73 void (*)(HdSceneDelegate *sceneDelegate,
74 SdfPath const& id,
75 HdVolumeFieldDescriptorVector const& fields,
76 RtPrimVarList* primvars);
77
81 static bool AddVolumeTypeEmitter(TfToken const& fieldPrimType,
82 HdPrman_VolumeTypeEmitter emitterFunc,
83 bool overrideExisting = false);
84
86 enum FieldType {
87 FloatType = 0,
88 IntType,
89 Float2Type,
90 Int2Type,
91 Float3Type,
92 Int3Type,
93 ColorType,
94 PointType,
95 NormalType,
96 VectorType,
97 Float4Type,
98 MatrixType,
99 StringType
100 };
101
103 static void DeclareFieldPrimvar(RtPrimVarList* primvars,
104 RtUString const& fieldName,
105 FieldType type);
106
107protected:
108 bool _ConvertGeometry(
109 HdPrman_RenderParam *renderParam,
110 HdSceneDelegate *sceneDelegate,
111 const SdfPath &id,
112 RtUString *primType,
113 RtPrimVarList *primvars,
114 std::vector<HdGeomSubset> *geomSubsets,
115 std::vector<RtPrimVarList> *geomSubsetPrimvars) override;
116
117 void _AddPrimvars(RtPrimVarList*) const override;
118
119 const std::vector<riley::CoordinateSystemId>&
120 _GetAdditionalCoordSysIds() const override;
121
122 riley::MaterialId
123 _GetFallbackMaterial(HdPrman_RenderParam *renderParam) override {
124 return renderParam->GetFallbackVolumeMaterialId();
125 }
126
127 bool _PrototypeOnly() override;
128
129 using _VolumeEmitterMap = std::map<TfToken, HdPrman_VolumeTypeEmitter>;
130 static _VolumeEmitterMap& _GetVolumeEmitterMap();
131
132private:
133 bool _isMeshLight;
134
135#if _PRMANAPI_VERSION_MAJOR_ >= 27 && HD_API_VERSION >= 93
136 SdfPathVector _volumeFilterPaths;
137 std::vector<RtUString> _volumeFilterNodeNames;
138 std::vector<riley::VolumeFilterId> _volumeFilterIds;
139 std::vector<riley::CoordinateSystemId> _volumeFilterCoordSysIds;
140#endif
141};
142
143PXR_NAMESPACE_CLOSE_SCOPE
144
145#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