Skip to content

Commit 0d47052

Browse files
StarwasterStarwaster
authored andcommitted
Restored missing shaders (again).
- Restored missing shaders (compiled versions) - Increased default FarPlaneClip value to 1000000000f (!!!!!) - Added Starwaster/Bumped Specular shader (reflective, WIP, highly experimental, use at your own risk)
1 parent f6807d0 commit 0d47052

26 files changed

Lines changed: 244785 additions & 663 deletions
7.7 MB
Binary file not shown.

Reflection-Plugin-Continued.sln

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 11.00
33
# Visual Studio 2010
4-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reflection-Plugin-Continued", "Reflection-Plugin-Continued.csproj", "{729C879C-030C-4473-8B33-7DFBF3C4431A}"
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectionPlugin", "ReflectionPlugin.csproj", "{729C879C-030C-4473-8B33-7DFBF3C4431A}"
55
EndProject
66
Global
77
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,7 +15,7 @@ Global
1515
{729C879C-030C-4473-8B33-7DFBF3C4431A}.Release|Any CPU.Build.0 = Release|Any CPU
1616
EndGlobalSection
1717
GlobalSection(MonoDevelopProperties) = preSolution
18-
StartupItem = Reflection-Plugin-Continued.csproj
18+
StartupItem = ReflectionPlugin.csproj
1919
Policies = $0
2020
$0.DotNetNamingPolicy = $1
2121
$1.DirectoryNamespaceAssociation = None
@@ -162,6 +162,17 @@ Global
162162
$27.NamingStyle = PascalCase
163163
$27.IncludeInstanceMembers = True
164164
$27.IncludeStaticEntities = True
165+
$0.TextStylePolicy = $29
166+
$29.inheritsSet = null
167+
$29.scope = text/x-shader
168+
$0.VersionControlPolicy = $30
169+
$30.inheritsSet = Mono
170+
$0.ChangeLogPolicy = $31
171+
$31.UpdateMode = ProjectRoot
172+
$31.VcsIntegration = None
173+
$31.MessageStyle = $32
174+
$32.LineAlign = 0
175+
$31.inheritsSet = Mono
165176
version = 1.0
166177
EndGlobalSection
167178
EndGlobal

Reflection-Plugin-Continued.userprefs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
<Properties>
22
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="MonoDevelop.Default" />
3-
<MonoDevelop.Ide.Workbench ActiveDocument="ReflectiveScript.cs">
3+
<MonoDevelop.Ide.Workbench ActiveDocument="ReflectiveShaderModule.cs">
44
<Files>
5-
<File FileName="ReflectiveScript.cs" Line="123" Column="37" />
6-
<File FileName="ReflectiveShaderModule.cs" Line="219" Column="68" />
5+
<File FileName="../../New Unity Project/Assets/PartTools/Shaders/Specular.shader" Line="1" Column="1" />
6+
<File FileName="Resources/Reflective.Bumped_Diffuse.shader" Line="1" Column="1" />
7+
<File FileName="Resources/Reflective.Bumped_Unlit.shader" Line="1" Column="1" />
8+
<File FileName="Resources/Reflective.Bumped_Specular.shader" Line="1" Column="1" />
9+
<File FileName="Resources/Reflective.Bumped_VertexLit.shader" Line="1" Column="1" />
10+
<File FileName="Resources/Reflective.Diffuse.shader" Line="1" Column="1" />
11+
<File FileName="Resources/Reflective.Specular.shader" Line="1" Column="1" />
12+
<File FileName="Resources/Reflective.Parallax_Diffuse.shader" Line="1" Column="1" />
13+
<File FileName="Resources/Reflective.Parallax_Specular.shader" Line="1" Column="1" />
14+
<File FileName="Resources/Reflective.VertexLit.shader" Line="1" Column="1" />
15+
<File FileName="ReflectiveShaderModule.cs" Line="176" Column="147" />
716
</Files>
8-
<Pads>
9-
<Pad Id="ProjectPad">
10-
<State expanded="True">
11-
<Node name="Reflection-Plugin-Continued" expanded="True" selected="True" />
12-
</State>
13-
</Pad>
14-
<Pad Id="ClassPad">
15-
<State expanded="True" selected="True" />
16-
</Pad>
17-
<Pad Id="MonoDevelop.Debugger.WatchPad">
18-
<State />
19-
</Pad>
20-
</Pads>
2117
</MonoDevelop.Ide.Workbench>
2218
<MonoDevelop.Ide.DebuggingService.Breakpoints>
2319
<BreakpointStore />

ReflectionPlugin.DEV.1.2.zip

1.22 MB
Binary file not shown.

ReflectionPlugin.DEV.VERSION.zip

