Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
v1.0.11 December 10th, 2024
fbx:
- adjust mesh and mesh instancing setup
gltf:
- adjust mesh and mesh instancing setup
sbsar:
- add texture export
utility:
- usd v24.11 cleanup
- doc updates
- refactor utility exporting, cmake cleanup, rename files, remove extra logs


v1.0.10 November 19th, 2024
fbx:
- small fbx spot light fixes
Expand Down
2 changes: 1 addition & 1 deletion fbx/src/fbx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ governing permissions and limitations under the License.
#include "fbx.h"
#include "debugCodes.h"
#include <algorithm>
#include <common.h>
#include <fileformatutils/common.h>
#include <fbxsdk.h>
#include <fstream>
#include <pxr/base/gf/matrix3d.h>
Expand Down
2 changes: 1 addition & 1 deletion fbx/src/fbx.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ governing permissions and limitations under the License.
#include <pxr/pxr.h>
#include <sstream>
#include <string>
#include <usdData.h>
#include <fileformatutils/usdData.h>
#include <utility>


Expand Down
10 changes: 5 additions & 5 deletions fbx/src/fbxExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ governing permissions and limitations under the License.
*/
#include "fbxExport.h"
#include "debugCodes.h"
#include "layerWriteShared.h"
#include <common.h>
#include <fbxsdk.h>
#include <images.h>
#include <materials.h>
#include <usdData.h>
#include <fileformatutils/layerWriteShared.h>
#include <fileformatutils/common.h>
#include <fileformatutils/images.h>
#include <fileformatutils/materials.h>
#include <fileformatutils/usdData.h>

#include <optional>

Expand Down
2 changes: 1 addition & 1 deletion fbx/src/fbxExport.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ governing permissions and limitations under the License.
*/
#pragma once
#include "fbx.h"
#include <usdData.h>
#include <fileformatutils/usdData.h>

