mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix cloud fog when using basic shader
This commit is contained in:
parent
ba2a9722fb
commit
e9106ad88e
@ -11,6 +11,7 @@ namespace NewHorizons.Builder.Atmosphere
|
|||||||
public static class CloudsBuilder
|
public static class CloudsBuilder
|
||||||
{
|
{
|
||||||
private static Shader _sphereShader = null;
|
private static Shader _sphereShader = null;
|
||||||
|
private static Material[] _gdCloudMaterials;
|
||||||
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
|
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
Texture2D image, cap, ramp;
|
Texture2D image, cap, ramp;
|
||||||
@ -45,26 +46,31 @@ namespace NewHorizons.Builder.Atmosphere
|
|||||||
topMF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
topMF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
||||||
|
|
||||||
MeshRenderer topMR = cloudsTopGO.AddComponent<MeshRenderer>();
|
MeshRenderer topMR = cloudsTopGO.AddComponent<MeshRenderer>();
|
||||||
if (!atmo.UseBasicCloudShader)
|
|
||||||
|
if (_sphereShader == null) _sphereShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
|
||||||
|
if (_gdCloudMaterials == null) _gdCloudMaterials = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials;
|
||||||
|
var tempArray = new Material[2];
|
||||||
|
|
||||||
|
if (atmo.UseBasicCloudShader)
|
||||||
{
|
{
|
||||||
var tempArray = new Material[2];
|
var material = new Material(_sphereShader);
|
||||||
for (int i = 0; i < 2; i++)
|
if (!atmo.ShadowsOnClouds) material.renderQueue = 2550;
|
||||||
{
|
material.name = atmo.ShadowsOnClouds ? "BasicShadowCloud" : "BasicCloud";
|
||||||
var mat = new Material(GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials[i]);
|
|
||||||
if (!atmo.ShadowsOnClouds) mat.renderQueue = 2550;
|
tempArray[0] = material;
|
||||||
mat.name = atmo.ShadowsOnClouds ? "AdvancedShadowCloud" : "AdvancedCloud";
|
|
||||||
tempArray[i] = mat;
|
|
||||||
}
|
|
||||||
topMR.sharedMaterials = tempArray;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_sphereShader == null) _sphereShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
|
var material = new Material(_gdCloudMaterials[0]);
|
||||||
topMR.material = new Material(_sphereShader);
|
if (!atmo.ShadowsOnClouds) material.renderQueue = 2550;
|
||||||
if (!atmo.ShadowsOnClouds) topMR.material.renderQueue = 2550;
|
material.name = atmo.ShadowsOnClouds ? "AdvancedShadowCloud" : "AdvancedCloud";
|
||||||
topMR.material.name = atmo.ShadowsOnClouds ? "BasicShadowCloud" : "BasicCloud";
|
tempArray[0] = material;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is the stencil material for the fog under the clouds
|
||||||
|
tempArray[1] = new Material(_gdCloudMaterials[1]);
|
||||||
|
topMR.sharedMaterials = tempArray;
|
||||||
|
|
||||||
foreach (var material in topMR.sharedMaterials)
|
foreach (var material in topMR.sharedMaterials)
|
||||||
{
|
{
|
||||||
material.SetColor("_Color", cloudTint);
|
material.SetColor("_Color", cloudTint);
|
||||||
@ -80,7 +86,6 @@ namespace NewHorizons.Builder.Atmosphere
|
|||||||
cloudsTopGO.layer = LayerMask.NameToLayer("IgnoreSun");
|
cloudsTopGO.layer = LayerMask.NameToLayer("IgnoreSun");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RotateTransform topRT = cloudsTopGO.AddComponent<RotateTransform>();
|
RotateTransform topRT = cloudsTopGO.AddComponent<RotateTransform>();
|
||||||
// Idk why but the axis is weird
|
// Idk why but the axis is weird
|
||||||
topRT._localAxis = atmo.UseBasicCloudShader ? Vector3.forward : Vector3.up;
|
topRT._localAxis = atmo.UseBasicCloudShader ? Vector3.forward : Vector3.up;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user