diff --git a/source/game/StarMaterialRenderProfile.cpp b/source/game/StarMaterialRenderProfile.cpp index 1272e83..f25913d 100644 --- a/source/game/StarMaterialRenderProfile.cpp +++ b/source/game/StarMaterialRenderProfile.cpp @@ -80,7 +80,7 @@ MaterialRenderProfile parseMaterialRenderProfile(Json const& spec, String const& bool lightTransparent = spec.getBool("lightTransparent", false); profile.foregroundLightTransparent = spec.getBool("foregroundLightTransparent", lightTransparent); profile.backgroundLightTransparent = spec.getBool("backgroundLightTransparent", lightTransparent); - profile.colorVariants = spec.getBool("multiColored", false) ? spec.getUInt("colorVariants", MaxMaterialColorVariant) : 0; + profile.colorVariants = spec.getBool("multiColored", false) ? spec.getUInt("colorVariants", (uint64_t)MaxMaterialColorVariant + 1) : 0; for (auto& entry : spec.getArray("colorDirectives", JsonArray())) profile.colorDirectives.append(entry.toString()); profile.occludesBehind = spec.getBool("occludesBelow", true); @@ -128,14 +128,12 @@ MaterialRenderProfile parseMaterialRenderProfile(Json const& spec, String const& auto flipTextureCoordinates = [imageHeight]( RectF const& rect) { return RectF::withSize(Vec2F(rect.xMin(), imageHeight - rect.yMax()), rect.size()); }; for (unsigned v = 0; v < variants; ++v) { - if (profile.colorVariants > 0) { - for (MaterialColorVariant c = 0; c <= profile.colorVariants; ++c) { - RectF textureRect = RectF::withSize(texturePosition + variantStride * v + colorStride * c, textureSize); - renderPiece->variants[c].append(flipTextureCoordinates(textureRect)); - } - } else { - RectF textureRect = RectF::withSize(texturePosition + variantStride * v, textureSize); - renderPiece->variants[DefaultMaterialColorVariant].append(flipTextureCoordinates(textureRect)); + auto i = DefaultMaterialColorVariant; + RectF textureRect = RectF::withSize(texturePosition + variantStride * v, textureSize); + renderPiece->variants[i].append(flipTextureCoordinates(textureRect)); + for (MaterialColorVariant c = 0; c != profile.colorVariants; ++c) { + RectF textureRect = RectF::withSize(texturePosition + variantStride * v + colorStride * ++i, textureSize); + renderPiece->variants[i].append(flipTextureCoordinates(textureRect)); } }