Add normal, metallic, smoothness to proc gen

This commit is contained in:
xen-42 2025-02-15 01:54:11 -05:00
parent b76623edb1
commit 0f259e1ccd
2 changed files with 49 additions and 6 deletions

View File

@ -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;
}

View File

@ -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;
/// <summary>
/// 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.
/// </summary>
public Material material;
/// <summary>
/// Can use a custom texture. Does not work with material or color.
/// </summary>
public string texturePath;
public string texture;
/// <summary>
/// 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.
/// </summary>
public string smoothnessMap;
/// <summary>
/// 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.
/// </summary>
[Range(0f, 1f)]
[DefaultValue(0f)]
public float smoothness = 0f;
/// <summary>
/// How metallic the surface is, from 0 to 1.
/// Multiplies with the red of the smoothness map if using one.
/// </summary>
[Range(0f, 1f)]
[DefaultValue(0f)]
public float metallic = 0f;
/// <summary>
/// Relative filepath to the texture used for the normal (aka bump) map. Optional.
/// </summary>
public string normalMap;
/// <summary>
/// Strength of the normal map. Usually 0-1, but can go above, or negative to invert the map.
/// </summary>
[DefaultValue(1f)]
public float normalStrength = 1f;
[JsonConverter(typeof(StringEnumConverter))]
public enum Material