Boundless
Removed hard zone boundaries Fixed stuff that broke because of hard zone boundary assumption (stardust placement, vertical fog) Added a skybox! Removed density-based albedo boost (_TintExponent) to improve perceptual uniformity at different step sizes, reconfigured shader to achieve / surpass previous looks and performance Cell Brush has a material editor now to enable variant selection Enabled Caching Shader Preprocessor Moved raymarching loop into CloudShader Get environment settings from game manager to enable configuration / variation Introduced slope-based nebulae damping and volumetric flow Hid optional volumetric features behind preprocessor branches Created shader variants selected by global keywords for all shaders depending on volumetrics Environment settings used to configure shader variant selection Moved dynamic lighting settings to own subclass Dynamically adjust gravity map isoline contour depth range according to zone contents
This commit is contained in:
parent
be5e7618d6
commit
69aca09f63
31 changed files with 642 additions and 508 deletions
35
Assets/Scripts/Editor/CellBrushEditor.cs
Normal file
35
Assets/Scripts/Editor/CellBrushEditor.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Linq;
|
||||
|
||||
public class CellBrushEditor : MaterialEditor
|
||||
{
|
||||
private static readonly string[] Keywords = new[] {"A", "B", "C", "D", "E", "F", "G", "H"};
|
||||
|
||||
public override void OnInspectorGUI ()
|
||||
{
|
||||
// Draw the default inspector.
|
||||
base.OnInspectorGUI ();
|
||||
|
||||
// If we are not visible, return.
|
||||
if (!isVisible)
|
||||
return;
|
||||
|
||||
// Get the current keywords from the material
|
||||
Material targetMat = target as Material;
|
||||
string[] keyWords = targetMat.shaderKeywords;
|
||||
|
||||
int selected = keyWords.Any()?Array.IndexOf(Keywords,keyWords.First()):0;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
selected = EditorGUILayout.Popup("Variant", selected, Keywords);
|
||||
|
||||
// If something has changed, update the material.
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
targetMat.shaderKeywords = new []{Keywords[selected]};
|
||||
EditorUtility.SetDirty (targetMat);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Editor/CellBrushEditor.cs.meta
Normal file
11
Assets/Scripts/Editor/CellBrushEditor.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cedd8e9182f02e84ca000e22e71c8b0e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -30,6 +30,7 @@ using Random = UnityEngine.Random;
|
|||
|
||||
public class ActionGameManager : MonoBehaviour
|
||||
{
|
||||
// Always check for null if accessing from anywhere that might not be in-game (e.g. menu UI)
|
||||
public static ActionGameManager Instance { get; private set; }
|
||||
private static DirectoryInfo _gameDataDirectory;
|
||||
public static DirectoryInfo GameDataDirectory
|
||||
|
|
@ -49,9 +50,11 @@ public class ActionGameManager : MonoBehaviour
|
|||
_cultCache.AddBackingStore(new MultiFileJsonBackingStore(GameDataDirectory.FullName));
|
||||
// _cultCache.AddBackingStore(
|
||||
// new SingleFileMessagePackBackingStore(Path.Combine(GameDataDirectory.FullName, "AetherDB.msgpack")));
|
||||
|
||||
// Particularly heavy objects should be stored in / retrieved from MsgPack files as it's much tighter than JSON
|
||||
// Such as NameFiles, which are just huge collections of geonames used to condition Markov chains
|
||||
_cultCache.AddBackingStore(new MultiFileMessagePackBackingStore(GameDataDirectory.FullName), typeof(NameFile));
|
||||
// _cultCache.AddBackingStore(
|
||||
// new MultiFileMessagePackBackingStore(GameDataDirectory.FullName), typeof(NameFile));
|
||||
|
||||
_cultCache.PullAllBackingStores();
|
||||
|
||||
return _cultCache;
|
||||
|
|
@ -119,7 +122,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
public CinemachineVirtualCamera WormholeCamera;
|
||||
//public SectorRenderer SectorRenderer;
|
||||
public SectorMap SectorMap;
|
||||
public VolumeSampling VolumeRenderer;
|
||||
|
||||
[Header("Menu UI")]
|
||||
public MainMenu MainMenu;
|
||||
|
|
@ -194,6 +196,14 @@ public class ActionGameManager : MonoBehaviour
|
|||
//if better place, please move
|
||||
public Entity TowingStation { get; private set; }
|
||||
|
||||
public ZoneEnvironment CurrentEnvironment
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.DefaultEnvironment;
|
||||
}
|
||||
}
|
||||
|
||||
public Entity CurrentEntity
|
||||
{
|
||||
get => _currentEntity;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public class ZoneEnvironment
|
|||
[JsonProperty("nebula"), Key(0)] public NebulaSettings Nebula;
|
||||
[JsonProperty("flow"), Key(1)] public FlowSettings Flow;
|
||||
[JsonProperty("noise"), Key(2)] public NoiseSettings Noise;
|
||||
[JsonProperty("lighting"), Key(2)] public AmbientLightingSettings Lighting;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
|
|
@ -19,31 +20,37 @@ public class NebulaSettings
|
|||
{
|
||||
[JsonProperty("fillDensity"), Key(0)] public float FillDensity;
|
||||
[JsonProperty("fillDistance"), Key(1)] public float FillDistance;
|
||||
[JsonProperty("fillExponent"), Key(11)] public float FillExponent;
|
||||
[JsonProperty("fillExponent"), Key(2)] public float FillExponent;
|
||||
[JsonProperty("fillOffset"), Key(12)] public float FillOffset;
|
||||
[JsonProperty("fogDensity"), Key(2)] public float FloorDensity;
|
||||
[JsonProperty("cloudDensity"), Key(3)] public float PatchDensity;
|
||||
[JsonProperty("fogOffset"), Key(4)] public float FloorOffset;
|
||||
[JsonProperty("fogBlend"), Key(5)] public float FloorBlend;
|
||||
[JsonProperty("cloudBlend"), Key(6)] public float PatchBlend;
|
||||
[JsonProperty("luminance"), Key(7)] public float Luminance;
|
||||
[JsonProperty("extinction"), Key(13)] public float Extinction;
|
||||
[JsonProperty("tintExponent"), Key(8)] public float TintExponent;
|
||||
//[JsonProperty("tintExponent"), Key(8)] public float TintExponent;
|
||||
[JsonProperty("tintLodExponent"), Key(9)] public float TintLodExponent;
|
||||
[JsonProperty("safetyDistance"), Key(10)] public float SafetyDistance;
|
||||
[JsonProperty("dynamicSkyBoost"), Key(14)] public float DynamicSkyBoost;
|
||||
[JsonProperty("dynamicLodRange"), Key(15)] public float DynamicLodRange;
|
||||
[JsonProperty("dynamicLodBias"), Key(16)] public float DynamicLodBias;
|
||||
[JsonProperty("dynamicIntensity"), Key(17)] public float DynamicIntensity;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class AmbientLightingSettings
|
||||
{
|
||||
[JsonProperty("dynamicSkyBoost"), Key(0)] public float DynamicSkyBoost;
|
||||
[JsonProperty("dynamicLodHigh"), Key(1)] public float DynamicLodHigh;
|
||||
[JsonProperty("dynamicLodLow"), Key(2)] public float DynamicLodLow;
|
||||
[JsonProperty("dynamicIntensity"), Key(3)] public float DynamicIntensity;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class FlowSettings
|
||||
{
|
||||
[JsonProperty("scale"), Key(0)] public float Scale;
|
||||
[JsonProperty("amplitude"), Key(1)] public float Amplitude;
|
||||
[JsonProperty("scrollSpeed"), Key(2)] public float ScrollSpeed;
|
||||
[JsonProperty("scale"), Key(0)] public float GlobalScale;
|
||||
[JsonProperty("amplitudeGlobal"), Key(1)] public float GlobalAmplitude;
|
||||
[JsonProperty("scrollSpeed"), Key(2)] public float GlobalScrollSpeed;
|
||||
[JsonProperty("period"), Key(3)] public float Period;
|
||||
[JsonProperty("amplitudeSlope"), Key(4)] public float SlopeAmplitude;
|
||||
[JsonProperty("amplitudeSwirl"), Key(4)] public float SwirlAmplitude;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
|
|
@ -53,6 +60,7 @@ public class NoiseSettings
|
|||
[JsonProperty("amplitude"), Key(1)] public float Amplitude;
|
||||
[JsonProperty("exponent"), Key(2)] public float Exponent;
|
||||
[JsonProperty("speed"), Key(3)] public float Speed;
|
||||
[JsonProperty("slopeExponent"), Key(4)] public float SlopeExponent;
|
||||
}
|
||||
|
||||
[Union(0, typeof(PowerBrush)),
|
||||
|
|
|
|||
|
|
@ -28,6 +28,16 @@ public class VolumeSampling : MonoBehaviour
|
|||
|
||||
private float _flowScroll;
|
||||
private Transform _gridTransform;
|
||||
private GlobalKeyword _keywordFlowGlobal;
|
||||
private GlobalKeyword _keywordFlowSlope;
|
||||
private GlobalKeyword _keywordNoiseSlope;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_keywordFlowGlobal = GlobalKeyword.Create("FLOW_GLOBAL");
|
||||
_keywordFlowSlope = GlobalKeyword.Create("FLOW_SLOPE");
|
||||
_keywordNoiseSlope = GlobalKeyword.Create("NOISE_SLOPE");
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
|
@ -37,40 +47,48 @@ public class VolumeSampling : MonoBehaviour
|
|||
if(GridCamera != null)
|
||||
Shader.SetGlobalVector("_GridTransform", new Vector4(_gridTransform.position.x,_gridTransform.position.z,GridCamera.orthographicSize*2));
|
||||
|
||||
var environment = ActionGameManager.Instance?.CurrentEnvironment ?? Settings.DefaultEnvironment;
|
||||
|
||||
// Volumetric sampling parameters are used by several shaders
|
||||
Shader.SetGlobalTexture("_NebulaSurfaceHeight", NebulaSurfaceHeight);
|
||||
Shader.SetGlobalTexture("_NebulaPatchHeight", NebulaPatchHeight);
|
||||
Shader.SetGlobalTexture("_NebulaPatch", NebulaPatch);
|
||||
Shader.SetGlobalTexture("_NebulaTint", NebulaTint);
|
||||
|
||||
Shader.SetGlobalFloat("_NebulaFillDensity", Settings.DefaultEnvironment.Nebula.FillDensity);
|
||||
Shader.SetGlobalFloat("_NebulaFillDistance", Settings.DefaultEnvironment.Nebula.FillDistance);
|
||||
Shader.SetGlobalFloat("_NebulaFillExponent", Settings.DefaultEnvironment.Nebula.FillExponent);
|
||||
Shader.SetGlobalFloat("_NebulaFillOffset", Settings.DefaultEnvironment.Nebula.FillOffset);
|
||||
Shader.SetGlobalFloat("_NebulaFloorDensity", Settings.DefaultEnvironment.Nebula.FloorDensity);
|
||||
Shader.SetGlobalFloat("_NebulaPatchDensity", Settings.DefaultEnvironment.Nebula.PatchDensity);
|
||||
Shader.SetGlobalFloat("_NebulaFloorOffset", Settings.DefaultEnvironment.Nebula.FloorOffset);
|
||||
Shader.SetGlobalFloat("_NebulaFloorBlend", Settings.DefaultEnvironment.Nebula.FloorBlend);
|
||||
Shader.SetGlobalFloat("_NebulaPatchBlend", Settings.DefaultEnvironment.Nebula.PatchBlend);
|
||||
Shader.SetGlobalFloat("_NebulaLuminance", Settings.DefaultEnvironment.Nebula.Luminance);
|
||||
Shader.SetGlobalFloat("_ExtinctionCoefficient", Settings.DefaultEnvironment.Nebula.Extinction);
|
||||
Shader.SetGlobalFloat("_TintExponent", Settings.DefaultEnvironment.Nebula.TintExponent);
|
||||
Shader.SetGlobalFloat("_TintLodExponent", Settings.DefaultEnvironment.Nebula.TintLodExponent);
|
||||
Shader.SetGlobalFloat("_SafetyDistance", Settings.DefaultEnvironment.Nebula.SafetyDistance);
|
||||
Shader.SetGlobalFloat("_DynamicSkyBoost", Settings.DefaultEnvironment.Nebula.DynamicSkyBoost);
|
||||
Shader.SetGlobalFloat("_DynamicLodRange", Settings.DefaultEnvironment.Nebula.DynamicLodRange);
|
||||
Shader.SetGlobalFloat("_DynamicLodBias", Settings.DefaultEnvironment.Nebula.DynamicLodBias);
|
||||
Shader.SetGlobalFloat("_DynamicIntensity", Settings.DefaultEnvironment.Nebula.DynamicIntensity);
|
||||
Shader.SetGlobalFloat("_NebulaFillDensity", environment.Nebula.FillDensity);
|
||||
Shader.SetGlobalFloat("_NebulaFillDistance", environment.Nebula.FillDistance);
|
||||
Shader.SetGlobalFloat("_NebulaFillExponent", environment.Nebula.FillExponent);
|
||||
Shader.SetGlobalFloat("_NebulaFillOffset", environment.Nebula.FillOffset);
|
||||
Shader.SetGlobalFloat("_NebulaPatchDensity", environment.Nebula.PatchDensity);
|
||||
Shader.SetGlobalFloat("_NebulaFloorOffset", environment.Nebula.FloorOffset);
|
||||
Shader.SetGlobalFloat("_NebulaFloorBlend", environment.Nebula.FloorBlend);
|
||||
Shader.SetGlobalFloat("_NebulaPatchBlend", environment.Nebula.PatchBlend);
|
||||
Shader.SetGlobalFloat("_NebulaLuminance", environment.Nebula.Luminance);
|
||||
Shader.SetGlobalFloat("_ExtinctionCoefficient", environment.Nebula.Extinction);
|
||||
Shader.SetGlobalFloat("_TintLodExponent", environment.Nebula.TintLodExponent);
|
||||
Shader.SetGlobalFloat("_SafetyDistance", environment.Nebula.SafetyDistance);
|
||||
|
||||
Shader.SetGlobalFloat("_NebulaNoiseScale", Settings.DefaultEnvironment.Noise.Scale);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseExponent", Settings.DefaultEnvironment.Noise.Exponent);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseAmplitude", Settings.DefaultEnvironment.Noise.Amplitude);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseSpeed", Settings.DefaultEnvironment.Noise.Speed);
|
||||
Shader.SetGlobalFloat("_DynamicSkyBoost", environment.Lighting.DynamicSkyBoost);
|
||||
Shader.SetGlobalFloat("_DynamicLodHigh", environment.Lighting.DynamicLodHigh);
|
||||
Shader.SetGlobalFloat("_DynamicLodLow", environment.Lighting.DynamicLodLow);
|
||||
Shader.SetGlobalFloat("_DynamicIntensity", environment.Lighting.DynamicIntensity);
|
||||
|
||||
Shader.SetGlobalFloat("_FlowScale", Settings.DefaultEnvironment.Flow.Scale);
|
||||
Shader.SetGlobalFloat("_FlowAmplitude", Settings.DefaultEnvironment.Flow.Amplitude);
|
||||
_flowScroll += Settings.DefaultEnvironment.Flow.ScrollSpeed * Time.deltaTime;
|
||||
Shader.SetGlobalFloat("_NebulaNoiseScale", environment.Noise.Scale);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseExponent", environment.Noise.Exponent);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseAmplitude", environment.Noise.Amplitude);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseSpeed", environment.Noise.Speed);
|
||||
Shader.SetGlobalFloat("_NebulaNoiseSlopeExponent", environment.Noise.SlopeExponent);
|
||||
|
||||
Shader.SetGlobalFloat("_FlowScale", environment.Flow.GlobalScale);
|
||||
Shader.SetGlobalFloat("_FlowAmplitude", environment.Flow.GlobalAmplitude);
|
||||
Shader.SetGlobalFloat("_FlowSlopeAmplitude", environment.Flow.SlopeAmplitude);
|
||||
Shader.SetGlobalFloat("_FlowSwirlAmplitude", environment.Flow.SwirlAmplitude);
|
||||
_flowScroll += environment.Flow.GlobalScrollSpeed * Time.deltaTime;
|
||||
Shader.SetGlobalFloat("_FlowScroll", _flowScroll);
|
||||
Shader.SetGlobalFloat("_FlowPeriod", Settings.DefaultEnvironment.Flow.Period);
|
||||
Shader.SetGlobalFloat("_FlowPeriod", environment.Flow.Period);
|
||||
|
||||
Shader.SetKeyword(_keywordFlowGlobal, environment.Flow.GlobalAmplitude != 0);
|
||||
Shader.SetKeyword(_keywordFlowSlope, environment.Flow.SlopeAmplitude != 0 || environment.Flow.SwirlAmplitude != 0);
|
||||
Shader.SetKeyword(_keywordNoiseSlope, environment.Noise.SlopeExponent != 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
public GridObject CompoundCommodityPickup;
|
||||
public GridObject GearPickup;
|
||||
public GridObject WeaponPickup;
|
||||
public Material[] MapGravityMaterials;
|
||||
|
||||
[Header("Tour")] public bool Tour;
|
||||
public float TourSwitchTime = 5f;
|
||||
|
|
@ -547,11 +548,14 @@ public class ZoneRenderer : MonoBehaviour
|
|||
//var fogPos = FogCameraParent.position;
|
||||
SectorBoundaryBrush.material.SetFloat("_Power", Settings.PlanetSettings.ZoneDepthExponent);
|
||||
SectorBoundaryBrush.material.SetFloat("_Depth", Settings.PlanetSettings.ZoneDepth + Settings.PlanetSettings.ZoneBoundaryFog);
|
||||
// var startDepth = Zone.PowerPulse(Settings.MinimapZoneGravityRange, Settings.PlanetSettings.ZoneDepthExponent) *
|
||||
// Settings.PlanetSettings.ZoneDepth;
|
||||
//var depthRange = Settings.PlanetSettings.ZoneDepth - startDepth + _maxDepth;
|
||||
// MinimapGravityQuad.material.SetFloat("_StartDepth", startDepth);
|
||||
// MinimapGravityQuad.material.SetFloat("_DepthRange", depthRange);
|
||||
var startDepth = Zone.PowerPulse(Settings.MinimapZoneGravityRange, Settings.PlanetSettings.ZoneDepthExponent) *
|
||||
Settings.PlanetSettings.ZoneDepth;
|
||||
var depthRange = Settings.PlanetSettings.ZoneDepth - startDepth + _maxDepth;
|
||||
foreach (var mat in MapGravityMaterials)
|
||||
{
|
||||
mat.SetFloat("_StartDepth", startDepth);
|
||||
mat.SetFloat("_DepthRange", depthRange);
|
||||
}
|
||||
//Shader.SetGlobalFloat("_GridOffset", Settings.PlanetSettings.ZoneBoundaryFog);
|
||||
// var gravPos = MinimapGravityQuad.transform.position;
|
||||
// gravPos.y = -Settings.PlanetSettings.ZoneDepth - _maxDepth;
|
||||
|
|
|
|||
Loading…
Reference in a new issue