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

[for reference] Add Support for Image Planes (as a concrete schema type) #1

Open
wants to merge 2 commits 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
1 change: 1 addition & 0 deletions pxr/imaging/hdSt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ pxr_library(hdSt
shaders/renderPass.glslfx
shaders/renderPassShader.glslfx
shaders/simpleLightingShader.glslfx
shaders/simpleTexturedSurface.glslfx
shaders/terminals.glslfx
shaders/visibility.glslfx
shaders/volume.glslfx
Expand Down
25 changes: 25 additions & 0 deletions pxr/imaging/hdSt/shaders/simpleTexturedSurface.glslfx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- glslfx version 0.1

#import $TOOLS/glf/shaders/simpleLighting.glslfx

-- configuration
{
"techniques": {
"default": {
"surfaceShader": {
"source": [ "simpleTexturedSurface.Surface" ]
}
}
}
}

-- glsl simpleTexturedSurface.Surface

vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
{
#if defined(HD_HAS_baseColor)
return vec4(HdGet_baseColor(), 1.0);
#else
return vec4(1.0, 0.0, 0.0, 1.0);
#endif
}
25 changes: 25 additions & 0 deletions pxr/imaging/lib/hdSt/shaders/simpleTexturedSurface.glslfx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- glslfx version 0.1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the introduction of imaging/lib/hdSt/shaders/... intentional?


#import $TOOLS/glf/shaders/simpleLighting.glslfx

-- configuration
{
"techniques": {
"default": {
"surfaceShader": {
"source": [ "simpleTexturedSurface.Surface" ]
}
}
}
}

-- glsl simpleTexturedSurface.Surface

vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
{
#if defined(HD_HAS_baseColor)
return vec4(HdGet_baseColor(), 1.0);
#else
return vec4(1.0, 0.0, 0.0, 1.0);
#endif
}
8 changes: 6 additions & 2 deletions pxr/usd/usdGeom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ pxr_library(usdGeom
usd
work
${Boost_PYTHON_LIBRARY}
${TBB_tbb_LIBRARY}
${OIIO_LIBRARIES}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenUSD 23.11 has OpenEXR support built in, so it shouldn't be necessary to directly link OIIO or OpenEXR

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exr does not support 8-16 etc formats

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, to be more clear about my comment, we won't be able to add a dependency on OpenImageIO to usdGeom. Loading textures is a function of the Hio library, and Hio already has a plugin to support OpenImageIO reading and writing.

${OPENEXR_LIBRARIES}

INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
${TBB_INCLUDE_DIRS}
${OIIO_INCLUDE_DIRS}
${OPENEXR_INCLUDE_DIRS}

PUBLIC_CLASSES
debugCodes
Expand All @@ -35,6 +37,7 @@ pxr_library(usdGeom
cylinder
hermiteCurves
imageable
imagePlane
gprim
mesh
metrics
Expand Down Expand Up @@ -81,6 +84,7 @@ pxr_library(usdGeom
wrapGprim.cpp
wrapHermiteCurves.cpp
wrapImageable.cpp
wrapImagePlane.cpp
wrapMesh.cpp
wrapMetrics.cpp
wrapModelAPI.cpp
Expand Down
196 changes: 196 additions & 0 deletions pxr/usd/usdGeom/generatedSchema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,202 @@ class "Gprim" (
)
}

class ImagePlane "ImagePlane" (
doc = """
Basic schema to represent image planes.
"""
)
{
float alphaGain = 1 (
doc = "Alpha Gain"
)
rel camera (
doc = "Link to the camera from where aperture sizes are queried."
)
int2 coverage = (0, 0) (
doc = "Coverage of the image in pixels. 0 is equal to the image's size."
)
int2 coverageOrigin = (0, 0) (
doc = "Coverage origin in pixels. Clamped to -image's size and image's size."
)
float depth = 100 (
doc = "Depth"
)
uniform bool doubleSided = 0 (
doc = """Although some renderers treat all parametric or polygonal
surfaces as if they were effectively laminae with outward-facing
normals on both sides, some renderers derive significant optimizations
by considering these surfaces to have only a single outward side,
typically determined by control-point winding order and/or
orientation. By doing so they can perform \"backface culling\" to
avoid drawing the many polygons of most closed surfaces that face away
from the viewer.

However, it is often advantageous to model thin objects such as paper
and cloth as single, open surfaces that must be viewable from both
sides, always. Setting a gprim's doubleSided attribute to
\\c true instructs all renderers to disable optimizations such as
backface culling for the gprim, and attempt (not all renderers are able
to do so, but the USD reference GL renderer always will) to provide
forward-facing normals on each side of the surface for lighting
calculations."""
)
float3[] extent (
doc = """Extent is a three dimensional range measuring the geometric
extent of the authored gprim in its own local space (i.e. its own
transform not applied), without accounting for any shader-induced
displacement. Whenever any geometry-affecting attribute is authored
for any gprim in a layer, extent must also be authored at the same
timesample; failure to do so will result in incorrect bounds-computation.
\\sa \\ref UsdGeom_Boundable_Extent.

An authored extent on a prim which has children is expected to include
the extent of all children, as they will be pruned from BBox computation
during traversal."""
)
token fit = "best" (
allowedTokens = ["fill", "best", "horizontal", "vertical", "to size"]
doc = "Fitting mode for the image plane."
)
double frame = 0 (
doc = "The frame offset for animated textures."
)
int frameCache = 45 (
doc = "Precached frame count"
)
int frameOffset = 0 (
doc = "Frame offset"
)
float height = 0 (
doc = "Height"
)
float3 imageCenter = (0, 0, 0) (
doc = "3D offset for the image plane."
)
asset info:filename = @@ (
doc = "Asset path to the file containg the image data."
)
float2 offset = (0, 0) (
doc = "Image plane offset in inches."
)
uniform token orientation = "rightHanded" (
allowedTokens = ["rightHanded", "leftHanded"]
doc = """Orientation specifies whether the gprim's surface normal
should be computed using the right hand rule, or the left hand rule.
Please see for a deeper explanation and
generalization of orientation to composed scenes with transformation
hierarchies."""
)
color3f[] primvars:displayColor (
doc = '''It is useful to have an "official" colorSet that can be used
as a display or modeling color, even in the absence of any specified
shader for a gprim. DisplayColor serves this role; because it is a
UsdGeomPrimvar, it can also be used as a gprim override for any shader
that consumes a displayColor parameter.'''
)
float[] primvars:displayOpacity (
doc = """Companion to displayColor that specifies opacity, broken
out as an independent attribute rather than an rgba color, both so that
each can be independently overridden, and because shaders rarely consume
rgba parameters."""
)
rel proxyPrim (
doc = '''The proxyPrim relationship allows us to link a
prim whose purpose is "render" to its (single target)
purpose="proxy" prim. This is entirely optional, but can be
useful in several scenarios:

- In a pipeline that does pruning (for complexity management)
by deactivating prims composed from asset references, when we
deactivate a purpose="render" prim, we will be able to discover
and additionally deactivate its associated purpose="proxy" prim,
so that preview renders reflect the pruning accurately.

- DCC importers may be able to make more aggressive optimizations
for interactive processing and display if they can discover the proxy
for a given render prim.

- With a little more work, a Hydra-based application will be able
to map a picked proxy prim back to its render geometry for selection.

\\note It is only valid to author the proxyPrim relationship on
prims whose purpose is "render".'''
)
uniform token purpose = "default" (
allowedTokens = ["default", "render", "proxy", "guide"]
doc = '''Purpose is a concept we have found useful in our pipeline for
classifying geometry into categories that can each be independently
included or excluded from traversals of prims on a stage, such as
rendering or bounding-box computation traversals. The fallback
purpose, default indicates that a prim has "no special purpose"
and should generally be included in all traversals. Subtrees rooted
at a prim with purpose render should generally only be included
when performing a "final quality" render. Subtrees rooted at a prim
with purpose proxy should generally only be included when
performing a lightweight proxy render (such as openGL). Finally,
subtrees rooted at a prim with purpose guide should generally
only be included when an interactive application has been explicitly
asked to "show guides".

In the previous paragraph, when we say "subtrees rooted at a prim",
we mean the most ancestral or tallest subtree that has an authored,
non-default opinion. If the purpose of </RootPrim> is set to
"render", then the effective purpose of </RootPrim/ChildPrim> will
be "render" even if that prim has a different authored value for
purpose. <b>See ComputePurpose() for details of how purpose
inherits down namespace</b>.

As demonstrated in UsdGeomBBoxCache, a traverser should be ready to
accept combinations of included purposes as an input.

Purpose render can be useful in creating "light blocker"
geometry for raytracing interior scenes. Purposes render and
proxy can be used together to partition a complicated model
into a lightweight proxy representation for interactive use, and a
fully realized, potentially quite heavy, representation for rendering.
One can use UsdVariantSets to create proxy representations, but doing
so requires that we recompose parts of the UsdStage in order to change
to a different runtime level of detail, and that does not interact
well with the needs of multithreaded rendering. Purpose provides us with
a better tool for dynamic, interactive complexity management.'''
)
float rotate = 0 (
doc = "Rotation value for the image plane. Specified in degrees."
)
float2 size = (-1, -1) (
doc = "Image plane size in inches. Less than zero means equal to the camera aperture size."
)
float squeezeCorrection = 1 (
doc = "Squeeze Correction"
)
bool useFrameExtension = 0 (
doc = "Using frame extension"
)
token visibility = "inherited" (
allowedTokens = ["inherited", "invisible"]
doc = '''Visibility is meant to be the simplest form of "pruning"
visibility that is supported by most DCC apps. Visibility is
animatable, allowing a sub-tree of geometry to be present for some
segment of a shot, and absent from others; unlike the action of
deactivating geometry prims, invisible geometry is still
available for inspection, for positioning, for defining volumes, etc.'''
)
float width = 0 (
doc = "Width"
)
uniform token[] xformOpOrder (
doc = """Encodes the sequence of transformation operations in the
order in which they should be pushed onto a transform stack while
visiting a UsdStage's prims in a graph traversal that will effect
the desired positioning for this prim and its descendant prims.

You should rarely, if ever, need to manipulate this attribute directly.
It is managed by the AddXformOp(), SetResetXformStack(), and
SetXformOpOrder(), and consulted by GetOrderedXformOps() and
GetLocalTransformation()."""
)
}

class Cube "Cube" (
doc = """Defines a primitive rectilinear cube centered at the origin.

Expand Down
Loading