Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodesk: DashDotLine, DashDotPatternAPI Schemas #3151

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -850,3 +850,35 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

================================================================
dashDotCurves.glslfx
================================================================

GPU-accelerated Antialiased Dashed Stroked Polylines
Copyright (C) 2013 Nicolas P. Rougier. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are
those of the authors and should not be interpreted as representing official
policies, either expressed or implied, of Nicolas P. Rougier.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#usda 1.0

(
upAxis = "Y"
doc = """This layer represents the various geometric forms that curves
may be used to represent."""
)

def "MyPattern" (
prepend apiSchemas = ["DashDotPatternAPI"]
)
{
uniform float patternPeriod = 15
uniform float2[] pattern = [(0, 10)]
}

def Xform "Linear" {
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, 9, 0)
def Scope "Ribbons"{
def DashDotLines "StyledPolyline1" (
inherits = [</MyPattern>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, 0, 0)

uniform bool screenSpacePattern = false
uniform token startCapType = "round"
uniform token endCapType = "round"

int[] curveVertexCounts = [3, 4, 4]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0), (10, 70, 0), (10, 80, 0), (0, 90, 0), (-10, 100, 0)]
float[] widths = [5] (interpolation = "constant")
color3f[] primvars:displayColor = [(1, 0, 0)]
}
}
}
165 changes: 165 additions & 0 deletions extras/usd/examples/usdGeomExamples/styleCurve_ScreenSpace.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#usda 1.0

(
upAxis = "Y"
doc = """This layer represents the various geometric forms that curves
may be used to represent."""
)


