add usd-21-11-win64_py39
This commit is contained in:
1 parent
41d23e71ba
commit
ba5e1f7e67
15684 files changed
+3069957
No files matched your search
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"ArResolver": {},
|
||||
"ArDefaultResolver": {
|
||||
"bases": [
|
||||
"ArResolver"
|
||||
],
|
||||
"implementsContexts": true
|
||||
},
|
||||
"ArPackageResolver": {}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_ar.dll",
|
||||
"Name": "ar",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"ShaderResources": "shaders"
|
||||
},
|
||||
"LibraryPath": "../../usd_glf.dll",
|
||||
"Name": "glf",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
---Percentage-Closer Filtering (PCF)
|
||||
|
||||
-- glsl PCF.ShadowFilterVertex
|
||||
// ---------------------------------------------------------------------------
|
||||
// PCF compute shadow filter length in vertex shader
|
||||
// ---------------------------------------------------------------------------
|
||||
#define REQUIRE_SHADOW_FILTER_WIDTH
|
||||
|
||||
-- glsl PCF.ShadowFilterFragment
|
||||
// ---------------------------------------------------------------------------
|
||||
// PCF shadow filtering in fragment shader
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#if NUM_SHADOWS > 0
|
||||
|
||||
#define SHADOW_FILTER
|
||||
|
||||
#define JITTER_NUM_SAMPLES 16
|
||||
#define PCF_NUM_SAMPLES JITTER_NUM_SAMPLES
|
||||
|
||||
float shadowSample(int index, vec4 coord);
|
||||
float shadowCompare(int index, vec4 coord);
|
||||
|
||||
vec2 jitter[JITTER_NUM_SAMPLES] =
|
||||
vec2[JITTER_NUM_SAMPLES](
|
||||
vec2(-0.94201624, -0.39906216),
|
||||
vec2( 0.94558609, -0.76890725),
|
||||
vec2(-0.09418410, -0.92938870),
|
||||
vec2( 0.34495938, 0.29387760),
|
||||
vec2(-0.91588581, 0.45771432),
|
||||
vec2(-0.81544232, -0.87912464),
|
||||
vec2(-0.38277543, 0.27676845),
|
||||
vec2( 0.97484398, 0.75648379),
|
||||
vec2( 0.44323325, -0.97511554),
|
||||
vec2( 0.53742981, -0.47373420),
|
||||
vec2(-0.26496911, -0.41893023),
|
||||
vec2( 0.79197514, 0.19090188),
|
||||
vec2(-0.24188840, 0.99706507),
|
||||
vec2(-0.81409955, 0.91437590),
|
||||
vec2( 0.19984126, 0.78641367),
|
||||
vec2( 0.14383161, -0.14100790)
|
||||
);
|
||||
|
||||
in vec2 FshadowFilterWidth[NUM_SHADOWS];
|
||||
|
||||
float
|
||||
shadowFilter(int index, vec4 Pshadow, vec4 Peye)
|
||||
{
|
||||
vec2 filterWidth = FshadowFilterWidth[index];
|
||||
|
||||
float sum = 0.0;
|
||||
for (int i=0; i<PCF_NUM_SAMPLES; ++i) {
|
||||
// Note that the perspective division has not been applied to
|
||||
// either Pshadow or filterWidth.
|
||||
vec2 offset = jitter[i] * filterWidth;
|
||||
sum += shadowCompare(index, Pshadow + vec4(offset, 0, 0));
|
||||
}
|
||||
return sum / float(PCF_NUM_SAMPLES);
|
||||
}
|
||||
|
||||
#endif // NUM_SHADOWS > 0
|
||||
|
||||
-- glsl PCF.ShadowFilterFragmentOnly
|
||||
// ---------------------------------------------------------------------------
|
||||
// PCF shadow filtering with compute filter length on the fly.
|
||||
// no vertex shader needed.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#if NUM_SHADOWS > 0
|
||||
|
||||
#define SHADOW_FILTER
|
||||
#define JITTER_NUM_SAMPLES 16
|
||||
#define PCF_NUM_SAMPLES JITTER_NUM_SAMPLES
|
||||
|
||||
float shadowSample(int index, vec4 coord);
|
||||
float shadowCompare(int index, vec4 coord);
|
||||
|
||||
vec2 jitter[JITTER_NUM_SAMPLES] =
|
||||
vec2[JITTER_NUM_SAMPLES](
|
||||
vec2(-0.94201624, -0.39906216),
|
||||
vec2( 0.94558609, -0.76890725),
|
||||
vec2(-0.09418410, -0.92938870),
|
||||
vec2( 0.34495938, 0.29387760),
|
||||
vec2(-0.91588581, 0.45771432),
|
||||
vec2(-0.81544232, -0.87912464),
|
||||
vec2(-0.38277543, 0.27676845),
|
||||
vec2( 0.97484398, 0.75648379),
|
||||
vec2( 0.44323325, -0.97511554),
|
||||
vec2( 0.53742981, -0.47373420),
|
||||
vec2(-0.26496911, -0.41893023),
|
||||
vec2( 0.79197514, 0.19090188),
|
||||
vec2(-0.24188840, 0.99706507),
|
||||
vec2(-0.81409955, 0.91437590),
|
||||
vec2( 0.19984126, 0.78641367),
|
||||
vec2( 0.14383161, -0.14100790)
|
||||
);
|
||||
|
||||
vec2 computeShadowFilterWidth(int index, vec4 Peye); // defined in simpleLighting.glslfx
|
||||
|
||||
float
|
||||
shadowFilter(int index, vec4 Pshadow, vec4 Peye)
|
||||
{
|
||||
vec2 filterWidth = computeShadowFilterWidth(index, Peye);
|
||||
|
||||
float sum = 0.0;
|
||||
for (int i=0; i<PCF_NUM_SAMPLES; ++i) {
|
||||
// Note that the perspective division has not been applied to
|
||||
// either Pshadow or filterWidth.
|
||||
vec2 offset = jitter[i] * filterWidth;
|
||||
sum += shadowCompare(index, Pshadow + vec4(offset, 0, 0));
|
||||
}
|
||||
return sum / float(PCF_NUM_SAMPLES);
|
||||
}
|
||||
|
||||
|
||||
#endif // NUM_SHADOWS > 0
|
||||
@@ -0,0 +1,475 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/glos/shaders/simpleLighting.glslfx
|
||||
--- #import /user/anim/global/shaders/simpleLighting.glslfx
|
||||
|
||||
-- glsl SimpleLighting.GeometryInjection
|
||||
#ifndef NUM_SHADOWS
|
||||
#define NUM_SHADOWS 0
|
||||
#endif
|
||||
|
||||
#if NUM_SHADOWS == 0
|
||||
|
||||
#else // NUM_SHADOWS == 0
|
||||
|
||||
struct ShadowMatrix {
|
||||
mat4 eyeToShadowMatrix;
|
||||
mat4 shadowToEyeMatrix;
|
||||
float blur;
|
||||
float bias;
|
||||
float padding0;
|
||||
float padding1;
|
||||
};
|
||||
|
||||
layout(std140) uniform Shadow {
|
||||
ShadowMatrix shadow[NUM_SHADOWS];
|
||||
};
|
||||
|
||||
out vec2 FshadowFilterWidth[NUM_SHADOWS];
|
||||
|
||||
// Transforms a unit tangent vector parallel to a coordinate axis in
|
||||
// shadow space to eye space and returns the length of the result
|
||||
// (without doing the perspective division).
|
||||
//
|
||||
// The first argument is assumed to be a column of the shadow to eye
|
||||
// matrix (using first column corresponds to unit tangent vector
|
||||
// pointing in x-direction, ...). The second argument is supposed to
|
||||
// be the (homogeneous) coordinates of the point in eye space.
|
||||
//
|
||||
float
|
||||
shadowTangentLength(vec4 dir, vec4 Peye)
|
||||
{
|
||||
// Computation similar to computeRayDirectionEye in volume.glslfx.
|
||||
const vec3 shadowTangent = dir.xyz * Peye.w - dir.w * Peye.xyz;
|
||||
return length(shadowTangent);
|
||||
}
|
||||
|
||||
// Computes the lengths that tangent vectors parallel to the x-,
|
||||
// respectively, y-direction in shadow space at the current location
|
||||
// need to have such that their image in eye space have length blur
|
||||
// (without perspective division).
|
||||
//
|
||||
void
|
||||
computeShadowFilterWidth(vec4 Peye)
|
||||
{
|
||||
// interpolate filter width
|
||||
for (int i = 0; i < NUM_SHADOWS; ++i) {
|
||||
FShadowFilterWidth[i] =
|
||||
vec2(shadow[i].blur) /
|
||||
vec2(shadowTangentLength(shadow[i].shadowToEyeMatrix[0], Peye),
|
||||
shadowTangentLength(shadow[i].shadowToEyeMatrix[1], Peye));
|
||||
}
|
||||
}
|
||||
|
||||
#define COMPUTE_SHADOW_FILTER_WIDTH 1
|
||||
|
||||
#endif // NUM_SHADOWS == 0
|
||||
|
||||
-- glsl SimpleLighting.LightIntegrator
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// struct definitions
|
||||
// ---------------------------------------------------------------------------
|
||||
#ifndef NUM_LIGHTS
|
||||
#define NUM_LIGHTS 0
|
||||
#endif
|
||||
#ifndef NUM_SHADOWS
|
||||
#define NUM_SHADOWS 0
|
||||
#endif
|
||||
|
||||
#ifndef HD_HAS_integrateLights
|
||||
#define HD_HAS_integrateLights
|
||||
#endif
|
||||
|
||||
struct LightSource {
|
||||
vec4 position;
|
||||
vec4 ambient;
|
||||
vec4 diffuse;
|
||||
vec4 specular;
|
||||
vec4 spotDirection;
|
||||
vec4 spotCutoffAndFalloff;
|
||||
vec4 attenuation;
|
||||
mat4 worldToLightTransform;
|
||||
int shadowIndexStart;
|
||||
int shadowIndexEnd;
|
||||
bool hasShadow;
|
||||
bool isIndirectLight;
|
||||
};
|
||||
|
||||
struct ShadowMatrix {
|
||||
mat4 eyeToShadowMatrix;
|
||||
mat4 shadowToEyeMatrix;
|
||||
float blur;
|
||||
float bias;
|
||||
float padding0;
|
||||
float padding1;
|
||||
};
|
||||
|
||||
struct LightingContribution {
|
||||
vec3 ambient;
|
||||
vec3 diffuse;
|
||||
vec3 specular;
|
||||
};
|
||||
|
||||
struct LightingInterfaceProperties {
|
||||
float shininess;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// uniform blocks
|
||||
// ---------------------------------------------------------------------------
|
||||
#if NUM_LIGHTS == 0
|
||||
|
||||
#else // NUM_LIGHTS == 0
|
||||
|
||||
layout(std140) uniform Lighting {
|
||||
bool useLighting;
|
||||
bool useColorMaterialDiffuse;
|
||||
LightSource lightSource[NUM_LIGHTS];
|
||||
};
|
||||
|
||||
#endif // NUM_LIGHTS == 0
|
||||
|
||||
#if NUM_SHADOWS == 0
|
||||
|
||||
#else // NUM_SHADOWS == 0
|
||||
|
||||
layout(std140) uniform Shadow {
|
||||
ShadowMatrix shadow[NUM_SHADOWS];
|
||||
};
|
||||
|
||||
float
|
||||
shadowTangentLength(vec4 dir, vec4 Peye)
|
||||
{
|
||||
const vec3 shadowTangent = dir.xyz * Peye.w - dir.w * Peye.xyz;
|
||||
return length(shadowTangent);
|
||||
}
|
||||
|
||||
vec2
|
||||
computeShadowFilterWidth(int index, vec4 Peye)
|
||||
{
|
||||
return
|
||||
vec2(shadow[index].blur) /
|
||||
vec2(shadowTangentLength(shadow[index].shadowToEyeMatrix[0], Peye),
|
||||
shadowTangentLength(shadow[index].shadowToEyeMatrix[1], Peye));
|
||||
}
|
||||
|
||||
#endif // NUM_SHADOWS == 0
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// textures
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#if USE_BINDLESS_SHADOW_TEXTURES
|
||||
#if NUM_SHADOWS > 0
|
||||
|
||||
uniform BindlessShadowSamplers {
|
||||
uvec2 shadowCompareTextures[NUM_SHADOWS];
|
||||
};
|
||||
#endif // NUM_SHADOWS > 0
|
||||
#else // USE_BINDLESS_SHADOW_TEXTURES
|
||||
|
||||
uniform sampler2DArray shadowTexture;
|
||||
uniform sampler2DArrayShadow shadowCompareTexture;
|
||||
|
||||
#endif // !USE_BINDLESS_SHADOW_TEXTURES
|
||||
// ---------------------------------------------------------------------------
|
||||
// lighting functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#if NUM_LIGHTS == 0
|
||||
|
||||
LightingContribution
|
||||
integrateLightsConstant(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
LightingContribution result;
|
||||
result.ambient = vec3(0.0);
|
||||
//pefectly diffuse white hemisphere contribution
|
||||
result.diffuse = vec3(1.0);
|
||||
result.specular = vec3(0.0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LightingContribution
|
||||
integrateLightsDefault(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
// If no lights, lighting contribution is zero.
|
||||
LightingContribution result;
|
||||
result.ambient = vec3(0.0);
|
||||
result.diffuse = vec3(0.0);
|
||||
result.specular = vec3(0.0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#else // NUM_LIGHTS == 0
|
||||
|
||||
#if NUM_SHADOWS > 0
|
||||
float
|
||||
shadowCompare(int shadowIndex, vec4 coord)
|
||||
{
|
||||
coord /= coord.w;
|
||||
coord.z = min(1, coord.z + shadow[shadowIndex].bias);
|
||||
|
||||
// Cascade selection (in shadowing()) ensures Pshadow.xy is in [0,1],
|
||||
// but shadowFilter() can throw that off so we need to clamp.
|
||||
// XXX: sample the next cascade over?
|
||||
coord.xy = clamp(coord.xy, vec2(0), vec2(1));
|
||||
|
||||
#if USE_BINDLESS_SHADOW_TEXTURES
|
||||
return texture(sampler2DShadow(shadowCompareTextures[shadowIndex]), coord.xyz);
|
||||
#else
|
||||
return texture(shadowCompareTexture,
|
||||
vec4(coord.x, coord.y, shadowIndex, coord.z));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef SHADOW_FILTER
|
||||
float
|
||||
shadowFilter(int shadowIndex, vec4 coord, vec4 Peye)
|
||||
{
|
||||
return shadowCompare(index, coord);
|
||||
}
|
||||
#endif // SHADOW_FILTER
|
||||
#endif // NUM_SHADOWS > 0
|
||||
|
||||
float
|
||||
shadowing(int lightIndex, vec4 Peye)
|
||||
{
|
||||
#if NUM_SHADOWS > 0
|
||||
for (int shadowIndex = lightSource[lightIndex].shadowIndexStart;
|
||||
shadowIndex <= lightSource[lightIndex].shadowIndexEnd;
|
||||
++shadowIndex) {
|
||||
|
||||
vec4 coord = shadow[shadowIndex].eyeToShadowMatrix * Peye;
|
||||
|
||||
// If the point-to-be-lit isn't covered by this cascade, skip to
|
||||
// the next one...
|
||||
if (any(lessThan(coord.xyz, vec3(0))) ||
|
||||
any(greaterThan(coord.xyz, coord.www))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return shadowFilter(shadowIndex, coord, Peye);
|
||||
}
|
||||
#endif // NUM_SHADOWS > 0
|
||||
// ... either no shadows, or no coverage.
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
float
|
||||
lightDistanceAttenuation(vec4 Peye, int index)
|
||||
{
|
||||
float distAtten = 1.0;
|
||||
if (lightSource[index].position.w != 0.0) {
|
||||
float d = distance(lightSource[index].position, Peye);
|
||||
distAtten = 1.0 / (lightSource[index].attenuation[0] +
|
||||
lightSource[index].attenuation[1] * d +
|
||||
lightSource[index].attenuation[2] * d*d);
|
||||
}
|
||||
return distAtten;
|
||||
}
|
||||
|
||||
float
|
||||
lightSpotAttenuation(vec3 l, int index)
|
||||
{
|
||||
float spotAtten = 1.0;
|
||||
if (lightSource[index].spotCutoffAndFalloff.x < 180.0) {
|
||||
float cosLight = dot(-l, lightSource[index].spotDirection.xyz);
|
||||
spotAtten = (cosLight < cos(radians(lightSource[index].spotCutoffAndFalloff.x)))
|
||||
? 0.0 : pow(cosLight, lightSource[index].spotCutoffAndFalloff.y);
|
||||
}
|
||||
return spotAtten;
|
||||
}
|
||||
|
||||
// for the comaptibility, turn on shadowing by default.
|
||||
#ifndef USE_SHADOWS
|
||||
#define USE_SHADOWS 1
|
||||
#endif
|
||||
|
||||
LightingContribution
|
||||
integrateLightsDefault(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
LightingContribution result;
|
||||
result.ambient = vec3(0);
|
||||
result.diffuse = vec3(0);
|
||||
result.specular = vec3(0);
|
||||
|
||||
vec3 n = normalize(Neye);
|
||||
vec3 e = normalize(-Peye.xyz);
|
||||
|
||||
float shininess = props.shininess;
|
||||
|
||||
for (int i = 0; i < NUM_LIGHTS; ++i) {
|
||||
|
||||
vec4 Plight = lightSource[i].position;
|
||||
|
||||
vec3 l = (Plight.w == 0.0)
|
||||
? normalize(Plight.xyz)
|
||||
: normalize(Plight - Peye).xyz;
|
||||
|
||||
vec3 h = normalize(l + vec3(0,0,1)); // directional viewer
|
||||
|
||||
//cosine of incident angle of lightn
|
||||
float NdotL = max(0.0, dot(n, l));
|
||||
|
||||
//cosine of incident angle from halfway vector between the eye and the light
|
||||
float NdotH = max(0.0, dot(n, h));
|
||||
|
||||
//Lambert
|
||||
float d = NdotL;
|
||||
|
||||
//Blinn-Phong
|
||||
float s = pow(NdotH, shininess);
|
||||
|
||||
float atten = lightDistanceAttenuation(Peye, i);
|
||||
atten *= lightSpotAttenuation(l, i);
|
||||
|
||||
#if USE_SHADOWS
|
||||
float shadow = (lightSource[i].hasShadow) ?
|
||||
shadowing(/*lightIndex=*/i, Peye) : 1.0;
|
||||
#else
|
||||
float shadow = 1.0;
|
||||
#endif
|
||||
result.ambient += atten * lightSource[i].ambient.rgb;
|
||||
result.diffuse += atten * shadow * d * lightSource[i].diffuse.rgb;
|
||||
result.specular += atten * shadow * s * lightSource[i].specular.rgb;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LightingContribution
|
||||
integrateLightsConstant(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
LightingContribution result;
|
||||
result.ambient = vec3(0);
|
||||
result.specular = vec3(0);
|
||||
result.diffuse = vec3(1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // NUM_LIGHTS == 0
|
||||
|
||||
-- glsl SimpleLighting.SimpleLighting
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// struct definitions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// uniform blocks
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
layout(std140) uniform Material {
|
||||
vec4 ambient;
|
||||
vec4 diffuse;
|
||||
vec4 specular;
|
||||
vec4 emission;
|
||||
vec4 sceneColor;
|
||||
float shininess;
|
||||
} material;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// textures
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// lighting functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
LightingContribution
|
||||
integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props);
|
||||
|
||||
vec4
|
||||
simpleLighting(vec4 color, vec4 Peye, vec3 Neye, vec4 Ctint,
|
||||
vec4 matDiffuse, vec4 matAmbient, vec4 matSpecular, float matShininess)
|
||||
{
|
||||
|
||||
// Get the roughness and metallic values
|
||||
|
||||
#if defined(HD_HAS_displayRoughness)
|
||||
float roughness = max(0.0, min(1.0, float(HdGet_displayRoughness())));
|
||||
#else
|
||||
float roughness = 0.0;
|
||||
#endif
|
||||
|
||||
#if defined(HD_HAS_displayMetallic)
|
||||
float metallic = max(0.0, min(1.0, float(HdGet_displayMetallic())));
|
||||
#else
|
||||
float metallic = 0.0;
|
||||
#endif
|
||||
|
||||
// determine the specular and diffuse intensity
|
||||
float Ks = (1.0 - roughness) + 2.0 * metallic;
|
||||
|
||||
LightingInterfaceProperties props;
|
||||
|
||||
#if defined(HD_HAS_displayRoughness)
|
||||
float specularExp = (1.0 - roughness) * 120.0 + 8.0;
|
||||
props.shininess = specularExp;
|
||||
matSpecular.rgb = mix(vec3(1.0), matDiffuse.rgb, metallic);
|
||||
#else
|
||||
props.shininess = matShininess;
|
||||
#endif
|
||||
|
||||
LightingContribution light = integrateLights(Peye, Neye, props);
|
||||
|
||||
color.rgb += light.ambient * matAmbient.rgb;
|
||||
color.rgb += Ctint.rgb * light.diffuse * matDiffuse.rgb;
|
||||
color.rgb += Ks * light.specular * matSpecular.rgb;
|
||||
|
||||
color.a = matDiffuse.a;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
vec4
|
||||
simpleLightingMaterial(vec4 color, vec4 Peye, vec3 Neye, vec4 Ctint)
|
||||
{
|
||||
// XXX todo: useColorMaterialDiffuse
|
||||
|
||||
vec4 diffuse = color;
|
||||
vec4 ambient = material.ambient;
|
||||
vec4 specular = material.specular;
|
||||
float shininess = material.shininess;
|
||||
|
||||
color = material.emission + (material.sceneColor * material.ambient);
|
||||
|
||||
return simpleLighting(color, Peye, Neye, Ctint,
|
||||
diffuse, ambient, specular, shininess);
|
||||
}
|
||||
|
||||
vec4
|
||||
simpleLighting(vec4 color, vec4 Peye, vec3 Neye, vec4 Ctint)
|
||||
{
|
||||
return simpleLightingMaterial(color, Peye, Neye, Ctint);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {},
|
||||
"LibraryPath": "../../usd_hd.dll",
|
||||
"Name": "hd",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"ShaderResources": "shaders"
|
||||
},
|
||||
"LibraryPath": "../../usd_hdSt.dll",
|
||||
"Name": "hdSt",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,967 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/basisCurves.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/instancing.glslfx
|
||||
#import $TOOLS/hdSt/shaders/terminals.glslfx
|
||||
#import $TOOLS/hdSt/shaders/pointId.glslfx
|
||||
#import $TOOLS/hdSt/shaders/visibility.glslfx
|
||||
|
||||
// Known issues:
|
||||
// * The direction of the 'v' post tessellation is inconsistent between
|
||||
// curve representations with regards to whether it increases from left to right
|
||||
// or right to left. If we start using materials that require 'v', we should fix
|
||||
// this to be both consistent and match the RenderMan default orientation.
|
||||
//
|
||||
// * RenderMan uses 'u' describe the parameter along curve profile and 'v' to
|
||||
// describe the curve length. It's opposite here. It would be good to align
|
||||
// these once we start to use 'u' and 'v' in curve materials.
|
||||
//
|
||||
// * We might want to explore using fractional_even_spacing to better preserve
|
||||
// the shape of cubic curves.
|
||||
//
|
||||
// * We've realized that u appears to be 'backwards' in many cases, and so we
|
||||
// have updated many of the functions to use
|
||||
// mix(endPointValue, startPointValue, u) when intuitively it should be
|
||||
// the other way around.
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Vertex.Patch
|
||||
|
||||
out CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData;
|
||||
|
||||
// We will either generate a camera facing normal or use the authored normal.
|
||||
vec3 getNormal(MAT4 transform);
|
||||
// Fwd declare methods defined in pointId.glslfx, that are used below.
|
||||
int GetPointId();
|
||||
float GetPointRasterSize(int);
|
||||
void ProcessPointId(int);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
MAT4 transform = ApplyInstanceTransform(HdGet_transform());
|
||||
MAT4 transformInv = ApplyInstanceTransformInverse(HdGet_transformInverse());
|
||||
|
||||
outData.Peye = vec4(GetWorldToViewMatrix() * transform *
|
||||
vec4(HdGet_points(), 1));
|
||||
outData.Neye = getNormal(transpose(transformInv *
|
||||
GetWorldToViewInverseMatrix()));
|
||||
|
||||
ProcessPrimvars();
|
||||
|
||||
gl_Position = vec4(GetProjectionMatrix() * outData.Peye);
|
||||
ApplyClipPlanes(outData.Peye);
|
||||
|
||||
int pointId = GetPointId();
|
||||
gl_PointSize = GetPointRasterSize(pointId);
|
||||
ProcessPointId(pointId);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Vertex.Normal.Implicit
|
||||
|
||||
vec3 getNormal(MAT4 transform)
|
||||
{
|
||||
// Generate a camera-facing normal in camera/eye space, designed to match
|
||||
// RenderMan.
|
||||
return vec3(0, 0, 1);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Vertex.Normal.Oriented
|
||||
|
||||
vec3 getNormal(MAT4 transform)
|
||||
{
|
||||
return (transform * vec4(HdGet_normals(), 0)).xyz;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Vertex.Wire
|
||||
|
||||
out CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
} outData;
|
||||
|
||||
// Fwd declare methods defined in pointId.glslfx, that are used below.
|
||||
int GetPointId();
|
||||
float GetPointRasterSize(int);
|
||||
void ProcessPointId(int);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
MAT4 transform = ApplyInstanceTransform(HdGet_transform());
|
||||
|
||||
outData.Peye = vec4(GetWorldToViewMatrix() * transform *
|
||||
vec4(HdGet_points(), 1));
|
||||
|
||||
ProcessPrimvars();
|
||||
|
||||
gl_Position = vec4(GetProjectionMatrix() * outData.Peye);
|
||||
ApplyClipPlanes(outData.Peye);
|
||||
|
||||
int pointId = GetPointId();
|
||||
gl_PointSize = GetPointRasterSize(pointId);
|
||||
ProcessPointId(pointId);}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessControl.Shared
|
||||
|
||||
float GetMaxTess()
|
||||
{
|
||||
// Should be replaced with a uniform
|
||||
return 40;
|
||||
}
|
||||
|
||||
float GetPixelToTessRatio()
|
||||
{
|
||||
// Should be replaced with a uniform
|
||||
return 20.0;
|
||||
}
|
||||
|
||||
vec2 projectToScreen(MAT4 projMat, vec4 vertex, vec2 screen_size)
|
||||
{
|
||||
vec4 res = vec4(projMat * vertex);
|
||||
res /= res.w;
|
||||
return (clamp(res.xy, -1.3, 1.3) + 1) * (screen_size * 0.5);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessControl.Linear.Patch
|
||||
|
||||
layout(vertices = HD_NUM_PATCH_EVAL_VERTS) out;
|
||||
|
||||
in CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inData[gl_MaxPatchVertices];
|
||||
|
||||
out CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData[HD_NUM_PATCH_EVAL_VERTS];
|
||||
|
||||
void determineLODSettings();
|
||||
void main(void)
|
||||
{
|
||||
if(gl_InvocationID == 0) {
|
||||
determineLODSettings();
|
||||
}
|
||||
|
||||
outData[gl_InvocationID].Peye = inData[gl_InvocationID].Peye;
|
||||
outData[gl_InvocationID].Neye = inData[gl_InvocationID].Neye;
|
||||
|
||||
ProcessPrimvars();
|
||||
}
|
||||
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessControl.Linear.Ribbon
|
||||
|
||||
// Use the length of the control points in screen space to determine how many
|
||||
// times to subdivide the curve.
|
||||
void determineLODSettings()
|
||||
{
|
||||
gl_TessLevelOuter[0] = 1;
|
||||
gl_TessLevelOuter[1] = 1;
|
||||
gl_TessLevelOuter[2] = 1;
|
||||
gl_TessLevelOuter[3] = 1;
|
||||
|
||||
gl_TessLevelInner[0] = 1;
|
||||
gl_TessLevelInner[1] = 1;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessControl.Linear.HalfTube
|
||||
|
||||
// Use the width of the control points in screen space to determine how
|
||||
// many times to subdivide the curve. NOTE. As a quick hack, we leverage the
|
||||
// fact that the normal isn't normalized at this point in the pipeline to
|
||||
// provide a quick estimate of width in eye space. If that becomes a bad
|
||||
// assumption in the future, this needs to be reworked.
|
||||
void determineLODSettings()
|
||||
{
|
||||
MAT4 projMat = GetProjectionMatrix();
|
||||
vec4 viewport = GetViewport();
|
||||
vec2 screen_size = vec2(viewport.z, viewport.w);
|
||||
|
||||
// NOTE. We've observed that outData.Neye is not normalized, and
|
||||
// we're using its length as an estimator of the accumulated transform
|
||||
float wEye0 = HdGet_widths(0) * length(inData[0].Neye);
|
||||
float wEye1 = HdGet_widths(1) * length(inData[1].Neye);
|
||||
|
||||
// project a point that is 'w' units away from the origin
|
||||
vec2 v_w0 = projectToScreen(projMat, vec4(wEye0, 0, 0, 1), screen_size);
|
||||
vec2 v_w1 = projectToScreen(projMat, vec4(wEye1, 0, 0, 1), screen_size);
|
||||
|
||||
float maxTess = GetMaxTess();
|
||||
// reduce the tessellation in the width by this value.
|
||||
float widthDecimation = 10.0;
|
||||
|
||||
float maxWidthScreenSpace = max(length(v_w0), length(v_w1));
|
||||
|
||||
float level_w = clamp(maxWidthScreenSpace / GetPixelToTessRatio() / widthDecimation, 1, maxTess);
|
||||
|
||||
gl_TessLevelOuter[0] = 1;
|
||||
gl_TessLevelOuter[1] = level_w;
|
||||
gl_TessLevelOuter[2] = 1;
|
||||
gl_TessLevelOuter[3] = level_w;
|
||||
|
||||
gl_TessLevelInner[0] = level_w;
|
||||
gl_TessLevelInner[1] = 1;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessControl.Cubic.Wire
|
||||
|
||||
layout(vertices = HD_NUM_PATCH_EVAL_VERTS) out;
|
||||
|
||||
in CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
} inData[gl_MaxPatchVertices];
|
||||
|
||||
out CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
} outData[HD_NUM_PATCH_EVAL_VERTS];
|
||||
|
||||
void determineLODSettings();
|
||||
void main(void)
|
||||
{
|
||||
if(gl_InvocationID == 0) {
|
||||
determineLODSettings();
|
||||
}
|
||||
|
||||
outData[gl_InvocationID].Peye = inData[gl_InvocationID].Peye;
|
||||
|
||||
ProcessPrimvars();
|
||||
}
|
||||
|
||||
// Use the length of the control points in screen space to determine how many
|
||||
// times to subdivide the curve.
|
||||
void determineLODSettings()
|
||||
{
|
||||
MAT4 projMat = GetProjectionMatrix();
|
||||
vec4 viewport = GetViewport();
|
||||
vec2 screen_size = vec2(viewport.z, viewport.w);
|
||||
vec2 v0 = projectToScreen(projMat, inData[0].Peye, screen_size);
|
||||
vec2 v1 = projectToScreen(projMat, inData[1].Peye, screen_size);
|
||||
vec2 v2 = projectToScreen(projMat, inData[2].Peye, screen_size);
|
||||
vec2 v3 = projectToScreen(projMat, inData[3].Peye, screen_size);
|
||||
|
||||
float maxTess = GetMaxTess();
|
||||
|
||||
// Need to handle off screen
|
||||
float dist = distance(v0, v1) + distance(v1, v2) + distance(v2, v3);
|
||||
float level = clamp(dist / GetPixelToTessRatio(), 0, maxTess);
|
||||
|
||||
gl_TessLevelOuter[0] = 1;
|
||||
gl_TessLevelOuter[1] = level;
|
||||
}
|
||||
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessControl.Cubic.Patch
|
||||
|
||||
layout(vertices = HD_NUM_PATCH_EVAL_VERTS) out;
|
||||
|
||||
in CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inData[gl_MaxPatchVertices];
|
||||
|
||||
out CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData[HD_NUM_PATCH_EVAL_VERTS];
|
||||
|
||||
void determineLODSettings();
|
||||
void main(void)
|
||||
{
|
||||
if(gl_InvocationID == 0) {
|
||||
determineLODSettings();
|
||||
}
|
||||
|
||||
outData[gl_InvocationID].Peye = inData[gl_InvocationID].Peye;
|
||||
outData[gl_InvocationID].Neye = inData[gl_InvocationID].Neye;
|
||||
|
||||
ProcessPrimvars();
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessControl.Cubic.Ribbon
|
||||
|
||||
// Use the length of the control points in screen space to determine how many
|
||||
// times to subdivide the curve.
|
||||
void determineLODSettings()
|
||||
{
|
||||
MAT4 projMat = GetProjectionMatrix();
|
||||
vec4 viewport = GetViewport();
|
||||
vec2 screen_size = vec2(viewport.z, viewport.w);
|
||||
vec2 v0 = projectToScreen(projMat, inData[0].Peye, screen_size);
|
||||
vec2 v1 = projectToScreen(projMat, inData[1].Peye, screen_size);
|
||||
vec2 v2 = projectToScreen(projMat, inData[2].Peye, screen_size);
|
||||
vec2 v3 = projectToScreen(projMat, inData[3].Peye, screen_size);
|
||||
|
||||
float maxTess = GetMaxTess();
|
||||
|
||||
// Need to handle off screen
|
||||
float dist = distance(v0, v1) + distance(v1, v2) + distance(v2, v3);
|
||||
float level = clamp(dist / GetPixelToTessRatio(), 0, maxTess);
|
||||
|
||||
gl_TessLevelOuter[0] = level;
|
||||
gl_TessLevelOuter[1] = 1;
|
||||
gl_TessLevelOuter[2] = level;
|
||||
gl_TessLevelOuter[3] = 1;
|
||||
|
||||
gl_TessLevelInner[0] = 1;
|
||||
gl_TessLevelInner[1] = level;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessControl.Cubic.HalfTube
|
||||
|
||||
// Use the width & length of the control points in screen space to determine how
|
||||
// many times to subdivide the curve. NOTE. As a quick hack, we leverage the
|
||||
// fact that the normal isn't normalized at this point in the pipeline to
|
||||
// provide a quick estimate of width in eye space. If that becomes a bad
|
||||
// assumption in the future, this needs to be reworked.
|
||||
void determineLODSettings()
|
||||
{
|
||||
MAT4 projMat = GetProjectionMatrix();
|
||||
vec4 viewport = GetViewport();
|
||||
vec2 screen_size = vec2(viewport.z, viewport.w);
|
||||
vec2 v0 = projectToScreen(projMat, inData[0].Peye, screen_size);
|
||||
vec2 v1 = projectToScreen(projMat, inData[1].Peye, screen_size);
|
||||
vec2 v2 = projectToScreen(projMat, inData[2].Peye, screen_size);
|
||||
vec2 v3 = projectToScreen(projMat, inData[3].Peye, screen_size);
|
||||
|
||||
// NOTE. We've observed that outData.Neye is not normalized, and
|
||||
// we're using its length as an estimator of the accumulated transform
|
||||
float wEye0 = HdGet_widths(0) * length(inData[0].Neye);
|
||||
float wEye1 = HdGet_widths(1) * length(inData[1].Neye);
|
||||
float wEye2 = HdGet_widths(2) * length(inData[2].Neye);
|
||||
float wEye3 = HdGet_widths(3) * length(inData[3].Neye);
|
||||
|
||||
// project a point that is 'w' units away from the origin
|
||||
vec2 v_w0 = projectToScreen(projMat, vec4(wEye0, 0, 0, 1), screen_size);
|
||||
vec2 v_w1 = projectToScreen(projMat, vec4(wEye1, 0, 0, 1), screen_size);
|
||||
vec2 v_w2 = projectToScreen(projMat, vec4(wEye2, 0, 0, 1), screen_size);
|
||||
vec2 v_w3 = projectToScreen(projMat, vec4(wEye3, 0, 0, 1), screen_size);
|
||||
|
||||
float maxTess = GetMaxTess();
|
||||
// reduce the tessellation in the width by this value.
|
||||
float widthDecimation = 10.0;
|
||||
|
||||
// Need to handle off screen
|
||||
float dist = distance(v0, v1) + distance(v1, v2) + distance(v2, v3);
|
||||
float level = clamp(dist / GetPixelToTessRatio(), 0, maxTess);
|
||||
|
||||
float maxWidthScreenSpace =
|
||||
max(max(max(length(v_w0), length(v_w1)), length(v_w2)), length(v_w3));
|
||||
|
||||
float level_w = clamp(maxWidthScreenSpace / GetPixelToTessRatio() / widthDecimation, 1, maxTess);
|
||||
|
||||
gl_TessLevelOuter[0] = level;
|
||||
gl_TessLevelOuter[1] = level_w;
|
||||
gl_TessLevelOuter[2] = level;
|
||||
gl_TessLevelOuter[3] = level_w;
|
||||
|
||||
gl_TessLevelInner[0] = level_w;
|
||||
gl_TessLevelInner[1] = level;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessEval.Cubic.Wire
|
||||
|
||||
layout(isolines, fractional_odd_spacing) in;
|
||||
|
||||
struct Coeffs
|
||||
{
|
||||
vec4 basis;
|
||||
vec4 tangent_basis;
|
||||
};
|
||||
|
||||
in CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
} inData[gl_MaxPatchVertices];
|
||||
|
||||
out CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
} outData;
|
||||
|
||||
Coeffs evaluateBasis(float u, float u2, float u3);
|
||||
|
||||
void main()
|
||||
{
|
||||
float u = gl_TessCoord.x;
|
||||
float v = .5;
|
||||
|
||||
vec4 cv0 = inData[0].Peye;
|
||||
vec4 cv1 = inData[1].Peye;
|
||||
vec4 cv2 = inData[2].Peye;
|
||||
vec4 cv3 = inData[3].Peye;
|
||||
|
||||
Coeffs coeffs = evaluateBasis(u, u*u, u*u*u);
|
||||
vec4 basis = coeffs.basis;
|
||||
vec4 pos = basis[0] * cv0 +
|
||||
basis[1] * cv1 +
|
||||
basis[2] * cv2 +
|
||||
basis[3] * cv3;
|
||||
|
||||
outData.Peye = pos;
|
||||
gl_Position = vec4(GetProjectionMatrix() * outData.Peye);
|
||||
|
||||
ApplyClipPlanes(outData.Peye);
|
||||
|
||||
ProcessPrimvars(basis, 0, 1, 2, 3, vec2(u, v)); // interpolate varying primvars
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessEval.Patch
|
||||
|
||||
layout(quads, fractional_odd_spacing, ccw) in;
|
||||
|
||||
struct Coeffs
|
||||
{
|
||||
vec4 basis;
|
||||
vec4 tangent_basis;
|
||||
};
|
||||
|
||||
in CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inData[gl_MaxPatchVertices];
|
||||
|
||||
out CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData;
|
||||
|
||||
out float u;
|
||||
out float v;
|
||||
|
||||
// Predefine so that we can later swap in the correct one depending
|
||||
// on what type of curve we have
|
||||
|
||||
void evaluate(float u, float v, out vec4 position, out vec4 tangent,
|
||||
out float width, out vec3 normal);
|
||||
|
||||
Coeffs evaluateBasis(float u, float u2, float u3);
|
||||
|
||||
// it's the responsibility of orient to store Neye, usually with either
|
||||
// the computed normal or the tangent (from which the normal will be computed
|
||||
// in the fragment shader.)
|
||||
vec3 orient(float v, vec4 position, vec4 tangent, vec3 normal);
|
||||
void main()
|
||||
{
|
||||
u = gl_TessCoord.y;
|
||||
v = gl_TessCoord.x;
|
||||
|
||||
Coeffs coeffs = evaluateBasis(u, u*u, u*u*u);
|
||||
vec4 basis = coeffs.basis;
|
||||
|
||||
vec4 position;
|
||||
vec4 tangent;
|
||||
float width;
|
||||
vec3 normal;
|
||||
|
||||
evaluate(u, v, position, tangent, width, normal);
|
||||
vec3 direction = orient(v, position, tangent, normal);
|
||||
MAT4 transform = ApplyInstanceTransform(HdGet_transform());
|
||||
vec4 scaledDirection = GetWorldToViewMatrix() * transform
|
||||
* vec4(direction, 0);
|
||||
vec3 offset = direction * length(scaledDirection.xyz) * width * 0.5;
|
||||
position.xyz = position.xyz + offset;
|
||||
position.w = 1;
|
||||
|
||||
outData.Peye = position;
|
||||
|
||||
gl_Position = vec4(GetProjectionMatrix() * outData.Peye);
|
||||
ApplyClipPlanes(outData.Peye);
|
||||
|
||||
ProcessPrimvars(basis, 0, 1, 2, 3, vec2(u, v)); // interpolate varying primvars
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessEval.Linear.Patch
|
||||
|
||||
vec3 evaluateNormal(float u)
|
||||
{
|
||||
// XXX: This clamp is a hack to mask some odd orientation flipping issues
|
||||
u = clamp(u, 1e-3, 1.0 - 1e-3);
|
||||
return mix(inData[1].Neye, inData[0].Neye, u);
|
||||
}
|
||||
|
||||
void evaluate(float u, float v, out vec4 position, out vec4 tangent,
|
||||
out float width, out vec3 normal){
|
||||
vec4 p0 = inData[0].Peye;
|
||||
vec4 p1 = inData[1].Peye;
|
||||
|
||||
float w0 = HdGet_widths(0);
|
||||
float w1 = HdGet_widths(1);
|
||||
|
||||
position = mix(p1, p0, u);
|
||||
tangent = normalize(p1 - p0);
|
||||
width = mix(w1, w0, u);
|
||||
normal = normalize(evaluateNormal(u));
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessEval.Cubic.Patch
|
||||
struct Coeffs
|
||||
{
|
||||
vec4 basis;
|
||||
vec4 tangent_basis;
|
||||
};
|
||||
|
||||
Coeffs evaluateBasis(float u, float u2, float u3);
|
||||
float evaluateWidths(vec4 basis, float u);
|
||||
vec3 evaluateNormal(vec4 basis, float u);
|
||||
|
||||
void evaluate(float u, float v, out vec4 position, out vec4 tangent,
|
||||
out float width, out vec3 normal){
|
||||
vec4 p0 = inData[0].Peye;
|
||||
vec4 p1 = inData[1].Peye;
|
||||
vec4 p2 = inData[2].Peye;
|
||||
vec4 p3 = inData[3].Peye;
|
||||
|
||||
Coeffs coeffs = evaluateBasis(u, u*u, u*u*u);
|
||||
|
||||
position = coeffs.basis[0] * p0 +
|
||||
coeffs.basis[1] * p1 +
|
||||
coeffs.basis[2] * p2 +
|
||||
coeffs.basis[3] * p3;
|
||||
|
||||
tangent = coeffs.tangent_basis[0] * p0 +
|
||||
coeffs.tangent_basis[1] * p1 +
|
||||
coeffs.tangent_basis[2] * p2 +
|
||||
coeffs.tangent_basis[3] * p3;
|
||||
|
||||
width = evaluateWidths(coeffs.basis, u);
|
||||
normal = normalize(evaluateNormal(coeffs.basis, u));
|
||||
tangent = normalize(tangent);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessEval.HalfTube
|
||||
|
||||
vec3 orient(float v, vec4 position, vec4 tangent, vec3 normal){
|
||||
outData.Neye = tangent.xyz;
|
||||
vec3 d = normalize(cross(position.xyz, tangent.xyz));
|
||||
vec3 n = normalize(cross(d, tangent.xyz));
|
||||
|
||||
vec3 norm_pos = mix(n, d, (2.0*v) - 1.0);
|
||||
vec3 norm_neg = mix(-d, n, (2.0*v));
|
||||
normal = normalize(mix(norm_neg, norm_pos, step(0.5, v)));
|
||||
return normal;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessEval.Ribbon.Oriented
|
||||
|
||||
vec3 orient(float v, vec4 position, vec4 tangent, vec3 normal){
|
||||
outData.Neye = normal;
|
||||
return normalize(cross(tangent.xyz, normal) * (v - 0.5));
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.TessEval.Ribbon.Implicit
|
||||
|
||||
vec3 orient(float v, vec4 position, vec4 tangent, vec3 normal){
|
||||
outData.Neye = tangent.xyz;
|
||||
// NOTE: lava/lib/basisCurves currently uses tangent X position instead of
|
||||
// tangent X normal. We should do a more thorough evaluation to see which
|
||||
// is better but to minimize regressions, we're going to keep this as
|
||||
// tangent X normal for now.
|
||||
return normalize(cross(tangent.xyz, normal) * (v - 0.5));
|
||||
}
|
||||
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Cubic.Normals.Basis
|
||||
|
||||
vec3 evaluateNormal(vec4 basis, float u)
|
||||
{
|
||||
vec3 n0 = inData[0].Neye;
|
||||
vec3 n1 = inData[1].Neye;
|
||||
vec3 n2 = inData[2].Neye;
|
||||
vec3 n3 = inData[3].Neye;
|
||||
return n0 * basis.x
|
||||
+ n1 * basis.y
|
||||
+ n2 * basis.z
|
||||
+ n3 * basis.w;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Cubic.Normals.Linear
|
||||
|
||||
// HdSt only supports vertex (cubic) primvar indexes and expands varying
|
||||
// (linear) primvars so we pull the data out of only the two interior indices.
|
||||
// This may not be valid for all potential basis, but works well for curves with
|
||||
// vstep = 1 and bezier, the only supported cubic curves in HdSt.
|
||||
|
||||
vec3 evaluateNormal(vec4 basis, float u)
|
||||
{
|
||||
// XXX: This clamp is a hack to mask some odd orientation flipping issues
|
||||
// for oriented bezier curves.
|
||||
u = clamp(u, 1e-3, 1.0 - 1e-3);
|
||||
return mix(inData[2].Neye, inData[1].Neye, u);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Cubic.Widths.Basis
|
||||
|
||||
float evaluateWidths(vec4 basis, float u)
|
||||
{
|
||||
float w0 = HdGet_widths(0);
|
||||
float w1 = HdGet_widths(1);
|
||||
float w2 = HdGet_widths(2);
|
||||
float w3 = HdGet_widths(3);
|
||||
return w0 * basis.x
|
||||
+ w1 * basis.y
|
||||
+ w2 * basis.z
|
||||
+ w3 * basis.w;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Cubic.Widths.Linear
|
||||
|
||||
// HdSt only supports vertex (cubic) primvar indexes and expands varying
|
||||
// (linear) primvars so we pull the data out of only the two interior indices.
|
||||
// (ie. w0 -> widths[1], w1 -> widths[2])
|
||||
// This may not be valid for all potential basis, but works well for curves with
|
||||
// vstep = 1 and bezier, the only supported cubic curves in HdSt.
|
||||
float evaluateWidths(vec4 basis, float u)
|
||||
{
|
||||
float w0 = HdGet_widths(1);
|
||||
float w1 = HdGet_widths(2);
|
||||
return mix(w1, w0, u);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Linear.VaryingInterpolation
|
||||
|
||||
float ProcessPrimvar(float inPv0, float inPv1, float inPv2, float inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return inPv0 * basis.x +
|
||||
inPv1 * basis.y +
|
||||
inPv2 * basis.z +
|
||||
inPv3 * basis.w;
|
||||
}
|
||||
|
||||
vec2 ProcessPrimvar(vec2 inPv0, vec2 inPv1, vec2 inPv2, vec2 inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return inPv0 * basis.x +
|
||||
inPv1 * basis.y +
|
||||
inPv2 * basis.z +
|
||||
inPv3 * basis.w;
|
||||
}
|
||||
|
||||
vec3 ProcessPrimvar(vec3 inPv0, vec3 inPv1, vec3 inPv2, vec3 inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return inPv0 * basis.x +
|
||||
inPv1 * basis.y +
|
||||
inPv2 * basis.z +
|
||||
inPv3 * basis.w;
|
||||
}
|
||||
|
||||
vec4 ProcessPrimvar(vec4 inPv0, vec4 inPv1, vec4 inPv2, vec4 inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return inPv0 * basis.x +
|
||||
inPv1 * basis.y +
|
||||
inPv2 * basis.z +
|
||||
inPv3 * basis.w;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Cubic.VaryingInterpolation
|
||||
|
||||
float ProcessPrimvar(float inPv0, float inPv1, float inPv2, float inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return mix(inPv2, inPv1, uv.x);
|
||||
}
|
||||
|
||||
vec2 ProcessPrimvar(vec2 inPv0, vec2 inPv1, vec2 inPv2, vec2 inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return mix(inPv2, inPv1, uv.x);
|
||||
}
|
||||
|
||||
vec3 ProcessPrimvar(vec3 inPv0, vec3 inPv1, vec3 inPv2, vec3 inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return mix(inPv2, inPv1, uv.x);
|
||||
}
|
||||
|
||||
vec4 ProcessPrimvar(vec4 inPv0, vec4 inPv1, vec4 inPv2, vec4 inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return mix(inPv2, inPv1, uv.x);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.BezierBasis
|
||||
|
||||
Coeffs evaluateBasis(float u, float u2, float u3)
|
||||
{
|
||||
vec4 basis; vec4 tangent_basis;
|
||||
basis[0] = u3;
|
||||
basis[1] = -3.0*u3 + 3.0*u2;
|
||||
basis[2] = 3.0*u3 - 6.0*u2 + 3.0*u;
|
||||
basis[3] = -1.0*u3 + 3.0*u2 - 3.0*u + 1.0;
|
||||
|
||||
tangent_basis[0] = 3.0*u2;
|
||||
tangent_basis[1] = -9.0*u2 + 6.0*u;
|
||||
tangent_basis[2] = 9.0*u2 - 12.0*u + 3.0;
|
||||
tangent_basis[3] = -3.0*u2 + 6.0*u - 3.0;
|
||||
return Coeffs(basis, tangent_basis);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.LinearBasis
|
||||
|
||||
Coeffs evaluateBasis(float u, float u2, float u3)
|
||||
{
|
||||
vec4 basis; vec4 tangent_basis;
|
||||
basis[0] = u;
|
||||
basis[1] = 1.0 - u;
|
||||
basis[2] = 0;
|
||||
basis[3] = 0.0;
|
||||
|
||||
tangent_basis[0] = 1;
|
||||
tangent_basis[1] = -1;
|
||||
tangent_basis[2] = 0;
|
||||
tangent_basis[3] = 0;
|
||||
return Coeffs(basis, tangent_basis);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.CatmullRomBasis
|
||||
|
||||
Coeffs evaluateBasis(float u, float u2, float u3)
|
||||
{
|
||||
vec4 basis; vec4 tangent_basis;
|
||||
basis[0] = 0.5*u3 - 0.5*u2;
|
||||
basis[1] = -1.5*u3 + 2.0*u2 + 0.5*u;
|
||||
basis[2] = 1.5*u3 - 2.5*u2 + 1.0;
|
||||
basis[3] = -0.5*u3 + u2 - 0.5*u;
|
||||
|
||||
tangent_basis[0] = 1.5*u2 - u;
|
||||
tangent_basis[1] = -4.5*u2 + 4.0*u + 0.5;
|
||||
tangent_basis[2] = 4.5*u2 - 5.0*u;
|
||||
tangent_basis[3] = -1.5*u2 + 2.0*u - 0.5;
|
||||
return Coeffs(basis, tangent_basis);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.BsplineBasis
|
||||
|
||||
Coeffs evaluateBasis(float u, float u2, float u3)
|
||||
{
|
||||
vec4 basis; vec4 tangent_basis;
|
||||
basis[0] = (1.0/6.0)*u3;
|
||||
basis[1] = -0.5*u3 + 0.5*u2 + 0.5*u + (1.0/6.0);
|
||||
basis[2] = 0.5*u3 - u2 + (2.0/3.0);
|
||||
basis[3] = -(1.0/6.0)*u3 + 0.5*u2 - 0.5*u + (1.0/6.0);
|
||||
|
||||
tangent_basis[0] = 0.5*u2;
|
||||
tangent_basis[1] = -1.5*u2 + u + 0.5;
|
||||
tangent_basis[2] = 1.5*u2 - 2.0*u;
|
||||
tangent_basis[3] = -0.5*u2 + u - 0.5;
|
||||
return Coeffs(basis, tangent_basis);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Fragment.Wire
|
||||
|
||||
in CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
} inData;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
DiscardBasedOnTopologicalVisibility();
|
||||
|
||||
vec4 color = vec4(0.5, 0.5, 0.5, 1);
|
||||
#ifdef HD_HAS_displayColor
|
||||
color.rgb = HdGet_displayColor().rgb;
|
||||
#endif
|
||||
#ifdef HD_HAS_displayOpacity
|
||||
color.a = HdGet_displayOpacity().r;
|
||||
#endif
|
||||
color.rgb = ApplyColorOverrides(color).rgb;
|
||||
|
||||
vec3 Peye = inData.Peye.xyz / inData.Peye.w;
|
||||
|
||||
// We would like to have a better oriented normal here, however to keep the
|
||||
// shader fast, we use this camera-facing approximation.
|
||||
vec3 Neye = vec3(0,0,1);
|
||||
|
||||
vec4 patchCoord = vec4(0);
|
||||
|
||||
color.rgb = mix(color.rgb,
|
||||
ShadingTerminal(vec4(Peye, 1), Neye, color, patchCoord).rgb,
|
||||
GetLightingBlendAmount());
|
||||
|
||||
#ifdef HD_MATERIAL_TAG_MASKED
|
||||
if (ShouldDiscardByAlpha(color)) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
RenderOutput(vec4(Peye, 1), Neye, color, patchCoord);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Fragment.Patch
|
||||
|
||||
/// In the previous stage, we may have stored the tangent in Neye from which
|
||||
/// we plan to compute a normal in the fragment shader.
|
||||
in CurveVertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inData;
|
||||
|
||||
centroid in float u;
|
||||
centroid in float v;
|
||||
|
||||
vec3 fragmentNormal(vec3 position, vec3 normal, float v);
|
||||
void main(void)
|
||||
{
|
||||
DiscardBasedOnTopologicalVisibility();
|
||||
|
||||
vec4 color = vec4(0.5, 0.5, 0.5, 1);
|
||||
#ifdef HD_HAS_displayColor
|
||||
color.rgb = HdGet_displayColor().rgb;
|
||||
#endif
|
||||
#ifdef HD_HAS_displayOpacity
|
||||
color.a = HdGet_displayOpacity().r;
|
||||
#endif
|
||||
color.rgb = ApplyColorOverrides(color).rgb;
|
||||
|
||||
vec3 Peye = inData.Peye.xyz / inData.Peye.w;
|
||||
|
||||
vec3 Neye = fragmentNormal(Peye, inData.Neye, v);
|
||||
|
||||
vec4 patchCoord = vec4(0);
|
||||
color.rgb = mix(color.rgb,
|
||||
ShadingTerminal(vec4(Peye, 1), Neye, color, patchCoord).rgb,
|
||||
GetLightingBlendAmount());
|
||||
|
||||
#ifdef HD_MATERIAL_TAG_MASKED
|
||||
if (ShouldDiscardByAlpha(color)) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
RenderOutput(vec4(Peye, 1), Neye, color, patchCoord);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Fragment.HalfTube
|
||||
|
||||
vec3 fragmentNormal(in vec3 position, in vec3 tangent, in float v)
|
||||
{
|
||||
vec3 d = normalize(cross(position, tangent));
|
||||
vec3 n = normalize(cross(d, tangent));
|
||||
vec3 norm_pos = mix(n, d, (2.0*v) - 1.0);
|
||||
vec3 norm_neg = mix(-d, n, (2.0*v));
|
||||
return normalize(mix(norm_neg, norm_pos, step(0.5, v)));
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Fragment.Ribbon.Round
|
||||
|
||||
float remapFragmentV(float v){
|
||||
// As we are using a plane to approximate a tube, we don't want to shade
|
||||
// based on v but rather the projection of the tube's v onto the plane
|
||||
return clamp((asin(v * 2.0 - 1.0) / (3.146 / 2.0) + 1.0) / 2.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec3 fragmentNormal(vec3 position, in vec3 tangent, float v)
|
||||
{
|
||||
|
||||
// we slightly bias v towards 0.5 based on filterwidth as a hack to
|
||||
// minimize aliasing
|
||||
v = mix(remapFragmentV(v), 0.5, min(fwidth(v), .2));
|
||||
|
||||
vec3 d = normalize(cross(position, tangent));
|
||||
vec3 n = normalize(cross(d, tangent));
|
||||
vec3 norm_pos = mix(n, d, (2.0*v) - 1.0);
|
||||
vec3 norm_neg = mix(-d, n, (2.0*v));
|
||||
|
||||
return normalize(mix(norm_neg, norm_pos, step(0.5, v)));
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Fragment.Ribbon.Oriented
|
||||
|
||||
vec3 fragmentNormal(vec3 position, in vec3 normal, float v)
|
||||
{
|
||||
normal = normalize(normal);
|
||||
if (gl_FrontFacing){
|
||||
return normal;
|
||||
}
|
||||
else{
|
||||
return -normal;
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Curves.Fragment.Hair
|
||||
|
||||
// XXX: Neye is interpolated in from previous stages, however the
|
||||
// polarity is not stable due to instability in the cross-product in the
|
||||
// TessEval shader. Once that is fixed, we could use Neye directly here.
|
||||
// The normal computed here results in faceted shading.
|
||||
//
|
||||
vec3 fragmentNormal(vec3 position, in vec3 unused, float v)
|
||||
{
|
||||
return cross(dFdx(position), dFdy(position));
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/compute.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"smoothNormalsFloatToFloat": {
|
||||
"source": [ "Compute.NormalsSrcFloat",
|
||||
"Compute.NormalsDstFloat",
|
||||
"Compute.SmoothNormals" ]
|
||||
},
|
||||
"smoothNormalsDoubleToDouble": {
|
||||
"source": [ "Compute.NormalsSrcDouble",
|
||||
"Compute.NormalsDstDouble",
|
||||
"Compute.SmoothNormals" ]
|
||||
},
|
||||
"smoothNormalsFloatToPacked": {
|
||||
"source": [ "Compute.NormalsSrcFloat",
|
||||
"Compute.NormalsDstPacked",
|
||||
"Compute.SmoothNormals" ]
|
||||
},
|
||||
"smoothNormalsDoubleToPacked": {
|
||||
"source": [ "Compute.NormalsSrcDouble",
|
||||
"Compute.NormalsDstPacked",
|
||||
"Compute.SmoothNormals" ]
|
||||
},
|
||||
"flatNormalsTriFloatToFloat": {
|
||||
"source": [ "Compute.NormalsSrcFloat",
|
||||
"Compute.NormalsDstFloat",
|
||||
"Compute.FlatNormals",
|
||||
"Compute.FlatNormalsTri" ]
|
||||
},
|
||||
"flatNormalsTriDoubleToDouble": {
|
||||
"source": [ "Compute.NormalsSrcDouble",
|
||||
"Compute.NormalsDstDouble",
|
||||
"Compute.FlatNormals",
|
||||
"Compute.FlatNormalsTri" ]
|
||||
},
|
||||
"flatNormalsTriFloatToPacked": {
|
||||
"source": [ "Compute.NormalsSrcFloat",
|
||||
"Compute.NormalsDstPacked",
|
||||
"Compute.FlatNormals",
|
||||
"Compute.FlatNormalsTri" ]
|
||||
},
|
||||
"flatNormalsTriDoubleToPacked": {
|
||||
"source": [ "Compute.NormalsSrcDouble",
|
||||
"Compute.NormalsDstPacked",
|
||||
"Compute.FlatNormals",
|
||||
"Compute.FlatNormalsTri" ]
|
||||
},
|
||||
"flatNormalsQuadFloatToFloat": {
|
||||
"source": [ "Compute.NormalsSrcFloat",
|
||||
"Compute.NormalsDstFloat",
|
||||
"Compute.FlatNormals",
|
||||
"Compute.FlatNormalsQuad" ]
|
||||
},
|
||||
"flatNormalsQuadDoubleToDouble": {
|
||||
"source": [ "Compute.NormalsSrcDouble",
|
||||
"Compute.NormalsDstDouble",
|
||||
"Compute.FlatNormals",
|
||||
"Compute.FlatNormalsQuad" ]
|
||||
},
|
||||
"flatNormalsQuadFloatToPacked": {
|
||||
"source": [ "Compute.NormalsSrcFloat",
|
||||
"Compute.NormalsDstPacked",
|
||||
"Compute.FlatNormals",
|
||||
"Compute.FlatNormalsQuad" ]
|
||||
},
|
||||
"flatNormalsQuadDoubleToPacked": {
|
||||
"source": [ "Compute.NormalsSrcDouble",
|
||||
"Compute.NormalsDstPacked",
|
||||
"Compute.FlatNormals",
|
||||
"Compute.FlatNormalsQuad" ]
|
||||
},
|
||||
"quadrangulateFloat": {
|
||||
"source": [ "Compute.QuadrangulateFloat",
|
||||
"Compute.Quadrangulate" ]
|
||||
},
|
||||
"quadrangulateDouble": {
|
||||
"source": [ "Compute.QuadrangulateDouble",
|
||||
"Compute.Quadrangulate" ]
|
||||
},
|
||||
"evalStencils": {
|
||||
"source": [ "Compute.EvalStencils" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.NormalsSrcFloat
|
||||
|
||||
vec3 getPoint(int index)
|
||||
{
|
||||
return vec3(points[index],
|
||||
points[index + 1],
|
||||
points[index + 2]);
|
||||
}
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.NormalsSrcDouble
|
||||
|
||||
vec3 getPoint(int index)
|
||||
{
|
||||
return vec3(points[index],
|
||||
points[index + 1],
|
||||
points[index + 2]);
|
||||
}
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.NormalsDstFloat
|
||||
|
||||
void writeNormal(int nIndex, vec3 normal)
|
||||
{
|
||||
normals[nIndex+0] = normal.x;
|
||||
normals[nIndex+1] = normal.y;
|
||||
normals[nIndex+2] = normal.z;
|
||||
}
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.NormalsDstDouble
|
||||
|
||||
void writeNormal(int nIndex, vec3 normal)
|
||||
{
|
||||
normals[nIndex+0] = normal.x;
|
||||
normals[nIndex+1] = normal.y;
|
||||
normals[nIndex+2] = normal.z;
|
||||
}
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.NormalsDstPacked
|
||||
|
||||
void writeNormal(int nIndex, vec3 normal)
|
||||
{
|
||||
normal *= 511.0;
|
||||
normals[nIndex] =
|
||||
((int(normal.x) & 0x3ff) ) |
|
||||
((int(normal.y) & 0x3ff) << 10) |
|
||||
((int(normal.z) & 0x3ff) << 20);
|
||||
}
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.SmoothNormals
|
||||
|
||||
int getPointsIndex(int idx)
|
||||
{
|
||||
return (idx+vertexOffset)*pointsStride + pointsOffset;
|
||||
}
|
||||
|
||||
int getNormalsIndex(int idx)
|
||||
{
|
||||
return (idx+vertexOffset)*normalsStride + normalsOffset;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
int index = int(hd_GlobalInvocationID.x);
|
||||
|
||||
int offIndex = index * 2 + adjacencyOffset;
|
||||
|
||||
int offset = entry[offIndex] + adjacencyOffset;
|
||||
int valence = entry[offIndex + 1];
|
||||
|
||||
vec3 normal = vec3(0);
|
||||
|
||||
vec3 current = getPoint(getPointsIndex(index));
|
||||
for (int i = 0; i < valence; ++i) {
|
||||
int entryIdx = i * 2 + offset;
|
||||
|
||||
int prevIdx = entry[entryIdx];
|
||||
int nextIdx = entry[entryIdx + 1];
|
||||
|
||||
vec3 next = getPoint(getPointsIndex(nextIdx));
|
||||
vec3 prev = getPoint(getPointsIndex(prevIdx));
|
||||
normal += cross(next - current, prev - current);
|
||||
|
||||
}
|
||||
float n = 1.0/max(length(normal), 0.000001);
|
||||
normal *= n;
|
||||
writeNormal(getNormalsIndex(index), normal);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.FlatNormals
|
||||
|
||||
int getPointsIndex(int idx)
|
||||
{
|
||||
return (idx+vertexOffset)*pointsStride + pointsOffset;
|
||||
}
|
||||
|
||||
int getNormalsIndex(int idx)
|
||||
{
|
||||
return (idx+elementOffset)*normalsStride + normalsOffset;
|
||||
}
|
||||
|
||||
int getIndicesIndex(int idx)
|
||||
{
|
||||
return (idx+topologyOffset)*indexStride + indexOffset;
|
||||
}
|
||||
|
||||
int getPrimitiveParamIndex(int idx)
|
||||
{
|
||||
return (idx+topologyOffset)*pParamStride + pParamOffset;
|
||||
}
|
||||
|
||||
int getEdgeFlag(int pParam)
|
||||
{
|
||||
return pParam & 3;
|
||||
}
|
||||
|
||||
int getFaceIndex(int pParam)
|
||||
{
|
||||
return pParam >> 2;
|
||||
}
|
||||
|
||||
vec3 computeNormalForPrimIndex(int primIndex);
|
||||
|
||||
void main()
|
||||
{
|
||||
int primIndex = int(hd_GlobalInvocationID.x);
|
||||
int pParam = primitiveParam[getPrimitiveParamIndex(primIndex)];
|
||||
int edgeFlag = getEdgeFlag(pParam);
|
||||
int faceIndex = getFaceIndex(pParam);
|
||||
vec3 normal = vec3(0);
|
||||
|
||||
if (getEdgeFlag(pParam) == 0) {
|
||||
// 0 indicates an unsplit face (as authored)
|
||||
normal += computeNormalForPrimIndex(primIndex);
|
||||
|
||||
} else if (getEdgeFlag(pParam) == 1) {
|
||||
// A subdivided face will have a run of prims with
|
||||
// edge flags like: 1, 3, 3, 3, 2; where "3" denotes an interior
|
||||
// prim. Only compute normals for the first prim in a face.
|
||||
|
||||
int primCounter = 0;
|
||||
do {
|
||||
pParam = primitiveParam[getPrimitiveParamIndex(
|
||||
primIndex+primCounter)];
|
||||
normal += computeNormalForPrimIndex(primIndex+primCounter);
|
||||
primCounter++;
|
||||
} while(getEdgeFlag(pParam) != 2);
|
||||
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
float n = 1.0/max(length(normal), 0.000001);
|
||||
normal *= n;
|
||||
writeNormal(getNormalsIndex(faceIndex), normal);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.FlatNormalsTri
|
||||
|
||||
ivec3 getIndices(int idx)
|
||||
{
|
||||
return ivec3(indices[idx],
|
||||
indices[idx+1],
|
||||
indices[idx+2]);
|
||||
}
|
||||
|
||||
vec3 computeNormalForPrimIndex(int primIndex)
|
||||
{
|
||||
ivec3 indices = getIndices(getIndicesIndex(primIndex));
|
||||
|
||||
vec3 p0 = getPoint(getPointsIndex(indices.x));
|
||||
vec3 p1 = getPoint(getPointsIndex(indices.y));
|
||||
vec3 p2 = getPoint(getPointsIndex(indices.z));
|
||||
|
||||
return cross(p1-p0, p2-p0);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.FlatNormalsQuad
|
||||
|
||||
ivec4 getIndices(int idx)
|
||||
{
|
||||
return ivec4(indices[idx],
|
||||
indices[idx+1],
|
||||
indices[idx+2],
|
||||
indices[idx+3]);
|
||||
}
|
||||
|
||||
vec3 computeNormalForPrimIndex(int primIndex)
|
||||
{
|
||||
ivec4 indices = getIndices(getIndicesIndex(primIndex));
|
||||
|
||||
vec3 p0 = getPoint(getPointsIndex(indices.x));
|
||||
vec3 p1 = getPoint(getPointsIndex(indices.y));
|
||||
vec3 p2 = getPoint(getPointsIndex(indices.z));
|
||||
vec3 p3 = getPoint(getPointsIndex(indices.w));
|
||||
|
||||
return cross(p0-p3, p2-p3) + cross(p2-p1, p0-p1);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.QuadrangulateFloat
|
||||
|
||||
#define DATATYPE float
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.QuadrangulateDouble
|
||||
|
||||
#define DATATYPE double
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.Quadrangulate
|
||||
|
||||
void main()
|
||||
{
|
||||
int index = int(hd_GlobalInvocationID.x);
|
||||
|
||||
int quadInfoIndex = index * quadInfoStride + quadInfoOffset;
|
||||
int numVert = quadInfo[quadInfoIndex];
|
||||
int dstOffset = quadInfo[quadInfoIndex+1];
|
||||
|
||||
// GPU quadinfo table layout
|
||||
//
|
||||
// struct NonQuad {
|
||||
// int numVert;
|
||||
// int dstOffset;
|
||||
// int index[maxNumVert];
|
||||
// } quadInfo[]
|
||||
//
|
||||
|
||||
for (int j = 0; j < numComponents; ++j) {
|
||||
DATATYPE center = 0;
|
||||
for (int i = 0; i < numVert; ++i) {
|
||||
int i0 = quadInfo[quadInfoIndex + 2 + i];
|
||||
int i1 = quadInfo[quadInfoIndex + 2 + (i+1)%numVert];
|
||||
|
||||
DATATYPE v0 = primvar[(i0 + vertexOffset)*primvarStride + primvarOffset + j];
|
||||
DATATYPE v1 = primvar[(i1 + vertexOffset)*primvarStride + primvarOffset + j];
|
||||
DATATYPE edge = (v0 + v1) * 0.5;
|
||||
center += v0;
|
||||
|
||||
// edge
|
||||
primvar[(dstOffset + i + vertexOffset)*primvarStride + primvarOffset + j] = edge;
|
||||
}
|
||||
// center
|
||||
center /= numVert;
|
||||
primvar[(dstOffset + numVert + vertexOffset)*primvarStride + primvarOffset + j] = center;
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Compute.EvalStencils
|
||||
|
||||
void main()
|
||||
{
|
||||
const int pointIndex = pointIndexStart + int(hd_GlobalInvocationID.x);
|
||||
if (pointIndex >= pointIndexEnd) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int numElements = EVAL_STENCILS_NUM_ELEMENTS;
|
||||
float result[numElements];
|
||||
for (int element = 0; element < numElements; ++element) {
|
||||
result[element] = 0;
|
||||
}
|
||||
|
||||
const int stencilSize = sizes[pointIndex + sizesBase];
|
||||
const int stencilOffset = offsets[pointIndex + offsetsBase];
|
||||
|
||||
for (int stencil = 0; stencil < stencilSize; ++stencil) {
|
||||
const int index = indices[stencil + stencilOffset + indicesBase];
|
||||
const float weight = weights[stencil + stencilOffset + weightsBase];
|
||||
const int srcIndex = (index + srcBase) * srcStride;
|
||||
for (int element = 0; element < numElements; ++element) {
|
||||
result[element] += weight * primvar[srcIndex + element];
|
||||
}
|
||||
}
|
||||
|
||||
const int dstIndex = (pointIndex + dstBase) * dstStride;
|
||||
for (int element = 0; element < numElements; ++element) {
|
||||
primvar[dstIndex + element] = result[element];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"domeLightIrradiance": {
|
||||
"source": [ "DomeLight.Common",
|
||||
"DomeLight.Irradiance" ]
|
||||
},
|
||||
"domeLightPrefilter": {
|
||||
"source": [ "DomeLight.Common",
|
||||
"DomeLight.CommonSampling",
|
||||
"DomeLight.Prefilter" ]
|
||||
},
|
||||
"domeLightBRDF": {
|
||||
"source": [ "DomeLight.Common",
|
||||
"DomeLight.CommonSampling",
|
||||
"DomeLight.BRDF" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl DomeLight.Common
|
||||
|
||||
const float PI = 3.1415926536;
|
||||
|
||||
layout(binding = 0) uniform sampler2D inTexture;
|
||||
layout(rgba16f, binding = 1) uniform image2D outTexture;
|
||||
|
||||
// compute texture coords based on the size of the output image/texture
|
||||
vec2 GetTexCoords(ivec2 outCoords)
|
||||
{
|
||||
vec2 outDims = imageSize(outTexture);
|
||||
// apply a (0.5, 0.5) offset to use pixel centers and not pixel corners
|
||||
vec2 texCoords = (outCoords + vec2(0.5, 0.5)) / outDims;
|
||||
return texCoords;
|
||||
}
|
||||
|
||||
// sample lat/long env map input texture
|
||||
vec3 SampleEnvMapLod(vec3 sampleVec, float sampleLod) {
|
||||
vec2 coord = vec2((atan(sampleVec.z, sampleVec.x) + PI) / (2.0 * PI),
|
||||
acos(sampleVec.y) / PI);
|
||||
return textureLod(inTexture, coord, sampleLod).rgb;
|
||||
}
|
||||
|
||||
// compute world position from texture coords
|
||||
vec3 GetWorldPos(vec2 textureCoord)
|
||||
{
|
||||
// have theta range from [-PI, PI] so the origin is in the center
|
||||
// of the image
|
||||
float theta = (textureCoord.x * 2.0 * PI) - PI;
|
||||
float phi = (textureCoord.y * PI);
|
||||
float x = cos(theta) * sin(phi);
|
||||
float y = cos(phi);
|
||||
float z = sin(theta) * sin(phi);
|
||||
return vec3(x, y, z);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl DomeLight.CommonSampling
|
||||
|
||||
float RadicalInverse(uint a)
|
||||
{
|
||||
return float(bitfieldReverse(a)) * 2.3283064365386963e-10; // 0x1p-32
|
||||
}
|
||||
|
||||
vec2 Hammersley2d(uint a, uint N)
|
||||
{
|
||||
return vec2(float(a) / float(N), RadicalInverse(a));
|
||||
}
|
||||
|
||||
vec3 ImportanceSample_GGX(vec2 Xi, float roughness, vec3 normal)
|
||||
{
|
||||
// Maps a 2D point to a hemisphere with spread based on roughness
|
||||
float alpha = roughness * roughness;
|
||||
float phi = 2.0 * PI * Xi.x;
|
||||
float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (alpha*alpha - 1.0) * Xi.y));
|
||||
float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
|
||||
vec3 H = vec3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);
|
||||
|
||||
// Tangent space
|
||||
vec3 up = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
||||
vec3 tangentX = normalize(cross(up, normal));
|
||||
vec3 tangentY = normalize(cross(normal, tangentX));
|
||||
|
||||
// Convert to world Space
|
||||
return normalize(tangentX * H.x + tangentY * H.y + normal * H.z);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl DomeLight.Irradiance
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8) in;
|
||||
|
||||
const float deltaPhi = (2.0f * float(PI)) / 180.0f;
|
||||
const float deltaTheta = (0.5f * float(PI)) / 64.0f;
|
||||
|
||||
vec3 SampleEnvMap(vec3 sampleVec)
|
||||
{
|
||||
// sample from a mipmap level of the environment map determined by the
|
||||
// size of the environment map and the number of samples we are taking
|
||||
ivec2 inDims = textureSize(inTexture, 0);
|
||||
float mipLevel = ceil(log2(inDims.x * deltaPhi/(2.0 * PI)) * 2.0f);
|
||||
|
||||
return SampleEnvMapLod(sampleVec, mipLevel);
|
||||
}
|
||||
|
||||
vec3 ComputeIrradiance(vec3 inPos)
|
||||
{
|
||||
vec3 N = normalize(inPos);
|
||||
vec3 up = vec3(0.0, 1.0, 0.0);
|
||||
vec3 right = normalize(cross(up, N));
|
||||
up = cross(N, right);
|
||||
|
||||
const float TWO_PI = PI * 2.0;
|
||||
const float HALF_PI = PI * 0.5;
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
uint sampleCount = 0u;
|
||||
for (float phi = 0.0; phi < TWO_PI; phi += deltaPhi) {
|
||||
for (float theta = 0.0; theta < HALF_PI; theta += deltaTheta) {
|
||||
vec3 tempVec = cos(phi) * right + sin(phi) * up;
|
||||
vec3 sampleVector = cos(theta) * N + sin(theta) * tempVec;
|
||||
color += SampleEnvMap(sampleVector).rgb * cos(theta) * sin(theta);
|
||||
sampleCount++;
|
||||
}
|
||||
}
|
||||
return PI * color / float(sampleCount);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
ivec2 outCoords = ivec2(gl_GlobalInvocationID.xy);
|
||||
|
||||
vec2 texCoords = GetTexCoords(outCoords);
|
||||
vec3 pos3D = GetWorldPos(texCoords);
|
||||
vec4 outColor = vec4(ComputeIrradiance(pos3D), 1.0);
|
||||
|
||||
imageStore(outTexture, outCoords, outColor);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl DomeLight.Prefilter
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8) in;
|
||||
layout(std140, binding=0) uniform Uniforms {
|
||||
float roughness;
|
||||
} uniforms;
|
||||
|
||||
// Normal Distribution function
|
||||
float Distribution_GGX(float dotNH, float roughness)
|
||||
{
|
||||
float alpha = roughness * roughness;
|
||||
float alpha2 = alpha * alpha;
|
||||
float denom = dotNH * dotNH * (alpha2 - 1.0) + 1.0;
|
||||
return (alpha2)/(PI * denom*denom);
|
||||
}
|
||||
|
||||
vec3 PrefilterEnvMap(vec3 R, float roughness)
|
||||
{
|
||||
vec3 N = R;
|
||||
vec3 V = R;
|
||||
vec3 color = vec3(0.0);
|
||||
float totalWeight = 0.0;
|
||||
float envMapDim = float(textureSize(inTexture, 0).s);
|
||||
const uint numSamples = 1024u;
|
||||
for (uint i = 0u; i < numSamples; i++) {
|
||||
vec2 Xi = Hammersley2d(i, numSamples);
|
||||
vec3 H = ImportanceSample_GGX(Xi, roughness, N);
|
||||
vec3 L = 2.0 * dot(V, H) * H - V;
|
||||
float dotNL = clamp(dot(N, L), 0.0, 1.0);
|
||||
if (dotNL > 0.0) {
|
||||
|
||||
float dotNH = clamp(dot(N, H), 0.0, 1.0);
|
||||
float dotVH = clamp(dot(V, H), 0.0, 1.0);
|
||||
|
||||
// Probability Distribution Function
|
||||
float pdf = Distribution_GGX(dotNH, roughness) * dotNH
|
||||
/ (4.0 * dotVH) + 0.0001;
|
||||
// Solid angle of current sample
|
||||
float omegaS = 1.0 / (float(numSamples) * pdf);
|
||||
// Solid angle of 1 pixel across all cube faces
|
||||
float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim);
|
||||
// Biased (+1.0) mip level for better result
|
||||
float mipLevel = roughness == 0.0
|
||||
? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f);
|
||||
color += SampleEnvMapLod(L, mipLevel).rgb * dotNL;
|
||||
totalWeight += dotNL;
|
||||
|
||||
}
|
||||
}
|
||||
return (color / totalWeight);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
ivec2 outCoords = ivec2(gl_GlobalInvocationID.xy);
|
||||
|
||||
vec2 texCoords = GetTexCoords(outCoords);
|
||||
vec3 pos3D = GetWorldPos(texCoords);
|
||||
vec3 R = normalize(pos3D);
|
||||
vec4 outColor = vec4(PrefilterEnvMap(R, uniforms.roughness), 1.0);
|
||||
|
||||
imageStore(outTexture, outCoords, outColor);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl DomeLight.BRDF
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8) in;
|
||||
uniform int sampleLevel = 0;
|
||||
|
||||
float Geometry_SchlicksmithGGX(float dotNL, float dotNV, float roughness)
|
||||
{
|
||||
float k = (roughness * roughness) / 2.0;
|
||||
float GL = dotNL / (dotNL * (1.0 - k) + k);
|
||||
float GV = dotNV / (dotNV * (1.0 - k) + k);
|
||||
return GL * GV;
|
||||
}
|
||||
|
||||
vec2 ComputeBRDF(float NoV, float roughness)
|
||||
{
|
||||
// make sure NoV doesn't go exactly to 0 to avoid NaN
|
||||
NoV = max(NoV, 0.001);
|
||||
|
||||
// Normal always points along z-axis for the 2D lookup
|
||||
const vec3 N = vec3(0.0, 0.0, 1.0);
|
||||
vec3 V = vec3(sqrt(1.0 - NoV*NoV), 0.0, NoV);
|
||||
|
||||
vec2 LUT = vec2(0.0);
|
||||
const uint NUM_SAMPLES = 1024u;
|
||||
for (uint i = 0u; i < NUM_SAMPLES; i++) {
|
||||
vec2 Xi = Hammersley2d(i, NUM_SAMPLES);
|
||||
vec3 H = ImportanceSample_GGX(Xi, roughness, N);
|
||||
vec3 L = 2.0 * dot(V, H) * H - V;
|
||||
|
||||
float dotNL = max(dot(N, L), 0.0);
|
||||
float dotNV = max(dot(N, V), 0.0);
|
||||
float dotVH = max(dot(V, H), 0.0);
|
||||
float dotNH = max(dot(H, N), 0.0);
|
||||
|
||||
if (dotNL > 0.0) {
|
||||
float G = Geometry_SchlicksmithGGX(dotNL, dotNV, roughness);
|
||||
float G_Vis = (G * dotVH) / (dotNH * dotNV);
|
||||
float Fc = pow(1.0 - dotVH, 5.0);
|
||||
LUT += vec2((1.0 - Fc) * G_Vis, Fc * G_Vis);
|
||||
}
|
||||
}
|
||||
return LUT / float(NUM_SAMPLES);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
ivec2 outCoords = ivec2(gl_GlobalInvocationID.xy);
|
||||
|
||||
vec2 texCoords = GetTexCoords(outCoords);
|
||||
// texCoords.x represents N dot E and texCoords.y represents roughness
|
||||
vec4 outColor = vec4(ComputeBRDF(texCoords.x, texCoords.y), 0.0, 1.0);
|
||||
|
||||
imageStore(outTexture, outCoords, outColor);
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/edgeId.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl EdgeId.Fragment.Fallback
|
||||
// Mixin version to use when mesh edge selection and highlighting is inactive.
|
||||
// Note: When rendering a mesh as points, this mixin isn't used. We handle it
|
||||
// in code gen.
|
||||
|
||||
int GetPrimitiveEdgeId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
float GetSelectedEdgeOpacity() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl EdgeId.Fragment.Common
|
||||
|
||||
// Determines whether a fragment is on or close to an unhidden triangle edge.
|
||||
const float edgePickRadius = 2; // in viewport pixels
|
||||
const float edgePickParametricRadius = 0.02; // in parametric space
|
||||
|
||||
// For smooth looking edges, use an exponential falloff for the opacity.
|
||||
// Note: We use a slower falloff fn than in meshWire.glslfx to make the
|
||||
// selected edges stand out.
|
||||
float SelectedEdgeFalloff(float d) {
|
||||
return exp2(-1 * d * d);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl EdgeId.Fragment.TriangleSurface
|
||||
|
||||
vec3 ComputeBaseFaceEdgeDistanceTriangle()
|
||||
{
|
||||
return GetEdgeDistanceTriangle();
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl EdgeId.Fragment.TriangleLines
|
||||
|
||||
vec3 ComputeBaseFaceEdgeDistanceTriangle()
|
||||
{
|
||||
// Use parametric distance since we can't use surface derivatives for lines
|
||||
vec3 param = GetEdgeParamTriangle();
|
||||
bvec3 nearEdge = lessThan(param, vec3(edgePickParametricRadius));
|
||||
return vec3(edgePickRadius) * vec3(not(nearEdge));
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl EdgeId.Fragment.TriangleParam
|
||||
|
||||
float GetSelectedEdgeOpacity()
|
||||
{
|
||||
float closestEdgeDistance = 0.0;
|
||||
|
||||
// The sequence of comparisons should match GetPrimitiveEdgeId()
|
||||
vec3 dist = ComputeBaseFaceEdgeDistanceTriangle();
|
||||
if (dist.x < edgePickRadius) {
|
||||
closestEdgeDistance = dist.x;
|
||||
} else if (dist.y < edgePickRadius) {
|
||||
closestEdgeDistance = dist.y;
|
||||
} else if (dist.z < edgePickRadius) {
|
||||
closestEdgeDistance = dist.z;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SelectedEdgeFalloff(closestEdgeDistance);
|
||||
}
|
||||
|
||||
// called from hdx/renderPass.glslfx and selection.glslfx
|
||||
int GetPrimitiveEdgeId()
|
||||
{
|
||||
// 2 (0,1,0)
|
||||
// ^
|
||||
// e2 / \ e1
|
||||
// / \'
|
||||
// (0,0,1) 0 ----- 1 (1,0,0)
|
||||
// e0
|
||||
|
||||
int edgeId = -1;
|
||||
|
||||
vec3 dist = ComputeBaseFaceEdgeDistanceTriangle();
|
||||
if (dist.x < edgePickRadius) {
|
||||
edgeId = 0;
|
||||
} else if (dist.y < edgePickRadius) {
|
||||
edgeId = 1;
|
||||
} else if (dist.z < edgePickRadius) {
|
||||
edgeId = 2;
|
||||
} else {
|
||||
return -1; // Not on a mesh edge
|
||||
}
|
||||
|
||||
const int edgeFlag = GetEdgeFlag();
|
||||
const int meshEdgeIndex = HdGet_edgeIndices().x;
|
||||
|
||||
// Translate face-edge to authored mesh-edge
|
||||
if (edgeFlag == 0) {
|
||||
edgeId = meshEdgeIndex + edgeId; // regular triangle face.
|
||||
} else if ((bool(edgeFlag & 1) && edgeId == 2) ||
|
||||
(bool(edgeFlag & 2) && edgeId == 0)) {
|
||||
edgeId = -1; // Not an authored mesh edge
|
||||
} else {
|
||||
edgeId = meshEdgeIndex + edgeId - 1;
|
||||
}
|
||||
return edgeId;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl EdgeId.Fragment.QuadSurface
|
||||
|
||||
vec4 ComputeBaseFaceEdgeDistanceQuad()
|
||||
{
|
||||
return GetEdgeDistanceQuad();
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl EdgeId.Fragment.QuadLines
|
||||
|
||||
vec4 ComputeBaseFaceEdgeDistanceQuad()
|
||||
{
|
||||
// Use parametric distance since we can't use surface derivatives for lines
|
||||
vec4 param = GetEdgeParamQuad();
|
||||
bvec4 nearEdge = lessThan(param, vec4(edgePickParametricRadius));
|
||||
return vec4(edgePickRadius) * vec4(not(nearEdge));
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl EdgeId.Fragment.QuadParam
|
||||
|
||||
float GetSelectedEdgeOpacity()
|
||||
{
|
||||
float closestEdgeDistance = 0.0;
|
||||
|
||||
// The sequence of comparisons should match GetPrimitiveEdgeId()
|
||||
vec4 dist = ComputeBaseFaceEdgeDistanceQuad();
|
||||
if (dist.x < edgePickRadius) {
|
||||
closestEdgeDistance = dist.x;
|
||||
} else if (dist.y < edgePickRadius) {
|
||||
closestEdgeDistance = dist.y;
|
||||
} else if (dist.z < edgePickRadius) {
|
||||
closestEdgeDistance = dist.z;
|
||||
} else if (dist.w < edgePickRadius) {
|
||||
closestEdgeDistance = dist.w;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SelectedEdgeFalloff(closestEdgeDistance);
|
||||
}
|
||||
|
||||
// called from hdx/renderPass.glslfx and selection.glslfx
|
||||
int GetPrimitiveEdgeId()
|
||||
{
|
||||
// e2
|
||||
// (0,1) 3 ------ 2 (1,1)
|
||||
// | |
|
||||
// e3 | | e1
|
||||
// | |
|
||||
// (0,0) 0 ------ 1 (1,0)
|
||||
// e0
|
||||
|
||||
int edgeId = -1;
|
||||
|
||||
vec4 dist = ComputeBaseFaceEdgeDistanceQuad();
|
||||
if (dist.x < edgePickRadius) {
|
||||
edgeId = 0;
|
||||
} else if (dist.y < edgePickRadius) {
|
||||
edgeId = 1;
|
||||
} else if (dist.z < edgePickRadius) {
|
||||
edgeId = 2;
|
||||
} else if (dist.w < edgePickRadius) {
|
||||
edgeId = 3;
|
||||
} else {
|
||||
return -1; // Not on a mesh edge
|
||||
}
|
||||
|
||||
const int edgeFlag = GetEdgeFlag();
|
||||
const ivec2 meshEdgeIndices = HdGet_edgeIndices();
|
||||
|
||||
// Translate face-edge to authored mesh-edge
|
||||
if (edgeFlag == 0) {
|
||||
edgeId = meshEdgeIndices[0] + edgeId; // regular quad face
|
||||
} else if (edgeId == 0) {
|
||||
edgeId = meshEdgeIndices[0];
|
||||
} else if (edgeId == 3) {
|
||||
edgeId = meshEdgeIndices[1];
|
||||
} else {
|
||||
edgeId = -1; // Not an authored mesh edge
|
||||
}
|
||||
return edgeId;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/fallbackLighting.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fallback.LightIntegrator
|
||||
#ifndef HD_HAS_integrateLights
|
||||
#define HD_HAS_integrateLights
|
||||
#endif
|
||||
|
||||
struct LightingContribution {
|
||||
vec3 diffuse;
|
||||
};
|
||||
|
||||
struct LightingInterfaceProperties {
|
||||
float unused;
|
||||
};
|
||||
|
||||
LightingContribution
|
||||
integrateLightsDefault(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
vec3 n = normalize(Neye);
|
||||
|
||||
LightingContribution result;
|
||||
result.diffuse = vec3(dot(n, vec3(0,0,1)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LightingContribution
|
||||
integrateLightsConstant(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
LightingContribution result;
|
||||
//pefectly diffuse white hemisphere contribution
|
||||
result.diffuse = vec3(1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
-- glsl Fallback.Lighting
|
||||
|
||||
LightingContribution
|
||||
integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props);
|
||||
|
||||
vec3 FallbackLighting(in vec3 Peye, in vec3 Neye, in vec3 color)
|
||||
{
|
||||
LightingInterfaceProperties props;
|
||||
LightingContribution light = integrateLights(vec4(Peye, 1), Neye, props);
|
||||
return color * light.diffuse;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/fallbackLightingShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/fallbackLighting.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"fragmentShader" : {
|
||||
"source": [
|
||||
"Fallback.LightIntegrator",
|
||||
"Fallback.Lighting"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/fallbackSurface.glslfx
|
||||
|
||||
---
|
||||
--- The fallback shader is used as a replacement shader if the
|
||||
--- original material shader failed to compile. It needs to
|
||||
--- define both the surfaceShader() and displacementShader() terminals.
|
||||
---
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"displacementShader": {
|
||||
"source": [ "Fallback.Displacement" ]
|
||||
},
|
||||
"surfaceShader": {
|
||||
"source": [ "Fallback.Surface" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fallback.Surface
|
||||
|
||||
vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
// lighting
|
||||
color.rgb = FallbackLighting(Peye.xyz, Neye, color.rgb);
|
||||
return color;
|
||||
}
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fallback.Displacement
|
||||
|
||||
vec4 displacementShader(int index, vec4 Peye, vec3 Neye, vec4 patchCoord)
|
||||
{
|
||||
return Peye;
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/fallbackVolume.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"volumeShader": {
|
||||
"source": [ "FallbackVolume.VolumeShader" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl FallbackVolume.VolumeShader
|
||||
|
||||
// Functions that the volume shader of a volume material would provide.
|
||||
//
|
||||
// The functions give extinction, scattering, emission at a point as well as
|
||||
// a phase function such as Henyey-Greenstein (see, e.g., [1]).
|
||||
//
|
||||
// Only single scattering is taken into account and the result of the
|
||||
// scattering function (together with the phase function) is used to compute
|
||||
// the in-scattering component of the volume rendering equation for a light
|
||||
// source (point lights only).
|
||||
// The extinction function is supposed to return the sum of the
|
||||
// absorption and out-scattering cross section.
|
||||
// Note that the interpretation of emission here follows [1] (rather than [2]),
|
||||
// so the emission is added by the ray-marcher without being multiplied by
|
||||
// extinction.
|
||||
// Note that one cannot use the fallback volume shader for assets containing
|
||||
// "glow" rather "emission" where the convention is
|
||||
// emission = glow * extinction.
|
||||
//
|
||||
// [1] Matt Pharr, Wenzel Jakob, Greg Humphreys, "Physically Based Rendering",
|
||||
// Third Edition).
|
||||
// [2] Julian Fong, Magnus Wrenninge, Christopher Kulla, Ralf Habel,
|
||||
// "Production Volume Rendering", SIGGRAPH 2017 Course.
|
||||
|
||||
// The functions given here use a density and emission field with a fixed
|
||||
// albedo.
|
||||
//
|
||||
//
|
||||
|
||||
// Extinction function, returns sum of absorption and out-scattering cross
|
||||
// ratio.
|
||||
//
|
||||
float
|
||||
extinctionFunction(vec3 p)
|
||||
{
|
||||
return HdGet_density(p);
|
||||
}
|
||||
|
||||
// Scattering function, returns in-scattering cross-section (will be combined
|
||||
// with phase function).
|
||||
//
|
||||
// Here: constant on ellipsoid and zero outside.
|
||||
float
|
||||
scatteringFunction(vec3 p)
|
||||
{
|
||||
const float albedo = 0.18;
|
||||
|
||||
return extinctionFunction(p) * albedo;
|
||||
}
|
||||
|
||||
// Emission function, returns emission cross-section.
|
||||
//
|
||||
// Here: zero since volume is not emitting light.
|
||||
vec3
|
||||
emissionFunction(vec3 p)
|
||||
{
|
||||
return HdGet_emission(p);
|
||||
}
|
||||
|
||||
// Phase function in volume rendering equation.
|
||||
//
|
||||
// Here: isotropic.
|
||||
float
|
||||
phaseFunction(vec3 direction1, vec3 direction2)
|
||||
{
|
||||
const float pi = 3.14159265358979;
|
||||
const float sphereArea = 4.0 * pi;
|
||||
const float inverseSphereArea = 1.0 / sphereArea;
|
||||
|
||||
return inverseSphereArea;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/compute.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/instancing.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl ViewFrustumCull.Counting
|
||||
|
||||
layout (std430, binding = drawIndirectResult_Binding) buffer ResultData {
|
||||
int numVisibleInstances;
|
||||
};
|
||||
|
||||
void
|
||||
FrustumCullCountVisibleInstances(int resultInstanceCount)
|
||||
{
|
||||
atomicAdd(numVisibleInstances, resultInstanceCount);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl ViewFrustumCull.NoCounting
|
||||
|
||||
void
|
||||
FrustumCullCountVisibleInstances(int resultInstanceCount)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl ViewFrustumCull.NoTinyCull
|
||||
|
||||
bool
|
||||
FrustumCullIsTinyPrim(vec4 bboxMin, vec4 bboxMax, vec2 drawRangeNDC)
|
||||
{
|
||||
// do nothing
|
||||
return false;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl ViewFrustumCull.TinyCull
|
||||
|
||||
bool
|
||||
FrustumCullIsTinyPrim(vec4 bboxMin, vec4 bboxMax, vec2 drawRangeNDC)
|
||||
{
|
||||
// Check the length of the min/max diagonal, could do something better here.
|
||||
vec2 ndcMin = (bboxMin.xy/max(.000001,bboxMin.w));
|
||||
vec2 ndcMax = (bboxMax.xy/max(.000001,bboxMax.w));
|
||||
float diag = distance(ndcMin, ndcMax);
|
||||
|
||||
// Cull prims outside the min(x)/max(y) range.
|
||||
// When max is negative, do not cull based on max size
|
||||
|
||||
#define isLargeEnough (diag > drawRangeNDC.x)
|
||||
#define isSmallEnough (drawRangeNDC.y < 0 || diag < drawRangeNDC.y)
|
||||
|
||||
return !isLargeEnough || !isSmallEnough;
|
||||
|
||||
#undef isLargeEnough
|
||||
#undef isSmallEnough
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl ViewFrustumCull.IsVisible
|
||||
|
||||
bool
|
||||
FrustumCullIsVisible(MAT4 toClip, vec4 localMin, vec4 localMax, vec2 drawRangeNDC)
|
||||
{
|
||||
// Disable culling when:
|
||||
// (a) BBox is empty. An empty bbox defaults to [FLT_MAX, -FLT_MAX]), so
|
||||
// min > max.
|
||||
// (b) Bounds are infinite.
|
||||
if (any(greaterThan(localMin, localMax)) ||
|
||||
any(isinf(localMin)) || any(isinf(localMax))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Transform the corners of the bounding box to clipping space.
|
||||
vec4 p[8];
|
||||
p[0] = vec4(toClip * vec4(localMin.x, localMin.y, localMin.z, 1));
|
||||
p[2] = vec4(toClip * vec4(localMin.x, localMax.y, localMin.z, 1));
|
||||
p[5] = vec4(toClip * vec4(localMax.x, localMin.y, localMax.z, 1));
|
||||
p[7] = vec4(toClip * vec4(localMax.x, localMax.y, localMax.z, 1));
|
||||
|
||||
// This prim is visible if it wasn't culled and at least one tiny prim test
|
||||
// failed. Test two axes here because size is measured in screen space.
|
||||
// We front-load this test because it saves quite a bit of compute: in one
|
||||
// test the framerate went from 7.7 to 9.0 FPS.
|
||||
if (FrustumCullIsTinyPrim(p[0], p[7], drawRangeNDC) &&
|
||||
FrustumCullIsTinyPrim(p[2], p[5], drawRangeNDC))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Finish computing points and perform frustum culling.
|
||||
p[1] = vec4(toClip * vec4(localMin.x, localMin.y, localMax.z, 1));
|
||||
p[3] = vec4(toClip * vec4(localMin.x, localMax.y, localMax.z, 1));
|
||||
p[4] = vec4(toClip * vec4(localMax.x, localMin.y, localMin.z, 1));
|
||||
p[6] = vec4(toClip * vec4(localMax.x, localMax.y, localMin.z, 1));
|
||||
|
||||
// Test the corners of the bounding box against the clipping volume.
|
||||
// clipFlags is effectively a 6-bit field, holding one bit of information
|
||||
// per frustum plane. Each component of the vector holds 2 bits.
|
||||
// If the bounding box overlaps the clip volume, then clipFlags will be
|
||||
// (0b11, 0b11, 0b11).
|
||||
ivec3 clipFlags = ivec3(0);
|
||||
for (int i=0; i<8; ++i) {
|
||||
vec4 clipPos = p[i];
|
||||
bvec3 clip0 = lessThan(clipPos.xyz, vec3(clipPos.w));
|
||||
bvec3 clip1 = greaterThan(clipPos.xyz, -vec3(clipPos.w));
|
||||
clipFlags |= ivec3(clip0) /* bit 0 */ + 2*ivec3(clip1) /*bit 1*/;
|
||||
}
|
||||
|
||||
return clipFlags == ivec3(3);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl ViewFrustumCull.Vertex
|
||||
|
||||
layout (location = instanceCountInput_Binding) in int instanceCountInput;
|
||||
layout (location = drawCommandIndex_Binding) in int drawCommandIndex;
|
||||
|
||||
layout(std140, binding=ulocCullParams_Binding) uniform Uniforms {
|
||||
mat4 cullMatrix;
|
||||
vec2 drawRangeNDC;
|
||||
uint drawCommandNumUints;
|
||||
} cullParams;
|
||||
|
||||
layout (std430, binding = dispatchBuffer_Binding) buffer DispatchBuffer {
|
||||
uint drawCommands[];
|
||||
};
|
||||
|
||||
MAT4 GetCullMatrix()
|
||||
{
|
||||
return MAT4(cullParams.cullMatrix);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// instanceCountOffset is a relative offset in drawcommand struct.
|
||||
// it's a second entry in both DrawArraysCommand and DrawElementsCommand.
|
||||
const uint instanceCountOffset = 1;
|
||||
|
||||
MAT4 transform = HdGet_transform();
|
||||
MAT4 toClip = GetCullMatrix() * transform;
|
||||
|
||||
vec4 localMin = HdGet_bboxLocalMin();
|
||||
vec4 localMax = HdGet_bboxLocalMax();
|
||||
|
||||
bool isVisible = FrustumCullIsVisible(
|
||||
toClip, localMin, localMax, cullParams.drawRangeNDC);
|
||||
|
||||
// Compute the index to the 'instanceCount' struct member in drawCommands.
|
||||
uint index = uint(drawCommandIndex) *
|
||||
cullParams.drawCommandNumUints + instanceCountOffset;
|
||||
|
||||
// Set the resulting instance count to 0 if the primitive is culled
|
||||
// otherwise pass through the original incoming instance count.
|
||||
uint resultInstanceCount = instanceCountInput * uint(isVisible);
|
||||
drawCommands[index] = resultInstanceCount;
|
||||
|
||||
FrustumCullCountVisibleInstances(int(resultInstanceCount));
|
||||
}
|
||||
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl ViewFrustumCull.VertexInstancing
|
||||
|
||||
/*
|
||||
per-instance culling
|
||||
|
||||
We use instance index indirection buffer to switch prototypes efficiently.
|
||||
Per-instance culling exploits this indirection to trim culled instances
|
||||
from draw call.
|
||||
|
||||
Example: Prototype mesh M is instanced for 5 instances.
|
||||
|
||||
Instancer has instance primvars (translate, rotate, ...)
|
||||
and index indirection for M.
|
||||
|
||||
InstancePrimvar (T:translate)
|
||||
+-------+-----------------------------+-----------+
|
||||
: |T0 T1 T2 T3 T4 T5 T6 T7 T8 T9| :
|
||||
+-------+-----------------------------+-----------+
|
||||
^
|
||||
InstanceIndices(for M) |
|
||||
+-----------+---------------+-----------+
|
||||
: | 0 2 5 8 9 | :
|
||||
+-----------+---------------+-----------+
|
||||
^
|
||||
|
|
||||
M: gl_InstanceID (0-5)
|
||||
|
||||
We can draw all instances of M, by just drawing with numInstance = 6.
|
||||
|
||||
For per-instance culling, we test each bbox against the frustum.
|
||||
Then, we store only passed instance indices into culledInstanceIndices buffer,
|
||||
as well as counting them.
|
||||
|
||||
InstanceIndices(for M)
|
||||
+-----------+---------------+-----------+
|
||||
: | 0 2 5 8 9 | : instanceCount = 5
|
||||
+-----------+---------------+-----------+
|
||||
V
|
||||
<Frustum culling> (say only 2 and 8 are visible in frustum)
|
||||
V
|
||||
+-----------+---------------+-----------+
|
||||
: | 2 8 x x x | : instanceCount = 2
|
||||
+-----------+---------------+-----------+
|
||||
x:undefined value
|
||||
*/
|
||||
|
||||
layout (location = drawCommandIndex_Binding) in int drawCommandIndex;
|
||||
|
||||
layout(std140, binding=ulocCullParams_Binding) uniform Uniforms {
|
||||
mat4 cullMatrix;
|
||||
vec2 drawRangeNDC;
|
||||
uint drawCommandNumUints;
|
||||
int resetPass;
|
||||
} cullParams;
|
||||
|
||||
layout (std430, binding = dispatchBuffer_Binding) buffer DispatchBuffer {
|
||||
uint drawCommands[];
|
||||
};
|
||||
|
||||
MAT4 GetCullMatrix()
|
||||
{
|
||||
return MAT4(cullParams.cullMatrix);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// instanceCountOffset is a relative offset in drawcommand struct.
|
||||
// it's a second entry in both DrawArraysCommand and DrawElementsCommand.
|
||||
const uint instanceCountOffset = 1;
|
||||
|
||||
// reset pass
|
||||
if (cullParams.resetPass == 1) {
|
||||
// note: we expect all instance invocations of this draw command is clearing
|
||||
// same field to zero, and intentionally chosen to not guard this access as atomic.
|
||||
drawCommands[drawCommandIndex * cullParams.drawCommandNumUints + instanceCountOffset] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// culling pass
|
||||
// precondition: drawCommand.instanceCount has to be reset in the separate
|
||||
// invocation unit.
|
||||
|
||||
vec4 localMin = HdGet_bboxLocalMin();
|
||||
vec4 localMax = HdGet_bboxLocalMax();
|
||||
|
||||
MAT4 toClip = GetCullMatrix() * ApplyInstanceTransform(HdGet_transform());
|
||||
|
||||
bool isVisible = FrustumCullIsVisible(
|
||||
toClip, localMin, localMax, cullParams.drawRangeNDC);
|
||||
|
||||
if (isVisible) {
|
||||
// increment the instance count and store instanceIndex to culledInstanceIndices.
|
||||
|
||||
uint id = atomicAdd(drawCommands[
|
||||
drawCommandIndex * cullParams.drawCommandNumUints +
|
||||
instanceCountOffset], 1);
|
||||
|
||||
SetCulledInstanceIndex(id);
|
||||
FrustumCullCountVisibleInstances(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/imageShader.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "ImageShader.Vertex" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "ImageShader.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl ImageShader.Vertex
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec2 uv;
|
||||
} outData;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Position the vertices to create a large-than-screen triangle.
|
||||
// Adjust the UVs of the triangle to have 0-1 fit the screen exactly.
|
||||
// 'st' is the geometric UV where the [bottom,left] returns [0, 0].
|
||||
// Unlike gl_fragCoord where the [bottom,left] defaults to [0.5, 0.5].
|
||||
//
|
||||
// gl_VertexID=0 -> (-1,-1)
|
||||
// gl_VertexID=1 -> ( 3,-1)
|
||||
// gl_VertexID=2 -> (-1, 3)
|
||||
//
|
||||
// glDrawArrays( GL_TRIANGLES, 0, 3 );
|
||||
//
|
||||
// ID=2
|
||||
// x,y=-1,3
|
||||
// u,v=0,2
|
||||
// |\
|
||||
// | \
|
||||
// | \
|
||||
// | \
|
||||
// |--------\
|
||||
// | | \
|
||||
// | screen | \
|
||||
// | | \
|
||||
// ----------------
|
||||
// ID=0 ID=1
|
||||
// x,y=-1,-1 x,y=3,-1
|
||||
// u,v=0,0 u,v=2,0
|
||||
//
|
||||
//
|
||||
float x = -1.0 + float(((gl_VertexID%3) & 1) << 2);
|
||||
float y = -1.0 + float(((gl_VertexID%3) & 2) << 1);
|
||||
outData.uv.x = (x+1.0) * 0.5;
|
||||
outData.uv.y = (y+1.0) * 0.5;
|
||||
|
||||
gl_Position = vec4(x, y, 0, 1);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl ImageShader.Fragment
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec2 uv;
|
||||
} inData;
|
||||
|
||||
layout (location = 0) out vec4 colorOut;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
colorOut = imageShader(inData.uv);
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/instancing.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Instancing.Transform
|
||||
|
||||
// quaternion to matrix. xyz = imaginary, w = real
|
||||
MAT4 GetRotationMatrix(vec4 q)
|
||||
{
|
||||
MAT4 r;
|
||||
r[0].xyzw = vec4(1 - 2 * (q.y * q.y + q.z * q.z),
|
||||
2 * (q.x * q.y + q.z * q.w),
|
||||
2 * (q.x * q.z - q.y * q.w),
|
||||
0);
|
||||
r[1].xyzw = vec4( 2 * (q.x * q.y - q.z * q.w),
|
||||
1 - 2 * (q.x * q.x + q.z * q.z),
|
||||
2 * (q.y * q.z + q.x * q.w),
|
||||
0);
|
||||
r[2].xyzw = vec4( 2 * (q.x * q.z + q.y * q.w),
|
||||
2 * (q.y * q.z - q.x * q.w),
|
||||
1 - 2 * (q.x * q.x + q.y * q.y),
|
||||
0);
|
||||
r[3] = vec4(0, 0, 0, 1);
|
||||
return r;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
MAT4 GetInstanceTransform(int level)
|
||||
{
|
||||
MAT4 m = MAT4(1);
|
||||
#ifdef HD_HAS_INSTANCE_instanceTransform
|
||||
m = HdGetInstance_instanceTransform(level, MAT4(1)) * m;
|
||||
#endif
|
||||
|
||||
// instance transform elements are applied:
|
||||
// scale then rotate then translate
|
||||
// i.e. (T * R * S) * position
|
||||
|
||||
#ifdef HD_HAS_INSTANCE_scale
|
||||
vec3 s = HdGetInstance_scale(level, /*default=*/vec3(1));
|
||||
m = MAT4(s.x, 0, 0, 0,
|
||||
0, s.y, 0, 0,
|
||||
0, 0, s.z, 0,
|
||||
0, 0, 0, 1) * m;
|
||||
#endif
|
||||
|
||||
#ifdef HD_HAS_INSTANCE_rotate // GfQuat(ix, iy, iz, real)
|
||||
vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0));
|
||||
m = GetRotationMatrix(q) * m;
|
||||
#endif
|
||||
|
||||
#ifdef HD_HAS_INSTANCE_translate
|
||||
vec3 t = HdGetInstance_translate(level, /*default=*/vec3(0));
|
||||
m = MAT4( 1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
t.x, t.y, t.z, 1) * m;
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
MAT4 GetInstanceTransformInverse(int level)
|
||||
{
|
||||
MAT4 m = MAT4(1);
|
||||
|
||||
#ifdef HD_HAS_INSTANCE_instanceTransform
|
||||
m = inverse(HdGetInstance_instanceTransform(level, MAT4(1))) * m;
|
||||
#endif
|
||||
|
||||
#ifdef HD_HAS_INSTANCE_translate
|
||||
vec3 it = -HdGetInstance_translate(level, /*default=*/vec3(0)); // negate
|
||||
m = MAT4( 1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
it.x, it.y, it.z, 1) * m;
|
||||
#endif
|
||||
|
||||
#ifdef HD_HAS_INSTANCE_rotate
|
||||
vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0));
|
||||
q.xyz = -q.xyz; // inverse rotataion axis
|
||||
m = GetRotationMatrix(q) * m;
|
||||
#endif
|
||||
|
||||
#ifdef HD_HAS_INSTANCE_scale
|
||||
vec3 is = 1.0/HdGetInstance_scale(level, /*default=*/vec3(1)); // inverse scale
|
||||
m = MAT4(is.x, 0, 0, 0,
|
||||
0, is.y, 0, 0,
|
||||
0, 0, is.z, 0,
|
||||
0, 0, 0, 1) * m;
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
MAT4 GetInstanceTransform()
|
||||
{
|
||||
MAT4 m = MAT4(1);
|
||||
#ifdef HD_INSTANCER_NUM_LEVELS
|
||||
for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) {
|
||||
m = GetInstanceTransform(i) * m;
|
||||
#ifdef HD_HAS_instancerTransform
|
||||
m = HdGet_instancerTransform(i) * m;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
MAT4 GetInstanceTransformInverse()
|
||||
{
|
||||
MAT4 m = MAT4(1);
|
||||
#ifdef HD_INSTANCER_NUM_LEVELS
|
||||
for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) {
|
||||
m = m * GetInstanceTransformInverse(i);
|
||||
#ifdef HD_HAS_instancerTransformInverse
|
||||
m = m * HdGet_instancerTransformInverse(i);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
MAT4 ApplyInstanceTransform(MAT4 m)
|
||||
{
|
||||
return GetInstanceTransform() * m;
|
||||
}
|
||||
|
||||
MAT4 ApplyInstanceTransformInverse(MAT4 m)
|
||||
{
|
||||
return m * GetInstanceTransformInverse();
|
||||
}
|
||||
|
||||
bool IsFlipped()
|
||||
{
|
||||
#if defined(HD_HAS_isFlipped)
|
||||
bool flip = (HdGet_isFlipped() != 0);
|
||||
#elif defined(HD_HAS_transform)
|
||||
// The sign of the determinant indicates whether m flips handedness
|
||||
bool flip = (determinant(HdGet_transform()) < 0.0);
|
||||
#else
|
||||
bool flip = false;
|
||||
#endif
|
||||
|
||||
#ifdef HD_HAS_INSTANCE_scale
|
||||
for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) {
|
||||
vec3 scale = HdGetInstance_scale(i, /*default=*/vec3(1));
|
||||
flip = flip ^^ ((sign(scale.x) * sign(scale.y) * sign(scale.z)) < 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HD_HAS_INSTANCE_instanceTransform
|
||||
for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) {
|
||||
MAT4 m = HdGetInstance_instanceTransform(i, MAT4(1));
|
||||
flip = flip ^^ (determinant(m) < 0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return flip;
|
||||
}
|
||||
@@ -0,0 +1,709 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/mesh.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/instancing.glslfx
|
||||
#import $TOOLS/hdSt/shaders/meshFaceCull.glslfx
|
||||
#import $TOOLS/hdSt/shaders/meshNormal.glslfx
|
||||
#import $TOOLS/hdSt/shaders/meshWire.glslfx
|
||||
#import $TOOLS/hdSt/shaders/terminals.glslfx
|
||||
#import $TOOLS/hdSt/shaders/edgeId.glslfx
|
||||
#import $TOOLS/hdSt/shaders/pointId.glslfx
|
||||
#import $TOOLS/hdSt/shaders/visibility.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.Vertex
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData;
|
||||
|
||||
out vec4 tesPatchCoord;
|
||||
out vec2 tesTessCoord;
|
||||
out vec4 gsPatchCoord;
|
||||
out vec2 gsTessCoord;
|
||||
|
||||
// Fwd declare methods defined in pointId.glslfx, that are used below.
|
||||
int GetPointId();
|
||||
float GetPointRasterSize(int);
|
||||
void ProcessPointId(int);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
ProcessPrimvars();
|
||||
|
||||
MAT4 transform = ApplyInstanceTransform(HdGet_transform());
|
||||
vec4 point = vec4(HdGet_points().xyz, 1);
|
||||
outData.Peye = vec4(GetWorldToViewMatrix() * transform * point);
|
||||
|
||||
outData.Neye = GetNormal(vec3(0), 0); // normalized
|
||||
|
||||
// Fill out redundantly, since at this point we don't know
|
||||
// the following stages include tessellation or geometry shader.
|
||||
// we rely on that compiler (linker) optimizes out these redundant
|
||||
// assignment and attribute plumbing.
|
||||
tesPatchCoord = gsPatchCoord = vec4(0);
|
||||
tesTessCoord = gsTessCoord = vec2(0);
|
||||
|
||||
int pointId = GetPointId();
|
||||
gl_PointSize = GetPointRasterSize(pointId);
|
||||
ProcessPointId(pointId);
|
||||
|
||||
gl_Position = vec4(GetProjectionMatrix() * outData.Peye);
|
||||
ApplyClipPlanes(outData.Peye);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.TessControl.BSplineQuad
|
||||
|
||||
layout(vertices = HD_NUM_PATCH_EVAL_VERTS) out;
|
||||
|
||||
patch out vec4 tessOuterLo, tessOuterHi;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inpt[gl_MaxPatchVertices];
|
||||
|
||||
out VertexDataTess
|
||||
{
|
||||
OsdPerPatchVertexBezier v;
|
||||
} outpt[HD_NUM_PATCH_EVAL_VERTS];
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 cv[HD_NUM_PATCH_VERTS];
|
||||
for (int i = 0; i < HD_NUM_PATCH_VERTS; ++i) {
|
||||
cv[i] = inpt[i].Peye.xyz;
|
||||
}
|
||||
|
||||
ivec3 patchParam = GetPatchParam();
|
||||
|
||||
OsdComputePerPatchVertexBSpline(patchParam, gl_InvocationID, cv,
|
||||
outpt[gl_InvocationID].v);
|
||||
|
||||
// Wait for all basis conversion to be finished
|
||||
barrier();
|
||||
|
||||
if (gl_InvocationID == 0) {
|
||||
vec4 tessLevelOuter = vec4(0);
|
||||
vec2 tessLevelInner = vec2(0);
|
||||
|
||||
// Gather bezier control points to compute limit surface tess levels
|
||||
OsdPerPatchVertexBezier cpBezier[HD_NUM_PATCH_EVAL_VERTS];
|
||||
for (int i = 0; i < HD_NUM_PATCH_EVAL_VERTS; ++i) {
|
||||
cpBezier[i] = outpt[i].v;
|
||||
}
|
||||
OsdEvalPatchBezierTessLevels(cpBezier, patchParam,
|
||||
tessLevelOuter, tessLevelInner,
|
||||
tessOuterLo, tessOuterHi);
|
||||
|
||||
gl_TessLevelOuter[0] = tessLevelOuter[0];
|
||||
gl_TessLevelOuter[1] = tessLevelOuter[1];
|
||||
gl_TessLevelOuter[2] = tessLevelOuter[2];
|
||||
gl_TessLevelOuter[3] = tessLevelOuter[3];
|
||||
|
||||
gl_TessLevelInner[0] = tessLevelInner[0];
|
||||
gl_TessLevelInner[1] = tessLevelInner[1];
|
||||
}
|
||||
|
||||
ProcessPrimvars();
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.TessEval.BezierQuad
|
||||
|
||||
layout(quads) in;
|
||||
|
||||
patch in vec4 tessOuterLo, tessOuterHi;
|
||||
|
||||
in VertexDataTess {
|
||||
OsdPerPatchVertexBezier v;
|
||||
} inpt[gl_MaxPatchVertices];
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData;
|
||||
|
||||
// XXX: due to NVIDIA shader compiler bug (filed as 1687344)
|
||||
// we can't put patchCoord into interface block.
|
||||
out vec4 tesPatchCoord;
|
||||
out vec2 tesTessCoord;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
OsdPerPatchVertexBezier cv[16];
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
cv[i] = inpt[i].v;
|
||||
}
|
||||
vec2 UV = OsdGetTessParameterization(gl_TessCoord.xy,
|
||||
tessOuterLo,
|
||||
tessOuterHi);
|
||||
|
||||
vec3 P = vec3(0), dPu = vec3(0), dPv = vec3(0);
|
||||
vec3 N = vec3(0), dNu = vec3(0), dNv = vec3(0);
|
||||
|
||||
ivec3 patchParam = inpt[0].v.patchParam;
|
||||
OsdEvalPatchBezier(patchParam, UV, cv, P, dPu, dPv, N, dNu, dNv);
|
||||
|
||||
outData.Peye = vec4(P, 1);
|
||||
outData.Neye = N; // normalized
|
||||
|
||||
tesPatchCoord = OsdInterpolatePatchCoord(UV, patchParam);
|
||||
tesTessCoord = UV;
|
||||
|
||||
// Bilinear basis
|
||||
vec4 basis = vec4(
|
||||
(1.0-UV.x) * (1.0-UV.y), UV.x * (1.0-UV.y),
|
||||
(1.0-UV.x) * UV.y, UV.x * UV.y );
|
||||
|
||||
ProcessPrimvars(basis, 5, 6, 9, 10, UV);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.TessControl.BoxSplineTriangle
|
||||
|
||||
layout(vertices = HD_NUM_PATCH_EVAL_VERTS) out;
|
||||
|
||||
patch out vec4 tessOuterLo, tessOuterHi;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inpt[gl_MaxPatchVertices];
|
||||
|
||||
out VertexDataTess
|
||||
{
|
||||
OsdPerPatchVertexBezier v;
|
||||
} outpt[HD_NUM_PATCH_EVAL_VERTS];
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 cv[HD_NUM_PATCH_VERTS];
|
||||
for (int i = 0; i < HD_NUM_PATCH_VERTS; ++i) {
|
||||
cv[i] = inpt[i].Peye.xyz;
|
||||
}
|
||||
|
||||
ivec3 patchParam = GetPatchParam();
|
||||
|
||||
OsdComputePerPatchVertexBoxSplineTriangle(patchParam, gl_InvocationID, cv,
|
||||
outpt[gl_InvocationID].v);
|
||||
|
||||
// Wait for all basis conversion to be finished
|
||||
barrier();
|
||||
|
||||
if (gl_InvocationID == 0) {
|
||||
vec4 tessLevelOuter = vec4(0);
|
||||
vec2 tessLevelInner = vec2(0);
|
||||
|
||||
// Gather bezier control points to compute limit surface tess levels
|
||||
vec3 cpBezier[HD_NUM_PATCH_EVAL_VERTS];
|
||||
for (int i = 0; i < HD_NUM_PATCH_EVAL_VERTS; ++i) {
|
||||
cpBezier[i] = outpt[i].v.P;
|
||||
}
|
||||
OsdEvalPatchBezierTriangleTessLevels(cpBezier, patchParam,
|
||||
tessLevelOuter, tessLevelInner,
|
||||
tessOuterLo, tessOuterHi);
|
||||
|
||||
gl_TessLevelOuter[0] = tessLevelOuter[0];
|
||||
gl_TessLevelOuter[1] = tessLevelOuter[1];
|
||||
gl_TessLevelOuter[2] = tessLevelOuter[2];
|
||||
|
||||
gl_TessLevelInner[0] = tessLevelInner[0];
|
||||
}
|
||||
|
||||
ProcessPrimvars();
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.TessEval.BezierTriangle
|
||||
|
||||
layout(triangles) in;
|
||||
|
||||
patch in vec4 tessOuterLo, tessOuterHi;
|
||||
|
||||
in VertexDataTess {
|
||||
OsdPerPatchVertexBezier v;
|
||||
} inpt[gl_MaxPatchVertices];
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData;
|
||||
|
||||
// XXX: due to NVIDIA shader compiler bug (filed as 1687344)
|
||||
// we can't put patchCoord into interface block.
|
||||
out vec4 tesPatchCoord;
|
||||
out vec2 tesTessCoord;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
OsdPerPatchVertexBezier cv[15];
|
||||
for (int i = 0; i < 15; ++i) {
|
||||
cv[i] = inpt[i].v;
|
||||
}
|
||||
vec2 UV = OsdGetTessParameterizationTriangle(gl_TessCoord.xyz,
|
||||
tessOuterLo,
|
||||
tessOuterHi);
|
||||
|
||||
vec3 P = vec3(0), dPu = vec3(0), dPv = vec3(0);
|
||||
vec3 N = vec3(0), dNu = vec3(0), dNv = vec3(0);
|
||||
|
||||
ivec3 patchParam = inpt[0].v.patchParam;
|
||||
OsdEvalPatchBezierTriangle(patchParam, UV, cv, P, dPu, dPv, N, dNu, dNv);
|
||||
|
||||
outData.Peye = vec4(P, 1);
|
||||
outData.Neye = N; // normalized
|
||||
|
||||
tesPatchCoord = OsdInterpolatePatchCoordTriangle(UV, patchParam);
|
||||
tesTessCoord = UV;
|
||||
|
||||
// Barycentric basis
|
||||
vec4 basis = vec4(
|
||||
(1.0f-UV.x-UV.y), UV.x, UV.y, 0.0f);
|
||||
|
||||
ProcessPrimvars(basis, 4, 5, 8, 0, UV);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.Geometry.TriangleTess
|
||||
|
||||
layout(triangles) in;
|
||||
layout(triangle_strip, max_vertices = 3) out;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inData[3];
|
||||
|
||||
in vec4 tesPatchCoord[3];
|
||||
in vec2 tesTessCoord[3];
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData;
|
||||
|
||||
out vec4 gsPatchCoord;
|
||||
out vec2 gsTessCoord;
|
||||
|
||||
|
||||
vec4 GetPatchCoord(int index)
|
||||
{
|
||||
return tesPatchCoord[index];
|
||||
}
|
||||
|
||||
void emit(int index, vec4 Peye, vec3 Neye)
|
||||
{
|
||||
outData.Peye = Peye;
|
||||
outData.Neye = Neye;
|
||||
gsPatchCoord = GetPatchCoord(index);
|
||||
gsTessCoord = vec2(0);
|
||||
gl_Position = vec4(GetProjectionMatrix() * outData.Peye);
|
||||
ApplyClipPlanes(outData.Peye);
|
||||
|
||||
ProcessPrimvars(index, tesTessCoord[index]);
|
||||
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
vec4 ComputeSelectionOffset(); // selection.glslfx
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_PrimitiveID = gl_PrimitiveIDIn;
|
||||
|
||||
bool isFlipped = IsFlipped(); // consider handedness AND negative-scale
|
||||
|
||||
vec3 Neye0 = isFlipped ? -inData[0].Neye : inData[0].Neye;
|
||||
Neye0 = GetNormal(Neye0, 0, tesTessCoord[0]);
|
||||
Neye0 = GetTriGeometryNormal(Neye0, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, isFlipped);
|
||||
vec3 Neye1 = isFlipped ? -inData[1].Neye : inData[1].Neye;
|
||||
Neye1 = GetNormal(Neye1, 0, tesTessCoord[1]);
|
||||
Neye1 = GetTriGeometryNormal(Neye1, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, isFlipped);
|
||||
vec3 Neye2 = isFlipped ? -inData[2].Neye : inData[2].Neye;
|
||||
Neye2 = GetNormal(Neye2, 0, tesTessCoord[2]);
|
||||
Neye2 = GetTriGeometryNormal(Neye2, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, isFlipped);
|
||||
|
||||
vec4 Peye0 = DisplacementTerminal(
|
||||
0, inData[0].Peye, Neye0, GetPatchCoord(0));
|
||||
vec4 Peye1 = DisplacementTerminal(
|
||||
1, inData[1].Peye, Neye1, GetPatchCoord(1));
|
||||
vec4 Peye2 = DisplacementTerminal(
|
||||
2, inData[2].Peye, Neye2, GetPatchCoord(2));
|
||||
|
||||
// For wireframe, add a polygon offset to selected faces to ensure they
|
||||
// rasterize over unselected faces.
|
||||
vec4 selOffset = ComputeSelectionOffset();
|
||||
Peye0 += selOffset;
|
||||
Peye1 += selOffset;
|
||||
Peye2 += selOffset;
|
||||
|
||||
// triangle 0: vertices (0,1,2)
|
||||
emit(0, Peye0, Neye0);
|
||||
emit(1, Peye1, Neye1);
|
||||
emit(2, Peye2, Neye2);
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.TessEval.VaryingInterpolation
|
||||
|
||||
float ProcessPrimvar(float inPv0, float inPv1, float inPv2, float inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return basis[0] * inPv0 +
|
||||
basis[1] * inPv1 +
|
||||
basis[2] * inPv2 +
|
||||
basis[3] * inPv3;
|
||||
}
|
||||
|
||||
vec2 ProcessPrimvar(vec2 inPv0, vec2 inPv1, vec2 inPv2, vec2 inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return basis[0] * inPv0 +
|
||||
basis[1] * inPv1 +
|
||||
basis[2] * inPv2 +
|
||||
basis[3] * inPv3;
|
||||
}
|
||||
|
||||
vec3 ProcessPrimvar(vec3 inPv0, vec3 inPv1, vec3 inPv2, vec3 inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return basis[0] * inPv0 +
|
||||
basis[1] * inPv1 +
|
||||
basis[2] * inPv2 +
|
||||
basis[3] * inPv3;
|
||||
}
|
||||
|
||||
vec4 ProcessPrimvar(vec4 inPv0, vec4 inPv1, vec4 inPv2, vec4 inPv3,
|
||||
vec4 basis, vec2 uv)
|
||||
{
|
||||
return basis[0] * inPv0 +
|
||||
basis[1] * inPv1 +
|
||||
basis[2] * inPv2 +
|
||||
basis[3] * inPv3;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.Geometry.Triangle
|
||||
|
||||
layout(triangles) in;
|
||||
layout(triangle_strip, max_vertices = 3) out;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inData[3];
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData;
|
||||
|
||||
out vec4 gsPatchCoord;
|
||||
out vec2 gsTessCoord;
|
||||
|
||||
vec4 GetPatchCoord(int index)
|
||||
{
|
||||
vec2 uv[3];
|
||||
uv[0] = vec2(0, 0); // (0, 0, 1);
|
||||
uv[1] = vec2(1, 0); // (1, 0, 0);
|
||||
uv[2] = vec2(0, 1); // (0, 1, 0);
|
||||
|
||||
ivec3 patchParam = GetPatchParam();
|
||||
return OsdInterpolatePatchCoordTriangle(uv[index], patchParam);
|
||||
}
|
||||
|
||||
void emit(int index, vec4 Peye, vec3 Neye)
|
||||
{
|
||||
outData.Peye = Peye;
|
||||
outData.Neye = Neye;
|
||||
|
||||
gsPatchCoord = GetPatchCoord(index);
|
||||
gsTessCoord = vec2(0);
|
||||
|
||||
gl_Position = vec4(GetProjectionMatrix() * outData.Peye);
|
||||
ApplyClipPlanes(outData.Peye);
|
||||
|
||||
ProcessPrimvars(index);
|
||||
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
vec4 ComputeSelectionOffset();
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_PrimitiveID = gl_PrimitiveIDIn;
|
||||
|
||||
bool isFlipped = IsFlipped(); // consider handedness AND negative-scale
|
||||
|
||||
vec3 Neye0 = GetNormal(inData[0].Neye, 0);
|
||||
Neye0 = GetTriGeometryNormal(Neye0, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, isFlipped);
|
||||
vec3 Neye1 = GetNormal(inData[1].Neye, 1);
|
||||
Neye1 = GetTriGeometryNormal(Neye1, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, isFlipped);
|
||||
vec3 Neye2 = GetNormal(inData[2].Neye, 2);
|
||||
Neye2 = GetTriGeometryNormal(Neye2, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, isFlipped);
|
||||
|
||||
vec4 Peye0 = DisplacementTerminal(
|
||||
0, inData[0].Peye, Neye0, GetPatchCoord(0));
|
||||
vec4 Peye1 = DisplacementTerminal(
|
||||
1, inData[1].Peye, Neye1, GetPatchCoord(1));
|
||||
vec4 Peye2 = DisplacementTerminal(
|
||||
2, inData[2].Peye, Neye2, GetPatchCoord(2));
|
||||
|
||||
// For wireframe, add a polygon offset to selected faces to ensure they
|
||||
// rasterize over unselected faces.
|
||||
vec4 selOffset = ComputeSelectionOffset();
|
||||
Peye0 += selOffset;
|
||||
Peye1 += selOffset;
|
||||
Peye2 += selOffset;
|
||||
|
||||
// triangle 0: vertices (0,1,2)
|
||||
emit(0, Peye0, Neye0);
|
||||
emit(1, Peye1, Neye1);
|
||||
emit(2, Peye2, Neye2);
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.Geometry.Quad
|
||||
|
||||
layout(lines_adjacency) in;
|
||||
layout(triangle_strip, max_vertices = 6) out;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inData[4];
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} outData;
|
||||
|
||||
out vec4 gsPatchCoord;
|
||||
out vec2 gsTessCoord;
|
||||
|
||||
vec4 GetPatchCoord(int index)
|
||||
{
|
||||
vec2 uv[4];
|
||||
uv[0] = vec2(0, 0);
|
||||
uv[1] = vec2(1, 0);
|
||||
uv[2] = vec2(1, 1);
|
||||
uv[3] = vec2(0, 1);
|
||||
|
||||
ivec3 patchParam = GetPatchParam();
|
||||
return OsdInterpolatePatchCoord(uv[index], patchParam);
|
||||
}
|
||||
|
||||
void emit(int index, vec4 Peye, vec3 Neye)
|
||||
{
|
||||
outData.Peye = Peye;
|
||||
outData.Neye = Neye;
|
||||
|
||||
gsPatchCoord = GetPatchCoord(index);
|
||||
gsTessCoord = vec2(0);
|
||||
|
||||
gl_Position = vec4(GetProjectionMatrix() * outData.Peye);
|
||||
ApplyClipPlanes(outData.Peye);
|
||||
|
||||
ProcessPrimvars(index);
|
||||
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
vec4 ComputeSelectionOffset();
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_PrimitiveID = gl_PrimitiveIDIn;
|
||||
|
||||
bool isFlipped = IsFlipped(); // consider handedness AND negative-scale
|
||||
|
||||
vec3 Neye0 = GetNormal(inData[0].Neye, 0);
|
||||
Neye0 = GetQuadGeometryNormal(Neye0, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, inData[3].Peye, isFlipped);
|
||||
vec3 Neye1 = GetNormal(inData[1].Neye, 1);
|
||||
Neye1 = GetQuadGeometryNormal(Neye1, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, inData[3].Peye, isFlipped);
|
||||
vec3 Neye2 = GetNormal(inData[2].Neye, 2);
|
||||
Neye2 = GetQuadGeometryNormal(Neye2, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, inData[3].Peye, isFlipped);
|
||||
vec3 Neye3 = GetNormal(inData[3].Neye, 3);
|
||||
Neye3 = GetQuadGeometryNormal(Neye3, inData[0].Peye, inData[1].Peye,
|
||||
inData[2].Peye, inData[3].Peye, isFlipped);
|
||||
|
||||
vec4 Peye0 = DisplacementTerminal(
|
||||
0, inData[0].Peye, Neye0, GetPatchCoord(0));
|
||||
vec4 Peye1 = DisplacementTerminal(
|
||||
1, inData[1].Peye, Neye1, GetPatchCoord(1));
|
||||
vec4 Peye2 = DisplacementTerminal(
|
||||
2, inData[2].Peye, Neye2, GetPatchCoord(2));
|
||||
vec4 Peye3 = DisplacementTerminal(
|
||||
3, inData[3].Peye, Neye3, GetPatchCoord(3));
|
||||
|
||||
// Generate triangles (3,0,2) and (1,2,0)
|
||||
// 3---2
|
||||
// | .|
|
||||
// | . |
|
||||
// |. |
|
||||
// 0---1
|
||||
// The indices post-quadrangulation/subdivision follow the convention:
|
||||
// 0 -> original (hull) vertex
|
||||
// 1,3 -> edge vertices
|
||||
// 2 -> center vertex
|
||||
//
|
||||
// By having index 2 in both the triangles, we ensure the pre-quadrangulated
|
||||
// face's normal (at the center) is part of the rasterizer interpolation,
|
||||
// which matters when we use smooth/limit normals.
|
||||
// In the case of flat normals, we use the vertex positions, so it doesn't
|
||||
// matter.
|
||||
|
||||
// For wireframe, add a polygon offset to selected faces to ensure they
|
||||
// rasterize over unselected faces.
|
||||
vec4 selOffset = ComputeSelectionOffset();
|
||||
Peye0 += selOffset;
|
||||
Peye1 += selOffset;
|
||||
Peye2 += selOffset;
|
||||
Peye3 += selOffset;
|
||||
|
||||
// triangle 0: vertices (3,0,2)
|
||||
emit(3, Peye3, Neye3);
|
||||
emit(0, Peye0, Neye0);
|
||||
emit(2, Peye2, Neye2);
|
||||
EndPrimitive();
|
||||
|
||||
// triangle 1: vertices (1,2,0)
|
||||
emit(1, Peye1, Neye1);
|
||||
emit(2, Peye2, Neye2);
|
||||
emit(0, Peye0, Neye0);
|
||||
EndPrimitive();
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Mesh.Fragment
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
vec3 Neye;
|
||||
} inData;
|
||||
|
||||
in vec4 gsPatchCoord;
|
||||
in vec2 gsTessCoord;
|
||||
|
||||
#ifndef HD_HAS_ptexFaceOffset
|
||||
#define HD_HAS_ptexFaceOffset
|
||||
int HdGet_ptexFaceOffset()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec4 GetPatchCoord(int localIndex)
|
||||
{
|
||||
return vec4(gsPatchCoord.xyz,
|
||||
gsPatchCoord.w + HdGet_ptexFaceOffset());
|
||||
}
|
||||
|
||||
vec3 ComputeScreenSpacePeye()
|
||||
{
|
||||
return inData.Peye.xyz / inData.Peye.w;
|
||||
}
|
||||
|
||||
vec3 ComputeScreenSpaceNeye()
|
||||
{
|
||||
vec3 Peye = ComputeScreenSpacePeye();
|
||||
vec3 Neye = normalize(cross(dFdx(Peye), dFdy(Peye)));
|
||||
return (gl_FrontFacing ? Neye : -Neye);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
bool isFlipped = IsFlipped();
|
||||
|
||||
DiscardBasedOnShading(gl_FrontFacing, isFlipped);
|
||||
|
||||
DiscardBasedOnTopologicalVisibility();
|
||||
|
||||
vec4 color = vec4(0.5, 0.5, 0.5, 1);
|
||||
#ifdef HD_HAS_displayColor
|
||||
color.rgb = HdGet_displayColor().rgb;
|
||||
#endif
|
||||
#ifdef HD_HAS_displayOpacity
|
||||
color.a = HdGet_displayOpacity().r;
|
||||
#endif
|
||||
|
||||
vec3 Peye = ComputeScreenSpacePeye();
|
||||
|
||||
vec3 Neye = inData.Neye;
|
||||
// Normalize Neye after rasterizer interpolation.
|
||||
if (length(Neye) > 0.0) {
|
||||
Neye = normalize(Neye);
|
||||
}
|
||||
// Give the shader key a chance to override the normal.
|
||||
Neye = GetNormal(Neye, 0);
|
||||
// Orient the normal for shading.
|
||||
Neye = GetShadingNormal(Neye, isFlipped);
|
||||
|
||||
vec4 patchCoord = GetPatchCoord();
|
||||
color = ShadingTerminal(vec4(Peye, 1), Neye, color, patchCoord);
|
||||
|
||||
color = ApplyEdgeColor(color, patchCoord);
|
||||
|
||||
#ifdef HD_MATERIAL_TAG_MASKED
|
||||
if (ShouldDiscardByAlpha(color)) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
RenderOutput(vec4(Peye, 1), Neye, color, patchCoord);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/meshFaceCull.glslfx
|
||||
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshFaceCull.Fragment.None
|
||||
|
||||
void DiscardBasedOnShading(bool frontFacing, bool isFlipped)
|
||||
{
|
||||
// Nothing to do since h/w face culling is used.
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshFaceCull.Fragment.SingleSided
|
||||
|
||||
void DiscardBasedOnShading(bool frontFacing, bool isFlipped)
|
||||
{
|
||||
if (ShouldCullFace(frontFacing ^^ isFlipped, /*doubleSided=*/false)) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshFaceCull.Fragment.DoubleSided
|
||||
|
||||
void DiscardBasedOnShading(bool frontFacing, bool isFlipped)
|
||||
{
|
||||
if (ShouldCullFace(frontFacing ^^ isFlipped, /*doubleSided=*/true)) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/meshNormal.glslfx
|
||||
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Scene
|
||||
|
||||
vec3 GetNormal(vec3 Neye, int index)
|
||||
{
|
||||
vec3 normal = vec3(0);
|
||||
#if defined(HD_HAS_normals)
|
||||
normal = vec3(HdGet_normals(index).xyz);
|
||||
#endif
|
||||
|
||||
MAT4 transformInv = ApplyInstanceTransformInverse(HdGet_transformInverse());
|
||||
normal = vec4(transpose(transformInv * GetWorldToViewInverseMatrix()) *
|
||||
vec4(normal,0)).xyz;
|
||||
|
||||
if (length(normal) > 0.0)
|
||||
normal = normalize(normal);
|
||||
return normal;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Scene.Patches
|
||||
|
||||
vec3 GetNormal(vec3 Neye, int index, vec2 localST)
|
||||
{
|
||||
vec3 normal = vec3(0);
|
||||
#if defined(HD_HAS_normals)
|
||||
normal = vec3(HdGet_normals(index, localST).xyz);
|
||||
#endif
|
||||
|
||||
MAT4 transformInv = ApplyInstanceTransformInverse(HdGet_transformInverse());
|
||||
normal = vec4(transpose(transformInv * GetWorldToViewInverseMatrix()) *
|
||||
vec4(normal,0)).xyz;
|
||||
|
||||
if (length(normal) > 0.0)
|
||||
normal = normalize(normal);
|
||||
return normal;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Smooth
|
||||
|
||||
vec3 GetNormal(vec3 Neye, int index)
|
||||
{
|
||||
vec3 normal = vec3(0);
|
||||
#if defined(HD_HAS_smoothNormals)
|
||||
normal = vec3(HdGet_smoothNormals(index).xyz);
|
||||
#elif defined(HD_HAS_packedSmoothNormals)
|
||||
normal = vec3(HdGet_packedSmoothNormals(index).xyz);
|
||||
#endif
|
||||
|
||||
MAT4 transformInv = ApplyInstanceTransformInverse(HdGet_transformInverse());
|
||||
normal = vec4(transpose(transformInv * GetWorldToViewInverseMatrix()) *
|
||||
vec4(normal,0)).xyz;
|
||||
|
||||
if (length(normal) > 0.0)
|
||||
normal = normalize(normal);
|
||||
return normal;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Flat
|
||||
|
||||
vec3 GetNormal(vec3 Neye, int index)
|
||||
{
|
||||
vec3 normal = vec3(0);
|
||||
#if defined(HD_HAS_flatNormals)
|
||||
normal = vec3(HdGet_flatNormals(index).xyz);
|
||||
#elif defined(HD_HAS_packedFlatNormals)
|
||||
normal = vec3(HdGet_packedFlatNormals(index).xyz);
|
||||
#endif
|
||||
|
||||
MAT4 transformInv = ApplyInstanceTransformInverse(HdGet_transformInverse());
|
||||
normal = vec4(transpose(transformInv * GetWorldToViewInverseMatrix()) *
|
||||
vec4(normal,0)).xyz;
|
||||
|
||||
if (length(normal) > 0.0)
|
||||
normal = normalize(normal);
|
||||
return normal;
|
||||
}
|
||||
|
||||
vec3 GetNormal(vec3 Neye, int index, vec2 localST)
|
||||
{
|
||||
return GetNormal(Neye, index);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Fragment.ScreenSpace
|
||||
|
||||
vec3 ComputeScreenSpaceNeye();
|
||||
|
||||
vec3 GetNormal(vec3 Neye, int index)
|
||||
{
|
||||
return ComputeScreenSpaceNeye();
|
||||
}
|
||||
|
||||
vec3 GetNormal(vec3 Neye, int index, vec2 localST)
|
||||
{
|
||||
return GetNormal(Neye, index);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Pass
|
||||
|
||||
vec3 GetNormal(vec3 Neye, int index)
|
||||
{
|
||||
return Neye;
|
||||
}
|
||||
|
||||
vec3 GetNormal(vec3 Neye, int index, vec2 localST)
|
||||
{
|
||||
return GetNormal(Neye, index);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Geometry.Flat
|
||||
|
||||
vec3 GetTriGeometryNormal(vec3 Neye, vec4 Peye0, vec4 Peye1, vec4 Peye2,
|
||||
bool isFlipped)
|
||||
{
|
||||
// ignore vertex normal and compute flat facing normal
|
||||
vec3 n = normalize(cross(Peye1.xyz - Peye0.xyz, Peye2.xyz - Peye0.xyz));
|
||||
return isFlipped ? -n : n;
|
||||
}
|
||||
|
||||
vec3 GetQuadGeometryNormal(vec3 Neye,
|
||||
vec4 Peye0, vec4 Peye1, vec4 Peye2, vec4 Peye3,
|
||||
bool isFlipped)
|
||||
{
|
||||
// 0---3
|
||||
// |. |
|
||||
// | . |
|
||||
// | .|
|
||||
// 1---2
|
||||
// ignore vertex normal and compute flat facing normal
|
||||
// average diagonal cross products to deal with co-linear edges
|
||||
vec3 A0 = Peye2.xyz - Peye3.xyz;
|
||||
vec3 B0 = Peye0.xyz - Peye3.xyz;
|
||||
vec3 A1 = Peye0.xyz - Peye1.xyz;
|
||||
vec3 B1 = Peye2.xyz - Peye1.xyz;
|
||||
vec3 n = normalize(cross(B0, A0) + cross(B1, A1));
|
||||
return isFlipped ? -n : n;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Geometry.NoFlat
|
||||
|
||||
vec3 GetTriGeometryNormal(vec3 Neye, vec4 Peye0, vec4 Peye1, vec4 Peye2,
|
||||
bool isFlipped)
|
||||
{
|
||||
return Neye;
|
||||
}
|
||||
|
||||
vec3 GetQuadGeometryNormal(vec3 Neye,
|
||||
vec4 Peye0, vec4 Peye1, vec4 Peye2, vec4 Peye3,
|
||||
bool isFlipped)
|
||||
{
|
||||
return Neye;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Fragment.SingleSided
|
||||
|
||||
vec3 GetShadingNormal(vec3 N, bool isFlipped)
|
||||
{
|
||||
// the fragment shader takes already-flipped-normals.
|
||||
// no need to flip here.
|
||||
return N;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshNormal.Fragment.DoubleSided
|
||||
|
||||
vec3 GetShadingNormal(vec3 N, bool isFlipped)
|
||||
{
|
||||
// note that negative scaling isn't taken into account in gl_FrontFacing
|
||||
// so we have to consider isFlipped here too.
|
||||
return (isFlipped ^^ gl_FrontFacing) ? N : -N;
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/meshWire.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.EdgeMaskTriangle
|
||||
|
||||
vec3 GetPrimitiveEdgeMask()
|
||||
{
|
||||
// see hd/meshUtil.cpp
|
||||
//
|
||||
// 0__ 0 0 0__
|
||||
// _/|\ \_ _/. .. . \_
|
||||
// _/ | \ \_ -> _/ . . . . \_
|
||||
// / A |C \ B \_ / A . .C . . B \_
|
||||
// 1-----2---3----4 1-----2 1---2 1----2
|
||||
//
|
||||
// Type EdgeFlag Draw
|
||||
// - 0 show all edges
|
||||
// A 1 hide [2-0]
|
||||
// B 2 hide [0-1]
|
||||
// C 3 hide [0-1] and [2-0]
|
||||
|
||||
// A value of one in this mask hides the corresponding edge.
|
||||
return vec3(0, GetEdgeFlag() & 1, GetEdgeFlag() & 2);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.EdgeMaskQuad
|
||||
|
||||
vec3 GetPrimitiveEdgeMask()
|
||||
{
|
||||
// see hd/meshUtil.cpp
|
||||
// Case EdgeFlag Draw
|
||||
// Quad/Refined face 0 hide common edge for the tri-pair
|
||||
// Non-Quad face 1/2/3 hide common edge for the tri-pair &
|
||||
// hide interior quadrangulated edges
|
||||
//
|
||||
// The first quad of a non-quad face is marked 1; the last as 2; and
|
||||
// intermediate quads as 3.
|
||||
//
|
||||
// 3...2
|
||||
// | ..
|
||||
// | . .
|
||||
// |. .
|
||||
// 0---1
|
||||
//
|
||||
|
||||
// A value of one in this mask hides the corresponding edge.
|
||||
return vec3(1, 0, GetEdgeFlag() != 0);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.EdgeMaskRefinedQuad
|
||||
|
||||
vec3 GetPrimitiveEdgeMask()
|
||||
{
|
||||
// Hide the common edge between the pair of rasterized triangles.
|
||||
return vec3(1,0,0);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.EdgeMaskNone
|
||||
|
||||
vec3 GetPrimitiveEdgeMask()
|
||||
{
|
||||
return vec3(0);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.EdgeCommon
|
||||
|
||||
vec3 GetBarycentricCoord(); // codeGen
|
||||
|
||||
// Returns the distance of the current fragment (in viewport pixel units) from
|
||||
// the nearest edge.
|
||||
float GetMinEdgeDistance()
|
||||
{
|
||||
// Hide triangle edges by adding edge mask.
|
||||
vec3 param = GetBarycentricCoord() + GetPrimitiveEdgeMask();
|
||||
vec3 edgeDistance = max(vec3(0.0), param / fwidth(param));
|
||||
return min(edgeDistance.x,
|
||||
min(edgeDistance.y,
|
||||
edgeDistance.z));
|
||||
}
|
||||
|
||||
// Use edge distance to compute a smooth opacity falloff for good looking edges.
|
||||
float GetEdgeFalloff(float d) {
|
||||
return exp2(-4 * d * d);
|
||||
}
|
||||
|
||||
float GetEdgeOpacity() {
|
||||
return GetEdgeFalloff(GetMinEdgeDistance());
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.EdgeParam
|
||||
|
||||
vec4 GetPatchCoord(int localIndex); // codeGen
|
||||
|
||||
vec3 GetEdgeParamTriangle()
|
||||
{
|
||||
// Expand barycentric coordinates
|
||||
vec2 param = GetPatchCoord(0).xy;
|
||||
vec3 barycentric = vec3(param.x, param.y, 1 - param.x - param.y);
|
||||
|
||||
// Match triangle edge order
|
||||
return barycentric.yzx;
|
||||
}
|
||||
|
||||
vec3 GetEdgeDistanceTriangle()
|
||||
{
|
||||
vec3 param = GetEdgeParamTriangle();
|
||||
return max(vec3(0.0), param / fwidth(param));
|
||||
}
|
||||
|
||||
vec4 GetEdgeParamQuad()
|
||||
{
|
||||
// Expand coordinates to opposite corners of quad
|
||||
vec2 leftBottom = GetPatchCoord(0).xy;
|
||||
vec2 rightTop = vec2(1.0) - leftBottom;
|
||||
|
||||
// Match quad edge order
|
||||
return vec4(leftBottom.y, rightTop.x, rightTop.y, leftBottom.x);
|
||||
}
|
||||
|
||||
vec4 GetEdgeDistanceQuad()
|
||||
{
|
||||
vec4 param = GetEdgeParamQuad();
|
||||
return max(vec4(0.0), param / fwidth(param));
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshPatchWire.Fragment.PatchEdgeTriangle
|
||||
|
||||
// Override for subdivided faces to make the boundary of the face stand out.
|
||||
float GetEdgeOpacityForPatch()
|
||||
{
|
||||
// Distance in pixels from triangle patch edges.
|
||||
vec3 patchEdgeDistance = GetEdgeDistanceTriangle();
|
||||
|
||||
const float patchEdgeMinDistance =
|
||||
min(patchEdgeDistance.x, min(patchEdgeDistance.y, patchEdgeDistance.z));
|
||||
|
||||
// Reduce the opacity of edges not on patch boundaries
|
||||
if (patchEdgeMinDistance > 1.0) {
|
||||
return 0.3 * GetEdgeOpacity();
|
||||
}
|
||||
|
||||
// Use distance to patch edge rather than distance to primitive edge
|
||||
return GetEdgeFalloff(patchEdgeMinDistance);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshPatchWire.Fragment.PatchEdgeQuad
|
||||
|
||||
// Override for subdivided faces to make the boundary of the face stand out.
|
||||
float GetEdgeOpacityForPatch()
|
||||
{
|
||||
// Distance in pixels from quad patch edges.
|
||||
vec4 patchEdgeDistance = GetEdgeDistanceQuad();
|
||||
|
||||
// Hide sub-patch internal edges introduced by quadrangulation
|
||||
if (GetEdgeFlag() != 0) patchEdgeDistance.yz += vec2(2.0);
|
||||
|
||||
const float patchEdgeMinDistance =
|
||||
min(min(patchEdgeDistance.x, patchEdgeDistance.y),
|
||||
min(patchEdgeDistance.z, patchEdgeDistance.w));
|
||||
|
||||
// Reduce the opacity of edges not on patch boundaries
|
||||
if (patchEdgeMinDistance > 1.0) {
|
||||
return 0.3 * GetEdgeOpacity();
|
||||
}
|
||||
|
||||
// Use distance to patch edge rather than distance to primitive edge
|
||||
return GetEdgeFalloff(patchEdgeMinDistance);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.NoEdge
|
||||
|
||||
vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord)
|
||||
{
|
||||
return Cfill;
|
||||
}
|
||||
|
||||
// Return a large value, signifying that the fragment isn't near an edge.
|
||||
float GetMinEdgeDistance()
|
||||
{
|
||||
return 1000.0;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.EdgeOnSurface
|
||||
|
||||
vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord)
|
||||
{
|
||||
float p = GetEdgeOpacity();
|
||||
|
||||
vec4 wireColor = GetWireframeColor();
|
||||
|
||||
// If wireColor is unset (zero), the fill color is just dimmed a bit.
|
||||
if (wireColor == vec4(0)) wireColor.a = 0.5;
|
||||
|
||||
vec4 Cedge = vec4(mix(Cfill.rgb, wireColor.rgb, wireColor.a), 1);
|
||||
Cfill.rgb = mix(Cfill.rgb, Cedge.rgb, p);
|
||||
|
||||
return Cfill;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.EdgeOnlyBlendColor
|
||||
|
||||
vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord)
|
||||
{
|
||||
float p = GetEdgeOpacity();
|
||||
if (p < 0.5) discard;
|
||||
|
||||
vec4 wireColor = GetWireframeColor();
|
||||
|
||||
// If wireColor is unset (zero), ignore it altogether
|
||||
|
||||
Cfill.rgb = mix(Cfill.rgb, wireColor.rgb, wireColor.a);
|
||||
Cfill.a = 1.0; // edges ignore input opacity and are opaque.
|
||||
|
||||
return Cfill;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshWire.Fragment.EdgeOnlyNoBlend
|
||||
|
||||
vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord)
|
||||
{
|
||||
float p = GetEdgeOpacity();
|
||||
if (p < 0.5) discard;
|
||||
|
||||
Cfill.a = 1.0; // edges ignore input opacity and are opaque.
|
||||
return Cfill;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshPatchWire.Fragment.EdgeOnSurface
|
||||
|
||||
vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord)
|
||||
{
|
||||
float p = GetEdgeOpacityForPatch();
|
||||
|
||||
vec4 wireColor = GetWireframeColor();
|
||||
|
||||
// If wireColor is unset (zero), the fill color is just dimmed a bit.
|
||||
if (wireColor == vec4(0)) wireColor.a = 0.5;
|
||||
|
||||
vec4 Cedge = vec4(mix(Cfill.rgb, wireColor.rgb, wireColor.a), 1);
|
||||
Cfill.rgb = mix(Cfill.rgb, Cedge.rgb, p);
|
||||
|
||||
return Cfill;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl MeshPatchWire.Fragment.EdgeOnly
|
||||
|
||||
vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord)
|
||||
{
|
||||
float p = GetEdgeOpacity();
|
||||
if (p < 0.5) discard;
|
||||
|
||||
Cfill.a = 1.0; // edges ignore input opacity and are opaque.
|
||||
|
||||
return Cfill;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/pointId.glslfx
|
||||
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl PointId.Vertex.None
|
||||
|
||||
int GetPointId()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
float GetPointRasterSize(int pointId)
|
||||
{
|
||||
return GetPointSize();
|
||||
}
|
||||
|
||||
void ProcessPointId(int pointId)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl PointId.Vertex.PointParam
|
||||
|
||||
// Fwd declare accessor method defined via code gen
|
||||
int GetBaseVertexOffset();
|
||||
int GetPointId()
|
||||
{
|
||||
return gl_VertexID - GetBaseVertexOffset();
|
||||
}
|
||||
|
||||
// Fwd declare selection decoder method defined in hdx/shaders/selection.glslfx
|
||||
bool IsPointSelected(int);
|
||||
float GetPointRasterSize(int pointId)
|
||||
{
|
||||
return IsPointSelected(pointId)?
|
||||
GetPointSelectedSize() : GetPointSize();
|
||||
}
|
||||
|
||||
// Plumb the pointId, for use in the FS.
|
||||
// XXX: This works only because the TES and GS stages are disabled when
|
||||
// rendering as points. If they are enabled, we need to add the plumbing.
|
||||
flat out int vsPointId;
|
||||
void ProcessPointId(int pointId)
|
||||
{
|
||||
vsPointId = pointId;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl PointId.Fragment.Fallback
|
||||
|
||||
int GetPointId()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl PointId.Fragment.PointParam
|
||||
|
||||
flat in int vsPointId;
|
||||
|
||||
int GetPointId()
|
||||
{
|
||||
return vsPointId;
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/points.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/instancing.glslfx
|
||||
#import $TOOLS/hdSt/shaders/terminals.glslfx
|
||||
#import $TOOLS/hdSt/shaders/pointId.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Point.Vertex
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
} outData;
|
||||
|
||||
// Fwd declare methods defined in pointId.glslfx, that are used below.
|
||||
int GetPointId();
|
||||
void ProcessPointId(int);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
MAT4 transform = ApplyInstanceTransform(HdGet_transform());
|
||||
vec4 point = vec4(HdGet_points().xyz, 1);
|
||||
|
||||
outData.Peye = vec4(GetWorldToViewMatrix() * transform * point);
|
||||
|
||||
ProcessPrimvars();
|
||||
|
||||
gl_Position = vec4(GetProjectionMatrix() * outData.Peye);
|
||||
ApplyClipPlanes(outData.Peye);
|
||||
|
||||
// check for primvar 'widths'
|
||||
#if defined(HD_HAS_widths)
|
||||
float pvWidth = HdGet_widths();
|
||||
#else
|
||||
float pvWidth = 1.0;
|
||||
#endif
|
||||
// scale width following prman's behavior
|
||||
vec4 w = vec4(transform * pvWidth * normalize(vec4(1,1,1,0)));
|
||||
float width = length(w.xyz);
|
||||
|
||||
// compute screenspace width
|
||||
vec4 diameter = vec4(GetProjectionMatrix() * vec4(width, 0, outData.Peye.z, 1));
|
||||
vec2 viewportScale = GetViewport().zw * 0.5;
|
||||
|
||||
gl_PointSize = clamp(viewportScale.x * diameter.x/diameter.w,
|
||||
HD_GL_POINT_SIZE_MIN, HD_GL_POINT_SIZE_MAX);
|
||||
|
||||
ProcessPointId(GetPointId());
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Point.Fragment
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec4 Peye;
|
||||
} inData;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 Peye = inData.Peye.xyz / inData.Peye.w;
|
||||
// camera facing.
|
||||
vec3 Neye = vec3(0, 0, 1);
|
||||
|
||||
vec4 color = vec4(0.5, 0.5, 0.5, 1);
|
||||
#ifdef HD_HAS_displayColor
|
||||
color.rgb = HdGet_displayColor().rgb;
|
||||
#endif
|
||||
#ifdef HD_HAS_displayOpacity
|
||||
color.a = HdGet_displayOpacity().r;
|
||||
#endif
|
||||
|
||||
vec4 patchCoord = vec4(0);
|
||||
color = ShadingTerminal(vec4(Peye, 1), Neye, color, patchCoord);
|
||||
|
||||
#ifdef HD_MATERIAL_TAG_MASKED
|
||||
if (ShouldDiscardByAlpha(color)) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
RenderOutput(vec4(Peye, 1), Neye, color, patchCoord);
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"ptexTextureSampler" : {
|
||||
"source": [
|
||||
"PtexTextureSampler"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl PtexTextureSampler
|
||||
|
||||
// ----- following code comes from OpenSubdiv/examples/common
|
||||
|
||||
struct PtexPacking {
|
||||
int page;
|
||||
int nMipmap;
|
||||
int uOffset;
|
||||
int vOffset;
|
||||
int adjSizeDiffs[4];
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
int computeMipmapOffsetU(int w, int level)
|
||||
{
|
||||
int width = 1 << w;
|
||||
int m = (0x55555555 & (width | (width-1))) << (w&1);
|
||||
int x = ~((1 << (w -((level-1)&~1))) - 1);
|
||||
return (m & x) + ((level+1)&~1);
|
||||
}
|
||||
|
||||
int computeMipmapOffsetV(int h, int level)
|
||||
{
|
||||
int height = 1 << h;
|
||||
int m = (0x55555555 & (height-1)) << ((h+1)&1);;
|
||||
int x = ~((1 << (h - (level&~1))) - 1 );
|
||||
return (m & x) + (level&~1);
|
||||
}
|
||||
|
||||
void evalQuadraticBSpline(float u, out float B[3], out float BU[3])
|
||||
{
|
||||
B[0] = 0.5 * (u*u - 2.0*u + 1);
|
||||
B[1] = 0.5 + u - u*u;
|
||||
B[2] = 0.5 * u*u;
|
||||
|
||||
BU[0] = u - 1.0;
|
||||
BU[1] = 1 - 2 * u;
|
||||
BU[2] = u;
|
||||
}
|
||||
|
||||
PtexPacking getPtexPacking(usampler1DArray packings, int faceID, int level)
|
||||
{
|
||||
const int layoutTexelsPerFace = 3;
|
||||
const int stride = textureSize(packings, 0).x;
|
||||
const int index = faceID * layoutTexelsPerFace;
|
||||
const int layer = index / stride;
|
||||
|
||||
const ivec2 packingIndex = ivec2(index - (layer * stride), layer);
|
||||
|
||||
const uvec2 page = texelFetch(packings, packingIndex+ivec2(0,0), 0).xy;
|
||||
const uvec2 offsets = texelFetch(packings, packingIndex+ivec2(1,0), 0).xy;
|
||||
const uvec2 sizes = texelFetch(packings, packingIndex+ivec2(2,0), 0).xy;
|
||||
|
||||
PtexPacking packing;
|
||||
packing.page = int(page.x);
|
||||
packing.nMipmap = int(page.y);
|
||||
packing.uOffset = int(offsets.x);
|
||||
packing.vOffset = int(offsets.y);
|
||||
|
||||
const int adjSizeDiffs = int(sizes.x);
|
||||
packing.adjSizeDiffs[0] = (adjSizeDiffs >> 12) & 0xf;
|
||||
packing.adjSizeDiffs[1] = (adjSizeDiffs >> 8) & 0xf;
|
||||
packing.adjSizeDiffs[2] = (adjSizeDiffs >> 4) & 0xf;
|
||||
packing.adjSizeDiffs[3] = (adjSizeDiffs >> 0) & 0xf;
|
||||
|
||||
const int wh = int(sizes.y);
|
||||
const int w = wh >> 8;
|
||||
const int h = wh & 0xff;
|
||||
|
||||
// clamp max level
|
||||
level = min(level, packing.nMipmap);
|
||||
|
||||
packing.width = 1 << (w-level);
|
||||
packing.height = 1 << (h-level);
|
||||
|
||||
if (level > 0) {
|
||||
packing.uOffset += computeMipmapOffsetU(w, level);
|
||||
packing.vOffset += computeMipmapOffsetV(h, level);
|
||||
}
|
||||
|
||||
return packing;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Non-Mipmap Lookups
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
vec4 PtexLookupNearest(vec4 patchCoord,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
vec2 uv = clamp(patchCoord.xy, vec2(0), vec2(1));
|
||||
int faceID = int(patchCoord.w);
|
||||
PtexPacking ppack = getPtexPacking(packings, faceID, 0);
|
||||
vec2 coords = vec2(uv.x * ppack.width + ppack.uOffset,
|
||||
uv.y * ppack.height + ppack.vOffset);
|
||||
return texelFetch(data, ivec3(int(coords.x), int(coords.y), ppack.page), 0);
|
||||
}
|
||||
|
||||
vec4 PtexLookupNearest(vec4 patchCoord,
|
||||
int level,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
vec2 uv = clamp(patchCoord.xy, vec2(0), vec2(1));
|
||||
int faceID = int(patchCoord.w);
|
||||
PtexPacking ppack = getPtexPacking(packings, faceID, level);
|
||||
vec2 coords = vec2(uv.x * ppack.width + ppack.uOffset,
|
||||
uv.y * ppack.height + ppack.vOffset);
|
||||
return texelFetch(data, ivec3(int(coords.x), int(coords.y), ppack.page), 0);
|
||||
}
|
||||
|
||||
vec4 PtexLookupFast(vec4 patchCoord,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
vec2 uv = clamp(patchCoord.xy, vec2(0), vec2(1));
|
||||
int faceID = int(patchCoord.w);
|
||||
PtexPacking ppack = getPtexPacking(packings, faceID, 0);
|
||||
|
||||
ivec3 size = textureSize(data, 0);
|
||||
vec2 coords = vec2((uv.x * ppack.width + ppack.uOffset)/size.x,
|
||||
(uv.y * ppack.height + ppack.vOffset)/size.y);
|
||||
return texture(data, vec3(coords.x, coords.y, ppack.page));
|
||||
}
|
||||
|
||||
vec4 PtexLookupFast(vec4 patchCoord,
|
||||
int level,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
vec2 uv = clamp(patchCoord.xy, vec2(0), vec2(1));
|
||||
int faceID = int(patchCoord.w);
|
||||
PtexPacking ppack = getPtexPacking(packings, faceID, level);
|
||||
|
||||
ivec3 size = textureSize(data, 0);
|
||||
vec2 coords = vec2((uv.x * ppack.width + ppack.uOffset)/size.x,
|
||||
(uv.y * ppack.height + ppack.vOffset)/size.y);
|
||||
return texture(data, vec3(coords.x, coords.y, ppack.page));
|
||||
}
|
||||
|
||||
vec4 PtexLookup(vec4 patchCoord,
|
||||
int level,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
vec2 uv = clamp(patchCoord.xy, vec2(0), vec2(1));
|
||||
int faceID = int(patchCoord.w);
|
||||
PtexPacking ppack = getPtexPacking(packings, faceID, level);
|
||||
|
||||
vec2 coords = vec2(uv.x * ppack.width + ppack.uOffset,
|
||||
uv.y * ppack.height + ppack.vOffset);
|
||||
|
||||
coords -= vec2(0.5, 0.5);
|
||||
|
||||
int c0X = int(floor(coords.x));
|
||||
int c1X = int(ceil(coords.x));
|
||||
int c0Y = int(floor(coords.y));
|
||||
int c1Y = int(ceil(coords.y));
|
||||
|
||||
float t = coords.x - float(c0X);
|
||||
float s = coords.y - float(c0Y);
|
||||
|
||||
vec4 d0 = texelFetch(data, ivec3(c0X, c0Y, ppack.page), 0);
|
||||
vec4 d1 = texelFetch(data, ivec3(c0X, c1Y, ppack.page), 0);
|
||||
vec4 d2 = texelFetch(data, ivec3(c1X, c0Y, ppack.page), 0);
|
||||
vec4 d3 = texelFetch(data, ivec3(c1X, c1Y, ppack.page), 0);
|
||||
|
||||
vec4 result = (1-t) * ((1-s)*d0 + s*d1) + t * ((1-s)*d2 + s*d3);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
vec4 PtexLookupQuadratic(out vec4 du,
|
||||
out vec4 dv,
|
||||
vec4 patchCoord,
|
||||
int level,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
vec2 uv = clamp(patchCoord.xy, vec2(0), vec2(1));
|
||||
int faceID = int(patchCoord.w);
|
||||
PtexPacking ppack = getPtexPacking(packings, faceID, level);
|
||||
|
||||
vec2 coords = vec2(uv.x * ppack.width + ppack.uOffset,
|
||||
uv.y * ppack.height + ppack.vOffset);
|
||||
|
||||
coords -= vec2(0.5, 0.5);
|
||||
|
||||
int cX = int(round(coords.x));
|
||||
int cY = int(round(coords.y));
|
||||
|
||||
float x = 0.5 - (float(cX) - coords.x);
|
||||
float y = 0.5 - (float(cY) - coords.y);
|
||||
|
||||
vec4 d[9];
|
||||
d[0] = texelFetch(data, ivec3(cX-1, cY-1, ppack.page), 0);
|
||||
d[1] = texelFetch(data, ivec3(cX-1, cY-0, ppack.page), 0);
|
||||
d[2] = texelFetch(data, ivec3(cX-1, cY+1, ppack.page), 0);
|
||||
d[3] = texelFetch(data, ivec3(cX-0, cY-1, ppack.page), 0);
|
||||
d[4] = texelFetch(data, ivec3(cX-0, cY-0, ppack.page), 0);
|
||||
d[5] = texelFetch(data, ivec3(cX-0, cY+1, ppack.page), 0);
|
||||
d[6] = texelFetch(data, ivec3(cX+1, cY-1, ppack.page), 0);
|
||||
d[7] = texelFetch(data, ivec3(cX+1, cY-0, ppack.page), 0);
|
||||
d[8] = texelFetch(data, ivec3(cX+1, cY+1, ppack.page), 0);
|
||||
|
||||
float B[3], D[3];
|
||||
vec4 BUCP[3] = vec4[3](vec4(0,0,0,0), vec4(0,0,0,0), vec4(0,0,0,0)),
|
||||
DUCP[3] = vec4[3](vec4(0,0,0,0), vec4(0,0,0,0), vec4(0,0,0,0));
|
||||
evalQuadraticBSpline(y, B, D);
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
vec4 A = d[i*3+j];
|
||||
BUCP[i] += A * B[j];
|
||||
DUCP[i] += A * D[j];
|
||||
}
|
||||
}
|
||||
|
||||
evalQuadraticBSpline(x, B, D);
|
||||
|
||||
vec4 result = vec4(0);
|
||||
du = vec4(0);
|
||||
dv = vec4(0);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
result += B[i] * BUCP[i];
|
||||
du += D[i] * BUCP[i];
|
||||
dv += B[i] * DUCP[i];
|
||||
}
|
||||
|
||||
du *= ppack.width;
|
||||
dv *= ppack.height;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MipMap Lookups
|
||||
// ----------------------------------------------------------------------------
|
||||
vec4 PtexMipmapLookupNearest(vec4 patchCoord,
|
||||
float level,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
#if defined(SEAMLESS_MIPMAP)
|
||||
// diff level
|
||||
int faceID = int(patchCoord.w);
|
||||
vec2 uv = patchCoord.xy;
|
||||
PtexPacking packing = getPtexPacking(packings, faceID);
|
||||
level += mix(mix(packing.adjSizeDiffs[0], packing.adjSizeDiffs[1], uv.x),
|
||||
mix(packing.adjSizeDiffs[3], packing.adjSizeDiffs[2], uv.x),
|
||||
uv.y);
|
||||
#endif
|
||||
|
||||
int levelm = int(floor(level));
|
||||
int levelp = int(ceil(level));
|
||||
float t = level - float(levelm);
|
||||
|
||||
vec4 result = (1-t) * PtexLookupNearest(patchCoord, levelm, data, packings)
|
||||
+ t * PtexLookupNearest(patchCoord, levelp, data, packings);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
vec4 PtexMipmapLookup(vec4 patchCoord,
|
||||
float level,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
#if defined(SEAMLESS_MIPMAP)
|
||||
// diff level
|
||||
int faceID = int(patchCoord.w);
|
||||
vec2 uv = patchCoord.xy;
|
||||
PtexPacking packing = getPtexPacking(packings, faceID);
|
||||
level += mix(mix(packing.adjSizeDiffs[0], packing.adjSizeDiffs[1], uv.x),
|
||||
mix(packing.adjSizeDiffs[3], packing.adjSizeDiffs[2], uv.x),
|
||||
uv.y);
|
||||
#endif
|
||||
|
||||
int levelm = int(floor(level));
|
||||
int levelp = int(ceil(level));
|
||||
float t = level - float(levelm);
|
||||
|
||||
vec4 result = (1-t) * PtexLookup(patchCoord, levelm, data, packings)
|
||||
+ t * PtexLookup(patchCoord, levelp, data, packings);
|
||||
return result;
|
||||
}
|
||||
|
||||
vec4 PtexMipmapLookupQuadratic(out vec4 du,
|
||||
out vec4 dv,
|
||||
vec4 patchCoord,
|
||||
float level,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
#if defined(SEAMLESS_MIPMAP)
|
||||
// diff level
|
||||
int faceID = int(patchCoord.w);
|
||||
vec2 uv = patchCoord.xy;
|
||||
PtexPacking packing = getPtexPacking(packings, faceID);
|
||||
level += mix(mix(packing.adjSizeDiffs[0], packing.adjSizeDiffs[1], uv.x),
|
||||
mix(packing.adjSizeDiffs[3], packing.adjSizeDiffs[2], uv.x),
|
||||
uv.y);
|
||||
#endif
|
||||
|
||||
int levelm = int(floor(level));
|
||||
int levelp = int(ceil(level));
|
||||
float t = level - float(levelm);
|
||||
|
||||
vec4 du0, du1, dv0, dv1;
|
||||
vec4 r0 = PtexLookupQuadratic(du0, dv0, patchCoord, levelm, data, packings);
|
||||
vec4 r1 = PtexLookupQuadratic(du1, dv1, patchCoord, levelp, data, packings);
|
||||
|
||||
vec4 result = mix(r0, r1, t);
|
||||
du = mix(du0, du1, t);
|
||||
dv = mix(dv0, dv1, t);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
vec4 PtexMipmapLookupQuadratic(vec4 patchCoord,
|
||||
float level,
|
||||
sampler2DArray data,
|
||||
usampler1DArray packings)
|
||||
{
|
||||
vec4 du, dv;
|
||||
return PtexMipmapLookupQuadratic(du, dv, patchCoord, level, data, packings);
|
||||
}
|
||||
|
||||
// end from OpenSubdiv/examples/common
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifndef HD_PTEX_TEXTURE_FACEOFFSET
|
||||
#define HD_PTEX_TEXTURE_FACEOFFSET
|
||||
uniform int ptexFaceOffset;
|
||||
#endif
|
||||
|
||||
vec4
|
||||
PtexTextureLookup(sampler2DArray data,
|
||||
usampler1DArray packings,
|
||||
vec4 patchCoord)
|
||||
{
|
||||
patchCoord.w += ptexFaceOffset;
|
||||
return PtexLookup(patchCoord,
|
||||
/*level = */0,
|
||||
data,
|
||||
packings);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
|
||||
-- glsl RenderPass.Camera
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// global defines
|
||||
// ---------------------------------------------------------------------------
|
||||
// codeGen can override this range (currently not).
|
||||
// quadro 4000's max is 189.
|
||||
#ifndef HD_GL_POINT_SIZE_MAX
|
||||
#define HD_GL_POINT_SIZE_MAX 100.0
|
||||
#endif
|
||||
#ifndef HD_GL_POINT_SIZE_MIN
|
||||
#define HD_GL_POINT_SIZE_MIN .45
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// render pass states
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
MAT4 GetWorldToViewMatrix() {
|
||||
#if defined(HD_HAS_worldToViewMatrix)
|
||||
return MAT4(HdGet_worldToViewMatrix());
|
||||
#else
|
||||
return MAT4(1);
|
||||
#endif
|
||||
}
|
||||
MAT4 GetWorldToViewInverseMatrix() {
|
||||
#if defined(HD_HAS_worldToViewInverseMatrix)
|
||||
return MAT4(HdGet_worldToViewInverseMatrix());
|
||||
#else
|
||||
return MAT4(1);
|
||||
#endif
|
||||
}
|
||||
MAT4 GetProjectionMatrix() {
|
||||
#if defined(HD_HAS_projectionMatrix)
|
||||
return MAT4(HdGet_projectionMatrix());
|
||||
#else
|
||||
return MAT4(1);
|
||||
#endif
|
||||
}
|
||||
float GetLightingBlendAmount() {
|
||||
#if defined(HD_HAS_lightingBlendAmount)
|
||||
return HdGet_lightingBlendAmount();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
vec4 GetViewport() {
|
||||
#if defined(HD_HAS_viewport)
|
||||
return HdGet_viewport();
|
||||
#else
|
||||
return vec4(0,0,1,1);
|
||||
#endif
|
||||
}
|
||||
float GetTessLevel() {
|
||||
#if defined(HD_HAS_tessLevel)
|
||||
return HdGet_tessLevel();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
float GetPointSize() {
|
||||
#if defined(HD_HAS_pointSize)
|
||||
return HdGet_pointSize();
|
||||
#else
|
||||
return 3.0;
|
||||
#endif
|
||||
}
|
||||
float GetPointSelectedSize() {
|
||||
#if defined(HD_HAS_pointSelectedSize)
|
||||
return HdGet_pointSelectedSize();
|
||||
#else
|
||||
return 5.0;
|
||||
#endif
|
||||
}
|
||||
vec4 GetWireframeColor() {
|
||||
// Individual prims can specify an alternative wireframe color
|
||||
// to one specified in the render pass. This is used in cases were
|
||||
// there is not enough contrast with the normal one.
|
||||
#if defined(HD_HAS_overrideWireframeColor)
|
||||
return HdGet_overrideWireframeColor();
|
||||
#elif defined(HD_HAS_wireframeColor)
|
||||
return HdGet_wireframeColor();
|
||||
#else
|
||||
return vec4(0,0,0,0);
|
||||
#endif
|
||||
}
|
||||
vec4 GetMaskColor() {
|
||||
#if defined(HD_HAS_maskColor)
|
||||
return HdGet_maskColor();
|
||||
#else
|
||||
return vec4(0.5,0,0,1);
|
||||
#endif
|
||||
}
|
||||
vec4 GetIndicatorColor() {
|
||||
#if defined(HD_HAS_indicatorColor)
|
||||
return HdGet_indicatorColor();
|
||||
#else
|
||||
return vec4(0,0.5,0,1);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ShouldDiscardByAlpha(vec4 color)
|
||||
{
|
||||
#if defined(HD_HAS_alphaThreshold)
|
||||
float alphaThreshold = HdGet_alphaThreshold();
|
||||
#else
|
||||
float alphaThreshold = 0;
|
||||
#endif
|
||||
return (color.a < alphaThreshold);
|
||||
}
|
||||
|
||||
-- glsl RenderPass.ShouldCullFace
|
||||
|
||||
bool ShouldCullFace(bool frontFacing, bool doubleSided)
|
||||
{
|
||||
const uint HdCullStyleDontCare = uint(0);
|
||||
const uint HdCullStyleNothing = uint(1);
|
||||
const uint HdCullStyleBack = uint(2);
|
||||
const uint HdCullStyleFront = uint(3);
|
||||
const uint HdCullStyleBackUnlessDoubleSided = uint(4);
|
||||
const uint HdCullStyleFrontUnlessDoubleSided = uint(5);
|
||||
|
||||
#if defined(HD_HAS_cullStyle)
|
||||
uint cullStyle = HdGet_cullStyle();
|
||||
#else
|
||||
uint cullStyle = HdCullStyleNothing;
|
||||
#endif
|
||||
|
||||
return ((cullStyle == HdCullStyleBack && !frontFacing) ||
|
||||
(cullStyle == HdCullStyleFront && frontFacing) ||
|
||||
(cullStyle == HdCullStyleBackUnlessDoubleSided && !frontFacing && !doubleSided) ||
|
||||
(cullStyle == HdCullStyleFrontUnlessDoubleSided && frontFacing && !doubleSided));
|
||||
}
|
||||
|
||||
-- glsl RenderPass.ApplyClipPlanes
|
||||
|
||||
void ApplyClipPlanes(vec4 Peye)
|
||||
{
|
||||
#if defined(HD_HAS_clipPlanes)
|
||||
#if defined(HD_NUM_clipPlanes) // more than 1 (clipPlanes[N])
|
||||
for (int i=0; i<HD_NUM_clipPlanes; ++i) {
|
||||
gl_ClipDistance[i] = dot(HdGet_clipPlanes(i), Peye);
|
||||
}
|
||||
#else // only 1 (clipPlanes)
|
||||
gl_ClipDistance[0] = dot(HdGet_clipPlanes(), Peye);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
-- glsl RenderPass.NoColorOverrides
|
||||
|
||||
vec4 ApplyColorOverrides(vec4 color)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 ApplyMaskColor(vec3 color, float weight, vec4 maskColor)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
vec4 ApplyColorOverridesPostLighting(vec4 color)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
-- glsl RenderPass.NoSelection
|
||||
|
||||
vec4 ApplySelectionColor(vec4 color)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
-- glsl RenderPass.ApplyColorOverrides
|
||||
|
||||
// Forward declare selection functionality.
|
||||
// XXX: Currently, the non-empty implementation of this is in hdx.
|
||||
vec4 ApplySelectionColor(vec4 color);
|
||||
|
||||
// XXX: Make sure to update hdx/shaders/renderPass.glslfx when editing these
|
||||
// color override methods, since they're currently duplicated. This is because
|
||||
// we don't have a mixin token for color overrides in a render pass yet.
|
||||
vec4 ApplyColorOverrides(vec4 color)
|
||||
{
|
||||
#if defined(HD_HAS_overrideColor)
|
||||
// Mix in override color
|
||||
vec4 overrideColor = HdGet_overrideColor();
|
||||
color.rgb = mix(color.rgb, overrideColor.rgb, overrideColor.a);
|
||||
#endif
|
||||
return ApplySelectionColor(color);
|
||||
}
|
||||
|
||||
vec3 ApplyMaskColor(vec3 color, float weight, vec4 maskColor)
|
||||
{
|
||||
float strength = maskColor.a * clamp(weight, 0, 1);
|
||||
return mix(color, maskColor.rgb, strength);
|
||||
}
|
||||
|
||||
vec4 ApplyColorOverridesPostLighting(vec4 color)
|
||||
{
|
||||
#if defined(HD_HAS_maskWeight)
|
||||
float maskWeight = HdGet_maskWeight();
|
||||
vec4 maskColor = GetMaskColor();
|
||||
color.rgb = ApplyMaskColor(color.rgb, maskWeight, maskColor);
|
||||
#endif
|
||||
#if defined(HD_HAS_indicatorWeight)
|
||||
float indicatorWeight = HdGet_indicatorWeight();
|
||||
vec4 indicatorColor = GetIndicatorColor();
|
||||
color.rgb = ApplyMaskColor(color.rgb, indicatorWeight, indicatorColor);
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
|
||||
-- glsl RenderPass.RenderColor
|
||||
|
||||
layout (location = 0) out vec4 colorOut;
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
colorOut = color;
|
||||
}
|
||||
|
||||
-- glsl RenderPass.RenderId
|
||||
|
||||
// XXX: This whole snippet is a little sketchy and should ideally be replaced
|
||||
// with AoVs. We generate "primId" and "instanceId", and depending on how
|
||||
// the client called glDrawBuffers, they will get one or both.
|
||||
layout (location = 0) out vec4 primIdOut;
|
||||
layout (location = 1) out vec4 instanceIdOut;
|
||||
|
||||
vec4 IntToVec4(int id)
|
||||
{
|
||||
return vec4(((id >> 0) & 0xff) / 255.0,
|
||||
((id >> 8) & 0xff) / 255.0,
|
||||
((id >> 16) & 0xff) / 255.0,
|
||||
((id >> 24) & 0xff) / 255.0);
|
||||
}
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
// Allow alpha threshold discard for ID renders regardless of material tag
|
||||
if (ShouldDiscardByAlpha(color)) {
|
||||
discard;
|
||||
}
|
||||
|
||||
int primId = HdGet_primID();
|
||||
primIdOut = IntToVec4(primId);
|
||||
|
||||
// instanceIndex is a tuple of integers (num nested levels).
|
||||
// for picking, we store global instanceId (instanceIndex[0]) in the
|
||||
// selection framebuffer and then reconstruct the tuple in postprocess.
|
||||
int instanceId = GetDrawingCoord().instanceIndex[0];
|
||||
instanceIdOut = IntToVec4(instanceId);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/renderPassShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"RenderPass.NoSelection",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"RenderPass.RenderColor" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/simpleLightingShader.glslfx
|
||||
|
||||
#import $TOOLS/glf/shaders/pcfShader.glslfx
|
||||
#import $TOOLS/glf/shaders/simpleLighting.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"fragmentShader" : {
|
||||
"source": [
|
||||
"PCF.ShadowFilterFragmentOnly",
|
||||
"SimpleLighting.LightIntegrator",
|
||||
"SimpleLighting.SimpleLighting",
|
||||
"LightingOverride.SimpleLighting"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl LightingOverride.SimpleLighting
|
||||
|
||||
vec3 FallbackLighting(in vec3 Peye, in vec3 Neye, in vec3 color)
|
||||
{
|
||||
return simpleLightingMaterial(
|
||||
vec4(color,1),
|
||||
vec4(Peye,1),
|
||||
Neye,
|
||||
vec4(1)).rgb;
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2017 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/terminals.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Geometry.CustomDisplacement
|
||||
|
||||
vec4 displacementShader(int index, vec4 Peye, vec3 Neye, vec4 patchCoord);
|
||||
|
||||
vec4 DisplacementTerminal(int index, vec4 Peye, vec3 Neye, vec4 patchCoord)
|
||||
{
|
||||
return displacementShader(index, Peye, Neye, patchCoord);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Geometry.NoCustomDisplacement
|
||||
|
||||
vec4 DisplacementTerminal(int index, vec4 Peye, vec3 Neye, vec4 patchCoord)
|
||||
{
|
||||
return Peye;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.CommonTerminals
|
||||
|
||||
struct ReprStyle
|
||||
{
|
||||
vec4 color;
|
||||
bool usePrimvarColor;
|
||||
bool usePrimvarAlpha;
|
||||
bool applyColorOverride;
|
||||
bool useSurfaceShaderColor;
|
||||
bool useSurfaceShaderAlpha;
|
||||
};
|
||||
|
||||
struct ScalarOverride
|
||||
{
|
||||
bool enabled;
|
||||
vec3 color;
|
||||
};
|
||||
|
||||
ReprStyle GetReprStyle();
|
||||
ScalarOverride GetScalarOverride();
|
||||
vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord);
|
||||
vec4 postSurfaceShader(vec4 Peye, vec3 Neye, vec4 color);
|
||||
|
||||
vec4 ShadingTerminal(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
ReprStyle reprStyle = GetReprStyle();
|
||||
|
||||
// Apply scalar override.
|
||||
ScalarOverride scalarOverride = GetScalarOverride();
|
||||
if (scalarOverride.enabled) {
|
||||
vec4 result;
|
||||
|
||||
result.rgb = scalarOverride.color;
|
||||
result.a = reprStyle.usePrimvarAlpha ? color.a: reprStyle.color.a;
|
||||
|
||||
vec4 colorOverride = ApplyColorOverrides(result);
|
||||
result = reprStyle.applyColorOverride ? colorOverride : result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Draw mode can override face color
|
||||
vec4 reprColor;
|
||||
|
||||
reprColor.rgb = reprStyle.usePrimvarColor ? color.rgb : reprStyle.color.rgb;
|
||||
reprColor.a = reprStyle.usePrimvarAlpha ? color.a : reprStyle.color.a;
|
||||
|
||||
// Compute color overrides
|
||||
vec4 colorOverride = ApplyColorOverrides(reprColor);
|
||||
reprColor = reprStyle.applyColorOverride ? colorOverride : reprColor;
|
||||
|
||||
|
||||
// Surface shading can be expensive and also can contain undesirable
|
||||
// side effects (like discards). So only run it for reprs that require it.
|
||||
|
||||
if (reprStyle.useSurfaceShaderColor ||
|
||||
reprStyle.useSurfaceShaderAlpha) {
|
||||
vec4 shadingColor;
|
||||
|
||||
shadingColor = surfaceShader(Peye,
|
||||
Neye,
|
||||
reprColor,
|
||||
patchCoord);
|
||||
|
||||
#ifdef HD_HAS_postSurfaceShader
|
||||
shadingColor = postSurfaceShader(Peye,
|
||||
Neye,
|
||||
shadingColor);
|
||||
#endif
|
||||
|
||||
reprColor.rgb = reprStyle.useSurfaceShaderColor ?
|
||||
shadingColor.rgb :
|
||||
reprColor.rgb;
|
||||
|
||||
reprColor.a = reprStyle.useSurfaceShaderAlpha ?
|
||||
shadingColor.a :
|
||||
reprColor.a;
|
||||
}
|
||||
|
||||
vec4 baseColor = color;
|
||||
baseColor = ApplyColorOverrides(baseColor);
|
||||
|
||||
vec4 litColor = mix(baseColor,
|
||||
reprColor,
|
||||
GetLightingBlendAmount());
|
||||
|
||||
// Final overrides.
|
||||
|
||||
return ApplyColorOverridesPostLighting(litColor);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.Surface
|
||||
|
||||
#ifdef HD_HAS_integrateLights
|
||||
#ifndef HD_HAS_definedIntegrateLights
|
||||
#define HD_HAS_definedIntegrateLights
|
||||
|
||||
LightingContribution
|
||||
integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
return integrateLightsDefault(Peye, Neye, props);
|
||||
}
|
||||
|
||||
#endif // HD_HAS_definedIntegrateLights
|
||||
#endif
|
||||
|
||||
ReprStyle GetReprStyle()
|
||||
{
|
||||
ReprStyle reprStyle;
|
||||
|
||||
reprStyle.color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
reprStyle.usePrimvarColor = true;
|
||||
reprStyle.usePrimvarAlpha = true;
|
||||
reprStyle.applyColorOverride = true;
|
||||
reprStyle.useSurfaceShaderColor = true;
|
||||
reprStyle.useSurfaceShaderAlpha = true;
|
||||
|
||||
return reprStyle;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.SurfaceUnlit
|
||||
|
||||
#ifdef HD_HAS_integrateLights
|
||||
#ifndef HD_HAS_definedIntegrateLights
|
||||
#define HD_HAS_definedIntegrateLights
|
||||
|
||||
LightingContribution
|
||||
integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
return integrateLightsConstant(Peye, Neye, props);
|
||||
}
|
||||
|
||||
#endif // HD_HAS_definedIntegrateLights
|
||||
#endif
|
||||
|
||||
ReprStyle GetReprStyle()
|
||||
{
|
||||
ReprStyle reprStyle;
|
||||
|
||||
reprStyle.color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
reprStyle.usePrimvarColor = true;
|
||||
reprStyle.usePrimvarAlpha = true;
|
||||
reprStyle.applyColorOverride = true;
|
||||
reprStyle.useSurfaceShaderColor = true;
|
||||
reprStyle.useSurfaceShaderAlpha = true;
|
||||
|
||||
return reprStyle;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.SurfaceSheer
|
||||
|
||||
#ifdef HD_HAS_integrateLights
|
||||
#ifndef HD_HAS_definedIntegrateLights
|
||||
#define HD_HAS_definedIntegrateLights
|
||||
|
||||
LightingContribution
|
||||
integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
return integrateLightsConstant(Peye, Neye, props);
|
||||
}
|
||||
|
||||
#endif // HD_HAS_definedIntegrateLights
|
||||
#endif
|
||||
|
||||
ReprStyle GetReprStyle()
|
||||
{
|
||||
// shade only every 2nd pixel in x and y
|
||||
// creating a thin stippled mesh grid
|
||||
float factor = step(0.5, fract((gl_FragCoord.x + 1.0) * 0.5))
|
||||
* step(0.5, fract((gl_FragCoord.y + 0.0) * 0.5));
|
||||
|
||||
// make the surface translucent so that the lines of
|
||||
// the mesh edges are visible even from the back faces.
|
||||
float alpha = 0.2 * (1.0 - factor);
|
||||
|
||||
|
||||
ReprStyle reprStyle;
|
||||
|
||||
reprStyle.color = vec4(0.0, 0.0, 0.0, alpha);
|
||||
reprStyle.usePrimvarColor = true;
|
||||
reprStyle.usePrimvarAlpha = false;
|
||||
reprStyle.applyColorOverride = true;
|
||||
reprStyle.useSurfaceShaderColor = true;
|
||||
reprStyle.useSurfaceShaderAlpha = false;
|
||||
|
||||
return reprStyle;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.SurfaceOutline
|
||||
|
||||
#ifdef HD_HAS_integrateLights
|
||||
#ifndef HD_HAS_definedIntegrateLights
|
||||
#define HD_HAS_definedIntegrateLights
|
||||
|
||||
LightingContribution
|
||||
integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
return integrateLightsConstant(Peye, Neye, props);
|
||||
}
|
||||
|
||||
#endif // HD_HAS_definedIntegrateLights
|
||||
#endif
|
||||
|
||||
ReprStyle GetReprStyle()
|
||||
{
|
||||
ReprStyle reprStyle;
|
||||
|
||||
reprStyle.color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
reprStyle.usePrimvarColor = false;
|
||||
reprStyle.usePrimvarAlpha = false;
|
||||
reprStyle.applyColorOverride = false;
|
||||
reprStyle.useSurfaceShaderColor = false;
|
||||
reprStyle.useSurfaceShaderAlpha = false;
|
||||
|
||||
return reprStyle;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.ConstantColor
|
||||
|
||||
#ifdef HD_HAS_integrateLights
|
||||
#ifndef HD_HAS_definedIntegrateLights
|
||||
#define HD_HAS_definedIntegrateLights
|
||||
|
||||
LightingContribution
|
||||
integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
return integrateLightsConstant(Peye, Neye, props);
|
||||
}
|
||||
|
||||
#endif // HD_HAS_definedIntegrateLights
|
||||
#endif
|
||||
|
||||
ReprStyle GetReprStyle()
|
||||
{
|
||||
ReprStyle reprStyle;
|
||||
|
||||
reprStyle.color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
reprStyle.usePrimvarColor = true;
|
||||
reprStyle.usePrimvarAlpha = true;
|
||||
reprStyle.applyColorOverride = true;
|
||||
reprStyle.useSurfaceShaderColor = false;
|
||||
reprStyle.useSurfaceShaderAlpha = false;
|
||||
|
||||
return reprStyle;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.HullColor
|
||||
|
||||
#ifdef HD_HAS_integrateLights
|
||||
#ifndef HD_HAS_definedIntegrateLights
|
||||
#define HD_HAS_definedIntegrateLights
|
||||
|
||||
LightingContribution
|
||||
integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
return integrateLightsConstant(Peye, Neye, props);
|
||||
}
|
||||
|
||||
#endif // HD_HAS_definedIntegrateLights
|
||||
#endif
|
||||
|
||||
ReprStyle GetReprStyle()
|
||||
{
|
||||
vec4 hullColor = vec4(vec3(0.18), 1.0);
|
||||
|
||||
#if defined(HD_HAS_selectedWeight)
|
||||
float weight = clamp(HdGet_selectedWeight(), 0.0, 1.0);
|
||||
|
||||
if (weight <= 0.0) {
|
||||
discard;
|
||||
}
|
||||
|
||||
// The three control points of the quadratic curve for the selection color
|
||||
// with the binomial coefficient premultiplied in.
|
||||
// constant : 1
|
||||
// linear : 1 1
|
||||
// quadratic : 1 2 1
|
||||
vec3 c0 = vec3(0.0, 0.0, 0.0); // 1.0 * Black
|
||||
vec3 c1 = vec3(2.0, 0.0, 0.0); // 2.0 * Red
|
||||
vec3 c2 = vec3(1.0, 1.0, 0.0); // 1.0 * Yellow
|
||||
|
||||
// de Casteljau quadratic curve interpolation
|
||||
// A recursive application of lerp ('mix' in glsl) reducing the order each
|
||||
// step of the recursion.
|
||||
// at weight = 0.0 we get c0
|
||||
// at weight = 0.5 we get c0 * .25 + c1 * 0.5 + c2 *.25
|
||||
// at weight = 1.0 we get c2
|
||||
// Thus it is a smooth curve going from c0 to c2 bending towards c1
|
||||
hullColor.rgb = mix(mix(c0, c1, weight),
|
||||
mix(c1, c2, weight), weight);
|
||||
|
||||
#else
|
||||
#if defined(HD_HAS_hullColor)
|
||||
hullColor.rgb = HdGet_hullColor();
|
||||
#endif
|
||||
#if defined(HD_HAS_hullOpacity)
|
||||
hullColor.a = HdGet_hullOpacity();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ReprStyle reprStyle;
|
||||
|
||||
reprStyle.color = hullColor;
|
||||
reprStyle.usePrimvarColor = false;
|
||||
reprStyle.usePrimvarAlpha = false;
|
||||
reprStyle.applyColorOverride = true;
|
||||
reprStyle.useSurfaceShaderColor = false;
|
||||
reprStyle.useSurfaceShaderAlpha = false;
|
||||
|
||||
return reprStyle;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.PointColor
|
||||
|
||||
#ifdef HD_HAS_integrateLights
|
||||
#ifndef HD_HAS_definedIntegrateLights
|
||||
#define HD_HAS_definedIntegrateLights
|
||||
|
||||
LightingContribution
|
||||
integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
|
||||
{
|
||||
return integrateLightsConstant(Peye, Neye, props);
|
||||
}
|
||||
|
||||
#endif // HD_HAS_definedIntegrateLights
|
||||
#endif
|
||||
|
||||
ReprStyle GetReprStyle()
|
||||
{
|
||||
vec4 pointColor = vec4(vec3(0.18), 1.0);
|
||||
#if defined(HD_HAS_pointColor)
|
||||
pointColor = HdGet_pointColor();
|
||||
#endif
|
||||
|
||||
ReprStyle reprStyle;
|
||||
|
||||
reprStyle.color = pointColor;
|
||||
reprStyle.usePrimvarColor = false;
|
||||
reprStyle.usePrimvarAlpha = false;
|
||||
reprStyle.applyColorOverride = true;
|
||||
reprStyle.useSurfaceShaderColor = false;
|
||||
reprStyle.useSurfaceShaderAlpha = false;
|
||||
|
||||
return reprStyle;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.ScalarOverride
|
||||
|
||||
ScalarOverride GetScalarOverride()
|
||||
{
|
||||
ScalarOverride result;
|
||||
|
||||
#if defined(HD_HAS_scalarOverride)
|
||||
result.enabled = true;
|
||||
|
||||
// Allow a scalar value to override the color from the surface
|
||||
// for previewing heatmaps. This is useful for editing workflows.
|
||||
#if defined(HD_HAS_scalarOverrideColorRamp)
|
||||
int rampCount = constantPrimvars[GetDrawingCoord().constantCoord].
|
||||
scalarOverrideColorRamp.length();
|
||||
float scalar = HdGet_scalarOverride() * float(rampCount - 1);
|
||||
float baseIndex = floor(scalar);
|
||||
float nextIndex = min(float(rampCount - 1), baseIndex + 1.0);
|
||||
float interp = scalar - baseIndex;
|
||||
result.color = mix(HdGet_scalarOverrideColorRamp(int(baseIndex)).rgb,
|
||||
HdGet_scalarOverrideColorRamp(int(nextIndex)).rgb,
|
||||
interp);
|
||||
#else
|
||||
// If no ramp is given just gamma correct the scalar as greyscale.
|
||||
result.color = vec3(pow(HdGet_scalarOverride(), 2.2));
|
||||
#endif // HD_HAS_scalarOverrideColorRamp
|
||||
|
||||
#else // HD_HAS_scalarOverride
|
||||
result.enabled = false;
|
||||
result.color = vec3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Fragment.NoScalarOverride
|
||||
|
||||
ScalarOverride GetScalarOverride()
|
||||
{
|
||||
ScalarOverride result;
|
||||
|
||||
result.enabled = false;
|
||||
result.color = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/visibility.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Visibility.Fragment.Fallback
|
||||
void DiscardBasedOnTopologicalVisibility()
|
||||
{
|
||||
// Nothing to do, since there's no authored opinion.
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Visibility.Fragment.Topology
|
||||
|
||||
int GetElementID(); // code gen
|
||||
|
||||
void GetBitmaskBufferIndices(int id, out int arrayIndex, out int bitIndex)
|
||||
{
|
||||
arrayIndex = id / 32;
|
||||
bitIndex = id % 32;
|
||||
}
|
||||
|
||||
bool IsBitSet(uint bitmask, int bitIndex)
|
||||
{
|
||||
return bool(bitmask & (1 << bitIndex));
|
||||
}
|
||||
|
||||
bool IsElementVisible()
|
||||
{
|
||||
#if defined(HD_HAS_elementsVisibility)
|
||||
// Element (face) visibility is encoded as an array of bitmasks (uint32)
|
||||
// with 1 bit per authored face.
|
||||
int elementId = GetElementID();
|
||||
// When rendering a mesh as points, element id doesn't make sense. Code
|
||||
// gen returns -1 as a fallback for this case.
|
||||
if (elementId != -1) {
|
||||
int arrayIndex, bitIndex;
|
||||
GetBitmaskBufferIndices(elementId, arrayIndex, bitIndex);
|
||||
uint ev = HdGet_elementsVisibility(arrayIndex);
|
||||
return IsBitSet(ev, bitIndex);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetPointId(); // pointId.glslfx
|
||||
|
||||
bool IsPointVisible()
|
||||
{
|
||||
#if defined(HD_HAS_pointsVisibility)
|
||||
// Point visibility is encoded as an array of bitmasks (uint32) with 1 bit
|
||||
// per unrefined vertex.
|
||||
int pointId = GetPointId();
|
||||
// When *not* rendering a mesh as points, we return -1 for the point id.
|
||||
// See PointId.Fragment.Fallback
|
||||
if (pointId != -1) {
|
||||
int arrayIndex, bitIndex;
|
||||
GetBitmaskBufferIndices(pointId, arrayIndex, bitIndex);
|
||||
uint pv = HdGet_pointsVisibility(arrayIndex);
|
||||
return IsBitSet(pv, bitIndex);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void DiscardBasedOnTopologicalVisibility()
|
||||
{
|
||||
if (!IsElementVisible() || !IsPointVisible()) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,614 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdSt/shaders/volume.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/instancing.glslfx
|
||||
#import $TOOLS/hdSt/shaders/pointId.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Volume.Vertex
|
||||
|
||||
out VertexData
|
||||
{
|
||||
// Relying on perspectively correct interpolation.
|
||||
vec3 Peye;
|
||||
} outData;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Bounding box vertex in local spce
|
||||
const vec4 point = vec4(HdGet_points().xyz, 1);
|
||||
|
||||
const MAT4 transform = ApplyInstanceTransform(HdGet_transform());
|
||||
|
||||
// Bounding box vertex in eye space.
|
||||
const vec4 pointEye = vec4(GetWorldToViewMatrix() * transform * point);
|
||||
|
||||
outData.Peye = pointEye.xyz / pointEye.w;
|
||||
|
||||
gl_Position = vec4(GetProjectionMatrix() * pointEye);
|
||||
|
||||
ProcessPrimvars();
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Volume.Fragment
|
||||
|
||||
// Quality knobs, should eventually be configurable.
|
||||
//
|
||||
// We also might have different values for the raymarch
|
||||
// integrating the pixel value and for the raymarch doing
|
||||
// the lighting computation.
|
||||
|
||||
const int maxNumSteps = 10000;
|
||||
|
||||
// Min transmittance (ray marching stops when underrun)
|
||||
const float minTransmittance = 0.002;
|
||||
|
||||
// Minimal scattering amount to ray march to light
|
||||
const float minScattering = 0.002;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec3 Peye;
|
||||
} inData;
|
||||
|
||||
// Eye space to local space.
|
||||
// Used frequently per ray-marching step in both volumeIntegrator
|
||||
// and accumulatedTransmittance, so computed only once in main.
|
||||
//
|
||||
MAT4 instanceModelViewInverse;
|
||||
// Eye space to volume bounding box space
|
||||
mat4 eyeToBBox;
|
||||
float resolvedStepSizeEye;
|
||||
float resolvedStepSizeEyeLighting;
|
||||
float resolvedStepSizeWorld;
|
||||
float resolvedStepSizeWorldLighting;
|
||||
|
||||
// Transform a point by a 4x4 matrix
|
||||
vec3
|
||||
transformPoint(mat4 m, vec3 point)
|
||||
{
|
||||
const vec4 result = vec4(m * vec4(point, 1.0));
|
||||
return result.xyz / result.w;
|
||||
}
|
||||
|
||||
vec3
|
||||
transformPoint(dmat4 m, vec3 point)
|
||||
{
|
||||
const vec4 result = vec4(m * vec4(point, 1.0));
|
||||
return result.xyz / result.w;
|
||||
}
|
||||
|
||||
// Transform a direction by a 4x4 matrix
|
||||
vec3
|
||||
transformDir(mat4 m, vec3 dir)
|
||||
{
|
||||
const vec4 result = vec4(m * vec4(dir, 0.0));
|
||||
return result.xyz;
|
||||
}
|
||||
|
||||
vec3
|
||||
transformDir(dmat4 m, vec3 dir)
|
||||
{
|
||||
const vec4 result = vec4(m * vec4(dir, 0.0));
|
||||
return result.xyz;
|
||||
}
|
||||
|
||||
// Compute time when a ray starting at pos with direction dir
|
||||
// exits the axis-aligned box with vertices lMin and lMax.
|
||||
//
|
||||
// Assumes that dir.x isn't close to zero.
|
||||
float
|
||||
timeRayExitsBoxPreferX(vec3 pos, vec3 dir, vec3 lMin, vec3 lMax)
|
||||
{
|
||||
// Compute the time when the ray exists the region
|
||||
// R1 = [xMin, xMax] x [-inf,inf] x [-inf,inf].
|
||||
|
||||
// Depending on whether the the ray is going left or right, compute
|
||||
// the time when the ray is intersecting the plane containing the
|
||||
// left or right face of the box.
|
||||
float result = (((dir.x > 0.0) ? lMax.x : lMin.x) - pos.x) / dir.x;
|
||||
|
||||
// Compute the time when the ray exists the region
|
||||
// R2 = [xMin, xMax] x [yMin,yMax] x [-inf,inf].
|
||||
|
||||
// We can compute the intersection where the ray left R1 as
|
||||
// pos + dir * result.
|
||||
// If this intersection is above or below the box, we know that there
|
||||
// is an earlier intersection of the ray with the plane containing
|
||||
// the top or bottom face of the box, compute that intersection time.
|
||||
const float y = pos.y + dir.y * result;
|
||||
if (y < lMin.y) {
|
||||
result = (lMin.y - pos.y) / dir.y;
|
||||
}
|
||||
if (y > lMax.y) {
|
||||
result = (lMax.y - pos.y) / dir.y;
|
||||
}
|
||||
|
||||
// Compute the time when the ray exists the region
|
||||
// R3 = [xMin, xMax] x [yMin,yMax] x [zMin,zMax].
|
||||
|
||||
// Analogous procedure to above.
|
||||
const float z = pos.z + dir.z * result;
|
||||
if (z < lMin.z) {
|
||||
result = (lMin.z - pos.z) / dir.z;
|
||||
}
|
||||
if (z > lMax.z) {
|
||||
result = (lMax.z - pos.z) / dir.z;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Compute time when a ray starting at pos with direction dir
|
||||
// exits the axis-aligned box with vertices lMin and lMax.
|
||||
//
|
||||
// Assumes that dir is normalized.
|
||||
float
|
||||
timeRayExitsBox(vec3 pos, vec3 dir, vec3 lMin, vec3 lMax)
|
||||
{
|
||||
// Uses timeRayExitsBoxPreferX after permuting the coordinates
|
||||
// to make sure that x is not close to zero.
|
||||
//
|
||||
// Note that because dir has unit length, at least one of its entries
|
||||
// has absolute value larger 1/2 ( (1/2)^2 + (1/2)^2 + (1/2)^2 < 1^2).
|
||||
|
||||
const vec3 abs_dir = abs(dir);
|
||||
if (abs_dir.x > 0.5) {
|
||||
return timeRayExitsBoxPreferX(
|
||||
pos , dir , lMin , lMax );
|
||||
}
|
||||
if (abs_dir.y > 0.5) {
|
||||
return timeRayExitsBoxPreferX(
|
||||
pos.yzx, dir.yzx, lMin.yzx, lMax.yzx);
|
||||
}
|
||||
|
||||
return timeRayExitsBoxPreferX(
|
||||
pos.zxy, dir.zxy, lMin.zxy, lMax.zxy);
|
||||
}
|
||||
|
||||
// Given a ray in eye space starting inside a volume, compute the time when it
|
||||
// exists the volume (assuming rayDirectionEye is normalized).
|
||||
float
|
||||
timeRayExitsVolume(vec3 rayStartEye, vec3 rayDirectionEye)
|
||||
{
|
||||
// Transform ray to volume bounding box space
|
||||
const vec3 rayStartBBox = transformPoint(eyeToBBox, rayStartEye);
|
||||
const vec3 rayDirectionBBox = transformDir (eyeToBBox, rayDirectionEye);
|
||||
|
||||
// Compute when ray is leaving the volume bounding box
|
||||
return timeRayExitsBox(rayStartBBox,
|
||||
rayDirectionBBox,
|
||||
vec3(HdGet_volumeBBoxLocalMin().xyz),
|
||||
vec3(HdGet_volumeBBoxLocalMax().xyz));
|
||||
|
||||
}
|
||||
|
||||
// Given a ray in eye space, compute the time when it entered the volume
|
||||
// (assuming rayDirectionEye is normalized).
|
||||
// Note that it is assumed that the ray point is in the volume and that the
|
||||
// result will be negative.
|
||||
float
|
||||
timeRayEnteredVolume(vec3 rayEndEye, vec3 rayDirectionEye)
|
||||
{
|
||||
// Compute when reversed ray is exiting the volume bounding box
|
||||
return - timeRayExitsVolume(rayEndEye, -rayDirectionEye);
|
||||
}
|
||||
|
||||
vec3
|
||||
coordsToLocalVolumeSpace(vec3 coords)
|
||||
{
|
||||
return transformPoint(instanceModelViewInverse, coords);
|
||||
}
|
||||
|
||||
#if NUM_LIGHTS == 0
|
||||
|
||||
vec3
|
||||
lightingComputation(vec3 rayPointEye, vec3 rayDirectionEye)
|
||||
{
|
||||
return vec3(0.0);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Compute how the transmittance of volume from Peye to a
|
||||
// light source in the given direction rayDirection.
|
||||
// This integrates the density from Peye to the boundary of
|
||||
// the volume. The assumption is that the light source is
|
||||
// out of the volume.
|
||||
float
|
||||
accumulatedTransmittance(vec3 rayStartEye, vec3 rayDirectionEye)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
float totalExtinction = 0.0;
|
||||
|
||||
const vec3 rayStepEye = resolvedStepSizeEyeLighting * rayDirectionEye;
|
||||
|
||||
const float rayLength = timeRayExitsVolume(rayStartEye, rayDirectionEye);
|
||||
|
||||
const int numSteps =
|
||||
int(floor(min(maxNumSteps, rayLength / resolvedStepSizeEyeLighting)));
|
||||
|
||||
while(i < numSteps) {
|
||||
const vec3 rayPointEye = rayStartEye + i * rayStepEye;
|
||||
|
||||
totalExtinction += extinctionFunction(rayPointEye);
|
||||
|
||||
i+=1;
|
||||
}
|
||||
|
||||
return exp(-totalExtinction * resolvedStepSizeWorldLighting);
|
||||
}
|
||||
|
||||
// Computes amount of light arriving at point Peye
|
||||
// taking attenuation (e.g., by inverse-square law), shadows,
|
||||
// transmittance by volume into account.
|
||||
vec3
|
||||
lightingComputation(vec3 rayPointEye, vec3 rayDirectionEye)
|
||||
{
|
||||
vec3 result = vec3(0.0);
|
||||
for (int i = 0; i < NUM_LIGHTS; ++i) {
|
||||
|
||||
const vec4 Plight = lightSource[i].position;
|
||||
|
||||
const vec3 lightDirectionEye = normalize(
|
||||
(Plight.w == 0.0) ? Plight.xyz : Plight.xyz - rayPointEye);
|
||||
|
||||
const float atten =
|
||||
lightDistanceAttenuation(vec4(rayPointEye,1), i) *
|
||||
lightSpotAttenuation(lightDirectionEye, i);
|
||||
|
||||
// For now, not using shadows for volumes.
|
||||
#if USE_SHADOWS && 0
|
||||
const float shadow = (lightSource[i].hasShadow) ?
|
||||
shadowing(/*lightIndex=*/i, rayPointEye) : 1.0;
|
||||
#else
|
||||
const float shadow = 1.0;
|
||||
#endif
|
||||
|
||||
if (shadow > 0.0001) {
|
||||
result +=
|
||||
shadow *
|
||||
atten *
|
||||
// Assuming that light source is outside of volume's
|
||||
// bounding box (might integrate extinction along ray
|
||||
// beyond light source).
|
||||
accumulatedTransmittance(rayPointEye, lightDirectionEye) *
|
||||
phaseFunction(-rayDirectionEye, lightDirectionEye) *
|
||||
lightSource[i].diffuse.rgb;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Result of integrating volume along a ray
|
||||
struct VolumeContribution
|
||||
{
|
||||
// Coordinates where ray marching hit the first non-empty voxel
|
||||
// in eye space. 0 indicates the ray hit only empty voxels.
|
||||
vec3 firstHitPeye;
|
||||
|
||||
// Integrated color
|
||||
vec3 color;
|
||||
|
||||
// Integrated transmittance, i.e., what fraction of light from
|
||||
// geometry behind the volume is still visible.
|
||||
float transmittance;
|
||||
};
|
||||
|
||||
VolumeContribution
|
||||
volumeIntegrator(vec3 rayStartEye, vec3 rayDirectionEye, float rayLength)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
VolumeContribution result;
|
||||
result.firstHitPeye = vec3(0.0);
|
||||
result.color = vec3(0.0);
|
||||
result.transmittance = 1.0;
|
||||
|
||||
const vec3 rayStepEye = resolvedStepSizeEye * rayDirectionEye;
|
||||
|
||||
const int numSteps =
|
||||
int(floor(min(maxNumSteps, rayLength / resolvedStepSizeEye)));
|
||||
|
||||
// integrate transmittance and light along ray for bounding box
|
||||
while(i < numSteps) {
|
||||
const vec3 rayPointEye = rayStartEye + i * rayStepEye;
|
||||
|
||||
// Evaluate volume shader functions to determine extinction,
|
||||
// scattering, and emission.
|
||||
const float extinctionValue = extinctionFunction(rayPointEye);
|
||||
const float scatteringValue = scatteringFunction(rayPointEye);
|
||||
const vec3 emissionValue = emissionFunction(rayPointEye);
|
||||
|
||||
// If this is the first time the ray is hitting a non-empty voxel,
|
||||
// record the coordinates.
|
||||
if (result.firstHitPeye == vec3(0.0)) {
|
||||
if ( extinctionValue > 0 ||
|
||||
scatteringValue > 0 ||
|
||||
any(greaterThan(emissionValue, vec3(0)))) {
|
||||
result.firstHitPeye = rayPointEye;
|
||||
}
|
||||
}
|
||||
|
||||
// In scattering contribution, lighting only computed if scattering
|
||||
// is non-trivial.
|
||||
const vec3 inScattering =
|
||||
(resolvedStepSizeWorld * scatteringValue >= minScattering) ?
|
||||
(scatteringValue *
|
||||
lightingComputation(rayPointEye, rayDirectionEye))
|
||||
: vec3(0.0);
|
||||
|
||||
// In scattering and emission contribution
|
||||
result.color +=
|
||||
(resolvedStepSizeWorld * result.transmittance) *
|
||||
(inScattering + emissionValue);
|
||||
|
||||
// Update transmittance
|
||||
result.transmittance *= exp(-extinctionValue * resolvedStepSizeWorld);
|
||||
|
||||
// Stop when the volume has become close to opaque.
|
||||
if (result.transmittance < minTransmittance) {
|
||||
break;
|
||||
}
|
||||
|
||||
i+=1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Is camera orthographic?
|
||||
bool
|
||||
isCameraOrthographic()
|
||||
{
|
||||
return abs(GetProjectionMatrix()[3][3] - 1.0) < 1e-5;
|
||||
}
|
||||
|
||||
// Convert depth value z in [-1,1] to depth in eye space [-near, -far].
|
||||
float
|
||||
NDCtoEyeZ(float z)
|
||||
{
|
||||
const MAT4 m = inverse(GetProjectionMatrix());
|
||||
return float((m[2][2] * z + m[3][2]) / (m[2][3] * z + m[3][3]));
|
||||
}
|
||||
|
||||
// Compute the z-value of the near clipping plane in eye space.
|
||||
// Negative by OpenGL convention
|
||||
float
|
||||
computeNearZ()
|
||||
{
|
||||
return NDCtoEyeZ(-1.0);
|
||||
}
|
||||
|
||||
// Compute the near clipping distance. Always returns a positive value.
|
||||
float
|
||||
computeNearDistance()
|
||||
{
|
||||
return abs(computeNearZ());
|
||||
}
|
||||
|
||||
// Consider the ray from the eye to a given point in eye space.
|
||||
// Computes the direction of this ray in both cases where the
|
||||
// camera is orthographic or perspective.
|
||||
vec3
|
||||
computeRayDirectionEye(vec3 rayPointEye)
|
||||
{
|
||||
// In NDC space, the ray is always pointing into the z-direction (0,0,1).
|
||||
// In clip space, this corresponds to (0,0,1,0).
|
||||
// We need to multiply (0,0,1,0) by the inverse projection matrix to
|
||||
// get to homogeneous eye space.
|
||||
// Or alternatively, we can get the direction in homogeneous eye space
|
||||
// by taking the respective column of the inverse projection matrix:
|
||||
const vec4 dir = vec4(inverse(GetProjectionMatrix())[2]);
|
||||
|
||||
// To compute the corresponding direction in non-homogeneous eye space,
|
||||
// compute the position of the ray after time dt << 1:
|
||||
// vec4 pHomogeneous = vec4(rayPointEye, 1.0) + dt * dir;
|
||||
// vec3 p = pHomogeneous.xyz / pHomogeneous.w;
|
||||
//
|
||||
// Or equivalently:
|
||||
// vec3 p = (rayPointEye + dt * dir.xyz) / (1.0 + dir.w * dt);
|
||||
// And since dt << 1, we have
|
||||
// vec3 p = (rayPointEye + dt * dir.xyz) * (1.0 - dir.w * dt);
|
||||
// And dropping higher order terms:
|
||||
// vec3 p = rayPointEye + dt * (dir.xyz - rayPointEye * dir.w);
|
||||
// So the new direction is given by:
|
||||
// vec3 d = dir.xyz - rayPointEye * dir.w;
|
||||
|
||||
// Normalize direction in eye space.
|
||||
return normalize(dir.xyz - rayPointEye * dir.w);
|
||||
}
|
||||
|
||||
// Given where the ray is about to leave the volume, compute where we
|
||||
// should start ray marching: this is either the point where the ray
|
||||
// would have entered the volume or the intersection with the near
|
||||
// clipping plane or a sphere about the eye (in the perspective case).
|
||||
//
|
||||
vec3
|
||||
computeRayStartEye(vec3 rayEndEye, vec3 rayDirectionEye)
|
||||
{
|
||||
// Time where ray would have entered volume (negative).
|
||||
const float startTime = timeRayEnteredVolume(rayEndEye, rayDirectionEye);
|
||||
|
||||
if (isCameraOrthographic()) {
|
||||
// Time where ray would have intersected near plane
|
||||
const float nearTime =
|
||||
(computeNearZ() - rayEndEye.z)
|
||||
/ rayDirectionEye.z;
|
||||
// Take the latter of the two times for getting the start point
|
||||
return rayEndEye + max(startTime, nearTime) * rayDirectionEye;
|
||||
}
|
||||
|
||||
// Note that we intersect the ray with sphere about the eye with
|
||||
// radius equal to the near distance in the perspective case rather
|
||||
// than just the above intersection with the near plane.
|
||||
//
|
||||
// The motivation is that the distance between the eye and the
|
||||
// near plane is non-constant across the image. Thus, ray-marching
|
||||
// would skip more volume away from the center of the image making
|
||||
// the image darker there - so we see opposite vignetting. To
|
||||
// avoid this bias, we use a sphere about the eye.
|
||||
//
|
||||
// Note that we can use points in front of the near plane
|
||||
// since OIT resolution makes no assumptions about the
|
||||
// depth value.
|
||||
//
|
||||
|
||||
// Compute point where ray would have entered volume
|
||||
const vec3 rayStartEye = rayEndEye + startTime * rayDirectionEye;
|
||||
// If this point is behind the eye or in the sphere about the eye, ...
|
||||
if (rayStartEye.z > 0.0 || length(rayStartEye) < computeNearDistance()) {
|
||||
// ... use point on sphere.
|
||||
return normalize(rayDirectionEye) * computeNearDistance();
|
||||
}
|
||||
|
||||
return rayStartEye;
|
||||
}
|
||||
|
||||
// The depth at which we hit opaque geometry in eye space (negative
|
||||
// value by OpenGL convention).
|
||||
float
|
||||
sampleZBuffer(vec2 fragcoord)
|
||||
{
|
||||
#ifdef HD_HAS_depthReadback
|
||||
// Sample the z-Buffer at the frag coordinate.
|
||||
const float bufferVal = texelFetch(HdGetSampler_depthReadback(),
|
||||
ivec2(fragcoord),
|
||||
/* lod = */ 0).z;
|
||||
#else
|
||||
// Assume far-plane if we cannot sample the z-Buffer.
|
||||
const float bufferVal = 1.0;
|
||||
#endif
|
||||
|
||||
return NDCtoEyeZ(2.0 * bufferVal - 1.0);
|
||||
}
|
||||
|
||||
// Compute how much length we need to ray march.
|
||||
//
|
||||
// The ray is encoded through it start point and direction. Its end will be
|
||||
// determined from two things:
|
||||
// - the eye space coordinates of this fragment which is part of the back-faces
|
||||
// of the volume.
|
||||
// - the z-Value of the opaque geometry (since we want to stop raymarching
|
||||
// once the ray has hit opaque geometry)
|
||||
float
|
||||
computeRayLength(vec3 rayStartEye, vec3 rayDirectionEye, vec3 rayEndEye,
|
||||
float opaqueZ)
|
||||
{
|
||||
// Recall that the camera is looking down the minus z-direction by
|
||||
// OpenGL conventions so we need to take the max to get the closer
|
||||
// point.
|
||||
const float rayEndZ = max(opaqueZ, rayEndEye.z);
|
||||
return (rayEndZ - rayStartEye.z) / rayDirectionEye.z;
|
||||
}
|
||||
|
||||
float max3(float a, float b, float c)
|
||||
{
|
||||
return max(a, max(b, c));
|
||||
}
|
||||
|
||||
// Computes the inverse of the scaling of an affine transform.
|
||||
// Approximately - since most transforms have uniform scaling
|
||||
// and no shear, this is fine.
|
||||
float
|
||||
scaleOfMatrix(MAT4 m)
|
||||
{
|
||||
// Take the maximum of the lengths of the images of the x, y
|
||||
// and z vector.
|
||||
//
|
||||
// A more general, coordinate independent implementation would take
|
||||
// the minimum singular value from the singular value decomposition.
|
||||
//
|
||||
const mat3 affinePart = mat3(m);
|
||||
return max3(length(affinePart[0]),
|
||||
length(affinePart[1]),
|
||||
length(affinePart[2]));
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
instanceModelViewInverse =
|
||||
ApplyInstanceTransformInverse(HdGet_transformInverse()) *
|
||||
GetWorldToViewInverseMatrix();
|
||||
|
||||
eyeToBBox = mat4(
|
||||
MAT4(HdGet_volumeBBoxInverseTransform()) * instanceModelViewInverse);
|
||||
|
||||
ProcessSamplingTransforms(instanceModelViewInverse);
|
||||
|
||||
const float halfWorldSampleDistance =
|
||||
0.5 * float(HdGet_sampleDistance())
|
||||
/ scaleOfMatrix(instanceModelViewInverse);
|
||||
|
||||
const float viewScale = scaleOfMatrix(GetWorldToViewInverseMatrix());
|
||||
|
||||
resolvedStepSizeEye =
|
||||
HdGet_stepSize() * halfWorldSampleDistance;
|
||||
resolvedStepSizeWorld =
|
||||
viewScale * resolvedStepSizeEye;
|
||||
resolvedStepSizeEyeLighting =
|
||||
HdGet_stepSizeLighting() * halfWorldSampleDistance;
|
||||
resolvedStepSizeWorldLighting =
|
||||
viewScale * resolvedStepSizeEyeLighting;
|
||||
|
||||
// Discard front faces - ray marching stops at fragment eye position
|
||||
// and starts at the intersection of ray with volume bounding box or
|
||||
// near plane.
|
||||
if (gl_FrontFacing ^^ (determinant(instanceModelViewInverse) < 0.0)) {
|
||||
discard;
|
||||
}
|
||||
|
||||
// camera facing.
|
||||
const vec3 Neye = vec3(0, 0, 1);
|
||||
|
||||
// compute ray for ray marching
|
||||
const vec3 rayDirectionEye = computeRayDirectionEye(inData.Peye);
|
||||
const vec3 rayStartEye = computeRayStartEye(inData.Peye, rayDirectionEye);
|
||||
|
||||
// Use z-value from depth buffer to compute length for ray marching
|
||||
const float opaqueZ = sampleZBuffer(gl_FragCoord.xy);
|
||||
const float rayLength = computeRayLength(
|
||||
rayStartEye, rayDirectionEye, inData.Peye, opaqueZ);
|
||||
|
||||
const VolumeContribution volumeContribution =
|
||||
volumeIntegrator(rayStartEye, rayDirectionEye, rayLength);
|
||||
const float alpha = 1 - volumeContribution.transmittance;
|
||||
const vec4 color = ApplyColorOverrides(vec4(volumeContribution.color, alpha));
|
||||
|
||||
const vec4 patchCoord = vec4(0.0);
|
||||
|
||||
RenderOutput(vec4(volumeContribution.firstHitPeye, 1),
|
||||
Neye, color, patchCoord);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"ShaderResources": "shaders"
|
||||
},
|
||||
"LibraryPath": "../../usd_hdx.dll",
|
||||
"Name": "hdx",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"ColorChannelFragment": {
|
||||
"source": [ "ColorChannel.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl ColorChannel.Fragment
|
||||
|
||||
|
||||
// Display channel values. These should match the the indices of the entries in
|
||||
// HdxDisplayChannelTokens
|
||||
#define CHANNEL_COLOR 0
|
||||
#define CHANNEL_RED 1
|
||||
#define CHANNEL_GREEN 2
|
||||
#define CHANNEL_BLUE 3
|
||||
#define CHANNEL_ALPHA 4
|
||||
#define CHANNEL_LUMINANCE 5
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
vec4 color = HdTexelFetch_colorIn(ivec2(fragCoord));
|
||||
|
||||
// Display Channel
|
||||
if (channel == CHANNEL_RED) {
|
||||
color.g = color.b = color.r;
|
||||
} else if (channel == CHANNEL_GREEN) {
|
||||
color.r = color.b = color.g;
|
||||
} else if (channel == CHANNEL_BLUE) {
|
||||
color.r = color.g = color.b;
|
||||
} else if (channel == CHANNEL_ALPHA) {
|
||||
color.r = color.g = color.b = color.a;
|
||||
} else if (channel == CHANNEL_LUMINANCE) {
|
||||
const vec3 W = vec3(0.30, 0.59, 0.11);
|
||||
color.r = color.g = color.b = dot(color.rgb, W);
|
||||
} // Do nothing if channel == CHANNEL_COLOR
|
||||
|
||||
hd_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"ColorCorrectionVertex": {
|
||||
"source": [ "ColorCorrection.Vertex" ]
|
||||
},
|
||||
"ColorCorrectionFragment": {
|
||||
"source": [ "ColorCorrection.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl ColorCorrection.Vertex
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = position;
|
||||
uvOut = uvIn;
|
||||
}
|
||||
|
||||
-- glsl ColorCorrection.Fragment
|
||||
|
||||
// Similar to D3DX_DXGIFormatConvert.inl, but branchless
|
||||
// https://www.shadertoy.com/view/wds3zM
|
||||
vec3 FloatToSRGB(vec3 val)
|
||||
{
|
||||
val = mix((val * 12.92),
|
||||
(1.055 * pow(val, vec3(1.0/2.4)) - 0.055),
|
||||
step(0.0031308, val));
|
||||
return val;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
vec4 inCol = HdTexelFetch_colorIn(ivec2(fragCoord));
|
||||
|
||||
#if defined(GLSLFX_USE_OCIO)
|
||||
inCol = OCIODisplay(inCol, Lut3DIn);
|
||||
#else
|
||||
// Only color, not alpha is gamma corrected!
|
||||
inCol.rgb = FloatToSRGB(inCol.rgb);
|
||||
#endif
|
||||
|
||||
hd_FragColor = inCol;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"FullscreenVertex": {
|
||||
"source": [ "Fullscreen.Vertex" ]
|
||||
},
|
||||
"CompositeFragmentNoDepth": {
|
||||
"source": [ "Composite.FragmentNoDepth" ]
|
||||
},
|
||||
"CompositeFragmentWithDepth": {
|
||||
"source": [ "Composite.FragmentWithDepth" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl Fullscreen.Vertex
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = position;
|
||||
uvOut = uvIn;
|
||||
}
|
||||
|
||||
-- glsl Composite.FragmentNoDepth
|
||||
|
||||
void main(void)
|
||||
{
|
||||
hd_FragColor = vec4(HdGet_colorIn(uvOut));
|
||||
}
|
||||
|
||||
-- glsl Composite.FragmentWithDepth
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float depth = HdGet_depth(uvOut).x;
|
||||
hd_FragColor = vec4(HdGet_colorIn(uvOut));
|
||||
hd_FragDepth = depth;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"fragmentShader": {
|
||||
"source": [ "OitResolve.Image" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl OitResolve.Image
|
||||
|
||||
vec4 imageShader(vec2 uv)
|
||||
{
|
||||
#if defined(HD_HAS_hdxOitDataBuffer)
|
||||
int screenWidth = int(HdGet_oitScreenSize().x);
|
||||
|
||||
// +1 because index 0 of counter buffer is reserved as atomic counter in
|
||||
// WriteOitLayersToBuffer
|
||||
int screenIndex = int(gl_FragCoord.x) + int(gl_FragCoord.y) * screenWidth;
|
||||
screenIndex += 1;
|
||||
|
||||
int nodeIndex = hdxOitCounterBuffer[screenIndex];
|
||||
int numDepths = 0;
|
||||
|
||||
// XXX renderPass.WriteOitLayersToBuffer does not clamp the number of
|
||||
// depth samples we store for a pixel. Here we process no more than
|
||||
// 'maxSamples' for a pixel. (If there are greater than 'maxSamples'
|
||||
// samples stored for this pixel some will currently not contribute)
|
||||
const int maxSamples = 8;
|
||||
vec4 sortedColor[maxSamples];
|
||||
float sortedDepth[maxSamples];
|
||||
|
||||
while (nodeIndex != -1 &&
|
||||
numDepths < maxSamples &&
|
||||
nodeIndex < hdxOitDataBuffer.length())
|
||||
{
|
||||
float currentDepth = hdxOitDepthBuffer[nodeIndex];
|
||||
int insertIndex = numDepths;
|
||||
// Recall that depths are in eye space, so inequality is flipped.
|
||||
while (insertIndex > 0 && sortedDepth[insertIndex - 1] < currentDepth) {
|
||||
sortedDepth[insertIndex] = sortedDepth[insertIndex - 1];
|
||||
sortedColor[insertIndex] = sortedColor[insertIndex - 1];
|
||||
insertIndex -= 1;
|
||||
}
|
||||
sortedColor[insertIndex] = hdxOitDataBuffer[nodeIndex];
|
||||
sortedDepth[insertIndex] = hdxOitDepthBuffer[nodeIndex];
|
||||
numDepths += 1;
|
||||
nodeIndex = hdxOitIndexBuffer[nodeIndex];
|
||||
}
|
||||
|
||||
// Assume color in sortedColor is pre-multiplied by alpha
|
||||
int depth = 0;
|
||||
vec4 colorAccum = vec4(0);
|
||||
while (depth < numDepths) {
|
||||
colorAccum += sortedColor[depth] * (1 - colorAccum.a);
|
||||
|
||||
if (colorAccum.a >= 1.0) break;
|
||||
|
||||
depth += 1;
|
||||
}
|
||||
|
||||
colorAccum = clamp(colorAccum, vec4(0), vec4(1));
|
||||
return colorAccum;
|
||||
#else
|
||||
return vec4(0);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"OutlineFragment": {
|
||||
"source": [ "Outline.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl Outline.Fragment
|
||||
|
||||
#define EPSILON 0.0001
|
||||
#define LARGE 100000
|
||||
|
||||
// The color texture with the highlighted areas.
|
||||
|
||||
// Given a delta x and y in relation to the current texel coordinates, check if
|
||||
// the colorIn texture has a non-black texel and its distance^2 to the current
|
||||
// texel is smaller than the one passed as dist2. The color of that texel will
|
||||
// be returned in the color output var.
|
||||
void testTexel(int x, int y, REF(thread,float) dist2, REF(thread,vec4) color)
|
||||
{
|
||||
vec2 texCoords = uvOut + vec2(x, y) * texelSize;
|
||||
vec4 c = HdGet_colorIn(texCoords);
|
||||
|
||||
if ( c.r > EPSILON || c.g > EPSILON || c.b > EPSILON) {
|
||||
float d = float(x * x + y * y );
|
||||
if (d < dist2) {
|
||||
dist2 = d;
|
||||
color = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Used by testOctants() to scan each horizontal line in the circle.
|
||||
// Returns the distance^2 and color of the non-black texel that is closest to
|
||||
// the current texel.
|
||||
void testHLine(int x0, int x1, int y, REF(thread,float) dist2, REF(thread,vec4) color) {
|
||||
for (int x = x0; x < x1; x++) {
|
||||
testTexel(x, y, dist2, color);
|
||||
}
|
||||
}
|
||||
|
||||
// Part of the Bresenham algorithm: mirror the circle octant edge coords to
|
||||
// obtain a half circle and then mirror them horizontally to obtain the
|
||||
// horizontal lines that define the circle and its interior.
|
||||
// Returns the distance^2 and color of the non-black texel that is closest to
|
||||
// the current texel.
|
||||
void testOctants(int x, int y, REF(thread,float) dist2, REF(thread,vec4) color) {
|
||||
testHLine(-x, x, y, dist2, color);
|
||||
testHLine(-x, x, -y, dist2, color);
|
||||
testHLine(-y, y, x, dist2, color);
|
||||
testHLine(-y, y, -x, dist2, color);
|
||||
}
|
||||
|
||||
// Find the color and distance^2 to the closest texel in colorIn that is not
|
||||
// black and that is within a circle defined by the specified radius, centered
|
||||
// in the current texel. (Note: distance^2 is used to avoid sqrt).
|
||||
// This uses the Bresenham circle algorithm to discover the texels inside that
|
||||
// circle, to avoid having to read the colorIn texels outside of it.
|
||||
void testCircle(int r, REF(thread,float) dist2, REF(thread,vec4) color) {
|
||||
if (r < 0) { r = 0; }
|
||||
|
||||
int d = 3 - (2 * r);
|
||||
int x = 0;
|
||||
int y = r;
|
||||
|
||||
testOctants(x, y, dist2, color);
|
||||
|
||||
while (x < y) {
|
||||
x++;
|
||||
|
||||
if (d > 0) {
|
||||
y--;
|
||||
d = d + 4 * (x - y) + 10;
|
||||
} else {
|
||||
d = d + 4 * x + 6;
|
||||
}
|
||||
|
||||
testOctants(x, y, dist2, color);
|
||||
}
|
||||
}
|
||||
|
||||
// If radius is 0 then render colorIn as is. If radius > 0 then render only the
|
||||
// outline of the non-black areas in colorIn. The radius will define the
|
||||
// thickness of the outline. The color of each texel in the outline will be
|
||||
// defined by the closest color in colorIn, fading out when the distance to that
|
||||
// colorIn texel equals the radius. This will allow colorIn to potentially hold
|
||||
// several colors that will be respected by the outline.
|
||||
|
||||
void main()
|
||||
{
|
||||
hd_FragColor = vec4(0, 0, 0, 1);
|
||||
// Check if the current texel is not black - meaning that we are inside an
|
||||
// area of colorId that has been highlighted.
|
||||
vec4 color = HdGet_colorIn(uvOut);
|
||||
bool isInside = color.r > EPSILON || color.g > EPSILON || color.b > EPSILON;
|
||||
|
||||
if (enableOutline==0) {
|
||||
if (isInside) {
|
||||
// Inside the highlighted areas in colorIn : render colorIn.
|
||||
hd_FragColor = color;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!isInside) {
|
||||
// Outside the highlighted area: render the outline
|
||||
float r2 = float(radius * radius);
|
||||
float dist2 = LARGE;
|
||||
|
||||
// Check if there are any highlighted texels around the current one
|
||||
// inside the specified radius.
|
||||
testCircle(radius, dist2, color);
|
||||
|
||||
// Check if the distance^2 to the closest highlighted texel is within
|
||||
// radius^2.
|
||||
if (dist2 <= r2) {
|
||||
// Attenuate the texel color using the distance^2 to it.
|
||||
float factor = (r2 - dist2 ) / r2;
|
||||
factor *= factor;
|
||||
|
||||
hd_FragColor = color * factor;
|
||||
hd_FragColor.a = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
|
||||
-- glsl HdxRenderPass.RenderOitOpaquePixels
|
||||
|
||||
layout (location = 0) out vec4 colorOut;
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
if (color.a >= 1.0) {
|
||||
colorOut = vec4(color.rgb, 1);
|
||||
} else {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl HdxRenderPass.WriteOitLayersToBufferCommon
|
||||
|
||||
layout (early_fragment_tests) in;
|
||||
|
||||
void RenderOutputImpl(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
#if defined(HD_HAS_hdxOitDataBuffer)
|
||||
|
||||
int screenWidth = int(HdGet_oitScreenSize().x);
|
||||
|
||||
// +1 because the counter buffer is cleared with -1, but we want the
|
||||
// first index to start at 0.
|
||||
int writeIndex = atomicAdd(hdxOitCounterBuffer[0], 1) + 1;
|
||||
|
||||
if (writeIndex < hdxOitDataBuffer.length()) {
|
||||
int screenIndex =
|
||||
int(gl_FragCoord.x) + int(gl_FragCoord.y) * screenWidth;
|
||||
|
||||
if (screenIndex < hdxOitCounterBuffer.length()) {
|
||||
int prevIndex =
|
||||
atomicExchange(hdxOitCounterBuffer[screenIndex+1], writeIndex);
|
||||
hdxOitDataBuffer[writeIndex] = color;
|
||||
|
||||
// Note that we have a choice here to either pick gl_FragCoord.z or
|
||||
// the depth value from Peye. The former is obtained by applying
|
||||
// the perspective transform and cannot be changed by a shader.
|
||||
//
|
||||
// We pick Peye here so that a shader has an opportunity to change
|
||||
// the depth of the sample inserted into the OIT list.
|
||||
//
|
||||
// This is used by volumes. However, non-volume translucent
|
||||
// geometry should never modify Peye value and call RenderOutput
|
||||
// with the Peye value from the vertex shader so that it is
|
||||
// consistent with gl_FragCoord. This is because such geometry is
|
||||
// subject to a opaque pixel render pass performing a z-test
|
||||
// against gl_FragCoord.z.
|
||||
//
|
||||
// Note there are implications of using the depth value from Peye
|
||||
// instead of gl_FragCoord.z here for the subsequent OIT resolve
|
||||
// shader: the depth sorting order needs to be flipped and the
|
||||
// OIT resolve shader cannot compare depths in the OIT list
|
||||
// against the depth buffer unless it takes the perspective
|
||||
// transform into account.
|
||||
hdxOitDepthBuffer[writeIndex] = Peye.z / Peye.w;
|
||||
hdxOitIndexBuffer[writeIndex] = prevIndex;
|
||||
}
|
||||
} else {
|
||||
// We may overrun the counter buffer integer and wrap back to 0 if
|
||||
// we have a lot of OIT samples.
|
||||
atomicAdd(hdxOitCounterBuffer[0], -1);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
-- glsl HdxRenderPass.WriteOitLayersToBufferTranslucent
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
// There are two render passes for ordinary OIT geometry.
|
||||
// Fragments with alpha >= 1.0 are handled in the first (opaque)
|
||||
// render pass.
|
||||
if (color.a < 1.0 && color.a > 0.0001) {
|
||||
RenderOutputImpl(Peye, Neye, color, patchCoord);
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl HdxRenderPass.WriteOitLayersToBufferVolume
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
// Unlike ordinary OIT geometry, volumes have only one render pass,
|
||||
// so insert into OIT buffers even if alpha is 1.
|
||||
if (any(greaterThan(color, vec4(0.0001)))) {
|
||||
RenderOutputImpl(Peye, Neye, color, patchCoord);
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl HdxRenderPass.RenderPick
|
||||
|
||||
layout (location = 0) out vec4 primIdOut;
|
||||
layout (location = 1) out vec4 instanceIdOut;
|
||||
layout (location = 2) out vec4 elementIdOut;
|
||||
layout (location = 3) out vec4 edgeIdOut;
|
||||
layout (location = 4) out vec4 pointIdOut;
|
||||
layout (location = 5) out vec4 neyeOut;
|
||||
|
||||
vec4 IntToVec4(int id)
|
||||
{
|
||||
return vec4(((id >> 0) & 0xff) / 255.0,
|
||||
((id >> 8) & 0xff) / 255.0,
|
||||
((id >> 16) & 0xff) / 255.0,
|
||||
((id >> 24) & 0xff) / 255.0);
|
||||
}
|
||||
|
||||
// Fwd declare necessary methods to determine the subprim id of a fragment.
|
||||
int GetElementID(); // generated via codeGen
|
||||
int GetPrimitiveEdgeId(); // defined in edgeId.glslfx, or generated via codeGen
|
||||
int GetPointId(); // defined in pointId.glslfx
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
int primId = HdGet_primID();
|
||||
primIdOut = IntToVec4(primId);
|
||||
|
||||
// instanceIndex is a tuple of integers (num nested levels).
|
||||
// for picking, we store global instanceId (instanceIndex[0]) in the
|
||||
// selection framebuffer and then reconstruct the tuple in postprocess.
|
||||
int instanceId = GetDrawingCoord().instanceIndex[0];
|
||||
instanceIdOut = IntToVec4(instanceId);
|
||||
|
||||
elementIdOut = IntToVec4(GetElementID());
|
||||
edgeIdOut = IntToVec4(GetPrimitiveEdgeId());
|
||||
pointIdOut = IntToVec4(GetPointId());
|
||||
|
||||
neyeOut = IntToVec4(hd_vec4_2_10_10_10_set(vec4(Neye,0)));
|
||||
}
|
||||
|
||||
-- glsl HdxRenderPass.RenderColorAndSelection
|
||||
// Note: This mixin expects color and selected color attachments in the bound
|
||||
// FBO. It writes out the computed fragment color and whether it is selected
|
||||
// (as a float, so, 1.0 or 0.0).
|
||||
|
||||
bool IsSelected(); // defined in selection.glslfx
|
||||
|
||||
layout (location = 0) out vec4 colorOut;
|
||||
layout (location = 1) out float selectedOut;
|
||||
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
colorOut = color;
|
||||
selectedOut = float(IsSelected());
|
||||
}
|
||||
|
||||
-- glsl HdxRenderPass.RenderColorWithOccludedSelection
|
||||
// Note: This mixin expects color and selected color attachments in the bound
|
||||
// FBO. The alpha component of the computed fragment color is adjusted to blend
|
||||
// the existing (destination) fragment color if it is selected.
|
||||
|
||||
bool
|
||||
HasOccludedSelection(vec2 fragcoord)
|
||||
{
|
||||
#ifdef HD_HAS_selectedReadback
|
||||
const float isSelected = texelFetch(HdGetSampler_selectedReadback(),
|
||||
ivec2(fragcoord),
|
||||
0).x;
|
||||
return bool(isSelected);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
float
|
||||
GetShowThroughOpacity()
|
||||
{
|
||||
#ifdef HD_HAS_occludedSelectionOpacity
|
||||
// Note: occludedSelectionOpacity flows in as a parameter to the selection
|
||||
// setup task (HdxSelectionTask)
|
||||
const float dstOpacity = HdGet_occludedSelectionOpacity();
|
||||
// adjust source alpha used to blend source and dst colors.
|
||||
return 1.0 - dstOpacity;
|
||||
#else
|
||||
return 0.5;
|
||||
#endif
|
||||
}
|
||||
|
||||
layout (location = 0) out vec4 colorOut;
|
||||
|
||||
// Input AOV textures are provided by the task.
|
||||
void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
if (HasOccludedSelection(gl_FragCoord.xy)) {
|
||||
color.a = GetShowThroughOpacity();
|
||||
}
|
||||
|
||||
colorOut = color;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassShader.glslfx
|
||||
// Render pass shader configuration that writes color and selection information
|
||||
// (whether the fragment is selected).
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"Selection.Fragment",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.RenderColorAndSelection" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"RenderPass.RenderColor" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassShader.glslfx
|
||||
// Render pass shader configuration that writes color and selection information
|
||||
// (whether the fragment is selected).
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.RenderColorWithOccludedSelection" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassIdShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"RenderPass.NoSelection",
|
||||
"RenderPass.NoColorOverrides",
|
||||
"RenderPass.RenderId" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassOitShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.RenderOitOpaquePixels" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassOitShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.WriteOitLayersToBufferCommon",
|
||||
"HdxRenderPass.WriteOitLayersToBufferTranslucent" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassOitShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"Selection.DecodeUtils",
|
||||
"Selection.ComputeColor",
|
||||
"RenderPass.ApplyColorOverrides",
|
||||
"HdxRenderPass.WriteOitLayersToBufferCommon",
|
||||
"HdxRenderPass.WriteOitLayersToBufferVolume" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassPickingShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"RenderPass.NoSelection",
|
||||
"RenderPass.NoColorOverrides",
|
||||
"HdxRenderPass.RenderPick" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/renderPassIdShader.glslfx
|
||||
|
||||
#import $TOOLS/hdSt/shaders/renderPass.glslfx
|
||||
#import $TOOLS/hdx/shaders/renderPass.glslfx
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"vertexShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessControlShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"tessEvalShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"geometryShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ApplyClipPlanes" ]
|
||||
},
|
||||
"fragmentShader" : {
|
||||
"source": [ "RenderPass.Camera",
|
||||
"RenderPass.ShouldCullFace",
|
||||
"RenderPass.NoSelection",
|
||||
"RenderPass.NoColorOverrides",
|
||||
"RenderPass.RenderColor" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,509 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
--- This is what an import might look like.
|
||||
--- #import $TOOLS/hdx/shaders/selection.glslfx
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.DecodeUtils
|
||||
/// Decoding utilities for selection highlighting.
|
||||
/// This mixin may be safely included by any shader stage. Its lone dependency
|
||||
/// on code generation is the hdxSelectionBuffer SSBO that holds the encoded
|
||||
/// selection state.
|
||||
|
||||
// This should match the HdSelection enum.
|
||||
int GetMaxNumSelectionHighlightModes()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
// helper methods to decode hdxSelectionBuffer
|
||||
// ------ selection highlight mode specifics -------
|
||||
bool HighlightModeHasSelection(int offset)
|
||||
{
|
||||
return (offset != 0);
|
||||
}
|
||||
|
||||
int GetIndexOffsetForHighlightMode(int mode)
|
||||
{
|
||||
return HdGet_hdxSelectionBuffer(mode + 1/*[0] holds #modes*/);
|
||||
}
|
||||
|
||||
int GetNumSelectionHighlightModes()
|
||||
{
|
||||
return HdGet_hdxSelectionBuffer(0);
|
||||
}
|
||||
|
||||
// ------ selection offset specifics -------
|
||||
// Note: This should match the selection offset encoding in
|
||||
// hdx/SelectionTracker.cpp
|
||||
void DecodeSelOffset(int selOffset, out bool isSelected, out int nextOffset)
|
||||
{
|
||||
isSelected = bool(selOffset & 0x1); // bit 0
|
||||
nextOffset = selOffset >> 1; // bits 31:1
|
||||
}
|
||||
|
||||
// --------- subprim decoding ----------
|
||||
// Each subprims offsets' buffer encoding is:
|
||||
// [subprim-type][min][max][ selOffsets ]
|
||||
// <----------3 ----------><--- max - min + 1 -->
|
||||
struct SubprimHeader {
|
||||
int type;
|
||||
int min;
|
||||
int max;
|
||||
};
|
||||
SubprimHeader DecodeSubprimHeader(int offset)
|
||||
{
|
||||
SubprimHeader header;
|
||||
header.type = HdGet_hdxSelectionBuffer(offset );
|
||||
header.min = HdGet_hdxSelectionBuffer(offset + 1);
|
||||
header.max = HdGet_hdxSelectionBuffer(offset + 2);
|
||||
return header;
|
||||
}
|
||||
|
||||
bool IsSubprimSelected(int id, int min, int max, int headerStart,
|
||||
out int nextSubprimOffset)
|
||||
{
|
||||
const int SUBPRIM_SELOFFSETS_HEADER_SIZE = 3;
|
||||
|
||||
nextSubprimOffset = 0; // initialize
|
||||
bool isSelected = false;
|
||||
|
||||
if (id >= min && id < max) {
|
||||
int netSubprimIndex =
|
||||
headerStart + SUBPRIM_SELOFFSETS_HEADER_SIZE + id - min;
|
||||
int selOffset = HdGet_hdxSelectionBuffer(netSubprimIndex);
|
||||
|
||||
DecodeSelOffset(selOffset, /*out*/isSelected, /*out*/nextSubprimOffset);
|
||||
} else {
|
||||
// The subprim id does not fall in the selected id range, so the subprim
|
||||
// in question isn't selected. However, we can still have other
|
||||
// subprim(s) selected. To get the offset to jump to, we mimic decoding
|
||||
// the "min" subprim id.
|
||||
int minSubprimIndex = headerStart + SUBPRIM_SELOFFSETS_HEADER_SIZE;
|
||||
DecodeSelOffset(HdGet_hdxSelectionBuffer(minSubprimIndex),
|
||||
/*out*/isSelected, /*out*/nextSubprimOffset);
|
||||
isSelected = false;
|
||||
}
|
||||
|
||||
return isSelected;
|
||||
}
|
||||
#endif // HD_HAS_hdxSelectionBuffer
|
||||
|
||||
// Keep the result struct definition outside guards.
|
||||
struct SubprimSelectionResult {
|
||||
bool elementSelected;
|
||||
bool edgeSelected;
|
||||
bool pointSelected;
|
||||
int pointColorId;
|
||||
};
|
||||
bool IsAnySubprimSelected(SubprimSelectionResult s)
|
||||
{
|
||||
return (s.elementSelected || s.edgeSelected || s.pointSelected);
|
||||
}
|
||||
bool HasCustomizedPointColor(SubprimSelectionResult s)
|
||||
{
|
||||
// Use -1 to encode selected points that don't have a custom point color.
|
||||
return (s.pointColorId != -1);
|
||||
}
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
// Note: These should match the SubprimType enum in hdx/SelectionTracker.cpp
|
||||
#define SUBPRIM_TYPE_ELEMENT 0
|
||||
#define SUBPRIM_TYPE_EDGE 1
|
||||
#define SUBPRIM_TYPE_POINT 2
|
||||
#define SUBPRIM_TYPE_INSTANCE 3
|
||||
|
||||
SubprimSelectionResult GetSubprimSel(int offset,
|
||||
int elementId, int edgeId, int pointId)
|
||||
{
|
||||
SubprimSelectionResult s = SubprimSelectionResult(false, false, false, 0);
|
||||
int nextSubprimOffset = 0;
|
||||
SubprimHeader header = DecodeSubprimHeader(offset);
|
||||
|
||||
if (header.type == SUBPRIM_TYPE_ELEMENT) {
|
||||
s.elementSelected =
|
||||
IsSubprimSelected(elementId, header.min, header.max,
|
||||
offset, /*out*/nextSubprimOffset);
|
||||
|
||||
if (nextSubprimOffset != 0) {
|
||||
// fragment has additional subprim(s) selected. update header.
|
||||
header = DecodeSubprimHeader(nextSubprimOffset);
|
||||
offset = nextSubprimOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (header.type == SUBPRIM_TYPE_EDGE) {
|
||||
s.edgeSelected =
|
||||
IsSubprimSelected(edgeId, header.min, header.max,
|
||||
offset, /*out*/nextSubprimOffset);
|
||||
|
||||
if (nextSubprimOffset != 0) {
|
||||
// fragment has points selected. update header.
|
||||
header = DecodeSubprimHeader(nextSubprimOffset);
|
||||
offset = nextSubprimOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (header.type == SUBPRIM_TYPE_POINT) {
|
||||
s.pointSelected =
|
||||
IsSubprimSelected(pointId, header.min, header.max,
|
||||
offset, /*unused*/nextSubprimOffset);
|
||||
// For points alone, since there isn't any subprim to follow it, the
|
||||
// offset field is overriden to represent the index into the
|
||||
// selectedPointColors buffer to support customized coloring of a set of
|
||||
// selected points.
|
||||
s.pointColorId = nextSubprimOffset;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// --------- instance decoding ----------
|
||||
bool IsInstanceSelected(int offset, out int nextOffset)
|
||||
{
|
||||
// If we don't find an instance subprim block, pass the same offset to
|
||||
// GetSubprimSel.
|
||||
nextOffset = offset;
|
||||
bool sel = false;
|
||||
|
||||
int instanceId = GetDrawingCoord().instanceIndex[0];
|
||||
|
||||
SubprimHeader header = DecodeSubprimHeader(offset);
|
||||
if (header.type == SUBPRIM_TYPE_INSTANCE) {
|
||||
sel =
|
||||
IsSubprimSelected(instanceId, header.min, header.max,
|
||||
offset, /*out*/nextOffset);
|
||||
}
|
||||
|
||||
return sel;
|
||||
}
|
||||
#endif // HD_HAS_hdxSelectionBuffer
|
||||
|
||||
// --------- selection buffer decoding entry point ----------
|
||||
struct SelectionResult {
|
||||
bool primOrInstanceSel;
|
||||
SubprimSelectionResult subprimSel;
|
||||
};
|
||||
// Decodes the selection buffer encoding scheme for a given mode, and returns
|
||||
// the selection result.
|
||||
SelectionResult GetSelectionResult(int mode,
|
||||
int elementId, int edgeId, int pointId)
|
||||
{
|
||||
SelectionResult res =
|
||||
SelectionResult(false, SubprimSelectionResult(false, false, false, 0));
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
// The hdxSelectionBuffer layout is:
|
||||
// [#modes] [per-mode offset] [data mode0] ... [data modeM]
|
||||
// [---------header---------]
|
||||
// Each mode's data is laid out as:
|
||||
// [ prims | points | edges | elements | instance level-N | ... | level 0 ]
|
||||
// <-------- subprims -------> <----------- instances --------->
|
||||
// <---------------------- per prim ---------------------------->
|
||||
// See hdx/SelectionTracker.cpp for details on the encoding scheme.
|
||||
int modeOffset = GetIndexOffsetForHighlightMode(mode);
|
||||
if (!HighlightModeHasSelection(modeOffset)) {
|
||||
// highlight mode has no selected objects (prims/instances/elements)
|
||||
return res;
|
||||
}
|
||||
|
||||
const int PRIM_SELOFFSETS_HEADER_SIZE = 2;
|
||||
const int primId = HdGet_primID();
|
||||
int smin = HdGet_hdxSelectionBuffer(modeOffset);
|
||||
int smax = HdGet_hdxSelectionBuffer(modeOffset + 1);
|
||||
|
||||
if (primId >= smin && primId < smax) {
|
||||
int offset = modeOffset + PRIM_SELOFFSETS_HEADER_SIZE + primId - smin;
|
||||
int nextOffset = 0;
|
||||
bool sel = false;
|
||||
DecodeSelOffset(HdGet_hdxSelectionBuffer(offset),
|
||||
/*out*/sel, /*out*/nextOffset);
|
||||
|
||||
// At this point, sel indicates whether the fragment corresponds to
|
||||
// a prim that needs to be fully highlighted, while a non-zero
|
||||
// nextOffset indicates whether additional decoding may be done.
|
||||
|
||||
// We don't currently differentiate between prim, instance and
|
||||
// subprim selection highlighting (i.e., visually, they look the
|
||||
// same), and thus can skip additional decoding if sel is true.
|
||||
// We choose not to, for ease of future customization.
|
||||
if (nextOffset != 0) {
|
||||
// check if instance (or) subprim(s) are selected
|
||||
offset = nextOffset;
|
||||
sel = sel || IsInstanceSelected(offset, /*out*/nextOffset);
|
||||
|
||||
if (nextOffset != 0) {
|
||||
res.subprimSel =
|
||||
GetSubprimSel(nextOffset, elementId, edgeId, pointId);
|
||||
}
|
||||
}
|
||||
res.primOrInstanceSel = sel;
|
||||
}
|
||||
#endif // HD_HAS_hdxSelectionBuffer
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// Returns the logical OR of the inputs
|
||||
SelectionResult
|
||||
_CombineWithOr(SelectionResult a, SelectionResult b)
|
||||
{
|
||||
SelectionResult res =
|
||||
SelectionResult(false, SubprimSelectionResult(false, false, false, 0));
|
||||
|
||||
res.primOrInstanceSel = a.primOrInstanceSel || b.primOrInstanceSel;
|
||||
res.subprimSel.elementSelected = a.subprimSel.elementSelected ||
|
||||
b.subprimSel.elementSelected;
|
||||
res.subprimSel.edgeSelected = a.subprimSel.edgeSelected ||
|
||||
b.subprimSel.edgeSelected;
|
||||
res.subprimSel.pointSelected = a.subprimSel.pointSelected ||
|
||||
b.subprimSel.pointSelected;
|
||||
// pointColorIndex is ignored.
|
||||
return res;
|
||||
}
|
||||
|
||||
// Returns the net selection result aggregating the result of each selection
|
||||
// mode.
|
||||
SelectionResult GetNetSelectionResult(int elementId, int edgeId, int pointId)
|
||||
{
|
||||
SelectionResult netResult =
|
||||
SelectionResult(false, SubprimSelectionResult(false, false, false, 0));
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
const int numSelectionModes = GetNumSelectionHighlightModes();
|
||||
for (int mode = 0; mode < numSelectionModes; mode++) {
|
||||
SelectionResult modeResult =
|
||||
GetSelectionResult(mode, elementId, edgeId, pointId);
|
||||
netResult = _CombineWithOr(modeResult, netResult);
|
||||
}
|
||||
#endif
|
||||
return netResult;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Vertex.PointSel
|
||||
// Mixin for use in the vertex shader stage.
|
||||
// Decodes the selection buffer to find out if the current vertex (point) is
|
||||
// selected. This is called from hdSt/shaders/pointId.glslfx
|
||||
bool IsPointSelected(int pointId)
|
||||
{
|
||||
bool sel = false;
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
const int numSelectionModes = GetNumSelectionHighlightModes();
|
||||
for (int mode = 0; mode < numSelectionModes; mode++) {
|
||||
// At the VS stage, we don't carry enough state to determine the
|
||||
// elementId and edgeId. So, use fallback values instead.
|
||||
SelectionResult res =
|
||||
GetSelectionResult(mode, /*elementId*/-1, /*edgeId*/-1, pointId);
|
||||
if (res.subprimSel.pointSelected &&
|
||||
!HasCustomizedPointColor(res.subprimSel)) {
|
||||
sel = true;
|
||||
break;
|
||||
}
|
||||
} // for each highlight mode
|
||||
#endif
|
||||
return sel;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Geometry.ElementSel
|
||||
// Mixin for use in the geometry shader stage.
|
||||
// Helper functions to determine if the element (face) is selected for either
|
||||
// a given selection mode, or any of the modes.
|
||||
|
||||
int GetElementID(); // code gen
|
||||
|
||||
bool IsElementSelected(int mode)
|
||||
{
|
||||
bool sel = false;
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
const int numSelectionModes = GetNumSelectionHighlightModes();
|
||||
if (mode < numSelectionModes) {
|
||||
SelectionResult res =
|
||||
GetSelectionResult(mode, GetElementID(),
|
||||
/*edgeId*/-1, /*pointId*/-1);
|
||||
if (res.subprimSel.elementSelected) {
|
||||
sel = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return sel;
|
||||
}
|
||||
|
||||
bool IsSelected()
|
||||
{
|
||||
// Edge and point selection aren't relevant at the GS stage.
|
||||
SelectionResult res = GetNetSelectionResult(
|
||||
GetElementID(), /*edgeId*/-1, /*pointId*/-1);
|
||||
|
||||
return res.primOrInstanceSel || res.subprimSel.elementSelected;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Geometry.WireSelOffset
|
||||
// Mixin for use in the geometry shader stage for wireframe rendering.
|
||||
// See comment below.
|
||||
|
||||
int GetMaxNumSelectionHighlightModes();
|
||||
bool IsElementSelected(int mode);
|
||||
int GetElementID(); // code gen
|
||||
|
||||
vec4 ComputeSelectionOffset()
|
||||
{
|
||||
// For wireframe, we only render the edges of faces. Because we don't have
|
||||
// a way to control which face gets rasterized first, if face A is selected
|
||||
// and face B is unselected, it's possible for face B to draw over face A
|
||||
// and for the highlight to be dropped.
|
||||
|
||||
// To compensate for this, since we're running the geometry shader anyway,
|
||||
// add a small polygon offset for selected faces, to push them in front of
|
||||
// unselected faces.
|
||||
|
||||
// For doubly-selected faces (e.g. rollover & selection), apply a double
|
||||
// offset. The code below chooses a unique offset for each combination
|
||||
// of selection modes by constructing a bitmask of selection modes for
|
||||
// this face, and reinterpreting it as an integer.
|
||||
|
||||
int offset = 0;
|
||||
|
||||
int numModes = GetMaxNumSelectionHighlightModes();
|
||||
for (int mode = 0; mode < numModes; ++mode) {
|
||||
if (IsElementSelected(mode)) {
|
||||
offset += (1 << mode);
|
||||
}
|
||||
}
|
||||
|
||||
// Note: for our base epsilon, we're choosing this somewhat arbitrarily.
|
||||
// This is an eye space epsilon, so it's not dependent on distance-from-
|
||||
// camera. Rather, it's dependent on scene scale. 1e-3 works well for
|
||||
// our scenes, but if this causes trouble we could use an epsilon based on
|
||||
// the eye-space distance of a z-buffer bit flip, which would match the
|
||||
// behavior of glPolygonOffset better, at the cost of more math and some
|
||||
// extra shader uniforms.
|
||||
float eps = 1e-3;
|
||||
|
||||
return vec4(0, 0, offset * eps, 0);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Geometry.WireSelNoOffset
|
||||
|
||||
vec4 ComputeSelectionOffset()
|
||||
{
|
||||
return vec4(0);
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.Fragment
|
||||
// Mixin for use in the fragment shader stage to determine if the fragment is
|
||||
// selected.
|
||||
|
||||
int GetElementID(); // generated via codeGen
|
||||
int GetPrimitiveEdgeId(); // defined in edgeId.glslfx, or generated via codeGen
|
||||
int GetPointId(); // defined in pointId.glslfx
|
||||
|
||||
bool IsSelected()
|
||||
{
|
||||
SelectionResult res = GetNetSelectionResult(
|
||||
GetElementID(), GetPrimitiveEdgeId(), GetPointId());
|
||||
|
||||
return res.primOrInstanceSel || res.subprimSel.elementSelected;
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Selection.ComputeColor
|
||||
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
vec4 GetSelectionColor(int mode)
|
||||
{
|
||||
vec4 s = vec4(0,0,0,0);
|
||||
// XXX: Make selection colors an array so we can avoid the branching.
|
||||
if (mode == 0)
|
||||
s = HdGet_selColor();
|
||||
else if (mode == 1)
|
||||
s = HdGet_selLocateColor();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// fwd decl fn defined in edgeId.glslfx or generated via codeGen
|
||||
float GetSelectedEdgeOpacity();
|
||||
|
||||
vec4 GetSubprimSelectionColor(int mode, SubprimSelectionResult res)
|
||||
{
|
||||
vec4 s = GetSelectionColor(mode);
|
||||
if (res.edgeSelected) {
|
||||
s.a = GetSelectedEdgeOpacity();
|
||||
}
|
||||
if (res.pointSelected && HasCustomizedPointColor(res)) {
|
||||
#if defined(HD_HAS_selectionPointColors)
|
||||
s = HdGet_selectionPointColors(res.pointColorId);
|
||||
#endif
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Fwd declare necessary methods to determine the subprim id of a fragment.
|
||||
int GetElementID(); // generated via codeGen
|
||||
int GetPrimitiveEdgeId(); // defined in edgeId.glslfx, or generated via codeGen
|
||||
int GetPointId(); // defined in pointId.glslfx
|
||||
|
||||
// Decodes the selection buffer to find out if the current fragment is from
|
||||
// a prim/instance/subprim that is selected, applies selection highlighting to
|
||||
// the incoming color, and returns the resulting color.
|
||||
vec4 ApplySelectionColor(vec4 color)
|
||||
{
|
||||
#if defined(HD_HAS_hdxSelectionBuffer)
|
||||
int elementId = GetElementID();
|
||||
int edgeId = GetPrimitiveEdgeId();
|
||||
int pointId = GetPointId();
|
||||
|
||||
const int numSelectionModes = GetNumSelectionHighlightModes();
|
||||
|
||||
bool isSelected = false;
|
||||
for (int mode = 0; mode < numSelectionModes; mode++) {
|
||||
SelectionResult res =
|
||||
GetSelectionResult(mode, elementId, edgeId, pointId);
|
||||
|
||||
if (res.primOrInstanceSel) {
|
||||
isSelected = true;
|
||||
vec4 s = GetSelectionColor(mode);
|
||||
color.rgb = mix(color.rgb, s.rgb, s.a);
|
||||
}
|
||||
if (IsAnySubprimSelected(res.subprimSel)) {
|
||||
isSelected = true;
|
||||
vec4 ss = GetSubprimSelectionColor(mode, res.subprimSel);
|
||||
color.rgb = mix(color.rgb, ss.rgb, ss.a);
|
||||
}
|
||||
} // for each highlight mode
|
||||
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2021 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"SkydomeFragment": {
|
||||
"source": [ "Skydome.Fragment" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl Skydome.Fragment
|
||||
|
||||
const float PI = 3.1415926535898;
|
||||
const float farPlane = 1.0;
|
||||
|
||||
float wrapSampleValue(float value)
|
||||
{
|
||||
if (value < 0.0) {
|
||||
value += 1.0;
|
||||
}
|
||||
else if (value > 1.0) {
|
||||
value -= 1.0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// from PreviewSurface.glslfx
|
||||
vec2 projectToLatLong(vec3 sample3D)
|
||||
{
|
||||
// project spherical coord onto latitude-longitude map with
|
||||
// latitude: +y == pi/2 and longitude: +z == 0, +x == pi/2
|
||||
float x = (atan(sample3D.z, sample3D.x) + 0.5 * PI) / (2.0 * PI);
|
||||
float y = acos(sample3D.y) / PI;
|
||||
|
||||
return vec2(wrapSampleValue(x), wrapSampleValue(y));
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Transform the UV coordinates into NDC space and place at the far plane
|
||||
// (z = 1) before transforming into view space.
|
||||
vec2 uvOut_ndc = (uvOut * vec2(2.0)) - vec2(1.0);
|
||||
vec4 uvOut_view = invProjMatrix * vec4(uvOut_ndc, farPlane, 1.0);
|
||||
|
||||
// Normalize to use as the initial sampleDirection
|
||||
vec3 sampleDirection = normalize(uvOut_view.xyz);
|
||||
|
||||
// Apply the camera rotation and lightTransform to the sampleDirection
|
||||
sampleDirection =
|
||||
( lightTransform * viewToWorld * vec4(sampleDirection, 0.0) ).xyz;
|
||||
|
||||
// Sample Skydome Texture with the sampleDirection
|
||||
vec2 sampleCoord = projectToLatLong(sampleDirection);
|
||||
hd_FragColor = vec4(HdGet_skydomeTexture(sampleCoord).xyz, 0.0);
|
||||
gl_FragDepth = farPlane;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2021 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"VisualizeVertex": {
|
||||
"source": [ "Visualize.Vertex" ]
|
||||
},
|
||||
"VisualizeFragmentDepth": {
|
||||
"source": [ "Visualize.Fragment.Depth" ]
|
||||
},
|
||||
"VisualizeFragmentId": {
|
||||
"source": [ "Visualize.Fragment.Id" ]
|
||||
},
|
||||
"VisualizeFragmentNormal": {
|
||||
"source": [ "Visualize.Fragment.Normal" ]
|
||||
},
|
||||
"VisualizeFragmentFallback": {
|
||||
"source": [ "Visualize.Fragment.Fallback" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl Visualize.Vertex
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = position;
|
||||
uvOut = uvIn;
|
||||
}
|
||||
|
||||
-- glsl Visualize.Fragment.Depth
|
||||
|
||||
// Re-normalize clip space depth in the range [0.0, 1.0] to the range [min, max]
|
||||
// to allow better visualization of depth differences.
|
||||
float normalizeDepth(float depth)
|
||||
{
|
||||
float min = minMaxDepth.x, max = minMaxDepth.y;
|
||||
return (depth - min) / (max - min);
|
||||
}
|
||||
|
||||
// Display the renormalized depth as a grayscale image.
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
float depth = HdTexelFetch_depthIn(ivec2(fragCoord)).x;
|
||||
hd_FragColor = vec4( vec3(normalizeDepth(depth)), 1.0 );
|
||||
}
|
||||
|
||||
-- glsl Visualize.Fragment.Id
|
||||
|
||||
// Convert a 32 bit integer into a vec3 color.
|
||||
vec3 IntToVec3(int id)
|
||||
{
|
||||
// Create a 24 bit value by XORing the leading 8 bits with the remaining
|
||||
// 24 bits.
|
||||
int leadBits = id >> 24;
|
||||
int restBits = (id << 8) >> 8;
|
||||
int result = restBits ^ leadBits;
|
||||
|
||||
return vec3(((result >> 0) & 0xff) / 255.0,
|
||||
((result >> 8) & 0xff) / 255.0,
|
||||
((result >> 16) & 0xff) / 255.0);
|
||||
}
|
||||
|
||||
// Convert a 32 bit integer representing the ID of a primitive or sub-primitive
|
||||
// into a color such that consecutive IDs generally map to different colors.
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
int id = HdTexelFetch_idIn(ivec2(fragCoord)).x;
|
||||
int vizId = id * 11629091; // prime number near ln(2) * 2^24
|
||||
hd_FragColor = vec4(IntToVec3(vizId), 1.0);
|
||||
}
|
||||
|
||||
-- glsl Visualize.Fragment.Normal
|
||||
|
||||
// [-1,1] to [0,1]
|
||||
vec3 renormalize(vec3 normal)
|
||||
{
|
||||
return 0.5 * normal + 0.5;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
vec3 normal = HdTexelFetch_normalIn(ivec2(fragCoord)).xyz;
|
||||
hd_FragColor = vec4(renormalize(normal), 1.0);
|
||||
}
|
||||
|
||||
-- glsl Visualize.Fragment.Fallback
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fragCoord = uvOut * screenSize;
|
||||
// Force conversion to a vector of floats.
|
||||
hd_FragColor = vec4(HdTexelFetch_aovIn(ivec2(fragCoord)));
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"HgiGL" : {
|
||||
"bases": ["Hgi"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_hgiGL.dll",
|
||||
"Name": "hgiGL",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"Hio_StbImage" : {
|
||||
"bases": ["HioImage"],
|
||||
"imageTypes": ["bmp", "jpg", "jpeg", "png", "tga", "hdr"],
|
||||
"precedence": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_hio.dll",
|
||||
"Name": "hio",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"NdrDiscoveryPlugin": {},
|
||||
"_NdrFilesystemDiscoveryPlugin" : {
|
||||
"bases": ["NdrDiscoveryPlugin"],
|
||||
"displayName": "Filesystem Discovery"
|
||||
},
|
||||
"NdrParserPlugin": {}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_ndr.dll",
|
||||
"Name": "ndr",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"Includes": [
|
||||
"*/resources/"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"payloadAssetDependencies": {
|
||||
"appliesTo": "prims",
|
||||
"displayGroup": "Pipeline",
|
||||
"type": "asset[]"
|
||||
}
|
||||
},
|
||||
"Types": {
|
||||
"SdfFileFormat": {
|
||||
"displayName": "Sdf file format base class",
|
||||
"target": "sdf"
|
||||
},
|
||||
"SdfTextFileFormat": {
|
||||
"bases": [
|
||||
"SdfFileFormat"
|
||||
],
|
||||
"displayName": "Sdf Text File Format",
|
||||
"extensions": [
|
||||
"sdf"
|
||||
],
|
||||
"formatId": "sdf"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_sdf.dll",
|
||||
"Name": "sdf",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright 2017 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef {{ Upper(libraryName) }}_API_H
|
||||
#define {{ Upper(libraryName) }}_API_H
|
||||
|
||||
#include "pxr/base/arch/export.h"
|
||||
|
||||
#if defined(PXR_STATIC)
|
||||
# define {{ Upper(libraryName) }}_API
|
||||
# define {{ Upper(libraryName) }}_API_TEMPLATE_CLASS(...)
|
||||
# define {{ Upper(libraryName) }}_API_TEMPLATE_STRUCT(...)
|
||||
# define {{ Upper(libraryName) }}_LOCAL
|
||||
#else
|
||||
# if defined({{ Upper(libraryName) }}_EXPORTS)
|
||||
# define {{ Upper(libraryName) }}_API ARCH_EXPORT
|
||||
# define {{ Upper(libraryName) }}_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define {{ Upper(libraryName) }}_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# else
|
||||
# define {{ Upper(libraryName) }}_API ARCH_IMPORT
|
||||
# define {{ Upper(libraryName) }}_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define {{ Upper(libraryName) }}_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# endif
|
||||
# define {{ Upper(libraryName) }}_LOCAL ARCH_HIDDEN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
}
|
||||
},
|
||||
"LibraryPath": "@PLUG_INFO_LIBRARY_PATH@",
|
||||
"Name": "{{ libraryName }}",
|
||||
"ResourcePath": "@PLUG_INFO_RESOURCE_PATH@",
|
||||
"Root": "@PLUG_INFO_ROOT@",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#include "{{ libraryPath }}/{{ cls.GetHeaderFile() }}"
|
||||
#include "pxr/usd/usd/schemaRegistry.h"
|
||||
#include "pxr/usd/usd/typed.h"
|
||||
{% if cls.isApi %}
|
||||
#include "pxr/usd/usd/tokens.h"
|
||||
{% endif %}
|
||||
|
||||
#include "pxr/usd/sdf/types.h"
|
||||
#include "pxr/usd/sdf/assetPath.h"
|
||||
|
||||
{% if useExportAPI %}
|
||||
{{ namespaceOpen }}
|
||||
|
||||
{% endif %}
|
||||
// Register the schema with the TfType system.
|
||||
TF_REGISTRY_FUNCTION(TfType)
|
||||
{
|
||||
TfType::Define<{{ cls.cppClassName }},
|
||||
TfType::Bases< {{ cls.parentCppClassName }} > >();
|
||||
|
||||
{% if cls.isConcrete %}
|
||||
// Register the usd prim typename as an alias under UsdSchemaBase. This
|
||||
// enables one to call
|
||||
// TfType::Find<UsdSchemaBase>().FindDerivedByName("{{ cls.usdPrimTypeName }}")
|
||||
// to find TfType<{{ cls.cppClassName }}>, which is how IsA queries are
|
||||
// answered.
|
||||
TfType::AddAlias<UsdSchemaBase, {{ cls.cppClassName }}>("{{ cls.usdPrimTypeName }}");
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
{% if cls.isApi %}
|
||||
TF_DEFINE_PRIVATE_TOKENS(
|
||||
_schemaTokens,
|
||||
({{ cls.primName }})
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
({{ cls.propertyNamespacePrefix }})
|
||||
{% endif %}
|
||||
);
|
||||
|
||||
{% endif %}
|
||||
/* virtual */
|
||||
{{ cls.cppClassName }}::~{{ cls.cppClassName }}()
|
||||
{
|
||||
}
|
||||
|
||||
{% if not cls.isAPISchemaBase %}
|
||||
/* static */
|
||||
{{ cls.cppClassName }}
|
||||
{{ cls.cppClassName }}::Get(const UsdStagePtr &stage, const SdfPath &path)
|
||||
{
|
||||
if (!stage) {
|
||||
TF_CODING_ERROR("Invalid stage");
|
||||
return {{ cls.cppClassName }}();
|
||||
}
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
TfToken name;
|
||||
if (!Is{{ cls.usdPrimTypeName }}Path(path, &name)) {
|
||||
TF_CODING_ERROR("Invalid {{ cls.propertyNamespacePrefix }} path <%s>.", path.GetText());
|
||||
return {{ cls.cppClassName }}();
|
||||
}
|
||||
return {{ cls.cppClassName }}(stage->GetPrimAtPath(path.GetPrimPath()), name);
|
||||
{% else %}
|
||||
return {{ cls.cppClassName }}(stage->GetPrimAtPath(path));
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
{% if cls.isMultipleApply %}
|
||||
{{ cls.cppClassName }}
|
||||
{{ cls.cppClassName }}::Get(const UsdPrim &prim, const TfToken &name)
|
||||
{
|
||||
return {{ cls.cppClassName }}(prim, name);
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if cls.isConcrete %}
|
||||
/* static */
|
||||
{{ cls.cppClassName }}
|
||||
{{ cls.cppClassName }}::Define(
|
||||
const UsdStagePtr &stage, const SdfPath &path)
|
||||
{
|
||||
static TfToken usdPrimTypeName("{{ cls.usdPrimTypeName }}");
|
||||
if (!stage) {
|
||||
TF_CODING_ERROR("Invalid stage");
|
||||
return {{ cls.cppClassName }}();
|
||||
}
|
||||
return {{ cls.cppClassName }}(
|
||||
stage->DefinePrim(path, usdPrimTypeName));
|
||||
}
|
||||
{% endif %}
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
{{ cls.cppClassName }}::IsSchemaPropertyBaseName(const TfToken &baseName)
|
||||
{
|
||||
static TfTokenVector attrsAndRels = {
|
||||
{% for attrName in cls.attrOrder %}
|
||||
{% set attr = cls.attrs[attrName] %}
|
||||
{{ tokensPrefix }}Tokens->{{ attr.name }},
|
||||
{% endfor %}
|
||||
{% for relName in cls.relOrder %}
|
||||
{% set rel = cls.rels[relName] %}
|
||||
{{ tokensPrefix }}Tokens->{{ rel.name }},
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
return find(attrsAndRels.begin(), attrsAndRels.end(), baseName)
|
||||
!= attrsAndRels.end();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
{{ cls.cppClassName }}::Is{{ cls.usdPrimTypeName }}Path(
|
||||
const SdfPath &path, TfToken *name)
|
||||
{
|
||||
if (!path.IsPropertyPath()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string propertyName = path.GetName();
|
||||
TfTokenVector tokens = SdfPath::TokenizeIdentifierAsTokens(propertyName);
|
||||
|
||||
// The baseName of the {{ cls.usdPrimTypename }} path can't be one of the
|
||||
// schema properties. We should validate this in the creation (or apply)
|
||||
// API.
|
||||
TfToken baseName = *tokens.rbegin();
|
||||
if (IsSchemaPropertyBaseName(baseName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tokens.size() >= 2
|
||||
&& tokens[0] == _schemaTokens->{{ cls.propertyNamespacePrefix }}) {
|
||||
*name = TfToken(propertyName.substr(
|
||||
_schemaTokens->{{ cls.propertyNamespacePrefix }}.GetString().size() + 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
/* virtual */
|
||||
UsdSchemaKind {{ cls.cppClassName }}::_GetSchemaKind() const
|
||||
{
|
||||
return {{ cls.cppClassName }}::schemaKind;
|
||||
}
|
||||
{% if cls.isAppliedAPISchema %}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
{% if not cls.isMultipleApply %}
|
||||
{{ cls.cppClassName }}::CanApply(
|
||||
const UsdPrim &prim, std::string *whyNot)
|
||||
{% else %}
|
||||
{{ cls.cppClassName }}::CanApply(
|
||||
const UsdPrim &prim, const TfToken &name, std::string *whyNot)
|
||||
{% endif %}
|
||||
{
|
||||
{% if cls.isMultipleApply %}
|
||||
return prim.CanApplyAPI<{{ cls.cppClassName }}>(name, whyNot);
|
||||
{% else %}
|
||||
return prim.CanApplyAPI<{{ cls.cppClassName }}>(whyNot);
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
/* static */
|
||||
{{ cls.cppClassName }}
|
||||
{% if not cls.isMultipleApply %}
|
||||
{{ cls.cppClassName }}::Apply(const UsdPrim &prim)
|
||||
{% else %}
|
||||
{{ cls.cppClassName }}::Apply(const UsdPrim &prim, const TfToken &name)
|
||||
{% endif %}
|
||||
{
|
||||
{% if cls.isMultipleApply %}
|
||||
if (prim.ApplyAPI<{{ cls.cppClassName }}>(name)) {
|
||||
return {{ cls.cppClassName }}(prim, name);
|
||||
}
|
||||
{% else %}
|
||||
if (prim.ApplyAPI<{{ cls.cppClassName }}>()) {
|
||||
return {{ cls.cppClassName }}(prim);
|
||||
}
|
||||
{% endif %}
|
||||
return {{ cls.cppClassName }}();
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
/* static */
|
||||
const TfType &
|
||||
{{ cls.cppClassName }}::_GetStaticTfType()
|
||||
{
|
||||
static TfType tfType = TfType::Find<{{ cls.cppClassName }}>();
|
||||
return tfType;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
{{ cls.cppClassName }}::_IsTypedSchema()
|
||||
{
|
||||
static bool isTyped = _GetStaticTfType().IsA<UsdTyped>();
|
||||
return isTyped;
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
const TfType &
|
||||
{{ cls.cppClassName }}::_GetTfType() const
|
||||
{
|
||||
return _GetStaticTfType();
|
||||
}
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
|
||||
/// Returns the property name prefixed with the correct namespace prefix, which
|
||||
/// is composed of the the API's propertyNamespacePrefix metadata and the
|
||||
/// instance name of the API.
|
||||
static inline
|
||||
TfToken
|
||||
_GetNamespacedPropertyName(const TfToken instanceName, const TfToken propName)
|
||||
{
|
||||
TfTokenVector identifiers =
|
||||
{_schemaTokens->{{ cls.propertyNamespacePrefix }}, instanceName, propName};
|
||||
return TfToken(SdfPath::JoinIdentifier(identifiers));
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% for attrName in cls.attrOrder %}
|
||||
{% set attr = cls.attrs[attrName] %}
|
||||
{# Only emit Create/Get API and doxygen if apiName is not empty string. #}
|
||||
{% if attr.apiName != '' %}
|
||||
{% if attr.apiGet != "custom" %}
|
||||
UsdAttribute
|
||||
{{ cls.cppClassName }}::Get{{ Proper(attr.apiName) }}Attr() const
|
||||
{
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
return GetPrim().GetAttribute(
|
||||
_GetNamespacedPropertyName(
|
||||
GetName(),
|
||||
{{ tokensPrefix }}Tokens->{{ attr.name }}));
|
||||
{% else %}
|
||||
return GetPrim().GetAttribute({{ tokensPrefix }}Tokens->{{ attr.name }});
|
||||
{% endif %}
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
UsdAttribute
|
||||
{{ cls.cppClassName }}::Create{{ Proper(attr.apiName) }}Attr(VtValue const &defaultValue, bool writeSparsely) const
|
||||
{
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
return UsdSchemaBase::_CreateAttr(
|
||||
_GetNamespacedPropertyName(
|
||||
GetName(),
|
||||
{{ tokensPrefix }}Tokens->{{ attr.name }}),
|
||||
{% else %}
|
||||
return UsdSchemaBase::_CreateAttr({{ tokensPrefix }}Tokens->{{ attr.name }},
|
||||
{% endif %}
|
||||
{{ attr.usdType }},
|
||||
/* custom = */ {{ "true" if attr.custom else "false" }},
|
||||
{{ attr.variability }},
|
||||
defaultValue,
|
||||
writeSparsely);
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for relName in cls.relOrder %}
|
||||
{% set rel = cls.rels[relName] %}
|
||||
{# Only emit Create/Get API and doxygen if apiName is not empty string. #}
|
||||
{% if rel.apiName != '' %}
|
||||
{% if rel.apiGet != "custom" %}
|
||||
UsdRelationship
|
||||
{{ cls.cppClassName }}::Get{{ Proper(rel.apiName) }}Rel() const
|
||||
{
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
return GetPrim().GetRelationship(
|
||||
_GetNamespacedPropertyName(
|
||||
GetName(),
|
||||
{{ tokensPrefix }}Tokens->{{ rel.name }}));
|
||||
{% else %}
|
||||
return GetPrim().GetRelationship({{ tokensPrefix }}Tokens->{{ rel.name }});
|
||||
{% endif %}
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
UsdRelationship
|
||||
{{ cls.cppClassName }}::Create{{ Proper(rel.apiName) }}Rel() const
|
||||
{
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
return GetPrim().CreateRelationship(
|
||||
_GetNamespacedPropertyName(
|
||||
GetName(),
|
||||
{{ tokensPrefix }}Tokens->{{ rel.name }}),
|
||||
{% else %}
|
||||
return GetPrim().CreateRelationship({{ tokensPrefix }}Tokens->{{rel.name}},
|
||||
{% endif %}
|
||||
/* custom = */ {{ "true" if rel.custom else "false" }});
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if cls.attrOrder|length > 0 %}
|
||||
namespace {
|
||||
static inline TfTokenVector
|
||||
{% if cls.isMultipleApply %}
|
||||
_ConcatenateAttributeNames(
|
||||
const TfToken instanceName,
|
||||
const TfTokenVector& left,
|
||||
const TfTokenVector& right)
|
||||
{% else %}
|
||||
_ConcatenateAttributeNames(const TfTokenVector& left,const TfTokenVector& right)
|
||||
{% endif %}
|
||||
{
|
||||
TfTokenVector result;
|
||||
result.reserve(left.size() + right.size());
|
||||
result.insert(result.end(), left.begin(), left.end());
|
||||
{% if cls.isMultipleApply %}
|
||||
|
||||
for (const TfToken attrName : right) {
|
||||
result.push_back(
|
||||
_GetNamespacedPropertyName(instanceName, attrName));
|
||||
}
|
||||
{% endif %}
|
||||
result.insert(result.end(), right.begin(), right.end());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
/*static*/
|
||||
const TfTokenVector&
|
||||
{% if cls.isMultipleApply %}
|
||||
{{ cls.cppClassName }}::GetSchemaAttributeNames(
|
||||
bool includeInherited, const TfToken instanceName)
|
||||
{% else %}
|
||||
{{ cls.cppClassName }}::GetSchemaAttributeNames(bool includeInherited)
|
||||
{% endif %}
|
||||
{
|
||||
{% if cls.attrOrder|length > 0 %}
|
||||
static TfTokenVector localNames = {
|
||||
{% for attrName in cls.attrOrder %}
|
||||
{% set attr = cls.attrs[attrName] %}
|
||||
{{ tokensPrefix }}Tokens->{{ attr.name }},
|
||||
{% endfor %}
|
||||
};
|
||||
{% if cls.isMultipleApply %}
|
||||
static TfTokenVector allNames =
|
||||
_ConcatenateAttributeNames(
|
||||
instanceName,
|
||||
{# The schema generator has already validated whether our parent is #}
|
||||
{# a multiple apply schema or UsdSchemaBaseAPI, choose the correct function #}
|
||||
{# depending on the situation #}
|
||||
{% if cls.parentCppClassName == "UsdAPISchemaBase" %}
|
||||
{{ cls.parentCppClassName }}::GetSchemaAttributeNames(true),
|
||||
{% else %}
|
||||
{{ cls.parentCppClassName }}::GetSchemaAttributeNames(true, instanceName),
|
||||
{% endif %}
|
||||
localNames);
|
||||
{% else %}
|
||||
static TfTokenVector allNames =
|
||||
_ConcatenateAttributeNames(
|
||||
{{ cls.parentCppClassName }}::GetSchemaAttributeNames(true),
|
||||
localNames);
|
||||
{% endif %}
|
||||
{% else %}
|
||||
static TfTokenVector localNames;
|
||||
static TfTokenVector allNames =
|
||||
{{ cls.parentCppClassName }}::GetSchemaAttributeNames(true);
|
||||
{% endif %}
|
||||
|
||||
if (includeInherited)
|
||||
return allNames;
|
||||
else
|
||||
return localNames;
|
||||
}
|
||||
|
||||
{% if useExportAPI %}
|
||||
{{ namespaceClose }}
|
||||
|
||||
{% endif %}
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line. It will be preserved by
|
||||
// the code generator.
|
||||
{% if useExportAPI %}
|
||||
//
|
||||
// Just remember to wrap code in the appropriate delimiters:
|
||||
// '{{ namespaceOpen }}', '{{ namespaceClose }}'.
|
||||
{% endif %}
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
@@ -0,0 +1,444 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef {{ Upper(libraryName) }}_GENERATED_{{ Upper(cls.className) }}_H
|
||||
#define {{ Upper(libraryName) }}_GENERATED_{{ Upper(cls.className) }}_H
|
||||
|
||||
/// \file {{ libraryName }}/{{ cls.GetHeaderFile() }}
|
||||
|
||||
{% if useExportAPI %}
|
||||
#include "pxr/pxr.h"
|
||||
#include "{{ libraryPath }}/api.h"
|
||||
{% endif %}
|
||||
#include "{{ cls.parentLibPath }}/{{ cls.GetParentHeaderFile() }}"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
{% if cls.tokens -%}
|
||||
#include "{{ libraryPath }}/tokens.h"
|
||||
{% endif %}
|
||||
{% if cls.extraIncludes -%}
|
||||
{{ cls.extraIncludes }}
|
||||
{% endif %}
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
{% if useExportAPI %}
|
||||
{{ namespaceOpen }}
|
||||
|
||||
{% endif %}
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// {{ Upper(cls.usdPrimTypeName) }}{{' ' * (74 - cls.usdPrimTypeName|count)}} //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class {{ cls.cppClassName }}
|
||||
///
|
||||
{% if cls.doc -%}
|
||||
/// {{ cls.doc }}
|
||||
{% endif %}
|
||||
{% if cls.doc and hasTokenAttrs -%}
|
||||
///
|
||||
{%endif%}
|
||||
{% if hasTokenAttrs -%}
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref {{ tokensPrefix }}Tokens.
|
||||
/// So to set an attribute to the value "rightHanded", use {{ tokensPrefix }}Tokens->rightHanded
|
||||
/// as the value.
|
||||
{% endif %}
|
||||
///
|
||||
class {{ cls.cppClassName }} : public {{ cls.parentCppClassName }}
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = {{cls.schemaKindEnumValue }};
|
||||
|
||||
{% if cls.isMultipleApply %}
|
||||
/// Construct a {{ cls.cppClassName }} on UsdPrim \p prim with
|
||||
/// name \p name . Equivalent to
|
||||
/// {{ cls.cppClassName }}::Get(
|
||||
/// prim.GetStage(),
|
||||
/// prim.GetPath().AppendProperty(
|
||||
/// "{{ cls.propertyNamespacePrefix }}:name"));
|
||||
///
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit {{ cls.cppClassName }}(
|
||||
const UsdPrim& prim=UsdPrim(), const TfToken &name=TfToken())
|
||||
: {{ cls.parentCppClassName }}(prim, /*instanceName*/ name)
|
||||
{ }
|
||||
|
||||
/// Construct a {{ cls.cppClassName }} on the prim held by \p schemaObj with
|
||||
/// name \p name. Should be preferred over
|
||||
/// {{ cls.cppClassName }}(schemaObj.GetPrim(), name), as it preserves
|
||||
/// SchemaBase state.
|
||||
explicit {{ cls.cppClassName }}(
|
||||
const UsdSchemaBase& schemaObj, const TfToken &name)
|
||||
: {{ cls.parentCppClassName }}(schemaObj, /*instanceName*/ name)
|
||||
{ }
|
||||
{% else %}
|
||||
/// Construct a {{ cls.cppClassName }} on UsdPrim \p prim .
|
||||
/// Equivalent to {{ cls.cppClassName }}::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit {{ cls.cppClassName }}(const UsdPrim& prim=UsdPrim())
|
||||
: {{ cls.parentCppClassName }}(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a {{ cls.cppClassName }} on the prim held by \p schemaObj .
|
||||
/// Should be preferred over {{ cls.cppClassName }}(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit {{ cls.cppClassName }}(const UsdSchemaBase& schemaObj)
|
||||
: {{ cls.parentCppClassName }}(schemaObj)
|
||||
{
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
/// Destructor.
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
virtual ~{{ cls.cppClassName }}() {%- if cls.isAPISchemaBase %} = 0{% endif %};
|
||||
|
||||
{% if cls.isMultipleApply %}
|
||||
/// Return a vector of names of all pre-declared attributes for this schema
|
||||
/// class and all its ancestor classes for a given instance name. Does not
|
||||
/// include attributes that may be authored by custom/extended methods of
|
||||
/// the schemas involved. The names returned will have the proper namespace
|
||||
/// prefix.
|
||||
{% else %}
|
||||
/// Return a vector of names of all pre-declared attributes for this schema
|
||||
/// class and all its ancestor classes. Does not include attributes that
|
||||
/// may be authored by custom/extended methods of the schemas involved.
|
||||
{% endif %}
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static const TfTokenVector &
|
||||
{% if cls.isMultipleApply %}
|
||||
GetSchemaAttributeNames(
|
||||
bool includeInherited=true, const TfToken instanceName=TfToken());
|
||||
{% else %}
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
{% endif %}
|
||||
{% if cls.isMultipleApply %}
|
||||
|
||||
/// Returns the name of this multiple-apply schema instance
|
||||
TfToken GetName() const {
|
||||
return _GetInstanceName();
|
||||
}
|
||||
{% endif %}
|
||||
{% if not cls.isAPISchemaBase %}
|
||||
|
||||
/// Return a {{ cls.cppClassName }} holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p stage, or if the prim at that path does not adhere to this schema,
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
/// return an invalid schema object. \p path must be of the format
|
||||
/// <path>.{{ cls.propertyNamespacePrefix }}:name .
|
||||
///
|
||||
/// This is shorthand for the following:
|
||||
///
|
||||
/// \code
|
||||
/// TfToken name = SdfPath::StripNamespace(path.GetToken());
|
||||
/// {{ cls.cppClassName }}(
|
||||
/// stage->GetPrimAtPath(path.GetPrimPath()), name);
|
||||
/// \endcode
|
||||
{% else %}
|
||||
/// return an invalid schema object. This is shorthand for the following:
|
||||
///
|
||||
/// \code
|
||||
/// {{ cls.cppClassName }}(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
{% endif %}
|
||||
///
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static {{ cls.cppClassName }}
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
{% if cls.isMultipleApply %}
|
||||
|
||||
/// Return a {{ cls.cppClassName }} with name \p name holding the
|
||||
/// prim \p prim. Shorthand for {{ cls.cppClassName }}(prim, name);
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static {{ cls.cppClassName }}
|
||||
Get(const UsdPrim &prim, const TfToken &name);
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if cls.isConcrete %}
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a path must be an absolute prim path that does not contain
|
||||
/// any variant selections.
|
||||
///
|
||||
/// If it is impossible to author any of the necessary PrimSpecs, (for
|
||||
/// example, in case \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a UsdPrim.
|
||||
///
|
||||
/// Note that this method may return a defined prim whose typeName does not
|
||||
/// specify this schema class, in case a stronger typeName opinion overrides
|
||||
/// the opinion at the current EditTarget.
|
||||
///
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static {{ cls.cppClassName }}
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
{% endif %}
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
/// Checks if the given name \p baseName is the base name of a property
|
||||
/// of {{ cls.usdPrimTypeName }}.
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static bool
|
||||
IsSchemaPropertyBaseName(const TfToken &baseName);
|
||||
|
||||
/// Checks if the given path \p path is of an API schema of type
|
||||
/// {{ cls.usdPrimTypeName }}. If so, it stores the instance name of
|
||||
/// the schema in \p name and returns true. Otherwise, it returns false.
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static bool
|
||||
Is{{ cls.usdPrimTypeName }}Path(const SdfPath &path, TfToken *name);
|
||||
{% endif %}
|
||||
{% if cls.isAppliedAPISchema and not cls.isMultipleApply %}
|
||||
|
||||
/// Returns true if this <b>single-apply</b> API schema can be applied to
|
||||
/// the given \p prim. If this schema can not be a applied to the prim,
|
||||
/// this returns false and, if provided, populates \p whyNot with the
|
||||
/// reason it can not be applied.
|
||||
///
|
||||
/// Note that if CanApply returns false, that does not necessarily imply
|
||||
/// that calling Apply will fail. Callers are expected to call CanApply
|
||||
/// before calling Apply if they want to ensure that it is valid to
|
||||
/// apply a schema.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static bool
|
||||
CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
|
||||
|
||||
/// Applies this <b>single-apply</b> API schema to the given \p prim.
|
||||
/// This information is stored by adding "{{ cls.primName }}" to the
|
||||
/// token-valued, listOp metadata \em apiSchemas on the prim.
|
||||
///
|
||||
/// \return A valid {{ cls.cppClassName }} object is returned upon success.
|
||||
/// An invalid (or empty) {{ cls.cppClassName }} object is returned upon
|
||||
/// failure. See \ref UsdPrim::ApplyAPI() for conditions
|
||||
/// resulting in failure.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static {{ cls.cppClassName }}
|
||||
Apply(const UsdPrim &prim);
|
||||
{% endif %}
|
||||
{% if cls.isAppliedAPISchema and cls.isMultipleApply %}
|
||||
|
||||
/// Returns true if this <b>multiple-apply</b> API schema can be applied,
|
||||
/// with the given instance name, \p name, to the given \p prim. If this
|
||||
/// schema can not be a applied the prim, this returns false and, if
|
||||
/// provided, populates \p whyNot with the reason it can not be applied.
|
||||
///
|
||||
/// Note that if CanApply returns false, that does not necessarily imply
|
||||
/// that calling Apply will fail. Callers are expected to call CanApply
|
||||
/// before calling Apply if they want to ensure that it is valid to
|
||||
/// apply a schema.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static bool
|
||||
CanApply(const UsdPrim &prim, const TfToken &name,
|
||||
std::string *whyNot=nullptr);
|
||||
|
||||
/// Applies this <b>multiple-apply</b> API schema to the given \p prim
|
||||
/// along with the given instance name, \p name.
|
||||
///
|
||||
/// This information is stored by adding "{{ cls.primName }}:<i>name</i>"
|
||||
/// to the token-valued, listOp metadata \em apiSchemas on the prim.
|
||||
/// For example, if \p name is 'instance1', the token
|
||||
/// '{{ cls.primName }}:instance1' is added to 'apiSchemas'.
|
||||
///
|
||||
/// \return A valid {{ cls.cppClassName }} object is returned upon success.
|
||||
/// An invalid (or empty) {{ cls.cppClassName }} object is returned upon
|
||||
/// failure. See \ref UsdPrim::ApplyAPI() for
|
||||
/// conditions resulting in failure.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static {{ cls.cppClassName }}
|
||||
Apply(const UsdPrim &prim, const TfToken &name);
|
||||
{% endif %}
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
{% for attrName in cls.attrOrder %}
|
||||
{% set attr = cls.attrs[attrName]%}
|
||||
{# Only emit Create/Get API and doxygen if apiName is not empty string. #}
|
||||
{% if attr.apiName != '' %}
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// {{ Upper(attr.apiName) }}
|
||||
// --------------------------------------------------------------------- //
|
||||
/// {{ attr.doc }}
|
||||
///
|
||||
{% if attr.details %}
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
{% for detail in attr.details %}
|
||||
/// | {{ detail[0] }} | {{ detail[1] }} |
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
UsdAttribute Get{{ Proper(attr.apiName) }}Attr() const;
|
||||
|
||||
/// See Get{{ Proper(attr.apiName) }}Attr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
UsdAttribute Create{{ Proper(attr.apiName) }}Attr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for relName in cls.relOrder %}
|
||||
{% set rel = cls.rels[relName]%}
|
||||
{# Only emit Create/Get API and doxygen if apiName is not empty string. #}
|
||||
{% if rel.apiName != '' %}
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// {{ Upper(rel.apiName) }}
|
||||
// --------------------------------------------------------------------- //
|
||||
/// {{ rel.doc }}
|
||||
///
|
||||
{% for detail in rel.details %}
|
||||
/// \n {{ detail[0] }}: {{ detail[1] }}
|
||||
{% endfor %}
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
UsdRelationship Get{{ Proper(rel.apiName) }}Rel() const;
|
||||
|
||||
/// See Get{{ Proper(rel.apiName) }}Rel(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
|
||||
{% if useExportAPI -%}
|
||||
{{ Upper(libraryName) }}_API
|
||||
{% endif -%}
|
||||
UsdRelationship Create{{ Proper(rel.apiName) }}Rel() const;
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
{% if useExportAPI %}
|
||||
// - Close the namespace with {{ namespaceClose }}
|
||||
{% endif %}
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#include "{{ libraryPath }}/tokens.h"
|
||||
|
||||
{% if useExportAPI %}
|
||||
{{ namespaceOpen }}
|
||||
|
||||
{% endif %}
|
||||
{{ tokensPrefix }}TokensType::{{ tokensPrefix }}TokensType() :
|
||||
{% for token in tokens %}
|
||||
{{ token.id }}("{{ token.value }}", TfToken::Immortal),
|
||||
{% endfor %}
|
||||
allTokens({
|
||||
{% for token in tokens %}
|
||||
{{ token.id }}{% if not loop.last %},{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
TfStaticData<{{ tokensPrefix }}TokensType> {{ tokensPrefix }}Tokens;
|
||||
{% if useExportAPI %}
|
||||
|
||||
{{ namespaceClose }}
|
||||
{% endif %}
|
||||
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef {{ Upper(tokensPrefix) }}_TOKENS_H
|
||||
#define {{ Upper(tokensPrefix) }}_TOKENS_H
|
||||
|
||||
/// \file {{ libraryName }}/tokens.h
|
||||
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
//
|
||||
// This is an automatically generated file (by usdGenSchema.py).
|
||||
// Do not hand-edit!
|
||||
//
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
{% if useExportAPI %}
|
||||
#include "pxr/pxr.h"
|
||||
#include "{{ libraryPath }}/api.h"
|
||||
{% endif %}
|
||||
#include "pxr/base/tf/staticData.h"
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include <vector>
|
||||
|
||||
{% if useExportAPI %}
|
||||
{{ namespaceOpen }}
|
||||
|
||||
{% endif %}
|
||||
|
||||
/// \class {{ tokensPrefix }}TokensType
|
||||
///
|
||||
/// \link {{ tokensPrefix }}Tokens \endlink provides static, efficient
|
||||
/// \link TfToken TfTokens\endlink for use in all public USD API.
|
||||
///
|
||||
/// These tokens are auto-generated from the module's schema, representing
|
||||
/// property names, for when you need to fetch an attribute or relationship
|
||||
/// directly by name, e.g. UsdPrim::GetAttribute(), in the most efficient
|
||||
/// manner, and allow the compiler to verify that you spelled the name
|
||||
/// correctly.
|
||||
///
|
||||
/// {{ tokensPrefix }}Tokens also contains all of the \em allowedTokens values
|
||||
/// declared for schema builtin attributes of 'token' scene description type.
|
||||
{% if tokens %}
|
||||
/// Use {{ tokensPrefix }}Tokens like so:
|
||||
///
|
||||
/// \code
|
||||
/// gprim.GetMyTokenValuedAttr().Set({{ tokensPrefix }}Tokens->{{ tokens[0].id }});
|
||||
/// \endcode
|
||||
{% endif %}
|
||||
struct {{ tokensPrefix }}TokensType {
|
||||
{% if useExportAPI %}{{ Upper(libraryName) }}_API {% endif %}{{ tokensPrefix }}TokensType();
|
||||
{% for token in tokens %}
|
||||
/// \brief "{{ token.value }}"
|
||||
///
|
||||
/// {{ token.desc }}
|
||||
const TfToken {{ token.id }};
|
||||
{% endfor %}
|
||||
/// A vector of all of the tokens listed above.
|
||||
const std::vector<TfToken> allTokens;
|
||||
};
|
||||
|
||||
/// \var {{ tokensPrefix }}Tokens
|
||||
///
|
||||
/// A global variable with static, efficient \link TfToken TfTokens\endlink
|
||||
/// for use in all public USD API. \sa {{ tokensPrefix }}TokensType
|
||||
extern{% if useExportAPI %} {{ Upper(libraryName) }}_API{% endif %} TfStaticData<{{ tokensPrefix }}TokensType> {{ tokensPrefix }}Tokens;
|
||||
{% if useExportAPI %}
|
||||
|
||||
{{ namespaceClose }}
|
||||
{% endif %}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,270 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#include "{{ libraryPath }}/{{ cls.GetHeaderFile() }}"
|
||||
#include "pxr/usd/usd/schemaBase.h"
|
||||
|
||||
#include "pxr/usd/sdf/primSpec.h"
|
||||
|
||||
#include "pxr/usd/usd/pyConversions.h"
|
||||
{% if cls.isAppliedAPISchema %}
|
||||
#include "pxr/base/tf/pyAnnotatedBoolResult.h"
|
||||
{% endif %}
|
||||
#include "pxr/base/tf/pyContainerConversions.h"
|
||||
#include "pxr/base/tf/pyResultConversions.h"
|
||||
#include "pxr/base/tf/pyUtils.h"
|
||||
#include "pxr/base/tf/wrapTypeHelpers.h"
|
||||
|
||||
#include <boost/python.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
{% if useExportAPI %}
|
||||
{{ namespaceUsing }}
|
||||
|
||||
namespace {
|
||||
|
||||
{% endif %}
|
||||
#define WRAP_CUSTOM \
|
||||
template <class Cls> static void _CustomWrapCode(Cls &_class)
|
||||
|
||||
// fwd decl.
|
||||
WRAP_CUSTOM;
|
||||
|
||||
{% for attrName in cls.attrOrder -%}
|
||||
{% set attr = cls.attrs[attrName] %}
|
||||
{# Only emit Create/Get API if apiName is not empty string. #}
|
||||
{% if attr.apiName != '' %}
|
||||
|
||||
static UsdAttribute
|
||||
_Create{{ Proper(attr.apiName) }}Attr({{ cls.cppClassName }} &self,
|
||||
object defaultVal, bool writeSparsely) {
|
||||
return self.Create{{ Proper(attr.apiName) }}Attr(
|
||||
UsdPythonToSdfType(defaultVal, {{ attr.usdType }}), writeSparsely);
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
|
||||
static bool _WrapIs{{ cls.usdPrimTypeName }}Path(const SdfPath &path) {
|
||||
TfToken collectionName;
|
||||
return {{ cls.cppClassName }}::Is{{ cls.usdPrimTypeName }}Path(
|
||||
path, &collectionName);
|
||||
}
|
||||
{% endif %}
|
||||
{% if not cls.isAPISchemaBase %}
|
||||
|
||||
static std::string
|
||||
_Repr(const {{ cls.cppClassName }} &self)
|
||||
{
|
||||
std::string primRepr = TfPyRepr(self.GetPrim());
|
||||
{% if cls.isMultipleApply %}
|
||||
std::string instanceName = self.GetName();
|
||||
return TfStringPrintf(
|
||||
"{{ libraryName[0]|upper }}{{ libraryName[1:] }}.{{ cls.className }}(%s, '%s')",
|
||||
primRepr.c_str(), instanceName.c_str());
|
||||
{% else %}
|
||||
return TfStringPrintf(
|
||||
"{{ libraryName[0]|upper }}{{ libraryName[1:] }}.{{ cls.className }}(%s)",
|
||||
primRepr.c_str());
|
||||
{% endif %}
|
||||
}
|
||||
{% endif %}
|
||||
{% if cls.isAppliedAPISchema %}
|
||||
|
||||
struct {{ cls.cppClassName }}_CanApplyResult :
|
||||
public TfPyAnnotatedBoolResult<std::string>
|
||||
{
|
||||
{{ cls.cppClassName }}_CanApplyResult(bool val, std::string const &msg) :
|
||||
TfPyAnnotatedBoolResult<std::string>(val, msg) {}
|
||||
};
|
||||
|
||||
{% if cls.isMultipleApply %}
|
||||
static {{ cls.cppClassName }}_CanApplyResult
|
||||
_WrapCanApply(const UsdPrim& prim, const TfToken& name)
|
||||
{
|
||||
std::string whyNot;
|
||||
bool result = {{ cls.cppClassName }}::CanApply(prim, name, &whyNot);
|
||||
return {{ cls.cppClassName }}_CanApplyResult(result, whyNot);
|
||||
}
|
||||
{% else %}
|
||||
static {{ cls.cppClassName }}_CanApplyResult
|
||||
_WrapCanApply(const UsdPrim& prim)
|
||||
{
|
||||
std::string whyNot;
|
||||
bool result = {{ cls.cppClassName }}::CanApply(prim, &whyNot);
|
||||
return {{ cls.cppClassName }}_CanApplyResult(result, whyNot);
|
||||
}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if useExportAPI %}
|
||||
|
||||
} // anonymous namespace
|
||||
{% endif %}
|
||||
|
||||
void wrap{{ cls.cppClassName }}()
|
||||
{
|
||||
typedef {{ cls.cppClassName }} This;
|
||||
|
||||
{% if cls.isAppliedAPISchema %}
|
||||
{{ cls.cppClassName }}_CanApplyResult::Wrap<{{ cls.cppClassName }}_CanApplyResult>(
|
||||
"_CanApplyResult", "whyNot");
|
||||
|
||||
{% endif %}
|
||||
{% if cls.isAPISchemaBase %}
|
||||
class_< This , bases<{{ cls.parentCppClassName }}>, boost::noncopyable> cls ("APISchemaBase", "", no_init);
|
||||
{% else %}
|
||||
class_<This, bases<{{ cls.parentCppClassName }}> >
|
||||
cls("{{ cls.className }}");
|
||||
{% endif %}
|
||||
|
||||
cls
|
||||
{% if not cls.isAPISchemaBase %}
|
||||
{% if cls.isMultipleApply %}
|
||||
.def(init<UsdPrim, TfToken>())
|
||||
.def(init<UsdSchemaBase const&, TfToken>())
|
||||
{% else %}
|
||||
.def(init<UsdPrim>(arg("prim")))
|
||||
.def(init<UsdSchemaBase const&>(arg("schemaObj")))
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
.def(TfTypePythonClass())
|
||||
|
||||
{% if not cls.isAPISchemaBase %}
|
||||
{% if cls.isMultipleApply %}
|
||||
.def("Get",
|
||||
({{ cls.cppClassName }}(*)(const UsdStagePtr &stage,
|
||||
const SdfPath &path))
|
||||
&This::Get,
|
||||
(arg("stage"), arg("path")))
|
||||
.def("Get",
|
||||
({{ cls.cppClassName }}(*)(const UsdPrim &prim,
|
||||
const TfToken &name))
|
||||
&This::Get,
|
||||
(arg("prim"), arg("name")))
|
||||
{% else %}
|
||||
.def("Get", &This::Get, (arg("stage"), arg("path")))
|
||||
{% endif %}
|
||||
.staticmethod("Get")
|
||||
{% endif %}
|
||||
{% if cls.isConcrete %}
|
||||
|
||||
.def("Define", &This::Define, (arg("stage"), arg("path")))
|
||||
.staticmethod("Define")
|
||||
{% endif %}
|
||||
{% if cls.isAppliedAPISchema and not cls.isMultipleApply %}
|
||||
|
||||
.def("CanApply", &_WrapCanApply, (arg("prim")))
|
||||
.staticmethod("CanApply")
|
||||
{% endif %}
|
||||
{% if cls.isAppliedAPISchema and cls.isMultipleApply %}
|
||||
|
||||
.def("CanApply", &_WrapCanApply, (arg("prim"), arg("name")))
|
||||
.staticmethod("CanApply")
|
||||
{% endif %}
|
||||
{% if cls.isAppliedAPISchema and not cls.isMultipleApply %}
|
||||
|
||||
.def("Apply", &This::Apply, (arg("prim")))
|
||||
.staticmethod("Apply")
|
||||
{% endif %}
|
||||
{% if cls.isAppliedAPISchema and cls.isMultipleApply %}
|
||||
|
||||
.def("Apply", &This::Apply, (arg("prim"), arg("name")))
|
||||
.staticmethod("Apply")
|
||||
{% endif %}
|
||||
|
||||
.def("GetSchemaAttributeNames",
|
||||
&This::GetSchemaAttributeNames,
|
||||
arg("includeInherited")=true,
|
||||
{% if cls.isMultipleApply %}
|
||||
arg("instanceName")=TfToken(),
|
||||
{% endif %}
|
||||
return_value_policy<TfPySequenceToList>())
|
||||
.staticmethod("GetSchemaAttributeNames")
|
||||
|
||||
.def("_GetStaticTfType", (TfType const &(*)()) TfType::Find<This>,
|
||||
return_value_policy<return_by_value>())
|
||||
.staticmethod("_GetStaticTfType")
|
||||
|
||||
.def(!self)
|
||||
|
||||
{% for attrName in cls.attrOrder -%}
|
||||
{% set attr = cls.attrs[attrName] %}
|
||||
{# Only emit Create/Get API if apiName is not empty string. #}
|
||||
{% if attr.apiName != '' %}
|
||||
|
||||
.def("Get{{ Proper(attr.apiName) }}Attr",
|
||||
&This::Get{{ Proper(attr.apiName) }}Attr)
|
||||
.def("Create{{ Proper(attr.apiName) }}Attr",
|
||||
&_Create{{ Proper(attr.apiName) }}Attr,
|
||||
(arg("defaultValue")=object(),
|
||||
arg("writeSparsely")=false))
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% for relName in cls.relOrder -%}
|
||||
{# Only emit Create/Get API and doxygen if apiName is not empty string. #}
|
||||
{% set rel = cls.rels[relName] %}
|
||||
{% if rel.apiName != '' %}
|
||||
|
||||
.def("Get{{ Proper(rel.apiName) }}Rel",
|
||||
&This::Get{{ Proper(rel.apiName) }}Rel)
|
||||
.def("Create{{ Proper(rel.apiName) }}Rel",
|
||||
&This::Create{{ Proper(rel.apiName) }}Rel)
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if cls.isMultipleApply and cls.propertyNamespacePrefix %}
|
||||
.def("Is{{ cls.usdPrimTypeName }}Path", _WrapIs{{ cls.usdPrimTypeName }}Path)
|
||||
.staticmethod("Is{{ cls.usdPrimTypeName }}Path")
|
||||
{% endif %}
|
||||
{% if not cls.isAPISchemaBase %}
|
||||
.def("__repr__", ::_Repr)
|
||||
{% endif %}
|
||||
;
|
||||
|
||||
_CustomWrapCode(cls);
|
||||
}
|
||||
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator. The entry point for your custom code should look
|
||||
// minimally like the following:
|
||||
//
|
||||
// WRAP_CUSTOM {
|
||||
// _class
|
||||
// .def("MyCustomMethod", ...)
|
||||
// ;
|
||||
// }
|
||||
//
|
||||
// Of course any other ancillary or support code may be provided.
|
||||
{% if useExportAPI %}
|
||||
//
|
||||
// Just remember to wrap code in the appropriate delimiters:
|
||||
// 'namespace {', '}'.
|
||||
//
|
||||
{% endif %}
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
// GENERATED FILE. DO NOT EDIT.
|
||||
#include <boost/python/class.hpp>
|
||||
#include "{{ libraryPath }}/tokens.h"
|
||||
|
||||
{% if useExportAPI %}
|
||||
{{ namespaceUsing }}
|
||||
|
||||
{% endif %}
|
||||
namespace {
|
||||
|
||||
// Helper to return a static token as a string. We wrap tokens as Python
|
||||
// strings and for some reason simply wrapping the token using def_readonly
|
||||
// bypasses to-Python conversion, leading to the error that there's no
|
||||
// Python type for the C++ TfToken type. So we wrap this functor instead.
|
||||
class _WrapStaticToken {
|
||||
public:
|
||||
_WrapStaticToken(const TfToken* token) : _token(token) { }
|
||||
|
||||
std::string operator()() const
|
||||
{
|
||||
return _token->GetString();
|
||||
}
|
||||
|
||||
private:
|
||||
const TfToken* _token;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
_AddToken(T& cls, const char* name, const TfToken& token)
|
||||
{
|
||||
cls.add_static_property(name,
|
||||
boost::python::make_function(
|
||||
_WrapStaticToken(&token),
|
||||
boost::python::return_value_policy<
|
||||
boost::python::return_by_value>(),
|
||||
boost::mpl::vector1<std::string>()));
|
||||
}
|
||||
|
||||
} // anonymous
|
||||
|
||||
void wrap{{ tokensPrefix }}Tokens()
|
||||
{
|
||||
boost::python::class_<{{ tokensPrefix }}TokensType, boost::noncopyable>
|
||||
cls("Tokens", boost::python::no_init);
|
||||
{% for token in tokens %}
|
||||
_AddToken(cls, "{{ token.id }}", {{ tokensPrefix }}Tokens->{{ token.id }});
|
||||
{% endfor %}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"WARNING: THIS FILE IS GENERATED BY usdGenSchema. DO NOT EDIT."
|
||||
customLayerData = {
|
||||
dictionary multipleApplyAPISchemas = {
|
||||
string CollectionAPI = "collection"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
class "APISchemaBase" (
|
||||
doc = """The base class for all API schemas.
|
||||
|
||||
An API schema provides an interface to a prim's qualities, but does not
|
||||
specify a typeName for the underlying prim. The prim's qualities include
|
||||
its inheritance structure, attributes, relationships etc. Since it cannot
|
||||
provide a typeName, an API schema is considered to be non-concrete.
|
||||
|
||||
To auto-generate an API schema using usdGenSchema, simply leave the
|
||||
typeName empty and make it inherit from \"/APISchemaBase\" or from another
|
||||
API schema. See UsdModelAPI, UsdClipsAPI and UsdCollectionAPI for examples.
|
||||
|
||||
API schemas are classified into applied and non-applied API schemas.
|
||||
The author of an API schema has to decide on the type of API schema
|
||||
at the time of its creation by setting customData['apiSchemaType'] in the
|
||||
schema definition (i.e. in the associated primSpec inside the schema.usda
|
||||
file). UsdAPISchemaBase implements methods that are used to record the
|
||||
application of an API schema on a USD prim.
|
||||
|
||||
If an API schema only provides an interface to set certain core bits of
|
||||
metadata (like UsdModelAPI, which sets model kind and UsdClipsAPI, which
|
||||
sets clips-related metadata) OR if the API schema can apply to any type of
|
||||
prim or only to a known fixed set of prim types OR if there is no use of
|
||||
recording the application of the API schema, in such cases, it would be
|
||||
better to make it a non-applied API schema. Examples of non-applied API
|
||||
schemas include UsdModelAPI, UsdClipsAPI, UsdShadeConnectableAPI and
|
||||
UsdGeomPrimvarsAPI.
|
||||
|
||||
If there is a need to discover (or record) whether a prim contains or
|
||||
subscribes to a given API schema, it would be advantageous to make the API
|
||||
schema be \"applied\". In general, API schemas that add one or more properties
|
||||
to a prim should be tagged as applied API schemas. A public Apply() method
|
||||
is generated for applied API schemas by usdGenSchema. An applied API schema
|
||||
must be applied to a prim via a call to the generated Apply() method, for
|
||||
the schema object to evaluate to true when converted to a bool using the
|
||||
explicit bool conversion operator. Examples of applied API schemas include
|
||||
UsdCollectionAPI, UsdGeomModelAPI and UsdGeomMotionAPI
|
||||
|
||||
\\anchor UsdAPISchemaBase_SingleVsMultipleApply
|
||||
\\name Single vs. Multiple Apply API Schemas
|
||||
|
||||
Applied API schemas can further be classified into single-apply and
|
||||
multiple-apply API schemas. As the name suggests, a single-apply API schema
|
||||
can only be applied once to a prim. A multiple-apply API schema can be
|
||||
applied multiple times with different 'instanceName' values. An example of
|
||||
a multiple-apply API schema is UsdCollectionAPI, where the API schema is
|
||||
applied to a prim once for every collection owned by the prim.
|
||||
|
||||
\\note An applied API schema can only inherit from another applied API
|
||||
schema or directly from APISchemaBase. Similarly, a non-applied API schema
|
||||
can only inherit from a non-applied API Schema or directly from
|
||||
APISchemaBase. 'usdGenSchema' attempts to issue a warning if it detects
|
||||
an incompatibility.
|
||||
|
||||
\\note A multiple-apply API schema may not inherit from a single-apply API
|
||||
schema and vice versa.
|
||||
|
||||
\\note When the bool-conversion operator is invoked on an applied API
|
||||
schema, it evaluates to true only if the application of the API schema has
|
||||
been recorded on the prim via a call to the auto-generated Apply() method.
|
||||
|
||||
"""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "ModelAPI" (
|
||||
doc = """UsdModelAPI is an API schema that provides an interface to a prim's
|
||||
model qualities, if it does, in fact, represent the root prim of a model.
|
||||
|
||||
The first and foremost model quality is its kind, i.e. the metadata
|
||||
that establishes it as a model (See KindRegistry). UsdModelAPI provides
|
||||
various methods for setting and querying the prim's kind, as well as
|
||||
queries (also available on UsdPrim) for asking what category of model
|
||||
the prim is. See \"Kind and Model-ness\".
|
||||
|
||||
UsdModelAPI also provides access to a prim's \"assetInfo\"
|
||||
data. While any prim can host assetInfo, it is common that published
|
||||
(referenced) assets are packaged as models, therefore it is convenient
|
||||
to provide access to the one from the other.
|
||||
|
||||
\\todo establish an _IsCompatible() override that returns IsModel()
|
||||
\\todo GetModelInstanceName()
|
||||
"""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "CollectionAPI" (
|
||||
doc = """ This is a general purpose API schema, used to describe a
|
||||
collection of heterogeneous objects within the scene. \"Objects\" here may be
|
||||
prims or properties belonging to prims or other collections. It's an add-on
|
||||
schema that can be applied many times to a prim with different collection
|
||||
names.
|
||||
|
||||
A collection allows an enumeration of a set of paths to include and a
|
||||
set of paths to exclude. Whether the descendants of an included
|
||||
path are members of a collection are decided by its expansion rule
|
||||
(see below). If the collection excludes paths that are not descendents
|
||||
of included paths, the collection implicitly includes the root path
|
||||
</>. If such a collection also includes paths that are not
|
||||
descendants of the excluded paths, it is considered invalid, since
|
||||
the intention is ambiguous.
|
||||
|
||||
All the properties authored by the schema are namespaced under
|
||||
\"collection:\". The given name of the collection provides additional
|
||||
namespacing for the various per-collection properties, which include the
|
||||
following:
|
||||
|
||||
<ul><li><b>uniform token collection:<i>collectionName</i>:expansionRule</b> -
|
||||
specified how the paths that are included in the collection must be expanded
|
||||
to determine its members. Possible values include:
|
||||
<ul>
|
||||
<li><b>explicitOnly</b> - only paths in the includes rel targets and not
|
||||
in the excludes rel targets belong to the collection.
|
||||
</li>
|
||||
<li><b>expandPrims</b> - all the prims at or below the includes rel-
|
||||
targets (and not under the excludes rel-targets) belong to the
|
||||
collection. Any property paths included in the collection would, of
|
||||
course, also be honored. This is the default behavior as it satisfies
|
||||
most use cases.
|
||||
</li>
|
||||
<li><b>expandPrimsAndProperties</b> - like expandPrims, but also
|
||||
includes all properties on all matched prims. We're still not quite
|
||||
sure what the use cases are for this, but you can use it to capture a
|
||||
whole lot of UsdObjects very concisely.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><b>bool collection:<i>collectionName</i>:includeRoot</b> - boolean
|
||||
attribute indicating whether the pseudo-root path </> should
|
||||
be counted as one of the included target paths. The fallback is false.
|
||||
This separate attribute is required because relationships cannot
|
||||
directly target the root.
|
||||
<li><b>rel collection:<i>collectionName</i>:includes</b> - specifies a list
|
||||
of targets that are included in the collection. This can target prims or
|
||||
properties directly. A collection can insert the rules of another
|
||||
collection by making its <i>includes</i> relationship target the
|
||||
<b>collection:{collectionName}</b> property on the owning prim of the
|
||||
collection to be included.
|
||||
Such a property may not (and typically does not) exist on the UsdStage, but
|
||||
it is the path that is used to refer to the collection.
|
||||
It is important to note that including another collection does not
|
||||
guarantee the contents of that collection will be in the final collection;
|
||||
instead, the rules are merged. This means, for example, an exclude
|
||||
entry may exclude a portion of the included collection.
|
||||
When a collection includes one or more collections, the order in which
|
||||
targets are added to the includes relationship may become significant, if
|
||||
there are conflicting opinions about the same path. Targets that are added
|
||||
later are considered to be stronger than earlier targets for the same path.
|
||||
</li>
|
||||
<li><b>rel collection:<i>collectionName</i>:excludes</b> - specifies a list
|
||||
of targets that are excluded below the <b>included</b> paths in this
|
||||
collection. This can target prims or properties directly, but <b>cannot
|
||||
target another collection</b>. This is to keep the membership determining
|
||||
logic simple, efficient and easier to reason about. Finally, it is invalid
|
||||
for a collection to exclude paths that are not included in it. The presence
|
||||
of such \"orphaned\" excluded paths will not affect the set of paths included
|
||||
in the collection, but may affect the performance of querying membership of
|
||||
a path in the collection (see UsdCollectionAPI::MembershipQuery::IsPathIncluded)
|
||||
or of enumerating the objects belonging to the collection (see
|
||||
UsdCollectionAPI::GetIncludedObjects).
|
||||
</li></ul>
|
||||
|
||||
<b>Implicit inclusion</b>
|
||||
|
||||
In some scenarios it is useful to express a collection that includes
|
||||
everything except certain paths. To support this, a collection
|
||||
that has an exclude that is not a descendent of any include
|
||||
will include the root path </>.
|
||||
|
||||
<b>Creating collections in C++</b>
|
||||
|
||||
\\snippet examples.cpp ApplyCollections
|
||||
"""
|
||||
)
|
||||
{
|
||||
rel excludes (
|
||||
doc = '''Specifies a list of targets that are excluded below
|
||||
the included paths in this collection. This can target prims or
|
||||
properties directly, but cannot target another collection. This is to
|
||||
keep the membership determining logic simple, efficient and easier to
|
||||
reason about. Finally, it is invalid for a collection to exclude
|
||||
paths that are not included in it. The presence of such "orphaned"
|
||||
excluded paths will not affect the set of paths included in the
|
||||
collection, but may affect the performance of querying membership of
|
||||
a path in the collection (see
|
||||
UsdCollectionAPI::MembershipQuery::IsPathIncluded)
|
||||
or of enumerating the objects belonging to the collection (see
|
||||
UsdCollectionAPI::GetIncludedObjects).'''
|
||||
)
|
||||
uniform token expansionRule = "expandPrims" (
|
||||
allowedTokens = ["explicitOnly", "expandPrims", "expandPrimsAndProperties"]
|
||||
doc = """Specifies how the paths that are included in
|
||||
the collection must be expanded to determine its members."""
|
||||
)
|
||||
uniform bool includeRoot (
|
||||
doc = """Boolean attribute indicating whether the pseudo-root
|
||||
path </> should be counted as one of the included target
|
||||
paths. The fallback is false. This separate attribute is
|
||||
required because relationships cannot directly target the root."""
|
||||
)
|
||||
rel includes (
|
||||
doc = """Specifies a list of targets that are included in the collection.
|
||||
This can target prims or properties directly. A collection can insert
|
||||
the rules of another collection by making its <i>includes</i>
|
||||
relationship target the <b>collection:{collectionName}</b> property on
|
||||
the owning prim of the collection to be included"""
|
||||
)
|
||||
}
|
||||
|
||||
class "ClipsAPI" (
|
||||
doc = """ UsdClipsAPI is an API schema that provides an interface to
|
||||
a prim's clip metadata. Clips are a \"value resolution\" feature that
|
||||
allows one to specify a sequence of usd files (clips) to be consulted,
|
||||
over time, as a source of varying overrides for the prims at and
|
||||
beneath this prim in namespace.
|
||||
|
||||
SetClipAssetPaths() establishes the set of clips that can be consulted.
|
||||
SetClipActive() specifies the ordering of clip application over time
|
||||
(clips can be repeated), while SetClipTimes() specifies time-mapping
|
||||
from stage-time to clip-time for the clip active at a given stage-time,
|
||||
which allows for time-dilation and repetition of clips.
|
||||
Finally, SetClipPrimPath() determines the path within each clip that will
|
||||
map to this prim, i.e. the location within the clip at which we will look
|
||||
for opinions for this prim.
|
||||
|
||||
The clip asset paths, times and active metadata can also be specified
|
||||
through template clip metadata. This can be desirable when your set of
|
||||
assets is very large, as the template metadata is much more concise.
|
||||
SetClipTemplateAssetPath() establishes the asset identifier pattern of the
|
||||
set of clips to be consulted. SetClipTemplateStride(),
|
||||
SetClipTemplateEndTime(), and SetClipTemplateStartTime() specify the range
|
||||
in which USD will search, based on the template. From the set of resolved
|
||||
asset paths, times and active will be derived internally.
|
||||
|
||||
A prim may have multiple \"clip sets\" -- named sets of clips that each
|
||||
have their own values for the metadata described above. For example,
|
||||
a prim might have a clip set named \"Clips_1\" that specifies some group
|
||||
of clip asset paths, and another clip set named \"Clips_2\" that uses
|
||||
an entirely different set of clip asset paths. These clip sets are
|
||||
composed across composition arcs, so clip sets for a prim may be
|
||||
defined in multiple sublayers or references, for example. Individual
|
||||
metadata for a given clip set may be sparsely overridden.
|
||||
|
||||
Important facts about clips:
|
||||
- Within the layerstack in which clips are established, the
|
||||
opinions within the clips will be weaker than any local opinions
|
||||
in the layerstack, but em stronger than varying opinions coming across
|
||||
references and variants.
|
||||
- We will never look for metadata or default opinions in clips
|
||||
when performing value resolution on the owning stage, since these
|
||||
quantities must be time-invariant.
|
||||
|
||||
This leads to the common structure in which we reference a model asset
|
||||
on a prim, and then author clips at the same site: the asset reference
|
||||
will provide the topology and unvarying data for the model, while the
|
||||
clips will provide the time-sampled animation.
|
||||
|
||||
For further information, see \\ref Usd_Page_ValueClips
|
||||
"""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"apiSchemas": {
|
||||
"appliesTo": "prims",
|
||||
"type": "tokenlistop"
|
||||
},
|
||||
"clipSets": {
|
||||
"appliesTo": [
|
||||
"prims"
|
||||
],
|
||||
"type": "stringlistop"
|
||||
},
|
||||
"clips": {
|
||||
"appliesTo": [
|
||||
"prims"
|
||||
],
|
||||
"type": "dictionary"
|
||||
},
|
||||
"fallbackPrimTypes": {
|
||||
"appliesTo": [
|
||||
"layers"
|
||||
],
|
||||
"type": "dictionary"
|
||||
}
|
||||
},
|
||||
"Types": {
|
||||
"UsdAPISchemaBase": {
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdSchemaBase"
|
||||
],
|
||||
"schemaKind": "abstractBase"
|
||||
},
|
||||
"UsdClipsAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "ClipsAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "nonAppliedAPI"
|
||||
},
|
||||
"UsdCollectionAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "CollectionAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "multipleApplyAPI"
|
||||
},
|
||||
"UsdModelAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "ModelAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "nonAppliedAPI"
|
||||
},
|
||||
"UsdSchemaBase": {},
|
||||
"UsdTyped": {
|
||||
"bases": [
|
||||
"UsdSchemaBase"
|
||||
]
|
||||
},
|
||||
"UsdUsdFileFormat": {
|
||||
"bases": [
|
||||
"SdfFileFormat"
|
||||
],
|
||||
"displayName": "USD File Format",
|
||||
"extensions": [
|
||||
"usd"
|
||||
],
|
||||
"formatId": "usd",
|
||||
"primary": true,
|
||||
"target": "usd"
|
||||
},
|
||||
"UsdUsdaFileFormat": {
|
||||
"bases": [
|
||||
"SdfTextFileFormat"
|
||||
],
|
||||
"displayName": "USD Text File Format",
|
||||
"extensions": [
|
||||
"usda"
|
||||
],
|
||||
"formatId": "usda",
|
||||
"primary": true,
|
||||
"target": "usd"
|
||||
},
|
||||
"UsdUsdcFileFormat": {
|
||||
"bases": [
|
||||
"SdfFileFormat"
|
||||
],
|
||||
"displayName": "USD Crate File Format",
|
||||
"extensions": [
|
||||
"usdc"
|
||||
],
|
||||
"formatId": "usdc",
|
||||
"primary": true,
|
||||
"target": "usd"
|
||||
},
|
||||
"UsdUsdzFileFormat": {
|
||||
"bases": [
|
||||
"SdfFileFormat"
|
||||
],
|
||||
"displayName": "USDZ File Format",
|
||||
"extensions": [
|
||||
"usdz"
|
||||
],
|
||||
"formatId": "usdz",
|
||||
"primary": true,
|
||||
"target": "usd"
|
||||
},
|
||||
"Usd_UsdzResolver": {
|
||||
"bases": [
|
||||
"ArPackageResolver"
|
||||
],
|
||||
"extensions": [
|
||||
"usdz"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usd.dll",
|
||||
"Name": "usd",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"This file describes the USD primitive schemata and drives code generation."
|
||||
)
|
||||
|
||||
def "GLOBAL" (
|
||||
customData = {
|
||||
string libraryName = "usd"
|
||||
string libraryPath = "pxr/usd/usd"
|
||||
# string libraryPrefix = "Usd"
|
||||
# string tokensPrefix = "Usd"
|
||||
dictionary libraryTokens = {
|
||||
dictionary apiSchemas = {
|
||||
string doc = """
|
||||
A listop metadata containing the API schemas which have
|
||||
been applied to this prim, using the Apply() method on
|
||||
the particular schema class.
|
||||
"""
|
||||
}
|
||||
dictionary fallbackPrimTypes = {
|
||||
string doc = """
|
||||
A dictionary metadata that maps the name of a concrete schema
|
||||
prim type to an ordered list of schema prim types to use instead
|
||||
if the schema prim type doesn't exist in version of USD being
|
||||
used.
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "Typed"
|
||||
(
|
||||
doc = """The base class for all \\em typed schemas (those that can impart a
|
||||
typeName to a UsdPrim), and therefore the base class for all
|
||||
concrete, instantiable "IsA" schemas.
|
||||
|
||||
UsdTyped implements a typeName-based query for its override of
|
||||
UsdSchemaBase::_IsCompatible(). It provides no other behavior."""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "APISchemaBase"
|
||||
(
|
||||
doc = """The base class for all \\em API schemas.
|
||||
|
||||
An API schema provides an interface to a prim's qualities, but does not
|
||||
specify a typeName for the underlying prim. The prim's qualities include
|
||||
its inheritance structure, attributes, relationships etc. Since it cannot
|
||||
provide a typeName, an API schema is considered to be non-concrete.
|
||||
|
||||
To auto-generate an API schema using usdGenSchema, simply leave the
|
||||
typeName empty and make it inherit from "/APISchemaBase" or from another
|
||||
API schema. See UsdModelAPI, UsdClipsAPI and UsdCollectionAPI for examples.
|
||||
|
||||
API schemas are classified into applied and non-applied API schemas.
|
||||
The author of an API schema has to decide on the type of API schema
|
||||
at the time of its creation by setting customData['apiSchemaType'] in the
|
||||
schema definition (i.e. in the associated primSpec inside the schema.usda
|
||||
file). UsdAPISchemaBase implements methods that are used to record the
|
||||
application of an API schema on a USD prim.
|
||||
|
||||
If an API schema only provides an interface to set certain core bits of
|
||||
metadata (like UsdModelAPI, which sets model kind and UsdClipsAPI, which
|
||||
sets clips-related metadata) OR if the API schema can apply to any type of
|
||||
prim or only to a known fixed set of prim types OR if there is no use of
|
||||
recording the application of the API schema, in such cases, it would be
|
||||
better to make it a non-applied API schema. Examples of non-applied API
|
||||
schemas include UsdModelAPI, UsdClipsAPI, UsdShadeConnectableAPI and
|
||||
UsdGeomPrimvarsAPI.
|
||||
|
||||
If there is a need to discover (or record) whether a prim contains or
|
||||
subscribes to a given API schema, it would be advantageous to make the API
|
||||
schema be "applied". In general, API schemas that add one or more properties
|
||||
to a prim should be tagged as applied API schemas. A public Apply() method
|
||||
is generated for applied API schemas by usdGenSchema. An applied API schema
|
||||
must be applied to a prim via a call to the generated Apply() method, for
|
||||
the schema object to evaluate to true when converted to a bool using the
|
||||
explicit bool conversion operator. Examples of applied API schemas include
|
||||
UsdCollectionAPI, UsdGeomModelAPI and UsdGeomMotionAPI
|
||||
|
||||
\\anchor UsdAPISchemaBase_SingleVsMultipleApply
|
||||
\\name Single vs. Multiple Apply API Schemas
|
||||
|
||||
Applied API schemas can further be classified into single-apply and
|
||||
multiple-apply API schemas. As the name suggests, a single-apply API schema
|
||||
can only be applied once to a prim. A multiple-apply API schema can be
|
||||
applied multiple times with different 'instanceName' values. An example of
|
||||
a multiple-apply API schema is UsdCollectionAPI, where the API schema is
|
||||
applied to a prim once for every collection owned by the prim.
|
||||
|
||||
\\note An applied API schema can only inherit from another applied API
|
||||
schema or directly from APISchemaBase. Similarly, a non-applied API schema
|
||||
can only inherit from a non-applied API Schema or directly from
|
||||
APISchemaBase. 'usdGenSchema' attempts to issue a warning if it detects
|
||||
an incompatibility.
|
||||
|
||||
\\note A multiple-apply API schema may not inherit from a single-apply API
|
||||
schema and vice versa.
|
||||
|
||||
\\note When the bool-conversion operator is invoked on an applied API
|
||||
schema, it evaluates to true only if the application of the API schema has
|
||||
been recorded on the prim via a call to the auto-generated Apply() method.
|
||||
|
||||
"""
|
||||
customData = {
|
||||
string fileName = "apiSchemaBase"
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "ModelAPI"
|
||||
(
|
||||
inherits = </APISchemaBase>
|
||||
doc = """UsdModelAPI is an API schema that provides an interface to a prim's
|
||||
model qualities, if it does, in fact, represent the root prim of a model.
|
||||
|
||||
The first and foremost model quality is its \\em kind, i.e. the metadata
|
||||
that establishes it as a model (See KindRegistry). UsdModelAPI provides
|
||||
various methods for setting and querying the prim's kind, as well as
|
||||
queries (also available on UsdPrim) for asking what category of model
|
||||
the prim is. See \\ref Usd_ModelKind "Kind and Model-ness".
|
||||
|
||||
UsdModelAPI also provides access to a prim's \\ref Usd_Model_AssetInfo "assetInfo"
|
||||
data. While any prim \\em can host assetInfo, it is common that published
|
||||
(referenced) assets are packaged as models, therefore it is convenient
|
||||
to provide access to the one from the other.
|
||||
|
||||
\\todo establish an _IsCompatible() override that returns IsModel()
|
||||
\\todo GetModelInstanceName()
|
||||
"""
|
||||
customData = {
|
||||
string apiSchemaType = "nonApplied"
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "CollectionAPI"
|
||||
(
|
||||
inherits = </APISchemaBase>
|
||||
doc = """ This is a general purpose API schema, used to describe a
|
||||
collection of heterogeneous objects within the scene. "Objects" here may be
|
||||
prims or properties belonging to prims or other collections. It's an add-on
|
||||
schema that can be applied many times to a prim with different collection
|
||||
names.
|
||||
|
||||
A collection allows an enumeration of a set of paths to include and a
|
||||
set of paths to exclude. Whether the descendants of an included
|
||||
path are members of a collection are decided by its expansion rule
|
||||
(see below). If the collection excludes paths that are not descendents
|
||||
of included paths, the collection implicitly includes the root path
|
||||
</>. If such a collection also includes paths that are not
|
||||
descendants of the excluded paths, it is considered invalid, since
|
||||
the intention is ambiguous.
|
||||
|
||||
All the properties authored by the schema are namespaced under
|
||||
"collection:". The given name of the collection provides additional
|
||||
namespacing for the various per-collection properties, which include the
|
||||
following:
|
||||
|
||||
<ul><li><b>uniform token collection:<i>collectionName</i>:expansionRule</b> -
|
||||
specified how the paths that are included in the collection must be expanded
|
||||
to determine its members. Possible values include:
|
||||
<ul>
|
||||
<li><b>explicitOnly</b> - only paths in the includes rel targets and not
|
||||
in the excludes rel targets belong to the collection.
|
||||
</li>
|
||||
<li><b>expandPrims</b> - all the prims at or below the includes rel-
|
||||
targets (and not under the excludes rel-targets) belong to the
|
||||
collection. Any property paths included in the collection would, of
|
||||
course, also be honored. This is the default behavior as it satisfies
|
||||
most use cases.
|
||||
</li>
|
||||
<li><b>expandPrimsAndProperties</b> - like expandPrims, but also
|
||||
includes all properties on all matched prims. We're still not quite
|
||||
sure what the use cases are for this, but you can use it to capture a
|
||||
whole lot of UsdObjects very concisely.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><b>bool collection:<i>collectionName</i>:includeRoot</b> - boolean
|
||||
attribute indicating whether the pseudo-root path </> should
|
||||
be counted as one of the included target paths. The fallback is false.
|
||||
This separate attribute is required because relationships cannot
|
||||
directly target the root.
|
||||
<li><b>rel collection:<i>collectionName</i>:includes</b> - specifies a list
|
||||
of targets that are included in the collection. This can target prims or
|
||||
properties directly. A collection can insert the rules of another
|
||||
collection by making its <i>includes</i> relationship target the
|
||||
<b>collection:{collectionName}</b> property on the owning prim of the
|
||||
collection to be included.
|
||||
Such a property may not (and typically does not) exist on the UsdStage, but
|
||||
it is the path that is used to refer to the collection.
|
||||
It is important to note that including another collection does not
|
||||
guarantee the contents of that collection will be in the final collection;
|
||||
instead, the rules are merged. This means, for example, an exclude
|
||||
entry may exclude a portion of the included collection.
|
||||
When a collection includes one or more collections, the order in which
|
||||
targets are added to the includes relationship may become significant, if
|
||||
there are conflicting opinions about the same path. Targets that are added
|
||||
later are considered to be stronger than earlier targets for the same path.
|
||||
</li>
|
||||
<li><b>rel collection:<i>collectionName</i>:excludes</b> - specifies a list
|
||||
of targets that are excluded below the <b>included</b> paths in this
|
||||
collection. This can target prims or properties directly, but <b>cannot
|
||||
target another collection</b>. This is to keep the membership determining
|
||||
logic simple, efficient and easier to reason about. Finally, it is invalid
|
||||
for a collection to exclude paths that are not included in it. The presence
|
||||
of such "orphaned" excluded paths will not affect the set of paths included
|
||||
in the collection, but may affect the performance of querying membership of
|
||||
a path in the collection (see UsdCollectionAPI::MembershipQuery::IsPathIncluded)
|
||||
or of enumerating the objects belonging to the collection (see
|
||||
UsdCollectionAPI::GetIncludedObjects).
|
||||
</li></ul>
|
||||
|
||||
<b>Implicit inclusion</b>
|
||||
|
||||
In some scenarios it is useful to express a collection that includes
|
||||
everything except certain paths. To support this, a collection
|
||||
that has an exclude that is not a descendent of any include
|
||||
will include the root path </>.
|
||||
|
||||
<b>Creating collections in C++</b>
|
||||
|
||||
\\snippet examples.cpp ApplyCollections
|
||||
"""
|
||||
|
||||
customData = {
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usd/collectionMembershipQuery.h"
|
||||
#include "pxr/usd/usd/primFlags.h"
|
||||
#include "pxr/usd/usd/tokens.h"
|
||||
"""
|
||||
token apiSchemaType = "multipleApply"
|
||||
token propertyNamespacePrefix = "collection"
|
||||
dictionary schemaTokens = {
|
||||
dictionary exclude = {
|
||||
string doc = """
|
||||
This is the token used to exclude a path from a collection.
|
||||
Although it is not a possible value for the "expansionRule"
|
||||
attribute, it is used as the expansionRule for excluded paths
|
||||
in UsdCollectionAPI::MembershipQuery::IsPathIncluded.
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
uniform token expansionRule = "expandPrims" (
|
||||
allowedTokens = ["explicitOnly", "expandPrims", "expandPrimsAndProperties"]
|
||||
doc = """Specifies how the paths that are included in
|
||||
the collection must be expanded to determine its members."""
|
||||
)
|
||||
uniform bool includeRoot (
|
||||
doc = """Boolean attribute indicating whether the pseudo-root
|
||||
path </> should be counted as one of the included target
|
||||
paths. The fallback is false. This separate attribute is
|
||||
required because relationships cannot directly target the root."""
|
||||
)
|
||||
rel includes (
|
||||
doc = """Specifies a list of targets that are included in the collection.
|
||||
This can target prims or properties directly. A collection can insert
|
||||
the rules of another collection by making its <i>includes</i>
|
||||
relationship target the <b>collection:{collectionName}</b> property on
|
||||
the owning prim of the collection to be included"""
|
||||
)
|
||||
rel excludes (
|
||||
doc = """Specifies a list of targets that are excluded below
|
||||
the included paths in this collection. This can target prims or
|
||||
properties directly, but cannot target another collection. This is to
|
||||
keep the membership determining logic simple, efficient and easier to
|
||||
reason about. Finally, it is invalid for a collection to exclude
|
||||
paths that are not included in it. The presence of such "orphaned"
|
||||
excluded paths will not affect the set of paths included in the
|
||||
collection, but may affect the performance of querying membership of
|
||||
a path in the collection (see
|
||||
UsdCollectionAPI::MembershipQuery::IsPathIncluded)
|
||||
or of enumerating the objects belonging to the collection (see
|
||||
UsdCollectionAPI::GetIncludedObjects)."""
|
||||
)
|
||||
}
|
||||
|
||||
class "ClipsAPI"
|
||||
(
|
||||
inherits = </APISchemaBase>
|
||||
doc = """ UsdClipsAPI is an API schema that provides an interface to
|
||||
a prim's clip metadata. Clips are a "value resolution" feature that
|
||||
allows one to specify a sequence of usd files (clips) to be consulted,
|
||||
over time, as a source of varying overrides for the prims at and
|
||||
beneath this prim in namespace.
|
||||
|
||||
SetClipAssetPaths() establishes the set of clips that can be consulted.
|
||||
SetClipActive() specifies the ordering of clip application over time
|
||||
(clips can be repeated), while SetClipTimes() specifies time-mapping
|
||||
from stage-time to clip-time for the clip active at a given stage-time,
|
||||
which allows for time-dilation and repetition of clips.
|
||||
Finally, SetClipPrimPath() determines the path within each clip that will
|
||||
map to this prim, i.e. the location within the clip at which we will look
|
||||
for opinions for this prim.
|
||||
|
||||
The clip asset paths, times and active metadata can also be specified
|
||||
through template clip metadata. This can be desirable when your set of
|
||||
assets is very large, as the template metadata is much more concise.
|
||||
SetClipTemplateAssetPath() establishes the asset identifier pattern of the
|
||||
set of clips to be consulted. SetClipTemplateStride(),
|
||||
SetClipTemplateEndTime(), and SetClipTemplateStartTime() specify the range
|
||||
in which USD will search, based on the template. From the set of resolved
|
||||
asset paths, times and active will be derived internally.
|
||||
|
||||
A prim may have multiple "clip sets" -- named sets of clips that each
|
||||
have their own values for the metadata described above. For example,
|
||||
a prim might have a clip set named "Clips_1" that specifies some group
|
||||
of clip asset paths, and another clip set named "Clips_2" that uses
|
||||
an entirely different set of clip asset paths. These clip sets are
|
||||
composed across composition arcs, so clip sets for a prim may be
|
||||
defined in multiple sublayers or references, for example. Individual
|
||||
metadata for a given clip set may be sparsely overridden.
|
||||
|
||||
Important facts about clips:
|
||||
\\li Within the layerstack in which clips are established, the
|
||||
opinions within the clips will be \\em weaker than any local opinions
|
||||
in the layerstack, but \em stronger than varying opinions coming across
|
||||
references and variants.
|
||||
\\li We will never look for metadata or default opinions in clips
|
||||
when performing value resolution on the owning stage, since these
|
||||
quantities must be time-invariant.
|
||||
|
||||
This leads to the common structure in which we reference a model asset
|
||||
on a prim, and then author clips at the same site: the asset reference
|
||||
will provide the topology and unvarying data for the model, while the
|
||||
clips will provide the time-sampled animation.
|
||||
|
||||
For further information, see \\ref Usd_Page_ValueClips
|
||||
"""
|
||||
customData = {
|
||||
token apiSchemaType = "nonApplied"
|
||||
dictionary schemaTokens = {
|
||||
dictionary clips = {
|
||||
string doc = """
|
||||
Dictionary that contains the definition of the clip sets on
|
||||
this prim. See \\ref UsdClipsAPI::GetClips.
|
||||
"""
|
||||
}
|
||||
|
||||
dictionary clipSets = {
|
||||
string doc = """
|
||||
ListOp that may be used to affect how opinions from
|
||||
clip sets are applied during value resolution.
|
||||
See \\ref UsdClipsAPI::GetClipSets.
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,359 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"constraintTargetIdentifier": {
|
||||
"appliesTo": [
|
||||
"attributes"
|
||||
],
|
||||
"default": "",
|
||||
"documentation": "Unique identifier within a model's namespace for an matrix-valued attribute representing a constraint target",
|
||||
"type": "token"
|
||||
},
|
||||
"elementSize": {
|
||||
"appliesTo": [
|
||||
"attributes"
|
||||
],
|
||||
"default": 1,
|
||||
"displayGroup": "Primvars",
|
||||
"documentation": "The number of values in a primvar's value array that must be aggregated for each element on the primitive.",
|
||||
"type": "int"
|
||||
},
|
||||
"inactiveIds": {
|
||||
"appliesTo": [
|
||||
"prims"
|
||||
],
|
||||
"type": "int64listop"
|
||||
},
|
||||
"interpolation": {
|
||||
"appliesTo": [
|
||||
"attributes"
|
||||
],
|
||||
"default": "constant",
|
||||
"displayGroup": "Primvars",
|
||||
"documentation": "How a primvar interpolates across a primitive; equivalent to RenderMan's 'class specifier'",
|
||||
"type": "token"
|
||||
},
|
||||
"metersPerUnit": {
|
||||
"appliesTo": [
|
||||
"layers"
|
||||
],
|
||||
"default": 0.01,
|
||||
"displayGroup": "Stage",
|
||||
"type": "double"
|
||||
},
|
||||
"unauthoredValuesIndex": {
|
||||
"appliesTo": [
|
||||
"attributes"
|
||||
],
|
||||
"default": -1,
|
||||
"displayGroup": "Primvars",
|
||||
"documentation": "The index that represents unauthored values in the indices array of an indexed primvar.",
|
||||
"type": "int"
|
||||
},
|
||||
"upAxis": {
|
||||
"appliesTo": [
|
||||
"layers"
|
||||
],
|
||||
"default": "Y",
|
||||
"displayGroup": "Stage",
|
||||
"type": "token"
|
||||
}
|
||||
},
|
||||
"Types": {
|
||||
"UsdGeomBasisCurves": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "BasisCurves"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomCurves"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomBoundable": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Boundable"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomXformable"
|
||||
],
|
||||
"schemaKind": "abstractTyped"
|
||||
},
|
||||
"UsdGeomCamera": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Camera"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomXformable"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomCapsule": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Capsule"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomGprim"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomCone": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Cone"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomGprim"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomCube": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Cube"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomGprim"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomCurves": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Curves"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomPointBased"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "abstractTyped"
|
||||
},
|
||||
"UsdGeomCylinder": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Cylinder"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomGprim"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomGprim": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Gprim"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomBoundable"
|
||||
],
|
||||
"schemaKind": "abstractTyped"
|
||||
},
|
||||
"UsdGeomHermiteCurves": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "HermiteCurves"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomCurves"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomImageable": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Imageable"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "abstractTyped"
|
||||
},
|
||||
"UsdGeomMesh": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Mesh"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomPointBased"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomModelAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "GeomModelAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdGeomMotionAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "MotionAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdGeomNurbsCurves": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "NurbsCurves"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomCurves"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomNurbsPatch": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "NurbsPatch"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomPointBased"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomPointBased": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PointBased"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomGprim"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "abstractTyped"
|
||||
},
|
||||
"UsdGeomPointInstancer": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PointInstancer"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomBoundable"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomPoints": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Points"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomPointBased"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomPrimvarsAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PrimvarsAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "nonAppliedAPI"
|
||||
},
|
||||
"UsdGeomScope": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Scope"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomImageable"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomSphere": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Sphere"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomGprim"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomSubset": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "GeomSubset"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomVisibilityAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "VisibilityAPI"
|
||||
},
|
||||
"apiSchemaCanOnlyApplyTo": [
|
||||
"Imageable"
|
||||
],
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdGeomXform": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Xform"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomXformable"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdGeomXformCommonAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "XformCommonAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "nonAppliedAPI"
|
||||
},
|
||||
"UsdGeomXformable": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Xformable"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomImageable"
|
||||
],
|
||||
"schemaKind": "abstractTyped"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdGeom.dll",
|
||||
"Name": "usdGeom",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,22 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"UsdHydraDiscoveryPlugin" : {
|
||||
"bases": ["NdrDiscoveryPlugin"],
|
||||
"displayName": "Discovery plugin for deprecated hydra shaders."
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdHydra.dll",
|
||||
"Name": "usdHydra",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2018 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- This file is intentionally empty.
|
||||
@@ -0,0 +1,252 @@
|
||||
#usda 1.0
|
||||
|
||||
def Shader "HwPtexTexture_1" (
|
||||
sdrMetadata = {
|
||||
token role = "texture"
|
||||
token isPtex = "1"
|
||||
}
|
||||
)
|
||||
{
|
||||
uniform token info:id = "HwPtexTexture_1"
|
||||
uniform token info:implementationSource = "sourceAsset"
|
||||
|
||||
# Add a dummy sourceAsset attribute with sourceType="glslfx", so that
|
||||
# an entry gets created for this deprecated shader in the registry.
|
||||
uniform asset info:glslfx:sourceAsset = @./empty.glslfx@
|
||||
|
||||
token inputs:faceIndexPrimvar = "ptexFaceIndex" (
|
||||
sdrMetadata = {
|
||||
token primvarProperty = "1"
|
||||
}
|
||||
)
|
||||
|
||||
token inputs:faceOffsetPrimvar = "ptexFaceOffset" (
|
||||
sdrMetadata = {
|
||||
token primvarProperty = "1"
|
||||
}
|
||||
)
|
||||
|
||||
asset inputs:file = @@ (
|
||||
doc = "Asset path to the file containg the image data."
|
||||
)
|
||||
|
||||
float inputs:frame (
|
||||
doc = "The frame offset for animated textures."
|
||||
)
|
||||
|
||||
float inputs:textureMemory (
|
||||
doc = """Amount of memory used to store the texture (in Mb). A value of
|
||||
zero specifies the native resolution."""
|
||||
)
|
||||
|
||||
int inputs:faceIndex (
|
||||
doc = """The Ptex face index from which to sample. By default, this
|
||||
parameter will be bound to the ptexFaceIndex primvar."""
|
||||
)
|
||||
|
||||
int inputs:faceOffset (
|
||||
doc = """The Ptex face offset to be applied to the face index. By
|
||||
default, this parameter will be bound to the ptexFaceOffset primvar."""
|
||||
)
|
||||
|
||||
float outputs:r (
|
||||
doc = "Outputs the red channel."
|
||||
sdrMetadata = {
|
||||
token swizzle = "x"
|
||||
}
|
||||
)
|
||||
|
||||
float outputs:g (
|
||||
doc = "Outputs the green channel."
|
||||
sdrMetadata = {
|
||||
token swizzle = "y"
|
||||
}
|
||||
)
|
||||
|
||||
float outputs:b (
|
||||
doc = "Outputs the blue channnel."
|
||||
sdrMetadata = {
|
||||
token swizzle = "z"
|
||||
}
|
||||
)
|
||||
|
||||
float outputs:a (
|
||||
doc = "Outputs the alpha channnel."
|
||||
sdrMetadata = {
|
||||
token swizzle = "w"
|
||||
}
|
||||
)
|
||||
|
||||
float3 outputs:rgb (
|
||||
doc = "Outputs the red, green and blue channels."
|
||||
sdrMetadata = {
|
||||
token swizzle = "xyz"
|
||||
}
|
||||
)
|
||||
|
||||
float4 outputs:rgba (
|
||||
doc = "Outputs all 4 channels (red, green, blue and alpha)."
|
||||
sdrMetadata = {
|
||||
token swizzle = "xyzw"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def Shader "HwUvTexture_1" (
|
||||
sdrMetadata = {
|
||||
token role = "texture"
|
||||
token primvars = "uv"
|
||||
}
|
||||
)
|
||||
{
|
||||
uniform token info:id = "HwUvTexture_1"
|
||||
uniform token info:implementationSource = "sourceAsset"
|
||||
|
||||
# Add a dummy sourceAsset attribute with sourceType="glslfx", so that
|
||||
# an entry gets created for this deprecated shader in the registry.
|
||||
uniform asset info:glslfx:sourceAsset = @./empty.glslfx@
|
||||
|
||||
asset inputs:file = @@ (
|
||||
doc = "Asset path to the file containg the image data."
|
||||
)
|
||||
|
||||
float inputs:frame (
|
||||
doc = "The frame offset for animated textures."
|
||||
)
|
||||
|
||||
float inputs:textureMemory (
|
||||
doc = """Amount of memory used to store the texture (in Mb). A value of
|
||||
zero specifies the native resolution."""
|
||||
)
|
||||
|
||||
float2 inputs:uv (
|
||||
doc = "The uv coordinates at which to sample the texture."
|
||||
)
|
||||
|
||||
token inputs:wrapS (
|
||||
allowedTokens = ["clamp", "repeat", "mirror", "black"]
|
||||
doc = "Specifies the wrap mode for this texture."
|
||||
)
|
||||
|
||||
token inputs:wrapT (
|
||||
allowedTokens = ["clamp", "repeat", "mirror", "black"]
|
||||
doc = "Specifies the wrap mode for this texture."
|
||||
)
|
||||
|
||||
token inputs:minFilter (
|
||||
allowedTokens = ["nearest", "linear",
|
||||
"linearMipmapLinear", "linearMipmapNearest",
|
||||
"nearestMipmapLinear", "nearestMipmapNearest" ]
|
||||
doc = "Specifies the minification filter mode for this texture."
|
||||
)
|
||||
|
||||
token inputs:magFilter (
|
||||
allowedTokens = ["nearest", "linear"]
|
||||
doc = "Specifies the magnification filter mode for this texture."
|
||||
)
|
||||
|
||||
float4 inputs:fallback = (0.0, 0.0, 0.0, 1.0) (
|
||||
doc = """Fallback value to be used when no texture is connected."""
|
||||
sdrMetadata = {
|
||||
token defaultInput = "1"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def Shader "HwFieldReader_1" (
|
||||
sdrMetadata = {
|
||||
token role = "field"
|
||||
}
|
||||
doc = """Samples from a usdVol FieldAsset."""
|
||||
)
|
||||
{
|
||||
uniform asset info:glslfx:sourceAsset = @./empty.glslfx@
|
||||
uniform token info:implementationSource = "sourceAsset"
|
||||
token inputs:fieldname = "" (
|
||||
connectability = "interfaceOnly"
|
||||
doc = """Name of the field to be fetched from volume
|
||||
(e.g., FOO if the relationship from the volume to field is called field::FOO)."""
|
||||
sdrMetadata = {
|
||||
token fieldProperty = "1"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def Shader "HwFieldReader_float" (
|
||||
inherits = </HwFieldReader_1>
|
||||
)
|
||||
{
|
||||
uniform token info:id = "HwFieldReader_float"
|
||||
float inputs:fallback = 0 (
|
||||
doc = "Fallback value to be returned when fetch failed."
|
||||
sdrMetadata = {
|
||||
token defaultInput = "1"
|
||||
}
|
||||
)
|
||||
float outputs:result (
|
||||
sdrMetadata = {
|
||||
token swizzle = "x"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def Shader "HwFieldReader_float2" (
|
||||
inherits = </HwFieldReader_1>
|
||||
)
|
||||
{
|
||||
uniform token info:id = "HwFieldReader_float2"
|
||||
float2 inputs:fallback = (0, 0) (
|
||||
doc = "Fallback value to be returned when fetch failed."
|
||||
sdrMetadata = {
|
||||
token defaultInput = "1"
|
||||
}
|
||||
)
|
||||
float2 outputs:result (
|
||||
sdrMetadata = {
|
||||
token swizzle = "xy"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def Shader "HwFieldReader_float3" (
|
||||
inherits = </HwFieldReader_1>
|
||||
)
|
||||
{
|
||||
uniform token info:id = "HwFieldReader_float3"
|
||||
float3 inputs:fallback = (0, 0, 0) (
|
||||
doc = "Fallback value to be returned when fetch failed."
|
||||
sdrMetadata = {
|
||||
token defaultInput = "1"
|
||||
}
|
||||
)
|
||||
float3 outputs:result (
|
||||
sdrMetadata = {
|
||||
token swizzle = "xyz"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def Shader "HwPrimvar_1" (
|
||||
sdrMetadata = {
|
||||
token role = "primvar"
|
||||
}
|
||||
)
|
||||
{
|
||||
uniform token info:id = "HwPrimvar_1"
|
||||
uniform token info:implementationSource = "sourceAsset"
|
||||
|
||||
# Add a dummy sourceAsset attribute with sourceType="glslfx", so that
|
||||
# an entry gets created for this deprecated shader in the registry.
|
||||
uniform asset info:glslfx:sourceAsset = @./empty.glslfx@
|
||||
|
||||
token inputs:varname = "" (
|
||||
sdrMetadata = {
|
||||
bool primvarProperty = 1
|
||||
}
|
||||
doc = """The name of the primvar. Note that on the gprim, this primvar
|
||||
must follow the standard UsdGeom primvar declaration.
|
||||
Further note that this name should not contain the UsdGeom primvar
|
||||
namespace prefix.
|
||||
"""
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"faceIndexPrimvar": {
|
||||
"appliesTo": [
|
||||
"attributes"
|
||||
],
|
||||
"default": "ptexFaceIndex",
|
||||
"documentation": "Specifies an array of face indices used for ptex mapping",
|
||||
"type": "token"
|
||||
},
|
||||
"faceOffsetPrimvar": {
|
||||
"appliesTo": [
|
||||
"attributes"
|
||||
],
|
||||
"default": "ptexFaceOffset",
|
||||
"documentation": "Specifies the ptex face index offset for aggregated ptex files",
|
||||
"type": "token"
|
||||
},
|
||||
"uvPrimvar": {
|
||||
"appliesTo": [
|
||||
"attributes"
|
||||
],
|
||||
"default": "",
|
||||
"documentation": "Specifies the UV primvar for texture mapping",
|
||||
"type": "token"
|
||||
}
|
||||
},
|
||||
"Types": {
|
||||
"UsdImagingBasisCurvesAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "BasisCurves"
|
||||
},
|
||||
"UsdImagingCameraAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingPrimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Camera"
|
||||
},
|
||||
"UsdImagingCapsuleAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Capsule"
|
||||
},
|
||||
"UsdImagingConeAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Cone"
|
||||
},
|
||||
"UsdImagingCoordSysAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingPrimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "coordSys"
|
||||
},
|
||||
"UsdImagingCubeAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Cube"
|
||||
},
|
||||
"UsdImagingCylinderAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Cylinder"
|
||||
},
|
||||
"UsdImagingHermiteCurvesAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "HermiteCurves"
|
||||
},
|
||||
"UsdImagingMaterialAdapter" : {
|
||||
"bases": ["UsdImagingPrimAdapter"],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Material"
|
||||
},
|
||||
"UsdImagingMeshAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Mesh"
|
||||
},
|
||||
"UsdImagingNurbsCurvesAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "NurbsCurves"
|
||||
},
|
||||
"UsdImagingNurbsPatchAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "NurbsPatch"
|
||||
},
|
||||
"UsdImagingPointsAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Points"
|
||||
},
|
||||
"UsdImagingPointInstancerAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingPrimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "PointInstancer"
|
||||
},
|
||||
"UsdImagingSphereAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Sphere"
|
||||
},
|
||||
"UsdImagingVolumeAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingGprimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Volume"
|
||||
},
|
||||
"UsdImagingLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingPrimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "LightAPI",
|
||||
"includeDerivedPrimTypes" : true
|
||||
},
|
||||
"UsdImagingLightFilterAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingPrimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "LightFilter",
|
||||
"includeDerivedPrimTypes" : true
|
||||
},
|
||||
"UsdImagingDomeLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "DomeLight"
|
||||
},
|
||||
"UsdImagingRectLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "RectLight"
|
||||
},
|
||||
"UsdImagingSphereLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "SphereLight"
|
||||
},
|
||||
"UsdImagingCylinderLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "CylinderLight"
|
||||
},
|
||||
"UsdImagingDiskLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "DiskLight"
|
||||
},
|
||||
"UsdImagingDistantLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "DistantLight"
|
||||
},
|
||||
"UsdImagingPluginLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "PluginLight"
|
||||
},
|
||||
"UsdImagingGeometryLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "GeometryLight"
|
||||
},
|
||||
"UsdImagingPortalLightAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "PortalLight"
|
||||
},
|
||||
"UsdImagingPluginLightFilterAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightFilterAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "PluginLightFilter"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdImaging.dll",
|
||||
"Name": "usdImaging",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"UsdImagingGLDrawModeAdapter" : {
|
||||
"bases": ["UsdImagingPrimAdapter"],
|
||||
"isInternal": true,
|
||||
"primTypeName": "__drawModeAdapter"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdImagingGL.dll",
|
||||
"Name": "usdImagingGL",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"metadata": {
|
||||
"materialTag": "masked"
|
||||
},
|
||||
"techniques": {
|
||||
"default": {
|
||||
"surfaceShader": {
|
||||
"source": ["Surface.Fallback"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": {
|
||||
"textureXPosColor" : {
|
||||
"default": [0.18, 0.18, 0.18]
|
||||
},
|
||||
"textureXPosOpacity" : {
|
||||
"default": [1.0]
|
||||
},
|
||||
"textureXNegColor" : {
|
||||
"default": [0.18, 0.18, 0.18]
|
||||
},
|
||||
"textureXNegOpacity" : {
|
||||
"default": [1.0]
|
||||
},
|
||||
"textureYPosColor" : {
|
||||
"default": [0.18, 0.18, 0.18]
|
||||
},
|
||||
"textureYPosOpacity" : {
|
||||
"default": [1.0]
|
||||
},
|
||||
"textureYNegColor" : {
|
||||
"default": [0.18, 0.18, 0.18]
|
||||
},
|
||||
"textureYNegOpacity" : {
|
||||
"default": [1.0]
|
||||
},
|
||||
"textureZPosColor" : {
|
||||
"default": [0.18, 0.18, 0.18]
|
||||
},
|
||||
"textureZPosOpacity" : {
|
||||
"default": [1.0]
|
||||
},
|
||||
"textureZNegColor" : {
|
||||
"default": [0.18, 0.18, 0.18]
|
||||
},
|
||||
"textureZNegOpacity" : {
|
||||
"default": [1.0]
|
||||
},
|
||||
"activeTexCard" : {
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--- --------------------------------------------------------------------------
|
||||
-- glsl Surface.Fallback
|
||||
|
||||
vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)
|
||||
{
|
||||
// Texture assignment values, from drawModeAdapter.cpp's AxesMask.
|
||||
const int X_POS = 1;
|
||||
const int Y_POS = 2;
|
||||
const int Z_POS = 4;
|
||||
const int X_NEG = 8;
|
||||
const int Y_NEG = 16;
|
||||
const int Z_NEG = 32;
|
||||
|
||||
vec4 diffuse = color;
|
||||
const int texAssign = HdGet_activeTexCard();
|
||||
|
||||
if (texAssign == X_POS) {
|
||||
#if defined(HD_HAS_textureXPosColor) && defined(HD_HAS_textureXPosOpacity)
|
||||
diffuse = vec4(HdGet_textureXPosColor(), HdGet_textureXPosOpacity());
|
||||
#endif
|
||||
} else if (texAssign == X_NEG) {
|
||||
#if defined(HD_HAS_textureXNegColor) && defined(HD_HAS_textureXNegOpacity)
|
||||
diffuse = vec4(HdGet_textureXNegColor(), HdGet_textureXNegOpacity());
|
||||
#endif
|
||||
} else if (texAssign == Y_POS) {
|
||||
#if defined(HD_HAS_textureYPosColor) && defined(HD_HAS_textureYPosOpacity)
|
||||
diffuse = vec4(HdGet_textureYPosColor(), HdGet_textureYPosOpacity());
|
||||
#endif
|
||||
} else if (texAssign == Y_NEG) {
|
||||
#if defined(HD_HAS_textureYNegColor) && defined(HD_HAS_textureYNegOpacity)
|
||||
diffuse = vec4(HdGet_textureYNegColor(), HdGet_textureYNegOpacity());
|
||||
#endif
|
||||
} else if (texAssign == Z_POS) {
|
||||
#if defined(HD_HAS_textureZPosColor) && defined(HD_HAS_textureZPosOpacity)
|
||||
diffuse = vec4(HdGet_textureZPosColor(), HdGet_textureZPosOpacity());
|
||||
#endif
|
||||
} else if (texAssign == Z_NEG) {
|
||||
#if defined(HD_HAS_textureZNegColor) && defined(HD_HAS_textureZNegOpacity)
|
||||
diffuse = vec4(HdGet_textureZNegColor(), HdGet_textureZNegOpacity());
|
||||
#endif
|
||||
}
|
||||
|
||||
// Apply selection pre-lighting
|
||||
diffuse.rgb = ApplyColorOverrides(diffuse.rgbb).rgb;
|
||||
|
||||
color.rgb = FallbackLighting(Peye.xyz, Neye, diffuse.rgb);
|
||||
color.a = diffuse.a;
|
||||
return color;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,224 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"UsdLuxBoundableLightBase": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "BoundableLightBase"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomBoundable"
|
||||
],
|
||||
"schemaKind": "abstractTyped"
|
||||
},
|
||||
"UsdLuxCylinderLight": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "CylinderLight"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdLuxBoundableLightBase"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxDiskLight": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "DiskLight"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdLuxBoundableLightBase"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxDistantLight": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "DistantLight"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdLuxNonboundableLightBase"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxDomeLight": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "DomeLight"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdLuxNonboundableLightBase"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxGeometryLight": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "GeometryLight"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdLuxNonboundableLightBase"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxLightAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "LightAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"providesUsdShadeConnectableAPIBehavior": true,
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdLuxLightFilter": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "LightFilter"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomXformable"
|
||||
],
|
||||
"providesUsdShadeConnectableAPIBehavior": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxListAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "ListAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdLuxMeshLightAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "MeshLightAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdLuxNonboundableLightBase": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "NonboundableLightBase"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomXformable"
|
||||
],
|
||||
"schemaKind": "abstractTyped"
|
||||
},
|
||||
"UsdLuxPluginLight": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PluginLight"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomXformable"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxPluginLightFilter": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PluginLightFilter"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdLuxLightFilter"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxPortalLight": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PortalLight"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdLuxBoundableLightBase"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxRectLight": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "RectLight"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdLuxBoundableLightBase"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxShadowAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "ShadowAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdLuxShapingAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "ShapingAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdLuxSphereLight": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "SphereLight"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdLuxBoundableLightBase"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdLuxVolumeLightAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "VolumeLightAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdLux_DiscoveryPlugin": {
|
||||
"bases": [
|
||||
"NdrDiscoveryPlugin"
|
||||
]
|
||||
},
|
||||
"UsdLux_LightDefParserPlugin": {
|
||||
"bases": [
|
||||
"NdrParserPlugin"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdLux.dll",
|
||||
"Name": "usdLux",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,918 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"This file describes the USD Lux light schemata for code generation."
|
||||
subLayers = [
|
||||
@usdGeom/schema.usda@
|
||||
]
|
||||
)
|
||||
|
||||
over "GLOBAL" (
|
||||
customData = {
|
||||
string libraryName = "usdLux"
|
||||
string libraryPath = "pxr/usd/usdLux"
|
||||
dictionary libraryTokens = {
|
||||
dictionary lightLink = {
|
||||
string doc = """
|
||||
This token represents the collection name to use
|
||||
with UsdCollectionAPI to represent light-linking
|
||||
of a prim with an applied UsdLuxLightAPI.
|
||||
"""
|
||||
}
|
||||
dictionary shadowLink = {
|
||||
string doc = """
|
||||
This token represents the collection name to use
|
||||
with UsdCollectionAPI to represent shadow-linking
|
||||
of a prim with an applied UsdLuxLightAPI.
|
||||
"""
|
||||
}
|
||||
dictionary filterLink = {
|
||||
string doc = """
|
||||
This token represents the collection name to use
|
||||
with UsdCollectionAPI to represent filter-linking
|
||||
of a UsdLuxLightFilter prim.
|
||||
"""
|
||||
}
|
||||
dictionary orientToStageUpAxis = {
|
||||
string doc = """
|
||||
This token represents the suffix for a UsdGeomXformOp
|
||||
used to orient a light with the stage's up axis.
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "LightAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """API schema that imparts the quality of being a light onto a prim.
|
||||
|
||||
A light is any prim that has this schema applied to it. This is true
|
||||
regardless of whether LightAPI is included as a built-in API of the prim
|
||||
type (e.g. RectLight or DistantLight) or is applied directly to a Gprim
|
||||
that should be treated as a light.
|
||||
|
||||
<b>Linking</b>
|
||||
|
||||
Lights can be linked to geometry. Linking controls which geometry
|
||||
a light illuminates, and which geometry casts shadows from the light.
|
||||
|
||||
Linking is specified as collections (UsdCollectionAPI) which can
|
||||
be accessed via GetLightLinkCollection() and GetShadowLinkCollection().
|
||||
Note that these collections have their includeRoot set to true,
|
||||
so that lights will illuminate and cast shadows from all objects
|
||||
by default. To illuminate only a specific set of objects, there
|
||||
are two options. One option is to modify the collection paths
|
||||
to explicitly exclude everything else, assuming it is known;
|
||||
the other option is to set includeRoot to false and explicitly
|
||||
include the desired objects. These are complementary approaches
|
||||
that may each be preferable depending on the scenario and how
|
||||
to best express the intent of the light setup.
|
||||
"""
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool providesUsdShadeConnectableAPIBehavior = 1
|
||||
}
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usd/collectionAPI.h"
|
||||
#include "pxr/usd/usdShade/input.h"
|
||||
#include "pxr/usd/usdShade/output.h" """
|
||||
}
|
||||
prepend apiSchemas = ["CollectionAPI:lightLink", "CollectionAPI:shadowLink"]
|
||||
) {
|
||||
uniform bool collection:lightLink:includeRoot = 1 (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
)
|
||||
uniform bool collection:shadowLink:includeRoot = 1 (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
)
|
||||
uniform token light:shaderId = "" (
|
||||
doc = """Default ID for the light's shader.
|
||||
This defines the shader ID for this light when a render context specific
|
||||
shader ID is not available.
|
||||
|
||||
The default shaderId for the intrinsic UsdLux lights (RectLight,
|
||||
DistantLight, etc.) are set to default to the light's type name. For
|
||||
each intrinsic UsdLux light, we will always register an SdrShaderNode in
|
||||
the SdrRegistry, with the identifier matching the type name and the
|
||||
source type "USD", that corresponds to the light's inputs.
|
||||
\\see GetShaderId
|
||||
\\see GetShaderIdAttrForRenderContext
|
||||
\\see SdrRegistry::GetShaderNodeByIdentifier
|
||||
\\see SdrRegistry::GetShaderNodeByIdentifierAndType
|
||||
"""
|
||||
customData = {
|
||||
token apiName = "shaderId"
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
uniform token light:materialSyncMode = "noMaterialResponse" (
|
||||
doc = """For a LightAPI applied to geometry that has a bound Material,
|
||||
which is entirely or partly emissive, this specifies the relationship
|
||||
of the Material response to the lighting response.
|
||||
Valid values are:
|
||||
- materialGlowTintsLight: All primary and secondary rays see the
|
||||
emissive/glow response as dictated by the bound Material while the
|
||||
base color seen by light rays (which is then modulated by all of the
|
||||
other LightAPI controls) is the multiplication of the color feeding
|
||||
the emission/glow input of the Material (i.e. its surface or volume
|
||||
shader) with the scalar or pattern input to *inputs:color*.
|
||||
This allows the light's color to tint the geometry's glow color while
|
||||
preserving access to intensity and other light controls as ways to
|
||||
further modulate the illumination.
|
||||
- independent: All primary and secondary rays see the emissive/glow
|
||||
response as dictated by the bound Material, while the base color seen
|
||||
by light rays is determined solely by *inputs:color*. Note that for
|
||||
partially emissive geometry (in which some parts are reflective
|
||||
rather than emissive), a suitable pattern must be connected to the
|
||||
light's color input, or else the light will radiate uniformly from
|
||||
the geometry.
|
||||
- noMaterialResponse: The geometry behaves as if there is no Material
|
||||
bound at all, i.e. there is no diffuse, specular, or transmissive
|
||||
response. The base color of light rays is entirely controlled by the
|
||||
*inputs:color*. This is the standard mode for "canonical" lights in
|
||||
UsdLux and indicates to renderers that a Material will either never
|
||||
be bound or can always be ignored.
|
||||
"""
|
||||
allowedTokens = ["materialGlowTintsLight",
|
||||
"independent",
|
||||
"noMaterialResponse"]
|
||||
customData = {
|
||||
token apiName = "materialSyncMode"
|
||||
}
|
||||
)
|
||||
float inputs:intensity = 1 (
|
||||
doc = """Scales the power of the light linearly."""
|
||||
customData = {
|
||||
token apiName = "intensity"
|
||||
}
|
||||
)
|
||||
float inputs:exposure = 0 (
|
||||
doc = """Scales the power of the light exponentially as a power
|
||||
of 2 (similar to an F-stop control over exposure). The result
|
||||
is multiplied against the intensity."""
|
||||
customData = {
|
||||
token apiName = "exposure"
|
||||
}
|
||||
)
|
||||
float inputs:diffuse = 1.0 (
|
||||
displayName = "Diffuse Multiplier"
|
||||
doc = """A multiplier for the effect of this light on the diffuse
|
||||
response of materials. This is a non-physical control."""
|
||||
customData = {
|
||||
token apiName = "diffuse"
|
||||
}
|
||||
)
|
||||
float inputs:specular = 1.0 (
|
||||
displayName = "Specular Multiplier"
|
||||
doc = """A multiplier for the effect of this light on the specular
|
||||
response of materials. This is a non-physical control."""
|
||||
customData = {
|
||||
token apiName = "specular"
|
||||
}
|
||||
)
|
||||
bool inputs:normalize = false (
|
||||
displayName = "Normalize Power"
|
||||
doc = """Normalizes power by the surface area of the light.
|
||||
This makes it easier to independently adjust the power and shape
|
||||
of the light, by causing the power to not vary with the area or
|
||||
angular size of the light."""
|
||||
customData = {
|
||||
token apiName = "normalize"
|
||||
}
|
||||
)
|
||||
color3f inputs:color = (1, 1, 1) (
|
||||
doc = """The color of emitted light, in energy-linear terms."""
|
||||
customData = {
|
||||
token apiName = "color"
|
||||
}
|
||||
)
|
||||
bool inputs:enableColorTemperature = false (
|
||||
displayName = "Enable Color Temperature"
|
||||
doc = """Enables using colorTemperature."""
|
||||
customData = {
|
||||
token apiName = "enableColorTemperature"
|
||||
}
|
||||
)
|
||||
float inputs:colorTemperature = 6500 (
|
||||
displayName = "Color Temperature"
|
||||
doc = """Color temperature, in degrees Kelvin, representing the
|
||||
white point. The default is a common white point, D65. Lower
|
||||
values are warmer and higher values are cooler. The valid range
|
||||
is from 1000 to 10000. Only takes effect when
|
||||
enableColorTemperature is set to true. When active, the
|
||||
computed result multiplies against the color attribute.
|
||||
See UsdLuxBlackbodyTemperatureAsRgb()."""
|
||||
customData = {
|
||||
token apiName = "colorTemperature"
|
||||
}
|
||||
)
|
||||
rel light:filters (
|
||||
doc = """Relationship to the light filters that apply to this light."""
|
||||
customData = {
|
||||
token apiName = "filters"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class "MeshLightAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """This is the preferred API schema to apply to
|
||||
\\ref UsdGeomMesh "Mesh" type prims when adding light behaviors to a mesh.
|
||||
At its base, this API schema has the built-in behavior of applying LightAPI
|
||||
to the mesh and overriding the default materialSyncMode to allow the
|
||||
emission/glow of the bound material to affect the color of the light.
|
||||
But, it additionally serves as a hook for plugins to attach additional
|
||||
properties to "mesh lights" through the creation of API schemas which are
|
||||
authored to auto-apply to MeshLightAPI.
|
||||
\\see \\ref Usd_AutoAppliedAPISchemas
|
||||
"""
|
||||
prepend apiSchemas = ["LightAPI"]
|
||||
) {
|
||||
uniform token light:shaderId = "MeshLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
uniform token light:materialSyncMode = "materialGlowTintsLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class "VolumeLightAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """This is the preferred API schema to apply to
|
||||
\\ref UsdVolVolume "Volume" type prims when adding light behaviors to a
|
||||
volume. At its base, this API schema has the built-in behavior of applying
|
||||
LightAPI to the volume and overriding the default materialSyncMode to allow
|
||||
the emission/glow of the bound material to affect the color of the light.
|
||||
But, it additionally serves as a hook for plugins to attach additional
|
||||
properties to "volume lights" through the creation of API schemas which are
|
||||
authored to auto-apply to VolumeLightAPI.
|
||||
\\see \\ref Usd_AutoAppliedAPISchemas
|
||||
"""
|
||||
prepend apiSchemas = ["LightAPI"]
|
||||
) {
|
||||
uniform token light:shaderId = "VolumeLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
uniform token light:materialSyncMode = "materialGlowTintsLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class "ListAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """API schema to support discovery and publishing of lights in a scene.
|
||||
|
||||
\\section UsdLuxListAPI_Discovery Discovering Lights via Traversal
|
||||
|
||||
To motivate this API, consider what is required to discover all
|
||||
lights in a scene. We must load all payloads and traverse all prims:
|
||||
|
||||
\\code
|
||||
01 // Load everything on the stage so we can find all lights,
|
||||
02 // including those inside payloads
|
||||
03 stage->Load();
|
||||
04
|
||||
05 // Traverse all prims, checking if they have an applied UsdLuxLightAPI
|
||||
06 // (Note: ignoring instancing and a few other things for simplicity)
|
||||
07 SdfPathVector lights;
|
||||
08 for (UsdPrim prim: stage->Traverse()) {
|
||||
09 if (prim.HasAPI<UsdLuxLightAPI>()) {
|
||||
10 lights.push_back(i->GetPath());
|
||||
11 }
|
||||
12 }
|
||||
\\endcode
|
||||
|
||||
This traversal -- suitably elaborated to handle certain details --
|
||||
is the first and simplest thing UsdLuxListAPI provides.
|
||||
UsdLuxListAPI::ComputeLightList() performs this traversal and returns
|
||||
all lights in the scene:
|
||||
|
||||
\\code
|
||||
01 UsdLuxListAPI listAPI(stage->GetPseudoRoot());
|
||||
02 SdfPathVector lights = listAPI.ComputeLightList();
|
||||
\\endcode
|
||||
|
||||
\\section UsdLuxListAPI_LightList Publishing a Cached Light List
|
||||
|
||||
Consider a USD client that needs to quickly discover lights but
|
||||
wants to defer loading payloads and traversing the entire scene
|
||||
where possible, and is willing to do up-front computation and
|
||||
caching to achieve that.
|
||||
|
||||
UsdLuxListAPI provides a way to cache the computed light list,
|
||||
by publishing the list of lights onto prims in the model
|
||||
hierarchy. Consider a big set that contains lights:
|
||||
|
||||
\\code
|
||||
01 def Xform "BigSetWithLights" (
|
||||
02 kind = "assembly"
|
||||
03 payload = @BigSetWithLights.usd@ // Heavy payload
|
||||
04 ) {
|
||||
05 // Pre-computed, cached list of lights inside payload
|
||||
06 rel lightList = [
|
||||
07 <./Lights/light_1>,
|
||||
08 <./Lights/light_2>,
|
||||
09 ...
|
||||
10 ]
|
||||
11 token lightList:cacheBehavior = "consumeAndContinue";
|
||||
12 }
|
||||
\\endcode
|
||||
|
||||
The lightList relationship encodes a set of lights, and the
|
||||
lightList:cacheBehavior property provides fine-grained
|
||||
control over how to use that cache. (See details below.)
|
||||
|
||||
The cache can be created by first invoking
|
||||
ComputeLightList(ComputeModeIgnoreCache) to pre-compute the list
|
||||
and then storing the result with UsdLuxListAPI::StoreLightList().
|
||||
|
||||
To enable efficient retrieval of the cache, it should be stored
|
||||
on a model hierarchy prim. Furthermore, note that while you can
|
||||
use a UsdLuxListAPI bound to the pseudo-root prim to query the
|
||||
lights (as in the example above) because it will perform a
|
||||
traversal over descendants, you cannot store the cache back to the
|
||||
pseduo-root prim.
|
||||
|
||||
To consult the cached list, we invoke
|
||||
ComputeLightList(ComputeModeConsultModelHierarchyCache):
|
||||
|
||||
\\code
|
||||
01 // Find and load all lights, using lightList cache where available
|
||||
02 UsdLuxListAPI list(stage->GetPseudoRoot());
|
||||
03 SdfPathSet lights = list.ComputeLightList(
|
||||
04 UsdLuxListAPI::ComputeModeConsultModelHierarchyCache);
|
||||
05 stage.LoadAndUnload(lights, SdfPathSet());
|
||||
\\endcode
|
||||
|
||||
In this mode, ComputeLightList() will traverse the model
|
||||
hierarchy, accumulating cached light lists.
|
||||
|
||||
\\section UsdLuxListAPI_CacheBehavior Controlling Cache Behavior
|
||||
|
||||
The lightList:cacheBehavior property gives additional fine-grained
|
||||
control over cache behavior:
|
||||
|
||||
\\li The fallback value, "ignore", indicates that the lightList should
|
||||
be disregarded. This provides a way to invalidate cache entries.
|
||||
Note that unless "ignore" is specified, a lightList with an empty
|
||||
list of targets is considered a cache indicating that no lights
|
||||
are present.
|
||||
|
||||
\\li The value "consumeAndContinue" indicates that the cache should
|
||||
be consulted to contribute lights to the scene, and that recursion
|
||||
should continue down the model hierarchy in case additional lights
|
||||
are added as descedants. This is the default value established when
|
||||
StoreLightList() is invoked. This behavior allows the lights within
|
||||
a large model, such as the BigSetWithLights example above, to be
|
||||
published outside the payload, while also allowing referencing and
|
||||
layering to add additional lights over that set.
|
||||
|
||||
\\li The value "consumeAndHalt" provides a way to terminate recursive
|
||||
traversal of the scene for light discovery. The cache will be
|
||||
consulted but no descendant prims will be examined.
|
||||
|
||||
\\section UsdLuxListAPI_Instancing Instancing
|
||||
|
||||
Where instances are present, UsdLuxListAPI::ComputeLightList() will
|
||||
return the instance-unique paths to any lights discovered within
|
||||
those instances. Lights within a UsdGeomPointInstancer will
|
||||
not be returned, however, since they cannot be referred to
|
||||
solely via paths.
|
||||
"""
|
||||
) {
|
||||
rel lightList (
|
||||
doc = """Relationship to lights in the scene."""
|
||||
)
|
||||
token lightList:cacheBehavior (
|
||||
doc = """Controls how the lightList should be interpreted.
|
||||
Valid values are:
|
||||
- consumeAndHalt: The lightList should be consulted,
|
||||
and if it exists, treated as a final authoritative statement
|
||||
of any lights that exist at or below this prim, halting
|
||||
recursive discovery of lights.
|
||||
- consumeAndContinue: The lightList should be consulted,
|
||||
but recursive traversal over nameChildren should continue
|
||||
in case additional lights are added by descendants.
|
||||
- ignore: The lightList should be entirely ignored. This
|
||||
provides a simple way to temporarily invalidate an existing
|
||||
cache. This is the fallback behavior.
|
||||
"""
|
||||
allowedTokens = ["consumeAndHalt", "consumeAndContinue", "ignore"]
|
||||
)
|
||||
}
|
||||
|
||||
class "ShapingAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """Controls for shaping a light's emission."""
|
||||
customData = {
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usdShade/input.h"
|
||||
#include "pxr/usd/usdShade/output.h" """
|
||||
}
|
||||
|
||||
) {
|
||||
float inputs:shaping:focus = 0 (
|
||||
displayGroup = "Shaping"
|
||||
doc = """A control to shape the spread of light. Higher focus
|
||||
values pull light towards the center and narrow the spread.
|
||||
Implemented as an off-axis cosine power exponent.
|
||||
TODO: clarify semantics"""
|
||||
customData = {
|
||||
token apiName = "shaping:focus"
|
||||
}
|
||||
)
|
||||
color3f inputs:shaping:focusTint = (0, 0, 0) (
|
||||
displayGroup = "Shaping"
|
||||
doc = """Off-axis color tint. This tints the emission in the
|
||||
falloff region. The default tint is black.
|
||||
TODO: clarify semantics"""
|
||||
customData = {
|
||||
token apiName = "shaping:focusTint"
|
||||
}
|
||||
)
|
||||
float inputs:shaping:cone:angle = 90 (
|
||||
displayGroup = "Shaping"
|
||||
doc = """Angular limit off the primary axis to restrict the
|
||||
light spread."""
|
||||
customData = {
|
||||
token apiName = "shaping:cone:angle"
|
||||
}
|
||||
)
|
||||
float inputs:shaping:cone:softness = 0 (
|
||||
displayGroup = "Shaping"
|
||||
doc = """Controls the cutoff softness for cone angle.
|
||||
TODO: clarify semantics"""
|
||||
customData = {
|
||||
token apiName = "shaping:cone:softness"
|
||||
}
|
||||
)
|
||||
asset inputs:shaping:ies:file (
|
||||
displayGroup = "Shaping"
|
||||
doc = """An IES (Illumination Engineering Society) light
|
||||
profile describing the angular distribution of light."""
|
||||
customData = {
|
||||
token apiName = "shaping:ies:file"
|
||||
}
|
||||
)
|
||||
float inputs:shaping:ies:angleScale = 0 (
|
||||
displayGroup = "Shaping"
|
||||
doc = """Rescales the angular distribution of the IES profile.
|
||||
TODO: clarify semantics"""
|
||||
customData = {
|
||||
token apiName = "shaping:ies:angleScale"
|
||||
}
|
||||
)
|
||||
bool inputs:shaping:ies:normalize = false (
|
||||
displayGroup = "Shaping"
|
||||
doc = """Normalizes the IES profile so that it affects the shaping
|
||||
of the light while preserving the overall energy output."""
|
||||
customData = {
|
||||
token apiName = "shaping:ies:normalize"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class "ShadowAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """Controls to refine a light's shadow behavior. These are
|
||||
non-physical controls that are valuable for visual lighting work."""
|
||||
customData = {
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usdShade/input.h"
|
||||
#include "pxr/usd/usdShade/output.h" """
|
||||
}
|
||||
|
||||
) {
|
||||
bool inputs:shadow:enable = true (
|
||||
displayGroup = "Shadows"
|
||||
doc = """Enables shadows to be cast by this light."""
|
||||
customData = {
|
||||
token apiName = "shadow:enable"
|
||||
}
|
||||
)
|
||||
color3f inputs:shadow:color = (0, 0, 0) (
|
||||
displayGroup = "Shadows"
|
||||
doc = """The color of shadows cast by the light. This is a
|
||||
non-physical control. The default is to cast black shadows."""
|
||||
customData = {
|
||||
token apiName = "shadow:color"
|
||||
}
|
||||
)
|
||||
float inputs:shadow:distance = -1.0 (
|
||||
displayGroup = "Shadows"
|
||||
doc = """The maximum distance shadows are cast.
|
||||
The default value (-1) indicates no limit.
|
||||
"""
|
||||
customData = {
|
||||
token apiName = "shadow:distance"
|
||||
}
|
||||
)
|
||||
float inputs:shadow:falloff = -1.0 (
|
||||
displayGroup = "Shadows"
|
||||
doc = """The near distance at which shadow falloff begins.
|
||||
The default value (-1) indicates no falloff.
|
||||
"""
|
||||
customData = {
|
||||
token apiName = "shadow:falloff"
|
||||
}
|
||||
)
|
||||
float inputs:shadow:falloffGamma = 1.0 (
|
||||
displayGroup = "Shadows"
|
||||
doc = """A gamma (i.e., exponential) control over shadow strength
|
||||
with linear distance within the falloff zone.
|
||||
This requires the use of shadowDistance and shadowFalloff."""
|
||||
customData = {
|
||||
token apiName = "shadow:falloffGamma"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class LightFilter "LightFilter" (
|
||||
inherits = </Xformable>
|
||||
doc = """A light filter modifies the effect of a light.
|
||||
Lights refer to filters via relationships so that filters may be
|
||||
shared.
|
||||
|
||||
<b>Linking</b>
|
||||
|
||||
Filters can be linked to geometry. Linking controls which geometry
|
||||
a light-filter affects, when considering the light filters attached
|
||||
to a light illuminating the geometry.
|
||||
|
||||
Linking is specified as a collection (UsdCollectionAPI) which can
|
||||
be accessed via GetFilterLinkCollection().
|
||||
"""
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool providesUsdShadeConnectableAPIBehavior = 1
|
||||
}
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usd/collectionAPI.h"
|
||||
#include "pxr/usd/usdShade/input.h"
|
||||
#include "pxr/usd/usdShade/output.h" """
|
||||
}
|
||||
prepend apiSchemas = ["CollectionAPI:filterLink"]
|
||||
) {
|
||||
uniform bool collection:filterLink:includeRoot = 1 (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
)
|
||||
uniform token lightFilter:shaderId = "" (
|
||||
doc = """Default ID for the light filter's shader.
|
||||
This defines the shader ID for this light filter when a render context
|
||||
specific shader ID is not available.
|
||||
|
||||
\\see GetShaderId
|
||||
\\see GetShaderIdAttrForRenderContext
|
||||
\\see SdrRegistry::GetShaderNodeByIdentifier
|
||||
\\see SdrRegistry::GetShaderNodeByIdentifierAndType
|
||||
"""
|
||||
customData = {
|
||||
token apiName = "shaderId"
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
class "BoundableLightBase" (
|
||||
inherits = </Boundable>
|
||||
doc = """Base class for intrinsic lights that are boundable.
|
||||
|
||||
The primary purpose of this class is to provide a direct API to the
|
||||
functions provided by LightAPI for concrete derived light types.
|
||||
"""
|
||||
customData = {
|
||||
string extraIncludes = """#include "pxr/usd/usdLux/lightAPI.h" """
|
||||
}
|
||||
prepend apiSchemas = ["LightAPI"]
|
||||
) {
|
||||
}
|
||||
|
||||
class "NonboundableLightBase" (
|
||||
inherits = </Xformable>
|
||||
doc = """Base class for intrinsic lights that are not boundable.
|
||||
|
||||
The primary purpose of this class is to provide a direct API to the
|
||||
functions provided by LightAPI for concrete derived light types.
|
||||
"""
|
||||
customData = {
|
||||
string extraIncludes = """#include "pxr/usd/usdLux/lightAPI.h" """
|
||||
}
|
||||
prepend apiSchemas = ["LightAPI"]
|
||||
) {
|
||||
}
|
||||
|
||||
class DistantLight "DistantLight" (
|
||||
inherits = </NonboundableLightBase>
|
||||
doc = """Light emitted from a distant source along the -Z axis.
|
||||
Also known as a directional light."""
|
||||
) {
|
||||
uniform token light:shaderId = "DistantLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
float inputs:angle = 0.53 (
|
||||
doc = """Angular size of the light in degrees.
|
||||
As an example, the Sun is approximately 0.53 degrees as seen from Earth.
|
||||
Higher values broaden the light and therefore soften shadow edges.
|
||||
"""
|
||||
customData = {
|
||||
token apiName = "angle"
|
||||
}
|
||||
)
|
||||
float inputs:intensity = 50000 (
|
||||
doc = """Scales the emission of the light linearly.
|
||||
The DistantLight has a high default intensity to approximate the Sun."""
|
||||
customData = {
|
||||
token apiName = "intensity"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class DiskLight "DiskLight" (
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool implementsComputeExtent = 1
|
||||
}
|
||||
}
|
||||
inherits = </BoundableLightBase>
|
||||
doc = """Light emitted from one side of a circular disk.
|
||||
The disk is centered in the XY plane and emits light along the -Z axis."""
|
||||
) {
|
||||
uniform token light:shaderId = "DiskLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
float inputs:radius = 0.5 (
|
||||
doc = "Radius of the disk."
|
||||
customData = {
|
||||
token apiName = "radius"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class RectLight "RectLight" (
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool implementsComputeExtent = 1
|
||||
}
|
||||
}
|
||||
inherits = </BoundableLightBase>
|
||||
doc = """Light emitted from one side of a rectangle.
|
||||
The rectangle is centered in the XY plane and emits light along the -Z axis.
|
||||
The rectangle is 1 unit in length in the X and Y axis. In the default
|
||||
position, a texture file's min coordinates should be at (+X, +Y) and
|
||||
max coordinates at (-X, -Y)."""
|
||||
) {
|
||||
uniform token light:shaderId = "RectLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
float inputs:width = 1 (
|
||||
doc = "Width of the rectangle, in the local X axis."
|
||||
customData = {
|
||||
token apiName = "width"
|
||||
}
|
||||
|
||||
)
|
||||
float inputs:height = 1 (
|
||||
doc = "Height of the rectangle, in the local Y axis."
|
||||
customData = {
|
||||
token apiName = "height"
|
||||
}
|
||||
)
|
||||
asset inputs:texture:file (
|
||||
doc = """A color texture to use on the rectangle."""
|
||||
customData = {
|
||||
token apiName = "textureFile"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class SphereLight "SphereLight" (
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool implementsComputeExtent = 1
|
||||
}
|
||||
}
|
||||
inherits = </BoundableLightBase>
|
||||
doc = """Light emitted outward from a sphere."""
|
||||
) {
|
||||
uniform token light:shaderId = "SphereLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
float inputs:radius = 0.5 (
|
||||
doc = "Radius of the sphere."
|
||||
customData = {
|
||||
token apiName = "radius"
|
||||
}
|
||||
)
|
||||
bool treatAsPoint = false (
|
||||
doc = """A hint that this light can be treated as a 'point'
|
||||
light (effectively, a zero-radius sphere) by renderers that
|
||||
benefit from non-area lighting. Renderers that only support
|
||||
area lights can disregard this."""
|
||||
)
|
||||
}
|
||||
|
||||
class CylinderLight "CylinderLight" (
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool implementsComputeExtent = 1
|
||||
}
|
||||
}
|
||||
inherits = </BoundableLightBase>
|
||||
doc = """Light emitted outward from a cylinder.
|
||||
The cylinder is centered at the origin and has its major axis on the X axis.
|
||||
The cylinder does not emit light from the flat end-caps.
|
||||
"""
|
||||
) {
|
||||
uniform token light:shaderId = "CylinderLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
float inputs:length = 1 (
|
||||
doc = "Width of the rectangle, in the local X axis."
|
||||
customData = {
|
||||
token apiName = "length"
|
||||
}
|
||||
)
|
||||
float inputs:radius = 0.5 (
|
||||
doc = "Radius of the cylinder."
|
||||
customData = {
|
||||
token apiName = "radius"
|
||||
}
|
||||
)
|
||||
bool treatAsLine = false (
|
||||
doc = """A hint that this light can be treated as a 'line'
|
||||
light (effectively, a zero-radius cylinder) by renderers that
|
||||
benefit from non-area lighting. Renderers that only support
|
||||
area lights can disregard this."""
|
||||
)
|
||||
}
|
||||
|
||||
class GeometryLight "GeometryLight" (
|
||||
inherits = </NonboundableLightBase>
|
||||
doc = """\\deprecated
|
||||
Light emitted outward from a geometric prim (UsdGeomGprim),
|
||||
which is typically a mesh."""
|
||||
) {
|
||||
rel geometry (
|
||||
doc = """Relationship to the geometry to use as the light source."""
|
||||
)
|
||||
uniform token light:shaderId = "GeometryLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
}
|
||||
|
||||
class DomeLight "DomeLight" (
|
||||
inherits = </NonboundableLightBase>
|
||||
doc = """Light emitted inward from a distant external environment,
|
||||
such as a sky or IBL light probe. The orientation of a dome light with a
|
||||
latlong texture is expected to match the OpenEXR specification for latlong
|
||||
environment maps. From the OpenEXR documentation:
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
Latitude-Longitude Map:
|
||||
|
||||
The environment is projected onto the image using polar coordinates
|
||||
(latitude and longitude). A pixel's x coordinate corresponds to
|
||||
its longitude, and the y coordinate corresponds to its latitude.
|
||||
Pixel (dataWindow.min.x, dataWindow.min.y) has latitude +pi/2 and
|
||||
longitude +pi; pixel (dataWindow.max.x, dataWindow.max.y) has
|
||||
latitude -pi/2 and longitude -pi.
|
||||
|
||||
In 3D space, latitudes -pi/2 and +pi/2 correspond to the negative and
|
||||
positive y direction. Latitude 0, longitude 0 points into positive
|
||||
z direction; and latitude 0, longitude pi/2 points into positive x
|
||||
direction.
|
||||
|
||||
The size of the data window should be 2*N by N pixels (width by height),
|
||||
where N can be any integer greater than 0.
|
||||
-------------------------------------------------------------------------
|
||||
"""
|
||||
) {
|
||||
uniform token light:shaderId = "DomeLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
asset inputs:texture:file (
|
||||
doc = """A color texture to use on the dome, such as an HDR (high
|
||||
dynamic range) texture intended for IBL (image based lighting)."""
|
||||
customData = {
|
||||
token apiName = "textureFile"
|
||||
}
|
||||
)
|
||||
token inputs:texture:format = "automatic" (
|
||||
allowedTokens = ["automatic", "latlong", "mirroredBall", "angular", "cubeMapVerticalCross"]
|
||||
doc = """Specifies the parameterization of the color map file.
|
||||
Valid values are:
|
||||
- automatic: Tries to determine the layout from the file itself.
|
||||
For example, Renderman texture files embed an explicit
|
||||
parameterization.
|
||||
- latlong: Latitude as X, longitude as Y.
|
||||
- mirroredBall: An image of the environment reflected in a
|
||||
sphere, using an implicitly orthogonal projection.
|
||||
- angular: Similar to mirroredBall but the radial dimension
|
||||
is mapped linearly to the angle, providing better sampling
|
||||
at the edges.
|
||||
- cubeMapVerticalCross: A cube map with faces laid out as a
|
||||
vertical cross.
|
||||
"""
|
||||
customData = {
|
||||
token apiName = "textureFormat"
|
||||
}
|
||||
)
|
||||
rel portals (
|
||||
doc = """Optional portals to guide light sampling."""
|
||||
)
|
||||
}
|
||||
|
||||
class PortalLight "PortalLight" (
|
||||
inherits = </BoundableLightBase>
|
||||
doc = """A rectangular portal in the local XY plane that guides sampling
|
||||
of a dome light. Transmits light in the -Z direction.
|
||||
The rectangle is 1 unit in length."""
|
||||
) {
|
||||
uniform token light:shaderId = "PortalLight" (
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
displayGroup = "Internal"
|
||||
)
|
||||
float3[] extent = [(-0.5, -0.5, 0.0), (0.5, 0.5, 0.0)] (
|
||||
doc = """Boundary extent of the unit rectangle in the XY plane that
|
||||
defines the portal."""
|
||||
customData = {
|
||||
token apiName = ""
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class PluginLight "PluginLight" (
|
||||
inherits = </Xformable>
|
||||
doc = """Light that provides properties that allow it to identify an
|
||||
external SdrShadingNode definition, through UsdShadeNodeDefAPI, that can be
|
||||
provided to render delegates without the need to provide a schema
|
||||
definition for the light's type.
|
||||
|
||||
\\see \\ref usdLux_PluginSchemas
|
||||
"""
|
||||
prepend apiSchemas = ["NodeDefAPI", "LightAPI"]
|
||||
customData = {
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usdShade/nodeDefAPI.h" """
|
||||
}
|
||||
) {
|
||||
}
|
||||
|
||||
class PluginLightFilter "PluginLightFilter" (
|
||||
inherits = </LightFilter>
|
||||
doc = """Light filter that provides properties that allow it to identify an
|
||||
external SdrShadingNode definition, through UsdShadeNodeDefAPI, that can be
|
||||
provided to render delegates without the need to provide a schema
|
||||
definition for the light filter's type.
|
||||
|
||||
\\see \\ref usdLux_PluginSchemas
|
||||
"""
|
||||
prepend apiSchemas = ["NodeDefAPI"]
|
||||
customData = {
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usdShade/nodeDefAPI.h" """
|
||||
}
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"WARNING: THIS FILE IS GENERATED BY usdGenSchema. DO NOT EDIT."
|
||||
)
|
||||
|
||||
class SpatialAudio "SpatialAudio" (
|
||||
doc = """The SpatialAudio primitive defines basic properties for encoding
|
||||
playback of an audio file or stream within a USD Stage. The SpatialAudio
|
||||
schema derives from UsdGeomXformable since it can support full spatial
|
||||
audio while also supporting non-spatial mono and stereo sounds. One or
|
||||
more SpatialAudio prims can be placed anywhere in the namespace, though it
|
||||
is advantageous to place truly spatial audio prims under/inside the models
|
||||
from which the sound emanates, so that the audio prim need only be
|
||||
transformed relative to the model, rather than copying its animation.
|
||||
|
||||
Timecode Attributes and Time Scaling
|
||||
\\a startTime and \\a endTime are \"timecode\" valued
|
||||
attributes which gives them the special behavior that
|
||||
\"layer offsets\" affecting the layer in
|
||||
which one of these values is authored are applied to the attribute's value
|
||||
itself during value resolution. This allows audio playback to be kept in
|
||||
sync with time sampled animation as the animation is affected by
|
||||
\"layer offsets\" in the composition. But this behavior
|
||||
brings with it some interesting edge cases and caveats when it comes to
|
||||
\"layer offsets\" that include scale.
|
||||
|
||||
#### Layer Offsets do not affect Media Dilation
|
||||
Although authored layer offsets may have a time scale which can scale the
|
||||
duration between an authored \\a startTime and \\a endTime, we make no
|
||||
attempt to infer any playback dilation of the actual audio media itself.
|
||||
Given that \\a startTime and \\a endTime can be independently authored in
|
||||
different layers with differing time scales, it is not possible, in general,
|
||||
to define an \"original timeframe\" from which we can compute a dilation to
|
||||
composed stage-time. Even if we could compute a composed dilation this way,
|
||||
it would still be impossible to flatten a stage or layer stack into a single
|
||||
layer and still retain the composed audio dilation using this schema.
|
||||
|
||||
#### Inverting startTime and endTime
|
||||
Although we do not expect it to be common, it is possible to apply a
|
||||
negative time scale to USD layers, which mostly has the effect of reversing
|
||||
animation in the affected composition. If a negative scale is applied to a
|
||||
composition that contains authored \\a startTime and \\a endTime, it will
|
||||
reverse their relative ordering in time. Therefore, we stipulate when
|
||||
\\a playbackMode is \"onceFromStartToEnd\" or \"loopFromStartToEnd\", if
|
||||
\\a endTime is less than \\a startTime, then begin playback at \\a endTime,
|
||||
and continue until \\a startTime. When \\a startTime and \\a endTime are
|
||||
inverted, we do not, however, stipulate that playback of the audio media
|
||||
itself be inverted, since doing so \"successfully\" would require perfect
|
||||
knowledge of when, within the audio clip, relevant audio ends (so that we
|
||||
know how to offset the reversed audio to align it so that we reach the
|
||||
\"beginning\" at \\a startTime), and sounds played in reverse are not likely
|
||||
to produce desirable results.
|
||||
"""
|
||||
)
|
||||
{
|
||||
uniform token auralMode = "spatial" (
|
||||
allowedTokens = ["spatial", "nonSpatial"]
|
||||
doc = """Determines how audio should be played.
|
||||
Valid values are:
|
||||
- spatial: Play the audio in 3D space if the device can support spatial
|
||||
audio. if not, fall back to mono.
|
||||
- nonSpatial: Play the audio without regard to the SpatialAudio prim's
|
||||
position. If the audio media contains any form of stereo or other
|
||||
multi-channel sound, it is left to the application to determine
|
||||
whether the listener's position should be taken into account. We
|
||||
expect nonSpatial to be the choice for ambient sounds and music
|
||||
sound-tracks.
|
||||
"""
|
||||
)
|
||||
uniform timecode endTime = 0 (
|
||||
doc = """Expressed in the timeCodesPerSecond of the containing stage,
|
||||
\\a endTime specifies when the audio stream will cease playing during
|
||||
animation playback if the length of the referenced audio clip is
|
||||
longer than desired. This only applies if \\a playbackMode is set to
|
||||
onceFromStartToEnd or loopFromStartToEnd, otherwise the \\a endTimeCode
|
||||
of the stage is used instead of \\a endTime.
|
||||
If \\a endTime is less than \\a startTime, it is expected that the audio
|
||||
will instead be played from \\a endTime to \\a startTime.
|
||||
Note that \\a endTime is expressed as a timecode so that the stage can
|
||||
properly apply layer offsets when resolving its value.
|
||||
See for more details and caveats.
|
||||
"""
|
||||
)
|
||||
uniform asset filePath = @@ (
|
||||
doc = '''Path to the audio file.
|
||||
In general, the formats allowed for audio files is no more constrained
|
||||
by USD than is image-type. As with images, however, usdz has stricter
|
||||
requirements based on DMA and format support in browsers and consumer
|
||||
devices. The allowed audio filetypes for usdz are M4A, MP3, WAV
|
||||
(in order of preference).
|
||||
\\sa <a href="http://graphics.pixar.com/usd/docs/Usdz-File-Format-Specification.html#UsdzFileFormatSpecification-UsdzSpecification">Usdz Specification</a>
|
||||
'''
|
||||
)
|
||||
double gain = 1 (
|
||||
doc = '''Multiplier on the incoming audio signal. A value of 0 "mutes"
|
||||
the signal. Negative values will be clamped to 0.
|
||||
'''
|
||||
)
|
||||
uniform double mediaOffset = 0 (
|
||||
doc = """Expressed in seconds, \\a mediaOffset specifies the offset from
|
||||
the referenced audio file's beginning at which we should begin playback
|
||||
when stage playback reaches the time that prim's audio should start.
|
||||
If the prim's \\a playbackMode is a looping mode, \\a mediaOffset is
|
||||
applied only to the first run-through of the audio clip; the second and
|
||||
all other loops begin from the start of the audio clip.
|
||||
"""
|
||||
)
|
||||
uniform token playbackMode = "onceFromStart" (
|
||||
allowedTokens = ["onceFromStart", "onceFromStartToEnd", "loopFromStart", "loopFromStartToEnd", "loopFromStage"]
|
||||
doc = """Along with \\a startTime and \\a endTime, determines when the
|
||||
audio playback should start and stop during the stage's animation
|
||||
playback and whether the audio should loop during its duration.
|
||||
Valid values are:
|
||||
- onceFromStart: Play the audio once, starting at \\a startTime,
|
||||
continuing until the audio completes.
|
||||
- onceFromStartToEnd: Play the audio once beginning at \\a startTime,
|
||||
continuing until \\a endTime or until the audio completes, whichever
|
||||
comes first.
|
||||
- loopFromStart: Start playing the audio at \\a startTime and continue
|
||||
looping through to the stage's authored \\a endTimeCode.
|
||||
- loopFromStartToEnd: Start playing the audio at \\a startTime and
|
||||
continue looping through, stopping the audio at \\a endTime.
|
||||
- loopFromStage: Start playing the audio at the stage's authored
|
||||
\\a startTimeCode and continue looping through to the stage's authored
|
||||
\\a endTimeCode. This can be useful for ambient sounds that should always
|
||||
be active.
|
||||
"""
|
||||
)
|
||||
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 classification of 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.
|
||||
|
||||
See for more detail about how
|
||||
purpose is computed and used."""
|
||||
)
|
||||
uniform timecode startTime = 0 (
|
||||
doc = """Expressed in the timeCodesPerSecond of the containing stage,
|
||||
\\a startTime specifies when the audio stream will start playing during
|
||||
animation playback. This value is ignored when \\a playbackMode is set
|
||||
to loopFromStage as, in this mode, the audio will always start at the
|
||||
stage's authored \\a startTimeCode.
|
||||
Note that \\a startTime is expressed as a timecode so that the stage can
|
||||
properly apply layer offsets when resolving its value. See
|
||||
for more details and caveats.
|
||||
"""
|
||||
)
|
||||
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.'''
|
||||
)
|
||||
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()."""
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"UsdMediaSpatialAudio": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "SpatialAudio"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomXformable"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdMedia.dll",
|
||||
"Name": "usdMedia",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"This file describes the USD Media schemata for code generation."
|
||||
subLayers = [
|
||||
@usdGeom/schema.usda@
|
||||
]
|
||||
)
|
||||
|
||||
over "GLOBAL" (
|
||||
customData = {
|
||||
string libraryName = "usdMedia"
|
||||
string libraryPath = "pxr/usd/usdMedia"
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class SpatialAudio "SpatialAudio" (
|
||||
inherits = </Xformable>
|
||||
doc = """The SpatialAudio primitive defines basic properties for encoding
|
||||
playback of an audio file or stream within a USD Stage. The SpatialAudio
|
||||
schema derives from UsdGeomXformable since it can support full spatial
|
||||
audio while also supporting non-spatial mono and stereo sounds. One or
|
||||
more SpatialAudio prims can be placed anywhere in the namespace, though it
|
||||
is advantageous to place truly spatial audio prims under/inside the models
|
||||
from which the sound emanates, so that the audio prim need only be
|
||||
transformed relative to the model, rather than copying its animation.
|
||||
|
||||
\\section Usd_SpatialAudio_TimeScaling Timecode Attributes and Time Scaling
|
||||
\\a startTime and \\a endTime are \\ref SdfTimeCode "timecode" valued
|
||||
attributes which gives them the special behavior that
|
||||
\\ref SdfLayerOffset "layer offsets" affecting the layer in
|
||||
which one of these values is authored are applied to the attribute's value
|
||||
itself during value resolution. This allows audio playback to be kept in
|
||||
sync with time sampled animation as the animation is affected by
|
||||
\\ref SdfLayerOffset "layer offsets" in the composition. But this behavior
|
||||
brings with it some interesting edge cases and caveats when it comes to
|
||||
\\ref SdfLayerOffset "layer offsets" that include scale.
|
||||
|
||||
#### Layer Offsets do not affect Media Dilation
|
||||
Although authored layer offsets may have a time scale which can scale the
|
||||
duration between an authored \\a startTime and \\a endTime, we make no
|
||||
attempt to infer any playback dilation of the actual audio media itself.
|
||||
Given that \\a startTime and \\a endTime can be independently authored in
|
||||
different layers with differing time scales, it is not possible, in general,
|
||||
to define an "original timeframe" from which we can compute a dilation to
|
||||
composed stage-time. Even if we could compute a composed dilation this way,
|
||||
it would still be impossible to flatten a stage or layer stack into a single
|
||||
layer and still retain the composed audio dilation using this schema.
|
||||
|
||||
#### Inverting startTime and endTime
|
||||
Although we do not expect it to be common, it is possible to apply a
|
||||
negative time scale to USD layers, which mostly has the effect of reversing
|
||||
animation in the affected composition. If a negative scale is applied to a
|
||||
composition that contains authored \\a startTime and \\a endTime, it will
|
||||
reverse their relative ordering in time. Therefore, we stipulate when
|
||||
\\a playbackMode is "onceFromStartToEnd" or "loopFromStartToEnd", if
|
||||
\\a endTime is less than \\a startTime, then begin playback at \\a endTime,
|
||||
and continue until \\a startTime. When \\a startTime and \\a endTime are
|
||||
inverted, we do not, however, stipulate that playback of the audio media
|
||||
itself be inverted, since doing so "successfully" would require perfect
|
||||
knowledge of when, within the audio clip, relevant audio ends (so that we
|
||||
know how to offset the reversed audio to align it so that we reach the
|
||||
"beginning" at \\a startTime), and sounds played in reverse are not likely
|
||||
to produce desirable results.
|
||||
"""
|
||||
) {
|
||||
uniform asset filePath = @@ (
|
||||
doc = """Path to the audio file.
|
||||
In general, the formats allowed for audio files is no more constrained
|
||||
by USD than is image-type. As with images, however, usdz has stricter
|
||||
requirements based on DMA and format support in browsers and consumer
|
||||
devices. The allowed audio filetypes for usdz are M4A, MP3, WAV
|
||||
(in order of preference).
|
||||
\\sa <a href="http://graphics.pixar.com/usd/docs/Usdz-File-Format-Specification.html#UsdzFileFormatSpecification-UsdzSpecification">Usdz Specification</a>
|
||||
"""
|
||||
)
|
||||
uniform token auralMode = "spatial" (
|
||||
allowedTokens = ["spatial", "nonSpatial"]
|
||||
doc = """Determines how audio should be played.
|
||||
Valid values are:
|
||||
- spatial: Play the audio in 3D space if the device can support spatial
|
||||
audio. if not, fall back to mono.
|
||||
- nonSpatial: Play the audio without regard to the SpatialAudio prim's
|
||||
position. If the audio media contains any form of stereo or other
|
||||
multi-channel sound, it is left to the application to determine
|
||||
whether the listener's position should be taken into account. We
|
||||
expect nonSpatial to be the choice for ambient sounds and music
|
||||
sound-tracks.
|
||||
"""
|
||||
)
|
||||
uniform token playbackMode = "onceFromStart" (
|
||||
allowedTokens = ["onceFromStart", "onceFromStartToEnd", "loopFromStart",
|
||||
"loopFromStartToEnd", "loopFromStage"]
|
||||
doc = """Along with \\a startTime and \\a endTime, determines when the
|
||||
audio playback should start and stop during the stage's animation
|
||||
playback and whether the audio should loop during its duration.
|
||||
Valid values are:
|
||||
- onceFromStart: Play the audio once, starting at \\a startTime,
|
||||
continuing until the audio completes.
|
||||
- onceFromStartToEnd: Play the audio once beginning at \\a startTime,
|
||||
continuing until \\a endTime or until the audio completes, whichever
|
||||
comes first.
|
||||
- loopFromStart: Start playing the audio at \\a startTime and continue
|
||||
looping through to the stage's authored \\a endTimeCode.
|
||||
- loopFromStartToEnd: Start playing the audio at \\a startTime and
|
||||
continue looping through, stopping the audio at \\a endTime.
|
||||
- loopFromStage: Start playing the audio at the stage's authored
|
||||
\\a startTimeCode and continue looping through to the stage's authored
|
||||
\\a endTimeCode. This can be useful for ambient sounds that should always
|
||||
be active.
|
||||
"""
|
||||
)
|
||||
uniform timecode startTime = 0 (
|
||||
doc = """Expressed in the timeCodesPerSecond of the containing stage,
|
||||
\\a startTime specifies when the audio stream will start playing during
|
||||
animation playback. This value is ignored when \\a playbackMode is set
|
||||
to loopFromStage as, in this mode, the audio will always start at the
|
||||
stage's authored \\a startTimeCode.
|
||||
Note that \\a startTime is expressed as a timecode so that the stage can
|
||||
properly apply layer offsets when resolving its value. See
|
||||
\\ref Usd_SpatialAudio_TimeScaling for more details and caveats.
|
||||
"""
|
||||
)
|
||||
uniform timecode endTime = 0 (
|
||||
doc = """Expressed in the timeCodesPerSecond of the containing stage,
|
||||
\\a endTime specifies when the audio stream will cease playing during
|
||||
animation playback if the length of the referenced audio clip is
|
||||
longer than desired. This only applies if \\a playbackMode is set to
|
||||
onceFromStartToEnd or loopFromStartToEnd, otherwise the \\a endTimeCode
|
||||
of the stage is used instead of \\a endTime.
|
||||
If \\a endTime is less than \\a startTime, it is expected that the audio
|
||||
will instead be played from \\a endTime to \\a startTime.
|
||||
Note that \\a endTime is expressed as a timecode so that the stage can
|
||||
properly apply layer offsets when resolving its value.
|
||||
See \\ref Usd_SpatialAudio_TimeScaling for more details and caveats.
|
||||
"""
|
||||
)
|
||||
uniform double mediaOffset = 0 (
|
||||
doc = """Expressed in seconds, \\a mediaOffset specifies the offset from
|
||||
the referenced audio file's beginning at which we should begin playback
|
||||
when stage playback reaches the time that prim's audio should start.
|
||||
If the prim's \\a playbackMode is a looping mode, \\a mediaOffset is
|
||||
applied only to the first run-through of the audio clip; the second and
|
||||
all other loops begin from the start of the audio clip.
|
||||
"""
|
||||
)
|
||||
double gain = 1.0 (
|
||||
doc = """Multiplier on the incoming audio signal. A value of 0 "mutes"
|
||||
the signal. Negative values will be clamped to 0.
|
||||
"""
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,945 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"WARNING: THIS FILE IS GENERATED BY usdGenSchema. DO NOT EDIT."
|
||||
customLayerData = {
|
||||
dictionary multipleApplyAPISchemas = {
|
||||
string PhysicsDriveAPI = "drive"
|
||||
string PhysicsLimitAPI = "limit"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
class PhysicsScene "PhysicsScene" (
|
||||
doc = "General physics simulation properties, required for simulation."
|
||||
)
|
||||
{
|
||||
vector3f physics:gravityDirection = (0, 0, 0) (
|
||||
displayName = "Gravity Direction"
|
||||
doc = """Gravity direction vector in simulation world space. Will be
|
||||
normalized before use. A zero vector is a request to use the negative
|
||||
upAxis. Unitless."""
|
||||
)
|
||||
float physics:gravityMagnitude = -inf (
|
||||
displayName = "Gravity Magnitude"
|
||||
doc = """Gravity acceleration magnitude in simulation world space.
|
||||
A negative value is a request to use a value equivalent to earth
|
||||
gravity regardless of the metersPerUnit scaling used by this scene.
|
||||
Units: distance/second/second."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsRigidBodyAPI" (
|
||||
doc = """Applies physics body attributes to any UsdGeomXformable prim and
|
||||
marks that prim to be driven by a simulation. If a simulation is running
|
||||
it will update this prim's pose. All prims in the hierarchy below this
|
||||
prim should move accordingly."""
|
||||
)
|
||||
{
|
||||
vector3f physics:angularVelocity = (0, 0, 0) (
|
||||
displayName = "Angular Velocity"
|
||||
doc = """Angular velocity in the same space as the node's xform.
|
||||
Units: degrees/second."""
|
||||
)
|
||||
bool physics:kinematicEnabled = 0 (
|
||||
displayName = "Kinematic Enabled"
|
||||
doc = """Determines whether the body is kinematic or not. A kinematic
|
||||
body is a body that is moved through animated poses or through
|
||||
user defined poses. The simulation derives velocities for the
|
||||
kinematic body based on the external motion. When a continuous motion
|
||||
is not desired, this kinematic flag should be set to false."""
|
||||
)
|
||||
bool physics:rigidBodyEnabled = 1 (
|
||||
displayName = "Rigid Body Enabled"
|
||||
doc = "Determines if this PhysicsRigidBodyAPI is enabled."
|
||||
)
|
||||
rel physics:simulationOwner (
|
||||
displayName = "Simulation Owner"
|
||||
doc = """Single PhysicsScene that will simulate this body. By
|
||||
default this is the first PhysicsScene found in the stage using
|
||||
UsdStage::Traverse()."""
|
||||
)
|
||||
uniform bool physics:startsAsleep = 0 (
|
||||
displayName = "Starts as Asleep"
|
||||
doc = "Determines if the body is asleep when the simulation starts."
|
||||
)
|
||||
vector3f physics:velocity = (0, 0, 0) (
|
||||
displayName = "Linear Velocity"
|
||||
doc = """Linear velocity in the same space as the node's xform.
|
||||
Units: distance/second."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsMassAPI" (
|
||||
doc = """Defines explicit mass properties (mass, density, inertia etc.).
|
||||
MassAPI can be applied to any object that has a PhysicsCollisionAPI or
|
||||
a PhysicsRigidBodyAPI."""
|
||||
)
|
||||
{
|
||||
point3f physics:centerOfMass = (0, 0, 0) (
|
||||
displayName = "Center of Mass"
|
||||
doc = "Center of mass in the prim's local space. Units: distance."
|
||||
)
|
||||
float physics:density = 0 (
|
||||
displayName = "Density"
|
||||
doc = """If non-zero, specifies the density of the object.
|
||||
In the context of rigid body physics, density indirectly results in
|
||||
setting mass via (mass = density x volume of the object). How the
|
||||
volume is computed is up to implementation of the physics system.
|
||||
It is generally computed from the collision approximation rather than
|
||||
the graphical mesh. In the case where both density and mass are
|
||||
specified for the same object, mass has precedence over density.
|
||||
Unlike mass, child's prim's density overrides parent prim's density
|
||||
as it is accumulative. Note that density of a collisionAPI can be also
|
||||
alternatively set through a PhysicsMaterialAPI. The material density
|
||||
has the weakest precedence in density definition. Note if density is
|
||||
0.0 it is ignored. Units: mass/distance/distance/distance."""
|
||||
)
|
||||
float3 physics:diagonalInertia = (0, 0, 0) (
|
||||
displayName = "Diagonal Inertia"
|
||||
doc = """If non-zero, specifies diagonalized inertia tensor along the
|
||||
principal axes. Note if diagonalInertial is (0.0, 0.0, 0.0) it is
|
||||
ignored. Units: mass*distance*distance."""
|
||||
)
|
||||
float physics:mass = 0 (
|
||||
displayName = "Mass"
|
||||
doc = """If non-zero, directly specifies the mass of the object.
|
||||
Note that any child prim can also have a mass when they apply massAPI.
|
||||
In this case, the precedence rule is 'parent mass overrides the
|
||||
child's'. This may come as counter-intuitive, but mass is a computed
|
||||
quantity and in general not accumulative. For example, if a parent
|
||||
has mass of 10, and one of two children has mass of 20, allowing
|
||||
child's mass to override its parent results in a mass of -10 for the
|
||||
other child. Note if mass is 0.0 it is ignored. Units: mass.
|
||||
"""
|
||||
)
|
||||
quatf physics:principalAxes = (1, 0, 0, 0) (
|
||||
displayName = "Principal Axes"
|
||||
doc = """Orientation of the inertia tensor's principal axes in the
|
||||
prim's local space."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsCollisionAPI" (
|
||||
doc = """Applies collision attributes to a UsdGeomXformable prim. If a
|
||||
simulation is running, this geometry will collide with other geometries that
|
||||
have PhysicsCollisionAPI applied. If a prim in the parent hierarchy has the
|
||||
RigidBodyAPI applied, this collider is a part of that body. If there is
|
||||
no body in the parent hierarchy, this collider is considered to be static."""
|
||||
)
|
||||
{
|
||||
bool physics:collisionEnabled = 1 (
|
||||
displayName = "Collision Enabled"
|
||||
doc = "Determines if the PhysicsCollisionAPI is enabled."
|
||||
)
|
||||
rel physics:simulationOwner (
|
||||
displayName = "Simulation Owner"
|
||||
doc = """Single PhysicsScene that will simulate this collider.
|
||||
By default this object belongs to the first PhysicsScene.
|
||||
Note that if a RigidBodyAPI in the hierarchy above has a different
|
||||
simulationOwner then it has a precedence over this relationship."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsMeshCollisionAPI" (
|
||||
doc = """Attributes to control how a Mesh is made into a collider.
|
||||
Can be applied to only a USDGeomMesh in addition to its
|
||||
PhysicsCollisionAPI."""
|
||||
)
|
||||
{
|
||||
uniform token physics:approximation = "none" (
|
||||
allowedTokens = ["none", "convexDecomposition", "convexHull", "boundingSphere", "boundingCube", "meshSimplification"]
|
||||
displayName = "Approximation"
|
||||
doc = """Determines the mesh's collision approximation:
|
||||
\t\"none\" - The mesh geometry is used directly as a collider without any
|
||||
approximation.
|
||||
\t\"convexDecomposition\" - A convex mesh decomposition is performed. This
|
||||
results in a set of convex mesh colliders.
|
||||
\t\"convexHull\" - A convex hull of the mesh is generated and used as the
|
||||
collider.
|
||||
\t\"boundingSphere\" - A bounding sphere is computed around the mesh and used
|
||||
as a collider.
|
||||
\t\"boundingCube\" - An optimally fitting box collider is computed around the
|
||||
mesh.
|
||||
\t\"meshSimplification\" - A mesh simplification step is performed, resulting
|
||||
in a simplified triangle mesh collider."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsMaterialAPI" (
|
||||
doc = """ Adds simulation material properties to a Material. All collisions
|
||||
that have a relationship to this material will have their collision response
|
||||
defined through this material."""
|
||||
)
|
||||
{
|
||||
float physics:density = 0 (
|
||||
displayName = "Density"
|
||||
doc = """If non-zero, defines the density of the material. This can be
|
||||
used for body mass computation, see PhysicsMassAPI.
|
||||
Note that if the density is 0.0 it is ignored.
|
||||
Units: mass/distance/distance/distance."""
|
||||
)
|
||||
float physics:dynamicFriction = 0 (
|
||||
displayName = "Dynamic Friction"
|
||||
doc = "Dynamic friction coefficient. Unitless."
|
||||
)
|
||||
float physics:restitution = 0 (
|
||||
displayName = "Restitution"
|
||||
doc = "Restitution coefficient. Unitless."
|
||||
)
|
||||
float physics:staticFriction = 0 (
|
||||
displayName = "Static Friction"
|
||||
doc = "Static friction coefficient. Unitless."
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsCollisionGroup "PhysicsCollisionGroup" (
|
||||
apiSchemas = ["CollectionAPI:colliders"]
|
||||
doc = """Defines a collision group for coarse filtering. When a collision
|
||||
occurs between two objects that have a PhysicsCollisionGroup assigned,
|
||||
they will collide with each other unless this PhysicsCollisionGroup pair
|
||||
is filtered. See filteredGroups attribute.
|
||||
|
||||
A CollectionAPI:colliders maintains a list of PhysicsCollisionAPI rel-s that
|
||||
defines the members of this Collisiongroup.
|
||||
"""
|
||||
)
|
||||
{
|
||||
rel physics:filteredGroups (
|
||||
displayName = "Filtered Groups"
|
||||
doc = """References a list of PhysicsCollisionGroups with which
|
||||
collisions should be ignored."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsFilteredPairsAPI" (
|
||||
doc = '''API to describe fine-grained filtering. If a collision between
|
||||
two objects occurs, this pair might be filtered if the pair is defined
|
||||
through this API. This API can be applied either to a body or collision
|
||||
or even articulation. The "filteredPairs" defines what objects it should
|
||||
not collide against. Note that FilteredPairsAPI filtering has precedence
|
||||
over CollisionGroup filtering.'''
|
||||
)
|
||||
{
|
||||
rel physics:filteredPairs (
|
||||
displayName = "Filtered Pairs"
|
||||
doc = "Relationship to objects that should be filtered."
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsJoint "PhysicsJoint" (
|
||||
doc = """A joint constrains the movement of rigid bodies. Joint can be
|
||||
created between two rigid bodies or between one rigid body and world.
|
||||
By default joint primitive defines a D6 joint where all degrees of
|
||||
freedom are free. Three linear and three angular degrees of freedom.
|
||||
Note that default behavior is to disable collision between jointed bodies.
|
||||
"""
|
||||
)
|
||||
{
|
||||
rel physics:body0 (
|
||||
displayName = "Body 0"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
rel physics:body1 (
|
||||
displayName = "Body 1"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
float physics:breakForce = inf (
|
||||
displayName = "Break Force"
|
||||
doc = """Joint break force. If set, joint is to break when this force
|
||||
limit is reached. (Used for linear DOFs.)
|
||||
Units: mass * distance / second / second"""
|
||||
)
|
||||
float physics:breakTorque = inf (
|
||||
displayName = "Break Torque"
|
||||
doc = """Joint break torque. If set, joint is to break when this torque
|
||||
limit is reached. (Used for angular DOFs.)
|
||||
Units: mass * distance * distance / second / second"""
|
||||
)
|
||||
bool physics:collisionEnabled = 0 (
|
||||
displayName = "Collision Enabled"
|
||||
doc = "Determines if the jointed subtrees should collide or not."
|
||||
)
|
||||
uniform bool physics:excludeFromArticulation = 0 (
|
||||
displayName = "Exclude From Articulation"
|
||||
doc = "Determines if the joint can be included in an Articulation."
|
||||
)
|
||||
bool physics:jointEnabled = 1 (
|
||||
displayName = "Joint Enabled"
|
||||
doc = "Determines if the joint is enabled."
|
||||
)
|
||||
point3f physics:localPos0 = (0, 0, 0) (
|
||||
displayName = "Local Position 0"
|
||||
doc = "Relative position of the joint frame to body0's frame."
|
||||
)
|
||||
point3f physics:localPos1 = (0, 0, 0) (
|
||||
displayName = "Local Position 1"
|
||||
doc = "Relative position of the joint frame to body1's frame."
|
||||
)
|
||||
quatf physics:localRot0 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 0"
|
||||
doc = "Relative orientation of the joint frame to body0's frame."
|
||||
)
|
||||
quatf physics:localRot1 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 1"
|
||||
doc = "Relative orientation of the joint frame to body1's frame."
|
||||
)
|
||||
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 classification of 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.
|
||||
|
||||
See for more detail about how
|
||||
purpose is computed and used."""
|
||||
)
|
||||
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.'''
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsRevoluteJoint "PhysicsRevoluteJoint" (
|
||||
doc = """Predefined revolute joint type (rotation along revolute joint
|
||||
axis is permitted.)"""
|
||||
)
|
||||
{
|
||||
uniform token physics:axis = "X" (
|
||||
allowedTokens = ["X", "Y", "Z"]
|
||||
displayName = "Axis"
|
||||
doc = "Joint axis."
|
||||
)
|
||||
rel physics:body0 (
|
||||
displayName = "Body 0"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
rel physics:body1 (
|
||||
displayName = "Body 1"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
float physics:breakForce = inf (
|
||||
displayName = "Break Force"
|
||||
doc = """Joint break force. If set, joint is to break when this force
|
||||
limit is reached. (Used for linear DOFs.)
|
||||
Units: mass * distance / second / second"""
|
||||
)
|
||||
float physics:breakTorque = inf (
|
||||
displayName = "Break Torque"
|
||||
doc = """Joint break torque. If set, joint is to break when this torque
|
||||
limit is reached. (Used for angular DOFs.)
|
||||
Units: mass * distance * distance / second / second"""
|
||||
)
|
||||
bool physics:collisionEnabled = 0 (
|
||||
displayName = "Collision Enabled"
|
||||
doc = "Determines if the jointed subtrees should collide or not."
|
||||
)
|
||||
uniform bool physics:excludeFromArticulation = 0 (
|
||||
displayName = "Exclude From Articulation"
|
||||
doc = "Determines if the joint can be included in an Articulation."
|
||||
)
|
||||
bool physics:jointEnabled = 1 (
|
||||
displayName = "Joint Enabled"
|
||||
doc = "Determines if the joint is enabled."
|
||||
)
|
||||
point3f physics:localPos0 = (0, 0, 0) (
|
||||
displayName = "Local Position 0"
|
||||
doc = "Relative position of the joint frame to body0's frame."
|
||||
)
|
||||
point3f physics:localPos1 = (0, 0, 0) (
|
||||
displayName = "Local Position 1"
|
||||
doc = "Relative position of the joint frame to body1's frame."
|
||||
)
|
||||
quatf physics:localRot0 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 0"
|
||||
doc = "Relative orientation of the joint frame to body0's frame."
|
||||
)
|
||||
quatf physics:localRot1 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 1"
|
||||
doc = "Relative orientation of the joint frame to body1's frame."
|
||||
)
|
||||
float physics:lowerLimit = -inf (
|
||||
displayName = "Lower Limit"
|
||||
doc = """Lower limit. Units: degrees. -inf means not limited in
|
||||
negative direction."""
|
||||
)
|
||||
float physics:upperLimit = inf (
|
||||
displayName = "Upper Limit"
|
||||
doc = """Upper limit. Units: degrees. inf means not limited in
|
||||
positive direction."""
|
||||
)
|
||||
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 classification of 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.
|
||||
|
||||
See for more detail about how
|
||||
purpose is computed and used."""
|
||||
)
|
||||
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.'''
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsPrismaticJoint "PhysicsPrismaticJoint" (
|
||||
doc = """Predefined prismatic joint type (translation along prismatic
|
||||
joint axis is permitted.)"""
|
||||
)
|
||||
{
|
||||
uniform token physics:axis = "X" (
|
||||
allowedTokens = ["X", "Y", "Z"]
|
||||
displayName = "Axis"
|
||||
doc = "Joint axis."
|
||||
)
|
||||
rel physics:body0 (
|
||||
displayName = "Body 0"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
rel physics:body1 (
|
||||
displayName = "Body 1"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
float physics:breakForce = inf (
|
||||
displayName = "Break Force"
|
||||
doc = """Joint break force. If set, joint is to break when this force
|
||||
limit is reached. (Used for linear DOFs.)
|
||||
Units: mass * distance / second / second"""
|
||||
)
|
||||
float physics:breakTorque = inf (
|
||||
displayName = "Break Torque"
|
||||
doc = """Joint break torque. If set, joint is to break when this torque
|
||||
limit is reached. (Used for angular DOFs.)
|
||||
Units: mass * distance * distance / second / second"""
|
||||
)
|
||||
bool physics:collisionEnabled = 0 (
|
||||
displayName = "Collision Enabled"
|
||||
doc = "Determines if the jointed subtrees should collide or not."
|
||||
)
|
||||
uniform bool physics:excludeFromArticulation = 0 (
|
||||
displayName = "Exclude From Articulation"
|
||||
doc = "Determines if the joint can be included in an Articulation."
|
||||
)
|
||||
bool physics:jointEnabled = 1 (
|
||||
displayName = "Joint Enabled"
|
||||
doc = "Determines if the joint is enabled."
|
||||
)
|
||||
point3f physics:localPos0 = (0, 0, 0) (
|
||||
displayName = "Local Position 0"
|
||||
doc = "Relative position of the joint frame to body0's frame."
|
||||
)
|
||||
point3f physics:localPos1 = (0, 0, 0) (
|
||||
displayName = "Local Position 1"
|
||||
doc = "Relative position of the joint frame to body1's frame."
|
||||
)
|
||||
quatf physics:localRot0 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 0"
|
||||
doc = "Relative orientation of the joint frame to body0's frame."
|
||||
)
|
||||
quatf physics:localRot1 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 1"
|
||||
doc = "Relative orientation of the joint frame to body1's frame."
|
||||
)
|
||||
float physics:lowerLimit = -inf (
|
||||
displayName = "Lower Limit"
|
||||
doc = """Lower limit. Units: distance. -inf means not limited in
|
||||
negative direction."""
|
||||
)
|
||||
float physics:upperLimit = inf (
|
||||
displayName = "Upper Limit"
|
||||
doc = """Upper limit. Units: distance. inf means not limited in
|
||||
positive direction."""
|
||||
)
|
||||
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 classification of 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.
|
||||
|
||||
See for more detail about how
|
||||
purpose is computed and used."""
|
||||
)
|
||||
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.'''
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsSphericalJoint "PhysicsSphericalJoint" (
|
||||
doc = """Predefined spherical joint type (Removes linear degrees of
|
||||
freedom, cone limit may restrict the motion in a given range.) It allows
|
||||
two limit values, which when equal create a circular, else an elliptic
|
||||
cone limit around the limit axis."""
|
||||
)
|
||||
{
|
||||
uniform token physics:axis = "X" (
|
||||
allowedTokens = ["X", "Y", "Z"]
|
||||
displayName = "Axis"
|
||||
doc = "Cone limit axis."
|
||||
)
|
||||
rel physics:body0 (
|
||||
displayName = "Body 0"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
rel physics:body1 (
|
||||
displayName = "Body 1"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
float physics:breakForce = inf (
|
||||
displayName = "Break Force"
|
||||
doc = """Joint break force. If set, joint is to break when this force
|
||||
limit is reached. (Used for linear DOFs.)
|
||||
Units: mass * distance / second / second"""
|
||||
)
|
||||
float physics:breakTorque = inf (
|
||||
displayName = "Break Torque"
|
||||
doc = """Joint break torque. If set, joint is to break when this torque
|
||||
limit is reached. (Used for angular DOFs.)
|
||||
Units: mass * distance * distance / second / second"""
|
||||
)
|
||||
bool physics:collisionEnabled = 0 (
|
||||
displayName = "Collision Enabled"
|
||||
doc = "Determines if the jointed subtrees should collide or not."
|
||||
)
|
||||
float physics:coneAngle0Limit = -1 (
|
||||
displayName = "Cone Angle0 Limit"
|
||||
doc = """Cone limit from the primary joint axis in the local0 frame
|
||||
toward the next axis. (Next axis of X is Y, and of Z is X.) A
|
||||
negative value means not limited. Units: degrees."""
|
||||
)
|
||||
float physics:coneAngle1Limit = -1 (
|
||||
displayName = "Cone Angle1 Limit"
|
||||
doc = """Cone limit from the primary joint axis in the local0 frame
|
||||
toward the second to next axis. A negative value means not limited.
|
||||
Units: degrees."""
|
||||
)
|
||||
uniform bool physics:excludeFromArticulation = 0 (
|
||||
displayName = "Exclude From Articulation"
|
||||
doc = "Determines if the joint can be included in an Articulation."
|
||||
)
|
||||
bool physics:jointEnabled = 1 (
|
||||
displayName = "Joint Enabled"
|
||||
doc = "Determines if the joint is enabled."
|
||||
)
|
||||
point3f physics:localPos0 = (0, 0, 0) (
|
||||
displayName = "Local Position 0"
|
||||
doc = "Relative position of the joint frame to body0's frame."
|
||||
)
|
||||
point3f physics:localPos1 = (0, 0, 0) (
|
||||
displayName = "Local Position 1"
|
||||
doc = "Relative position of the joint frame to body1's frame."
|
||||
)
|
||||
quatf physics:localRot0 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 0"
|
||||
doc = "Relative orientation of the joint frame to body0's frame."
|
||||
)
|
||||
quatf physics:localRot1 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 1"
|
||||
doc = "Relative orientation of the joint frame to body1's frame."
|
||||
)
|
||||
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 classification of 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.
|
||||
|
||||
See for more detail about how
|
||||
purpose is computed and used."""
|
||||
)
|
||||
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.'''
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsDistanceJoint "PhysicsDistanceJoint" (
|
||||
doc = """Predefined distance joint type (Distance between rigid bodies
|
||||
may be limited to given minimum or maximum distance.)"""
|
||||
)
|
||||
{
|
||||
rel physics:body0 (
|
||||
displayName = "Body 0"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
rel physics:body1 (
|
||||
displayName = "Body 1"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
float physics:breakForce = inf (
|
||||
displayName = "Break Force"
|
||||
doc = """Joint break force. If set, joint is to break when this force
|
||||
limit is reached. (Used for linear DOFs.)
|
||||
Units: mass * distance / second / second"""
|
||||
)
|
||||
float physics:breakTorque = inf (
|
||||
displayName = "Break Torque"
|
||||
doc = """Joint break torque. If set, joint is to break when this torque
|
||||
limit is reached. (Used for angular DOFs.)
|
||||
Units: mass * distance * distance / second / second"""
|
||||
)
|
||||
bool physics:collisionEnabled = 0 (
|
||||
displayName = "Collision Enabled"
|
||||
doc = "Determines if the jointed subtrees should collide or not."
|
||||
)
|
||||
uniform bool physics:excludeFromArticulation = 0 (
|
||||
displayName = "Exclude From Articulation"
|
||||
doc = "Determines if the joint can be included in an Articulation."
|
||||
)
|
||||
bool physics:jointEnabled = 1 (
|
||||
displayName = "Joint Enabled"
|
||||
doc = "Determines if the joint is enabled."
|
||||
)
|
||||
point3f physics:localPos0 = (0, 0, 0) (
|
||||
displayName = "Local Position 0"
|
||||
doc = "Relative position of the joint frame to body0's frame."
|
||||
)
|
||||
point3f physics:localPos1 = (0, 0, 0) (
|
||||
displayName = "Local Position 1"
|
||||
doc = "Relative position of the joint frame to body1's frame."
|
||||
)
|
||||
quatf physics:localRot0 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 0"
|
||||
doc = "Relative orientation of the joint frame to body0's frame."
|
||||
)
|
||||
quatf physics:localRot1 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 1"
|
||||
doc = "Relative orientation of the joint frame to body1's frame."
|
||||
)
|
||||
float physics:maxDistance = -1 (
|
||||
displayName = "Maximum Distance"
|
||||
doc = """Maximum distance. If attribute is negative, the joint is not
|
||||
limited. Units: distance."""
|
||||
)
|
||||
float physics:minDistance = -1 (
|
||||
displayName = "Minimum Distance"
|
||||
doc = """Minimum distance. If attribute is negative, the joint is not
|
||||
limited. Units: distance."""
|
||||
)
|
||||
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 classification of 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.
|
||||
|
||||
See for more detail about how
|
||||
purpose is computed and used."""
|
||||
)
|
||||
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.'''
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsFixedJoint "PhysicsFixedJoint" (
|
||||
doc = """Predefined fixed joint type (All degrees of freedom are
|
||||
removed.)"""
|
||||
)
|
||||
{
|
||||
rel physics:body0 (
|
||||
displayName = "Body 0"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
rel physics:body1 (
|
||||
displayName = "Body 1"
|
||||
doc = "Relationship to any UsdGeomXformable."
|
||||
)
|
||||
float physics:breakForce = inf (
|
||||
displayName = "Break Force"
|
||||
doc = """Joint break force. If set, joint is to break when this force
|
||||
limit is reached. (Used for linear DOFs.)
|
||||
Units: mass * distance / second / second"""
|
||||
)
|
||||
float physics:breakTorque = inf (
|
||||
displayName = "Break Torque"
|
||||
doc = """Joint break torque. If set, joint is to break when this torque
|
||||
limit is reached. (Used for angular DOFs.)
|
||||
Units: mass * distance * distance / second / second"""
|
||||
)
|
||||
bool physics:collisionEnabled = 0 (
|
||||
displayName = "Collision Enabled"
|
||||
doc = "Determines if the jointed subtrees should collide or not."
|
||||
)
|
||||
uniform bool physics:excludeFromArticulation = 0 (
|
||||
displayName = "Exclude From Articulation"
|
||||
doc = "Determines if the joint can be included in an Articulation."
|
||||
)
|
||||
bool physics:jointEnabled = 1 (
|
||||
displayName = "Joint Enabled"
|
||||
doc = "Determines if the joint is enabled."
|
||||
)
|
||||
point3f physics:localPos0 = (0, 0, 0) (
|
||||
displayName = "Local Position 0"
|
||||
doc = "Relative position of the joint frame to body0's frame."
|
||||
)
|
||||
point3f physics:localPos1 = (0, 0, 0) (
|
||||
displayName = "Local Position 1"
|
||||
doc = "Relative position of the joint frame to body1's frame."
|
||||
)
|
||||
quatf physics:localRot0 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 0"
|
||||
doc = "Relative orientation of the joint frame to body0's frame."
|
||||
)
|
||||
quatf physics:localRot1 = (1, 0, 0, 0) (
|
||||
displayName = "Local Rotation 1"
|
||||
doc = "Relative orientation of the joint frame to body1's frame."
|
||||
)
|
||||
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 classification of 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.
|
||||
|
||||
See for more detail about how
|
||||
purpose is computed and used."""
|
||||
)
|
||||
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.'''
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsLimitAPI" (
|
||||
doc = '''The PhysicsLimitAPI can be applied to a PhysicsJoint and will
|
||||
restrict the movement along an axis. PhysicsLimitAPI is a multipleApply
|
||||
schema: The PhysicsJoint can be restricted along "transX", "transY",
|
||||
"transZ", "rotX", "rotY", "rotZ", "distance". Setting these as a
|
||||
multipleApply schema TfToken name will define the degree of freedom the
|
||||
PhysicsLimitAPI is applied to. Note that if the low limit is higher than
|
||||
the high limit, motion along this axis is considered locked.'''
|
||||
)
|
||||
{
|
||||
float physics:high = inf (
|
||||
displayName = "High Limit"
|
||||
doc = """Upper limit. Units: degrees or distance depending on trans or
|
||||
rot axis applied to. inf means not limited in positive direction."""
|
||||
)
|
||||
float physics:low = -inf (
|
||||
displayName = "Low Limit"
|
||||
doc = """Lower limit. Units: degrees or distance depending on trans or
|
||||
rot axis applied to. -inf means not limited in negative direction."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsDriveAPI" (
|
||||
doc = '''The PhysicsDriveAPI when applied to any joint primitive will drive
|
||||
the joint towards a given target. The PhysicsDriveAPI is a multipleApply
|
||||
schema: drive can be set per axis "transX", "transY", "transZ", "rotX",
|
||||
"rotY", "rotZ" or its "linear" for prismatic joint or "angular" for revolute
|
||||
joints. Setting these as a multipleApply schema TfToken name will
|
||||
define the degree of freedom the DriveAPI is applied to. Each drive is an
|
||||
implicit force-limited damped spring:
|
||||
Force or acceleration = stiffness * (targetPosition - position)
|
||||
+ damping * (targetVelocity - velocity)'''
|
||||
)
|
||||
{
|
||||
float physics:damping = 0 (
|
||||
doc = """Damping of the drive. Units:
|
||||
\t\tif linear drive: mass/second
|
||||
\t\tIf angular drive: mass*DIST_UNITS*DIST_UNITS/second/second/degrees."""
|
||||
)
|
||||
float physics:maxForce = inf (
|
||||
displayName = "Max Force"
|
||||
doc = """Maximum force that can be applied to drive. Units:
|
||||
if linear drive: mass*DIST_UNITS/second/second
|
||||
if angular drive: mass*DIST_UNITS*DIST_UNITS/second/second
|
||||
inf means not limited. Must be non-negative.
|
||||
"""
|
||||
)
|
||||
float physics:stiffness = 0 (
|
||||
doc = """Stiffness of the drive. Units:
|
||||
\t\tif linear drive: mass/second/second
|
||||
\t\tif angular drive: mass*DIST_UNITS*DIST_UNITS/degree/second/second."""
|
||||
)
|
||||
float physics:targetPosition = 0 (
|
||||
displayName = "Target Position"
|
||||
doc = """Target value for position. Units:
|
||||
if linear drive: distance
|
||||
if angular drive: degrees."""
|
||||
)
|
||||
float physics:targetVelocity = 0 (
|
||||
displayName = "Target Velocity"
|
||||
doc = """Target value for velocity. Units:
|
||||
if linear drive: distance/second
|
||||
if angular drive: degrees/second."""
|
||||
)
|
||||
uniform token physics:type = "force" (
|
||||
allowedTokens = ["force", "acceleration"]
|
||||
displayName = "Type"
|
||||
doc = """Drive spring is for the acceleration at the joint (rather
|
||||
than the force)."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsArticulationRootAPI" (
|
||||
doc = """PhysicsArticulationRootAPI can be applied to a scene graph node,
|
||||
and marks the subtree rooted here for inclusion in one or more reduced
|
||||
coordinate articulations. For floating articulations, this should be on
|
||||
the root body. For fixed articulations (robotics jargon for e.g. a robot
|
||||
arm for welding that is bolted to the floor), this API can be on a direct
|
||||
or indirect parent of the root joint which is connected to the world, or
|
||||
on the joint itself.."""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"kilogramsPerUnit": {
|
||||
"appliesTo": [
|
||||
"layers"
|
||||
],
|
||||
"default": 1.0,
|
||||
"displayGroup": "Stage",
|
||||
"type": "double"
|
||||
}
|
||||
},
|
||||
"Types": {
|
||||
"UsdPhysicsArticulationRootAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsArticulationRootAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdPhysicsCollisionAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsCollisionAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdPhysicsCollisionGroup": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsCollisionGroup"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdPhysicsDistanceJoint": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsDistanceJoint"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdPhysicsJoint"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdPhysicsDriveAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsDriveAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "multipleApplyAPI"
|
||||
},
|
||||
"UsdPhysicsFilteredPairsAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsFilteredPairsAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdPhysicsFixedJoint": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsFixedJoint"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdPhysicsJoint"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdPhysicsJoint": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsJoint"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomImageable"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdPhysicsLimitAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsLimitAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "multipleApplyAPI"
|
||||
},
|
||||
"UsdPhysicsMassAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsMassAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdPhysicsMaterialAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsMaterialAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdPhysicsMeshCollisionAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsMeshCollisionAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdPhysicsPrismaticJoint": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsPrismaticJoint"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdPhysicsJoint"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdPhysicsRevoluteJoint": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsRevoluteJoint"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdPhysicsJoint"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdPhysicsRigidBodyAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsRigidBodyAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdPhysicsScene": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsScene"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdPhysicsSphericalJoint": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PhysicsSphericalJoint"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdPhysicsJoint"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdPhysics.dll",
|
||||
"Name": "usdPhysics",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,849 @@
|
||||
#usda 1.0
|
||||
(
|
||||
subLayers = [
|
||||
@usdGeom/schema.usda@
|
||||
]
|
||||
)
|
||||
|
||||
over "GLOBAL" (
|
||||
customData = {
|
||||
string libraryName = "usdPhysics"
|
||||
string libraryPath = "pxr/usd/usdPhysics"
|
||||
dictionary libraryTokens = {
|
||||
dictionary colliders = {
|
||||
string doc = """
|
||||
This token represents the collection name to use
|
||||
with UsdCollectionAPI to represent colliders
|
||||
of a CollisionGroup prim.
|
||||
"""
|
||||
}
|
||||
dictionary kilogramsPerUnit = {
|
||||
string doc = """Stage-level metadata that encodes a scene's
|
||||
linear unit of measure as kilograms per encoded unit."""
|
||||
}
|
||||
dictionary transX = {
|
||||
string doc = """
|
||||
This token represents the translate around X axis degree of freedom
|
||||
used in Joint Limits and Drives.
|
||||
"""
|
||||
}
|
||||
dictionary transY = {
|
||||
string doc = """
|
||||
This token represents the translate around Y axis degree of freedom
|
||||
used in Joint Limits and Drives.
|
||||
"""
|
||||
}
|
||||
dictionary transZ = {
|
||||
string doc = """
|
||||
This token represents the translate around Z axis degree of freedom
|
||||
used in Joint Limits and Drives.
|
||||
"""
|
||||
}
|
||||
dictionary rotX = {
|
||||
string doc = """
|
||||
This token represents the rotate around X axis degree of freedom
|
||||
used in Joint Limits and Drives.
|
||||
"""
|
||||
}
|
||||
dictionary rotY = {
|
||||
string doc = """
|
||||
This token represents the rotate around Y axis degree of freedom
|
||||
used in Joint Limits and Drives.
|
||||
"""
|
||||
}
|
||||
dictionary rotZ = {
|
||||
string doc = """
|
||||
This token represents the rotate around Z axis degree of freedom
|
||||
used in Joint Limits and Drives.
|
||||
"""
|
||||
}
|
||||
dictionary linear = {
|
||||
string doc = """
|
||||
This token represents the linear degree of freedom
|
||||
used in Prismatic Joint Drive.
|
||||
"""
|
||||
}
|
||||
dictionary angular = {
|
||||
string doc = """
|
||||
This token represents the angular degree of freedom
|
||||
used in Revolute Joint Drive.
|
||||
"""
|
||||
}
|
||||
dictionary distance = {
|
||||
string doc = """
|
||||
This token represents the distance limit used for generic D6 joint.
|
||||
"""
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class PhysicsScene "PhysicsScene"
|
||||
(
|
||||
customData = {
|
||||
string className = "Scene"
|
||||
}
|
||||
doc = """General physics simulation properties, required for simulation."""
|
||||
|
||||
inherits = </Typed>
|
||||
)
|
||||
{
|
||||
vector3f physics:gravityDirection = (0.0, 0.0, 0.0) (
|
||||
customData = {
|
||||
string apiName = "gravityDirection"
|
||||
}
|
||||
displayName = "Gravity Direction"
|
||||
doc = """Gravity direction vector in simulation world space. Will be
|
||||
normalized before use. A zero vector is a request to use the negative
|
||||
upAxis. Unitless."""
|
||||
)
|
||||
|
||||
float physics:gravityMagnitude = -inf (
|
||||
customData = {
|
||||
string apiName = "gravityMagnitude"
|
||||
}
|
||||
displayName = "Gravity Magnitude"
|
||||
doc = """Gravity acceleration magnitude in simulation world space.
|
||||
A negative value is a request to use a value equivalent to earth
|
||||
gravity regardless of the metersPerUnit scaling used by this scene.
|
||||
Units: distance/second/second."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsRigidBodyAPI"
|
||||
(
|
||||
customData = {
|
||||
string className = "RigidBodyAPI"
|
||||
}
|
||||
doc = """Applies physics body attributes to any UsdGeomXformable prim and
|
||||
marks that prim to be driven by a simulation. If a simulation is running
|
||||
it will update this prim's pose. All prims in the hierarchy below this
|
||||
prim should move accordingly."""
|
||||
|
||||
inherits = </APISchemaBase>
|
||||
)
|
||||
{
|
||||
|
||||
bool physics:rigidBodyEnabled = true (
|
||||
customData = {
|
||||
string apiName = "rigidBodyEnabled"
|
||||
}
|
||||
displayName = "Rigid Body Enabled"
|
||||
doc = """Determines if this PhysicsRigidBodyAPI is enabled."""
|
||||
)
|
||||
|
||||
bool physics:kinematicEnabled = false (
|
||||
customData = {
|
||||
string apiName = "kinematicEnabled"
|
||||
}
|
||||
displayName = "Kinematic Enabled"
|
||||
doc = """Determines whether the body is kinematic or not. A kinematic
|
||||
body is a body that is moved through animated poses or through
|
||||
user defined poses. The simulation derives velocities for the
|
||||
kinematic body based on the external motion. When a continuous motion
|
||||
is not desired, this kinematic flag should be set to false."""
|
||||
)
|
||||
|
||||
rel physics:simulationOwner (
|
||||
customData = {
|
||||
string apiName = "simulationOwner"
|
||||
}
|
||||
displayName = "Simulation Owner"
|
||||
doc = """Single PhysicsScene that will simulate this body. By
|
||||
default this is the first PhysicsScene found in the stage using
|
||||
UsdStage::Traverse()."""
|
||||
|
||||
)
|
||||
|
||||
uniform bool physics:startsAsleep = false (
|
||||
customData = {
|
||||
string apiName = "startsAsleep"
|
||||
}
|
||||
displayName = "Starts as Asleep"
|
||||
doc = "Determines if the body is asleep when the simulation starts."
|
||||
)
|
||||
|
||||
vector3f physics:velocity= (0.0, 0.0, 0.0) (
|
||||
customData = {
|
||||
string apiName = "velocity"
|
||||
}
|
||||
displayName = "Linear Velocity"
|
||||
doc = """Linear velocity in the same space as the node's xform.
|
||||
Units: distance/second."""
|
||||
)
|
||||
|
||||
vector3f physics:angularVelocity = (0.0, 0.0, 0.0) (
|
||||
customData = {
|
||||
string apiName = "angularVelocity"
|
||||
}
|
||||
displayName = "Angular Velocity"
|
||||
doc = """Angular velocity in the same space as the node's xform.
|
||||
Units: degrees/second."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsMassAPI"
|
||||
(
|
||||
customData = {
|
||||
string className = "MassAPI"
|
||||
}
|
||||
|
||||
doc = """Defines explicit mass properties (mass, density, inertia etc.).
|
||||
MassAPI can be applied to any object that has a PhysicsCollisionAPI or
|
||||
a PhysicsRigidBodyAPI."""
|
||||
|
||||
inherits = </APISchemaBase>
|
||||
)
|
||||
{
|
||||
float physics:mass = 0.0 (
|
||||
customData = {
|
||||
string apiName = "mass"
|
||||
}
|
||||
displayName = "Mass"
|
||||
doc = """If non-zero, directly specifies the mass of the object.
|
||||
Note that any child prim can also have a mass when they apply massAPI.
|
||||
In this case, the precedence rule is 'parent mass overrides the
|
||||
child's'. This may come as counter-intuitive, but mass is a computed
|
||||
quantity and in general not accumulative. For example, if a parent
|
||||
has mass of 10, and one of two children has mass of 20, allowing
|
||||
child's mass to override its parent results in a mass of -10 for the
|
||||
other child. Note if mass is 0.0 it is ignored. Units: mass.
|
||||
"""
|
||||
)
|
||||
|
||||
float physics:density = 0.0 (
|
||||
customData = {
|
||||
string apiName = "density"
|
||||
}
|
||||
displayName = "Density"
|
||||
doc = """If non-zero, specifies the density of the object.
|
||||
In the context of rigid body physics, density indirectly results in
|
||||
setting mass via (mass = density x volume of the object). How the
|
||||
volume is computed is up to implementation of the physics system.
|
||||
It is generally computed from the collision approximation rather than
|
||||
the graphical mesh. In the case where both density and mass are
|
||||
specified for the same object, mass has precedence over density.
|
||||
Unlike mass, child's prim's density overrides parent prim's density
|
||||
as it is accumulative. Note that density of a collisionAPI can be also
|
||||
alternatively set through a PhysicsMaterialAPI. The material density
|
||||
has the weakest precedence in density definition. Note if density is
|
||||
0.0 it is ignored. Units: mass/distance/distance/distance."""
|
||||
)
|
||||
|
||||
point3f physics:centerOfMass = (0.0, 0.0, 0.0) (
|
||||
customData = {
|
||||
string apiName = "centerOfMass"
|
||||
}
|
||||
displayName = "Center of Mass"
|
||||
doc = """Center of mass in the prim's local space. Units: distance."""
|
||||
)
|
||||
|
||||
float3 physics:diagonalInertia = (0.0, 0.0, 0.0) (
|
||||
customData = {
|
||||
string apiName = "diagonalInertia"
|
||||
}
|
||||
displayName = "Diagonal Inertia"
|
||||
doc = """If non-zero, specifies diagonalized inertia tensor along the
|
||||
principal axes. Note if diagonalInertial is (0.0, 0.0, 0.0) it is
|
||||
ignored. Units: mass*distance*distance."""
|
||||
)
|
||||
|
||||
quatf physics:principalAxes = (1, 0, 0, 0) (
|
||||
customData = {
|
||||
string apiName = "principalAxes"
|
||||
}
|
||||
displayName = "Principal Axes"
|
||||
doc = """Orientation of the inertia tensor's principal axes in the
|
||||
prim's local space."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsCollisionAPI"
|
||||
(
|
||||
customData = {
|
||||
string className = "CollisionAPI"
|
||||
}
|
||||
doc = """Applies collision attributes to a UsdGeomXformable prim. If a
|
||||
simulation is running, this geometry will collide with other geometries that
|
||||
have PhysicsCollisionAPI applied. If a prim in the parent hierarchy has the
|
||||
RigidBodyAPI applied, this collider is a part of that body. If there is
|
||||
no body in the parent hierarchy, this collider is considered to be static."""
|
||||
|
||||
inherits = </APISchemaBase>
|
||||
)
|
||||
{
|
||||
bool physics:collisionEnabled = true (
|
||||
customData = {
|
||||
string apiName = "collisionEnabled"
|
||||
}
|
||||
displayName = "Collision Enabled"
|
||||
doc = """Determines if the PhysicsCollisionAPI is enabled."""
|
||||
)
|
||||
|
||||
rel physics:simulationOwner (
|
||||
customData = {
|
||||
string apiName = "simulationOwner"
|
||||
}
|
||||
displayName = "Simulation Owner"
|
||||
doc = """Single PhysicsScene that will simulate this collider.
|
||||
By default this object belongs to the first PhysicsScene.
|
||||
Note that if a RigidBodyAPI in the hierarchy above has a different
|
||||
simulationOwner then it has a precedence over this relationship."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsMeshCollisionAPI"
|
||||
(
|
||||
customData = {
|
||||
string className = "MeshCollisionAPI"
|
||||
}
|
||||
doc = """Attributes to control how a Mesh is made into a collider.
|
||||
Can be applied to only a USDGeomMesh in addition to its
|
||||
PhysicsCollisionAPI."""
|
||||
|
||||
inherits = </APISchemaBase>
|
||||
)
|
||||
{
|
||||
uniform token physics:approximation = "none" (
|
||||
customData = {
|
||||
string apiName = "approximation"
|
||||
}
|
||||
allowedTokens = ["none","convexDecomposition","convexHull",
|
||||
"boundingSphere","boundingCube","meshSimplification"]
|
||||
|
||||
displayName = "Approximation"
|
||||
doc = """Determines the mesh's collision approximation:
|
||||
"none" - The mesh geometry is used directly as a collider without any
|
||||
approximation.
|
||||
"convexDecomposition" - A convex mesh decomposition is performed. This
|
||||
results in a set of convex mesh colliders.
|
||||
"convexHull" - A convex hull of the mesh is generated and used as the
|
||||
collider.
|
||||
"boundingSphere" - A bounding sphere is computed around the mesh and used
|
||||
as a collider.
|
||||
"boundingCube" - An optimally fitting box collider is computed around the
|
||||
mesh.
|
||||
"meshSimplification" - A mesh simplification step is performed, resulting
|
||||
in a simplified triangle mesh collider."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsMaterialAPI"
|
||||
(
|
||||
customData = {
|
||||
string className = "MaterialAPI"
|
||||
}
|
||||
doc = """ Adds simulation material properties to a Material. All collisions
|
||||
that have a relationship to this material will have their collision response
|
||||
defined through this material."""
|
||||
|
||||
inherits = </APISchemaBase>
|
||||
)
|
||||
{
|
||||
float physics:dynamicFriction = 0.0 (
|
||||
customData = {
|
||||
string apiName = "dynamicFriction"
|
||||
}
|
||||
displayName = "Dynamic Friction"
|
||||
doc = """Dynamic friction coefficient. Unitless."""
|
||||
)
|
||||
|
||||
float physics:staticFriction = 0.0 (
|
||||
customData = {
|
||||
string apiName = "staticFriction"
|
||||
}
|
||||
displayName = "Static Friction"
|
||||
doc = """Static friction coefficient. Unitless."""
|
||||
)
|
||||
|
||||
float physics:restitution = 0.0 (
|
||||
customData = {
|
||||
string apiName = "restitution"
|
||||
}
|
||||
displayName = "Restitution"
|
||||
doc = """Restitution coefficient. Unitless."""
|
||||
)
|
||||
|
||||
float physics:density = 0.0 (
|
||||
customData = {
|
||||
string apiName = "density"
|
||||
}
|
||||
displayName = "Density"
|
||||
doc = """If non-zero, defines the density of the material. This can be
|
||||
used for body mass computation, see PhysicsMassAPI.
|
||||
Note that if the density is 0.0 it is ignored.
|
||||
Units: mass/distance/distance/distance."""
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsCollisionGroup "PhysicsCollisionGroup"
|
||||
(
|
||||
customData = {
|
||||
string className = "CollisionGroup"
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usd/collectionAPI.h" """
|
||||
}
|
||||
doc = """Defines a collision group for coarse filtering. When a collision
|
||||
occurs between two objects that have a PhysicsCollisionGroup assigned,
|
||||
they will collide with each other unless this PhysicsCollisionGroup pair
|
||||
is filtered. See filteredGroups attribute.
|
||||
|
||||
A CollectionAPI:colliders maintains a list of PhysicsCollisionAPI rel-s that
|
||||
defines the members of this Collisiongroup.
|
||||
"""
|
||||
|
||||
inherits = </Typed>
|
||||
prepend apiSchemas = ["CollectionAPI:colliders"]
|
||||
)
|
||||
{
|
||||
rel physics:filteredGroups (
|
||||
customData = {
|
||||
string apiName = "filteredGroups"
|
||||
}
|
||||
|
||||
displayName = "Filtered Groups"
|
||||
doc = """References a list of PhysicsCollisionGroups with which
|
||||
collisions should be ignored."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsFilteredPairsAPI"
|
||||
(
|
||||
customData = {
|
||||
string className = "FilteredPairsAPI"
|
||||
}
|
||||
doc = """API to describe fine-grained filtering. If a collision between
|
||||
two objects occurs, this pair might be filtered if the pair is defined
|
||||
through this API. This API can be applied either to a body or collision
|
||||
or even articulation. The "filteredPairs" defines what objects it should
|
||||
not collide against. Note that FilteredPairsAPI filtering has precedence
|
||||
over CollisionGroup filtering."""
|
||||
|
||||
inherits = </APISchemaBase>
|
||||
)
|
||||
{
|
||||
rel physics:filteredPairs (
|
||||
customData = {
|
||||
string apiName = "filteredPairs"
|
||||
}
|
||||
displayName = "Filtered Pairs"
|
||||
doc = """Relationship to objects that should be filtered."""
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
class PhysicsJoint "PhysicsJoint"
|
||||
(
|
||||
customData = {
|
||||
string className = "Joint"
|
||||
}
|
||||
doc = """A joint constrains the movement of rigid bodies. Joint can be
|
||||
created between two rigid bodies or between one rigid body and world.
|
||||
By default joint primitive defines a D6 joint where all degrees of
|
||||
freedom are free. Three linear and three angular degrees of freedom.
|
||||
Note that default behavior is to disable collision between jointed bodies.
|
||||
"""
|
||||
|
||||
inherits = </Imageable>
|
||||
)
|
||||
{
|
||||
rel physics:body0 (
|
||||
customData = {
|
||||
string apiName = "body0"
|
||||
}
|
||||
displayName = "Body 0"
|
||||
doc = """Relationship to any UsdGeomXformable."""
|
||||
)
|
||||
|
||||
rel physics:body1 (
|
||||
customData = {
|
||||
string apiName = "body1"
|
||||
}
|
||||
displayName = "Body 1"
|
||||
doc = """Relationship to any UsdGeomXformable."""
|
||||
)
|
||||
|
||||
point3f physics:localPos0 = (0.0, 0.0, 0.0) (
|
||||
customData = {
|
||||
string apiName = "localPos0"
|
||||
}
|
||||
displayName = "Local Position 0"
|
||||
doc = """Relative position of the joint frame to body0's frame."""
|
||||
)
|
||||
|
||||
quatf physics:localRot0 = (1.0, 0.0, 0.0, 0.0) (
|
||||
customData = {
|
||||
string apiName = "localRot0"
|
||||
}
|
||||
displayName = "Local Rotation 0"
|
||||
doc = """Relative orientation of the joint frame to body0's frame."""
|
||||
)
|
||||
|
||||
point3f physics:localPos1 = (0.0, 0.0, 0.0) (
|
||||
customData = {
|
||||
string apiName = "localPos1"
|
||||
}
|
||||
displayName = "Local Position 1"
|
||||
doc = """Relative position of the joint frame to body1's frame."""
|
||||
)
|
||||
|
||||
quatf physics:localRot1 = (1.0, 0.0, 0.0, 0.0) (
|
||||
customData = {
|
||||
string apiName = "localRot1"
|
||||
}
|
||||
displayName = "Local Rotation 1"
|
||||
doc = """Relative orientation of the joint frame to body1's frame."""
|
||||
)
|
||||
|
||||
bool physics:jointEnabled = true (
|
||||
customData = {
|
||||
string apiName = "jointEnabled"
|
||||
}
|
||||
displayName = "Joint Enabled"
|
||||
doc = """Determines if the joint is enabled."""
|
||||
)
|
||||
|
||||
bool physics:collisionEnabled = false (
|
||||
customData = {
|
||||
string apiName = "collisionEnabled"
|
||||
}
|
||||
displayName = "Collision Enabled"
|
||||
doc = """Determines if the jointed subtrees should collide or not."""
|
||||
)
|
||||
|
||||
uniform bool physics:excludeFromArticulation = false (
|
||||
customData = {
|
||||
string apiName = "excludeFromArticulation"
|
||||
}
|
||||
displayName = "Exclude From Articulation"
|
||||
doc = """Determines if the joint can be included in an Articulation."""
|
||||
)
|
||||
|
||||
float physics:breakForce = inf (
|
||||
customData = {
|
||||
string apiName = "breakForce"
|
||||
}
|
||||
displayName = "Break Force"
|
||||
doc = """Joint break force. If set, joint is to break when this force
|
||||
limit is reached. (Used for linear DOFs.)
|
||||
Units: mass * distance / second / second"""
|
||||
)
|
||||
|
||||
float physics:breakTorque = inf (
|
||||
customData = {
|
||||
string apiName = "breakTorque"
|
||||
}
|
||||
displayName = "Break Torque"
|
||||
doc = """Joint break torque. If set, joint is to break when this torque
|
||||
limit is reached. (Used for angular DOFs.)
|
||||
Units: mass * distance * distance / second / second"""
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
class PhysicsRevoluteJoint "PhysicsRevoluteJoint"
|
||||
(
|
||||
customData = {
|
||||
string className = "RevoluteJoint"
|
||||
}
|
||||
doc = """Predefined revolute joint type (rotation along revolute joint
|
||||
axis is permitted.)"""
|
||||
|
||||
inherits = </PhysicsJoint>
|
||||
)
|
||||
{
|
||||
uniform token physics:axis = "X" (
|
||||
customData = {
|
||||
string apiName = "axis"
|
||||
}
|
||||
allowedTokens = ["X", "Y", "Z"]
|
||||
displayName = "Axis"
|
||||
doc = """Joint axis."""
|
||||
)
|
||||
|
||||
float physics:lowerLimit = -inf (
|
||||
customData = {
|
||||
string apiName = "lowerLimit"
|
||||
}
|
||||
displayName = "Lower Limit"
|
||||
doc = """Lower limit. Units: degrees. -inf means not limited in
|
||||
negative direction."""
|
||||
)
|
||||
|
||||
float physics:upperLimit = inf (
|
||||
customData = {
|
||||
string apiName = "upperLimit"
|
||||
}
|
||||
displayName = "Upper Limit"
|
||||
doc = """Upper limit. Units: degrees. inf means not limited in
|
||||
positive direction."""
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsPrismaticJoint "PhysicsPrismaticJoint"
|
||||
(
|
||||
customData = {
|
||||
string className = "PrismaticJoint"
|
||||
}
|
||||
doc = """Predefined prismatic joint type (translation along prismatic
|
||||
joint axis is permitted.)"""
|
||||
|
||||
inherits = </PhysicsJoint>
|
||||
)
|
||||
{
|
||||
uniform token physics:axis = "X" (
|
||||
customData = {
|
||||
string apiName = "axis"
|
||||
}
|
||||
displayName = "Axis"
|
||||
allowedTokens = ["X", "Y", "Z"]
|
||||
doc = """Joint axis."""
|
||||
)
|
||||
|
||||
float physics:lowerLimit = -inf (
|
||||
customData = {
|
||||
string apiName = "lowerLimit"
|
||||
}
|
||||
displayName = "Lower Limit"
|
||||
doc = """Lower limit. Units: distance. -inf means not limited in
|
||||
negative direction."""
|
||||
)
|
||||
|
||||
float physics:upperLimit = inf (
|
||||
customData = {
|
||||
string apiName = "upperLimit"
|
||||
}
|
||||
displayName = "Upper Limit"
|
||||
doc = """Upper limit. Units: distance. inf means not limited in
|
||||
positive direction."""
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsSphericalJoint "PhysicsSphericalJoint"
|
||||
(
|
||||
customData = {
|
||||
string className = "SphericalJoint"
|
||||
}
|
||||
doc = """Predefined spherical joint type (Removes linear degrees of
|
||||
freedom, cone limit may restrict the motion in a given range.) It allows
|
||||
two limit values, which when equal create a circular, else an elliptic
|
||||
cone limit around the limit axis."""
|
||||
|
||||
inherits = </PhysicsJoint>
|
||||
)
|
||||
{
|
||||
uniform token physics:axis = "X" (
|
||||
customData = {
|
||||
string apiName = "axis"
|
||||
}
|
||||
allowedTokens = ["X", "Y", "Z"]
|
||||
displayName = "Axis"
|
||||
doc = """Cone limit axis."""
|
||||
)
|
||||
|
||||
float physics:coneAngle0Limit = -1.0 (
|
||||
customData = {
|
||||
string apiName = "coneAngle0Limit"
|
||||
}
|
||||
displayName = "Cone Angle0 Limit"
|
||||
doc = """Cone limit from the primary joint axis in the local0 frame
|
||||
toward the next axis. (Next axis of X is Y, and of Z is X.) A
|
||||
negative value means not limited. Units: degrees."""
|
||||
)
|
||||
|
||||
float physics:coneAngle1Limit = -1.0 (
|
||||
customData = {
|
||||
string apiName = "coneAngle1Limit"
|
||||
}
|
||||
displayName = "Cone Angle1 Limit"
|
||||
doc = """Cone limit from the primary joint axis in the local0 frame
|
||||
toward the second to next axis. A negative value means not limited.
|
||||
Units: degrees."""
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
class PhysicsDistanceJoint "PhysicsDistanceJoint"
|
||||
(
|
||||
customData = {
|
||||
string className = "DistanceJoint"
|
||||
}
|
||||
doc = """Predefined distance joint type (Distance between rigid bodies
|
||||
may be limited to given minimum or maximum distance.)"""
|
||||
|
||||
inherits = </PhysicsJoint>
|
||||
)
|
||||
{
|
||||
float physics:minDistance = -1.0 (
|
||||
customData = {
|
||||
string apiName = "minDistance"
|
||||
}
|
||||
displayName = "Minimum Distance"
|
||||
doc = """Minimum distance. If attribute is negative, the joint is not
|
||||
limited. Units: distance."""
|
||||
)
|
||||
|
||||
float physics:maxDistance = -1.0 (
|
||||
customData = {
|
||||
string apiName = "maxDistance"
|
||||
}
|
||||
displayName = "Maximum Distance"
|
||||
doc = """Maximum distance. If attribute is negative, the joint is not
|
||||
limited. Units: distance."""
|
||||
)
|
||||
}
|
||||
|
||||
class PhysicsFixedJoint "PhysicsFixedJoint"
|
||||
(
|
||||
customData = {
|
||||
string className = "FixedJoint"
|
||||
}
|
||||
doc = """Predefined fixed joint type (All degrees of freedom are
|
||||
removed.)"""
|
||||
|
||||
inherits = </PhysicsJoint>
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "PhysicsLimitAPI"
|
||||
(
|
||||
customData = {
|
||||
string className = "LimitAPI"
|
||||
token apiSchemaType = "multipleApply"
|
||||
token propertyNamespacePrefix = "limit"
|
||||
}
|
||||
doc = """The PhysicsLimitAPI can be applied to a PhysicsJoint and will
|
||||
restrict the movement along an axis. PhysicsLimitAPI is a multipleApply
|
||||
schema: The PhysicsJoint can be restricted along "transX", "transY",
|
||||
"transZ", "rotX", "rotY", "rotZ", "distance". Setting these as a
|
||||
multipleApply schema TfToken name will define the degree of freedom the
|
||||
PhysicsLimitAPI is applied to. Note that if the low limit is higher than
|
||||
the high limit, motion along this axis is considered locked."""
|
||||
|
||||
inherits = </APISchemaBase>
|
||||
|
||||
)
|
||||
{
|
||||
float physics:low = -inf (
|
||||
customData = {
|
||||
string apiName = "low"
|
||||
}
|
||||
displayName = "Low Limit"
|
||||
doc = """Lower limit. Units: degrees or distance depending on trans or
|
||||
rot axis applied to. -inf means not limited in negative direction."""
|
||||
)
|
||||
|
||||
float physics:high = inf (
|
||||
customData = {
|
||||
string apiName = "high"
|
||||
}
|
||||
displayName = "High Limit"
|
||||
doc = """Upper limit. Units: degrees or distance depending on trans or
|
||||
rot axis applied to. inf means not limited in positive direction."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsDriveAPI"
|
||||
(
|
||||
customData = {
|
||||
string className = "DriveAPI"
|
||||
token apiSchemaType = "multipleApply"
|
||||
token propertyNamespacePrefix = "drive"
|
||||
}
|
||||
doc = """The PhysicsDriveAPI when applied to any joint primitive will drive
|
||||
the joint towards a given target. The PhysicsDriveAPI is a multipleApply
|
||||
schema: drive can be set per axis "transX", "transY", "transZ", "rotX",
|
||||
"rotY", "rotZ" or its "linear" for prismatic joint or "angular" for revolute
|
||||
joints. Setting these as a multipleApply schema TfToken name will
|
||||
define the degree of freedom the DriveAPI is applied to. Each drive is an
|
||||
implicit force-limited damped spring:
|
||||
Force or acceleration = stiffness * (targetPosition - position)
|
||||
+ damping * (targetVelocity - velocity)"""
|
||||
|
||||
inherits = </APISchemaBase>
|
||||
)
|
||||
{
|
||||
uniform token physics:type = "force" (
|
||||
customData = {
|
||||
string apiName = "type"
|
||||
}
|
||||
allowedTokens = ["force", "acceleration"]
|
||||
displayName = "Type"
|
||||
doc = """Drive spring is for the acceleration at the joint (rather
|
||||
than the force)."""
|
||||
)
|
||||
|
||||
float physics:maxForce = inf (
|
||||
customData = {
|
||||
string apiName = "maxForce"
|
||||
}
|
||||
displayName = "Max Force"
|
||||
doc = """Maximum force that can be applied to drive. Units:
|
||||
if linear drive: mass*DIST_UNITS/second/second
|
||||
if angular drive: mass*DIST_UNITS*DIST_UNITS/second/second
|
||||
inf means not limited. Must be non-negative.
|
||||
"""
|
||||
)
|
||||
|
||||
float physics:targetPosition = 0.0 (
|
||||
customData = {
|
||||
string apiName = "targetPosition"
|
||||
}
|
||||
displayName = "Target Position"
|
||||
doc = """Target value for position. Units:
|
||||
if linear drive: distance
|
||||
if angular drive: degrees."""
|
||||
)
|
||||
|
||||
float physics:targetVelocity = 0.0 (
|
||||
customData = {
|
||||
string apiName = "targetVelocity"
|
||||
}
|
||||
displayName = "Target Velocity"
|
||||
doc = """Target value for velocity. Units:
|
||||
if linear drive: distance/second
|
||||
if angular drive: degrees/second."""
|
||||
)
|
||||
|
||||
float physics:damping = 0.0 (
|
||||
customData = {
|
||||
string apiName = "damping"
|
||||
}
|
||||
doc = """Damping of the drive. Units:
|
||||
if linear drive: mass/second
|
||||
If angular drive: mass*DIST_UNITS*DIST_UNITS/second/second/degrees."""
|
||||
)
|
||||
|
||||
float physics:stiffness = 0.0 (
|
||||
customData = {
|
||||
string apiName = "stiffness"
|
||||
}
|
||||
doc = """Stiffness of the drive. Units:
|
||||
if linear drive: mass/second/second
|
||||
if angular drive: mass*DIST_UNITS*DIST_UNITS/degree/second/second."""
|
||||
)
|
||||
}
|
||||
|
||||
class "PhysicsArticulationRootAPI"
|
||||
(
|
||||
customData = {
|
||||
string className = "ArticulationRootAPI"
|
||||
}
|
||||
doc = """PhysicsArticulationRootAPI can be applied to a scene graph node,
|
||||
and marks the subtree rooted here for inclusion in one or more reduced
|
||||
coordinate articulations. For floating articulations, this should be on
|
||||
the root body. For fixed articulations (robotics jargon for e.g. a robot
|
||||
arm for welding that is bolted to the floor), this API can be on a direct
|
||||
or indirect parent of the root joint which is connected to the world, or
|
||||
on the joint itself.."""
|
||||
|
||||
inherits = </APISchemaBase>
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"WARNING: THIS FILE IS GENERATED BY usdGenSchema. DO NOT EDIT."
|
||||
)
|
||||
|
||||
class "RenderSettingsBase" (
|
||||
doc = """Abstract base class that defines render settings that
|
||||
can be specified on either a RenderSettings prim or a RenderProduct
|
||||
prim."""
|
||||
)
|
||||
{
|
||||
uniform token aspectRatioConformPolicy = "expandAperture" (
|
||||
allowedTokens = ["expandAperture", "cropAperture", "adjustApertureWidth", "adjustApertureHeight", "adjustPixelAspectRatio"]
|
||||
doc = '''Indicates the policy to use to resolve an aspect
|
||||
ratio mismatch between the camera aperture and image settings.
|
||||
|
||||
This policy allows a standard render setting to do something
|
||||
reasonable given varying camera inputs.
|
||||
|
||||
The camera aperture aspect ratio is determined by the
|
||||
aperture atributes on the UsdGeomCamera.
|
||||
|
||||
The image aspect ratio is determined by the resolution and
|
||||
pixelAspectRatio attributes in the render settings.
|
||||
|
||||
- "expandAperture": if necessary, expand the aperture to
|
||||
fit the image, exposing additional scene content
|
||||
- "cropAperture": if necessary, crop the aperture to fit
|
||||
the image, cropping scene content
|
||||
- "adjustApertureWidth": if necessary, adjust aperture width
|
||||
to make its aspect ratio match the image
|
||||
- "adjustApertureHeight": if necessary, adjust aperture height
|
||||
to make its aspect ratio match the image
|
||||
- "adjustPixelAspectRatio": compute pixelAspectRatio to
|
||||
make the image exactly cover the aperture; disregards
|
||||
existing attribute value of pixelAspectRatio
|
||||
'''
|
||||
)
|
||||
rel camera (
|
||||
doc = """The _camera_ relationship specifies the primary
|
||||
camera to use in a render. It must target a UsdGeomCamera."""
|
||||
)
|
||||
uniform float4 dataWindowNDC = (0, 0, 1, 1) (
|
||||
doc = """dataWindowNDC specifies the axis-aligned rectangular
|
||||
region in the adjusted aperture window within which the renderer
|
||||
should produce data.
|
||||
|
||||
It is specified as (xmin, ymin, xmax, ymax) in normalized
|
||||
device coordinates, where the range 0 to 1 corresponds to the
|
||||
aperture. (0,0) corresponds to the bottom-left
|
||||
corner and (1,1) corresponds to the upper-right corner.
|
||||
|
||||
Specifying a window outside the unit square will produce
|
||||
overscan data. Specifying a window that does not cover the unit
|
||||
square will produce a cropped render.
|
||||
|
||||
A pixel is included in the rendered result if the pixel
|
||||
center is contained by the data window. This is consistent
|
||||
with standard rules used by polygon rasterization engines.
|
||||
\\ref UsdRenderRasterization
|
||||
|
||||
The data window is expressed in NDC so that cropping and
|
||||
overscan may be resolution independent. In interactive
|
||||
workflows, incremental cropping and resolution adjustment
|
||||
may be intermixed to isolate and examine parts of the scene.
|
||||
In compositing workflows, overscan may be used to support
|
||||
image post-processing kernels, and reduced-resolution proxy
|
||||
renders may be used for faster iteration.
|
||||
|
||||
The dataWindow:ndc coordinate system references the
|
||||
aperture after any adjustments required by
|
||||
aspectRatioConformPolicy.
|
||||
"""
|
||||
)
|
||||
uniform bool instantaneousShutter = 0 (
|
||||
doc = """Override the targeted _camera_'s _shutterClose_ to be
|
||||
equal to the value of its _shutterOpen_, to produce a zero-width
|
||||
shutter interval. This gives us a convenient way to disable
|
||||
motion blur."""
|
||||
)
|
||||
uniform float pixelAspectRatio = 1 (
|
||||
doc = """The aspect ratio (width/height) of image pixels..
|
||||
The default ratio 1.0 indicates square pixels."""
|
||||
)
|
||||
uniform int2 resolution = (2048, 1080) (
|
||||
doc = """The image pixel resolution, corresponding to the
|
||||
camera's screen window."""
|
||||
)
|
||||
}
|
||||
|
||||
class RenderSettings "RenderSettings" (
|
||||
doc = """A UsdRenderSettings prim specifies global settings for
|
||||
a render process, including an enumeration of the RenderProducts
|
||||
that should result, and the UsdGeomImageable purposes that should
|
||||
be rendered. \\ref UsdRenderHowSettingsAffectRendering"""
|
||||
)
|
||||
{
|
||||
uniform token aspectRatioConformPolicy = "expandAperture" (
|
||||
allowedTokens = ["expandAperture", "cropAperture", "adjustApertureWidth", "adjustApertureHeight", "adjustPixelAspectRatio"]
|
||||
doc = '''Indicates the policy to use to resolve an aspect
|
||||
ratio mismatch between the camera aperture and image settings.
|
||||
|
||||
This policy allows a standard render setting to do something
|
||||
reasonable given varying camera inputs.
|
||||
|
||||
The camera aperture aspect ratio is determined by the
|
||||
aperture atributes on the UsdGeomCamera.
|
||||
|
||||
The image aspect ratio is determined by the resolution and
|
||||
pixelAspectRatio attributes in the render settings.
|
||||
|
||||
- "expandAperture": if necessary, expand the aperture to
|
||||
fit the image, exposing additional scene content
|
||||
- "cropAperture": if necessary, crop the aperture to fit
|
||||
the image, cropping scene content
|
||||
- "adjustApertureWidth": if necessary, adjust aperture width
|
||||
to make its aspect ratio match the image
|
||||
- "adjustApertureHeight": if necessary, adjust aperture height
|
||||
to make its aspect ratio match the image
|
||||
- "adjustPixelAspectRatio": compute pixelAspectRatio to
|
||||
make the image exactly cover the aperture; disregards
|
||||
existing attribute value of pixelAspectRatio
|
||||
'''
|
||||
)
|
||||
rel camera (
|
||||
doc = """The _camera_ relationship specifies the primary
|
||||
camera to use in a render. It must target a UsdGeomCamera."""
|
||||
)
|
||||
uniform float4 dataWindowNDC = (0, 0, 1, 1) (
|
||||
doc = """dataWindowNDC specifies the axis-aligned rectangular
|
||||
region in the adjusted aperture window within which the renderer
|
||||
should produce data.
|
||||
|
||||
It is specified as (xmin, ymin, xmax, ymax) in normalized
|
||||
device coordinates, where the range 0 to 1 corresponds to the
|
||||
aperture. (0,0) corresponds to the bottom-left
|
||||
corner and (1,1) corresponds to the upper-right corner.
|
||||
|
||||
Specifying a window outside the unit square will produce
|
||||
overscan data. Specifying a window that does not cover the unit
|
||||
square will produce a cropped render.
|
||||
|
||||
A pixel is included in the rendered result if the pixel
|
||||
center is contained by the data window. This is consistent
|
||||
with standard rules used by polygon rasterization engines.
|
||||
\\ref UsdRenderRasterization
|
||||
|
||||
The data window is expressed in NDC so that cropping and
|
||||
overscan may be resolution independent. In interactive
|
||||
workflows, incremental cropping and resolution adjustment
|
||||
may be intermixed to isolate and examine parts of the scene.
|
||||
In compositing workflows, overscan may be used to support
|
||||
image post-processing kernels, and reduced-resolution proxy
|
||||
renders may be used for faster iteration.
|
||||
|
||||
The dataWindow:ndc coordinate system references the
|
||||
aperture after any adjustments required by
|
||||
aspectRatioConformPolicy.
|
||||
"""
|
||||
)
|
||||
uniform token[] includedPurposes = ["default", "render"] (
|
||||
doc = """The list of UsdGeomImageable _purpose_ values that
|
||||
should be included in the render. Note this cannot be
|
||||
specified per-RenderProduct because it is a statement of
|
||||
which geometry is present."""
|
||||
)
|
||||
uniform bool instantaneousShutter = 0 (
|
||||
doc = """Override the targeted _camera_'s _shutterClose_ to be
|
||||
equal to the value of its _shutterOpen_, to produce a zero-width
|
||||
shutter interval. This gives us a convenient way to disable
|
||||
motion blur."""
|
||||
)
|
||||
uniform token[] materialBindingPurposes = ["full", ""] (
|
||||
allowedTokens = ["full", "preview", ""]
|
||||
doc = '''Ordered list of material purposes to consider when
|
||||
resolving material bindings in the scene. The empty string
|
||||
indicates the "allPurpose" binding.'''
|
||||
)
|
||||
uniform float pixelAspectRatio = 1 (
|
||||
doc = """The aspect ratio (width/height) of image pixels..
|
||||
The default ratio 1.0 indicates square pixels."""
|
||||
)
|
||||
rel products (
|
||||
doc = """The set of RenderProducts the render should produce.
|
||||
This relationship should target UsdRenderProduct prims.
|
||||
If no _products_ are specified, an application should produce
|
||||
an rgb image according to the RenderSettings configuration,
|
||||
to a default display or image name."""
|
||||
)
|
||||
uniform int2 resolution = (2048, 1080) (
|
||||
doc = """The image pixel resolution, corresponding to the
|
||||
camera's screen window."""
|
||||
)
|
||||
}
|
||||
|
||||
class "RenderSettingsAPI" (
|
||||
doc = """UsdRenderSettingsAPI is a base class for API schemas
|
||||
to encode renderer-specific settings."""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class RenderVar "RenderVar" (
|
||||
doc = """A UsdRenderVar describes a custom data variable for
|
||||
a render to produce. The prim describes the source of the data, which
|
||||
can be a shader output or an LPE (Light Path Expression), and also
|
||||
allows encoding of (generally renderer-specific) parameters that
|
||||
configure the renderer for computing the variable.
|
||||
|
||||
|
||||
ote In the future, UsdRender may standardize RenderVar representation
|
||||
for well-known variables under the sourceType `intrinsic`,
|
||||
such as _r_, _g_, _b_, _a_, _z_, or _id_.
|
||||
"""
|
||||
)
|
||||
{
|
||||
uniform token dataType = "color3f" (
|
||||
doc = "The type of this channel, as a USD attribute type."
|
||||
)
|
||||
uniform string sourceName = "" (
|
||||
doc = """The renderer should look for an output of this name
|
||||
as the computed value for the RenderVar."""
|
||||
)
|
||||
uniform token sourceType = "raw" (
|
||||
allowedTokens = ["raw", "primvar", "lpe", "intrinsic"]
|
||||
doc = '''Indicates the type of the source.
|
||||
|
||||
- "raw": The name should be passed directly to the
|
||||
renderer. This is the default behavior.
|
||||
- "primvar": This source represents the name of a primvar.
|
||||
Some renderers may use this to ensure that the primvar
|
||||
is provided; other renderers may require that a suitable
|
||||
material network be provided, in which case this is simply
|
||||
an advisory setting.
|
||||
- "lpe": Specifies a Light Path Expression in the
|
||||
[OSL Light Path Expressions language](https://github.com/imageworks/OpenShadingLanguage/wiki/OSL-Light-Path-Expressions) as the source for
|
||||
this RenderVar. Some renderers may use extensions to
|
||||
that syntax, which will necessarily be non-portable.
|
||||
- "intrinsic": This setting is currently unimplemented,
|
||||
but represents a future namespace for UsdRender to provide
|
||||
portable baseline RenderVars, such as camera depth, that
|
||||
may have varying implementations for each renderer.
|
||||
'''
|
||||
)
|
||||
}
|
||||
|
||||
class RenderProduct "RenderProduct" (
|
||||
doc = """A UsdRenderProduct describes an image or other
|
||||
file-like artifact produced by a render. A RenderProduct
|
||||
combines one or more RenderVars into a file or interactive
|
||||
buffer. It also provides all the controls established in
|
||||
UsdRenderSettingsBase as optional overrides to whatever the
|
||||
owning UsdRenderSettings prim dictates.
|
||||
|
||||
Specific renderers may support additional settings, such
|
||||
as a way to configure compression settings, filetype metadata,
|
||||
and so forth. Such settings can be encoded using
|
||||
renderer-specific API schemas applied to the product prim.
|
||||
"""
|
||||
)
|
||||
{
|
||||
uniform token aspectRatioConformPolicy = "expandAperture" (
|
||||
allowedTokens = ["expandAperture", "cropAperture", "adjustApertureWidth", "adjustApertureHeight", "adjustPixelAspectRatio"]
|
||||
doc = '''Indicates the policy to use to resolve an aspect
|
||||
ratio mismatch between the camera aperture and image settings.
|
||||
|
||||
This policy allows a standard render setting to do something
|
||||
reasonable given varying camera inputs.
|
||||
|
||||
The camera aperture aspect ratio is determined by the
|
||||
aperture atributes on the UsdGeomCamera.
|
||||
|
||||
The image aspect ratio is determined by the resolution and
|
||||
pixelAspectRatio attributes in the render settings.
|
||||
|
||||
- "expandAperture": if necessary, expand the aperture to
|
||||
fit the image, exposing additional scene content
|
||||
- "cropAperture": if necessary, crop the aperture to fit
|
||||
the image, cropping scene content
|
||||
- "adjustApertureWidth": if necessary, adjust aperture width
|
||||
to make its aspect ratio match the image
|
||||
- "adjustApertureHeight": if necessary, adjust aperture height
|
||||
to make its aspect ratio match the image
|
||||
- "adjustPixelAspectRatio": compute pixelAspectRatio to
|
||||
make the image exactly cover the aperture; disregards
|
||||
existing attribute value of pixelAspectRatio
|
||||
'''
|
||||
)
|
||||
rel camera (
|
||||
doc = """The _camera_ relationship specifies the primary
|
||||
camera to use in a render. It must target a UsdGeomCamera."""
|
||||
)
|
||||
uniform float4 dataWindowNDC = (0, 0, 1, 1) (
|
||||
doc = """dataWindowNDC specifies the axis-aligned rectangular
|
||||
region in the adjusted aperture window within which the renderer
|
||||
should produce data.
|
||||
|
||||
It is specified as (xmin, ymin, xmax, ymax) in normalized
|
||||
device coordinates, where the range 0 to 1 corresponds to the
|
||||
aperture. (0,0) corresponds to the bottom-left
|
||||
corner and (1,1) corresponds to the upper-right corner.
|
||||
|
||||
Specifying a window outside the unit square will produce
|
||||
overscan data. Specifying a window that does not cover the unit
|
||||
square will produce a cropped render.
|
||||
|
||||
A pixel is included in the rendered result if the pixel
|
||||
center is contained by the data window. This is consistent
|
||||
with standard rules used by polygon rasterization engines.
|
||||
\\ref UsdRenderRasterization
|
||||
|
||||
The data window is expressed in NDC so that cropping and
|
||||
overscan may be resolution independent. In interactive
|
||||
workflows, incremental cropping and resolution adjustment
|
||||
may be intermixed to isolate and examine parts of the scene.
|
||||
In compositing workflows, overscan may be used to support
|
||||
image post-processing kernels, and reduced-resolution proxy
|
||||
renders may be used for faster iteration.
|
||||
|
||||
The dataWindow:ndc coordinate system references the
|
||||
aperture after any adjustments required by
|
||||
aspectRatioConformPolicy.
|
||||
"""
|
||||
)
|
||||
uniform bool instantaneousShutter = 0 (
|
||||
doc = """Override the targeted _camera_'s _shutterClose_ to be
|
||||
equal to the value of its _shutterOpen_, to produce a zero-width
|
||||
shutter interval. This gives us a convenient way to disable
|
||||
motion blur."""
|
||||
)
|
||||
rel orderedVars (
|
||||
doc = """Specifies the RenderVars that should be consumed and
|
||||
combined into the final product. If ordering is relevant to the
|
||||
output driver, then the ordering of targets in this relationship
|
||||
provides the order to use."""
|
||||
)
|
||||
uniform float pixelAspectRatio = 1 (
|
||||
doc = """The aspect ratio (width/height) of image pixels..
|
||||
The default ratio 1.0 indicates square pixels."""
|
||||
)
|
||||
token productName = "" (
|
||||
doc = """Specifies the name that the output/display driver
|
||||
should give the product. This is provided as-authored to the
|
||||
driver, whose responsibility it is to situate the product on a
|
||||
filesystem or other storage, in the desired location."""
|
||||
)
|
||||
uniform token productType = "raster" (
|
||||
doc = '''The type of output to produce.
|
||||
The default, "raster", indicates a 2D image.
|
||||
|
||||
|
||||
ote In the future, UsdRender may define additional product
|
||||
types.'''
|
||||
)
|
||||
uniform int2 resolution = (2048, 1080) (
|
||||
doc = """The image pixel resolution, corresponding to the
|
||||
camera's screen window."""
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"renderSettingsPrimPath": {
|
||||
"appliesTo": "layers",
|
||||
"default": "",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Types": {
|
||||
"UsdRenderProduct": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "RenderProduct"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdRenderSettingsBase"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdRenderSettings": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "RenderSettings"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdRenderSettingsBase"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdRenderSettingsAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "RenderSettingsAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdRenderSettingsBase": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "RenderSettingsBase"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "abstractTyped"
|
||||
},
|
||||
"UsdRenderVar": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "RenderVar"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdRender.dll",
|
||||
"Name": "usdRender",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"This file describes the USD Render schemata for code generation."
|
||||
subLayers = [
|
||||
@usd/schema.usda@
|
||||
]
|
||||
)
|
||||
|
||||
over "GLOBAL" (
|
||||
customData = {
|
||||
string libraryName = "usdRender"
|
||||
string libraryPath = "pxr/usd/usdRender"
|
||||
dictionary libraryTokens = {
|
||||
dictionary renderSettingsPrimPath = {
|
||||
string doc = """Stage-level metadata that encodes the
|
||||
path to UsdRenderSettingsPrim to use for rendering."""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "RenderSettingsBase" (
|
||||
inherits = </Typed>
|
||||
doc = """Abstract base class that defines render settings that
|
||||
can be specified on either a RenderSettings prim or a RenderProduct
|
||||
prim."""
|
||||
customData = {
|
||||
string className = "SettingsBase"
|
||||
}
|
||||
)
|
||||
{
|
||||
rel camera (
|
||||
doc = """The _camera_ relationship specifies the primary
|
||||
camera to use in a render. It must target a UsdGeomCamera."""
|
||||
)
|
||||
uniform int2 resolution = (2048, 1080) (
|
||||
doc = """The image pixel resolution, corresponding to the
|
||||
camera's screen window."""
|
||||
)
|
||||
uniform float pixelAspectRatio = 1.0 (
|
||||
doc = """The aspect ratio (width/height) of image pixels..
|
||||
The default ratio 1.0 indicates square pixels."""
|
||||
)
|
||||
uniform token aspectRatioConformPolicy = "expandAperture" (
|
||||
doc = """Indicates the policy to use to resolve an aspect
|
||||
ratio mismatch between the camera aperture and image settings.
|
||||
|
||||
This policy allows a standard render setting to do something
|
||||
reasonable given varying camera inputs.
|
||||
|
||||
The camera aperture aspect ratio is determined by the
|
||||
aperture atributes on the UsdGeomCamera.
|
||||
|
||||
The image aspect ratio is determined by the resolution and
|
||||
pixelAspectRatio attributes in the render settings.
|
||||
|
||||
- "expandAperture": if necessary, expand the aperture to
|
||||
fit the image, exposing additional scene content
|
||||
- "cropAperture": if necessary, crop the aperture to fit
|
||||
the image, cropping scene content
|
||||
- "adjustApertureWidth": if necessary, adjust aperture width
|
||||
to make its aspect ratio match the image
|
||||
- "adjustApertureHeight": if necessary, adjust aperture height
|
||||
to make its aspect ratio match the image
|
||||
- "adjustPixelAspectRatio": compute pixelAspectRatio to
|
||||
make the image exactly cover the aperture; disregards
|
||||
existing attribute value of pixelAspectRatio
|
||||
"""
|
||||
allowedTokens = ["expandAperture", "cropAperture", "adjustApertureWidth", "adjustApertureHeight", "adjustPixelAspectRatio"]
|
||||
)
|
||||
uniform float4 dataWindowNDC = (0.0, 0.0, 1.0, 1.0) (
|
||||
doc = """dataWindowNDC specifies the axis-aligned rectangular
|
||||
region in the adjusted aperture window within which the renderer
|
||||
should produce data.
|
||||
|
||||
It is specified as (xmin, ymin, xmax, ymax) in normalized
|
||||
device coordinates, where the range 0 to 1 corresponds to the
|
||||
aperture. (0,0) corresponds to the bottom-left
|
||||
corner and (1,1) corresponds to the upper-right corner.
|
||||
|
||||
Specifying a window outside the unit square will produce
|
||||
overscan data. Specifying a window that does not cover the unit
|
||||
square will produce a cropped render.
|
||||
|
||||
A pixel is included in the rendered result if the pixel
|
||||
center is contained by the data window. This is consistent
|
||||
with standard rules used by polygon rasterization engines.
|
||||
\\ref UsdRenderRasterization
|
||||
|
||||
The data window is expressed in NDC so that cropping and
|
||||
overscan may be resolution independent. In interactive
|
||||
workflows, incremental cropping and resolution adjustment
|
||||
may be intermixed to isolate and examine parts of the scene.
|
||||
In compositing workflows, overscan may be used to support
|
||||
image post-processing kernels, and reduced-resolution proxy
|
||||
renders may be used for faster iteration.
|
||||
|
||||
The dataWindow:ndc coordinate system references the
|
||||
aperture after any adjustments required by
|
||||
aspectRatioConformPolicy.
|
||||
"""
|
||||
)
|
||||
uniform bool instantaneousShutter = false (
|
||||
doc = """Override the targeted _camera_'s _shutterClose_ to be
|
||||
equal to the value of its _shutterOpen_, to produce a zero-width
|
||||
shutter interval. This gives us a convenient way to disable
|
||||
motion blur."""
|
||||
)
|
||||
}
|
||||
|
||||
class RenderSettings "RenderSettings" (
|
||||
inherits = </RenderSettingsBase>
|
||||
doc = """A UsdRenderSettings prim specifies global settings for
|
||||
a render process, including an enumeration of the RenderProducts
|
||||
that should result, and the UsdGeomImageable purposes that should
|
||||
be rendered. \\ref UsdRenderHowSettingsAffectRendering"""
|
||||
customData = {
|
||||
string className = "Settings"
|
||||
string extraIncludes = """
|
||||
#include "pxr/base/gf/frustum.h"
|
||||
"""
|
||||
}
|
||||
)
|
||||
{
|
||||
rel products (
|
||||
doc = """The set of RenderProducts the render should produce.
|
||||
This relationship should target UsdRenderProduct prims.
|
||||
If no _products_ are specified, an application should produce
|
||||
an rgb image according to the RenderSettings configuration,
|
||||
to a default display or image name."""
|
||||
)
|
||||
uniform token[] includedPurposes = ["default", "render"] (
|
||||
doc = """The list of UsdGeomImageable _purpose_ values that
|
||||
should be included in the render. Note this cannot be
|
||||
specified per-RenderProduct because it is a statement of
|
||||
which geometry is present."""
|
||||
)
|
||||
uniform token[] materialBindingPurposes = ["full", ""] (
|
||||
allowedTokens = ["full", "preview", ""]
|
||||
doc = """Ordered list of material purposes to consider when
|
||||
resolving material bindings in the scene. The empty string
|
||||
indicates the "allPurpose" binding."""
|
||||
)
|
||||
}
|
||||
|
||||
class "RenderSettingsAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
customData = {
|
||||
token apiSchemaType = "singleApply"
|
||||
string className = "SettingsAPI"
|
||||
}
|
||||
doc = """UsdRenderSettingsAPI is a base class for API schemas
|
||||
to encode renderer-specific settings."""
|
||||
) {
|
||||
}
|
||||
|
||||
class RenderVar "RenderVar" (
|
||||
inherits = </Typed>
|
||||
doc = """A UsdRenderVar describes a custom data variable for
|
||||
a render to produce. The prim describes the source of the data, which
|
||||
can be a shader output or an LPE (Light Path Expression), and also
|
||||
allows encoding of (generally renderer-specific) parameters that
|
||||
configure the renderer for computing the variable.
|
||||
|
||||
\note In the future, UsdRender may standardize RenderVar representation
|
||||
for well-known variables under the sourceType `intrinsic`,
|
||||
such as _r_, _g_, _b_, _a_, _z_, or _id_.
|
||||
"""
|
||||
customData = {
|
||||
string className = "Var"
|
||||
}
|
||||
) {
|
||||
uniform token dataType = "color3f" (
|
||||
doc = """The type of this channel, as a USD attribute type."""
|
||||
)
|
||||
uniform string sourceName = "" (
|
||||
doc = """The renderer should look for an output of this name
|
||||
as the computed value for the RenderVar."""
|
||||
)
|
||||
uniform token sourceType = "raw" (
|
||||
doc = """Indicates the type of the source.
|
||||
|
||||
- "raw": The name should be passed directly to the
|
||||
renderer. This is the default behavior.
|
||||
- "primvar": This source represents the name of a primvar.
|
||||
Some renderers may use this to ensure that the primvar
|
||||
is provided; other renderers may require that a suitable
|
||||
material network be provided, in which case this is simply
|
||||
an advisory setting.
|
||||
- "lpe": Specifies a Light Path Expression in the
|
||||
[OSL Light Path Expressions language](https://github.com/imageworks/OpenShadingLanguage/wiki/OSL-Light-Path-Expressions) as the source for
|
||||
this RenderVar. Some renderers may use extensions to
|
||||
that syntax, which will necessarily be non-portable.
|
||||
- "intrinsic": This setting is currently unimplemented,
|
||||
but represents a future namespace for UsdRender to provide
|
||||
portable baseline RenderVars, such as camera depth, that
|
||||
may have varying implementations for each renderer.
|
||||
"""
|
||||
allowedTokens = ["raw", "primvar", "lpe", "intrinsic"]
|
||||
)
|
||||
}
|
||||
|
||||
class RenderProduct "RenderProduct" (
|
||||
inherits = </RenderSettingsBase>
|
||||
doc = """A UsdRenderProduct describes an image or other
|
||||
file-like artifact produced by a render. A RenderProduct
|
||||
combines one or more RenderVars into a file or interactive
|
||||
buffer. It also provides all the controls established in
|
||||
UsdRenderSettingsBase as optional overrides to whatever the
|
||||
owning UsdRenderSettings prim dictates.
|
||||
|
||||
Specific renderers may support additional settings, such
|
||||
as a way to configure compression settings, filetype metadata,
|
||||
and so forth. Such settings can be encoded using
|
||||
renderer-specific API schemas applied to the product prim.
|
||||
"""
|
||||
customData = {
|
||||
string className = "Product"
|
||||
dictionary schemaTokens = {
|
||||
dictionary raster = {
|
||||
string doc = """RenderProduct productType value that
|
||||
indicates a 2D raster image of pixels."""
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
uniform token productType = "raster" (
|
||||
doc = """The type of output to produce.
|
||||
The default, "raster", indicates a 2D image.
|
||||
|
||||
\note In the future, UsdRender may define additional product
|
||||
types."""
|
||||
)
|
||||
token productName = "" (
|
||||
doc = """Specifies the name that the output/display driver
|
||||
should give the product. This is provided as-authored to the
|
||||
driver, whose responsibility it is to situate the product on a
|
||||
filesystem or other storage, in the desired location."""
|
||||
)
|
||||
rel orderedVars (
|
||||
doc = """Specifies the RenderVars that should be consumed and
|
||||
combined into the final product. If ordering is relevant to the
|
||||
output driver, then the ordering of targets in this relationship
|
||||
provides the order to use."""
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"WARNING: THIS FILE IS GENERATED BY usdGenSchema. DO NOT EDIT."
|
||||
)
|
||||
|
||||
class "StatementsAPI" (
|
||||
doc = """Container namespace schema for all renderman statements.
|
||||
|
||||
\\note The longer term goal is for clients to go directly to primvar
|
||||
or render-attribute API's, instead of using UsdRi StatementsAPI
|
||||
for inherited attributes. Anticpating this, StatementsAPI
|
||||
can smooth the way via a few environment variables:
|
||||
|
||||
* USDRI_STATEMENTS_READ_OLD_ENCODING: Causes StatementsAPI to read
|
||||
old-style attributes instead of primvars in the \"ri:\"
|
||||
namespace.
|
||||
"""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "RiMaterialAPI" (
|
||||
doc = """
|
||||
\\deprecated Materials should use UsdShadeMaterial instead.
|
||||
This schema will be removed in a future release.
|
||||
|
||||
This API provides outputs that connect a material prim to prman
|
||||
shaders and RIS objects."""
|
||||
)
|
||||
{
|
||||
token outputs:ri:displacement (
|
||||
displayGroup = "Outputs"
|
||||
)
|
||||
token outputs:ri:surface (
|
||||
displayGroup = "Outputs"
|
||||
)
|
||||
token outputs:ri:volume (
|
||||
displayGroup = "Outputs"
|
||||
)
|
||||
}
|
||||
|
||||
class "RiSplineAPI" (
|
||||
doc = '''
|
||||
\\deprecated This API schema will be removed in a future release.
|
||||
|
||||
RiSplineAPI is a general purpose API schema used to describe
|
||||
a named spline stored as a set of attributes on a prim.
|
||||
|
||||
It is an add-on schema that can be applied many times to a prim with
|
||||
different spline names. All the attributes authored by the schema
|
||||
are namespaced under "$NAME:spline:", with the name of the
|
||||
spline providing a namespace for the attributes.
|
||||
|
||||
The spline describes a 2D piecewise cubic curve with a position and
|
||||
value for each knot. This is chosen to give straightforward artistic
|
||||
control over the shape. The supported basis types are:
|
||||
|
||||
- linear (UsdRiTokens->linear)
|
||||
- bspline (UsdRiTokens->bspline)
|
||||
- Catmull-Rom (UsdRiTokens->catmullRom)
|
||||
'''
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "RiTextureAPI" (
|
||||
doc = """
|
||||
\\deprecated This API schema will be removed in a future release.
|
||||
|
||||
RiTextureAPI is an API schema that provides an interface
|
||||
to add Renderman-specific attributes to adjust textures."""
|
||||
)
|
||||
{
|
||||
float ri:texture:gamma (
|
||||
doc = "Gamma-correct the texture"
|
||||
)
|
||||
float ri:texture:saturation (
|
||||
doc = "Adjust the texture's saturation"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"UsdRiMaterialAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "RiMaterialAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdRiSplineAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "RiSplineAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdRiStatementsAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "StatementsAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdRiTextureAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "RiTextureAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdRi.dll",
|
||||
"Name": "usdRi",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"This file describes the USD RenderMan Interface (UsdRi) schemata for code generation."
|
||||
subLayers = [
|
||||
@usd/schema.usda@,
|
||||
@usdShade/schema.usda@,
|
||||
]
|
||||
)
|
||||
|
||||
def "GLOBAL" (
|
||||
customData = {
|
||||
string libraryName = "usdRi"
|
||||
string libraryPath = "pxr/usd/usdRi"
|
||||
# string libraryPrefix = "UsdRi"
|
||||
# string tokensPrefix = "UsdRi"
|
||||
# dictionary libraryTokens = {}
|
||||
dictionary libraryTokens = {
|
||||
dictionary "renderContext" = {
|
||||
string value = "ri"
|
||||
string doc = "UsdShadeMaterial / Hydra render context token for UsdRi"
|
||||
}
|
||||
dictionary spline = {
|
||||
string doc = "UsdSplineAPI - Namespace for spline attributes"
|
||||
}
|
||||
dictionary interpolation = {
|
||||
string doc = "UsdSplineAPI - Interpolation attribute name"
|
||||
}
|
||||
dictionary positions = {
|
||||
string doc = "UsdSplineAPI - Positions attribute name"
|
||||
}
|
||||
dictionary values = {
|
||||
string doc = "UsdSplineAPI - values attribute name"
|
||||
}
|
||||
dictionary linear = {
|
||||
string doc = "UsdSplineAPI - Linear spline interpolation"
|
||||
}
|
||||
dictionary bspline = {
|
||||
string doc = "UsdSplineAPI - BSpline spline interpolation"
|
||||
}
|
||||
dictionary "catmullRom" = {
|
||||
string value = "catmull-rom"
|
||||
string doc = "UsdSplineAPI - Catmull-Rom spline interpolation"
|
||||
}
|
||||
dictionary constant = {
|
||||
string doc = "UsdSplineAPI - Constant-value spline interpolation"
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "StatementsAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """Container namespace schema for all renderman statements.
|
||||
|
||||
\\note The longer term goal is for clients to go directly to primvar
|
||||
or render-attribute API's, instead of using UsdRi StatementsAPI
|
||||
for inherited attributes. Anticpating this, StatementsAPI
|
||||
can smooth the way via a few environment variables:
|
||||
|
||||
* USDRI_STATEMENTS_READ_OLD_ENCODING: Causes StatementsAPI to read
|
||||
old-style attributes instead of primvars in the "ri:"
|
||||
namespace.
|
||||
"""
|
||||
customData = {
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usdGeom/primvarsAPI.h"
|
||||
"""
|
||||
}
|
||||
) {
|
||||
}
|
||||
|
||||
### Material API common to both RSL and RIS ###
|
||||
|
||||
class "RiMaterialAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """
|
||||
\\deprecated Materials should use UsdShadeMaterial instead.
|
||||
This schema will be removed in a future release.
|
||||
|
||||
This API provides outputs that connect a material prim to prman
|
||||
shaders and RIS objects."""
|
||||
customData = {
|
||||
# We want the class name to be UsdRiMaterialAPI
|
||||
string className = "MaterialAPI"
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usdShade/input.h"
|
||||
#include "pxr/usd/usdShade/output.h"
|
||||
#include "pxr/usd/usdShade/material.h"
|
||||
"""
|
||||
}
|
||||
) {
|
||||
token outputs:ri:surface (
|
||||
displayGroup = "Outputs"
|
||||
customData = {
|
||||
string apiName = "surface"
|
||||
}
|
||||
)
|
||||
token outputs:ri:displacement (
|
||||
displayGroup = "Outputs"
|
||||
customData = {
|
||||
string apiName = "displacement"
|
||||
}
|
||||
)
|
||||
token outputs:ri:volume (
|
||||
displayGroup = "Outputs"
|
||||
customData = {
|
||||
string apiName = "volume"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
########################################################################
|
||||
# Lighting API
|
||||
|
||||
class "RiSplineAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """
|
||||
\\deprecated This API schema will be removed in a future release.
|
||||
|
||||
RiSplineAPI is a general purpose API schema used to describe
|
||||
a named spline stored as a set of attributes on a prim.
|
||||
|
||||
It is an add-on schema that can be applied many times to a prim with
|
||||
different spline names. All the attributes authored by the schema
|
||||
are namespaced under "$NAME:spline:", with the name of the
|
||||
spline providing a namespace for the attributes.
|
||||
|
||||
The spline describes a 2D piecewise cubic curve with a position and
|
||||
value for each knot. This is chosen to give straightforward artistic
|
||||
control over the shape. The supported basis types are:
|
||||
|
||||
- linear (UsdRiTokens->linear)
|
||||
- bspline (UsdRiTokens->bspline)
|
||||
- Catmull-Rom (UsdRiTokens->catmullRom)
|
||||
"""
|
||||
customData = {
|
||||
string className = "SplineAPI"
|
||||
}
|
||||
) {
|
||||
}
|
||||
|
||||
class "RiTextureAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """
|
||||
\\deprecated This API schema will be removed in a future release.
|
||||
|
||||
RiTextureAPI is an API schema that provides an interface
|
||||
to add Renderman-specific attributes to adjust textures."""
|
||||
customData = {
|
||||
string className = "TextureAPI"
|
||||
}
|
||||
) {
|
||||
float ri:texture:gamma (
|
||||
doc = """Gamma-correct the texture"""
|
||||
)
|
||||
float ri:texture:saturation (
|
||||
doc = """Adjust the texture's saturation"""
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"UsdRiImagingPxrBarnLightFilterAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightFilterAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "PxrBarnLightFilter"
|
||||
},
|
||||
"UsdRiImagingPxrIntMultLightFilterAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightFilterAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "PxrIntMultLightFilter"
|
||||
},
|
||||
"UsdRiImagingPxrRodLightFilterAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingLightFilterAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "PxrRodLightFilter"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdRiImaging.dll",
|
||||
"Name": "usdRiImaging",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"WARNING: THIS FILE IS GENERATED BY usdGenSchema. DO NOT EDIT."
|
||||
)
|
||||
|
||||
class NodeGraph "NodeGraph" (
|
||||
doc = '''A node-graph is a container for shading nodes, as well as other
|
||||
node-graphs. It has a public input interface and provides a list of public
|
||||
outputs.
|
||||
|
||||
<b>Node Graph Interfaces</b>
|
||||
|
||||
One of the most important functions of a node-graph is to host the "interface"
|
||||
with which clients of already-built shading networks will interact. Please
|
||||
see "Interface Inputs" for a detailed
|
||||
explanation of what the interface provides, and how to construct and
|
||||
use it, to effectively share/instance shader networks.
|
||||
|
||||
<b>Node Graph Outputs</b>
|
||||
|
||||
These behave like outputs on a shader and are typically connected to an
|
||||
output on a shader inside the node-graph.
|
||||
'''
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class Material "Material" (
|
||||
doc = """A Material provides a container into which multiple \"render targets\"
|
||||
can add data that defines a \"shading material\" for a renderer. Typically
|
||||
this consists of one or more UsdRelationship properties that target
|
||||
other prims of type Shader - though a target/client is free to add
|
||||
any data that is suitable. We <b>strongly advise</b> that all targets
|
||||
adopt the convention that all properties be prefixed with a namespace
|
||||
that identifies the target, e.g. \"rel ri:surface = </Shaders/mySurf>\".
|
||||
|
||||
## Binding Materials
|
||||
|
||||
In the UsdShading model, geometry expresses a binding to a single Material or
|
||||
to a set of Materials partitioned by UsdGeomSubsets defined beneath the
|
||||
geometry; it is legal to bind a Material at the root (or other sub-prim) of
|
||||
a model, and then bind a different Material to individual gprims, but the
|
||||
meaning of inheritance and \"ancestral overriding\" of Material bindings is
|
||||
left to each render-target to determine. Since UsdGeom has no concept of
|
||||
shading, we provide the API for binding and unbinding geometry on the API
|
||||
schema UsdShadeMaterialBindingAPI.
|
||||
|
||||
## Material Variation
|
||||
|
||||
The entire power of USD VariantSets and all the other composition
|
||||
operators can leveraged when encoding shading variation.
|
||||
UsdShadeMaterial provides facilities for a particular way of building
|
||||
\"Material variants\" in which neither the identity of the Materials themselves
|
||||
nor the geometry Material-bindings need to change - instead we vary the
|
||||
targeted networks, interface values, and even parameter values within
|
||||
a single variantSet.
|
||||
See \"Authoring Material Variations\"
|
||||
for more details.
|
||||
|
||||
## Materials Encapsulate their Networks in Namespace
|
||||
|
||||
UsdShade requires that all of the shaders that \"belong\" to the Material
|
||||
live under the Material in namespace. This supports powerful, easy reuse
|
||||
of Materials, because it allows us to *reference* a Material from one
|
||||
asset (the asset might be a library of Materials) into another asset: USD
|
||||
references compose all descendant prims of the reference target into the
|
||||
referencer's namespace, which means that all of the referenced Material's
|
||||
shader networks will come along with the Material. When referenced in this
|
||||
way, Materials can also be [instanced](http://openusd.org/docs/USD-Glossary.html#USDGlossary-Instancing), for ease of deduplication and compactness.
|
||||
Finally, Material encapsulation also allows us to
|
||||
\"specialize\" child materials from
|
||||
parent materials.
|
||||
|
||||
"""
|
||||
)
|
||||
{
|
||||
token outputs:displacement (
|
||||
displayGroup = "Outputs"
|
||||
doc = '''Represents the universal "displacement" output terminal of a
|
||||
material.'''
|
||||
)
|
||||
token outputs:surface (
|
||||
displayGroup = "Outputs"
|
||||
doc = '''Represents the universal "surface" output terminal of a
|
||||
material.'''
|
||||
)
|
||||
token outputs:volume (
|
||||
displayGroup = "Outputs"
|
||||
doc = '''Represents the universal "volume" output terminal of a
|
||||
material.'''
|
||||
)
|
||||
}
|
||||
|
||||
class Shader "Shader" (
|
||||
apiSchemas = ["NodeDefAPI"]
|
||||
doc = '''Base class for all USD shaders. Shaders are the building blocks
|
||||
of shading networks. While UsdShadeShader objects are not target specific,
|
||||
each renderer or application target may derive its own renderer-specific
|
||||
shader object types from this base, if needed.
|
||||
|
||||
Objects of this class generally represent a single shading object, whether
|
||||
it exists in the target renderer or not. For example, a texture, a fractal,
|
||||
or a mix node.
|
||||
|
||||
The UsdShadeNodeDefAPI provides attributes to uniquely identify the
|
||||
type of this node. The id resolution into a renderable shader target
|
||||
type of this node. The id resolution into a renderable shader target
|
||||
is deferred to the consuming application.
|
||||
|
||||
The purpose of representing them in Usd is two-fold:
|
||||
- To represent, via "connections" the topology of the shading network
|
||||
that must be reconstructed in the renderer. Facilities for authoring and
|
||||
manipulating connections are encapsulated in the API schema
|
||||
UsdShadeConnectableAPI.
|
||||
- To present a (partial or full) interface of typed input parameters
|
||||
whose values can be set and overridden in Usd, to be provided later at
|
||||
render-time as parameter values to the actual render shader objects. Shader
|
||||
input parameters are encapsulated in the property schema UsdShadeInput.
|
||||
'''
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "NodeDefAPI" (
|
||||
doc = '''UsdShadeNodeDefAPI is an API schema that provides attributes
|
||||
for a prim to select a corresponding Shader Node Definition ("Sdr Node"),
|
||||
as well as to look up a runtime entry for that shader node in the
|
||||
form of an SdrShaderNode.
|
||||
|
||||
UsdShadeNodeDefAPI is intended to be a pre-applied API schema for any
|
||||
prim type that wants to refer to the SdrRegistry for further implementation
|
||||
details about the behavior of that prim. The primary use in UsdShade
|
||||
itself is as UsdShadeShader, which is a basis for material shading networks
|
||||
(UsdShadeMaterial), but this is intended to be used in other domains
|
||||
that also use the Sdr node mechanism.
|
||||
|
||||
This schema provides properties that allow a prim to identify an external
|
||||
node definition, either by a direct identifier key into the SdrRegistry
|
||||
(info:id), an asset to be parsed by a suitable NdrParserPlugin
|
||||
(info:sourceAsset), or an inline source code that must also be parsed
|
||||
(info:sourceCode); as well as a selector attribute to determine which
|
||||
specifier is active (info:implementationSource).
|
||||
'''
|
||||
)
|
||||
{
|
||||
uniform token info:id (
|
||||
doc = """The id is an identifier for the type or purpose of the
|
||||
shader. E.g.: Texture or FractalFloat.
|
||||
The use of this id will depend on the render target: some will turn it
|
||||
into an actual shader path, some will use it to generate shader source
|
||||
code dynamically.
|
||||
|
||||
\\sa SetShaderId()
|
||||
"""
|
||||
)
|
||||
uniform token info:implementationSource = "id" (
|
||||
allowedTokens = ["id", "sourceAsset", "sourceCode"]
|
||||
doc = """Specifies the attribute that should be consulted to get the
|
||||
shader's implementation or its source code.
|
||||
|
||||
* If set to \"id\", the \"info:id\" attribute's value is used to
|
||||
determine the shader source from the shader registry.
|
||||
* If set to \"sourceAsset\", the resolved value of the \"info:sourceAsset\"
|
||||
attribute corresponding to the desired implementation (or source-type)
|
||||
is used to locate the shader source. A source asset file may also
|
||||
specify multiple shader definitions, so there is an optional attribute
|
||||
\"info:sourceAsset:subIdentifier\" whose value should be used to indicate
|
||||
a particular shader definition from a source asset file.
|
||||
* If set to \"sourceCode\", the value of \"info:sourceCode\" attribute
|
||||
corresponding to the desired implementation (or source type) is used as
|
||||
the shader source.
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
class "ConnectableAPI" (
|
||||
doc = """UsdShadeConnectableAPI is an API schema that provides a common
|
||||
interface for creating outputs and making connections between shading
|
||||
parameters and outputs. The interface is common to all UsdShade schemas
|
||||
that support Inputs and Outputs, which currently includes UsdShadeShader,
|
||||
UsdShadeNodeGraph, and UsdShadeMaterial .
|
||||
|
||||
One can construct a UsdShadeConnectableAPI directly from a UsdPrim, or
|
||||
from objects of any of the schema classes listed above. If it seems
|
||||
onerous to need to construct a secondary schema object to interact with
|
||||
Inputs and Outputs, keep in mind that any function whose purpose is either
|
||||
to walk material/shader networks via their connections, or to create such
|
||||
networks, can typically be written entirely in terms of
|
||||
UsdShadeConnectableAPI objects, without needing to care what the underlying
|
||||
prim type is.
|
||||
|
||||
Additionally, the most common UsdShadeConnectableAPI behaviors
|
||||
(creating Inputs and Outputs, and making connections) are wrapped as
|
||||
convenience methods on the prim schema classes (creation) and
|
||||
UsdShadeInput and UsdShadeOutput.
|
||||
"""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "MaterialBindingAPI" (
|
||||
doc = """UsdShadeMaterialBindingAPI is an API schema that provides an
|
||||
interface for binding materials to prims or collections of prims
|
||||
(represented by UsdCollectionAPI objects).
|
||||
|
||||
In the USD shading model, each renderable gprim computes a single
|
||||
<b>resolved Material</b> that will be used to shade the gprim (exceptions,
|
||||
of course, for gprims that possess UsdGeomSubsets, as each subset can be
|
||||
shaded by a different Material). A gprim <b>and each of its ancestor
|
||||
prims</b> can possess, through the MaterialBindingAPI, both a
|
||||
<b>direct</b> binding to a Material, and any number of
|
||||
<b>collection-based</b> bindings to Materials; each binding can be generic
|
||||
or declared for a particular <b>purpose</b>, and given a specific <b>binding
|
||||
strength</b>. It is the process of \"material resolution\" (see
|
||||
that examines all of
|
||||
these bindings, and selects the one Material that best matches the
|
||||
client's needs.
|
||||
|
||||
The intent of <b>purpose</b> is that each gprim should be able to resolve a
|
||||
Material for any given purpose, which implies it can have differently bound
|
||||
materials for different purposes. There are two <i>special</i> values of
|
||||
<b>purpose</b> defined in UsdShade, although the API fully supports
|
||||
specifying arbitrary values for it, for the sake of extensibility:
|
||||
<ul><li><b>UsdShadeTokens->full</b>: to be used when the purpose of the
|
||||
render is entirely to visualize the truest representation of a scene,
|
||||
considering all lighting and material information, at highest fidelity.</li>
|
||||
<li><b>UsdShadeTokens->preview</b>: to be used when the render is in
|
||||
service of a goal other than a high fidelity \"full\" render (such as scene
|
||||
manipulation, modeling, or realtime playback). Latency and speed are
|
||||
generally of greater concern for preview renders, therefore preview
|
||||
materials are generally designed to be \"lighterweight\" compared to full
|
||||
materials.</li></ul>
|
||||
A binding can also have no specific purpose at all, in which
|
||||
case, it is considered to be the fallback or all-purpose binding (denoted
|
||||
by the empty-valued token <b>UsdShadeTokens->allPurpose</b>).
|
||||
|
||||
The <b>purpose</b> of a material binding is encoded in the name of the
|
||||
binding relationship.
|
||||
<ul><li>
|
||||
In the case of a direct binding, the <i>allPurpose</i> binding is
|
||||
represented by the relationship named <b>\"material:binding\"</b>.
|
||||
Special-purpose direct bindings are represented by relationships named
|
||||
<b>\"material:binding:<i>purpose</i></b>. A direct binding relationship
|
||||
must have a single target path that points to a <b>UsdShadeMaterial</b>.</li>
|
||||
<li>
|
||||
In the case of a collection-based binding, the <i>allPurpose</i> binding is
|
||||
represented by a relationship named
|
||||
\"material:binding:collection:<i>bindingName</i>\", where
|
||||
<b>bindingName</b> establishes an identity for the binding that is unique
|
||||
on the prim. Attempting to establish two collection bindings of the same
|
||||
name on the same prim will result in the first binding simply being
|
||||
overridden. A special-purpose collection-based binding is represented by a
|
||||
relationship named \"material:binding:collection:<i>purpose:bindingName</i>\".
|
||||
A collection-based binding relationship must have exacly two targets, one of
|
||||
which should be a collection-path (see
|
||||
and the other should point to a
|
||||
<b>UsdShadeMaterial</b>. In the future, we may allow a single collection
|
||||
binding to target multiple collections, if we can establish a reasonable
|
||||
round-tripping pattern for applications that only allow a single collection
|
||||
to be associated with each Material.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<b>Note:</b> Both <b>bindingName</b> and <b>purpose</b> must be
|
||||
non-namespaced tokens. This allows us to know the role of a binding
|
||||
relationship simply from the number of tokens in it.
|
||||
<ul><li><b>Two tokens</b>: the fallback, \"all purpose\", direct binding,
|
||||
<i>material:binding</i></li>
|
||||
<li><b>Three tokens</b>: a purpose-restricted, direct, fallback binding,
|
||||
e.g. material:binding:preview</li>
|
||||
<li><b>Four tokens</b>: an all-purpose, collection-based binding, e.g.
|
||||
material:binding:collection:metalBits</li>
|
||||
<li><b>Five tokens</b>: a purpose-restricted, collection-based binding,
|
||||
e.g. material:binding:collection:full:metalBits</li>
|
||||
</ul>
|
||||
|
||||
A <b>binding-strength</b> value is used to specify whether a binding
|
||||
authored on a prim should be weaker or stronger than bindings that appear
|
||||
lower in namespace. We encode the binding strength with as token-valued
|
||||
metadata <b>'bindMaterialAs'</b> for future flexibility, even though for
|
||||
now, there are only two possible values:
|
||||
<i>UsdShadeTokens->weakerThanDescendants</i> and
|
||||
<i>UsdShadeTokens->strongerThanDescendants</i>. When binding-strength is
|
||||
not authored (i.e. empty) on a binding-relationship, the default behavior
|
||||
matches UsdShadeTokens->weakerThanDescendants.
|
||||
|
||||
\\note If a material binding relationship is a built-in property defined as
|
||||
part of a typed prim's schema, a fallback value should not be provided for
|
||||
it. This is because the \"material resolution\" algorithm only conisders
|
||||
<i>authored</i> properties.
|
||||
"""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "CoordSysAPI" (
|
||||
doc = '''UsdShadeCoordSysAPI provides a way to designate, name,
|
||||
and discover coordinate systems.
|
||||
|
||||
Coordinate systems are implicitly established by UsdGeomXformable
|
||||
prims, using their local space. That coordinate system may be
|
||||
bound (i.e., named) from another prim. The binding is encoded
|
||||
as a single-target relationship in the "coordSys:" namespace.
|
||||
Coordinate system bindings apply to descendants of the prim
|
||||
where the binding is expressed, but names may be re-bound by
|
||||
descendant prims.
|
||||
|
||||
Named coordinate systems are useful in shading workflows.
|
||||
An example is projection paint, which projects a texture
|
||||
from a certain view (the paint coordinate system). Using
|
||||
the paint coordinate frame avoids the need to assign a UV
|
||||
set to the object, and can be a concise way to project
|
||||
paint across a collection of objects with a single shared
|
||||
paint coordinate system.
|
||||
|
||||
This is a non-applied API schema.
|
||||
'''
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"bindMaterialAs": {
|
||||
"appliesTo": [
|
||||
"relationships"
|
||||
],
|
||||
"displayGroup": "Shading",
|
||||
"documentation": "Metadata authored on collection-based material binding relationship to indicate the strength of the binding relative to bindings authored on descendant prims.",
|
||||
"type": "token"
|
||||
},
|
||||
"connectability": {
|
||||
"appliesTo": [
|
||||
"attributes"
|
||||
],
|
||||
"default": "full",
|
||||
"displayGroup": "Shading",
|
||||
"documentation": "Metadata authored on UsdShadeInput's to specify what they can be connected to. Can be either \"full\" or \"interfaceOnly\". \"full\" implies that the input can be connected to any other input or output. \"interfaceOnly\" implies that the input can only connect to a NodeGraph Input (which represents an interface override, not a render-time dataflow connection), or another Input whose connectability is also \"interfaceOnly\".",
|
||||
"type": "token"
|
||||
},
|
||||
"outputName": {
|
||||
"appliesTo": [
|
||||
"relationships"
|
||||
],
|
||||
"displayGroup": "deprecated",
|
||||
"type": "token"
|
||||
},
|
||||
"renderType": {
|
||||
"appliesTo": [
|
||||
"properties"
|
||||
],
|
||||
"displayGroup": "Rendering",
|
||||
"type": "token"
|
||||
},
|
||||
"sdrMetadata": {
|
||||
"appliesTo": [
|
||||
"prims",
|
||||
"attributes"
|
||||
],
|
||||
"displayGroup": "Shading",
|
||||
"type": "dictionary"
|
||||
}
|
||||
},
|
||||
"Types": {
|
||||
"UsdShadeConnectableAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "ConnectableAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "nonAppliedAPI"
|
||||
},
|
||||
"UsdShadeCoordSysAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "CoordSysAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "nonAppliedAPI"
|
||||
},
|
||||
"UsdShadeMaterial": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Material"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdShadeNodeGraph"
|
||||
],
|
||||
"providesUsdShadeConnectableAPIBehavior": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdShadeMaterialBindingAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "MaterialBindingAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdShadeNodeDefAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "NodeDefAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdShadeNodeGraph": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "NodeGraph"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"providesUsdShadeConnectableAPIBehavior": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdShadeShader": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Shader"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"providesUsdShadeConnectableAPIBehavior": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdShadeShaderDefParserPlugin": {
|
||||
"bases": [
|
||||
"NdrParserPlugin"
|
||||
],
|
||||
"displayName": "USD-based shader definition parser plugin"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdShade.dll",
|
||||
"Name": "usdShade",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,593 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"This file describes the USD Shader schemata for code generation."
|
||||
subLayers = [
|
||||
@usd/schema.usda@
|
||||
]
|
||||
)
|
||||
|
||||
over "GLOBAL" (
|
||||
customData = {
|
||||
string libraryName = "usdShade"
|
||||
string libraryPath = "pxr/usd/usdShade"
|
||||
dictionary libraryTokens = {
|
||||
dictionary materialBind = {
|
||||
string doc = """The name of the GeomSubset family used to
|
||||
identify face subsets defined for the purpose of binding
|
||||
materials to facesets.
|
||||
"""
|
||||
}
|
||||
dictionary full = {
|
||||
string doc= """Possible value for 'connectability' metadata on
|
||||
a UsdShadeInput. When connectability of an input is set to
|
||||
"full", it implies that it can be connected to any input or
|
||||
output.
|
||||
"""
|
||||
}
|
||||
dictionary interfaceOnly = {
|
||||
string doc= """Possible value for 'connectability' metadata on
|
||||
a UsdShadeInput. It implies that the input can only connect to
|
||||
a NodeGraph Input (which represents an interface override, not
|
||||
a render-time dataflow connection), or another Input whose
|
||||
connectability is also 'interfaceOnly'.
|
||||
"""
|
||||
}
|
||||
dictionary outputs = {
|
||||
string value = "outputs:"
|
||||
string doc = """The prefix on shading attributes
|
||||
denoting an output.
|
||||
"""
|
||||
}
|
||||
dictionary inputs = {
|
||||
string value = "inputs:"
|
||||
string doc = """The prefix on shading attributes
|
||||
denoting an input.
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class NodeGraph "NodeGraph" (
|
||||
inherits = </Typed>
|
||||
doc = """A node-graph is a container for shading nodes, as well as other
|
||||
node-graphs. It has a public input interface and provides a list of public
|
||||
outputs.
|
||||
|
||||
<b>Node Graph Interfaces</b>
|
||||
|
||||
One of the most important functions of a node-graph is to host the "interface"
|
||||
with which clients of already-built shading networks will interact. Please
|
||||
see \\ref UsdShadeNodeGraph_Interfaces "Interface Inputs" for a detailed
|
||||
explanation of what the interface provides, and how to construct and
|
||||
use it, to effectively share/instance shader networks.
|
||||
|
||||
<b>Node Graph Outputs</b>
|
||||
|
||||
These behave like outputs on a shader and are typically connected to an
|
||||
output on a shader inside the node-graph.
|
||||
"""
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool providesUsdShadeConnectableAPIBehavior = 1
|
||||
}
|
||||
string extraIncludes = '''
|
||||
#include <utility>
|
||||
#include "pxr/usd/usd/editTarget.h"
|
||||
#include "pxr/usd/usd/relationship.h"
|
||||
#include "pxr/usd/usdShade/input.h"
|
||||
#include "pxr/usd/usdShade/output.h"
|
||||
#include "pxr/usd/usdShade/shader.h"
|
||||
#include "pxr/usd/usdShade/connectableAPIBehavior.h"'''
|
||||
}
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Material "Material" (
|
||||
inherits = </NodeGraph>
|
||||
doc = """A Material provides a container into which multiple "render targets"
|
||||
can add data that defines a "shading material" for a renderer. Typically
|
||||
this consists of one or more UsdRelationship properties that target
|
||||
other prims of type \\em Shader - though a target/client is free to add
|
||||
any data that is suitable. We <b>strongly advise</b> that all targets
|
||||
adopt the convention that all properties be prefixed with a namespace
|
||||
that identifies the target, e.g. "rel ri:surface = </Shaders/mySurf>".
|
||||
|
||||
## Binding Materials
|
||||
|
||||
In the UsdShading model, geometry expresses a binding to a single Material or
|
||||
to a set of Materials partitioned by UsdGeomSubsets defined beneath the
|
||||
geometry; it is legal to bind a Material at the root (or other sub-prim) of
|
||||
a model, and then bind a different Material to individual gprims, but the
|
||||
meaning of inheritance and "ancestral overriding" of Material bindings is
|
||||
left to each render-target to determine. Since UsdGeom has no concept of
|
||||
shading, we provide the API for binding and unbinding geometry on the API
|
||||
schema UsdShadeMaterialBindingAPI.
|
||||
|
||||
## Material Variation
|
||||
|
||||
The entire power of USD VariantSets and all the other composition
|
||||
operators can leveraged when encoding shading variation.
|
||||
UsdShadeMaterial provides facilities for a particular way of building
|
||||
"Material variants" in which neither the identity of the Materials themselves
|
||||
nor the geometry Material-bindings need to change - instead we vary the
|
||||
targeted networks, interface values, and even parameter values within
|
||||
a single variantSet.
|
||||
See \\ref UsdShadeMaterial_Variations "Authoring Material Variations"
|
||||
for more details.
|
||||
|
||||
## Materials Encapsulate their Networks in Namespace
|
||||
|
||||
UsdShade requires that all of the shaders that "belong" to the Material
|
||||
live under the Material in namespace. This supports powerful, easy reuse
|
||||
of Materials, because it allows us to *reference* a Material from one
|
||||
asset (the asset might be a library of Materials) into another asset: USD
|
||||
references compose all descendant prims of the reference target into the
|
||||
referencer's namespace, which means that all of the referenced Material's
|
||||
shader networks will come along with the Material. When referenced in this
|
||||
way, Materials can also be [instanced](http://openusd.org/docs/USD-Glossary.html#USDGlossary-Instancing), for ease of deduplication and compactness.
|
||||
Finally, Material encapsulation also allows us to
|
||||
\\ref UsdShadeMaterial_BaseMaterial "specialize" child materials from
|
||||
parent materials.
|
||||
|
||||
"""
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool providesUsdShadeConnectableAPIBehavior = 1
|
||||
}
|
||||
string extraIncludes = '''
|
||||
#include "pxr/usd/usd/variantSets.h"
|
||||
#include "pxr/usd/usdGeom/subset.h"
|
||||
#include "pxr/usd/usdShade/connectableAPI.h"'''
|
||||
dictionary schemaTokens = {
|
||||
dictionary materialVariant = {
|
||||
string doc = """The variant name of material variation
|
||||
described on a UsdShadeMaterial.
|
||||
"""
|
||||
}
|
||||
dictionary surface = {
|
||||
string doc = """Describes the <i>surface</i> output
|
||||
terminal on a UsdShadeMaterial. It is used to define the
|
||||
terminal UsdShadeShader describing the surface of a
|
||||
UsdShadeMaterial.
|
||||
"""
|
||||
}
|
||||
dictionary displacement = {
|
||||
string doc = """Describes the <i>displacement</i> output
|
||||
terminal on a UsdShadeMaterial. It is used to define the
|
||||
terminal UsdShadeShader describing the displacement of a
|
||||
UsdShadeMaterial.
|
||||
"""
|
||||
}
|
||||
dictionary volume = {
|
||||
string doc = """Describes the <i>volume</i> output
|
||||
terminal on a UsdShadeMaterial. It is used to define the
|
||||
terminal UsdShadeShader describing the volume of a
|
||||
UsdShadeMaterial.
|
||||
"""
|
||||
}
|
||||
dictionary universalRenderContext = {
|
||||
string value = ""
|
||||
string doc = """Possible value for the "renderContext" parameter
|
||||
in \\ref UsdShadeMaterial_Outputs API. Represents the universal
|
||||
renderContext. An output with a universal renderContext is
|
||||
applicable to all possible rendering contexts.
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
token outputs:surface (
|
||||
doc = """Represents the universal "surface" output terminal of a
|
||||
material."""
|
||||
displayGroup = "Outputs"
|
||||
customData = {
|
||||
string apiName = "surface"
|
||||
}
|
||||
)
|
||||
token outputs:displacement (
|
||||
doc = """Represents the universal "displacement" output terminal of a
|
||||
material."""
|
||||
displayGroup = "Outputs"
|
||||
customData = {
|
||||
string apiName = "displacement"
|
||||
}
|
||||
)
|
||||
token outputs:volume (
|
||||
doc = """Represents the universal "volume" output terminal of a
|
||||
material."""
|
||||
displayGroup = "Outputs"
|
||||
customData = {
|
||||
string apiName = "volume"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class Shader "Shader" (
|
||||
inherits = </Typed>
|
||||
prepend apiSchemas = ["NodeDefAPI"]
|
||||
doc = """Base class for all USD shaders. Shaders are the building blocks
|
||||
of shading networks. While UsdShadeShader objects are not target specific,
|
||||
each renderer or application target may derive its own renderer-specific
|
||||
shader object types from this base, if needed.
|
||||
|
||||
Objects of this class generally represent a single shading object, whether
|
||||
it exists in the target renderer or not. For example, a texture, a fractal,
|
||||
or a mix node.
|
||||
|
||||
The UsdShadeNodeDefAPI provides attributes to uniquely identify the
|
||||
type of this node. The id resolution into a renderable shader target
|
||||
type of this node. The id resolution into a renderable shader target
|
||||
is deferred to the consuming application.
|
||||
|
||||
The purpose of representing them in Usd is two-fold:
|
||||
\\li To represent, via "connections" the topology of the shading network
|
||||
that must be reconstructed in the renderer. Facilities for authoring and
|
||||
manipulating connections are encapsulated in the API schema
|
||||
UsdShadeConnectableAPI.
|
||||
\\li To present a (partial or full) interface of typed input parameters
|
||||
whose values can be set and overridden in Usd, to be provided later at
|
||||
render-time as parameter values to the actual render shader objects. Shader
|
||||
input parameters are encapsulated in the property schema UsdShadeInput.
|
||||
"""
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool providesUsdShadeConnectableAPIBehavior = 1
|
||||
}
|
||||
string extraIncludes = '''
|
||||
#include "pxr/usd/usdShade/input.h"
|
||||
#include "pxr/usd/usdShade/output.h"
|
||||
#include "pxr/usd/usdShade/tokens.h"
|
||||
#include "pxr/usd/ndr/declare.h"
|
||||
#include "pxr/usd/sdr/shaderNode.h"'''
|
||||
}
|
||||
) {
|
||||
}
|
||||
|
||||
class "NodeDefAPI"
|
||||
(
|
||||
inherits = </APISchemaBase>
|
||||
doc = """UsdShadeNodeDefAPI is an API schema that provides attributes
|
||||
for a prim to select a corresponding Shader Node Definition ("Sdr Node"),
|
||||
as well as to look up a runtime entry for that shader node in the
|
||||
form of an SdrShaderNode.
|
||||
|
||||
UsdShadeNodeDefAPI is intended to be a pre-applied API schema for any
|
||||
prim type that wants to refer to the SdrRegistry for further implementation
|
||||
details about the behavior of that prim. The primary use in UsdShade
|
||||
itself is as UsdShadeShader, which is a basis for material shading networks
|
||||
(UsdShadeMaterial), but this is intended to be used in other domains
|
||||
that also use the Sdr node mechanism.
|
||||
|
||||
This schema provides properties that allow a prim to identify an external
|
||||
node definition, either by a direct identifier key into the SdrRegistry
|
||||
(info:id), an asset to be parsed by a suitable NdrParserPlugin
|
||||
(info:sourceAsset), or an inline source code that must also be parsed
|
||||
(info:sourceCode); as well as a selector attribute to determine which
|
||||
specifier is active (info:implementationSource).
|
||||
"""
|
||||
customData = {
|
||||
token apiSchemaType = "singleApply"
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/ndr/declare.h"
|
||||
#include "pxr/usd/sdr/shaderNode.h"
|
||||
"""
|
||||
dictionary schemaTokens = {
|
||||
dictionary universalSourceType = {
|
||||
string value = ""
|
||||
string doc = """Possible value for the "sourceType" parameter
|
||||
in \\ref UsdShadeNodeDefAPI_ImplementationSource API. Represents
|
||||
the universal or fallback source type.
|
||||
"""
|
||||
}
|
||||
dictionary sdrMetadata = {
|
||||
string doc = """Dictionary valued metadata key authored on
|
||||
Shader prims with implementationSource value of sourceAsset or
|
||||
sourceCode to pass along metadata to the shader parser or
|
||||
compiler. It is also used to author metadata on shader
|
||||
properties in a UsdShade-based shader definition file.
|
||||
"""
|
||||
}
|
||||
dictionary subIdentifier = {
|
||||
string doc = """This identifier is used in conjunction with a
|
||||
specific source asset to indicate a particular definition within
|
||||
the source asset, if the source asset specifies more than one
|
||||
shader node definition.
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
uniform token info:implementationSource = "id" (
|
||||
allowedTokens = ["id", "sourceAsset", "sourceCode"]
|
||||
doc = """Specifies the attribute that should be consulted to get the
|
||||
shader's implementation or its source code.
|
||||
|
||||
* If set to "id", the "info:id" attribute's value is used to
|
||||
determine the shader source from the shader registry.
|
||||
* If set to "sourceAsset", the resolved value of the "info:sourceAsset"
|
||||
attribute corresponding to the desired implementation (or source-type)
|
||||
is used to locate the shader source. A source asset file may also
|
||||
specify multiple shader definitions, so there is an optional attribute
|
||||
"info:sourceAsset:subIdentifier" whose value should be used to indicate
|
||||
a particular shader definition from a source asset file.
|
||||
* If set to "sourceCode", the value of "info:sourceCode" attribute
|
||||
corresponding to the desired implementation (or source type) is used as
|
||||
the shader source.
|
||||
"""
|
||||
customData = {
|
||||
string apiName = "implementationSource"
|
||||
}
|
||||
)
|
||||
|
||||
uniform token info:id (
|
||||
doc = """The id is an identifier for the type or purpose of the
|
||||
shader. E.g.: Texture or FractalFloat.
|
||||
The use of this id will depend on the render target: some will turn it
|
||||
into an actual shader path, some will use it to generate shader source
|
||||
code dynamically.
|
||||
|
||||
\\sa SetShaderId()
|
||||
"""
|
||||
customData = {
|
||||
string apiName = "id"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class "ConnectableAPI"
|
||||
(
|
||||
inherits = </APISchemaBase>
|
||||
doc = """UsdShadeConnectableAPI is an API schema that provides a common
|
||||
interface for creating outputs and making connections between shading
|
||||
parameters and outputs. The interface is common to all UsdShade schemas
|
||||
that support Inputs and Outputs, which currently includes UsdShadeShader,
|
||||
UsdShadeNodeGraph, and UsdShadeMaterial .
|
||||
|
||||
One can construct a UsdShadeConnectableAPI directly from a UsdPrim, or
|
||||
from objects of any of the schema classes listed above. If it seems
|
||||
onerous to need to construct a secondary schema object to interact with
|
||||
Inputs and Outputs, keep in mind that any function whose purpose is either
|
||||
to walk material/shader networks via their connections, or to create such
|
||||
networks, can typically be written entirely in terms of
|
||||
UsdShadeConnectableAPI objects, without needing to care what the underlying
|
||||
prim type is.
|
||||
|
||||
Additionally, the most common UsdShadeConnectableAPI behaviors
|
||||
(creating Inputs and Outputs, and making connections) are wrapped as
|
||||
convenience methods on the prim schema classes (creation) and
|
||||
UsdShadeInput and UsdShadeOutput.
|
||||
"""
|
||||
customData = {
|
||||
token apiSchemaType = "nonApplied"
|
||||
string extraIncludes = '''
|
||||
#include "pxr/usd/usd/typed.h"
|
||||
#include "pxr/usd/usdShade/input.h"
|
||||
#include "pxr/usd/usdShade/output.h"
|
||||
#include "pxr/usd/usdShade/tokens.h"
|
||||
#include "pxr/usd/usdShade/types.h"'''
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "MaterialBindingAPI"
|
||||
(
|
||||
inherits = </APISchemaBase>
|
||||
doc = """UsdShadeMaterialBindingAPI is an API schema that provides an
|
||||
interface for binding materials to prims or collections of prims
|
||||
(represented by UsdCollectionAPI objects).
|
||||
|
||||
In the USD shading model, each renderable gprim computes a single
|
||||
<b>resolved Material</b> that will be used to shade the gprim (exceptions,
|
||||
of course, for gprims that possess UsdGeomSubsets, as each subset can be
|
||||
shaded by a different Material). A gprim <b>and each of its ancestor
|
||||
prims</b> can possess, through the MaterialBindingAPI, both a
|
||||
<b>direct</b> binding to a Material, and any number of
|
||||
<b>collection-based</b> bindings to Materials; each binding can be generic
|
||||
or declared for a particular <b>purpose</b>, and given a specific <b>binding
|
||||
strength</b>. It is the process of "material resolution" (see
|
||||
\\ref UsdShadeMaterialBindingAPI_MaterialResolution) that examines all of
|
||||
these bindings, and selects the one Material that best matches the
|
||||
client's needs.
|
||||
|
||||
The intent of <b>purpose</b> is that each gprim should be able to resolve a
|
||||
Material for any given purpose, which implies it can have differently bound
|
||||
materials for different purposes. There are two <i>special</i> values of
|
||||
<b>purpose</b> defined in UsdShade, although the API fully supports
|
||||
specifying arbitrary values for it, for the sake of extensibility:
|
||||
<ul><li><b>UsdShadeTokens->full</b>: to be used when the purpose of the
|
||||
render is entirely to visualize the truest representation of a scene,
|
||||
considering all lighting and material information, at highest fidelity.</li>
|
||||
<li><b>UsdShadeTokens->preview</b>: to be used when the render is in
|
||||
service of a goal other than a high fidelity "full" render (such as scene
|
||||
manipulation, modeling, or realtime playback). Latency and speed are
|
||||
generally of greater concern for preview renders, therefore preview
|
||||
materials are generally designed to be "lighterweight" compared to full
|
||||
materials.</li></ul>
|
||||
A binding can also have no specific purpose at all, in which
|
||||
case, it is considered to be the fallback or all-purpose binding (denoted
|
||||
by the empty-valued token <b>UsdShadeTokens->allPurpose</b>).
|
||||
|
||||
The <b>purpose</b> of a material binding is encoded in the name of the
|
||||
binding relationship.
|
||||
<ul><li>
|
||||
In the case of a direct binding, the <i>allPurpose</i> binding is
|
||||
represented by the relationship named <b>"material:binding"</b>.
|
||||
Special-purpose direct bindings are represented by relationships named
|
||||
<b>"material:binding:<i>purpose</i></b>. A direct binding relationship
|
||||
must have a single target path that points to a <b>UsdShadeMaterial</b>.</li>
|
||||
<li>
|
||||
In the case of a collection-based binding, the <i>allPurpose</i> binding is
|
||||
represented by a relationship named
|
||||
"material:binding:collection:<i>bindingName</i>", where
|
||||
<b>bindingName</b> establishes an identity for the binding that is unique
|
||||
on the prim. Attempting to establish two collection bindings of the same
|
||||
name on the same prim will result in the first binding simply being
|
||||
overridden. A special-purpose collection-based binding is represented by a
|
||||
relationship named "material:binding:collection:<i>purpose:bindingName</i>".
|
||||
A collection-based binding relationship must have exacly two targets, one of
|
||||
which should be a collection-path (see
|
||||
\ref UsdCollectionAPI::GetCollectionPath()) and the other should point to a
|
||||
<b>UsdShadeMaterial</b>. In the future, we may allow a single collection
|
||||
binding to target multiple collections, if we can establish a reasonable
|
||||
round-tripping pattern for applications that only allow a single collection
|
||||
to be associated with each Material.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<b>Note:</b> Both <b>bindingName</b> and <b>purpose</b> must be
|
||||
non-namespaced tokens. This allows us to know the role of a binding
|
||||
relationship simply from the number of tokens in it.
|
||||
<ul><li><b>Two tokens</b>: the fallback, "all purpose", direct binding,
|
||||
<i>material:binding</i></li>
|
||||
<li><b>Three tokens</b>: a purpose-restricted, direct, fallback binding,
|
||||
e.g. material:binding:preview</li>
|
||||
<li><b>Four tokens</b>: an all-purpose, collection-based binding, e.g.
|
||||
material:binding:collection:metalBits</li>
|
||||
<li><b>Five tokens</b>: a purpose-restricted, collection-based binding,
|
||||
e.g. material:binding:collection:full:metalBits</li>
|
||||
</ul>
|
||||
|
||||
A <b>binding-strength</b> value is used to specify whether a binding
|
||||
authored on a prim should be weaker or stronger than bindings that appear
|
||||
lower in namespace. We encode the binding strength with as token-valued
|
||||
metadata <b>'bindMaterialAs'</b> for future flexibility, even though for
|
||||
now, there are only two possible values:
|
||||
<i>UsdShadeTokens->weakerThanDescendants</i> and
|
||||
<i>UsdShadeTokens->strongerThanDescendants</i>. When binding-strength is
|
||||
not authored (i.e. empty) on a binding-relationship, the default behavior
|
||||
matches UsdShadeTokens->weakerThanDescendants.
|
||||
|
||||
\\note If a material binding relationship is a built-in property defined as
|
||||
part of a typed prim's schema, a fallback value should not be provided for
|
||||
it. This is because the "material resolution" algorithm only conisders
|
||||
<i>authored</i> properties.
|
||||
"""
|
||||
customData = {
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usd/collectionAPI.h"
|
||||
#include "pxr/usd/usdGeom/subset.h"
|
||||
#include "pxr/usd/usdShade/material.h"
|
||||
#include <tbb/concurrent_unordered_map.h>"""
|
||||
dictionary schemaTokens = {
|
||||
dictionary materialBinding = {
|
||||
string value = "material:binding"
|
||||
string doc = """
|
||||
The relationship name on non-shading prims to
|
||||
denote a binding to a UsdShadeMaterial.
|
||||
"""
|
||||
}
|
||||
dictionary materialBindingCollection = {
|
||||
string value = "material:binding:collection"
|
||||
string doc = """
|
||||
The relationship name on non-shading prims to
|
||||
denote a collection-based binding to a UsdShadeMaterial.
|
||||
"""
|
||||
}
|
||||
dictionary allPurpose = {
|
||||
string value = ""
|
||||
string doc = """Possible value for the 'materialPurpose' parameter
|
||||
in the various methods available in UsdShadeMaterialBindingAPI.
|
||||
Its value is empty and its purpose is to represent a general
|
||||
purpose material-binding that applies in the absence of a
|
||||
specific-purpose binding.
|
||||
"""
|
||||
}
|
||||
dictionary preview = {
|
||||
string doc = """Possible value for the 'materialPurpose'
|
||||
parameter in UsdShadeMaterialBindingAPI, to be used when the
|
||||
render is in service of a goal other than a high fidelity "full"
|
||||
render (such as scene manipulation, modeling, or realtime
|
||||
playback). Latency and speed are generally of greater concern
|
||||
for preview renders, therefore preview materials are generally
|
||||
designed to be "lighterweight" compared to full materials.
|
||||
"""
|
||||
}
|
||||
|
||||
dictionary full = {
|
||||
string doc= """Possible value for the 'materialPurpose'
|
||||
parameter in UsdShadeMaterialBindingAPI, to be used when the
|
||||
purpose of the render is entirely about visualizing the truest
|
||||
representation of a scene, considering all lighting and material
|
||||
information, at highest fidelity.
|
||||
"""
|
||||
}
|
||||
dictionary bindMaterialAs = {
|
||||
string doc = """Token valued metadata key authored on a material
|
||||
binding relationship to indicate the strength of the binding
|
||||
relative to bindings authored on descendants.
|
||||
"""
|
||||
}
|
||||
dictionary weakerThanDescendants = {
|
||||
string doc = """Possible value for 'bindMaterialAs' metadata on the
|
||||
collection-based material binding relationship. Indicates
|
||||
that the binding represented by the relationship is weaker than
|
||||
any bindings authored on the descendants."""
|
||||
}
|
||||
dictionary strongerThanDescendants = {
|
||||
string doc = """Possible value for 'bindMaterialAs' metadata on the
|
||||
collection-based material binding relationship. Indicates
|
||||
that the binding represented by the relationship is stronger than
|
||||
any bindings authored on the descendants."""
|
||||
}
|
||||
dictionary fallbackStrength = {
|
||||
string doc = """Sentinal value to be used for 'bindMaterialAs'
|
||||
metadata's default value. Clients should pass this in for the
|
||||
'bindingStrength' argument to UsdShadeMaterialBindingAPI::Bind(),
|
||||
if they want to author the default value (weakerThanDescendants)
|
||||
sparsely. The value "fallbackStrength" never gets authored
|
||||
into scene description."""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class "CoordSysAPI"
|
||||
(
|
||||
inherits = </APISchemaBase>
|
||||
doc = """UsdShadeCoordSysAPI provides a way to designate, name,
|
||||
and discover coordinate systems.
|
||||
|
||||
Coordinate systems are implicitly established by UsdGeomXformable
|
||||
prims, using their local space. That coordinate system may be
|
||||
bound (i.e., named) from another prim. The binding is encoded
|
||||
as a single-target relationship in the "coordSys:" namespace.
|
||||
Coordinate system bindings apply to descendants of the prim
|
||||
where the binding is expressed, but names may be re-bound by
|
||||
descendant prims.
|
||||
|
||||
Named coordinate systems are useful in shading workflows.
|
||||
An example is projection paint, which projects a texture
|
||||
from a certain view (the paint coordinate system). Using
|
||||
the paint coordinate frame avoids the need to assign a UV
|
||||
set to the object, and can be a concise way to project
|
||||
paint across a collection of objects with a single shared
|
||||
paint coordinate system.
|
||||
|
||||
This is a non-applied API schema.
|
||||
"""
|
||||
customData = {
|
||||
token apiSchemaType = "nonApplied"
|
||||
string extraIncludes = '''
|
||||
#include "pxr/usd/usdGeom/xformable.h"'''
|
||||
dictionary schemaTokens = {
|
||||
dictionary coordSys = {
|
||||
string value = "coordSys:"
|
||||
string doc = """Namespace prefix for relationships that
|
||||
bind coordinate systems."""
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
#usda 1.0
|
||||
(
|
||||
"WARNING: THIS FILE IS GENERATED BY usdGenSchema. DO NOT EDIT."
|
||||
)
|
||||
|
||||
class SkelRoot "SkelRoot" (
|
||||
doc = '''Boundable prim type used to identify a scope beneath which
|
||||
skeletally-posed primitives are defined.
|
||||
|
||||
A SkelRoot must be defined at or above a skinned primitive for any skinning
|
||||
behaviors in UsdSkel.
|
||||
|
||||
See the extended "Skel Root Schema" documentation for
|
||||
more information.'''
|
||||
)
|
||||
{
|
||||
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."""
|
||||
)
|
||||
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 classification of 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.
|
||||
|
||||
See for more detail about how
|
||||
purpose is computed and used."""
|
||||
)
|
||||
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.'''
|
||||
)
|
||||
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 Skeleton "Skeleton" (
|
||||
doc = '''Describes a skeleton.
|
||||
|
||||
See the extended "Skeleton Schema" documentation for
|
||||
more information.
|
||||
'''
|
||||
)
|
||||
{
|
||||
uniform matrix4d[] bindTransforms (
|
||||
doc = """Specifies the bind-pose transforms of each joint in
|
||||
**world space**, in the ordering imposed by *joints*."""
|
||||
)
|
||||
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."""
|
||||
)
|
||||
uniform token[] jointNames (
|
||||
doc = """If authored, provides a unique name per joint. This may be
|
||||
optionally set to provide better names when translating to DCC apps
|
||||
that require unique joint names."""
|
||||
)
|
||||
uniform token[] joints (
|
||||
doc = """An array of path tokens identifying the set of joints that make
|
||||
up the skeleton, and their order. Each token in the array must be valid
|
||||
when parsed as an SdfPath. The parent-child relationships of the
|
||||
corresponding paths determine the parent-child relationships of each
|
||||
joint. It is not required that the name at the end of each path be
|
||||
unique, but rather only that the paths themselves be unique."""
|
||||
)
|
||||
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 classification of 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.
|
||||
|
||||
See for more detail about how
|
||||
purpose is computed and used."""
|
||||
)
|
||||
uniform matrix4d[] restTransforms (
|
||||
doc = """Specifies the rest-pose transforms of each joint in
|
||||
**local space**, in the ordering imposed by *joints*. This provides
|
||||
fallback values for joint transforms when a Skeleton either has no
|
||||
bound animation source, or when that animation source only contains
|
||||
animation for a subset of a Skeleton's joints."""
|
||||
)
|
||||
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.'''
|
||||
)
|
||||
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 SkelAnimation "SkelAnimation" (
|
||||
doc = '''Describes a skel animation, where joint animation is stored in a
|
||||
vectorized form.
|
||||
|
||||
See the extended "Skel Animation"
|
||||
documentation for more information.
|
||||
'''
|
||||
)
|
||||
{
|
||||
uniform token[] blendShapes (
|
||||
doc = """Array of tokens identifying which blend shapes this
|
||||
animation's data applies to. The tokens for blendShapes correspond to
|
||||
the tokens set in the *skel:blendShapes* binding property of the
|
||||
UsdSkelBindingAPI."""
|
||||
)
|
||||
float[] blendShapeWeights (
|
||||
doc = """Array of weight values for each blend shape. Each weight value
|
||||
is associated with the corresponding blend shape identified within the
|
||||
*blendShapes* token array, and therefore must have the same length as
|
||||
*blendShapes."""
|
||||
)
|
||||
uniform token[] joints (
|
||||
doc = """Array of tokens identifying which joints this animation's
|
||||
data applies to. The tokens for joints correspond to the tokens of
|
||||
Skeleton primitives. The order of the joints as listed here may
|
||||
vary from the order of joints on the Skeleton itself."""
|
||||
)
|
||||
quatf[] rotations (
|
||||
doc = """Joint-local unit quaternion rotations of all affected joints,
|
||||
in 32-bit precision. Array length should match the size of the
|
||||
*joints* attribute."""
|
||||
)
|
||||
half3[] scales (
|
||||
doc = """Joint-local scales of all affected joints, in
|
||||
16 bit precision. Array length should match the size of the *joints*
|
||||
attribute."""
|
||||
)
|
||||
float3[] translations (
|
||||
doc = """Joint-local translations of all affected joints. Array length
|
||||
should match the size of the *joints* attribute."""
|
||||
)
|
||||
}
|
||||
|
||||
class PackedJointAnimation "PackedJointAnimation" (
|
||||
doc = "Deprecated. Please use SkelAnimation instead."
|
||||
)
|
||||
{
|
||||
uniform token[] blendShapes (
|
||||
doc = """Array of tokens identifying which blend shapes this
|
||||
animation's data applies to. The tokens for blendShapes correspond to
|
||||
the tokens set in the *skel:blendShapes* binding property of the
|
||||
UsdSkelBindingAPI."""
|
||||
)
|
||||
float[] blendShapeWeights (
|
||||
doc = """Array of weight values for each blend shape. Each weight value
|
||||
is associated with the corresponding blend shape identified within the
|
||||
*blendShapes* token array, and therefore must have the same length as
|
||||
*blendShapes."""
|
||||
)
|
||||
uniform token[] joints (
|
||||
doc = """Array of tokens identifying which joints this animation's
|
||||
data applies to. The tokens for joints correspond to the tokens of
|
||||
Skeleton primitives. The order of the joints as listed here may
|
||||
vary from the order of joints on the Skeleton itself."""
|
||||
)
|
||||
quatf[] rotations (
|
||||
doc = """Joint-local unit quaternion rotations of all affected joints,
|
||||
in 32-bit precision. Array length should match the size of the
|
||||
*joints* attribute."""
|
||||
)
|
||||
half3[] scales (
|
||||
doc = """Joint-local scales of all affected joints, in
|
||||
16 bit precision. Array length should match the size of the *joints*
|
||||
attribute."""
|
||||
)
|
||||
float3[] translations (
|
||||
doc = """Joint-local translations of all affected joints. Array length
|
||||
should match the size of the *joints* attribute."""
|
||||
)
|
||||
}
|
||||
|
||||
class "SkelBindingAPI" (
|
||||
doc = '''Provides API for authoring and extracting all the skinning-related
|
||||
data that lives in the "geometry hierarchy" of prims and models that want
|
||||
to be skeletally deformed.
|
||||
|
||||
See the extended "UsdSkelBindingAPI schema"
|
||||
documentation for more about bindings and how they apply in a scene graph.
|
||||
'''
|
||||
)
|
||||
{
|
||||
matrix4d primvars:skel:geomBindTransform (
|
||||
doc = '''Encodes the bind-time world space transforms of the prim.
|
||||
If the transform is identical for a group of gprims that share a common
|
||||
ancestor, the transform may be authored on the ancestor, to "inherit"
|
||||
down to all the leaf gprims. If this transform is unset, an identity
|
||||
transform is used instead.'''
|
||||
)
|
||||
int[] primvars:skel:jointIndices (
|
||||
doc = """Indices into the *joints* attribute of the closest
|
||||
(in namespace) bound Skeleton that affect each point of a PointBased
|
||||
gprim. The primvar can have either *constant* or *vertex* interpolation.
|
||||
This primvar's *elementSize* will determine how many joint influences
|
||||
apply to each point. Indices must point be valid. Null influences should
|
||||
be defined by setting values in jointWeights to zero.
|
||||
See UsdGeomPrimvar for more information on interpolation and
|
||||
elementSize."""
|
||||
)
|
||||
float[] primvars:skel:jointWeights (
|
||||
doc = """Weights for the joints that affect each point of a PointBased
|
||||
gprim. The primvar can have either *constant* or *vertex* interpolation.
|
||||
This primvar's *elementSize* will determine how many joints influences
|
||||
apply to each point. The length, interpolation, and elementSize of
|
||||
*jointWeights* must match that of *jointIndices*. See UsdGeomPrimvar
|
||||
for more information on interpolation and elementSize."""
|
||||
)
|
||||
rel skel:animationSource (
|
||||
doc = """Animation source to be bound to Skeleton primitives at or
|
||||
beneath the location at which this property is defined.
|
||||
"""
|
||||
)
|
||||
uniform token[] skel:blendShapes (
|
||||
doc = """An array of tokens defining the order onto which blend shape
|
||||
weights from an animation source map onto the *skel:blendShapeTargets*
|
||||
rel of a binding site. If authored, the number of elements must be equal
|
||||
to the number of targets in the _blendShapeTargets_ rel. This property
|
||||
is not inherited hierarchically, and is expected to be authored directly
|
||||
on the skinnable primitive to which the blend shapes apply."""
|
||||
)
|
||||
rel skel:blendShapeTargets (
|
||||
doc = """Ordered list of all target blend shapes. This property is not
|
||||
inherited hierarchically, and is expected to be authored directly on
|
||||
the skinnable primitive to which the the blend shapes apply."""
|
||||
)
|
||||
uniform token[] skel:joints (
|
||||
doc = """An (optional) array of tokens defining the list of
|
||||
joints to which jointIndices apply. If not defined, jointIndices applies
|
||||
to the ordered list of joints defined in the bound Skeleton's *joints*
|
||||
attribute. If undefined on a primitive, the primitive inherits the
|
||||
value of the nearest ancestor prim, if any."""
|
||||
)
|
||||
rel skel:skeleton (
|
||||
doc = """Skeleton to be bound to this prim and its descendents that
|
||||
possess a mapping and weighting to the joints of the identified
|
||||
Skeleton."""
|
||||
)
|
||||
}
|
||||
|
||||
class BlendShape "BlendShape" (
|
||||
doc = '''Describes a target blend shape, possibly containing inbetween
|
||||
shapes.
|
||||
|
||||
See the extended "Blend Shape Schema
|
||||
documentation for information.
|
||||
'''
|
||||
)
|
||||
{
|
||||
uniform vector3f[] normalOffsets (
|
||||
doc = """**Required property**. Normal offsets which, when added to the
|
||||
base pose, provides the normals of the target shape."""
|
||||
)
|
||||
uniform vector3f[] offsets (
|
||||
doc = """**Required property**. Position offsets which, when added to the
|
||||
base pose, provides the target shape."""
|
||||
)
|
||||
uniform int[] pointIndices (
|
||||
doc = """**Optional property**. Indices into the original mesh that
|
||||
correspond to the values in *offsets* and of any inbetween shapes. If
|
||||
authored, the number of elements must be equal to the number of elements
|
||||
in the *offsets* array."""
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# Portions of this file auto-generated by usdGenSchema.
|
||||
# Edits will survive regeneration except for comments and
|
||||
# changes to types with autoGenerated=true.
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"SdfMetadata": {
|
||||
"weight": {
|
||||
"appliesTo": [
|
||||
"attributes"
|
||||
],
|
||||
"default": 0,
|
||||
"displayGroup": "BlendShape",
|
||||
"documentation": "The weight value at which an inbeteen shape is applied.",
|
||||
"type": "float"
|
||||
}
|
||||
},
|
||||
"Types": {
|
||||
"UsdSkelAnimation": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "SkelAnimation"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdSkelBindingAPI": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "SkelBindingAPI"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdAPISchemaBase"
|
||||
],
|
||||
"schemaKind": "singleApplyAPI"
|
||||
},
|
||||
"UsdSkelBlendShape": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "BlendShape"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdTyped"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdSkelPackedJointAnimation": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "PackedJointAnimation"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdSkelAnimation"
|
||||
],
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdSkelRoot": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "SkelRoot"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomBoundable"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
},
|
||||
"UsdSkelSkeleton": {
|
||||
"alias": {
|
||||
"UsdSchemaBase": "Skeleton"
|
||||
},
|
||||
"autoGenerated": true,
|
||||
"bases": [
|
||||
"UsdGeomBoundable"
|
||||
],
|
||||
"implementsComputeExtent": true,
|
||||
"schemaKind": "concreteTyped"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdSkel.dll",
|
||||
"Name": "usdSkel",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
#usda 1.0
|
||||
(
|
||||
""" This file contains a schema for supporting skeletal animations in USD.
|
||||
"""
|
||||
subLayers = [
|
||||
@usdGeom/schema.usda@
|
||||
]
|
||||
)
|
||||
|
||||
over "GLOBAL" (
|
||||
customData = {
|
||||
string libraryName = "usdSkel"
|
||||
string libraryPath = "pxr/usd/usdSkel"
|
||||
|
||||
dictionary libraryTokens = {
|
||||
dictionary weight = {
|
||||
string doc = """UsdSkelInbetweenShape - The weight location at
|
||||
which the inbetween shape applies."""
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
class SkelRoot "SkelRoot" (
|
||||
inherits = </Boundable>
|
||||
doc = """Boundable prim type used to identify a scope beneath which
|
||||
skeletally-posed primitives are defined.
|
||||
|
||||
A SkelRoot must be defined at or above a skinned primitive for any skinning
|
||||
behaviors in UsdSkel.
|
||||
|
||||
See the extended \\ref UsdSkel_SkelRoot "Skel Root Schema" documentation for
|
||||
more information."""
|
||||
customData = {
|
||||
string className = "Root"
|
||||
|
||||
dictionary extraPlugInfo = {
|
||||
bool implementsComputeExtent = true
|
||||
}
|
||||
}
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
class Skeleton "Skeleton" (
|
||||
inherits = </Boundable>
|
||||
doc = """Describes a skeleton.
|
||||
|
||||
See the extended \\ref UsdSkel_Skeleton "Skeleton Schema" documentation for
|
||||
more information.
|
||||
"""
|
||||
customData = {
|
||||
dictionary extraPlugInfo = {
|
||||
bool implementsComputeExtent = true
|
||||
}
|
||||
|
||||
string extraIncludes = """
|
||||
#include "pxr/usd/usdSkel/topology.h" """
|
||||
}
|
||||
) {
|
||||
uniform token[] joints (
|
||||
doc = """An array of path tokens identifying the set of joints that make
|
||||
up the skeleton, and their order. Each token in the array must be valid
|
||||
when parsed as an SdfPath. The parent-child relationships of the
|
||||
corresponding paths determine the parent-child relationships of each
|
||||
joint. It is not required that the name at the end of each path be
|
||||
unique, but rather only that the paths themselves be unique."""
|
||||
)
|
||||
|
||||
uniform token[] jointNames (
|
||||
doc = """If authored, provides a unique name per joint. This may be
|
||||
optionally set to provide better names when translating to DCC apps
|
||||
that require unique joint names."""
|
||||
)
|
||||
|
||||
uniform matrix4d[] bindTransforms (
|
||||
doc = """Specifies the bind-pose transforms of each joint in
|
||||
**world space**, in the ordering imposed by *joints*."""
|
||||
)
|
||||
uniform matrix4d[] restTransforms (
|
||||
doc = """Specifies the rest-pose transforms of each joint in
|
||||
**local space**, in the ordering imposed by *joints*. This provides
|
||||
fallback values for joint transforms when a Skeleton either has no
|
||||
bound animation source, or when that animation source only contains
|
||||
animation for a subset of a Skeleton's joints."""
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
class SkelAnimation "SkelAnimation" (
|
||||
inherits = </Typed>
|
||||
doc = """Describes a skel animation, where joint animation is stored in a
|
||||
vectorized form.
|
||||
|
||||
See the extended \\ref UsdSkel_SkelAnimation "Skel Animation"
|
||||
documentation for more information.
|
||||
"""
|
||||
customData = {
|
||||
string className = "Animation"
|
||||
}
|
||||
) {
|
||||
uniform token[] joints (
|
||||
doc = """Array of tokens identifying which joints this animation's
|
||||
data applies to. The tokens for joints correspond to the tokens of
|
||||
Skeleton primitives. The order of the joints as listed here may
|
||||
vary from the order of joints on the Skeleton itself."""
|
||||
)
|
||||
|
||||
float3[] translations (
|
||||
doc = """Joint-local translations of all affected joints. Array length
|
||||
should match the size of the *joints* attribute."""
|
||||
)
|
||||
|
||||
quatf[] rotations (
|
||||
doc = """Joint-local unit quaternion rotations of all affected joints,
|
||||
in 32-bit precision. Array length should match the size of the
|
||||
*joints* attribute."""
|
||||
)
|
||||
|
||||
half3[] scales (
|
||||
doc = """Joint-local scales of all affected joints, in
|
||||
16 bit precision. Array length should match the size of the *joints*
|
||||
attribute."""
|
||||
)
|
||||
|
||||
uniform token[] blendShapes (
|
||||
doc = """Array of tokens identifying which blend shapes this
|
||||
animation's data applies to. The tokens for blendShapes correspond to
|
||||
the tokens set in the *skel:blendShapes* binding property of the
|
||||
UsdSkelBindingAPI."""
|
||||
)
|
||||
|
||||
float[] blendShapeWeights (
|
||||
doc = """Array of weight values for each blend shape. Each weight value
|
||||
is associated with the corresponding blend shape identified within the
|
||||
*blendShapes* token array, and therefore must have the same length as
|
||||
*blendShapes."""
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
class PackedJointAnimation "PackedJointAnimation" (
|
||||
inherits = </SkelAnimation>
|
||||
doc = """Deprecated. Please use SkelAnimation instead."""
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
class "SkelBindingAPI" (
|
||||
inherits = </APISchemaBase>
|
||||
doc = """Provides API for authoring and extracting all the skinning-related
|
||||
data that lives in the "geometry hierarchy" of prims and models that want
|
||||
to be skeletally deformed.
|
||||
|
||||
See the extended \\ref UsdSkel_BindingAPI "UsdSkelBindingAPI schema"
|
||||
documentation for more about bindings and how they apply in a scene graph.
|
||||
"""
|
||||
customData = {
|
||||
string className = "BindingAPI"
|
||||
string extraIncludes = """
|
||||
#include "pxr/base/tf/span.h"
|
||||
#include "pxr/usd/usdGeom/primvar.h"
|
||||
#include "pxr/usd/usdSkel/skeleton.h" """
|
||||
}
|
||||
)
|
||||
{
|
||||
rel skel:animationSource (
|
||||
customData = {
|
||||
string apiName = "animationSource"
|
||||
}
|
||||
doc = """Animation source to be bound to Skeleton primitives at or
|
||||
beneath the location at which this property is defined.
|
||||
"""
|
||||
)
|
||||
|
||||
rel skel:skeleton (
|
||||
customData = {
|
||||
string apiName = "skeleton"
|
||||
}
|
||||
doc = """Skeleton to be bound to this prim and its descendents that
|
||||
possess a mapping and weighting to the joints of the identified
|
||||
Skeleton."""
|
||||
)
|
||||
|
||||
matrix4d primvars:skel:geomBindTransform (
|
||||
customData = {
|
||||
string apiName = "geomBindTransform"
|
||||
}
|
||||
doc = """Encodes the bind-time world space transforms of the prim.
|
||||
If the transform is identical for a group of gprims that share a common
|
||||
ancestor, the transform may be authored on the ancestor, to "inherit"
|
||||
down to all the leaf gprims. If this transform is unset, an identity
|
||||
transform is used instead."""
|
||||
)
|
||||
|
||||
uniform token[] skel:joints (
|
||||
customData = {
|
||||
string apiName = "joints"
|
||||
}
|
||||
doc = """An (optional) array of tokens defining the list of
|
||||
joints to which jointIndices apply. If not defined, jointIndices applies
|
||||
to the ordered list of joints defined in the bound Skeleton's *joints*
|
||||
attribute. If undefined on a primitive, the primitive inherits the
|
||||
value of the nearest ancestor prim, if any."""
|
||||
)
|
||||
|
||||
int[] primvars:skel:jointIndices (
|
||||
customData = {
|
||||
string apiName = "jointIndices"
|
||||
}
|
||||
doc = """Indices into the *joints* attribute of the closest
|
||||
(in namespace) bound Skeleton that affect each point of a PointBased
|
||||
gprim. The primvar can have either *constant* or *vertex* interpolation.
|
||||
This primvar's *elementSize* will determine how many joint influences
|
||||
apply to each point. Indices must point be valid. Null influences should
|
||||
be defined by setting values in jointWeights to zero.
|
||||
See UsdGeomPrimvar for more information on interpolation and
|
||||
elementSize."""
|
||||
)
|
||||
|
||||
float[] primvars:skel:jointWeights (
|
||||
customData = {
|
||||
string apiName = "jointWeights"
|
||||
}
|
||||
doc = """Weights for the joints that affect each point of a PointBased
|
||||
gprim. The primvar can have either *constant* or *vertex* interpolation.
|
||||
This primvar's *elementSize* will determine how many joints influences
|
||||
apply to each point. The length, interpolation, and elementSize of
|
||||
*jointWeights* must match that of *jointIndices*. See UsdGeomPrimvar
|
||||
for more information on interpolation and elementSize."""
|
||||
)
|
||||
|
||||
uniform token[] skel:blendShapes (
|
||||
customData = {
|
||||
string apiName = "blendShapes"
|
||||
}
|
||||
doc = """An array of tokens defining the order onto which blend shape
|
||||
weights from an animation source map onto the *skel:blendShapeTargets*
|
||||
rel of a binding site. If authored, the number of elements must be equal
|
||||
to the number of targets in the _blendShapeTargets_ rel. This property
|
||||
is not inherited hierarchically, and is expected to be authored directly
|
||||
on the skinnable primitive to which the blend shapes apply."""
|
||||
)
|
||||
rel skel:blendShapeTargets (
|
||||
customData = {
|
||||
string apiName= "blendShapeTargets"
|
||||
}
|
||||
doc = """Ordered list of all target blend shapes. This property is not
|
||||
inherited hierarchically, and is expected to be authored directly on
|
||||
the skinnable primitive to which the the blend shapes apply."""
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
class BlendShape "BlendShape" (
|
||||
inherits = </Typed>
|
||||
doc = """Describes a target blend shape, possibly containing inbetween
|
||||
shapes.
|
||||
|
||||
See the extended \\ref UsdSkel_BlendShape "Blend Shape Schema
|
||||
documentation for information.
|
||||
"""
|
||||
customData = {
|
||||
string extraIncludes = """
|
||||
#include "pxr/base/tf/span.h"
|
||||
#include "pxr/usd/usdSkel/inbetweenShape.h" """
|
||||
}
|
||||
)
|
||||
{
|
||||
uniform vector3f[] offsets (
|
||||
doc = """**Required property**. Position offsets which, when added to the
|
||||
base pose, provides the target shape."""
|
||||
)
|
||||
|
||||
uniform vector3f[] normalOffsets (
|
||||
doc = """**Required property**. Normal offsets which, when added to the
|
||||
base pose, provides the normals of the target shape."""
|
||||
)
|
||||
|
||||
uniform int[] pointIndices (
|
||||
doc = """**Optional property**. Indices into the original mesh that
|
||||
correspond to the values in *offsets* and of any inbetween shapes. If
|
||||
authored, the number of elements must be equal to the number of elements
|
||||
in the *offsets* array."""
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Plugins": [
|
||||
{
|
||||
"Info": {
|
||||
"Types": {
|
||||
"UsdSkelImagingSkeletonAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingPrimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "Skeleton"
|
||||
},
|
||||
"UsdSkelImagingSkelRootAdapter": {
|
||||
"bases": [
|
||||
"UsdImagingPrimAdapter"
|
||||
],
|
||||
"isInternal": true,
|
||||
"primTypeName": "SkelRoot"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibraryPath": "../../usd_usdSkelImaging.dll",
|
||||
"Name": "usdSkelImaging",
|
||||
"ResourcePath": "resources",
|
||||
"Root": "..",
|
||||
"Type": "library"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
-- glslfx version 0.1
|
||||
|
||||
-- configuration
|
||||
{
|
||||
"techniques": {
|
||||
"default": {
|
||||
"skinPointsLBSKernel": {
|
||||
"source": [ "Compute.SkinPointsLBS" ]
|
||||
},
|
||||
"skinPointsSimpleKernel": {
|
||||
"source": [ "Compute.SkinPointsSimple" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- glsl Compute.SkinPointsLBS
|
||||
|
||||
const float EPS = 1e-5;
|
||||
|
||||
void compute(int index)
|
||||
{
|
||||
// model space -> bind space
|
||||
mat4 geomBindXform = HdGet_geomBindXform();
|
||||
|
||||
vec3 restP = HdGet_restPoints(index);
|
||||
|
||||
// apply blend shapes
|
||||
int numBlendShapeOffsetRanges = HdGet_numBlendShapeOffsetRanges();
|
||||
if (index < numBlendShapeOffsetRanges) {
|
||||
ivec2 blendShapeOffsetRange = HdGet_blendShapeOffsetRanges(index);
|
||||
for (int i = blendShapeOffsetRange.x; i < blendShapeOffsetRange.y; ++i) {
|
||||
vec4 offset = HdGet_blendShapeOffsets(i);
|
||||
int shapeIndex = int(offset.w);
|
||||
float weight = HdGet_blendShapeWeights(shapeIndex);
|
||||
restP += offset.xyz * weight;
|
||||
}
|
||||
}
|
||||
vec4 initP = geomBindXform * vec4(restP, 1);
|
||||
|
||||
int numInfluencesPerComponent = HdGet_numInfluencesPerComponent();
|
||||
vec3 p;
|
||||
if (numInfluencesPerComponent > 0) {
|
||||
p = vec3(0,0,0);
|
||||
|
||||
bool constantPointInfluence = HdGet_hasConstantInfluences();
|
||||
int offset = constantPointInfluence? 0 : numInfluencesPerComponent*index;
|
||||
|
||||
for (int i = 0; i < numInfluencesPerComponent; i++) {
|
||||
vec2 influence = HdGet_influences(offset + i);
|
||||
float jointWeight = influence.y;
|
||||
|
||||
if (jointWeight > EPS) {
|
||||
int jointIdx = int( influence.x );
|
||||
mat4 skinningXform = HdGet_skinningXforms(jointIdx);
|
||||
|
||||
p += ((skinningXform * initP) * jointWeight).xyz;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p = initP.xyz;
|
||||
}
|
||||
|
||||
// skel space -> world space -> model space
|
||||
// XXX: Casts to mat4 below are necessary because the matrices passed
|
||||
// down use doubles and not floats.
|
||||
mat4 skelToPrimLocal = mat4( HdGet_primWorldToLocal() ) *
|
||||
mat4( HdGet_skelLocalToWorld() );
|
||||
p = (skelToPrimLocal * vec4(p,1)).xyz;
|
||||
|
||||
HdSet_skinnedPoints(index, p);
|
||||
}
|
||||
|
||||
|
||||
-- glsl Compute.SkinPointsSimple
|
||||
|
||||
void compute(int index)
|
||||
{
|
||||
// This is simple joint-constraint skinning model.
|
||||
|
||||
mat4 geomBindXform = HdGet_geomBindXform();
|
||||
int jointIndex = int( HdGet_influences(index).x );
|
||||
mat4 skinningXform = HdGet_skinningXforms(jointIndex);
|
||||
|
||||
// model space -> bind space -> skel space
|
||||
vec4 p = skinningXform * geomBindXform * vec4(HdGet_restPoints(index), 1);
|
||||
|
||||
// skel space -> world space -> model space
|
||||
// XXX: Casts to mat4 below are necessary because the matrices passed
|
||||
// down use doubles and not floats.
|
||||
mat4 skelToPrimLocal = mat4( HdGet_primWorldToLocal() ) *
|
||||
mat4( HdGet_skelLocalToWorld() );
|
||||
p = skelToPrimLocal * p;
|
||||
|
||||
HdSet_skinnedPoints(index, p.xyz);
|
||||
}
|
||||
Loaded 100 of 15684 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user