Skip to content

Commit

Permalink
Merge branch 'main' into curl-reserve
Browse files Browse the repository at this point in the history
  • Loading branch information
weegeekps authored Oct 20, 2023
2 parents 3994b05 + 12fcea0 commit 1f34c22
Show file tree
Hide file tree
Showing 20 changed files with 375 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ def _customize_props_layout(self, props):
with CustomLayoutGroup("Source"):
CustomLayoutProperty("cesium:ionAssetId")
CustomLayoutProperty("cesium:ionAccessToken")
with CustomLayoutGroup("Rendering"):
CustomLayoutProperty("cesium:alpha")

return frame.apply(props)
60 changes: 44 additions & 16 deletions exts/cesium.omniverse/mdl/cesium.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,34 @@ float4 compute_base_color(

export gltf_texture_lookup_value cesium_internal_texture_lookup(*) [[ anno::hidden() ]] = gltf_texture_lookup();

export gltf_texture_lookup_value cesium_internal_imagery_layer_lookup(
uniform float alpha = 1.0,
// gltf_texture_lookup inputs below
uniform texture_2d texture = texture_2d(),
uniform int tex_coord_index = 0,
uniform float2 offset = float2(0.0, 0.0),
uniform float rotation = 0.0,
uniform float2 scale = float2(1.0, 1.0),
uniform gltf_wrapping_mode wrap_s = repeat,
uniform gltf_wrapping_mode wrap_t = repeat
) [[ anno::hidden() ]] {
auto imagery_layer = gltf_texture_lookup(
texture: texture,
tex_coord_index: tex_coord_index,
offset: offset,
rotation: rotation,
scale: scale,
wrap_s: wrap_s,
wrap_t: wrap_t
);

if (imagery_layer.valid) {
imagery_layer.value.w *= alpha;
}

return imagery_layer;
}

export material cesium_internal_material(
gltf_texture_lookup_value imagery_layers_texture = gltf_texture_lookup_value(true, float4(0.0)),
uniform color debug_color = color(1.0),
Expand Down Expand Up @@ -175,22 +203,22 @@ export material cesium_internal_material(

export gltf_texture_lookup_value cesium_internal_imagery_layer_resolver(
uniform int imagery_layers_count = 0,
gltf_texture_lookup_value imagery_layer_0 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_1 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_2 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_3 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_4 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_5 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_6 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_7 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_8 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_9 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_10 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_11 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_12 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_13 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_14 = gltf_texture_lookup(),
gltf_texture_lookup_value imagery_layer_15 = gltf_texture_lookup()
gltf_texture_lookup_value imagery_layer_0 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_1 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_2 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_3 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_4 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_5 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_6 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_7 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_8 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_9 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_10 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_11 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_12 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_13 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_14 = gltf_texture_lookup_value(),
gltf_texture_lookup_value imagery_layer_15 = gltf_texture_lookup_value()
) [[ anno::hidden() ]] {
// The array length should match MAX_IMAGERY_LAYERS_COUNT in Tokens.h
gltf_texture_lookup_value[16] imagery_layers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class Data(pxr.Usd.Typed):
def CreateProjectDefaultIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateProjectDefaultIonAccessTokenIdAttr(cls, *args, **kwargs) -> Any: ...
def Define(self, *args, **kwargs) -> Any: ...
def Get(self, *args, **kwargs) -> Any: ...
@classmethod
def Define(cls, *args, **kwargs) -> Any: ...
@classmethod
def Get(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetDebugDisableGeometryPoolAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
Expand All @@ -60,10 +62,12 @@ class Data(pxr.Usd.Typed):
def GetProjectDefaultIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetProjectDefaultIonAccessTokenIdAttr(cls, *args, **kwargs) -> Any: ...
def GetSchemaAttributeNames(self, *args, **kwargs) -> Any: ...
def _GetStaticTfType(self, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> Any: ...
def GetSchemaAttributeNames(cls, *args, **kwargs) -> Any: ...
@classmethod
def _GetStaticTfType(cls, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> bool: ...
@classmethod
def __reduce__(cls) -> Any: ...

Expand All @@ -77,27 +81,33 @@ class Georeference(pxr.Usd.Typed):
def CreateGeoreferenceOriginLatitudeAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateGeoreferenceOriginLongitudeAttr(cls, *args, **kwargs) -> Any: ...
def Define(self, *args, **kwargs) -> Any: ...
def Get(self, *args, **kwargs) -> Any: ...
@classmethod
def Define(cls, *args, **kwargs) -> Any: ...
@classmethod
def Get(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetGeoreferenceOriginHeightAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetGeoreferenceOriginLatitudeAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetGeoreferenceOriginLongitudeAttr(cls, *args, **kwargs) -> Any: ...
def GetSchemaAttributeNames(self, *args, **kwargs) -> Any: ...
def _GetStaticTfType(self, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> Any: ...
def GetSchemaAttributeNames(cls, *args, **kwargs) -> Any: ...
@classmethod
def _GetStaticTfType(cls, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> bool: ...
@classmethod
def __reduce__(cls) -> Any: ...

class GlobeAnchorAPI(pxr.Usd.APISchemaBase):
__instance_size__: ClassVar[int] = ...
@classmethod
def __init__(cls, *args, **kwargs) -> None: ...
def Apply(self, *args, **kwargs) -> Any: ...
def CanApply(self, *args, **kwargs) -> Any: ...
@classmethod
def Apply(cls, *args, **kwargs) -> Any: ...
@classmethod
def CanApply(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateAdjustOrientationForGlobeWhenMovingAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
Expand All @@ -112,7 +122,8 @@ class GlobeAnchorAPI(pxr.Usd.APISchemaBase):
def CreateRotationAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateScaleAttr(cls, *args, **kwargs) -> Any: ...
def Get(self, *args, **kwargs) -> Any: ...
@classmethod
def Get(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetAdjustOrientationForGlobeWhenMovingAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
Expand All @@ -127,10 +138,12 @@ class GlobeAnchorAPI(pxr.Usd.APISchemaBase):
def GetRotationAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetScaleAttr(cls, *args, **kwargs) -> Any: ...
def GetSchemaAttributeNames(self, *args, **kwargs) -> Any: ...
def _GetStaticTfType(self, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> Any: ...
def GetSchemaAttributeNames(cls, *args, **kwargs) -> Any: ...
@classmethod
def _GetStaticTfType(cls, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> bool: ...
@classmethod
def __reduce__(cls) -> Any: ...

Expand All @@ -139,23 +152,31 @@ class Imagery(pxr.Usd.Typed):
@classmethod
def __init__(cls, *args, **kwargs) -> None: ...
@classmethod
def CreateAlphaAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateIonAssetIdAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateShowCreditsOnScreenAttr(cls, *args, **kwargs) -> Any: ...
def Define(self, *args, **kwargs) -> Any: ...
def Get(self, *args, **kwargs) -> Any: ...
@classmethod
def Define(cls, *args, **kwargs) -> Any: ...
@classmethod
def Get(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetAlphaAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetIonAssetIdAttr(cls, *args, **kwargs) -> Any: ...
def GetSchemaAttributeNames(self, *args, **kwargs) -> Any: ...
@classmethod
def GetSchemaAttributeNames(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetShowCreditsOnScreenAttr(cls, *args, **kwargs) -> Any: ...
def _GetStaticTfType(self, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> Any: ...
def _GetStaticTfType(cls, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> bool: ...
@classmethod
def __reduce__(cls) -> Any: ...

Expand All @@ -165,14 +186,18 @@ class Session(pxr.Usd.Typed):
def __init__(cls, *args, **kwargs) -> None: ...
@classmethod
def CreateEcefToUsdTransformAttr(cls, *args, **kwargs) -> Any: ...
def Define(self, *args, **kwargs) -> Any: ...
def Get(self, *args, **kwargs) -> Any: ...
@classmethod
def Define(cls, *args, **kwargs) -> Any: ...
@classmethod
def Get(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetEcefToUsdTransformAttr(cls, *args, **kwargs) -> Any: ...
def GetSchemaAttributeNames(self, *args, **kwargs) -> Any: ...
def _GetStaticTfType(self, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> Any: ...
def GetSchemaAttributeNames(cls, *args, **kwargs) -> Any: ...
@classmethod
def _GetStaticTfType(cls, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> bool: ...
@classmethod
def __reduce__(cls) -> Any: ...

Expand Down Expand Up @@ -220,8 +245,10 @@ class Tileset(pxr.UsdGeom.Gprim):
def CreateSuspendUpdateAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateUrlAttr(cls, *args, **kwargs) -> Any: ...
def Define(self, *args, **kwargs) -> Any: ...
def Get(self, *args, **kwargs) -> Any: ...
@classmethod
def Define(cls, *args, **kwargs) -> Any: ...
@classmethod
def Get(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetCulledScreenSpaceErrorAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
Expand Down Expand Up @@ -252,7 +279,8 @@ class Tileset(pxr.UsdGeom.Gprim):
def GetPreloadAncestorsAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetPreloadSiblingsAttr(cls, *args, **kwargs) -> Any: ...
def GetSchemaAttributeNames(self, *args, **kwargs) -> Any: ...
@classmethod
def GetSchemaAttributeNames(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetShowCreditsOnScreenAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
Expand All @@ -263,9 +291,10 @@ class Tileset(pxr.UsdGeom.Gprim):
def GetSuspendUpdateAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetUrlAttr(cls, *args, **kwargs) -> Any: ...
def _GetStaticTfType(self, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> Any: ...
def _GetStaticTfType(cls, *args, **kwargs) -> Any: ...
@classmethod
def __bool__(cls) -> bool: ...
@classmethod
def __reduce__(cls) -> Any: ...

Expand All @@ -275,6 +304,8 @@ class Tokens(Boost.Python.instance):
@classmethod
def __reduce__(cls) -> Any: ...
@property
def cesiumAlpha(self) -> Any: ...
@property
def cesiumAnchorAdjustOrientationForGlobeWhenMoving(self) -> Any: ...
@property
def cesiumAnchorDetectTransformChanges(self) -> Any: ...
Expand Down Expand Up @@ -370,13 +401,13 @@ class _CanApplyResult(Boost.Python.instance):
@classmethod
def __init__(cls, *args, **kwargs) -> None: ...
@classmethod
def __bool__(cls) -> Any: ...
def __bool__(cls) -> bool: ...
@classmethod
def __eq__(cls, other) -> Any: ...
def __eq__(cls, other) -> bool: ...
@classmethod
def __getitem__(cls, index) -> Any: ...
@classmethod
def __ne__(cls, other) -> Any: ...
def __ne__(cls, other) -> bool: ...
@classmethod
def __reduce__(cls) -> Any: ...
@property
Expand Down
8 changes: 8 additions & 0 deletions exts/cesium.usd.plugins/schemas/cesium_schemas.usda
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ class CesiumImageryPrim "CesiumImageryPrim" (
displayName = "Show Credits On Screen"
doc = "Whether or not to show this imagery layer's credits on screen."
)

float cesium:alpha = 1.0 (
customData = {
string apiName = "alpha"
}
displayName = "Alpha"
doc = "The alpha blending value, from 0.0 to 1.0, where 1.0 is fully opaque."
)
}

class "CesiumGlobeAnchorSchemaAPI" (
Expand Down
27 changes: 26 additions & 1 deletion src/core/include/cesium/omniverse/FabricMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class FabricMaterial {
const pxr::TfToken& textureAssetPathToken,
const TextureInfo& textureInfo,
uint64_t texcoordIndex,
uint64_t imageryLayerIndex);
uint64_t imageryLayerIndex,
float alpha);
void setImageryLayerAlpha(uint64_t imageryLayerIndex, float alpha);

void clearMaterial();
void clearBaseColorTexture();
Expand All @@ -52,22 +54,45 @@ class FabricMaterial {

void createMaterial(const omni::fabric::Path& materialPath);
void createShader(const omni::fabric::Path& shaderPath, const omni::fabric::Path& materialPath);
void createTextureCommon(
const omni::fabric::Path& texturePath,
const omni::fabric::Path& shaderPath,
const omni::fabric::Token& shaderInput,
const omni::fabric::Token& subIdentifier,
const std::vector<std::pair<omni::fabric::Type, omni::fabric::Token>>& additionalAttributes = {});
void createTexture(
const omni::fabric::Path& texturePath,
const omni::fabric::Path& shaderPath,
const omni::fabric::Token& shaderInput);
void createImageryLayer(
const omni::fabric::Path& imageryLayerPath,
const omni::fabric::Path& shaderPath,
const omni::fabric::Token& shaderInput);
void createImageryLayerResolver(
const omni::fabric::Path& imageryLayerResolverPath,
const omni::fabric::Path& shaderPath,
const omni::fabric::Token& shaderInput,
uint64_t textureCount);
void reset();
void setShaderValues(const omni::fabric::Path& shaderPath, const MaterialInfo& materialInfo);
void setTextureValuesCommon(
const omni::fabric::Path& texturePath,
const pxr::TfToken& textureAssetPathToken,
const TextureInfo& textureInfo,
uint64_t texcoordIndex);
void setTextureValues(
const omni::fabric::Path& texturePath,
const pxr::TfToken& textureAssetPathToken,
const TextureInfo& textureInfo,
uint64_t texcoordIndex);
void setImageryLayerValues(
const omni::fabric::Path& imageryLayerPath,
const pxr::TfToken& textureAssetPathToken,
const TextureInfo& textureInfo,
uint64_t texcoordIndex,
float alpha);
void setImageryLayerAlphaValue(const omni::fabric::Path& imageryLayerPath, float alpha);

bool stageDestroyed();

omni::fabric::Path _materialPath;
Expand Down
1 change: 1 addition & 0 deletions src/core/include/cesium/omniverse/OmniImagery.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class OmniImagery {
[[nodiscard]] int64_t getIonAssetId() const;
[[nodiscard]] std::optional<CesiumIonClient::Token> getIonAccessToken() const;
[[nodiscard]] bool getShowCreditsOnScreen() const;
[[nodiscard]] float getAlpha() const;

private:
pxr::SdfPath _path;
Expand Down
4 changes: 4 additions & 0 deletions src/core/include/cesium/omniverse/OmniTileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ class OmniTileset {
void addImageryIon(const pxr::SdfPath& imageryPath);
[[nodiscard]] std::optional<uint64_t>
findImageryLayerIndex(const Cesium3DTilesSelection::RasterOverlay& overlay) const;
[[nodiscard]] std::optional<uint64_t> findImageryLayerIndex(const pxr::SdfPath& imageryPath) const;
[[nodiscard]] uint64_t getImageryLayerCount() const;
float getImageryLayerAlpha(uint64_t imageryLayerIndex) const;
void updateImageryLayerAlpha(uint64_t imageryLayerIndex);
void onUpdateFrame(const std::vector<Viewport>& viewports);

private:
Expand All @@ -94,5 +97,6 @@ class OmniTileset {
std::vector<Cesium3DTilesSelection::ViewState> _viewStates;
bool _extentSet = false;
bool _activeLoading{false};
std::vector<pxr::SdfPath> _imageryPaths;
};
} // namespace cesium::omniverse
Loading

0 comments on commit 1f34c22

Please sign in to comment.