Skip to content

Commit

Permalink
[OGSMOD-2703] Use vertex shader to replace Geometry shader in Linesty…
Browse files Browse the repository at this point in the history
…le (PixarAnimationStudios#217)

Use vertex shader to replace Geometry shader in Linestyle
  • Loading branch information
PierreWang committed Jan 17, 2023
1 parent c962379 commit c096bb1
Show file tree
Hide file tree
Showing 14 changed files with 960 additions and 138 deletions.
7 changes: 6 additions & 1 deletion pxr/imaging/hd/basisCurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ HdBasisCurves::GetBuiltinPrimvarNames() const
HdTokens->normals,
HdTokens->widths,
HdTokens->accumulatedLength,
HdTokens->adjPoints1,
HdTokens->adjPoints2,
HdTokens->adjPoints3,
HdTokens->extrude,
HdTokens->screenSpacePattern,
HdTokens->period,
HdTokens->scale,
HdTokens->leftCapType,
HdTokens->rightCapType
HdTokens->rightCapType,
HdTokens->hasLineStyle
};
return primvarNames;
}
Expand Down
26 changes: 21 additions & 5 deletions pxr/imaging/hd/basisCurvesTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,27 @@ namespace {
static size_t
_ComputeNumPoints(
VtIntArray const &curveVertexCounts,
VtIntArray const &indices)
VtIntArray const &indices,
bool needAdjInfo)
{
// Make absolutely sure the iterator is constant
// (so we don't detach the array while multi-threaded)
if (indices.empty()) {
return std::accumulate(
curveVertexCounts.cbegin(), curveVertexCounts.cend(), size_t {0} );
if (needAdjInfo)
{
// Calculate the count of line segments.
size_t countOfLineSegmemt = 0;
for (auto count : curveVertexCounts)
{
countOfLineSegmemt += (count - 1);
}
// For each line segment, we need four vertices: each line segment will
// be converted to a quad.
return countOfLineSegmemt * 4;
}
else
return std::accumulate(
curveVertexCounts.cbegin(), curveVertexCounts.cend(), size_t {0} );
} else {
return 1 + *std::max_element(indices.cbegin(), indices.cend());
}
Expand Down Expand Up @@ -79,7 +93,8 @@ HdBasisCurvesTopology::HdBasisCurvesTopology(const HdBasisCurvesTopology& src)
, _updateEachFrame(src._updateEachFrame)
{
HD_PERF_COUNTER_INCR(HdPerfTokens->basisCurvesTopology);
_numPoints = _ComputeNumPoints(_curveVertexCounts, _curveIndices);
_numPoints = _ComputeNumPoints(_curveVertexCounts, _curveIndices,
_curveStyle != HdTokens->none);
}

HdBasisCurvesTopology::HdBasisCurvesTopology(const TfToken &curveType,
Expand Down Expand Up @@ -110,7 +125,8 @@ HdBasisCurvesTopology::HdBasisCurvesTopology(const TfToken &curveType,
_curveBasis = TfToken();
}
HD_PERF_COUNTER_INCR(HdPerfTokens->basisCurvesTopology);
_numPoints = _ComputeNumPoints(_curveVertexCounts, _curveIndices);
_numPoints = _ComputeNumPoints(_curveVertexCounts, _curveIndices,
_curveStyle != HdTokens->none);
}

HdBasisCurvesTopology::~HdBasisCurvesTopology()
Expand Down
4 changes: 4 additions & 0 deletions pxr/imaging/hd/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ PXR_NAMESPACE_OPEN_SCOPE
(accelerations) \
(accumulatedLength) \
(adjacency) \
(adjPoints1) \
(adjPoints2) \
(adjPoints3) \
(bboxLocalMin) \
(bboxLocalMax) \
(bbox) \
Expand Down Expand Up @@ -64,6 +67,7 @@ PXR_NAMESPACE_OPEN_SCOPE
(elementCount) \
(elementsVisibility) \
(extent) \
(extrude) \
(faceColors) \
(filters) \
(full) \
Expand Down
Loading

0 comments on commit c096bb1

Please sign in to comment.