-6.19 KB
Binary file not shown.
-6.19 KB
Binary file not shown.
Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<SchemaVersion>2.0</SchemaVersion>
88
<ProjectGuid>{729C879C-030C-4473-8B33-7DFBF3C4431A}</ProjectGuid>
99
<OutputType>Library</OutputType>
10-
<RootNamespace>ReflectionPluginContinued</RootNamespace>
10+
<RootNamespace>ReflectionPlugin</RootNamespace>
1111
<AssemblyName>ReflectionPlugin</AssemblyName>
1212
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1313
<ReleaseVersion>1.0</ReleaseVersion>
@@ -38,6 +38,7 @@
3838
<Reference Include="UnityEngine">
3939
<HintPath>..\..\..\..\Applications\KSP_osx_0.24.2\KSP.app\Contents\Data\Managed\UnityEngine.dll</HintPath>
4040
</Reference>
41+
<Reference Include="System.Core" />
4142
</ItemGroup>
4243
<ItemGroup>
4344
<Compile Include="AssemblyInfo.cs" />
@@ -46,41 +47,24 @@
4647
</ItemGroup>
4748
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4849
<ItemGroup>
49-
<EmbeddedResource Include="Resources\Reflect-BumpNolight.shader">
50-
<Link>Reflect-BumpNolight.shader</Link>
51-
<LogicalName>Reflective.Bumped_Unlit</LogicalName>
52-
</EmbeddedResource>
53-
<EmbeddedResource Include="Resources\Reflect-BumpSpec.shader">
54-
<Link>Reflect-BumpSpec.shader</Link>
55-
<LogicalName>Reflective.Bumped_Specular</LogicalName>
56-
</EmbeddedResource>
57-
<EmbeddedResource Include="Resources\Reflect-BumpVertexLit.shader">
58-
<Link>Reflect-BumpVertexLit.shader</Link>
59-
<LogicalName>Reflective.Bumped_VertexLit</LogicalName>
60-
</EmbeddedResource>
61-
<EmbeddedResource Include="Resources\Reflect-Bumped.shader">
62-
<Link>Reflect-Bumped.shader</Link>
63-
<LogicalName>Reflective.Bumped_Diffuse</LogicalName>
64-
</EmbeddedResource>
65-
<EmbeddedResource Include="Resources\Reflect-Diffuse.shader">
66-
<Link>Reflect-Diffuse.shader</Link>
67-
<LogicalName>Reflective.Diffuse</LogicalName>
68-
</EmbeddedResource>
69-
<EmbeddedResource Include="Resources\Reflect-Glossy.shader">
70-
<Link>Reflect-Glossy.shader</Link>
71-
<LogicalName>Reflective.Specular</LogicalName>
72-
</EmbeddedResource>
73-
<EmbeddedResource Include="Resources\Reflect-Parallax.shader">
74-
<Link>Reflect-Parallax.shader</Link>
75-
<LogicalName>Reflective.Parallax_Diffuse</LogicalName>
50+
<Folder Include="Resources\" />
51+
</ItemGroup>
52+
<ItemGroup>
53+
<EmbeddedResource Include="Resources\Reflective.Bumped_Diffuse.shader">
54+
<LogicalName>ReflectionPlugin.Resources.Reflective.Bumped_Diffuse.shader</LogicalName>
7655
</EmbeddedResource>
77-
<EmbeddedResource Include="Resources\Reflect-ParallaxSpec.shader">
78-
<Link>Reflect-ParallaxSpec.shader</Link>
79-
<LogicalName>Reflective.Parallax_Specular</LogicalName>
56+
<EmbeddedResource Include="Resources\Reflective.Bumped_Specular.shader">
57+
<LogicalName>ReflectionPlugin.Resources.Reflective.Bumped_Specular.shader</LogicalName>
8058
</EmbeddedResource>
81-
<EmbeddedResource Include="Resources\Reflect-VertexLit.shader">
82-
<Link>Reflect-VertexLit.shader</Link>
83-
<LogicalName>Reflective.VertexLit</LogicalName>
59+
<EmbeddedResource Include="Resources\Reflective.Bumped_Unlit.shader">
60+
<LogicalName>ReflectionPlugin.Resources.Reflective.Bumped_Unlit.shader</LogicalName>
8461
</EmbeddedResource>
62+
<EmbeddedResource Include="Resources\Reflective.VertexLit.shader" />
63+
<EmbeddedResource Include="Resources\Reflective.Specular.shader" />
64+
<EmbeddedResource Include="Resources\Reflective.Parallax_Specular.shader" />
65+
<EmbeddedResource Include="Resources\Reflective.Parallax_Diffuse.shader" />
66+
<EmbeddedResource Include="Resources\Reflective.Diffuse.shader" />
67+
<EmbeddedResource Include="Resources\Reflective.Bumped_VertexLit.shader" />
68+
<EmbeddedResource Include="Resources\Starwaster.Bumped_Specular.shader" />
8569
</ItemGroup>
8670
</Project>

