9 #include <pxr/imaging/hd/extComputationUtils.h>
14 #
if PXR_VERSION < 2102
16 const SdfPath &instancerId
20 #
if PXR_VERSION < 2102
35 bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths |
36 HdChangeTracker::DirtyPrimvar;
40 HdDirtyBits HdCyclesPoints::_PropagateDirtyBits(HdDirtyBits bits)
const
43 if (bits & (HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths)) {
44 bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths;
50 void HdCyclesPoints::Populate(HdSceneDelegate *sceneDelegate, HdDirtyBits dirtyBits,
bool &rebuild)
52 if (dirtyBits & (HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths)) {
53 const size_t numPoints =
_geom->num_points();
55 PopulatePoints(sceneDelegate);
56 PopulateWidths(sceneDelegate);
58 rebuild =
_geom->num_points() != numPoints;
62 for (
size_t i = 0; i <
_geom->num_points(); ++i) {
69 if (dirtyBits & HdChangeTracker::DirtyPrimvar) {
70 PopulatePrimvars(sceneDelegate);
74 void HdCyclesPoints::PopulatePoints(HdSceneDelegate *sceneDelegate)
78 for (
const HdExtComputationPrimvarDescriptor &desc :
79 sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) {
80 if (desc.name == HdTokens->points) {
81 auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate);
82 const auto valueStoreIt = valueStore.find(desc.name);
83 if (valueStoreIt != valueStore.end()) {
84 value = std::move(valueStoreIt->second);
90 if (value.IsEmpty()) {
91 value = GetPrimvar(sceneDelegate, HdTokens->points);
94 if (!value.IsHolding<VtVec3fArray>()) {
95 TF_WARN(
"Invalid points data for %s", GetId().GetText());
99 const auto &points = value.UncheckedGet<VtVec3fArray>();
102 pointsDataCycles.
reserve(points.size());
104 for (
const GfVec3f &
point : points) {
108 _geom->set_points(pointsDataCycles);
111 void HdCyclesPoints::PopulateWidths(HdSceneDelegate *sceneDelegate)
113 VtValue value = GetPrimvar(sceneDelegate, HdTokens->widths);
116 if (!value.IsHolding<VtFloatArray>()) {
117 TF_WARN(
"Invalid widths data for %s", GetId().GetText());
121 const auto &widths = value.UncheckedGet<VtFloatArray>();
126 if (interpolation == HdInterpolationConstant) {
127 TF_VERIFY(widths.size() == 1);
129 const float constantRadius = widths[0] * 0.5f;
131 for (
size_t i = 0; i <
_geom->num_points(); ++i) {
132 radiusDataCycles.push_back_reserved(constantRadius);
135 else if (interpolation == HdInterpolationVertex) {
136 TF_VERIFY(widths.size() ==
_geom->num_points());
138 for (
size_t i = 0; i <
_geom->num_points(); ++i) {
139 radiusDataCycles.push_back_reserved(widths[i] * 0.5f);
143 _geom->set_radius(radiusDataCycles);
146 void HdCyclesPoints::PopulatePrimvars(HdSceneDelegate *sceneDelegate)
150 const std::pair<HdInterpolation, AttributeElement> interpolations[] = {
155 for (
const auto &interpolation : interpolations) {
156 for (
const HdPrimvarDescriptor &desc :
157 GetPrimvarDescriptors(sceneDelegate, interpolation.first)) {
159 if (desc.name == HdTokens->points || desc.name == HdTokens->widths) {
163 VtValue value = GetPrimvar(sceneDelegate, desc.name);
164 if (value.IsEmpty()) {
168 const ustring name(desc.name.GetString());
171 if (desc.role == HdPrimvarRoleTokens->textureCoordinate) {
174 else if (interpolation.first == HdInterpolationVertex) {
175 if (desc.name == HdTokens->displayColor || desc.role == HdPrimvarRoleTokens->color) {
178 else if (desc.name == HdTokens->normals) {
182 else if (desc.name == HdTokens->displayColor &&
183 interpolation.first == HdInterpolationConstant) {
184 if (value.IsHolding<VtVec3fArray>() && value.GetArraySize() == 1) {
185 const GfVec3f
color = value.UncheckedGet<VtVec3fArray>()[0];
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 point
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
PXR_NS::HdInterpolation GetPrimvarInterpolation(PXR_NS::HdSceneDelegate *sceneDelegate, const PXR_NS::TfToken &name) const
CCL_NS::PointCloud * _geom
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override
std::vector< CCL_NS::Object * > _instances
HdCyclesPoints(const PXR_NS::SdfPath &rprimId, const PXR_NS::SdfPath &instancerId={})
~HdCyclesPoints() override
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override
void reserve(size_t newcapacity)
HDCYCLES_NAMESPACE_OPEN_SCOPE void ApplyPrimvars(AttributeSet &attributes, const ustring &name, VtValue value, AttributeElement elem, AttributeStandard std)
#define HDCYCLES_NAMESPACE_CLOSE_SCOPE