-
Notifications
You must be signed in to change notification settings - Fork 4
/
TopSidesNoLerpColorsVoxelTypeFunctions.cs
47 lines (40 loc) · 2.12 KB
/
TopSidesNoLerpColorsVoxelTypeFunctions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UltimateTerrains
{
[Serializable]
public class TopSidesNoLerpColorsVoxelTypeFunctions : AbstractVoxelTypeFunctions
{
[SerializeField] private Color32 topColor = new Color32(255, 0, 0, 0);
[SerializeField] private Vector4 topUv2 = Vector4.zero;
[SerializeField] private Color32 sidesColor = new Color32(0, 255, 0, 0);
[SerializeField] private Vector4 sidesUv2 = Vector4.zero;
[SerializeField] private float slopeLimit = 0.7f;
public override Color32 GetVertexColor(Vector3d meshWorldPosition, Vector3 vertexPosition, Vector3 vertexNormal)
{
return vertexNormal.y < slopeLimit ? sidesColor : topColor;
}
public override Vector4 GetVertexUVW2(Vector3d meshWorldPosition, Vector3 vertexPosition, Vector3 vertexNormal)
{
return vertexNormal.y < slopeLimit ? sidesUv2 : topUv2;
}
public override void OnEditorGUI(UltimateTerrain uTerrain, VoxelType voxelType)
{
#if UNITY_EDITOR
var vColLabel = new GUIContent("Top Color:", "(RGBA) R <=> 1st texture, G <=> 2nd texture, B <=> 3rd texture, A <=> 4th texture");
topColor = EditorGUILayout.ColorField(vColLabel, topColor);
var vUV2Label = new GUIContent("Top UV2:", "(RG) R <=> 5th texture, G <=> 6th texture");
topUv2 = EditorGUILayout.ColorField(vUV2Label, topUv2);
vColLabel = new GUIContent("Sides Color:", "(RGBA) R <=> 1st texture, G <=> 2nd texture, B <=> 3rd texture, A <=> 4th texture");
sidesColor = EditorGUILayout.ColorField(vColLabel, sidesColor);
vUV2Label = new GUIContent("Sides UV2:", "(RG) R <=> 5th texture, G <=> 6th texture");
sidesUv2 = EditorGUILayout.ColorField(vUV2Label, sidesUv2);
var slopeLabel = new GUIContent("Top min normal.y:", "Min normal.y of ground to be considered as Top. If normal.y is lower than this, it will be considered as Sides.");
slopeLimit = EditorGUILayout.Slider(slopeLabel, slopeLimit, -1f, 1f);
#endif
}
}
}