mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
tweak max texture resolution thresholds
This commit is contained in:
parent
8b2c720e29
commit
8b1f569132
1 changed files with 12 additions and 11 deletions
|
@ -1468,25 +1468,26 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
|
||||
// HACK: until we get proper LOD management we're going to cap model textures
|
||||
// according to how many unique textures the model uses:
|
||||
// 1 - 7 textures --> 2048
|
||||
// 8 - 31 textures --> 1024
|
||||
// 32 - 127 textures --> 512
|
||||
// 1 - 8 textures --> 2048
|
||||
// 8 - 32 textures --> 1024
|
||||
// 33 - 128 textures --> 512
|
||||
// etc...
|
||||
QSet<QString> uniqueTextures;
|
||||
for (auto& material : _fbxMaterials) {
|
||||
material.getTextureNames(uniqueTextures);
|
||||
}
|
||||
int numTextures = uniqueTextures.size();
|
||||
const int MAX_NUM_TEXTURES_AT_MAX_RESOLUTION = 7;
|
||||
const int MAX_NUM_TEXTURES_AT_MAX_RESOLUTION = 8;
|
||||
int maxWidth = sqrt(MAX_NUM_PIXELS_FOR_FBX_TEXTURE);
|
||||
if (numTextures > MAX_NUM_TEXTURES_AT_MAX_RESOLUTION) {
|
||||
int maxWidth = sqrt(MAX_NUM_PIXELS_FOR_FBX_TEXTURE + 1);
|
||||
int t = numTextures;
|
||||
t /= MAX_NUM_TEXTURES_AT_MAX_RESOLUTION;
|
||||
while (t > 0) {
|
||||
int numTextureThreshold = MAX_NUM_TEXTURES_AT_MAX_RESOLUTION;
|
||||
const int MIN_MIP_TEXTURE_WIDTH = 64;
|
||||
do {
|
||||
maxWidth /= 2;
|
||||
t /= 4;
|
||||
}
|
||||
qCDebug(modelformat) << "max square texture width =" << maxWidth << " for model" << url;
|
||||
numTextureThreshold *= 4;
|
||||
} while (numTextureThreshold < numTextures && maxWidth > MIN_MIP_TEXTURE_WIDTH);
|
||||
|
||||
qCDebug(modelformat) << "Capped square texture width =" << maxWidth << "for model" << url << "with" << numTextures << "textures";
|
||||
for (auto& material : _fbxMaterials) {
|
||||
material.setMaxNumPixelsPerTexture(maxWidth * maxWidth);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue