mirror of
https://github.com/PorktoberRevolution/ReStocked
synced 2024-09-01 17:34:42 +00:00
Add support to set what object gets affected by the depthMask
used for setting an "interior" mesh while allowing transparent meshes outside to still render correctly
This commit is contained in:
parent
6519ecfc61
commit
c824d83bfe
Binary file not shown.
@ -9,6 +9,9 @@ namespace Restock
|
|||||||
[KSPField]
|
[KSPField]
|
||||||
public string maskTransform= "";
|
public string maskTransform= "";
|
||||||
|
|
||||||
|
[KSPField]
|
||||||
|
public string bodyTransform = "";
|
||||||
|
|
||||||
// The name of the depth mask shader
|
// The name of the depth mask shader
|
||||||
[KSPField]
|
[KSPField]
|
||||||
public string shaderName = "DepthMask";
|
public string shaderName = "DepthMask";
|
||||||
@ -24,6 +27,8 @@ namespace Restock
|
|||||||
// depth mask object transform
|
// depth mask object transform
|
||||||
public Transform depthMask;
|
public Transform depthMask;
|
||||||
|
|
||||||
|
public Transform bodyRoot;
|
||||||
|
|
||||||
// depth mask shader object
|
// depth mask shader object
|
||||||
public Shader depthShader;
|
public Shader depthShader;
|
||||||
|
|
||||||
@ -44,7 +49,7 @@ namespace Restock
|
|||||||
|
|
||||||
base.OnLoad(node);
|
base.OnLoad(node);
|
||||||
|
|
||||||
//if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) return;
|
if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) return;
|
||||||
|
|
||||||
this.depthMask = base.part.FindModelTransform(maskTransform);
|
this.depthMask = base.part.FindModelTransform(maskTransform);
|
||||||
if (!(this.depthMask is Transform))
|
if (!(this.depthMask is Transform))
|
||||||
@ -53,6 +58,20 @@ namespace Restock
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bodyTransform == "")
|
||||||
|
{
|
||||||
|
bodyRoot = base.part.partTransform;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.bodyRoot = base.part.partTransform.Find(bodyTransform);
|
||||||
|
if (!(this.bodyRoot is Transform))
|
||||||
|
{
|
||||||
|
this.LogError($"Can't find transform {bodyTransform}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.depthShader = Shader.Find(shaderName);
|
this.depthShader = Shader.Find(shaderName);
|
||||||
if (!(this.depthShader is Shader))
|
if (!(this.depthShader is Shader))
|
||||||
@ -80,17 +99,23 @@ namespace Restock
|
|||||||
this.Log(depthShader.name);
|
this.Log(depthShader.name);
|
||||||
this.Log(windowRenderer.material.shader.name);
|
this.Log(windowRenderer.material.shader.name);
|
||||||
|
|
||||||
var meshRenderers = part.partTransform.GetComponentsInChildren<MeshRenderer>(true);
|
var meshRenderers = bodyRoot.GetComponentsInChildren<MeshRenderer>(true);
|
||||||
var skinnedMeshRenderers = part.partTransform.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
var skinnedMeshRenderers = bodyRoot.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
||||||
|
|
||||||
foreach (var renderer in meshRenderers)
|
foreach (var renderer in meshRenderers)
|
||||||
{
|
{
|
||||||
this.Log(renderer.material.name + " " + renderer.material.renderQueue.ToString());
|
|
||||||
if (renderer == windowRenderer) continue;
|
if (renderer == windowRenderer) continue;
|
||||||
var queue = renderer.material.renderQueue;
|
var queue = renderer.material.renderQueue;
|
||||||
queue = meshRenderQueue + ((queue - 2000) / 2);
|
queue = meshRenderQueue + ((queue - 2000) / 2);
|
||||||
renderer.material.renderQueue = queue;
|
renderer.material.renderQueue = queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var renderer in skinnedMeshRenderers)
|
||||||
|
{
|
||||||
|
if (renderer == windowRenderer) continue;
|
||||||
|
var queue = renderer.material.renderQueue;
|
||||||
|
queue = meshRenderQueue + ((queue - 2000) / 2);
|
||||||
|
renderer.material.renderQueue = queue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user