Skip to content

Commit a16df32

Browse files
committed
Add DDSLoader 1.7, reference it.
Support loading DDS for all textures in RSS.
1 parent 66a450b commit a16df32

6 files changed

Lines changed: 72 additions & 7 deletions

File tree

DDSLoader/DDSLoader.cfg

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
DDSLoader
2+
{
3+
// Maximum number of mipmap to keep for a texture
4+
// 0 keep them all. 1 keep only the texture, 2 keep 1 mipmap, 3 keep 2, ...
5+
mipmapBias = 0
6+
7+
// Maximum number of mipmap to keep for a normal texture
8+
normalMipmapBias = 0
9+
10+
// Those section define exception. You can have more than one cfg file
11+
// with a DDSLoader node and those subnodes.
12+
13+
//NORMAL_LIST
14+
//{
15+
// // Regex of textures to force as Normal
16+
// texture = Squad/Spaces/mk1CockpitInternal/model002
17+
// texture = Squad/Spaces/.*
18+
//}
19+
20+
//READABLE_LIST
21+
//{
22+
// // Regex of textures to keep readable for mods
23+
// texture = BoulderCo/Clouds/.*
24+
//}
25+
26+
}

DDSLoader/DDSLoader.dll

10.5 KB
Binary file not shown.

DDSLoader/LICENSE.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 sarbian
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
512 Bytes
Binary file not shown.

Source/RealSolarSystem.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
<HintPath>..\..\..\..\..\..\Games\KSP_025clean\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
5656
<Private>False</Private>
5757
</Reference>
58+
<Reference Include="DDSLoader">
59+
<HintPath>..\..\..\..\..\..\Games\KSP_025\GameData\DDSLoader\DDSLoader.dll</HintPath>
60+
<Private>False</Private>
61+
</Reference>
5862
<Reference Include="System" />
5963
<Reference Include="UnityEngine">
6064
<HintPath>..\..\..\..\..\..\Games\KSP_025clean\KSP_Data\Managed\UnityEngine.dll</HintPath>

Source/Utils.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,28 @@ public static bool LoadTexture(string path, ref Texture2D map, bool compress, bo
6868
path = KSPUtil.ApplicationRootPath + path;
6969
if (File.Exists(path))
7070
{
71-
map = new Texture2D(4, 4, TextureFormat.RGB24, true);
72-
map.LoadImage(System.IO.File.ReadAllBytes(path));
73-
if(compress)
74-
map.Compress(true);
75-
if(upload)
76-
map.Apply(true, unreadable);
77-
return true;
71+
try
72+
{
73+
map = new Texture2D(4, 4, TextureFormat.RGB24, true);
74+
if (path.ToLower().Contains(".dds"))
75+
{
76+
GameDatabase.TextureInfo tInfo = DDSLoader.DatabaseLoaderTexture_DDS.LoadDDS(path, !unreadable, path.Contains("NRM"), -1, upload);
77+
map = tInfo.texture;
78+
}
79+
else
80+
{
81+
map.LoadImage(System.IO.File.ReadAllBytes(path));
82+
if (compress)
83+
map.Compress(true);
84+
if (upload)
85+
map.Apply(true, unreadable);
86+
}
87+
return true;
88+
}
89+
catch (Exception e)
90+
{
91+
Debug.Log("*RSS* *ERROR* failed to load " + path);
92+
}
7893
}
7994
else
8095
print("*RSS* *ERROR* texture does not exist! " + path);

0 commit comments

Comments
 (0)