Skip to content

Commit

Permalink
🐛 TEX0: Automate LOD range calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
riidefi committed Jan 21, 2021
1 parent 1d7ade0 commit d10f6a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/plugins/g3d/io/TEX0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ void writeTexture(const Texture& data, oishii::Writer& writer,
writer.write<u16>(data.height);
writer.write<u32>(static_cast<u32>(data.format));
writer.write<u32>(data.mipLevel);
writer.write<f32>(data.minLod);
writer.write<f32>(data.maxLod);
writer.write<f32>(data.custom_lod ? data.minLod : 0.0f);
writer.write<f32>(data.custom_lod ? data.maxLod
: static_cast<float>(data.mipLevel - 1));
writer.write<u32>(0); // src path
writer.write<u32>(0); // user data
writer.alignTo(32); // Assumes already 32b aligned
Expand Down Expand Up @@ -48,6 +49,8 @@ void readTexture(Texture& data, oishii::BinaryReader& reader) {
data.mipLevel = reader.read<u32>();
data.minLod = reader.read<f32>();
data.maxLod = reader.read<f32>();
data.custom_lod = data.minLod != 0.0f ||
data.maxLod != static_cast<float>(data.mipLevel - 1);
data.sourcePath = readName(reader, start);
// Skip user data
reader.seekSet(start + ofsTex);
Expand Down
1 change: 1 addition & 0 deletions source/plugins/g3d/texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct TextureData {
u32 height = 32;

u32 mipLevel{1}; // 1 - no mipmaps
bool custom_lod = false;
f32 minLod{0.0f};
f32 maxLod{1.0f};

Expand Down

0 comments on commit d10f6a6

Please sign in to comment.