Skip to content

Commit

Permalink
Disabled visor reflections
Browse files Browse the repository at this point in the history
  • Loading branch information
ducakar committed Apr 4, 2016
1 parent c84bdd3 commit 4a99b01
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 35 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,15 @@ Known Issues
* Clouds from EVE are only reflected when on/near the ground or over 160 km.
* Clouds from EVE Overhaul are not correctly reflected.
* Cabin-specific IVA suits don't persist through scene switches while on EVA.
* Visor reflections don't work for KSP 1.1.


Change Log
----------

* 2.4.13
- fixed for 1.1 thanks to RangeMachine
- visor reflections still not working
- disabled visor reflections because visor shader is broken
* 2.4.12
- removed / replaced Kerbal Stuff links
- possibly fixed a reflections-related crash
Expand Down
69 changes: 35 additions & 34 deletions TextureReplacer/Reflections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ public Script(Part part, int updateInterval)
transform = part.transform;
isEva = part.GetComponent<KerbalEVA>() != null;

if (isEva)
{
transform = transform.Find("model01");

SkinnedMeshRenderer visor = transform.GetComponentsInChildren<SkinnedMeshRenderer>(true)
.FirstOrDefault(m => m.name == "visor");

if (visor != null)
{
Material material = visor.material;

material.shader = instance.visorShader;
material.SetTexture(Util.CUBE_PROPERTY, envMap);
material.SetColor(Util.REFLECT_COLOR_PROPERTY, visorReflectionColour);
}
}
// if (isEva)
// {
// transform = transform.Find("model01");
//
// SkinnedMeshRenderer visor = transform.GetComponentsInChildren<SkinnedMeshRenderer>(true)
// .FirstOrDefault(m => m.name == "visor");
//
// if (visor != null)
// {
// Material material = visor.material;
//
// material.shader = instance.visorShader;
// material.SetTexture(Util.CUBE_PROPERTY, envMap);
// material.SetColor(Util.REFLECT_COLOR_PROPERTY, visorReflectionColour);
// }
// }

interval = updateInterval;
counter = Util.random.Next(updateInterval);
Expand Down Expand Up @@ -236,7 +236,7 @@ public static void updateScripts()
// Print names of meshes and their shaders in parts with TRReflection module.
public bool logReflectiveMeshes = false;
// Reflective shader.
Shader visorShader = null;
// Shader visorShader = null;
// Instance.
public static Reflections instance = null;

Expand Down Expand Up @@ -300,7 +300,8 @@ public void setReflectionType(Type type)

// We apply visor shader for real reflections later, through TREvaModule since we don't
// want corrupted reflections in the main menu.
material.shader = enableStatic ? visorShader : transparentSpecularShader;
// material.shader = enableStatic ? visorShader : transparentSpecularShader;
material.shader = transparentSpecularShader;
material.SetTexture(Util.CUBE_PROPERTY, enableStatic ? staticEnvMap : null);
material.SetColor(Util.REFLECT_COLOR_PROPERTY, visorReflectionColour);
}
Expand Down Expand Up @@ -403,22 +404,22 @@ public void load()
}
}

try
{
Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream("TextureReplacer.Visor-compiled.shader");
StreamReader reader = new StreamReader(stream);

shaderMaterial = new Material(reader.ReadToEnd());
visorShader = shaderMaterial.shader;

Util.log("Visor shader sucessfully compiled.");
}
catch
{
isVisorReflectionEnabled = false;
Util.log("Visor shader loading failed. Visor reflections disabled.");
}
// try
// {
// Assembly assembly = Assembly.GetExecutingAssembly();
// Stream stream = assembly.GetManifestResourceStream("TextureReplacer.Visor-compiled.shader");
// StreamReader reader = new StreamReader(stream);
//
// shaderMaterial = new Material(reader.ReadToEnd());
// visorShader = shaderMaterial.shader;
//
// Util.log("Visor shader sucessfully compiled.");
// }
// catch
// {
// isVisorReflectionEnabled = false;
// Util.log("Visor shader loading failed. Visor reflections disabled.");
// }

for (int i = 0; i < SHADER_MAP.GetLength(0); ++i)
{
Expand Down
5 changes: 5 additions & 0 deletions TextureReplacer/TextureReplacer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<PlatformTarget>x86</PlatformTarget>
<CustomCommands>
<CustomCommands>
<Command type="AfterBuild" command="cp ${TargetPath} &quot;/run/media/davorin/Windows 7/KSP-test/GameData/TextureReplacer/Plugins&quot;" workingdir="${SolutionDir}" />
</CustomCommands>
</CustomCommands>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<Optimize>true</Optimize>
Expand Down

0 comments on commit 4a99b01

Please sign in to comment.