ReflectiveShaderModule.cs

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class ReflectiveShaderModule : PartModule
1313
[KSPField(isPersistant = false)]
1414
public int CubeMapSize = 128;
1515
[KSPField(isPersistant = false)]
16-
public float FarClipPlane = 100f;
16+
public float FarClipPlane = 1000000000f;
1717
[KSPField(isPersistant = false)]
1818
public float NearClipPlane = -1f;
1919
[KSPField(isPersistant = false)]
@@ -61,6 +61,7 @@ public class ReflectiveShaderModule : PartModule
6161
public override void OnStart(PartModule.StartState state)
6262
{
6363
Debug.Log((object)"RP: Starting ReflectionPlugin .. ");
64+
GameEvents.onVesselGoOffRails.Add(RefreshReflection);
6465
if (this.ShaderName == string.Empty)
6566
{
6667
Debug.Log((object)"RP: Defaulting shader to \"Reflective/VertexLit\"");
@@ -130,24 +131,34 @@ public override void OnStart(PartModule.StartState state)
130131

131132
private void ReplaceShader(UnityEngine.Renderer pRenderer)
132133
{
133-
if ((UnityEngine.Object)pRenderer != (UnityEngine.Object)null)
134+
if ((object)pRenderer != null)
134135
{
135136
Debug.Log((object)string.Format("RP: Renderer found: {0}", (object)this._rShader));
136137
Material material;
137138
string shaderName = this.ShaderName;
139+
string resourceNamesString = "EMBEDDED RESOURCE NAMES\n";
138140

139-
shaderName.Replace (" ", "_");
140-
shaderName.Replace ("/", ".");
141+
shaderName = shaderName.Replace (" ", "_");
142+
shaderName = shaderName.Replace ("/", ".");
141143

142144
if (this._rShader == null)
143145
{
144-
Debug.Log((object)("RP: null shader. Trying to retrieve ReflectionPlugin.Shaders." + this.ShaderName));
146+
Debug.Log((object)("RP: null shader. Trying to retrieve ReflectionPlugin.Shaders." + shaderName));
145147
Assembly assembly = Assembly.GetExecutingAssembly();
148+
149+
string[] resourceNamesList = assembly.GetManifestResourceNames();
150+
foreach (string resourceName in resourceNamesList)
151+
{
152+
resourceNamesString += resourceName + "\n";
153+
}
154+
155+
Debug.Log (resourceNamesString);
156+
146157
try
147158
{
148159
Debug.Log ("[ReflectionPlugin] Looking for resource " + shaderName);
149160

150-
StreamReader shaderStreamReader = new StreamReader(assembly.GetManifestResourceStream(/*"ReflectionPlugin.Shaders." + */shaderName));
161+
StreamReader shaderStreamReader = new StreamReader(assembly.GetManifestResourceStream(/*"ReflectionPlugin.Shaders." + */"ReflectionPlugin.Resources." + shaderName + ".shader"));
151162

152163
Debug.Log ("[ReflectionPlugin] Got " + shaderName);
153164

@@ -159,11 +170,20 @@ private void ReplaceShader(UnityEngine.Renderer pRenderer)
159170
catch (Exception e)
160171
{
161172
Debug.Log ("ReflectionPlugin caught exception " + e.ToString() + " (" + e.Message + ")");
162-
material = new Material(Shader.Find("Reflective/VertexList"))
173+
174+
shaderName = "Reflective.VertexLit";
175+
Debug.Log ("[ReflectionPlugin] Looking for fallback resource " + shaderName);
176+
177+
StreamReader shaderStreamReader = new StreamReader(assembly.GetManifestResourceStream("ReflectionPlugin.Resources." + shaderName + ".shader"));
178+
179+
Debug.Log ("[ReflectionPlugin] Got " + shaderName);
180+
181+
material = new Material(shaderStreamReader.ReadToEnd())
163182
{
164183
mainTexture = pRenderer.material.mainTexture
165184
};
166185
}
186+
Debug.Log ("[ReflectionPlugin] Initialized Material: " + material.ToString ());
167187
}
168188
else
169189
{
@@ -174,13 +194,13 @@ private void ReplaceShader(UnityEngine.Renderer pRenderer)
174194
}
175195
Texture texture1 = pRenderer.material.GetTexture("_BumpMap");
176196
Texture texture2 = pRenderer.material.GetTexture("_Emissive");
177-
if ((UnityEngine.Object)texture1 != (UnityEngine.Object)null)
197+
if ((object)texture1 != null)
178198
{
179199
Debug.LogWarning((object)"RP: Found bumpmap texture, applying..");
180200
material.SetTexture("_BumpMap", texture1);
181201
material.SetTextureScale("_BumpMap", pRenderer.material.GetTextureScale("_BumpMap"));
182202
}
183-
if ((UnityEngine.Object)texture2 != (UnityEngine.Object)null)
203+
if ((object)texture2 != null)
184204
{
185205
Debug.LogWarning((object)"RP: Found heightmap texture, applying..");
186206
material.SetTexture("_ParallaxMap", texture2);
@@ -236,6 +256,10 @@ private void ReplaceShader(UnityEngine.Renderer pRenderer)
236256
else
237257
Debug.LogError((object)("RP: Unable to find a Renderer component on the part. Part: " + this.part.partName));
238258
}
259+
public void RefreshReflection(Vessel v)
260+
{
261+
this.reflectiveScript.dirty = 7;
262+
}
239263
public void FixedUpdate()
240264
{
241265
scriptStatus = this.reflectiveScript.status;

Resources/Reflect-BumpNolight.shader

Lines changed: 0 additions & 109 deletions
This file was deleted.

0 commit comments

Comments
 (0)