Skip to content

Commit

Permalink
Fixing Incise Flow panel and map Zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
d1060 committed Apr 27, 2023
1 parent 91ab24b commit 9311fe2
Show file tree
Hide file tree
Showing 9 changed files with 1,119 additions and 1,126 deletions.
18 changes: 9 additions & 9 deletions Assets/Materials/Planetary Surface.mat
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Material:
- _DesertThreshold1: 10
- _DesertThreshold2: 20
- _DetailNormalMapScale: 1
- _DomainWarping: 0.55380034
- _DomainWarping: 0.6426012
- _DomainWarping2: 0.898079
- _DrawType: 0
- _DstBlend: 0
Expand All @@ -116,19 +116,19 @@ Material:
- _IsHeightmapSet: 0
- _IsLandmaskSet: 0
- _IsMainmapSet: 0
- _Lacunarity: 1.6283267
- _Lacunarity: 1.7018614
- _Lacunarity2: 1.6880908
- _LandGlossiness: 0.376
- _LandMetallic: 0
- _LayerStrength: 0.41418076
- _LayerStrength2: 0.58581924
- _LightFalloff: 16.55
- _LightIntensity: 1
- _MaxHeight: 0.89704984
- _MaxHeight: 0.94607276
- _Metallic: 0
- _MinHeight: 0.156864
- _Mode: 0
- _Multiplier: 2.133469
- _Multiplier: 2.2302768
- _Multiplier2: 2.924182
- _NormalScale: 10
- _OcclusionStrength: 1
Expand All @@ -140,7 +140,7 @@ Material:
- _Octaves: 15
- _Octaves2: 13
- _Parallax: 0.02
- _Persistence: 0.46700287
- _Persistence: 0.471874
- _Persistence2: 0.69903696
- _RidgedNoise: 1
- _RidgedNoise2: 1
Expand All @@ -155,12 +155,12 @@ Material:
- _TextureWidth: 2048
- _UVSec: 0
- _UnderwaterNormalScale: 0.5
- _WaterLevel: 0.7342952
- _XOffset: 0.08447481
- _WaterLevel: 0.66070825
- _XOffset: 0.19547692
- _XOffset2: 0.14873621
- _YOffset: 0.19823718
- _YOffset: 0.36493605
- _YOffset2: 0.38053253
- _ZOffset: 0.3807435
- _ZOffset: 0.538143
- _ZOffset2: 0.051870674
- _ZWrite: 1
m_Colors:
Expand Down
2,118 changes: 1,059 additions & 1,059 deletions Assets/Scenes/Main Scene.unity

Large diffs are not rendered by default.

53 changes: 22 additions & 31 deletions Assets/Scripts/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,18 @@ void Update()
map.MouseMapHit = hitPoint;
}

Vector3 planeHitPoint = new Vector3();
if (mouseWheel != 0)
{
if (!isMapHit)
{
float intersectionDistance = 0;
Plane zZero = new Plane(new Vector3(0, 0, -1), 0.0f);
zZero.Raycast(ray, out intersectionDistance);
Vector3 hitPoint = ray.GetPoint(intersectionDistance);
}
//Debug.Log("Doing Zoom.");
DoZoom(mouseWheel, isMapHit, mapHit);
DoZoom(mouseWheel, isMapHit ? mapHit.point : planeHitPoint);
}

if ((xAxisMovement != 0 || yAxisMovement != 0) && isMouseButtonDown && prevMousePosition.x != float.MinValue)
Expand Down Expand Up @@ -380,53 +388,36 @@ bool IsClickGoingToHitAWaypointMarker()
return false;
}

