diff --git a/NewHorizons/Builder/Body/ProcGenBuilder.cs b/NewHorizons/Builder/Body/ProcGenBuilder.cs index 754252dc..913ea72c 100644 --- a/NewHorizons/Builder/Body/ProcGenBuilder.cs +++ b/NewHorizons/Builder/Body/ProcGenBuilder.cs @@ -62,14 +62,23 @@ namespace NewHorizons.Builder.Body material.name = planetGO.name; if (module.material == ProcGenModule.Material.Default) { - if (!string.IsNullOrEmpty(module.texturePath)) + if (!string.IsNullOrEmpty(module.texture)) { - material.SetTexture($"_BaseTileAlbedo", ImageUtilities.GetTexture(mod, module.texturePath, wrap: true)); + material.SetTexture($"_BaseTileAlbedo", ImageUtilities.GetTexture(mod, module.texture, wrap: true)); } else { material.mainTexture = ImageUtilities.MakeSolidColorTexture(1, 1, module.color?.ToColor() ?? Color.white); } + if (!string.IsNullOrEmpty(module.smoothnessMap)) + { + material.SetTexture($"_BaseTileSmoothnessMap", ImageUtilities.GetTexture(mod, module.smoothnessMap, wrap: true)); + } + if (!string.IsNullOrEmpty(module.normalMap)) + { + material.SetFloat($"_BaseTileBumpStrength", module.normalStrength); + material.SetTexture($"_BaseTileBumpMap", ImageUtilities.GetTexture(mod, module.normalMap, wrap: true)); + } } else { @@ -94,8 +103,8 @@ namespace NewHorizons.Builder.Body } } - material.SetFloat("_Smoothness", 0.1f); - material.SetFloat("_Metallic", 0.1f); + material.SetFloat("_Smoothness", module.smoothness); + material.SetFloat("_Metallic", module.metallic); _materialCache[module] = material; } diff --git a/NewHorizons/External/Modules/ProcGenModule.cs b/NewHorizons/External/Modules/ProcGenModule.cs index f96e632a..273005df 100644 --- a/NewHorizons/External/Modules/ProcGenModule.cs +++ b/NewHorizons/External/Modules/ProcGenModule.cs @@ -1,3 +1,4 @@ +using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using NewHorizons.External.SerializableData; @@ -20,14 +21,47 @@ namespace NewHorizons.External.Modules public MColor color; /// - /// Can pick a preset material with a texture from the base game. Does not work with color. + /// Can pick a preset material with a texture from the base game. Does not work with color or any textures. /// public Material material; /// /// Can use a custom texture. Does not work with material or color. /// - public string texturePath; + public string texture; + + /// + /// Relative filepath to the texture used for the terrain's smoothness and metallic, which are controlled by the texture's alpha and red channels respectively. Optional. + /// Typically black with variable transparency, when metallic isn't wanted. + /// + public string smoothnessMap; + + /// + /// How "glossy" the surface is, where 0 is diffuse, and 1 is like a mirror. + /// Multiplies with the alpha of the smoothness map if using one. + /// + [Range(0f, 1f)] + [DefaultValue(0f)] + public float smoothness = 0f; + + /// + /// How metallic the surface is, from 0 to 1. + /// Multiplies with the red of the smoothness map if using one. + /// + [Range(0f, 1f)] + [DefaultValue(0f)] + public float metallic = 0f; + + /// + /// Relative filepath to the texture used for the normal (aka bump) map. Optional. + /// + public string normalMap; + + /// + /// Strength of the normal map. Usually 0-1, but can go above, or negative to invert the map. + /// + [DefaultValue(1f)] + public float normalStrength = 1f; [JsonConverter(typeof(StringEnumConverter))] public enum Material