Skip to content

Commit

Permalink
GLTF Loader: extend TextureShaderAttribs to support UV rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Nov 25, 2023
1 parent b50f47c commit d52f73a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions AssetLoader/interface/GLTFLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ struct Material
{
float UVSelector = -1;
float TextureSlice = 0;
float Padding0 = 0;
float Padding1 = 0;
float UBias = 0;
float VBias = 0;

float4 UVScaleBias = float4{1, 1, 0, 0};
float4 UVScaleAndRotation = float4{1, 0, 0, 1};
};
static_assert(sizeof(TextureShaderAttribs) % 16 == 0, "TextureShaderAttribs struct must be 16-byte aligned");

Expand Down
7 changes: 5 additions & 2 deletions AssetLoader/src/GLTFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,11 @@ void Model::InitMaterialTextureAddressingAttribs(Material& Mat, Uint32 TextureIn
if (Mat.GetTextureId(i) == static_cast<int>(TextureIndex))
{
Material::TextureShaderAttribs& TexAttribs{Mat.GetTextureAttrib(i)};
TexAttribs.UVScaleBias = TexInfo.pAtlasSuballocation->GetUVScaleBias();
TexAttribs.TextureSlice = static_cast<float>(TexInfo.pAtlasSuballocation->GetSlice());
const float4& UVScaleBias{TexInfo.pAtlasSuballocation->GetUVScaleBias()};
TexAttribs.UVScaleAndRotation = float4{UVScaleBias.x, 0, 0, UVScaleBias.y};
TexAttribs.UBias = UVScaleBias.z;
TexAttribs.VBias = UVScaleBias.w;
TexAttribs.TextureSlice = static_cast<float>(TexInfo.pAtlasSuballocation->GetSlice());
}
}
}
Expand Down

0 comments on commit d52f73a

Please sign in to comment.