Skip to content

Commit

Permalink
fix primer disease, normal scales, bogie colors
Browse files Browse the repository at this point in the history
  • Loading branch information
katycat5e committed Feb 4, 2025
1 parent 24cea84 commit b25db98
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 35 deletions.
1 change: 1 addition & 0 deletions SMShared/Json/SkinConfigJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum BaseTheme
Pristine = 1,
Demonstrator = 2,
Relic = 4,
Primer = 8,

DVRT_NoDetails = 32,
Pristine_NoDetails = Pristine | DVRT_NoDetails,
Expand Down
27 changes: 2 additions & 25 deletions SkinManagerMod/SkinProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static BaseTheme GetThemeTypeByName(string themeName)
DefaultNewThemeName => BaseTheme.Pristine,
DemoThemeName => BaseTheme.Demonstrator,
DemoRustyThemeName => BaseTheme.Relic,
PrimerThemeName => BaseTheme.Primer,
_ => BaseTheme.DVRT,
};
}
Expand All @@ -58,6 +59,7 @@ public static CustomPaintTheme GetBaseTheme(BaseTheme themeType)
BaseTheme.Pristine => DefaultNewThemeName,
BaseTheme.Demonstrator => DemoThemeName,
BaseTheme.Relic => DemoRustyThemeName,
BaseTheme.Primer => PrimerThemeName,
_ => DefaultThemeName,
};

Expand Down Expand Up @@ -635,31 +637,6 @@ private static void InjectNewDefaultThemes()
_themeDict[themeName] = customDefaultTheme;
//PaintTheme.loadedThemes[themeName.ToLower()] = customDefaultTheme;
}

// primer
PaintTheme.TryLoad(PrimerThemeName, out PaintTheme defaultPrimer);

var customPrimer = ScriptableObject.CreateInstance<CustomPaintTheme>();
UnityEngine.Object.DontDestroyOnLoad(customPrimer);
customPrimer.assetName = defaultPrimer.assetName;
customPrimer.name = defaultPrimer.name;
customPrimer.nameLocalizationKey = defaultPrimer.nameLocalizationKey;
customPrimer.substitutions = defaultPrimer.substitutions;

foreach (var carType in Globals.G.Types.Liveries)
{
if (IsThemeable(carType))
{
var fakeSkin = Skin.Default(carType.id, BaseTheme.DVRT);
var carData = CarMaterialData.GetDataForCar(carType.id);

foreach (var substitution in customPrimer.substitutions
.Where(sub => carData.GetDataForMaterial(sub.original) is not null))
{

}
}
}
}

/// <summary>
Expand Down
39 changes: 29 additions & 10 deletions SkinManagerMod/TextureUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static class PropNames

public static readonly string DetailAlbedo = "_DetailAlbedoMap";
public static readonly string DetailNormal = "_DetailNormalMap";
public static readonly string DetailNormalScale = "_DetailNormalMapScale";

public static readonly string[] UniqueTextures =
{
Expand Down Expand Up @@ -307,6 +308,11 @@ public static void ApplyTextures(MeshRenderer renderer, Skin skin, CarMaterialDa
var skinTexture = skin.GetTexture(defaultTexture.TextureName)!;
renderer.material.SetTexture(defaultTexture.PropertyName, skinTexture.TextureData);

if (defaultTexture.PropertyName == PropNames.Main)
{
renderer.material.color = Color.white;
}

if (defaultTexture.PropertyName == PropNames.MetalGlossMap)
{
if (!GetMaterialTexture(renderer.material, PropNames.OcclusionMap))
Expand All @@ -317,20 +323,33 @@ public static void ApplyTextures(MeshRenderer renderer, Skin skin, CarMaterialDa
}
else
{
var skinTexture = defaultMaterial.GetTexture(defaultTexture.PropertyName);
renderer.material.SetTexture(defaultTexture.PropertyName, skinTexture);

if (!skinTexture)
if (PropNames.DetailTextures.Contains(defaultTexture.PropertyName) && skin.BaseTheme.HasFlag(BaseTheme.DVRT_NoDetails))
{
// demo bogies et al. don't have textures...
renderer.material.color = defaultMaterial.color;
renderer.material.SetTexture(defaultTexture.PropertyName, null);
}

if (defaultTexture.PropertyName == PropNames.MetalGlossMap)
else
{
if (!GetMaterialTexture(renderer.material, PropNames.OcclusionMap))
var skinTexture = defaultMaterial.GetTexture(defaultTexture.PropertyName);
renderer.material.SetTexture(defaultTexture.PropertyName, skinTexture);

if (defaultTexture.PropertyName == PropNames.DetailNormal)
{
float intensity = defaultMaterial.GetFloat(PropNames.DetailNormalScale);
renderer.material.SetFloat(PropNames.DetailNormalScale, intensity);
}

if ((defaultTexture.PropertyName == PropNames.Main) && !skinTexture)
{
// demo bogies et al. don't have textures...
renderer.material.color = defaultMaterial.color;
}

if (defaultTexture.PropertyName == PropNames.MetalGlossMap)
{
renderer.material.SetTexture(PropNames.OcclusionMap, skinTexture);
if (!GetMaterialTexture(renderer.material, PropNames.OcclusionMap))
{
renderer.material.SetTexture(PropNames.OcclusionMap, skinTexture);
}
}
}
}
Expand Down

0 comments on commit b25db98

Please sign in to comment.