mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Transparent clouds (#338)
Adds fourth cloud prefab that allows transparency.
This commit is contained in:
commit
9192890f4c
Binary file not shown.
@ -1,14 +1,16 @@
|
||||
ManifestFileVersion: 0
|
||||
CRC: 1014555239
|
||||
CRC: 2022446871
|
||||
Hashes:
|
||||
AssetFileHash:
|
||||
serializedVersion: 2
|
||||
Hash: 45fa3430ee7bea1e8384e57927fc0f76
|
||||
Hash: 083882699617744b8fc49234bb8cb795
|
||||
TypeTreeHash:
|
||||
serializedVersion: 2
|
||||
Hash: 55d48f4ad9c3b13330b9eb5ee5686477
|
||||
Hash: 10a6a558690295dadb3dd990eda0821a
|
||||
HashAppended: 0
|
||||
ClassTypes:
|
||||
- Class: 21
|
||||
Script: {instanceID: 0}
|
||||
- Class: 48
|
||||
Script: {instanceID: 0}
|
||||
SerializeReferenceClassIdentifiers: []
|
||||
@ -18,6 +20,7 @@ Assets:
|
||||
- Assets/Shaders/SphereTextureWrapperNormal.shader
|
||||
- Assets/Shaders/UnlitRing1Pixel.shader
|
||||
- Assets/Shaders/UnlitTransparent.shader
|
||||
- Assets/Resources/TransparentCloud.mat
|
||||
- Assets/Shaders/StandardCullOFF.shader
|
||||
- Assets/Shaders/Ring1Pixel.shader
|
||||
Dependencies: []
|
||||
|
||||
@ -59,7 +59,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
}
|
||||
}
|
||||
|
||||
material.SetFloat(InnerRadius, atmosphereModule.clouds != null ? atmosphereModule.size : surfaceSize);
|
||||
material.SetFloat(InnerRadius, (atmosphereModule.clouds != null && atmosphereModule.clouds.cloudsPrefab != CloudPrefabType.Transparent) ? atmosphereModule.size : surfaceSize);
|
||||
material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f);
|
||||
if (atmosphereModule.atmosphereTint != null) material.SetColor(SkyColor, atmosphereModule.atmosphereTint.ToColor());
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
private static Material[] _gdCloudMaterials;
|
||||
private static Material[] _qmCloudMaterials;
|
||||
private static Material _transparentCloud;
|
||||
private static GameObject _lightningPrefab;
|
||||
private static Texture2D _colorRamp;
|
||||
private static readonly int Color = Shader.PropertyToID("_Color");
|
||||
@ -18,6 +19,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
private static readonly int MainTex = Shader.PropertyToID("_MainTex");
|
||||
private static readonly int RampTex = Shader.PropertyToID("_RampTex");
|
||||
private static readonly int CapTex = Shader.PropertyToID("_CapTex");
|
||||
private static readonly int Smoothness = Shader.PropertyToID("_Glossiness");
|
||||
|
||||
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, bool cloaked, IModBehaviour mod)
|
||||
{
|
||||
@ -28,7 +30,15 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
cloudsMainGO.SetActive(false);
|
||||
cloudsMainGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
|
||||
MakeTopClouds(cloudsMainGO, atmo, mod);
|
||||
if (atmo.clouds.cloudsPrefab != CloudPrefabType.Transparent) MakeTopClouds(cloudsMainGO, atmo, mod);
|
||||
else
|
||||
{
|
||||
MakeTransparentClouds(cloudsMainGO, atmo, mod);
|
||||
if (atmo.clouds.hasLightning) MakeLightning(cloudsMainGO, sector, atmo);
|
||||
cloudsMainGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
|
||||
cloudsMainGO.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject cloudsBottomGO = new GameObject("BottomClouds");
|
||||
cloudsBottomGO.SetActive(false);
|
||||
@ -114,7 +124,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
lightning.transform.localPosition = Vector3.zero;
|
||||
|
||||
var lightningGenerator = lightning.GetComponent<CloudLightningGenerator>();
|
||||
lightningGenerator._altitude = (atmo.clouds.outerCloudRadius + atmo.clouds.innerCloudRadius) / 2f;
|
||||
lightningGenerator._altitude = atmo.clouds.cloudsPrefab != CloudPrefabType.Transparent ? (atmo.clouds.outerCloudRadius + atmo.clouds.innerCloudRadius) / 2f : atmo.clouds.outerCloudRadius;
|
||||
if (noAudio)
|
||||
{
|
||||
lightningGenerator._audioPrefab = null;
|
||||
@ -177,7 +187,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
var material = new Material(Shader.Find("Standard"));
|
||||
if (atmo.clouds.unlit) material.renderQueue = 3000;
|
||||
material.name = atmo.clouds.unlit ? "BasicCloud" : "BasicShadowCloud";
|
||||
material.SetFloat(279, 0f); // smoothness
|
||||
material.SetFloat(Smoothness, 0f);
|
||||
tempArray[0] = material;
|
||||
}
|
||||
else
|
||||
@ -218,5 +228,65 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
return cloudsTopGO;
|
||||
}
|
||||
|
||||
public static GameObject MakeTransparentClouds(GameObject rootObject, AtmosphereModule atmo, IModBehaviour mod, bool isProxy = false)
|
||||
{
|
||||
Texture2D image;
|
||||
|
||||
try
|
||||
{
|
||||
image = ImageUtilities.GetTexture(mod, atmo.clouds.texturePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Couldn't load Cloud texture for [{atmo.clouds.texturePath}]:\n{e}");
|
||||
return null;
|
||||
}
|
||||
|
||||
GameObject cloudsTransparentGO = new GameObject("TransparentClouds");
|
||||
cloudsTransparentGO.SetActive(false);
|
||||
cloudsTransparentGO.transform.parent = rootObject.transform;
|
||||
cloudsTransparentGO.transform.localScale = Vector3.one * atmo.clouds.outerCloudRadius;
|
||||
|
||||
MeshFilter filter = cloudsTransparentGO.AddComponent<MeshFilter>();
|
||||
filter.mesh = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
||||
|
||||
MeshRenderer renderer = cloudsTransparentGO.AddComponent<MeshRenderer>();
|
||||
if (_transparentCloud == null) _transparentCloud = Main.NHAssetBundle.LoadAsset<Material>("Assets/Resources/TransparentCloud.mat");
|
||||
var material = new Material(_transparentCloud);
|
||||
material.name = "TransparentClouds_" + image.name;
|
||||
material.SetTexture(MainTex, image);
|
||||
renderer.sharedMaterial = material;
|
||||
|
||||
if (!isProxy)
|
||||
{
|
||||
GameObject tcrqcGO = new GameObject("TransparentCloudRenderQueueController");
|
||||
tcrqcGO.transform.SetParent(cloudsTransparentGO.transform, false);
|
||||
tcrqcGO.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
|
||||
var shape = tcrqcGO.AddComponent<SphereShape>();
|
||||
shape.radius = 1;
|
||||
|
||||
var owTriggerVolume = tcrqcGO.AddComponent<OWTriggerVolume>();
|
||||
owTriggerVolume._shape = shape;
|
||||
|
||||
TransparentCloudRenderQueueController tcrqc = tcrqcGO.AddComponent<TransparentCloudRenderQueueController>();
|
||||
tcrqc.renderer = renderer;
|
||||
}
|
||||
|
||||
if (atmo.clouds.rotationSpeed != 0f)
|
||||
{
|
||||
var rt = cloudsTransparentGO.AddComponent<RotateTransform>();
|
||||
rt._localAxis = Vector3.up;
|
||||
rt._degreesPerSecond = atmo.clouds.rotationSpeed;
|
||||
rt._randomizeRotationRate = false;
|
||||
}
|
||||
|
||||
cloudsTransparentGO.transform.localPosition = Vector3.zero;
|
||||
|
||||
cloudsTransparentGO.SetActive(true);
|
||||
|
||||
return cloudsTransparentGO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
SCG._waitForStreaming = false;
|
||||
|
||||
var minHeight = surfaceSize;
|
||||
var maxHeight = config.Atmosphere.size;
|
||||
if (config.HeightMap?.minHeight != null)
|
||||
{
|
||||
if (config.Water?.size >= config.HeightMap.minHeight) minHeight = config.Water.size; // use sea level if its higher
|
||||
@ -30,6 +29,9 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
else if (config.Water?.size != null) minHeight = config.Water.size;
|
||||
else if (config.Lava?.size != null) minHeight = config.Lava.size;
|
||||
|
||||
var maxHeight = config.Atmosphere.size;
|
||||
if (config.Atmosphere.clouds?.outerCloudRadius != null) maxHeight = config.Atmosphere.clouds.outerCloudRadius;
|
||||
|
||||
if (config.Atmosphere.hasRain)
|
||||
{
|
||||
var rainGO = GameObject.Instantiate(SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform);
|
||||
|
||||
@ -111,7 +111,8 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
if (body.Config.Atmosphere.clouds != null)
|
||||
{
|
||||
topClouds = CloudsBuilder.MakeTopClouds(proxy, body.Config.Atmosphere, body.Mod).GetComponent<MeshRenderer>();
|
||||
if (body.Config.Atmosphere.clouds.cloudsPrefab != External.Modules.CloudPrefabType.Transparent) topClouds = CloudsBuilder.MakeTopClouds(proxy, body.Config.Atmosphere, body.Mod).GetComponent<MeshRenderer>();
|
||||
else topClouds = CloudsBuilder.MakeTransparentClouds(proxy, body.Config.Atmosphere, body.Mod, true).GetAddComponent<MeshRenderer>();
|
||||
|
||||
if (body.Config.Atmosphere.clouds.hasLightning) lightningGenerator = CloudsBuilder.MakeLightning(proxy, null, body.Config.Atmosphere, true);
|
||||
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Components
|
||||
{
|
||||
[RequireComponent(typeof(OWTriggerVolume))]
|
||||
public class TransparentCloudRenderQueueController : MonoBehaviour
|
||||
{
|
||||
public int insideQueue = 3001;
|
||||
public int outsideQueue = 2999;
|
||||
|
||||
private OWTriggerVolume _triggerVolume;
|
||||
public Renderer renderer;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_triggerVolume = this.GetRequiredComponent<OWTriggerVolume>();
|
||||
if (_triggerVolume == null) return;
|
||||
_triggerVolume.OnEntry += OnTriggerVolumeEntry;
|
||||
_triggerVolume.OnExit += OnTriggerVolumeExit;
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (_triggerVolume == null) return;
|
||||
_triggerVolume.OnEntry -= OnTriggerVolumeEntry;
|
||||
_triggerVolume.OnExit -= OnTriggerVolumeExit;
|
||||
}
|
||||
|
||||
public void OnTriggerVolumeEntry(GameObject hitObj)
|
||||
{
|
||||
if (hitObj.CompareTag("PlayerDetector")) SetQueueToInside();
|
||||
}
|
||||
|
||||
public void OnTriggerVolumeExit(GameObject hitObj)
|
||||
{
|
||||
if (hitObj.CompareTag("PlayerDetector")) SetQueueToOutside();
|
||||
}
|
||||
|
||||
public void SetQueueToInside()
|
||||
{
|
||||
if (renderer == null) return;
|
||||
renderer.sharedMaterial.renderQueue = insideQueue;
|
||||
}
|
||||
|
||||
public void SetQueueToOutside()
|
||||
{
|
||||
if (renderer == null) return;
|
||||
renderer.sharedMaterial.renderQueue = outsideQueue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -30,6 +30,8 @@ namespace NewHorizons.External.Modules
|
||||
[EnumMember(Value = @"quantumMoon")] QuantumMoon = 1,
|
||||
|
||||
[EnumMember(Value = @"basic")] Basic = 2,
|
||||
|
||||
[EnumMember(Value = @"transparent")] Transparent = 3,
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
|
||||
@ -590,7 +590,7 @@ namespace NewHorizons.Handlers
|
||||
if (!string.IsNullOrEmpty(body.Config.Atmosphere?.clouds?.texturePath))
|
||||
{
|
||||
CloudsBuilder.Make(go, sector, body.Config.Atmosphere, willHaveCloak, body.Mod);
|
||||
SunOverrideBuilder.Make(go, sector, body.Config.Atmosphere, body.Config.Water, surfaceSize);
|
||||
if (body.Config.Atmosphere.clouds.cloudsPrefab != External.Modules.CloudPrefabType.Transparent) SunOverrideBuilder.Make(go, sector, body.Config.Atmosphere, body.Config.Water, surfaceSize);
|
||||
}
|
||||
|
||||
if (body.Config.Atmosphere.hasRain || body.Config.Atmosphere.hasSnow)
|
||||
|
||||
@ -89,7 +89,7 @@ namespace NewHorizons.Handlers
|
||||
heightMap.minHeight = body.Config.HeightMap.minHeight * size / body.Config.HeightMap.maxHeight;
|
||||
heightMap.stretch = body.Config.HeightMap.stretch;
|
||||
}
|
||||
if (body.Config.Atmosphere?.clouds?.texturePath != null)
|
||||
if (body.Config.Atmosphere?.clouds?.texturePath != null && body.Config.Atmosphere?.clouds?.cloudsPrefab != CloudPrefabType.Transparent)
|
||||
{
|
||||
// Hacky but whatever I just want a sphere
|
||||
size = Mathf.Clamp(body.Config.Atmosphere.size / 10, minSize, maxSize);
|
||||
|
||||
@ -400,12 +400,14 @@
|
||||
"x-enumNames": [
|
||||
"GiantsDeep",
|
||||
"QuantumMoon",
|
||||
"Basic"
|
||||
"Basic",
|
||||
"Transparent"
|
||||
],
|
||||
"enum": [
|
||||
"giantsDeep",
|
||||
"quantumMoon",
|
||||
"basic"
|
||||
"basic",
|
||||
"transparent"
|
||||
]
|
||||
},
|
||||
"FluidType": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user