Skip to content

Commit

Permalink
Hydrogent: enabled objects without texture coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Sep 15, 2023
1 parent 225e7d5 commit 221792c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Hydrogent/src/HnMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void HnMaterial::Sync(pxr::HdSceneDelegate* SceneDelegate,
};

SetFallbackValue(HnTokens->diffuseColor, [this](const pxr::VtValue& Val) {
m_ShaderAttribs.BaseColorFactor.MakeVector(Val.Get<pxr::GfVec4f>().data());
m_ShaderAttribs.BaseColorFactor = float4{float3::MakeVector(Val.Get<pxr::GfVec3f>().data()), 1};
});
SetFallbackValue(HnTokens->metallic, [this](const pxr::VtValue& Val) {
m_ShaderAttribs.MetallicFactor = Val.Get<float>();
Expand Down
2 changes: 1 addition & 1 deletion Hydrogent/src/HnMaterialNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ HnSubTextureIdentifier GetSubtextureIdentifier(const pxr::TfToken& ParamNa
}
else if (SourceColorSpace == "auto")
{
TextureId.IsSRGB = ParamName == HnTokens->diffuseColor;
//TextureId.IsSRGB = ParamName == HnTokens->diffuseColor;
}

if (TextureType == pxr::HdTextureType::Uv)
Expand Down
15 changes: 15 additions & 0 deletions Hydrogent/src/HnMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "DebugUtilities.hpp"
#include "GraphicsTypesX.hpp"

#include "pxr/base/gf/vec2f.h"
#include "pxr/imaging/hd/meshUtil.h"
#include "pxr/imaging/hd/vtBufferSource.h"

Expand Down Expand Up @@ -226,6 +227,20 @@ void HnMesh::UpdateVertexPrims(pxr::HdSceneDelegate& SceneDelegate,
m_BufferSources.emplace(PrimDesc.name, std::move(BufferSource));
}

// Create dummy texture coordinates if they are not present
if (m_BufferSources.find(HnTokens->st0) == m_BufferSources.end())
{
pxr::VtValue DummyUVs;
DummyUVs = pxr::VtArray<pxr::GfVec2f>{static_cast<size_t>(NumPoints), pxr::GfVec2f{0}};
auto BufferSource = std::make_shared<pxr::HdVtBufferSource>(
HnTokens->st0,
DummyUVs,
1, // values per element
false // whether doubles are supported or must be converted to floats
);
m_BufferSources.emplace(HnTokens->st0, std::move(BufferSource));
}

DirtyBits &= ~pxr::HdChangeTracker::DirtyPrimvar;
}

Expand Down

0 comments on commit 221792c

Please sign in to comment.