10#include <pxr/imaging/hd/extComputationUtils.h>
17 const SdfPath &instancerId
34 bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths |
35 HdChangeTracker::DirtyPrimvar;
39HdDirtyBits HdCyclesPoints::_PropagateDirtyBits(HdDirtyBits bits)
const
42 if (bits & (HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths)) {
43 bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths;
49void HdCyclesPoints::Populate(HdSceneDelegate *sceneDelegate, HdDirtyBits dirtyBits,
bool &rebuild)
51 if (dirtyBits & (HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths)) {
52 const size_t numPoints =
_geom->num_points();
54 PopulatePoints(sceneDelegate);
55 PopulateWidths(sceneDelegate);
57 rebuild =
_geom->num_points() != numPoints;
61 for (
size_t i = 0; i <
_geom->num_points(); ++i) {
65 _geom->set_shader(shaders);
68 if (dirtyBits & HdChangeTracker::DirtyPrimvar) {
69 PopulatePrimvars(sceneDelegate);
73void HdCyclesPoints::PopulatePoints(HdSceneDelegate *sceneDelegate)
77 for (
const HdExtComputationPrimvarDescriptor &desc :
78 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>();
101 array<float3> pointsDataCycles;
102 pointsDataCycles.reserve(points.size());
104 for (
const GfVec3f &
point : points) {
108 _geom->set_points(pointsDataCycles);
111void 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>();
123 array<float> radiusDataCycles;
124 radiusDataCycles.reserve(
_geom->num_points());
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);
146void 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))
160 if (desc.name == HdTokens->points || desc.name == HdTokens->widths) {
164 VtValue value = GetPrimvar(sceneDelegate, desc.name);
165 if (value.IsEmpty()) {
169 const ustring name(desc.name.GetString());
172 if (desc.role == HdPrimvarRoleTokens->textureCoordinate) {
175 else if (interpolation.first == HdInterpolationVertex) {
176 if (desc.name == HdTokens->displayColor || desc.role == HdPrimvarRoleTokens->color) {
179 else if (desc.name == HdTokens->normals) {
183 else if (desc.name == HdTokens->displayColor &&
184 interpolation.first == HdInterpolationConstant)
186 if (value.IsHolding<VtVec3fArray>() && value.GetArraySize() == 1) {
187 const GfVec3f
color = value.UncheckedGet<VtVec3fArray>()[0];
194 _geom->need_attribute(scene, name))
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 Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves 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 Invert a color
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 Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture 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
HdCyclesGeometry(const PXR_NS::SdfPath &rprimId, const PXR_NS::SdfPath &instancerId)
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
HDCYCLES_NAMESPACE_OPEN_SCOPE void ApplyPrimvars(AttributeSet &attributes, const ustring &name, VtValue value, AttributeElement elem, AttributeStandard std)
#define HDCYCLES_NAMESPACE_CLOSE_SCOPE