namespace adobe::usd {

Expand Down
8 changes: 4 additions & 4 deletions fbx/src/fbxImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ governing permissions and limitations under the License.
*/
#include "fbxImport.h"
#include "debugCodes.h"
#include <common.h>
#include <filesystem>
#include <fstream>
#include <images.h>
#include <iomanip>
#include <materials.h>
#include <fileformatutils/common.h>
#include <fileformatutils/images.h>
#include <fileformatutils/materials.h>
#include <fileformatutils/usdData.h>
#include <pxr/base/tf/fileUtils.h>
#include <pxr/base/tf/pathUtils.h>
#include <pxr/base/tf/stringUtils.h>
#include <pxr/usd/usdSkel/utils.h>
#include <usdData.h>

using namespace PXR_NS;
using namespace fbxsdk;
Expand Down
2 changes: 1 addition & 1 deletion fbx/src/fbxImport.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ governing permissions and limitations under the License.
*/
#pragma once
#include "fbx.h"
#include <usdData.h>
#include <fileformatutils/usdData.h>

namespace adobe::usd {

Expand Down
2 changes: 1 addition & 1 deletion fbx/src/fbxResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ governing permissions and limitations under the License.
#include "debugCodes.h"
#include "fbx.h"
#include "fbxImport.h"
#include <common.h>
#include <fileformatutils/common.h>
#include <mutex>
#include <pxr/base/tf/stopwatch.h>
#include <pxr/usd/ar/definePackageResolver.h>
Expand Down
2 changes: 1 addition & 1 deletion fbx/src/fbxResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/
#pragma once
#include <resolver.h>
#include <fileformatutils/resolver.h>

namespace adobe::usd {

Expand Down
10 changes: 5 additions & 5 deletions fbx/src/fileFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ governing permissions and limitations under the License.
#include "fbxExport.h"
#include "fbxImport.h"

#include <common.h>
#include <layerRead.h>
#include <layerWriteSdfData.h>
#include <resolver.h>
#include <usdData.h>
#include <fileformatutils/common.h>
#include <fileformatutils/layerRead.h>
#include <fileformatutils/layerWriteSdfData.h>
#include <fileformatutils/resolver.h>
#include <fileformatutils/usdData.h>

#include <pxr/usd/usd/usdaFileFormat.h>

Expand Down
2 changes: 1 addition & 1 deletion fbx/src/fileFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ governing permissions and limitations under the License.
#endif // _MSC_VER
#include "api.h"
#include <iosfwd>
#include <fileformatutils/sdfUtils.h>
#include <pxr/base/tf/staticTokens.h>
#include <pxr/usd/pcp/dynamicFileFormatInterface.h>
#include <pxr/usd/sdf/data.h>
#include <sdfUtils.h>
#include <string>
#include <version.h>

Expand Down
10 changes: 5 additions & 5 deletions gltf/src/fileFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ governing permissions and limitations under the License.
#include "gltfImport.h"

// utils
#include <common.h>
#include <layerRead.h>
#include <layerWriteSdfData.h>
#include <resolver.h>
#include <usdData.h>
#include <fileformatutils/common.h>
#include <fileformatutils/layerRead.h>
#include <fileformatutils/layerWriteSdfData.h>
#include <fileformatutils/resolver.h>
#include <fileformatutils/usdData.h>

// USD
#include <pxr/base/tf/pathUtils.h>
Expand Down
2 changes: 1 addition & 1 deletion gltf/src/fileFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ governing permissions and limitations under the License.
#include "api.h"
#include <version.h>

#include <sdfUtils.h>
#include <fileformatutils/sdfUtils.h>

#include <pxr/base/tf/staticTokens.h>
#include <pxr/pxr.h>
Expand Down
4 changes: 2 additions & 2 deletions gltf/src/gltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ governing permissions and limitations under the License.
*/
#include "gltf.h"
#include "debugCodes.h"
#include "neuralAssetsHelper.h"
#include <common.h>
#include <iostream>
#include <limits>
#include <fileformatutils/common.h>
#include <fileformatutils/neuralAssetsHelper.h>
#include <pxr/base/tf/fileUtils.h>
#include <pxr/base/tf/pathUtils.h>
#include <pxr/base/tf/stringUtils.h>
Expand Down
16 changes: 9 additions & 7 deletions gltf/src/gltfAnisotropy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ governing permissions and limitations under the License.
#include "debugCodes.h"
#include "gltfImport.h"
#include <cmath>
#include <common.h>
#include <iomanip>
#include <sstream>

#include <fileformatutils/common.h>

using namespace PXR_NS;

namespace adobe::usd {
Expand Down Expand Up @@ -456,7 +457,9 @@ constructAnisotropyImage(const Material& m,
roughness = static_cast<float>(roughnessImage->image[i]) / MAX_COLOR_VALUE;
}
} else {
roughness = m.roughness.value.Get<float>();
if (m.roughness.value.IsHolding<float>()) {
roughness = m.roughness.value.Get<float>();
}
}

// Set anisotropy level (blue channel)
Expand Down Expand Up @@ -491,11 +494,10 @@ exportAnisotropyExtension(ExportGltfContext& ctx,
tinygltf::ExtensionMap ext;
if (m.anisotropyLevel.value.IsHolding<float>()) {
// Use default roughness if none is available
float roughness = m.roughness.value.IsHolding<float>()
? m.roughness.value.UncheckedGet<float>()
: 0.0f;
reconstructedStrength = reverseASMLevel(
m.anisotropyLevel.value.UncheckedGet<float>(), 1.0f, roughness);
float roughness =
m.roughness.value.IsHolding<float>() ? m.roughness.value.UncheckedGet<float>() : 0.0f;
reconstructedStrength =
reverseASMLevel(m.anisotropyLevel.value.UncheckedGet<float>(), 1.0f, roughness);
addFloatValueToExt(ext, "anisotropyStrength", reconstructedStrength);
}

Expand Down
4 changes: 2 additions & 2 deletions gltf/src/gltfAnisotropy.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ governing permissions and limitations under the License.
#pragma once
#include "gltf.h"
#include "gltfExport.h"
#include "images.h"
#include "importGltfContext.h"
#include "usdData.h"
#include <fileformatutils/images.h>
#include <fileformatutils/usdData.h>
#include <unordered_map>

namespace adobe::usd {
Expand Down
8 changes: 4 additions & 4 deletions gltf/src/gltfExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ governing permissions and limitations under the License.
#include "gltfExport.h"
#include "debugCodes.h"
#include "gltfAnisotropy.h"
#include "neuralAssetsHelper.h"
#include <common.h>
#include <geometry.h>
#include <images.h>
#include <fileformatutils/common.h>
#include <fileformatutils/geometry.h>
#include <fileformatutils/images.h>
#include <fileformatutils/neuralAssetsHelper.h>
#include <pxr/base/tf/token.h>
#include <pxr/usd/ar/asset.h>
#include <pxr/usd/ar/defaultResolver.h>
Expand Down
4 changes: 2 additions & 2 deletions gltf/src/gltfExport.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ governing permissions and limitations under the License.
*/
#pragma once
#include "gltf.h"
#include "materials.h"
#include <tiny_gltf.h>
#include <usdData.h>
#include <fileformatutils/materials.h>
#include <fileformatutils/usdData.h>

namespace adobe::usd {

Expand Down
36 changes: 32 additions & 4 deletions gltf/src/gltfImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ governing permissions and limitations under the License.
#include "gltfAnisotropy.h"
#include "gltfSpecGloss.h"
#include "importGltfContext.h"
#include "neuralAssetsHelper.h"
#include <common.h>
#include <images.h>
#include <fileformatutils/common.h>
#include <fileformatutils/images.h>
#include <fileformatutils/neuralAssetsHelper.h>
#include <pxr/base/tf/pathUtils.h>
#include <pxr/base/tf/stringUtils.h>

Expand Down Expand Up @@ -1413,6 +1413,7 @@ void
importMeshes(ImportGltfContext& ctx)
{
ctx.meshes.resize(ctx.gltf->meshes.size());
ctx.meshUseCount.resize(ctx.gltf->meshes.size(), 0);
for (size_t i = 0; i < ctx.gltf->meshes.size(); i++) {
const tinygltf::Mesh& gmesh = ctx.gltf->meshes[i];
ctx.meshes[i].resize(gmesh.primitives.size());
Expand All @@ -1426,7 +1427,11 @@ importMeshes(ImportGltfContext& ctx)
auto [meshIndex, mesh] = ctx.usd->addMesh();
ctx.meshes[i][j] = meshIndex;
mesh.name = gmesh.name;
mesh.instanceable = true;
// When we have multiple GLTF primitives that we turn into meshes, we create names that
// are derived from the primitive index instead of just duplicating the name.
if (gmesh.primitives.size() > 1) {
mesh.name = mesh.name + "_primitive" + std::to_string(j);
}
int positionsIndex = getPrimitiveAttribute(primitive, "POSITION");
int normalsIndex = getPrimitiveAttribute(primitive, "NORMAL");
int tangentsIndex = getPrimitiveAttribute(primitive, "TANGENT");
Expand Down Expand Up @@ -2103,6 +2108,7 @@ importNodes(ImportGltfContext& ctx)
int usdParentIndex = (parentIndex != -1) ? ctx.nodeMap[parentIndex] : -1;
n.parent = usdParentIndex;
if (node.mesh >= 0) {
ctx.meshUseCount[node.mesh]++;
// If the node has a skin, add the mesh to the root node of the skeleton held by the
// skin.
if (node.skin >= 0) {
Expand Down Expand Up @@ -2174,6 +2180,27 @@ importNodes(ImportGltfContext& ctx)
return true;
}

void
checkMeshInstancing(ImportGltfContext& ctx)
{
// Visit all meshes and check if they are used by more than one node and if so mark them as
// instanceable
for (size_t meshIdx = 0; meshIdx < ctx.meshUseCount.size(); ++meshIdx) {
int useCount = ctx.meshUseCount[meshIdx];
if (useCount > 1) {
const std::vector<int>& meshPrimitiveIndices = ctx.meshes[meshIdx];
for (int primitiveIdx : meshPrimitiveIndices) {
ctx.usd->meshes[primitiveIdx].instanceable = true;
}
}

if (useCount == 0) {
const tinygltf::Mesh& gmesh = ctx.gltf->meshes[meshIdx];
TF_WARN("Mesh %zu (%s) appears to be unused", meshIdx, gmesh.name.c_str());
}
}
}

static const std::set<std::string> supportedExtension = {
// Ratified extensions
"KHR_draco_mesh_compression",
Expand Down Expand Up @@ -2293,6 +2320,7 @@ importGltf(const ImportGltfOptions& options,
importAnimationTracks(ctx);
importNodeAnimations(ctx);
importSkeletonAnimations(ctx);
checkMeshInstancing(ctx);
}

usd.metadata.SetValueAtPath("filenames", VtValue(ctx.filenames));
Expand Down
2 changes: 1 addition & 1 deletion gltf/src/gltfImport.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ governing permissions and limitations under the License.
#include "gltf.h"
#include "importGltfContext.h"
#include <tiny_gltf.h>
#include <usdData.h>
#include <fileformatutils/usdData.h>

namespace adobe::usd {

Expand Down
3 changes: 0 additions & 3 deletions gltf/src/gltfResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ governing permissions and limitations under the License.

#include <pxr/usd/ar/definePackageResolver.h>

// from utils
#include <resolver.h>

using namespace PXR_NS;
namespace adobe::usd {

Expand Down
2 changes: 1 addition & 1 deletion gltf/src/gltfResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/
#pragma once
#include <resolver.h>
#include <fileformatutils/resolver.h>

namespace adobe::usd {

Expand Down
4 changes: 2 additions & 2 deletions gltf/src/gltfSpecGloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ governing permissions and limitations under the License.
#include "debugCodes.h"
#include "gltfImport.h"
#include "importGltfContext.h"
#include <common.h>
#include <images.h>
#include <fileformatutils/common.h>
#include <fileformatutils/images.h>
#include <pxr/base/tf/pathUtils.h>
#include <pxr/base/tf/stringUtils.h>

Expand Down
2 changes: 1 addition & 1 deletion gltf/src/gltfSpecGloss.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ governing permissions and limitations under the License.
#pragma once
#include "gltf.h"
#include "importGltfContext.h"
#include "usdData.h"
#include <fileformatutils/usdData.h>
#include <unordered_map>


Expand Down
Loading
Loading