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 | HdChangeTracker::DirtyTopology;
40 HdDirtyBits HdCyclesCurves::_PropagateDirtyBits(HdDirtyBits bits)
const
42 if (bits & (HdChangeTracker::DirtyTopology)) {
44 bits |= HdChangeTracker::DirtyPoints | HdChangeTracker::DirtyWidths |
45 HdChangeTracker::DirtyPrimvar;
51 void HdCyclesCurves::Populate(HdSceneDelegate *sceneDelegate, HdDirtyBits dirtyBits,
bool &rebuild)
53 if (HdChangeTracker::IsTopologyDirty(dirtyBits, GetId())) {
54 PopulateTopology(sceneDelegate);
57 if (dirtyBits & HdChangeTracker::DirtyPoints) {
58 PopulatePoints(sceneDelegate);
61 if (dirtyBits & HdChangeTracker::DirtyWidths) {
62 PopulateWidths(sceneDelegate);
65 if (dirtyBits & HdChangeTracker::DirtyPrimvar) {
66 PopulatePrimvars(sceneDelegate);
69 rebuild = (
_geom->curve_keys_is_modified()) || (
_geom->curve_radius_is_modified());
72 void HdCyclesCurves::PopulatePoints(HdSceneDelegate *sceneDelegate)
76 for (
const HdExtComputationPrimvarDescriptor &desc :
77 sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) {
78 if (desc.name == HdTokens->points) {
79 auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate);
80 const auto valueStoreIt = valueStore.find(desc.name);
81 if (valueStoreIt != valueStore.end()) {
82 value = std::move(valueStoreIt->second);
88 if (value.IsEmpty()) {
89 value = GetPrimvar(sceneDelegate, HdTokens->points);
92 if (!value.IsHolding<VtVec3fArray>()) {
93 TF_WARN(
"Invalid points data for %s", GetId().GetText());
97 const auto &points = value.UncheckedGet<VtVec3fArray>();
100 pointsDataCycles.
reserve(points.size());
102 for (
const GfVec3f &
point : points) {
106 _geom->set_curve_keys(pointsDataCycles);
109 void HdCyclesCurves::PopulateWidths(HdSceneDelegate *sceneDelegate)
111 VtValue value = GetPrimvar(sceneDelegate, HdTokens->widths);
114 if (!value.IsHolding<VtFloatArray>()) {
115 TF_WARN(
"Invalid widths data for %s", GetId().GetText());
119 const auto &widths = value.UncheckedGet<VtFloatArray>();
122 radiusDataCycles.
reserve(widths.size());
124 if (interpolation == HdInterpolationConstant) {
125 TF_VERIFY(widths.size() == 1);
127 const float constantRadius = widths[0] * 0.5f;
129 for (
size_t i = 0; i <
_geom->num_keys(); ++i) {
130 radiusDataCycles.push_back_reserved(constantRadius);
133 else if (interpolation == HdInterpolationVertex) {
134 TF_VERIFY(widths.size() ==
_geom->num_keys());
136 for (
size_t i = 0; i <
_geom->num_keys(); ++i) {
137 radiusDataCycles.push_back_reserved(widths[i] * 0.5f);
141 _geom->set_curve_radius(radiusDataCycles);
144 void HdCyclesCurves::PopulatePrimvars(HdSceneDelegate *sceneDelegate)
148 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 (desc.name == HdTokens->displayColor &&
175 interpolation.first == HdInterpolationConstant) {
176 if (value.IsHolding<VtVec3fArray>() && value.GetArraySize() == 1) {
177 const GfVec3f
color = value.UncheckedGet<VtVec3fArray>()[0];
191 void HdCyclesCurves::PopulateTopology(HdSceneDelegate *sceneDelegate)
196 HdBasisCurvesTopology topology = GetBasisCurvesTopology(sceneDelegate);
198 _geom->reserve_curves(topology.GetNumCurves(), topology.CalculateNeededNumberOfControlPoints());
200 const VtIntArray vertCounts = topology.GetCurveVertexCounts();
202 for (
int curve = 0, key = 0;
curve < topology.GetNumCurves(); ++
curve) {
204 _geom->add_curve(key, 0);
206 key += vertCounts[
curve];
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
HdCyclesCurves(const PXR_NS::SdfPath &rprimId, const PXR_NS::SdfPath &instancerId={})
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override
~HdCyclesCurves() override
PXR_NS::HdInterpolation GetPrimvarInterpolation(PXR_NS::HdSceneDelegate *sceneDelegate, const PXR_NS::TfToken &name) const
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override
std::vector< CCL_NS::Object * > _instances
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