mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add normal, metallic, smoothness to proc gen
This commit is contained in:
parent
b76623edb1
commit
0f259e1ccd
@ -62,14 +62,23 @@ namespace NewHorizons.Builder.Body
|
|||||||
material.name = planetGO.name;
|
material.name = planetGO.name;
|
||||||
if (module.material == ProcGenModule.Material.Default)
|
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
|
else
|
||||||
{
|
{
|
||||||
material.mainTexture = ImageUtilities.MakeSolidColorTexture(1, 1, module.color?.ToColor() ?? Color.white);
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -94,8 +103,8 @@ namespace NewHorizons.Builder.Body
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
material.SetFloat("_Smoothness", 0.1f);
|
material.SetFloat("_Smoothness", module.smoothness);
|
||||||
material.SetFloat("_Metallic", 0.1f);
|
material.SetFloat("_Metallic", module.metallic);
|
||||||
|
|
||||||
_materialCache[module] = material;
|
_materialCache[module] = material;
|
||||||
}
|
}
|
||||||
|
|||||||
38
NewHorizons/External/Modules/ProcGenModule.cs
vendored
38
NewHorizons/External/Modules/ProcGenModule.cs
vendored
@ -1,3 +1,4 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using NewHorizons.External.SerializableData;
|
using NewHorizons.External.SerializableData;
|
||||||
@ -20,14 +21,47 @@ namespace NewHorizons.External.Modules
|
|||||||
public MColor color;
|
public MColor color;
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public Material material;
|
public Material material;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Can use a custom texture. Does not work with material or color.
|
/// Can use a custom texture. Does not work with material or color.
|
||||||
/// </summary>
|
/// </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))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public enum Material
|
public enum Material
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user