Skip to content

Commit 6df93e3

Browse files
committed
Fixed issue with reflectiveScript storage in partmodule
Fixed issue with reflectiveScript storage in partmodule adopted TextureReplacer's method of using multiple render groups for the layer we need.
1 parent 00d36dd commit 6df93e3

4 files changed

Lines changed: 32 additions & 21 deletions

File tree

512 Bytes
Binary file not shown.

ReflectionPlugin.1.3.zip

1.29 MB
Binary file not shown.

ReflectiveScript.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,6 @@ protected void UpdateCubemap(int faceMask)
144144
_go.camera.renderingPath = RenderingPath.UsePlayerSettings;
145145
_go.camera.depth = Camera.main.depth + 1;
146146
_go.camera.aspect = 1;
147-
float[] distances = new float[32];
148-
149-
distances[0] = distances[1] = distances[15] = 60000;
150-
distances[10] = 3.0E+07F;
151-
distances[23] = 3.0E+07F;
152-
153-
_go.camera.layerCullDistances = distances;
154-
155-
_go.camera.cullingMask = (1 << 0) | (1 << 1) | (1 << 4) | (1 << 9) | (1 << 10) | (1 << 15) | (1 << 16) | (1 << 18) | (1 << 20) | (1 << 23) | (1 << 30);
156147

157148
_cam = _go.camera;
158149
_cam.nearClipPlane = NearClipPlane;
@@ -197,7 +188,7 @@ protected void UpdateCubemap(int faceMask)
197188
renderTexture1.useMipMap = true;
198189
renderTexture1.wrapMode = TextureWrapMode.Clamp;
199190
RenderTexture renderTexture2 = renderTexture1;
200-
_cam.backgroundColor = Color.black;
191+
_cam.backgroundColor = Color.blue;
201192

202193
reflectiveScript._rtex = renderTexture2;
203194
//MatRenderer.sharedMaterial.SetTexture("_Cube", (Texture)_rtex);
@@ -221,7 +212,27 @@ protected void UpdateCubemap(int faceMask)
221212

222213

223214
_cam.transform.position = transform.position;
215+
216+
bool result = false;
217+
218+
_cam.transform.position = GalaxyCubeControl.Instance.transform.position;
219+
_cam.farClipPlane = 100.0f;
220+
_cam.cullingMask = 1 << 18;
224221
if (_cam.RenderToCubemap(_rtex, faceMask))
222+
result = true;
223+
224+
_cam.transform.position = ScaledSpace.Instance.transform.position;
225+
_cam.farClipPlane = 3.0e7f;
226+
_cam.cullingMask = (1 << 10) | (1 << 23);
227+
if (_cam.RenderToCubemap(_rtex, faceMask))
228+
result = true;
229+
230+
_cam.farClipPlane = 60000.0f;
231+
_cam.cullingMask = (1 << 0) | (1 << 1) | (1 << 5) | (1 << 15);
232+
if (_cam.RenderToCubemap(_rtex, faceMask))
233+
result = true;
234+
235+
if (result)
225236
{
226237
//Debug.Log ("Checking time");
227238
lastUpdate = Planetarium.GetUniversalTime();

ReflectiveShaderModule.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class ReflectiveShaderModule : PartModule
4949
[KSPField(isPersistant = false)]
5050
public float NearClipPlane = -1f;
5151
[KSPField(isPersistant = false)]
52-
public string MeshesToChange = "";
52+
public string MeshesToChange = "all";
5353
[KSPField(isPersistant = false)]
5454
public bool OneFacePerFrame = true;
5555
[KSPField(isPersistant = false)]
@@ -273,16 +273,16 @@ private void ReplaceShader(UnityEngine.Renderer pRenderer)
273273
material.mainTextureScale = pRenderer.material.mainTextureScale;
274274

275275
pRenderer.material = material;
276-
ReflectiveScript reflectiveScript = part.gameObject.AddComponent<ReflectiveScript>();
277-
reflectiveScript.MatRenderer = pRenderer;
278-
reflectiveScript.CubemapSize = CubeMapSize;
279-
reflectiveScript.FarClipPlane = FarClipPlane;
280-
reflectiveScript.NearClipPlane = NearClipPlane;
281-
reflectiveScript.OneFacePerFrame = OneFacePerFrame;
282-
reflectiveScript.realTimeReflection = realTimeReflection;
283-
reflectiveScript.updateRate = updateRate;
284-
reflectiveScript.dirty = 7;
285-
reflectiveScript = reflectiveScript;
276+
ReflectiveScript _reflectiveScript = part.gameObject.AddComponent<ReflectiveScript>();
277+
_reflectiveScript.MatRenderer = pRenderer;
278+
_reflectiveScript.CubemapSize = CubeMapSize;
279+
_reflectiveScript.FarClipPlane = FarClipPlane;
280+
_reflectiveScript.NearClipPlane = NearClipPlane;
281+
_reflectiveScript.OneFacePerFrame = OneFacePerFrame;
282+
_reflectiveScript.realTimeReflection = realTimeReflection;
283+
_reflectiveScript.updateRate = updateRate;
284+
_reflectiveScript.dirty = 7;
285+
reflectiveScript = _reflectiveScript;
286286
Debug.Log((object)"RP: Material, shader and texture updated.");
287287
}
288288
else

0 commit comments

Comments
 (0)