Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarMaterialRenderProfile.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-06-02 22:37:52 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-06-02 22:37:52 +1000
commitadd17da988f4518c451abc4d0bacf536071e1c0b (patch)
tree86e1db5f276269e41f93d9f6e198186d2d95fa26 /source/game/StarMaterialRenderProfile.cpp
parent68bd850fe73819c75841c5b6147255caf16c6ed9 (diff)
directive-based color variants for materials
Diffstat (limited to 'source/game/StarMaterialRenderProfile.cpp')
-rw-r--r--source/game/StarMaterialRenderProfile.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/game/StarMaterialRenderProfile.cpp b/source/game/StarMaterialRenderProfile.cpp
index 975e7fa..1272e83 100644
--- a/source/game/StarMaterialRenderProfile.cpp
+++ b/source/game/StarMaterialRenderProfile.cpp
@@ -80,7 +80,9 @@ 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.multiColor = spec.getBool("multiColored", false);
+ profile.colorVariants = spec.getBool("multiColored", false) ? spec.getUInt("colorVariants", MaxMaterialColorVariant) : 0;
+ for (auto& entry : spec.getArray("colorDirectives", JsonArray()))
+ profile.colorDirectives.append(entry.toString());
profile.occludesBehind = spec.getBool("occludesBelow", true);
profile.zLevel = spec.getUInt("zLevel", 0);
profile.radiantLight = Color::rgb(jsonToVec3B(spec.get("radiantLight", JsonArray{0, 0, 0}))).toRgbF();
@@ -126,8 +128,8 @@ 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.multiColor) {
- for (MaterialColorVariant c = 0; c <= MaxMaterialColorVariant; ++c) {
+ 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));
}