Skip to content

Commit 329ea4c

Browse files
committed
Fix normal maps, add SScam, nearclip. v8.1.2 FINAL
1 parent 91bfa9c commit 329ea4c

6 files changed

Lines changed: 38 additions & 11 deletions

File tree

512 Bytes
Binary file not shown.

RealSolarSystem/Readme_RSS.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ Pluto is represented by Vall
4646

4747
===========================
4848
Changelog
49+
v8.1.2
50+
*Fixed normal map loading
51+
*Added ability to set both far and near clip planes in cfg, added cfg support for camScaledSpace (camScaledSpaceNearClip like cam01FarClip in cfg)
52+
*Water now no longer disappears when close (by setting cam01NearClip to 1)
53+
4954
v8.1.1
5055
*Fixed stupidity where I deleted textures after loading them.
5156

RealSolarSystem/RealSolarSystem.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ REALSOLARSYSTEM
99
// useSphericalSSM to override the global value. Defaults to the global value.
1010
wrap = true
1111
useKeypressClip = true
12-
12+
cam01NearClip = 1
1313

1414
// do we only use spheres for scaledspace?
1515
spheresOnly = false

RealSolarSystem/RealSolarSystem.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"VERSION": {
55
"MAJOR": 8,
66
"MINOR": 1,
7-
"PATCH": 1
7+
"PATCH": 2
88
},
99
"KSP_VERSION": {
1010
"MAJOR": 0,

Source/RealSolarSystem.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,8 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
15721572
print("RSS Loading local texture " + path);
15731573
localLoad = true;
15741574
success = false;
1575-
if (File.Exists(KSPUtil.ApplicationRootPath + path))
1575+
path = KSPUtil.ApplicationRootPath + path;
1576+
if (File.Exists(path))
15761577
{
15771578
map = new Texture2D(4, 4, replaceColor == 1 ? TextureFormat.RGB24 : TextureFormat.RGBA32, true);
15781579
map.LoadImage(System.IO.File.ReadAllBytes(path));
@@ -1607,12 +1608,12 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
16071608
if (node.HasValue("SSBump"))
16081609
{
16091610
guiExtra = "Normal Map";
1611+
path = node.GetValue("SSBump");
16101612
//Texture2D map = GameDatabase.Instance.GetTexture(node.GetValue("SSBump"), false);
16111613
Texture2D map = null;
1612-
string tName = node.GetValue("SSBump");
16131614
Texture2D[] textures = Resources.FindObjectsOfTypeAll(typeof(Texture2D)) as Texture2D[];
16141615
foreach (Texture2D tex in textures)
1615-
if (tex.name.Equals(tName))
1616+
if (tex.name.Equals(path))
16161617
{
16171618
map = tex;
16181619
break;
@@ -1623,35 +1624,38 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
16231624
if ((object)map == null)
16241625
{
16251626
localLoad = true;
1627+
print("RSS Loading local texture " + path);
16261628
success = false;
1627-
if (File.Exists(KSPUtil.ApplicationRootPath + node.GetValue("SSBump")))
1629+
path = KSPUtil.ApplicationRootPath + path;
1630+
if (File.Exists(path))
16281631
{
16291632

16301633
yield return null;
16311634
//OnGui();
16321635
map = new Texture2D(4, 4, TextureFormat.RGB24, true);
1633-
map.LoadImage(System.IO.File.ReadAllBytes(node.GetValue("SSBump")));
1636+
map.LoadImage(System.IO.File.ReadAllBytes(path));
16341637
yield return null;
16351638
if (loadInfo.compressNormals)
16361639
map.Compress(true);
16371640
yield return null;
16381641
map.Apply(true, true);
1642+
success = true;
16391643
yield return null;
16401644
}
16411645
else
1642-
print("*RSS* *ERROR* texture does not exist! " + node.GetValue("SSBump"));
1646+
print("*RSS* *ERROR* texture does not exist! " + path);
16431647
}
16441648
if (success)
16451649
{
16461650
Texture oldBump = t.gameObject.renderer.material.GetTexture("_BumpMap");
1647-
bool replacedOrig = false;
16481651
if (oldBump != null)
16491652
{
16501653
foreach (Material m in Resources.FindObjectsOfTypeAll(typeof(Material)))
16511654
{
1652-
if (m.GetTexture("_BumpMap") == oldBump || m == t.gameObject.renderer.material)
1655+
if (m.GetTexture("_BumpMap") == oldBump)
16531656
m.SetTexture("_BumpMap", map);
16541657
}
1658+
t.gameObject.renderer.material.SetTexture("_BumpMap", map); // in case one wasn't set.
16551659
DestroyImmediate(oldBump);
16561660
oldBump = null;
16571661
yield return null;

Source/Watchdogs.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,38 @@ public void Update()
6767
else
6868
{
6969
float farClip = -1;
70+
float nearClip = 01;
7071
if (cam.name.Equals("Camera 00"))
7172
{
7273
RSSSettings.TryGetValue("cam00FarClip", ref farClip);
7374
if (RSSSettings.HasNode(bodyName))
7475
RSSSettings.GetNode(bodyName).TryGetValue("cam00FarClip", ref farClip);
76+
RSSSettings.TryGetValue("cam00NearClip", ref nearClip);
77+
if (RSSSettings.HasNode(bodyName))
78+
RSSSettings.GetNode(bodyName).TryGetValue("cam00NearClip", ref nearClip);
7579
}
76-
else
80+
else if (cam.name.Equals("Camera 01"))
7781
{
7882
RSSSettings.TryGetValue("cam01FarClip", ref farClip);
7983
if (RSSSettings.HasNode(bodyName))
8084
RSSSettings.GetNode(bodyName).TryGetValue("cam01FarClip", ref farClip);
85+
RSSSettings.TryGetValue("cam01NearClip", ref nearClip);
86+
if (RSSSettings.HasNode(bodyName))
87+
RSSSettings.GetNode(bodyName).TryGetValue("cam01NearClip", ref nearClip);
88+
}
89+
else if (cam.name.Equals("Camera ScaledSpace"))
90+
{
91+
RSSSettings.TryGetValue("camScaledSpaceFarClip", ref farClip);
92+
if (RSSSettings.HasNode(bodyName))
93+
RSSSettings.GetNode(bodyName).TryGetValue("camScaledSpaceFarClip", ref farClip);
94+
RSSSettings.TryGetValue("camScaledSpaceNearClip", ref nearClip);
95+
if (RSSSettings.HasNode(bodyName))
96+
RSSSettings.GetNode(bodyName).TryGetValue("camScaledSpaceNearClip", ref nearClip);
8197
}
8298
if (farClip > 0)
8399
cam.farClipPlane = farClip;
100+
if (nearClip > 0)
101+
cam.nearClipPlane = nearClip;
84102
}
85103

86104
msg += " (" + cam.name + "): " + cam.farClipPlane + ".";

0 commit comments

Comments
 (0)