Skip to content

Commit

Permalink
update scenes with new PBR material
Browse files Browse the repository at this point in the history
  • Loading branch information
ofux committed May 14, 2019
1 parent 888df32 commit b99bdeb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
8 changes: 5 additions & 3 deletions VoxelTypeFunctions/DefaultVoxelTypeFunctions.cs
Expand Up @@ -10,7 +10,7 @@ namespace UltimateTerrains
[Serializable]
public class DefaultVoxelTypeFunctions : AbstractVoxelTypeFunctions
{
[SerializeField] private Color32 vertexColor = Color.red;
[SerializeField] private Color32 vertexColor = new Color32(255, 0, 0, 0);
[SerializeField] private Vector4 uv2 = Vector4.zero;

public override Color32 GetVertexColor(Vector3d meshWorldPosition, Vector3 vertexPosition, Vector3 vertexNormal)
Expand All @@ -26,8 +26,10 @@ public override Vector4 GetVertexUVW2(Vector3d meshWorldPosition, Vector3 vertex
public override void OnEditorGUI(UltimateTerrain uTerrain, VoxelType voxelType)
{
#if UNITY_EDITOR
vertexColor = EditorGUILayout.ColorField("Vertex Color:", vertexColor);
uv2 = EditorGUILayout.ColorField("UV2 (X = R, Y = G):", uv2);
var vColLabel = new GUIContent("Vertex Color:", "(RGBA) R <=> 1st texture, G <=> 2nd texture, B <=> 3rd texture, A <=> 4th texture");
vertexColor = EditorGUILayout.ColorField(vColLabel, vertexColor);
var vUV2Label = new GUIContent("UV2 (X = R, Y = G):", "(RG) R <=> 5th texture, G <=> 6th texture");
uv2 = EditorGUILayout.ColorField(vUV2Label, uv2);
#endif
}
}
Expand Down
28 changes: 22 additions & 6 deletions VoxelTypeFunctions/TopSidesColorsVoxelTypeFunctions.cs
Expand Up @@ -10,21 +10,37 @@ namespace UltimateTerrains
[Serializable]
public class TopSidesColorsVoxelTypeFunctions : AbstractVoxelTypeFunctions
{
[SerializeField] private Color topColor = Color.clear;
[SerializeField] private Color sidesColor = Color.clear;
[SerializeField] private float slopeModificator;
[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 slopeModificator = 0.7f;

public override Color32 GetVertexColor(Vector3d meshWorldPosition, Vector3 vertexPosition, Vector3 vertexNormal)
{
return Color.Lerp(sidesColor, topColor, vertexNormal.y + slopeModificator);
}

public override Vector4 GetVertexUVW2(Vector3d meshWorldPosition, Vector3 vertexPosition, Vector3 vertexNormal)
{
return Vector4.Lerp(sidesUv2, topUv2, vertexNormal.y + slopeModificator);
}

public override void OnEditorGUI(UltimateTerrain uTerrain, VoxelType voxelType)
{
#if UNITY_EDITOR
topColor = EditorGUILayout.ColorField("Top Color:", topColor);
sidesColor = EditorGUILayout.ColorField("Sides Color:", sidesColor);
slopeModificator = EditorGUILayout.Slider("Slope modificator:", slopeModificator, -1f, 1f);
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.");
slopeModificator = EditorGUILayout.Slider(slopeLabel, slopeModificator, -1f, 1f);
#endif
}
}
Expand Down
31 changes: 19 additions & 12 deletions VoxelTypeFunctions/TopSidesNoLerpColorsVoxelTypeFunctions.cs
@@ -1,5 +1,5 @@
using UnityEngine;
using System;
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;

Expand All @@ -10,11 +10,11 @@ namespace UltimateTerrains
[Serializable]
public class TopSidesNoLerpColorsVoxelTypeFunctions : AbstractVoxelTypeFunctions
{
[SerializeField] private Color32 topColor = Color.clear;
[SerializeField] private Vector4 topUv2 = Color.clear;
[SerializeField] private Color32 sidesColor = Color.clear;
[SerializeField] private Vector4 sidesUv2 = Color.clear;
[SerializeField] private float slopeLimit = 0f;
[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)
{
Expand All @@ -29,11 +29,18 @@ public override Vector4 GetVertexUVW2(Vector3d meshWorldPosition, Vector3 vertex
public override void OnEditorGUI(UltimateTerrain uTerrain, VoxelType voxelType)
{
#if UNITY_EDITOR
topColor = EditorGUILayout.ColorField("Top Color:", topColor);
topUv2 = EditorGUILayout.ColorField("Top UV2 (x=r, y=g, z=b, w=a):", topUv2);
sidesColor = EditorGUILayout.ColorField("Sides Color:", sidesColor);
sidesUv2 = EditorGUILayout.ColorField("Sides UV2 (x=r, y=g, z=b, w=a):", sidesUv2);
slopeLimit = EditorGUILayout.Slider("Slope limit:", slopeLimit, -1f, 1f);
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
}
}
Expand Down

0 comments on commit b99bdeb

Please sign in to comment.