def Xform "Linear" {
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, 9, 0)
def Scope "Ribbons"{
def DashDotLines "StyledPolyline1" (
inherits = [</Pattern1>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, 0, 0)

uniform bool screenSpacePattern = true
uniform token startCapType = "round"
uniform token endCapType = "round"
uniform float patternScale = 5
int[] curveVertexCounts = [7]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
float[] widths = [5] (interpolation = "constant")
color3f[] primvars:displayColor = [(1, 0, 0)]
}
def DashDotLines "StyledPolyline2" (
inherits = [</Pattern1>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (30, 0, 0)

uniform bool screenSpacePattern = true
uniform token startCapType = "square"
uniform token endCapType = "triangle"
uniform float patternScale = 7
int[] curveVertexCounts = [7]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
float[] widths = [8] (interpolation = "constant")
color3f[] primvars:displayColor = [(1, 0, 0)]
}
def DashDotLines "StyledPolyline3" (
inherits = [</Pattern1>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (60, 0, 0)

uniform bool screenSpacePattern = true
uniform token startCapType = "round"
uniform token endCapType = "triangle"
uniform float patternScale = 10
int[] curveVertexCounts = [7]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
float[] widths = [3] (interpolation = "constant")
color3f[] primvars:displayColor = [(1, 0, 0)]
}
def DashDotLines "StyledPolyline4" (
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (90, 0, 0)

uniform token startCapType = "round"
uniform token endCapType = "round"
int[] curveVertexCounts = [7]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
float[] widths = [8] (interpolation = "constant")
color3f[] primvars:displayColor = [(1, 0, 0)]
}

def DashDotLines "StyledPolyline5" (
inherits = [</Pattern1>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, -80, 0)

uniform bool screenSpacePattern = true
uniform token startCapType = "round"
uniform token endCapType = "round"
uniform float patternScale = 5
int[] curveVertexCounts = [7]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
float[] widths = [5] (interpolation = "constant")
color3f[] primvars:displayColor = [(0, 1, 0)]
}
def DashDotLines "StyledPolyline6" (
inherits = [</Pattern2>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (30, -80, 0)

uniform bool screenSpacePattern = true
uniform token startCapType = "round"
uniform token endCapType = "round"
uniform float patternScale = 5
int[] curveVertexCounts = [7]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
float[] widths = [5] (interpolation = "constant")
color3f[] primvars:displayColor = [(0, 1, 0)]
}
def DashDotLines "StyledPolyline7" (
inherits = [</Pattern3>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (60, -80, 0)

uniform bool screenSpacePattern = true
uniform token startCapType = "round"
uniform token endCapType = "round"
uniform float patternScale = 5
int[] curveVertexCounts = [7]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
float[] widths = [5] (interpolation = "constant")
color3f[] primvars:displayColor = [(0, 1, 0)]
}
def DashDotLines "StyledPolyline8" (
inherits = [</Pattern4>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (90, -80, 0)

uniform bool screenSpacePattern = true
uniform token startCapType = "round"
uniform token endCapType = "round"
uniform float patternScale = 5
int[] curveVertexCounts = [7]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0)]
float[] widths = [5] (interpolation = "constant")
color3f[] primvars:displayColor = [(0, 1, 0)]
}
}
}

def "Pattern1" (
prepend apiSchemas = ["DashDotPatternAPI"]
)
{
uniform float patternPeriod = 20
uniform float2[] pattern = [(0, 12.5), (2.5, 2.5)]
}

def "Pattern2" (
prepend apiSchemas = ["DashDotPatternAPI"]
)
{
uniform float patternPeriod = 10
uniform float2[] pattern = [(0, 5), (2.5, 0)]
}

def "Pattern3" (
prepend apiSchemas = ["DashDotPatternAPI"]
)
{
uniform float patternPeriod = 15
uniform float2[] pattern = [(0, 10)]
}

def "Pattern4" (
prepend apiSchemas = ["DashDotPatternAPI"]
)
{
uniform float patternPeriod = 5
uniform float2[] pattern = [(0, 0)]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#usda 1.0

(
upAxis = "Y"
doc = """This layer represents the various geometric forms that curves
may be used to represent."""
)

def "MyPattern" (
prepend apiSchemas = ["DashDotPatternAPI"]
)
{
uniform float patternPeriod = 15
uniform float2[] pattern = [(0, 10)]
}

def Xform "Linear" {
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, 9, 0)
def Scope "Ribbons"{
def DashDotLines "StyledPolyline1" (
prepend inherits = [</MyPattern>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, 0, 0)

uniform bool screenSpacePattern = true
uniform token startCapType = "round"
uniform token endCapType = "round"
uniform float patternScale = 5

int[] curveVertexCounts = [3, 4, 4]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0), (10, 70, 0), (10, 80, 0), (0, 90, 0), (-10, 100, 0)]
float[] widths = [5] (interpolation = "constant")
color3f[] primvars:displayColor = [(1, 0, 0)]
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#usda 1.0

(
upAxis = "Y"
doc = """This layer represents the various geometric forms that curves
may be used to represent."""
)

def "MyPattern" (
prepend apiSchemas = ["DashDotPatternAPI"]
)
{
uniform float patternPeriod = 15
uniform float2[] pattern = [(0, 10)]
}

def Xform "Linear" {
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, 9, 0)
def Scope "Ribbons"{
def DashDotLines "StyledPolyline1" (
inherits = [</MyPattern>]
){
uniform token[] xformOpOrder = ["xformOp:translate"]
float3 xformOp:translate = (0, 0, 0)

uniform bool screenSpacePattern = true
uniform token startCapType = "round"
uniform token endCapType = "round"
uniform float patternScale = 5

int[] curveVertexCounts = [3, 4, 4]
point3f[] points = [(0, 0, 0), (10, 10, 0), (10, 20, 0), (0, 30, 0), (-10, 40, 0), (-10, 50, 0), (0, 60, 0), (10, 70, 0), (10, 80, 0), (0, 90, 0), (-10, 100, 0)]
float[] widths = [5] (interpolation = "constant")
color3f[] primvars:displayColor = [(1, 0, 0), (1, 0, 0), (0, 0, 1), (1, 1, 0), (1, 0 ,1), (0, 1, 1), (0, 1, 0), (0, 0, 1), (1, 1, 0), (1, 0 ,1), (0, 1, 1)](interpolation = "vertex")
}
}
}
14 changes: 13 additions & 1 deletion pxr/imaging/hd/basisCurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ TF_DEFINE_ENV_SETTING(HD_ENABLE_REFINED_CURVES, 0,

HdBasisCurves::HdBasisCurves(SdfPath const& id)
: HdRprim(id)
, _wvpMatrix(1)
{
/*NOTHING*/
}
Expand All @@ -32,7 +33,18 @@ HdBasisCurves::GetBuiltinPrimvarNames() const
static const TfTokenVector primvarNames = {
HdTokens->points,
HdTokens->normals,
HdTokens->widths
HdTokens->widths,
HdTokens->accumulatedLength,
HdTokens->adjPoints1,
HdTokens->adjPoints2,
HdTokens->adjPoints3,
HdTokens->extrude,
HdTokens->pattern,
HdTokens->patternPartCount,
HdTokens->patternPeriod,
HdTokens->patternScale,
HdTokens->startCapType,
HdTokens->endCapType
};
return primvarNames;
}
Expand Down
27 changes: 26 additions & 1 deletion pxr/imaging/hd/basisCurves.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class HdBasisCurves : public HdRprim
public:
HD_API
~HdBasisCurves() override;

enum DirtyBits : HdDirtyBits {
DirtyIndices = HdChangeTracker::CustomBitsBegin,
// Need to update the accumulated length when camera is dirty and the curve has screen space
// Style.
DirtyCamera = (DirtyIndices << 1)
};

///
/// Topology
Expand All @@ -71,7 +78,23 @@ class HdBasisCurves : public HdRprim
/// Returns whether refinement is always on or not.
HD_API
static bool IsEnabledForceRefinedCurves();


/// Set the WVP matrix.
void UpdateWVPMatrix(const GfMatrix4d& wvpMatrix)
{
_wvpMatrix = wvpMatrix;
}

/// Set the Viewport
void UpdateViewport(const GfVec4f& viewport)
{
_viewport = viewport;
}

/// Check if the curve need to be updated each frame.
HD_API
virtual bool NeedUpdateEachFrame(HdSceneDelegate* /*sceneDelegate*/) const { return false; }

protected:
HD_API
HdBasisCurves(SdfPath const& id);
Expand All @@ -82,6 +105,8 @@ class HdBasisCurves : public HdRprim
static _BasisCurvesReprConfig::DescArray
_GetReprDesc(TfToken const &reprName);

GfMatrix4d _wvpMatrix;
GfVec4f _viewport;
private:
// Class can not be default constructed or copied.
HdBasisCurves() = delete;
Expand Down
Loading
Loading