void DoZoom(float zoomChange, bool isMapHit, RaycastHit hit)
void DoZoom(float zoomChange, Vector3 hitPoint)
{
zoomChange *= zoomSpeed;

if (isMapHit)
if (!map.ShowGlobe)
{
Vector3 zoomDirection = hit.point - transform.position;
Vector3 zoomDirection = hitPoint - transform.position;

zoomDirection.Normalize();
zoomDirection *= zoomChange;
Vector3 cameraPosition = targetCameraPosition;

//float xDelta = zoomDirection.x;
//float yDelta = zoomDirection.y;
float zDelta = zoomDirection.z;
Vector3 cameraPan = new Vector3(0, 0, zDelta);

cameraPosition += cameraPan;

//if (xDelta != 0)
//{
//map.Shift(-xDelta);
//globe.Shift(map.CenterScreenWorldPosition, cam);
//}
if (cameraPosition.z > -minCameraDistance) cameraPosition.z = -minCameraDistance;
if (cameraPosition.z < -maxCameraDistance) cameraPosition.z = -maxCameraDistance;

//CalculateVisibleFlatLatitudeAndLongitude();

//zoomLevel = GetZoomLevel(-transform.position.z);

if (-cameraPosition.z >= minCameraDistance && -cameraPosition.z <= maxCameraDistance)
if (!IsInsidePlanes(cameraPosition))
{
if (!map.ShowGlobe)
{
if (!IsInsidePlanes(cameraPosition))
{
cameraPosition = MoveIntoPlanes(cameraPosition);
CalculateVisibleFlatLatitudeAndLongitude();
geosphere?.RotateCameraTo((visibleLowerLongitude + visibleUpperLongitude) / 2, (visibleLowerLatitude + visibleUpperLatitude) / 2);
}
}

if (cameraPosition.z > -minCameraDistance) cameraPosition.z = -minCameraDistance;
if (cameraPosition.z < -maxCameraDistance) cameraPosition.z = -maxCameraDistance;

cameraPan = cameraPosition - targetCameraPosition;
targetCameraPosition += cameraPan;
cameraPosition = MoveIntoPlanes(cameraPosition);
CalculateVisibleFlatLatitudeAndLongitude();
geosphere?.RotateCameraTo((visibleLowerLongitude + visibleUpperLongitude) / 2, (visibleLowerLatitude + visibleUpperLatitude) / 2);
}

cameraPan = cameraPosition - targetCameraPosition;
targetCameraPosition += cameraPan;

geosphere?.ZoomCameraTo(-transform.position.z);
}
else if (geosphere != null)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Geosphere/Geosphere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Geosphere : MonoBehaviour
int prevDivisions = 5;
float prevRadius = 200.0f;
Vector3 targetCameraPosition = Vector3.zero;
new Camera camera = null;
Camera camera = null;
public float minNavigationSpeed = 0.04f;
public float smoothTime = 0.1f;
private Vector3 velocity = Vector3.zero;
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/Menu/MapSliderField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void Update()
public void Init(float initialValue)
{
slider = GetComponent<Slider>();
if (slider == null) return;
slider.value = initialValue;
if (valueText == null)
{
Expand All @@ -66,6 +67,7 @@ public void Init(float initialValue)

public void OnChanged()
{
if (slider == null) return;
float sValue = slider.value;
if (valueText == null)
{
Expand Down Expand Up @@ -99,6 +101,7 @@ public void OnChanged()

public void OnTextChanged()
{
if (slider == null) return;
string levelText = valueText.text;
if (levelText.EndsWith("%"))
levelText = levelText.Remove(levelText.Length - 1, 1);
Expand Down
10 changes: 5 additions & 5 deletions Assets/Scripts/World/Map.Textures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public void UpdateSurfaceMaterialHeightMap(bool isEroded = false)
heightmapRT = new RenderTexture(heightmap.width, heightmap.height, 16, RenderTextureFormat.ARGBHalf);
heightmapRT.name = "Heightmap Render Texture";
heightmapRT.enableRandomWrite = true;
heightmapRT.wrapMode = TextureWrapMode.Mirror;
heightmapRT.wrapMode = TextureWrapMode.Repeat;
heightmapRT.Create();

RenderTexture prevActive = RenderTexture.active;
Expand All @@ -501,7 +501,7 @@ public void UpdateSurfaceMaterialHeightMap(bool isEroded = false)
RenderTexture newRT = new RenderTexture(TextureManager.instance.Settings.textureWidth * 4, TextureManager.instance.Settings.textureWidth * 2, 16, RenderTextureFormat.ARGBHalf);
newRT.name = "Heightmap Render Texture";
newRT.enableRandomWrite = true;
newRT.wrapMode = TextureWrapMode.Mirror;
newRT.wrapMode = TextureWrapMode.Repeat;
newRT.Create();

RenderTexture prevActive = RenderTexture.active;
Expand All @@ -518,7 +518,7 @@ public void UpdateSurfaceMaterialHeightMap(bool isEroded = false)
heightmapRT = new RenderTexture(TextureManager.instance.Settings.textureWidth * 4, TextureManager.instance.Settings.textureWidth * 2, 16, RenderTextureFormat.ARGBHalf);
heightmapRT.name = "Heightmap Render Texture";
heightmapRT.enableRandomWrite = true;
heightmapRT.wrapMode = TextureWrapMode.Mirror;
heightmapRT.wrapMode = TextureWrapMode.Repeat;
heightmapRT.Create();
}

Expand All @@ -534,7 +534,7 @@ public void UpdateSurfaceMaterialHeightMap(bool isEroded = false)

if (heightmapRT != null)
{
heightmapRT.wrapMode = TextureWrapMode.Mirror;
heightmapRT.wrapMode = TextureWrapMode.Repeat;
planetSurfaceMaterial.SetTexture("_HeightMap", heightmapRT);
}

Expand Down Expand Up @@ -749,7 +749,7 @@ public void HeightMap2Texture()
if (heightmapRT == null)
{
heightmapRT = new RenderTexture(TextureManager.instance.Settings.textureWidth * 4, TextureManager.instance.Settings.textureWidth * 2, 16, RenderTextureFormat.ARGBHalf);
heightmapRT.wrapMode = TextureWrapMode.Mirror;
heightmapRT.wrapMode = TextureWrapMode.Repeat;
heightmapRT.name = "Heightmap Render Texture";
heightmapRT.enableRandomWrite = true;
heightmapRT.Create();
Expand Down
8 changes: 7 additions & 1 deletion Assets/Shaders/ComputeShaders/InciseFlow_Erode.compute
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ float getErodeValueFromFlowCoordinates(float flowHeight, uint3 coordinates)
erodeValue = 0;

erodeValue = pow(abs(erodeValue), curveFactor);
erodeValue = erodeValue * ((1 - heightInfluence) + heightInfluence * ((flowHeight - waterLevel) / (1 - waterLevel)));

float maxErosionValueAtHeightInfluence1 = flowHeight - waterLevel - 0.0001;
float erosionValueAtHeightInfluence1 = erodeValue;
if (erodeValue > maxErosionValueAtHeightInfluence1)
erosionValueAtHeightInfluence1 = maxErosionValueAtHeightInfluence1;

erodeValue = (erodeValue * (1 - heightInfluence)) + (erosionValueAtHeightInfluence1 * heightInfluence);
erodeValue *= strength;
return erodeValue;
}
Expand Down
7 changes: 0 additions & 7 deletions Assets/Shaders/SurfaceTexture.shader
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ Shader "Noise/PlanetarySurfaceTexture"
_Octaves("Number of Octaves", Range(1, 30)) = 10
_Lacunarity("Lacunarity", Range(1, 2)) = 1.5
_Persistence("Persistance", Range(0, 1)) = 0.7
_LayerStrength("Layer Strength", Range(0, 1)) = 1
_HeightExponent("Height Exponent", Range(0, 10)) = 1
_RidgedNoise("Ridged Noise", Int) = 0
_DomainWarping("Domain Warping", Range(0, 4)) = 0

_HeightMap("Heightmap", 2D) = "white" {}
_MainMap("Main Map", 2D) = "white" {}
Expand Down Expand Up @@ -131,7 +128,6 @@ Shader "Noise/PlanetarySurfaceTexture"
int _Octaves;
float _Lacunarity;
float _Persistence;
float _LayerStrength;
float _HeightExponent;
float _MinHeight;
float _MaxHeight;
Expand Down Expand Up @@ -179,9 +175,6 @@ Shader "Noise/PlanetarySurfaceTexture"
float _XOffset;
float _YOffset;
float _ZOffset;
int _RidgedNoise;
float _DomainWarping;
float _DomainWarping2;
float _BakedNormalIntensity;

// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
Expand Down
26 changes: 13 additions & 13 deletions UserSettings/Layouts/default-2021.dwlt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ MonoBehaviour:
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
controlID: 76
controlID: 92
--- !u!114 &4
MonoBehaviour:
m_ObjectHideFlags: 52
Expand Down Expand Up @@ -126,7 +126,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 97
controlID: 27
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
Expand Down Expand Up @@ -172,8 +172,8 @@ MonoBehaviour:
y: 842
width: 2167
height: 465
m_MinSize: {x: 102, y: 121}
m_MaxSize: {x: 4002, y: 4021}
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 19}
m_Panes:
- {fileID: 19}
Expand Down Expand Up @@ -274,7 +274,7 @@ MonoBehaviour:
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
controlID: 98
controlID: 18
--- !u!114 &12
MonoBehaviour:
m_ObjectHideFlags: 52
Expand All @@ -294,8 +294,8 @@ MonoBehaviour:
y: 0
width: 2167
height: 842
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 18}
m_Panes:
- {fileID: 18}
Expand Down Expand Up @@ -481,7 +481,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 066f0000
m_LastClickedID: 28422
m_ExpandedIDs: 00000000406b0000446b0000a06b0000be6e0000c06e0000c26e0000c46e0000c66e0000c86e0000ca6e0000cc6e0000ce6e0000d06e0000d26e0000d46e0000d66e0000d86e0000da6e0000dc6e0000de6e0000e06e0000e26e0000e46e0000e66e0000e86e0000ea6e0000ec6e0000
m_ExpandedIDs: 00000000446b0000486b0000a46b0000c26e0000c46e0000c66e0000c86e0000ca6e0000cc6e0000ce6e0000d06e0000d26e0000d46e0000d66e0000d86e0000da6e0000dc6e0000de6e0000e06e0000e26e0000e46e0000e66e0000e86e0000ea6e0000ec6e0000ee6e0000f06e0000f26e0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand Down Expand Up @@ -509,7 +509,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: ffffffff00000000406b0000446b0000a06b0000be6e0000c06e0000c26e0000c46e0000c66e0000c86e0000ca6e0000cc6e0000ce6e0000d06e0000d26e0000d46e0000d66e0000d86e0000da6e0000dc6e0000de6e0000e06e0000e26e0000e46e0000e66e0000e86e0000ea6e0000ec6e0000086f0000
m_ExpandedIDs: ffffffff00000000446b0000486b0000a46b0000c26e0000c46e0000c66e0000c86e0000ca6e0000cc6e0000ce6e0000d06e0000d26e0000d46e0000d66e0000d86e0000da6e0000dc6e0000de6e0000e06e0000e26e0000e46e0000e66e0000e86e0000ea6e0000ec6e0000ee6e0000f06e0000f26e0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand Down Expand Up @@ -639,9 +639,9 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: ac730100
m_LastClickedID: 95148
m_ExpandedIDs: 4e65ffff9c65ffff4068ffff38fbffff1c580000a858000096590000f05900001a5a00005a5a00002a5b0000b65b0000da5b0000ea5c00000c5d0000625d0000ba5d0000f85d0000045f0000ea5f00001460000096600000c4600000e46000000261000094610000b26100000862000026620000a0620000b0620000e6630000ce640000b065000060660000e8660000fc6700002468000066680000726a0000da6a0000e26a0000026b00009a6b0100526e0100806e010058700100b87101001e750100ba76010008780100307b0100
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 6a4cffffbe4cffff624fffff38fbffffd2580000f45e0000e86000006a680000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand Down Expand Up @@ -774,7 +774,7 @@ MonoBehaviour:
containerId: overlay-container--right
floating: 0
collapsed: 0
displayed: 1
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
Expand Down

0 comments on commit 9311fe2

Please sign in to comment.