portals and dash. Also a bit of terrain building and level design

This commit is contained in:
2022-03-13 00:26:35 +02:00
parent 813cd0c451
commit e82799c36a
6242 changed files with 2160679 additions and 188245 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 96444dd15c9a29843b69d6b602a3d706
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 83b687eddf2507540b2ba1002e73c202
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d02815eee0ae46e41ad0d69e53162cd8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 085a183f1c941974bb3f5f9f4943425d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.Callbacks;
namespace Pinwheel.Jupiter
{
internal class JCompileLogger
{
private const string PACKAGE_NAME = "Jupiter - Low Poly Sky And Weather System";
private const string PACKAGE_NAME_PLACEHOLDER = "${PACKAGE_NAME}";
private const string WEBSITE = "http://pinwheel.studio";
private const string WEBSITE_PLACEHOLDER = "${WEBSITE}";
private const string SUPPORT_MAIL = "support@pinwheel.studio";
private const string SUPPORT_MAIL_PLACEHOLDER = "${SUPPORT_MAIL}";
private const string LINK_COLOR = "blue";
private const string LINK_COLOR_PLACEHOLDER = "${LC}";
private const float LOG_MESSAGE_PROBABIILITY = 0.03F;
private static string[] messages = new string[]
{
"Thanks for using the ${PACKAGE_NAME}, please contact <color=${LC}>${SUPPORT_MAIL}</color> for support!",
"Thanks for using the ${PACKAGE_NAME}, please give it a 5-stars rating and a positive review on the store!"
};
//[DidReloadScripts]
public static void ShowMessageOnCompileSucceeded()
{
ValidatePackageAndNamespace();
if (Random.value < LOG_MESSAGE_PROBABIILITY)
{
if (messages.Length == 0)
return;
int msgIndex = Random.Range(0, messages.Length);
string msg = messages[msgIndex]
.Replace(PACKAGE_NAME_PLACEHOLDER, JVersionInfo.ProductNameAndVersionShort)
.Replace(WEBSITE_PLACEHOLDER, WEBSITE)
.Replace(SUPPORT_MAIL_PLACEHOLDER, SUPPORT_MAIL)
.Replace(LINK_COLOR_PLACEHOLDER, LINK_COLOR);
Debug.Log(msg, null);
}
}
private static void ValidatePackageAndNamespace()
{
bool isPackageNameInvalid = PACKAGE_NAME.Equals("PACKAGE_NAME");
bool isNamespaceInvalid = typeof(JCompileLogger).Namespace.Contains("PACKAGE_NAME");
if (isPackageNameInvalid)
{
string message = "<color=red>Invalid PACKAGE_NAME in CompileLogger, fix it before release!</color>";
Debug.Log(message);
}
if (isNamespaceInvalid)
{
string message = "<color=red>Invalid NAMESPACE in CompileLogger, fix it before release!</color>";
Debug.Log(message);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce55681244a3d7340ac0377c305e70d5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f0c378e47d1e02b45bc362a927a1f184
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,151 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace Pinwheel.Jupiter
{
public static class JEditorMenus
{
[MenuItem("GameObject/3D Object/Jupiter Sky/Sunny Day")]
public static JSky CreateSunnyDaySky(MenuCommand cmd)
{
GameObject g = new GameObject("Sunny Day Sky");
if (cmd != null && cmd.context != null)
{
GameObject root = cmd.context as GameObject;
GameObjectUtility.SetParentAndAlign(g, root);
}
JSky skyComponent = g.AddComponent<JSky>();
JSkyProfile profile = JSkyProfile.CreateInstance<JSkyProfile>();
string fileName = "SkyProfile-" + JCommon.GetUniqueID();
string filePath = string.Format("Assets/{0}.asset", fileName);
AssetDatabase.CreateAsset(profile, filePath);
profile.CopyFrom(JJupiterSettings.Instance.DefaultProfileSunnyDay);
skyComponent.Profile = profile;
skyComponent.MoonLightSource = null;
Light[] lights = Object.FindObjectsOfType<Light>();
for (int i = 0; i < lights.Length; ++i)
{
if (lights[i].type == LightType.Directional)
{
skyComponent.SunLightSource = lights[i];
break;
}
}
return skyComponent;
}
[MenuItem("GameObject/3D Object/Jupiter Sky/Starry Night")]
public static JSky CreateStarryNightSky(MenuCommand cmd)
{
GameObject g = new GameObject("Starry Night Sky");
if (cmd != null && cmd.context != null)
{
GameObject root = cmd.context as GameObject;
GameObjectUtility.SetParentAndAlign(g, root);
}
JSky skyComponent = g.AddComponent<JSky>();
JSkyProfile profile = JSkyProfile.CreateInstance<JSkyProfile>();
string fileName = "SkyProfile-" + JCommon.GetUniqueID();
string filePath = string.Format("Assets/{0}.asset", fileName);
AssetDatabase.CreateAsset(profile, filePath);
profile.CopyFrom(JJupiterSettings.Instance.DefaultProfileStarryNight);
skyComponent.Profile = profile;
skyComponent.SunLightSource = null;
Light[] lights = Object.FindObjectsOfType<Light>();
for (int i = 0; i < lights.Length; ++i)
{
if (lights[i].type == LightType.Directional)
{
skyComponent.MoonLightSource = lights[i];
break;
}
}
return skyComponent;
}
[MenuItem("Window/Jupiter/Tools/Cubemap Creator")]
public static void ShowCubemapCreator()
{
JCubemapCreatorWindow.ShowWindow();
}
[MenuItem("Window/Jupiter/Project/Settings")]
public static void ShowSettings()
{
Selection.activeObject = JJupiterSettings.Instance;
}
[MenuItem("Window/Jupiter/Project/Version Info")]
public static void ShowVersionInfo()
{
EditorUtility.DisplayDialog(
"Version Info",
JVersionInfo.ProductNameAndVersion,
"OK");
}
[MenuItem("Window/Jupiter/Project/Update Dependencies")]
public static void UpdateDependencies()
{
JPackageInitializer.Init();
}
[MenuItem("Window/Jupiter/Learning Resources/Youtube Channel")]
public static void ShowYoutubeChannel()
{
Application.OpenURL(JCommon.YOUTUBE_CHANNEL);
}
[MenuItem("Window/Jupiter/Learning Resources/Online Manual")]
public static void ShowOnlineManual()
{
Application.OpenURL(JCommon.ONLINE_MANUAL);
}
[MenuItem("Window/Jupiter/Community/Forum")]
public static void ShowForum()
{
Application.OpenURL(JCommon.FORUM);
}
[MenuItem("Window/Jupiter/Community/Discord")]
public static void ShowDiscord()
{
Application.OpenURL(JCommon.DISCORD);
}
[MenuItem("Window/Jupiter/Contact/Support")]
public static void ShowSupportEmailEditor()
{
JEditorCommon.OpenEmailEditor(
JCommon.SUPPORT_EMAIL,
"[Jupiter] SHORT_QUESTION_HERE",
"YOUR_QUESTION_IN_DETAIL");
}
[MenuItem("Window/Jupiter/Contact/Business")]
public static void ShowBusinessEmailEditor()
{
JEditorCommon.OpenEmailEditor(
JCommon.BUSINESS_EMAIL,
"[Jupiter] SHORT_MESSAGE_HERE",
"YOUR_MESSAGE_IN_DETAIL");
}
[MenuItem("Window/Jupiter/Leave a Review")]
public static void OpenStorePage()
{
Application.OpenURL("http://u3d.as/1Hry");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8003db96cc44b774993bca3e76fc0b65
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,124 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Callbacks;
using System;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
namespace Pinwheel.Jupiter
{
public static class JPackageInitializer
{
public delegate void InitCompletedHandler();
public static event InitCompletedHandler Completed;
public static string JUPITER_KW = "JUPITER";
private static ListRequest listPackageRequest = null;
#pragma warning disable 0414
#pragma warning restore 0414
[DidReloadScripts]
public static void Init()
{
CheckThirdPartyPackages();
CheckUnityPackagesAndInit();
}
private static void CheckThirdPartyPackages()
{
}
private static void CheckUnityPackagesAndInit()
{
listPackageRequest = Client.List(true);
EditorApplication.update += OnRequestingPackageList;
}
private static void OnRequestingPackageList()
{
if (listPackageRequest == null)
return;
if (!listPackageRequest.IsCompleted)
return;
if (listPackageRequest.Error != null)
{
}
else
{
foreach (UnityEditor.PackageManager.PackageInfo p in listPackageRequest.Result)
{
}
}
EditorApplication.update -= OnRequestingPackageList;
InitPackage();
}
private static void InitPackage()
{
BuildTarget buildTarget = EditorUserBuildSettings.activeBuildTarget;
BuildTargetGroup buildGroup = BuildPipeline.GetBuildTargetGroup(buildTarget);
string symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildGroup);
List<string> symbolList = new List<string>(symbols.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries));
bool isDirty = false;
if (!symbolList.Contains(JUPITER_KW))
{
symbolList.Add(JUPITER_KW);
isDirty = true;
}
if (isDirty)
{
symbols = symbolList.ListElementsToString(";");
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildGroup, symbols);
}
if (Completed != null)
{
Completed.Invoke();
}
}
private static bool SetKeywordActive(List<string> kwList, string keyword, bool active)
{
bool isDirty = false;
if (active && !kwList.Contains(keyword))
{
kwList.Add(keyword);
isDirty = true;
}
else if (!active && kwList.Contains(keyword))
{
kwList.RemoveAll(s => s.Equals(keyword));
isDirty = true;
}
return isDirty;
}
public static List<System.Type> GetAllLoadedTypes()
{
List<System.Type> loadedTypes = new List<System.Type>();
List<string> typeName = new List<string>();
foreach (var assembly in System.AppDomain.CurrentDomain.GetAssemblies())
{
foreach (var t in assembly.GetTypes())
{
if (t.IsVisible && !t.IsGenericType)
{
typeName.Add(t.Name);
loadedTypes.Add(t);
}
}
}
return loadedTypes;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 996904e2726a51e41b8099fac3469ad1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,361 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace Pinwheel.Jupiter
{
[CustomEditor(typeof(JSky))]
public class JSkyInspector : Editor
{
private JSky sky;
private JSkyProfile profile;
private JDayNightCycle dnc;
private const string DNC_LABEL = "Controlled by Day Night Cycle";
private void OnEnable()
{
sky = target as JSky;
profile = sky.Profile;
}
public override void OnInspectorGUI()
{
sky.Profile = JEditorCommon.ScriptableObjectField<JSkyProfile>("Profile", sky.Profile);
profile = sky.Profile;
if (sky.Profile == null)
return;
dnc = sky.GetComponent<JDayNightCycle>();
DrawSceneReferencesGUI();
EditorGUI.BeginChangeCheck();
DrawSkyGUI();
DrawStarsGUI();
DrawSunGUI();
DrawMoonGUI();
DrawHorizonCloudGUI();
DrawOverheadCloudGUI();
DrawDetailOverlayGUI();
DrawUtilitiesGUI();
if (EditorGUI.EndChangeCheck())
{
profile.UpdateMaterialProperties();
EditorUtility.SetDirty(sky);
EditorUtility.SetDirty(profile);
}
DrawAddDayNightCycleGUI();
}
private void DrawSceneReferencesGUI()
{
string label = "Scene References";
string id = "scene-references";
JEditorCommon.Foldout(label, false, id, () =>
{
sky.SunLightSource = EditorGUILayout.ObjectField("Sun Light Source", sky.SunLightSource, typeof(Light), true) as Light;
sky.MoonLightSource = EditorGUILayout.ObjectField("Moon Light Source", sky.MoonLightSource, typeof(Light), true) as Light;
});
}
private void DrawSkyGUI()
{
string label = "Sky";
string id = "sky" + profile.GetInstanceID(); ;
JEditorCommon.Foldout(label, false, id, () =>
{
profile.SkyColor = ColorField("Sky Color", profile.SkyColor, true, true, true, nameof(profile.SkyColor));
profile.HorizonColor = ColorField("Horizon Color", profile.HorizonColor, true, true, true, nameof(profile.HorizonColor));
profile.GroundColor = ColorField("Ground Color", profile.GroundColor, true, true, true, nameof(profile.GroundColor));
if (profile.AllowStepEffect)
{
profile.HorizonStep = EditorGUILayout.IntField("Horizon Step", profile.HorizonStep);
}
profile.HorizonExponent = FloatField("Horizon Exponent", profile.HorizonExponent, nameof(profile.HorizonExponent));
profile.HorizonThickness = Slider("Horizon Thickness", profile.HorizonThickness, 0f, 1f, nameof(profile.HorizonThickness));
profile.FogSyncOption = (JFogSyncOption)EditorGUILayout.EnumPopup("Fog Sync", profile.FogSyncOption);
if (profile.FogSyncOption == JFogSyncOption.CustomColor)
{
profile.FogColor = ColorField("Fog Color", profile.FogColor, true, true, false, nameof(profile.FogColor));
}
});
}
private void DrawStarsGUI()
{
string label = "Stars";
string id = "stars" + profile.GetInstanceID(); ;
JEditorCommon.Foldout(label, false, id, () =>
{
profile.EnableStars = EditorGUILayout.Toggle("Enable", profile.EnableStars);
if (profile.EnableStars)
{
profile.UseBakedStars = EditorGUILayout.Toggle("Baked", profile.UseBakedStars);
}
if (profile.EnableStars && !profile.UseBakedStars)
{
profile.StarsStartPosition = Slider("Start", profile.StarsStartPosition, -1, 1, nameof(profile.StarsStartPosition));
profile.StarsEndPosition = Slider("End", profile.StarsEndPosition, -1, 1, nameof(profile.StarsEndPosition));
profile.StarsOpacity = Slider("Opacity", profile.StarsOpacity, 0f, 1f, nameof(profile.StarsOpacity));
profile.StarsLayerCount = EditorGUILayout.DelayedIntField("Layers", profile.StarsLayerCount);
if (profile.StarsLayerCount > 0)
{
JEditorCommon.Separator();
EditorGUILayout.LabelField("Layer 0");
EditorGUI.indentLevel += 1;
profile.StarsColor0 = ColorField("Color", profile.StarsColor0, true, true, true, nameof(profile.StarsColor0));
profile.StarsDensity0 = Slider("Density", profile.StarsDensity0, 0.01f, 1f, nameof(profile.StarsDensity0));
profile.StarsSize0 = Slider("Size", profile.StarsSize0, 0.01f, 1f, nameof(profile.StarsSize0));
profile.StarsGlow0 = Slider("Glow", profile.StarsGlow0, 0f, 1f, nameof(profile.StarsGlow0));
profile.StarsTwinkle0 = FloatField("Twinkle", profile.StarsTwinkle0, nameof(profile.StarsTwinkle0));
EditorGUI.indentLevel -= 1;
}
if (profile.StarsLayerCount > 1)
{
JEditorCommon.Separator();
EditorGUILayout.LabelField("Layer 1");
EditorGUI.indentLevel += 1;
profile.StarsColor1 = ColorField("Color", profile.StarsColor1, true, true, true, nameof(profile.StarsColor1));
profile.StarsDensity1 = Slider("Density", profile.StarsDensity1, 0.01f, 1f, nameof(profile.StarsDensity1));
profile.StarsSize1 = Slider("Size", profile.StarsSize1, 0.01f, 1f, nameof(profile.StarsSize1));
profile.StarsGlow1 = Slider("Glow", profile.StarsGlow1, 0f, 1f, nameof(profile.StarsGlow1));
profile.StarsTwinkle1 = FloatField("Twinkle", profile.StarsTwinkle1, nameof(profile.StarsTwinkle1));
EditorGUI.indentLevel -= 1;
}
if (profile.StarsLayerCount > 2)
{
JEditorCommon.Separator();
EditorGUILayout.LabelField("Layer 2");
EditorGUI.indentLevel += 1;
profile.StarsColor2 = ColorField("Color", profile.StarsColor2, true, true, true, nameof(profile.StarsColor2));
profile.StarsDensity2 = Slider("Density", profile.StarsDensity2, 0.01f, 1f, nameof(profile.StarsDensity2));
profile.StarsSize2 = Slider("Size", profile.StarsSize2, 0.01f, 1f, nameof(profile.StarsSize2));
profile.StarsGlow2 = Slider("Glow", profile.StarsGlow2, 0f, 1f, nameof(profile.StarsGlow2));
profile.StarsTwinkle2 = FloatField("Twinkle", profile.StarsTwinkle2, nameof(profile.StarsTwinkle2));
EditorGUI.indentLevel -= 1;
}
}
if (profile.EnableStars && profile.UseBakedStars)
{
profile.StarsCubemap = JEditorCommon.InlineCubemapField("Cubemap", profile.StarsCubemap, -1);
profile.StarsTwinkleMap = JEditorCommon.InlineTexture2DField("Twinkle Map", profile.StarsTwinkleMap, -1);
profile.StarsOpacity = Slider("Opacity", profile.StarsOpacity, 0f, 1f, nameof(profile.StarsOpacity));
}
});
}
private void DrawSunGUI()
{
string label = "Sun";
string id = "sun" + profile.GetInstanceID(); ;
JEditorCommon.Foldout(label, false, id, () =>
{
profile.EnableSun = EditorGUILayout.Toggle("Enable", profile.EnableSun);
if (profile.EnableSun)
{
profile.UseBakedSun = EditorGUILayout.Toggle("Baked", profile.UseBakedSun);
}
if (profile.EnableSun && !profile.UseBakedSun)
{
profile.SunTexture = JEditorCommon.InlineTexture2DField("Texture", profile.SunTexture, -1);
profile.SunColor = ColorField("Color", profile.SunColor, true, true, true, nameof(profile.SunColor));
profile.SunSize = Slider("Size", profile.SunSize, 0f, 1f, nameof(profile.SunSize));
profile.SunSoftEdge = Slider("Soft Edge", profile.SunSoftEdge, 0f, 1f, nameof(profile.SunSoftEdge));
profile.SunGlow = Slider("Glow", profile.SunGlow, 0f, 1f, nameof(profile.SunGlow));
}
if (profile.EnableSun && profile.UseBakedSun)
{
profile.SunCubemap = JEditorCommon.InlineCubemapField("Cubemap", profile.SunCubemap, -1);
}
if (profile.EnableSun)
{
profile.SunLightColor = ColorField("Light Color", profile.SunLightColor, true, false, false, nameof(profile.SunLightColor));
profile.SunLightIntensity = FloatField("Light Intensity", profile.SunLightIntensity, nameof(profile.SunLightIntensity));
}
});
}
private void DrawMoonGUI()
{
string label = "Moon";
string id = "moon" + profile.GetInstanceID(); ;
JEditorCommon.Foldout(label, false, id, () =>
{
profile.EnableMoon = EditorGUILayout.Toggle("Enable", profile.EnableMoon);
if (profile.EnableMoon)
{
profile.UseBakedMoon = EditorGUILayout.Toggle("Baked", profile.UseBakedMoon);
}
if (profile.EnableMoon && !profile.UseBakedMoon)
{
profile.MoonTexture = JEditorCommon.InlineTexture2DField("Texture", profile.MoonTexture, -1);
profile.MoonColor = ColorField("Color", profile.MoonColor, true, true, true, nameof(profile.MoonColor));
profile.MoonSize = Slider("Size", profile.MoonSize, 0f, 1f, nameof(profile.MoonSize));
profile.MoonSoftEdge = Slider("Soft Edge", profile.MoonSoftEdge, 0f, 1f, nameof(profile.MoonSoftEdge));
profile.MoonGlow = Slider("Glow", profile.MoonGlow, 0f, 1f, nameof(profile.MoonGlow));
}
if (profile.EnableMoon && profile.UseBakedMoon)
{
profile.MoonCubemap = JEditorCommon.InlineCubemapField("Cubemap", profile.MoonCubemap, -1);
}
if (profile.EnableMoon)
{
profile.MoonLightColor = ColorField("Light Color", profile.MoonLightColor, true, false, false, nameof(profile.MoonLightColor));
profile.MoonLightIntensity = FloatField("Light Intensity", profile.MoonLightIntensity, nameof(profile.MoonLightIntensity));
}
});
}
private void DrawHorizonCloudGUI()
{
string label = "Horizon Cloud";
string id = "horizon-cloud" + profile.GetInstanceID(); ;
JEditorCommon.Foldout(label, false, id, () =>
{
profile.EnableHorizonCloud = EditorGUILayout.Toggle("Enable", profile.EnableHorizonCloud);
if (profile.EnableHorizonCloud)
{
profile.CustomCloudTexture = JEditorCommon.InlineTexture2DField("Texture", profile.CustomCloudTexture, -1);
profile.HorizonCloudColor = ColorField("Color", profile.HorizonCloudColor, true, true, false, nameof(profile.HorizonCloudColor));
profile.HorizonCloudStartPosition = Slider("Start", profile.HorizonCloudStartPosition, -1, 1, nameof(profile.HorizonCloudStartPosition));
profile.HorizonCloudEndPosition = Slider("End", profile.HorizonCloudEndPosition, -1, 1, nameof(profile.HorizonCloudEndPosition));
profile.HorizonCloudSize = FloatField("Size", profile.HorizonCloudSize, nameof(profile.HorizonCloudSize));
if (profile.AllowStepEffect)
{
profile.HorizonCloudStep = EditorGUILayout.IntField("Step", profile.HorizonCloudStep);
}
profile.HorizonCloudAnimationSpeed = FloatField("Animation Speed", profile.HorizonCloudAnimationSpeed, nameof(profile.HorizonCloudAnimationSpeed));
}
});
}
private void DrawOverheadCloudGUI()
{
string label = "Overhead Cloud";
string id = "overhead-cloud" + profile.GetInstanceID(); ;
JEditorCommon.Foldout(label, false, id, () =>
{
profile.EnableOverheadCloud = EditorGUILayout.Toggle("Enable", profile.EnableOverheadCloud);
if (profile.EnableOverheadCloud)
{
profile.CustomCloudTexture = JEditorCommon.InlineTexture2DField("Texture", profile.CustomCloudTexture, -1);
profile.OverheadCloudColor = ColorField("Color", profile.OverheadCloudColor, true, true, false, nameof(profile.OverheadCloudColor));
profile.OverheadCloudAltitude = FloatField("Altitude", profile.OverheadCloudAltitude, nameof(profile.OverheadCloudAltitude));
profile.OverheadCloudSize = FloatField("Size", profile.OverheadCloudSize, nameof(profile.OverheadCloudSize));
if (profile.AllowStepEffect)
{
profile.OverheadCloudStep = EditorGUILayout.IntField("Step", profile.OverheadCloudStep);
}
profile.OverheadCloudAnimationSpeed = FloatField("Animation Speed", profile.OverheadCloudAnimationSpeed, nameof(profile.OverheadCloudAnimationSpeed));
profile.OverheadCloudFlowDirectionX = Slider("Flow X", profile.OverheadCloudFlowDirectionX, -1, 1, nameof(profile.OverheadCloudFlowDirectionX));
profile.OverheadCloudFlowDirectionZ = Slider("Flow Z", profile.OverheadCloudFlowDirectionZ, -1, 1, nameof(profile.OverheadCloudFlowDirectionZ));
profile.OverheadCloudRemapMin = FloatField("Remap Min", profile.OverheadCloudRemapMin, nameof(profile.OverheadCloudRemapMin));
profile.OverheadCloudRemapMax = FloatField("Remap Max", profile.OverheadCloudRemapMax, nameof(profile.OverheadCloudRemapMax));
profile.OverheadCloudCastShadow = EditorGUILayout.Toggle("Cast Shadow (Experimental)", profile.OverheadCloudCastShadow);
if (profile.OverheadCloudCastShadow)
{
profile.OverheadCloudShadowClipMask = EditorGUILayout.Slider("Clip Mask", profile.OverheadCloudShadowClipMask, 0f, 1f);
}
}
});
}
private void DrawDetailOverlayGUI()
{
string label = "Detail Overlay";
string id = "detail-overlay" + profile.GetInstanceID(); ;
JEditorCommon.Foldout(label, false, id, () =>
{
profile.EnableDetailOverlay = EditorGUILayout.Toggle("Enable", profile.EnableDetailOverlay);
if (profile.EnableDetailOverlay)
{
profile.DetailOverlayTintColor = ColorField("Color", profile.DetailOverlayTintColor, true, true, false, nameof(profile.DetailOverlayTintColor));
profile.DetailOverlayCubeMap = JEditorCommon.InlineCubemapField("Cubemap", profile.DetailOverlayCubeMap, -1);
profile.DetailOverlayLayer = (JDetailOverlayLayer)EditorGUILayout.EnumPopup("Layer", profile.DetailOverlayLayer);
profile.DetailOverlayRotationSpeed = FloatField("Rotation Speed", profile.DetailOverlayRotationSpeed, nameof(profile.DetailOverlayRotationSpeed));
}
});
}
private void DrawUtilitiesGUI()
{
string label = "Utilities";
string id = "utilities" + profile.GetInstanceID(); ;
JEditorCommon.Foldout(label, false, id, () =>
{
profile.AllowStepEffect = EditorGUILayout.Toggle("Allow Step Effect", profile.AllowStepEffect);
});
}
private void DrawAddDayNightCycleGUI()
{
JDayNightCycle cycle = sky.GetComponent<JDayNightCycle>();
if (cycle != null)
return;
string label = "Day Night Cycle";
string id = "day-night-cycle" + sky.GetInstanceID();
JEditorCommon.Foldout(label, false, id, () =>
{
if (GUILayout.Button("Add Day Night Cycle"))
{
sky.gameObject.AddComponent<JDayNightCycle>();
}
});
}
private Color ColorField(string label, Color color, bool colorPicker, bool alpha, bool hdr, string propName)
{
if (dnc != null && dnc.enabled == true && dnc.Profile != null && dnc.Profile.ContainProperty(propName))
{
EditorGUILayout.LabelField(label, DNC_LABEL, JEditorCommon.ItalicLabel);
return color;
}
else
{
return EditorGUILayout.ColorField(new GUIContent(label), color, colorPicker, alpha, hdr);
}
}
private float FloatField(string label, float value, string propName)
{
if (dnc != null && dnc.enabled == true && dnc.Profile != null && dnc.Profile.ContainProperty(propName))
{
EditorGUILayout.LabelField(label, DNC_LABEL, JEditorCommon.ItalicLabel);
return value;
}
else
{
return EditorGUILayout.FloatField(label, value);
}
}
private float Slider(string label, float value, float min, float max, string propName)
{
if (dnc != null && dnc.enabled == true && dnc.Profile != null && dnc.Profile.ContainProperty(propName))
{
EditorGUILayout.LabelField(label, DNC_LABEL, JEditorCommon.ItalicLabel);
return value;
}
else
{
return EditorGUILayout.Slider(label, value, min, max);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b7ef7541219a5d438eb1d140ff29d73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace Pinwheel.Jupiter
{
[CustomEditor(typeof(JSkyProfile))]
public class JSkyProfileInspector : Editor
{
private JSkyProfile instance;
private void OnEnable()
{
instance = target as JSkyProfile;
}
public override void OnInspectorGUI()
{
EditorGUILayout.LabelField("Select the sky object in the scene to edit this profile.", JEditorCommon.WordWrapItalicLabel);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 51d8b71d564080a4ab2d06d2f5ba64cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3ba4fba9fb114d14daca8699b76b14b8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,394 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using System.Reflection;
using System;
using UnityEngine.Rendering;
namespace Pinwheel.Jupiter
{
[CustomEditor(typeof(JDayNightCycle))]
public class JDayNightCycleInspector : Editor
{
private static List<JAnimatedProperty> allProperties;
private static List<JAnimatedProperty> AllProperties
{
get
{
if (allProperties == null)
{
allProperties = new List<JAnimatedProperty>();
}
return allProperties;
}
set
{
allProperties = value;
}
}
static JDayNightCycleInspector()
{
InitAllAnimatableProperties();
}
private static void InitAllAnimatableProperties()
{
AllProperties.Clear();
Type type = typeof(JSkyProfile);
PropertyInfo[] props = type.GetProperties();
for (int i = 0; i < props.Length; ++i)
{
Attribute att = props[i].GetCustomAttribute(typeof(JAnimatableAttribute));
if (att != null)
{
JAnimatableAttribute animAtt = att as JAnimatableAttribute;
AllProperties.Add(JAnimatedProperty.Create(props[i].Name, animAtt.DisplayName, animAtt.CurveOrGradient));
}
}
}
private JDayNightCycle cycle;
private JDayNightCycleProfile profile;
bool isTimeFoldoutExpanded;
private static readonly int[] resolutionValues = new int[]
{
16,32,64,128,256,512,1024,2048
};
private static readonly string[] resolutionLabels = new string[]
{
"16","32","64","128","256","512","1024","2048"
};
private void OnEnable()
{
cycle = target as JDayNightCycle;
profile = cycle.Profile;
}
public override void OnInspectorGUI()
{
cycle.Profile = JEditorCommon.ScriptableObjectField<JDayNightCycleProfile>("Profile", cycle.Profile);
profile = cycle.Profile;
if (cycle.Profile == null)
return;
DrawSceneReferencesGUI();
DrawTimeGUI();
EditorGUI.BeginChangeCheck();
DrawSkyGUI();
DrawStarsGUI();
DrawSunGUI();
DrawMoonGUI();
DrawHorizonCloudGUI();
DrawOverheadCloudGUI();
DrawDetailOverlayGUI();
DrawEnvironmentReflectionGUI();
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(cycle);
EditorUtility.SetDirty(profile);
}
}
private void DrawSceneReferencesGUI()
{
string label = "Scene References";
string id = "scene-ref" + cycle.GetInstanceID();
JEditorCommon.Foldout(label, false, id, () =>
{
cycle.Sky = EditorGUILayout.ObjectField("Sky", cycle.Sky, typeof(JSky), true) as JSky;
cycle.SunOrbitPivot = EditorGUILayout.ObjectField("Orbit Pivot", cycle.SunOrbitPivot, typeof(Transform), true) as Transform;
});
}
private void DrawTimeGUI()
{
string label = "Time";
string id = "time" + cycle.GetInstanceID();
isTimeFoldoutExpanded = JEditorCommon.Foldout(label, false, id, () =>
{
cycle.StartTime = EditorGUILayout.FloatField("Start Time", cycle.StartTime);
cycle.TimeIncrement = EditorGUILayout.FloatField("Time Increment", cycle.TimeIncrement);
GUI.enabled = !cycle.AutoTimeIncrement;
cycle.Time = EditorGUILayout.Slider("Time", cycle.Time, 0f, 24f);
GUI.enabled = true;
cycle.AutoTimeIncrement = EditorGUILayout.Toggle("Auto", cycle.AutoTimeIncrement);
});
}
private void DrawSkyGUI()
{
string label = "Sky";
string id = "sky" + profile.GetInstanceID();
JEditorCommon.Foldout(label, false, id, () =>
{
DisplayAddedProperties("Sky");
if (GUILayout.Button("Add"))
{
DisplayAllPropertiesAsContext("Sky");
}
});
}
private void DrawStarsGUI()
{
string label = "Stars";
string id = "stars" + profile.GetInstanceID();
JEditorCommon.Foldout(label, false, id, () =>
{
DisplayAddedProperties("Stars");
if (GUILayout.Button("Add"))
{
DisplayAllPropertiesAsContext("Stars");
}
});
}
private void DrawSunGUI()
{
string label = "Sun";
string id = "sun" + profile.GetInstanceID();
JEditorCommon.Foldout(label, false, id, () =>
{
cycle.UseSunPivot = EditorGUILayout.Toggle("Custom Pivot", cycle.UseSunPivot);
if (cycle.UseSunPivot)
{
cycle.SunOrbitPivot = EditorGUILayout.ObjectField("Pivot", cycle.SunOrbitPivot, typeof(Transform), true) as Transform;
}
JEditorCommon.Separator();
DisplayAddedProperties("Sun");
if (GUILayout.Button("Add"))
{
DisplayAllPropertiesAsContext("Sun");
}
});
}
private void DrawMoonGUI()
{
string label = "Moon";
string id = "moon" + profile.GetInstanceID();
JEditorCommon.Foldout(label, false, id, () =>
{
cycle.UseMoonPivot = EditorGUILayout.Toggle("Custom Pivot", cycle.UseMoonPivot);
if (cycle.UseMoonPivot)
{
cycle.MoonOrbitPivot = EditorGUILayout.ObjectField("Pivot", cycle.MoonOrbitPivot, typeof(Transform), true) as Transform;
}
JEditorCommon.Separator();
DisplayAddedProperties("Moon");
if (GUILayout.Button("Add"))
{
DisplayAllPropertiesAsContext("Moon");
}
});
}
private void DrawHorizonCloudGUI()
{
string label = "Horizon Cloud";
string id = "horizon-cloud" + profile.GetInstanceID();
JEditorCommon.Foldout(label, false, id, () =>
{
DisplayAddedProperties("Horizon Cloud");
if (GUILayout.Button("Add"))
{
DisplayAllPropertiesAsContext("Horizon Cloud");
}
});
}
private void DrawOverheadCloudGUI()
{
string label = "Overhead Cloud";
string id = "overhead-cloud" + profile.GetInstanceID();
JEditorCommon.Foldout(label, false, id, () =>
{
DisplayAddedProperties("Overhead Cloud");
if (GUILayout.Button("Add"))
{
DisplayAllPropertiesAsContext("Overhead Cloud");
}
});
}
private void DrawDetailOverlayGUI()
{
string label = "Detail Overlay";
string id = "detail-overlay" + profile.GetInstanceID();
JEditorCommon.Foldout(label, false, id, () =>
{
DisplayAddedProperties("Detail Overlay");
if (GUILayout.Button("Add"))
{
DisplayAllPropertiesAsContext("Detail Overlay");
}
});
}
private void DrawEnvironmentReflectionGUI()
{
string label = "Environment Reflection";
string id = "env-reflection";
JEditorCommon.Foldout(label, false, id, () =>
{
cycle.ShouldUpdateEnvironmentReflection = EditorGUILayout.Toggle("Enable", cycle.ShouldUpdateEnvironmentReflection);
if (cycle.ShouldUpdateEnvironmentReflection)
{
cycle.EnvironmentReflectionResolution = EditorGUILayout.IntPopup("Resolution", cycle.EnvironmentReflectionResolution, resolutionLabels, resolutionValues);
cycle.EnvironmentReflectionTimeSlicingMode = (ReflectionProbeTimeSlicingMode)EditorGUILayout.EnumPopup("Time Slicing", cycle.EnvironmentReflectionTimeSlicingMode);
EditorGUILayout.LabelField("Realtime Reflection Probe must be enabled in Quality Settings.", JEditorCommon.WordWrapItalicLabel);
}
});
}
private void DisplayAddedProperties(string group)
{
EditorGUI.indentLevel -= 1;
JAnimatedProperty toRemoveProp = null;
List<JAnimatedProperty> props = profile.AnimatedProperties.FindAll(p => p.DisplayName.StartsWith(group));
for (int i = 0; i < props.Count; ++i)
{
EditorGUILayout.BeginHorizontal();
JAnimatedProperty p = props[i];
if (GUILayout.Button("▬", EditorStyles.miniLabel, GUILayout.Width(12)))
{
toRemoveProp = p;
}
string itemLabel = p.DisplayName.Substring(p.DisplayName.IndexOf("/") + 1);
itemLabel = ObjectNames.NicifyVariableName(itemLabel);
if (p.CurveOrGradient == JCurveOrGradient.Curve)
{
p.Curve = EditorGUILayout.CurveField(itemLabel, p.Curve);
}
else
{
p.Gradient = EditorGUILayout.GradientField(new GUIContent(itemLabel), p.Gradient, true);
}
EditorGUILayout.EndHorizontal();
}
if (props.Count > 0)
{
JEditorCommon.Separator();
}
if (toRemoveProp != null)
{
profile.AnimatedProperties.Remove(toRemoveProp);
}
EditorGUI.indentLevel += 1;
}
private void DisplayAllPropertiesAsContext(string group)
{
GenericMenu menu = new GenericMenu();
List<JAnimatedProperty> props = AllProperties.FindAll(p => p.DisplayName.StartsWith(group));
if (props.Count == 0)
{
menu.AddDisabledItem(new GUIContent("No item found"));
menu.ShowAsContext();
return;
}
for (int i = 0; i < props.Count; ++i)
{
JAnimatedProperty p = props[i];
string itemLabel = p.DisplayName.Substring(p.DisplayName.IndexOf("/") + 1);
bool added = profile.AnimatedProperties.FindIndex(p0 => p0.Name.Equals(p.Name)) >= 0;
if (added)
{
menu.AddDisabledItem(new GUIContent(itemLabel));
}
else
{
menu.AddItem(
new GUIContent(itemLabel),
false,
() =>
{
profile.AddProperty(p);
});
}
}
menu.ShowAsContext();
}
public override bool RequiresConstantRepaint()
{
return isTimeFoldoutExpanded;
}
private void OnSceneGUI()
{
if (cycle == null)
return;
float evalTime = Mathf.InverseLerp(0f, 24f, cycle.Time);
if (cycle.Sky.Profile.EnableSun && cycle.Sky.SunLightSource != null)
{
Color c = cycle.Sky.Profile.SunColor;
c.a = Mathf.Max(0.1f, c.a);
Transform pivot = (cycle.UseSunPivot && cycle.SunOrbitPivot != null) ? cycle.SunOrbitPivot : cycle.transform;
Vector3 normal = pivot.right;
Handles.color = c;
float radius = 10;
Handles.DrawWireDisc(pivot.position, normal, radius);
float angle = evalTime * 360f;
Matrix4x4 localRotationMatrix = Matrix4x4.Rotate(Quaternion.Euler(angle, 0, 0));
Vector3 localDirection = localRotationMatrix.MultiplyVector(Vector3.up);
Matrix4x4 localToWorld = pivot.localToWorldMatrix;
Vector3 worldDirection = localToWorld.MultiplyVector(localDirection);
Vector3 worldPos = pivot.transform.position - worldDirection * radius;
Handles.color = c;
Handles.DrawSolidDisc(worldPos, normal, 1);
}
if (cycle.Sky.Profile.EnableMoon && cycle.Sky.MoonLightSource != null)
{
Color c = cycle.Sky.Profile.MoonColor;
c.a = Mathf.Max(0.1f, c.a);
Transform pivot = (cycle.UseMoonPivot && cycle.MoonOrbitPivot != null) ? cycle.MoonOrbitPivot : cycle.transform;
Vector3 normal = pivot.right;
Handles.color = c;
float radius = 10;
Handles.DrawWireDisc(pivot.position, normal, radius);
float angle = evalTime * 360f;
Matrix4x4 localRotationMatrix = Matrix4x4.Rotate(Quaternion.Euler(angle, 0, 0));
Vector3 localDirection = localRotationMatrix.MultiplyVector(Vector3.down);
Matrix4x4 localToWorld = pivot.localToWorldMatrix;
Vector3 worldDirection = localToWorld.MultiplyVector(localDirection);
Vector3 worldPos = pivot.transform.position - worldDirection * radius;
Handles.color = c;
Handles.DrawSolidDisc(worldPos, normal, 1);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 71909ab86f782f647a2dec01e5b6b5e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace Pinwheel.Jupiter
{
[CustomEditor(typeof(JDayNightCycleProfile))]
public class JDayNightCycleProfileInspector : Editor
{
private JDayNightCycleProfile instance;
private void OnEnable()
{
instance = target as JDayNightCycleProfile;
}
public override void OnInspectorGUI()
{
EditorGUILayout.LabelField("Select the sky object in the scene to edit this profile.", JEditorCommon.WordWrapItalicLabel);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d687dcdcf19ef14eb838a32e165bee8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 16b9f95f849d38a4f9ba66ad73d90316
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,170 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Pinwheel.Jupiter;
using UnityEditor;
using System.IO;
namespace Pinwheel.Jupiter
{
public class JCubemapCreatorWindow : EditorWindow
{
public Vector3 CameraPosition { get; set; }
public float CameraNearPlane { get; set; }
public float CameraFarPlane { get; set; }
public CameraClearFlags CameraClearFlag { get; set; }
public Color CameraBackgroundColor { get; set; }
public int Resolution { get; set; }
public bool ExportFaceTextures { get; set; }
public string Directory { get; set; }
public static readonly int[] ResolutionValues = new int[] { 16, 32, 64, 128, 256, 512, 1024, 2048 };
public static readonly string[] ResolutionLabels = new string[] { "16", "32", "64", "128", "256", "512", "1024", "2048" };
public const string PREF_PREFIX = "cubemap-creator";
public const string CAM_POS_X = "cam-pos-x";
public const string CAM_POS_Y = "cam-pos-y";
public const string CAM_POS_Z = "cam-pos-z";
public const string CAM_NEAR_PLANE = "cam-near-plane";
public const string CAM_FAR_PLANE = "cam-far-plane";
public const string CAM_CLEAR_FLAG = "cam-clear-flag";
public const string CAM_BG_COLOR = "cam-background-color";
public const string RESOLUTION = "resolution";
public const string EXPORT_FACE_TEXTURES = "export-face-textures";
public const string DIRECTORY = "directory";
public static void ShowWindow()
{
JCubemapCreatorWindow window = EditorWindow.CreateInstance<JCubemapCreatorWindow>();
window.titleContent = new GUIContent("Cubemap Creator");
window.minSize = new Vector2(400, 300);
window.Show();
}
private void OnEnable()
{
float x = EditorPrefs.GetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_POS_X), 0);
float y = EditorPrefs.GetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_POS_Y), 0);
float z = EditorPrefs.GetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_POS_Z), 0);
CameraPosition = new Vector3(x, y, z);
CameraNearPlane = EditorPrefs.GetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_NEAR_PLANE), 0);
CameraFarPlane = EditorPrefs.GetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_FAR_PLANE), 1000);
CameraClearFlag = (CameraClearFlags)EditorPrefs.GetInt(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_CLEAR_FLAG), 0);
string htmlColor = EditorPrefs.GetString(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_BG_COLOR), "FFFFFF");
Color c = Color.white;
ColorUtility.TryParseHtmlString("#" + htmlColor, out c);
CameraBackgroundColor = c;
Resolution = EditorPrefs.GetInt(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, RESOLUTION), 512);
ExportFaceTextures = EditorPrefs.GetBool(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, EXPORT_FACE_TEXTURES), false);
Directory = EditorPrefs.GetString(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, DIRECTORY), "Assets/");
}
private void OnDisable()
{
EditorPrefs.SetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_POS_X), CameraPosition.x);
EditorPrefs.SetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_POS_Y), CameraPosition.y);
EditorPrefs.SetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_POS_Z), CameraPosition.z);
EditorPrefs.SetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_NEAR_PLANE), CameraNearPlane);
EditorPrefs.SetFloat(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_FAR_PLANE), CameraFarPlane);
EditorPrefs.SetInt(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_CLEAR_FLAG), (int)CameraClearFlag);
EditorPrefs.SetString(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, CAM_BG_COLOR), ColorUtility.ToHtmlStringRGB(CameraBackgroundColor));
EditorPrefs.SetInt(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, RESOLUTION), Resolution);
EditorPrefs.SetBool(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, EXPORT_FACE_TEXTURES), ExportFaceTextures);
EditorPrefs.SetString(JEditorCommon.GetProjectRelatedEditorPrefsKey(PREF_PREFIX, DIRECTORY), Directory);
}
private void OnGUI()
{
DrawExportGUI();
}
private void DrawExportGUI()
{
string label = "Export";
string id = "export" + GetInstanceID();
JEditorCommon.Foldout(label, true, id, () =>
{
CameraPosition = JEditorCommon.InlineVector3Field("Position", CameraPosition);
CameraNearPlane = EditorGUILayout.FloatField("Near Plane", CameraNearPlane);
CameraFarPlane = EditorGUILayout.FloatField("Far Plane", CameraFarPlane);
CameraClearFlag = (CameraClearFlags)EditorGUILayout.EnumPopup("Clear Flags", CameraClearFlag);
if (CameraClearFlag == CameraClearFlags.Color)
{
CameraBackgroundColor = EditorGUILayout.ColorField("Background Color", CameraBackgroundColor);
}
Resolution = EditorGUILayout.IntPopup("Resolution", Resolution, ResolutionLabels, ResolutionValues);
ExportFaceTextures = EditorGUILayout.Toggle("Export Face Textures", ExportFaceTextures);
string dir = Directory;
JEditorCommon.BrowseFolder("Directory", ref dir);
Directory = dir;
GUI.enabled = !string.IsNullOrEmpty(Directory);
if (GUILayout.Button("Export"))
{
Export();
}
GUI.enabled = true;
});
}
private void Export()
{
JUtilities.EnsureDirectoryExists(Directory);
Cubemap cube = new Cubemap(Resolution, TextureFormat.ARGB32, false);
JCubemapRendererArgs args = new JCubemapRendererArgs()
{
CameraPosition = this.CameraPosition,
CameraNearPlane = this.CameraNearPlane,
CameraFarPlane = this.CameraFarPlane,
CameraClearFlag = this.CameraClearFlag,
CameraBackgroundColor = this.CameraBackgroundColor,
Resolution = this.Resolution,
Cubemap = cube,
Face = (CubemapFace)63
};
JCubemapRenderer.Render(args);
string fileName = Path.Combine(Directory, "Cubemap-" + JCommon.GetUniqueID() + ".cubemap");
AssetDatabase.CreateAsset(cube, fileName);
if (ExportFaceTextures)
{
ExportFace(cube, CubemapFace.PositiveX);
ExportFace(cube, CubemapFace.NegativeX);
ExportFace(cube, CubemapFace.PositiveY);
ExportFace(cube, CubemapFace.NegativeY);
ExportFace(cube, CubemapFace.PositiveZ);
ExportFace(cube, CubemapFace.NegativeZ);
}
AssetDatabase.Refresh();
EditorGUIUtility.PingObject(cube);
Selection.activeObject = cube;
}
private void ExportFace(Cubemap cube, CubemapFace face)
{
Texture2D tex = new Texture2D(cube.width, cube.height);
Color[] data = cube.GetPixels(face);
Color[] flipData = new Color[data.Length];
for (int y = 0; y < Resolution; ++y)
{
for (int x = 0; x < Resolution; ++x)
{
flipData[JUtilities.To1DIndex(x, y, Resolution)] = data[JUtilities.To1DIndex(Resolution - 1 - x, Resolution - 1 - y, Resolution)];
}
}
tex.SetPixels(flipData);
tex.Apply();
byte[] bytes = tex.EncodeToPNG();
string fileName = Path.Combine(Directory, cube.name + "-" + face.ToString() + ".png");
File.WriteAllBytes(fileName, bytes);
JUtilities.DestroyObject(tex);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7aee1f13740ef4c438b6a59a60558865
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,138 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace Pinwheel.Jupiter
{
public class JTwoPaneWindowWindow : EditorWindow
{
protected float toolbarHeight = EditorGUIUtility.singleLineHeight;
protected int toolbarOffsetX = 4;
protected int toolbarOverflowY = 5;
protected int rightPaneWidth = 300;
protected int rightPaneWidthMin = 200;
protected int rightPaneWidthMax = 400;
protected int resizeRectWidth = 10;
protected bool isResizinng = false;
protected Vector2 rightPaneScrollPos;
protected Rect LeftPaneRect
{
get
{
Rect r = new Rect();
r.size = new Vector2(position.size.x - rightPaneWidth, position.size.y - toolbarHeight - toolbarOverflowY);
r.position = new Vector2(0, toolbarHeight + toolbarOverflowY);
return r;
}
}
protected Rect RightPaneRect
{
get
{
Rect r = new Rect();
r.size = new Vector2(rightPaneWidth, position.size.y - toolbarHeight - toolbarOverflowY);
r.position = new Vector2(position.size.x - rightPaneWidth, toolbarHeight + toolbarOverflowY);
return r;
}
}
protected Rect ResizePaneRect
{
get
{
Rect r = new Rect();
r.position = new Vector2(position.size.x - rightPaneWidth - resizeRectWidth * 0.5f, toolbarHeight + toolbarOverflowY);
r.size = new Vector2(resizeRectWidth, position.size.y - toolbarHeight - toolbarOverflowY);
return r;
}
}
public void OnGUI()
{
DrawToolbar();
DrawLeftPane();
DrawRightPane();
HandleResize();
HandleRepaint();
}
private void DrawToolbar()
{
Rect r = EditorGUILayout.GetControlRect();
RectOffset offset = new RectOffset(toolbarOffsetX, toolbarOffsetX, 0, 0);
GUI.Box(offset.Add(r), string.Empty, EditorStyles.toolbar);
OnToolbarGUI(r);
}
protected virtual void OnToolbarGUI(Rect r)
{
}
private void DrawLeftPane()
{
OnLeftPaneGUI(LeftPaneRect);
}
protected virtual void OnLeftPaneGUI(Rect r)
{
}
private void DrawRightPane()
{
Color separatorColor = JEditorCommon.boxBorderColor;
JEditorCommon.DrawLine(
new Vector2(RightPaneRect.min.x - 2, RightPaneRect.min.y - 2),
new Vector2(RightPaneRect.min.x - 2, RightPaneRect.max.y),
separatorColor);
GUILayout.BeginArea(RightPaneRect);
rightPaneScrollPos = EditorGUILayout.BeginScrollView(rightPaneScrollPos);
OnRightPaneScrollViewGUI();
EditorGUILayout.EndScrollView();
GUILayout.EndArea();
}
protected virtual void OnRightPaneScrollViewGUI()
{
}
private void HandleResize()
{
EditorGUIUtility.AddCursorRect(ResizePaneRect, MouseCursor.ResizeHorizontal);
if (Event.current == null)
return;
if (Event.current.type == EventType.MouseDown &&
ResizePaneRect.Contains(Event.current.mousePosition))
{
isResizinng = true;
}
else if (Event.current.type == EventType.MouseUp)
{
isResizinng = false;
}
if (isResizinng)
{
rightPaneWidth = (int)(position.size.x - Event.current.mousePosition.x);
rightPaneWidth = Mathf.Clamp(rightPaneWidth, rightPaneWidthMin, rightPaneWidthMax);
}
}
private void HandleRepaint()
{
if (Event.current == null)
return;
Repaint();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 34a2ea782a08e8c4ab155ddec745b699
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c8552727fbfc7144e957efcb4abc7144
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e28879aacec79e14a8f9510e45449678
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 73519ac058dab824498b577d8bcac265
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 038b4db3822d0934bafe44586a5925fe
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,193 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &-7953337332898741536
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Jupiter/Sky
m_Shader: {fileID: 4800000, guid: 3129e3b90193a0547900ecf4cf4e9864, type: 3}
m_ShaderKeywords: ALLOW_STEP_EFFECT HORIZON_CLOUD MOON OVERHEAD_CLOUD STARS STARS_LAYER_0
STARS_LAYER_1 STARS_LAYER_2
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _DetailOverlayCubemap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MoonCubemap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MoonTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _StarsCubemap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _StarsTwinkleMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SunCubemap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SunTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _DetailOverlayLayer: 0
- _DetailOverlayRotationSpeed: 0
- _HorizonCloudAnimationSpeed: 50
- _HorizonCloudEnd: 0.35
- _HorizonCloudSize: 4.47
- _HorizonCloudStart: -0.01
- _HorizonCloudStep: 25
- _HorizonExponent: 5
- _HorizonStep: 1000
- _HorizonThickness: 1
- _MoonGlow: 0.24
- _MoonSize: 0.07
- _MoonSoftEdge: 0.22
- _OverheadCloudAltitude: 1000
- _OverheadCloudAnimationSpeed: 50
- _OverheadCloudFlowX: 1
- _OverheadCloudFlowZ: 1
- _OverheadCloudSize: 10
- _OverheadCloudStep: 2
- _StarsDensity0: 0.4
- _StarsDensity1: 0.34
- _StarsDensity2: 0.45
- _StarsEnd: 1
- _StarsGlow0: 0.01
- _StarsGlow1: 0.01
- _StarsGlow2: 0.01
- _StarsOpacity: 1
- _StarsSize0: 0.42
- _StarsSize1: 0.53
- _StarsSize2: 0.46
- _StarsStart: 0.25
- _StarsTwinkle0: 5
- _StarsTwinkle1: 6
- _StarsTwinkle2: 2
- _SunGlow: 0
- _SunSize: 0
- _SunSoftEdge: 0
m_Colors:
- _DetailOverlayColor: {r: 0, g: 0, b: 0, a: 0}
- _GroundColor: {r: 0.1981132, g: 0.1981132, b: 0.1981132, a: 1}
- _HorizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
- _HorizonColor: {r: 0.38431373, g: 0.48638386, b: 0.6509804, a: 1}
- _MoonColor: {r: 1, g: 1, b: 1, a: 1}
- _MoonDirection: {r: 0, g: 0, b: 1, a: 0}
- _OverheadCloudColor: {r: 1, g: 1, b: 1, a: 0.09803922}
- _SkyColor: {r: 0.10090523, g: 0.06363475, b: 0.20754719, a: 1}
- _StarsColor0: {r: 0.9254902, g: 0.88081425, b: 0.5432628, a: 1}
- _StarsColor1: {r: 1, g: 0.24056602, b: 0.8628801, a: 1}
- _StarsColor2: {r: 0, g: 0.8351569, b: 1, a: 1}
- _SunColor: {r: 0, g: 0, b: 0, a: 0}
- _SunDirection: {r: -1, g: -1, b: -1, a: 0}
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fa5278d11d9502245b5cc174a196561b, type: 3}
m_Name: StarryNight
m_EditorClassIdentifier:
skyColor: {r: 0.10090523, g: 0.06363475, b: 0.20754719, a: 1}
horizonColor: {r: 0.38431373, g: 0.48638386, b: 0.6509804, a: 1}
groundColor: {r: 0.1981132, g: 0.1981132, b: 0.1981132, a: 1}
horizonThickness: 1
horizonExponent: 5
horizonStep: 1000
fogSyncOption: 2
fogColor: {r: 0, g: 0, b: 0, a: 0}
enableStars: 1
starsStartPosition: 0.25
starsEndPosition: 1
starsOpacity: 1
starsLayerCount: 3
starsColor0: {r: 0.9254902, g: 0.88081425, b: 0.5432628, a: 1}
starsColor1: {r: 1, g: 0.24056602, b: 0.8628801, a: 1}
starsColor2: {r: 0, g: 0.8351569, b: 1, a: 1}
starsDensity0: 0.4
starsDensity1: 0.34
starsDensity2: 0.45
starsSize0: 0.42
starsSize1: 0.53
starsSize2: 0.46
starsGlow0: 0.01
starsGlow1: 0.01
starsGlow2: 0.01
starsTwinkle0: 5
starsTwinkle1: 6
starsTwinkle2: 2
useBakedStars: 0
starsCubemap: {fileID: 0}
starsTwinkleMap: {fileID: 0}
enableSun: 0
sunTexture: {fileID: 0}
sunColor: {r: 0, g: 0, b: 0, a: 0}
sunSize: 0
sunSoftEdge: 0
sunGlow: 0
useBakedSun: 0
sunCubemap: {fileID: 0}
sunLightColor: {r: 0, g: 0, b: 0, a: 0}
sunLightIntensity: 0
enableMoon: 1
moonTexture: {fileID: 0}
moonColor: {r: 1, g: 1, b: 1, a: 1}
moonSize: 0.07
moonSoftEdge: 0.22
moonGlow: 0.24
useBakedMoon: 0
moonCubemap: {fileID: 0}
moonLightColor: {r: 0.8443396, g: 0.9841163, b: 1, a: 1}
moonLightIntensity: 0.2
customCloudTexture: {fileID: 0}
enableHorizonCloud: 1
horizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
horizonCloudStartPosition: -0.01
horizonCloudEndPosition: 0.35
horizonCloudSize: 4.47
horizonCloudStep: 25
horizonCloudAnimationSpeed: 50
enableOverheadCloud: 1
overheadCloudColor: {r: 1, g: 1, b: 1, a: 0.09803922}
overheadCloudAltitude: 1000
overheadCloudSize: 10
overheadCloudStep: 2
overheadCloudAnimationSpeed: 50
overheadCloudFlowDirectionX: 1
overheadCloudFlowDirectionZ: 1
overheadCloudRemapMin: 0
overheadCloudRemapMax: 1
overheadCloudCastShadow: 0
overheadCloudShadowClipMask: 0
enableDetailOverlay: 0
detailOverlayTintColor: {r: 0, g: 0, b: 0, a: 0}
detailOverlayCubeMap: {fileID: 0}
detailOverlayLayer: 0
detailOverlayRotationSpeed: 0
allowStepEffect: 1
material: {fileID: -7953337332898741536}
shadowMaterial: {fileID: 0}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8585bdf0dc6491649be0609424d9661b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,192 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fa5278d11d9502245b5cc174a196561b, type: 3}
m_Name: SunnyDay
m_EditorClassIdentifier:
skyColor: {r: 0.2264151, g: 0.6028122, b: 0.9056604, a: 1}
horizonColor: {r: 1, g: 0.94944346, b: 0.839, a: 1}
groundColor: {r: 0.4339623, g: 0.4339623, b: 0.4339623, a: 1}
horizonThickness: 1
horizonExponent: 3
horizonStep: 500
fogSyncOption: 2
fogColor: {r: 0, g: 0, b: 0, a: 0}
enableStars: 0
starsStartPosition: 0
starsEndPosition: 0
starsOpacity: 0
starsLayerCount: 0
starsColor0: {r: 0, g: 0, b: 0, a: 0}
starsColor1: {r: 0, g: 0, b: 0, a: 0}
starsColor2: {r: 0, g: 0, b: 0, a: 0}
starsDensity0: 0
starsDensity1: 0
starsDensity2: 0
starsSize0: 0
starsSize1: 0
starsSize2: 0
starsGlow0: 0
starsGlow1: 0
starsGlow2: 0
starsTwinkle0: 0
starsTwinkle1: 0
starsTwinkle2: 0
useBakedStars: 0
starsCubemap: {fileID: 0}
starsTwinkleMap: {fileID: 0}
enableSun: 1
sunTexture: {fileID: 0}
sunColor: {r: 1, g: 0.9700814, b: 0.9009434, a: 1}
sunSize: 0.07
sunSoftEdge: 0.5
sunGlow: 0.45
useBakedSun: 0
sunCubemap: {fileID: 0}
sunLightColor: {r: 1, g: 0.9929226, b: 0.9009434, a: 1}
sunLightIntensity: 1
enableMoon: 0
moonTexture: {fileID: 0}
moonColor: {r: 0, g: 0, b: 0, a: 0}
moonSize: 0
moonSoftEdge: 0
moonGlow: 0
useBakedMoon: 0
moonCubemap: {fileID: 0}
moonLightColor: {r: 0, g: 0, b: 0, a: 0}
moonLightIntensity: 0
customCloudTexture: {fileID: 0}
enableHorizonCloud: 0
horizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
horizonCloudStartPosition: -0.1
horizonCloudEndPosition: 0.65
horizonCloudSize: 4.91
horizonCloudStep: 25
horizonCloudAnimationSpeed: 50
enableOverheadCloud: 1
overheadCloudColor: {r: 1, g: 1, b: 1, a: 0.5647059}
overheadCloudAltitude: 1000
overheadCloudSize: 10
overheadCloudStep: 2
overheadCloudAnimationSpeed: 50
overheadCloudFlowDirectionX: 1
overheadCloudFlowDirectionZ: 1
overheadCloudRemapMin: 0
overheadCloudRemapMax: 1
overheadCloudCastShadow: 0
overheadCloudShadowClipMask: 0
enableDetailOverlay: 1
detailOverlayTintColor: {r: 0, g: 0, b: 0, a: 0}
detailOverlayCubeMap: {fileID: 0}
detailOverlayLayer: 0
detailOverlayRotationSpeed: 0
allowStepEffect: 1
material: {fileID: 683795580653540547}
shadowMaterial: {fileID: 0}
--- !u!21 &683795580653540547
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Jupiter/Sky
m_Shader: {fileID: 4800000, guid: 3129e3b90193a0547900ecf4cf4e9864, type: 3}
m_ShaderKeywords: ALLOW_STEP_EFFECT DETAIL_OVERLAY OVERHEAD_CLOUD SUN
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _DetailOverlayCubemap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MoonCubemap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MoonTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _StarsCubemap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _StarsTwinkleMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SunCubemap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SunTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _DetailOverlayLayer: 0
- _DetailOverlayRotationSpeed: 0
- _HorizonCloudAnimationSpeed: 50
- _HorizonCloudEnd: 0.65
- _HorizonCloudSize: 4.91
- _HorizonCloudStart: -0.1
- _HorizonCloudStep: 25
- _HorizonExponent: 3
- _HorizonStep: 500
- _HorizonThickness: 1
- _MoonGlow: 0
- _MoonSize: 0
- _MoonSoftEdge: 0
- _OverheadCloudAltitude: 1000
- _OverheadCloudAnimationSpeed: 50
- _OverheadCloudFlowX: 1
- _OverheadCloudFlowZ: 1
- _OverheadCloudSize: 10
- _OverheadCloudStep: 2
- _StarsDensity0: 0
- _StarsDensity1: 0
- _StarsDensity2: 0
- _StarsEnd: 0
- _StarsGlow0: 0
- _StarsGlow1: 0
- _StarsGlow2: 0
- _StarsOpacity: 0
- _StarsSize0: 0
- _StarsSize1: 0
- _StarsSize2: 0
- _StarsStart: 0
- _StarsTwinkle0: 0
- _StarsTwinkle1: 0
- _StarsTwinkle2: 0
- _SunGlow: 0.45
- _SunSize: 0.07
- _SunSoftEdge: 0.5
m_Colors:
- _DetailOverlayColor: {r: 0, g: 0, b: 0, a: 0}
- _GroundColor: {r: 0.4339623, g: 0.4339623, b: 0.4339623, a: 1}
- _HorizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
- _HorizonColor: {r: 1, g: 0.94944346, b: 0.839, a: 1}
- _MoonColor: {r: 0, g: 0, b: 0, a: 0}
- _MoonDirection: {r: 1, g: 1, b: 1, a: 0}
- _OverheadCloudColor: {r: 1, g: 1, b: 1, a: 0.5647059}
- _SkyColor: {r: 0.2264151, g: 0.6028122, b: 0.9056604, a: 1}
- _StarsColor0: {r: 0, g: 0, b: 0, a: 0}
- _StarsColor1: {r: 0, g: 0, b: 0, a: 0}
- _StarsColor2: {r: 0, g: 0, b: 0, a: 0}
- _SunColor: {r: 1, g: 0.9700814, b: 0.9009434, a: 1}
- _SunDirection: {r: -0.3213938, g: -0.76604444, b: 0.5566705, a: 0}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b4b856d2b3d3c164fbcf5c87fc2abee2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5a4f409a17acb104fa9d13ff1ea7478c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4602ffc9ae1863b4b9155331571220f2, type: 3}
m_Name: JupiterSettings
m_EditorClassIdentifier:
defaultSkybox: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
noiseTexture: {fileID: 2800000, guid: 7f313a2cde54f8e4ba19db94edca915b, type: 3}
cloudTexture: {fileID: 2800000, guid: 433abcf8c760aa746a5580cd0a190b51, type: 3}
defaultProfileSunnyDay: {fileID: 11400000, guid: b4b856d2b3d3c164fbcf5c87fc2abee2,
type: 2}
defaultProfileStarryNight: {fileID: 11400000, guid: 8585bdf0dc6491649be0609424d9661b,
type: 2}
defaultDayNightCycleProfile: {fileID: 11400000, guid: 038b4db3822d0934bafe44586a5925fe,
type: 2}
internalShaders:
skyShader: {fileID: 4800000, guid: 3129e3b90193a0547900ecf4cf4e9864, type: 3}
skyShadowShader: {fileID: 4800000, guid: 561c1777fd66e5d488ef1b85ed82bbaa, type: 3}
copyTextureShader: {fileID: 4800000, guid: b3f0e74bdb60b6b478290fc44ebf68f6, type: 3}
solidColorShader: {fileID: 4800000, guid: 3fe9e551ea5d3fe41b879f13cf0e6a1b, type: 3}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 304bf31ea7c9c5443812ff14450b262f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 77a4334784cc50642aaed74a662c3a10
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 803df85fca46f2042afbffbbfcb2fef3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,485 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine.Rendering;
using DateTime = System.DateTime;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Pinwheel.Jupiter
{
public static class JCommon
{
public static string SUPPORT_EMAIL = "support@pinwheel.studio";
public static string BUSINESS_EMAIL = "hello@pinwheel.studio";
public static string YOUTUBE_CHANNEL = "https://www.youtube.com/channel/UCebwuk5CfIe5kolBI9nuBTg";
public static string ONLINE_MANUAL = "https://docs.google.com/document/d/1Wf4CDlD96c6tna1ee0fpquWkdSrGDIO-eKuQDxjJedY/edit?usp=sharing";
public static string FORUM = "https://forum.unity.com/threads/pre-released-jupiter-procedural-sky-builtin-lwrp-urp.799635/";
public static string DISCORD = "https://discord.gg/HXNnFpS";
public const int PREVIEW_TEXTURE_SIZE = 512;
public const int TEXTURE_SIZE_MIN = 1;
public const int TEXTURE_SIZE_MAX = 8192;
public static JRenderPipelineType CurrentRenderPipeline
{
get
{
string pipelineName = Shader.globalRenderPipeline;
if (pipelineName.Equals("UniversalPipeline,LightweightPipeline"))
{
return JRenderPipelineType.Universal;
}
else if (pipelineName.Equals("LightweightPipeline"))
{
return JRenderPipelineType.Lightweight;
}
else
{
return JRenderPipelineType.Builtin;
}
}
}
private static Vector2[] fullRectUvPoints;
public static Vector2[] FullRectUvPoints
{
get
{
if (fullRectUvPoints == null)
{
fullRectUvPoints = new Vector2[]
{
Vector2.zero,
Vector2.up,
Vector2.one,
Vector2.right
};
}
return fullRectUvPoints;
}
}
private static Mesh emptyMesh;
public static Mesh EmptyMesh
{
get
{
if (emptyMesh == null)
{
emptyMesh = new Mesh();
}
return emptyMesh;
}
}
private static Material[] emptyMaterials;
public static Material[] EmptyMaterials
{
get
{
if (emptyMaterials==null)
{
emptyMaterials = new Material[0];
}
return emptyMaterials;
}
}
public static Rect UnitRect
{
get
{
return new Rect(0, 0, 1, 1);
}
}
public static string GetUniqueID()
{
string s = GetTimeTick().ToString();
return Reverse(s);
}
public static long GetTimeTick()
{
DateTime time = DateTime.Now;
return time.Ticks;
}
public static string Reverse(string s)
{
char[] chars = s.ToCharArray();
System.Array.Reverse(chars);
return new string(chars);
}
public static void SetDirty(Object o)
{
#if UNITY_EDITOR
EditorUtility.SetDirty(o);
#endif
}
public static void AddObjectToAsset(Object objectToAdd, Object asset)
{
#if UNITY_EDITOR
AssetDatabase.AddObjectToAsset(objectToAdd, asset);
#endif
}
public static Texture2D CreateTexture(int resolution, Color fill, TextureFormat format = TextureFormat.ARGB32)
{
Texture2D t = new Texture2D(resolution, resolution, format, false);
Color[] colors = new Color[resolution * resolution];
JUtilities.Fill(colors, fill);
t.SetPixels(colors);
t.Apply();
return t;
}
public static void CopyToRT(Texture t, RenderTexture rt)
{
RenderTexture.active = rt;
Graphics.Blit(t, rt);
RenderTexture.active = null;
}
public static void CopyFromRT(Texture2D t, RenderTexture rt)
{
RenderTexture.active = rt;
t.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
t.Apply();
RenderTexture.active = null;
}
public static void CopyTexture(Texture2D src, Texture2D des)
{
RenderTexture rt = new RenderTexture(des.width, des.height, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Default);
CopyToRT(src, rt);
CopyFromRT(des, rt);
rt.Release();
JUtilities.DestroyObject(rt);
}
public static Texture2D CloneTexture(Texture2D t)
{
RenderTexture rt = new RenderTexture(t.width, t.height, 0, RenderTextureFormat.ARGB32);
CopyToRT(t, rt);
Texture2D result = new Texture2D(t.width, t.height, TextureFormat.ARGB32, false);
result.filterMode = t.filterMode;
result.wrapMode = t.wrapMode;
CopyFromRT(result, rt);
rt.Release();
Object.DestroyImmediate(rt);
return result;
}
public static void FillTexture(Texture2D t, Color c)
{
Color[] colors = new Color[t.width * t.height];
JUtilities.Fill(colors, c);
t.SetPixels(colors);
t.Apply();
}
public static void FillTexture(RenderTexture rt, Color c)
{
Texture2D tex = new Texture2D(1, 1, TextureFormat.ARGB32, false);
tex.SetPixel(0, 0, c);
tex.Apply();
CopyToRT(tex, rt);
JUtilities.DestroyObject(tex);
}
public static Texture2D CloneAndResizeTexture(Texture2D t, int width, int height)
{
RenderTexture rt = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32);
CopyToRT(t, rt);
Texture2D result = new Texture2D(width, height, TextureFormat.ARGB32, false);
result.filterMode = t.filterMode;
result.wrapMode = t.wrapMode;
CopyFromRT(result, rt);
rt.Release();
Object.DestroyImmediate(rt);
return result;
}
public static RenderTexture CopyToRT(Texture src, int startX, int startY, int width, int height, Color defaultColor)
{
int endX = startX + width - 1;
int endY = startY + height - 1;
Vector2 startUV = new Vector2(
JUtilities.InverseLerpUnclamped(0, src.width - 1, startX),
JUtilities.InverseLerpUnclamped(0, src.height - 1, startY));
Vector2 endUV = new Vector2(
JUtilities.InverseLerpUnclamped(0, src.width - 1, endX),
JUtilities.InverseLerpUnclamped(0, src.height - 1, endY));
Material mat = JInternalMaterials.CopyTextureMaterial;
mat.SetTexture("_MainTex", src);
mat.SetVector("_StartUV", startUV);
mat.SetVector("_EndUV", endUV);
mat.SetColor("_DefaultColor", defaultColor);
mat.SetPass(0);
RenderTexture rt = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
RenderTexture.active = rt;
Graphics.Blit(src, mat);
RenderTexture.active = null;
return rt;
}
public static void DrawTexture(RenderTexture rt, Texture texture, Rect uvRect, Material mat, int pass = 0)
{
if (mat == null)
mat = JInternalMaterials.UnlitTextureMaterial;
RenderTexture.active = rt;
GL.PushMatrix();
mat.SetTexture("_MainTex", texture);
mat.SetPass(pass);
GL.LoadOrtho();
GL.Begin(GL.QUADS);
GL.TexCoord(new Vector3(0, 0, 0));
GL.Vertex3(uvRect.min.x, uvRect.min.y, 0);
GL.TexCoord(new Vector3(0, 1, 0));
GL.Vertex3(uvRect.min.x, uvRect.max.y, 0);
GL.TexCoord(new Vector3(1, 1, 0));
GL.Vertex3(uvRect.max.x, uvRect.max.y, 0);
GL.TexCoord(new Vector3(1, 0, 0));
GL.Vertex3(uvRect.max.x, uvRect.min.y, 0);
GL.End();
GL.PopMatrix();
RenderTexture.active = null;
}
public static void DrawTriangle(RenderTexture rt, Vector2 v0, Vector2 v1, Vector2 v2, Color c)
{
Material mat = JInternalMaterials.SolidColorMaterial;
mat.SetColor("_Color", c);
RenderTexture.active = rt;
GL.PushMatrix();
mat.SetPass(0);
GL.LoadOrtho();
GL.Begin(GL.TRIANGLES);
GL.Vertex3(v0.x, v0.y, 0);
GL.Vertex3(v1.x, v1.y, 0);
GL.Vertex3(v2.x, v2.y, 0);
GL.End();
GL.PopMatrix();
RenderTexture.active = null;
}
public static void DrawQuad(RenderTexture rt, Vector2[] quadCorners, Material mat, int pass)
{
RenderTexture.active = rt;
GL.PushMatrix();
mat.SetPass(pass);
GL.LoadOrtho();
GL.Begin(GL.QUADS);
GL.TexCoord(new Vector3(0, 0, 0));
GL.Vertex3(quadCorners[0].x, quadCorners[0].y, 0);
GL.TexCoord(new Vector3(0, 1, 0));
GL.Vertex3(quadCorners[1].x, quadCorners[1].y, 0);
GL.TexCoord(new Vector3(1, 1, 0));
GL.Vertex3(quadCorners[2].x, quadCorners[2].y, 0);
GL.TexCoord(new Vector3(1, 0, 0));
GL.Vertex3(quadCorners[3].x, quadCorners[3].y, 0);
GL.End();
GL.PopMatrix();
RenderTexture.active = null;
}
public static List<System.Type> GetAllLoadedTypes()
{
List<System.Type> loadedTypes = new List<System.Type>();
List<string> typeName = new List<string>();
foreach (var assembly in System.AppDomain.CurrentDomain.GetAssemblies())
{
foreach (var t in assembly.GetTypes())
{
if (t.IsVisible && !t.IsGenericType)
{
typeName.Add(t.Name);
loadedTypes.Add(t);
}
}
}
return loadedTypes;
}
public static IEnumerable<Rect> CompareHeightMap(int gridSize, Color[] oldValues, Color[] newValues)
{
if (oldValues.LongLength != newValues.LongLength)
{
return new Rect[1] { new Rect(0, 0, 1, 1) };
}
Rect[] rects = new Rect[gridSize * gridSize];
for (int x = 0; x < gridSize; ++x)
{
for (int z = 0; z < gridSize; ++z)
{
rects[JUtilities.To1DIndex(x, z, gridSize)] = GetUvRange(gridSize, x, z);
}
}
HashSet<Rect> dirtyRects = new HashSet<Rect>();
int index = 0;
int resolution = Mathf.RoundToInt(Mathf.Sqrt(newValues.LongLength));
for (int rectIndex = 0; rectIndex < rects.Length; ++rectIndex)
{
Rect r = rects[rectIndex];
int startX = (int)Mathf.Lerp(0, resolution - 1, r.min.x);
int startY = (int)Mathf.Lerp(0, resolution - 1, r.min.y);
int endX = (int)Mathf.Lerp(0, resolution - 1, r.max.x);
int endY = (int)Mathf.Lerp(0, resolution - 1, r.max.y);
for (int x = startX; x <= endX; ++x)
{
for (int y = startY; y <= endY; ++y)
{
index = JUtilities.To1DIndex(x, y, resolution);
if (oldValues[index].r == newValues[index].r &&
oldValues[index].g == newValues[index].g &&
oldValues[index].b == newValues[index].b &&
oldValues[index].a == newValues[index].a)
continue;
dirtyRects.Add(r);
Rect hRect = new Rect();
hRect.size = new Vector2(r.width * 1.2f, r.height);
hRect.center = r.center;
dirtyRects.Add(hRect);
Rect vRect = new Rect();
vRect.size = new Vector2(r.width, r.height * 1.2f);
vRect.center = r.center;
dirtyRects.Add(vRect);
break;
}
if (dirtyRects.Contains(r))
break;
}
}
return dirtyRects;
}
public static Rect GetUvRange(int gridSize, int x, int z)
{
Vector2 position = new Vector2(x * 1.0f / gridSize, z * 1.0f / gridSize);
Vector2 size = Vector2.one / gridSize;
return new Rect(position, size);
}
public static Texture2D CreateTextureFromCurve(AnimationCurve curve, int width, int height)
{
Texture2D t = new Texture2D(width, height, TextureFormat.ARGB32, false);
t.wrapMode = TextureWrapMode.Clamp;
Color[] colors = new Color[width * height];
for (int x = 0; x < width; ++x)
{
float f = Mathf.InverseLerp(0, width - 1, x);
float value = curve.Evaluate(f);
Color c = new Color(value, value, value, value);
for (int y = 0; y < height; ++y)
{
colors[JUtilities.To1DIndex(x, y, width)] = c;
}
}
t.filterMode = FilterMode.Bilinear;
t.SetPixels(colors);
t.Apply();
return t;
}
public static Vector3[] GetBrushQuadCorners(Vector3 center, float radius, float rotation)
{
Matrix4x4 matrix = Matrix4x4.Rotate(Quaternion.Euler(0, rotation, 0));
Vector3[] corners = new Vector3[]
{
center + matrix.MultiplyPoint(new Vector3(-1,0,-1)*radius),
center + matrix.MultiplyPoint(new Vector3(-1,0,1)*radius),
center + matrix.MultiplyPoint(new Vector3(1,0,1)*radius),
center + matrix.MultiplyPoint(new Vector3(1,0,-1)*radius)
};
return corners;
}
//public static void RegisterBeginRender(Camera.CameraCallback callback)
//{
// Camera.onPreCull += callback;
//}
//public static void RegisterBeginRenderSRP(System.Action<Camera> callback)
//{
// RenderPipelineManager.beginCameraRendering += callback;
//}
//public static void UnregisterBeginRender(Camera.CameraCallback callback)
//{
// Camera.onPreCull -= callback;
//}
//public static void UnregisterBeginRenderSRP(System.Action<Camera> callback)
//{
// RenderPipeline.beginCameraRendering -= callback;
//}
//public static void RegisterEndRender(Camera.CameraCallback callback)
//{
// Camera.onPostRender += callback;
//}
public static void ClearRT(RenderTexture rt)
{
RenderTexture.active = rt;
GL.Clear(true, true, Color.clear);
RenderTexture.active = null;
}
public static void SetMaterialKeywordActive(Material mat, string keyword, bool active)
{
if (active)
{
mat.EnableKeyword(keyword);
}
else
{
mat.DisableKeyword(keyword);
}
}
public static void Editor_ProgressBar(string title, string detail, float percent)
{
#if UNITY_EDITOR
EditorUtility.DisplayProgressBar(title, detail, percent);
#endif
}
public static void Editor_CancelableProgressBar(string title, string detail, float percent)
{
#if UNITY_EDITOR
if (EditorUtility.DisplayCancelableProgressBar(title, detail, percent))
{
throw new JProgressCancelledException();
}
#endif
}
public static void Editor_ClearProgressBar()
{
#if UNITY_EDITOR
EditorUtility.ClearProgressBar();
#endif
}
public static Camera CreateCamera()
{
GameObject g = new GameObject();
Camera cam = g.AddComponent<Camera>();
return cam;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eecf0dc3227a8864087fe5c95bf7d2a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
public enum JDetailOverlayLayer
{
AfterSky,
AfterStars,
AfterSun,
AfterMoon,
AfterHorizonCloud,
AfterOverheadCloud
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43bc06ee4a9de7c4398a4b61d88a44e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
public enum JFogSyncOption
{
DontSync,
SkyColor,
HorizonColor,
GroundColor,
CustomColor
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9563b0fb01aca484fbe749edcb192621
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,125 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
//[CreateAssetMenu(menuName = "Jupiter/Settings")]
public class JJupiterSettings : ScriptableObject
{
private static JJupiterSettings instance;
public static JJupiterSettings Instance
{
get
{
if (instance == null)
{
instance = Resources.Load<JJupiterSettings>("JupiterSettings");
if (instance == null)
{
instance = ScriptableObject.CreateInstance<JJupiterSettings>() as JJupiterSettings;
}
}
return instance;
}
}
[SerializeField]
private Material defaultSkybox;
public Material DefaultSkybox
{
get
{
return defaultSkybox;
}
set
{
defaultSkybox = value;
}
}
[SerializeField]
private Texture2D noiseTexture;
public Texture2D NoiseTexture
{
get
{
return noiseTexture;
}
set
{
noiseTexture = value;
}
}
[SerializeField]
private Texture2D cloudTexture;
public Texture2D CloudTexture
{
get
{
return cloudTexture;
}
set
{
cloudTexture = value;
}
}
[SerializeField]
private JSkyProfile defaultProfileSunnyDay;
public JSkyProfile DefaultProfileSunnyDay
{
get
{
return defaultProfileSunnyDay;
}
set
{
defaultProfileSunnyDay = value;
}
}
[SerializeField]
private JSkyProfile defaultProfileStarryNight;
public JSkyProfile DefaultProfileStarryNight
{
get
{
return defaultProfileStarryNight;
}
set
{
defaultProfileStarryNight = value;
}
}
[SerializeField]
private JDayNightCycleProfile defaultDayNightCycleProfile;
public JDayNightCycleProfile DefaultDayNightCycleProfile
{
get
{
return defaultDayNightCycleProfile;
}
set
{
defaultDayNightCycleProfile = value;
}
}
[SerializeField]
private JInternalShaderSettings internalShaders;
public JInternalShaderSettings InternalShaders
{
get
{
return internalShaders;
}
set
{
internalShaders = value;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4602ffc9ae1863b4b9155331571220f2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,334 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine.Rendering;
namespace Pinwheel.Jupiter
{
public static class JMat
{
public static readonly int NOISE_TEX = Shader.PropertyToID("_NoiseTex");
public static readonly int CLOUD_TEX = Shader.PropertyToID("_CloudTex");
public static readonly int SKY_COLOR = Shader.PropertyToID("_SkyColor");
public static readonly int HORIZON_COLOR = Shader.PropertyToID("_HorizonColor");
public static readonly int GROUND_COLOR = Shader.PropertyToID("_GroundColor");
public static readonly int HORIZON_THICKNESS = Shader.PropertyToID("_HorizonThickness");
public static readonly int HORIZON_EXPONENT = Shader.PropertyToID("_HorizonExponent");
public static readonly int HORIZON_STEP = Shader.PropertyToID("_HorizonStep");
public static readonly int FOG_COLOR = Shader.PropertyToID("_FogColor");
public static readonly string KW_STARS = "STARS";
public static readonly string KW_STARS_LAYER_0 = "STARS_LAYER_0";
public static readonly string KW_STARS_LAYER_1 = "STARS_LAYER_1";
public static readonly string KW_STARS_LAYER_2 = "STARS_LAYER_2";
public static readonly int STARS_START = Shader.PropertyToID("_StarsStartPosition");
public static readonly int STARS_END = Shader.PropertyToID("_StarsEndPosition");
public static readonly int STARS_OPACITY = Shader.PropertyToID("_StarsOpacity");
public static readonly int STARS_COLOR_0 = Shader.PropertyToID("_StarsColor0");
public static readonly int STARS_COLOR_1 = Shader.PropertyToID("_StarsColor1");
public static readonly int STARS_COLOR_2 = Shader.PropertyToID("_StarsColor2");
public static readonly int STARS_DENSITY_0 = Shader.PropertyToID("_StarsDensity0");
public static readonly int STARS_DENSITY_1 = Shader.PropertyToID("_StarsDensity1");
public static readonly int STARS_DENSITY_2 = Shader.PropertyToID("_StarsDensity2");
public static readonly int STARS_SIZE_0 = Shader.PropertyToID("_StarsSize0");
public static readonly int STARS_SIZE_1 = Shader.PropertyToID("_StarsSize1");
public static readonly int STARS_SIZE_2 = Shader.PropertyToID("_StarsSize2");
public static readonly int STARS_GLOW_0 = Shader.PropertyToID("_StarsGlow0");
public static readonly int STARS_GLOW_1 = Shader.PropertyToID("_StarsGlow1");
public static readonly int STARS_GLOW_2 = Shader.PropertyToID("_StarsGlow2");
public static readonly int STARS_TWINKLE_0 = Shader.PropertyToID("_StarsTwinkle0");
public static readonly int STARS_TWINKLE_1 = Shader.PropertyToID("_StarsTwinkle1");
public static readonly int STARS_TWINKLE_2 = Shader.PropertyToID("_StarsTwinkle2");
public static readonly string KW_STARS_BAKED = "STARS_BAKED";
public static readonly int STARS_CUBEMAP = Shader.PropertyToID("_StarsCubemap");
public static readonly int STARS_TWINKLE_MAP = Shader.PropertyToID("_StarsTwinkleMap");
public static readonly string KW_SUN = "SUN";
public static readonly string KW_SUN_USE_TEXTURE = "SUN_USE_TEXTURE";
public static readonly int SUN_TEX = Shader.PropertyToID("_SunTex");
public static readonly int SUN_COLOR = Shader.PropertyToID("_SunColor");
public static readonly int SUN_SIZE = Shader.PropertyToID("_SunSize");
public static readonly int SUN_SOFT_EDGE = Shader.PropertyToID("_SunSoftEdge");
public static readonly int SUN_GLOW = Shader.PropertyToID("_SunGlow");
public static readonly int SUN_DIRECTION = Shader.PropertyToID("_SunDirection");
public static readonly int SUN_TRANSFORM_MATRIX = Shader.PropertyToID("_PositionToSunUV");
public static readonly int SUN_LIGHT_COLOR = Shader.PropertyToID("_SunLightColor");
public static readonly int SUN_LIGHT_INTENSITY = Shader.PropertyToID("_SunLightIntensity");
public static readonly string KW_SUN_BAKED = "SUN_BAKED";
public static readonly int SUN_CUBEMAP = Shader.PropertyToID("_SunCubemap");
public static readonly int SUN_ROTATION_MATRIX = Shader.PropertyToID("_SunRotationMatrix");
public static readonly string KW_MOON = "MOON";
public static readonly string KW_MOON_USE_TEXTURE = "MOON_USE_TEXTURE";
public static readonly int MOON_TEX = Shader.PropertyToID("_MoonTex");
public static readonly int MOON_COLOR = Shader.PropertyToID("_MoonColor");
public static readonly int MOON_SIZE = Shader.PropertyToID("_MoonSize");
public static readonly int MOON_SOFT_EDGE = Shader.PropertyToID("_MoonSoftEdge");
public static readonly int MOON_GLOW = Shader.PropertyToID("_MoonGlow");
public static readonly int MOON_DIRECTION = Shader.PropertyToID("_MoonDirection");
public static readonly int MOON_TRANSFORM_MATRIX = Shader.PropertyToID("_PositionToMoonUV");
public static readonly int MOON_LIGHT_COLOR = Shader.PropertyToID("_MoonLightColor");
public static readonly int MOON_LIGHT_INTENSITY = Shader.PropertyToID("_MoonLightIntensity");
public static readonly string KW_MOON_BAKED = "MOON_BAKED";
public static readonly int MOON_CUBEMAP = Shader.PropertyToID("_MoonCubemap");
public static readonly int MOON_ROTATION_MATRIX = Shader.PropertyToID("_MoonRotationMatrix");
public static readonly string KW_HORIZON_CLOUD = "HORIZON_CLOUD";
public static readonly int HORIZON_CLOUD_COLOR = Shader.PropertyToID("_HorizonCloudColor");
public static readonly int HORIZON_CLOUD_START = Shader.PropertyToID("_HorizonCloudStartPosition");
public static readonly int HORIZON_CLOUD_END = Shader.PropertyToID("_HorizonCloudEndPosition");
public static readonly int HORIZON_CLOUD_SIZE = Shader.PropertyToID("_HorizonCloudSize");
public static readonly int HORIZON_CLOUD_STEP = Shader.PropertyToID("_HorizonCloudStep");
public static readonly int HORIZON_CLOUD_ANIMATION_SPEED = Shader.PropertyToID("_HorizonCloudAnimationSpeed");
public static readonly string KW_OVERHEAD_CLOUD = "OVERHEAD_CLOUD";
public static readonly int OVERHEAD_CLOUD_COLOR = Shader.PropertyToID("_OverheadCloudColor");
public static readonly int OVERHEAD_CLOUD_ALTITUDE = Shader.PropertyToID("_OverheadCloudAltitude");
public static readonly int OVERHEAD_CLOUD_SIZE = Shader.PropertyToID("_OverheadCloudSize");
public static readonly int OVERHEAD_CLOUD_STEP = Shader.PropertyToID("_OverheadCloudStep");
public static readonly int OVERHEAD_CLOUD_ANIMATION_SPEED = Shader.PropertyToID("_OverheadCloudAnimationSpeed");
public static readonly int OVERHEAD_CLOUD_FLOW_X = Shader.PropertyToID("_OverheadCloudFlowDirectionX");
public static readonly int OVERHEAD_CLOUD_FLOW_Z = Shader.PropertyToID("_OverheadCloudFlowDirectionZ");
public static readonly int OVERHEAD_CLOUD_REMAP_MIN = Shader.PropertyToID("_OverheadCloudRemapMin");
public static readonly int OVERHEAD_CLOUD_REMAP_MAX = Shader.PropertyToID("_OverheadCloudRemapMax");
public static readonly int OVERHEAD_CLOUD_SHADOW_CLIP_MASK = Shader.PropertyToID("_OverheadCloudShadowClipMask");
public static readonly string KW_DETAIL_OVERLAY = "DETAIL_OVERLAY";
public static readonly string KW_DETAIL_OVERLAY_ROTATION = "DETAIL_OVERLAY_ROTATION";
public static readonly int DETAIL_OVERLAY_COLOR = Shader.PropertyToID("_DetailOverlayTintColor");
public static readonly int DETAIL_OVERLAY_CUBEMAP = Shader.PropertyToID("_DetailOverlayCubemap");
public static readonly int DETAIL_OVERLAY_LAYER = Shader.PropertyToID("_DetailOverlayLayer");
public static readonly int DETAIL_OVERLAY_ROTATION_SPEED = Shader.PropertyToID("_DetailOverlayRotationSpeed");
public static readonly string KW_ALLOW_STEP_EFFECT = "ALLOW_STEP_EFFECT";
private static Material activeMaterial;
public static void SetActiveMaterial(Material mat)
{
activeMaterial = mat;
}
public static void GetColor(int prop, ref Color value)
{
try
{
if (activeMaterial.HasProperty(prop))
{
value = activeMaterial.GetColor(prop);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void GetFloat(int prop, ref float value)
{
try
{
if (activeMaterial.HasProperty(prop))
{
value = activeMaterial.GetFloat(prop);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void GetVector(int prop, ref Vector4 value)
{
try
{
if (activeMaterial.HasProperty(prop))
{
value = activeMaterial.GetVector(prop);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void GetTexture(int prop, ref Texture value)
{
try
{
if (activeMaterial.HasProperty(prop))
{
value = activeMaterial.GetTexture(prop);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void GetKeywordEnabled(string kw, ref bool value)
{
try
{
value = activeMaterial.IsKeywordEnabled(kw);
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void SetColor(int prop, Color value)
{
try
{
if (activeMaterial.HasProperty(prop))
{
activeMaterial.SetColor(prop, value);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void SetFloat(int prop, float value)
{
try
{
if (activeMaterial.HasProperty(prop))
{
activeMaterial.SetFloat(prop, value);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void SetVector(int prop, Vector4 value)
{
try
{
if (activeMaterial.HasProperty(prop))
{
activeMaterial.SetVector(prop, value);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void SetTexture(int prop, Texture value)
{
try
{
if (activeMaterial.HasProperty(prop))
{
activeMaterial.SetTexture(prop, value);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void SetMatrix(int prop, Matrix4x4 value)
{
try
{
if (activeMaterial.HasProperty(prop))
{
activeMaterial.SetMatrix(prop, value);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void SetKeywordEnable(string kw, bool enable)
{
try
{
if (enable)
{
activeMaterial.EnableKeyword(kw);
}
else
{
activeMaterial.DisableKeyword(kw);
}
}
catch (NullReferenceException nullEx)
{
Debug.LogError(nullEx.ToString());
}
catch { }
}
public static void SetOverrideTag(string tag, string value)
{
activeMaterial.SetOverrideTag(tag, value);
}
public static void SetRenderQueue(int queue)
{
activeMaterial.renderQueue = queue;
}
public static void SetRenderQueue(RenderQueue queue)
{
activeMaterial.renderQueue = (int)queue;
}
public static void SetSourceBlend(BlendMode mode)
{
activeMaterial.SetInt("_SrcBlend", (int)mode);
}
public static void SetDestBlend(BlendMode mode)
{
activeMaterial.SetInt("_DstBlend", (int)mode);
}
public static void SetZWrite(bool value)
{
activeMaterial.SetInt("_ZWrite", value ? 1 : 0);
}
public static void SetBlend(bool value)
{
activeMaterial.SetInt("_Blend", value ? 1 : 0);
}
public static void SetShader(Shader shader)
{
activeMaterial.shader = shader;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9a58b96c6d0a1f04ea3a3e06e58fc925
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,261 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Rendering;
namespace Pinwheel.Jupiter
{
[ExecuteInEditMode]
public class JSky : MonoBehaviour
{
public static readonly Vector3 DefaultSunDirection = Vector3.forward;
public static readonly Vector3 DefaultMoonDirection = Vector3.forward;
[SerializeField]
private JSkyProfile profile;
public JSkyProfile Profile
{
get
{
return profile;
}
set
{
profile = value;
}
}
[SerializeField]
private Light sunLightSource;
public Light SunLightSource
{
get
{
return sunLightSource;
}
set
{
Light src = value;
if (src != null && src.type == LightType.Directional)
{
sunLightSource = src;
}
else
{
sunLightSource = null;
}
}
}
[SerializeField]
private Light moonLightSource;
public Light MoonLightSource
{
get
{
return moonLightSource;
}
set
{
Light src = value;
if (src != null && src.type == LightType.Directional)
{
moonLightSource = src;
}
else
{
moonLightSource = null;
}
}
}
public JDayNightCycle DNC { get; set; }
private static Mesh sphereMesh;
private static Mesh SphereMesh
{
get
{
if (sphereMesh == null)
{
sphereMesh = Resources.GetBuiltinResource<Mesh>("Sphere.fbx");
}
return sphereMesh;
}
}
private void OnEnable()
{
Camera.onPreCull += OnCameraPreCull;
RenderPipelineManager.beginCameraRendering += OnBeginCameraRenderingSRP;
}
private void OnDisable()
{
Camera.onPreCull -= OnCameraPreCull;
RenderPipelineManager.beginCameraRendering -= OnBeginCameraRenderingSRP;
RenderSettings.skybox = JJupiterSettings.Instance.DefaultSkybox;
}
private void OnDestroy()
{
RenderSettings.skybox = JJupiterSettings.Instance.DefaultSkybox;
}
private void Reset()
{
Light[] lights = FindObjectsOfType<Light>();
for (int i = 0; i < lights.Length; ++i)
{
if (lights[i].type == LightType.Directional)
{
SunLightSource = lights[i];
break;
}
}
}
private void OnCameraPreCull(Camera cam)
{
SetupSkyMaterial();
SyncFog();
RenderShadow(cam);
}
private void OnBeginCameraRenderingSRP(ScriptableRenderContext context, Camera cam)
{
OnCameraPreCull(cam);
}
private void SetupSkyMaterial()
{
if (Profile == null)
{
RenderSettings.skybox = JJupiterSettings.Instance.DefaultSkybox;
return;
}
RenderSettings.skybox = Profile.Material;
Profile.Material.SetTexture(JMat.NOISE_TEX, JJupiterSettings.Instance.NoiseTexture);
Profile.Material.SetTexture(JMat.CLOUD_TEX, Profile.CustomCloudTexture ? Profile.CustomCloudTexture : JJupiterSettings.Instance.CloudTexture);
if (Profile.EnableSun)
{
if (SunLightSource != null)
{
JDayNightCycleProfile dncProfile = DNC ? DNC.Profile : null;
bool isSunLightColorOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.SunLightColor));
if (!isSunLightColorOverridden)
{
SunLightSource.color = Profile.SunLightColor;
}
bool isSunLightIntensityOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.SunLightIntensity));
if (!isSunLightIntensityOverridden)
{
SunLightSource.intensity = Profile.SunLightIntensity;
}
}
Vector3 sunDirection = SunLightSource ? SunLightSource.transform.forward : DefaultSunDirection;
if (Profile.UseBakedSun)
{
Matrix4x4 sunRotationMatrix = Matrix4x4.Rotate(
Quaternion.FromToRotation(sunDirection, DefaultSunDirection));
Profile.Material.SetMatrix(JMat.SUN_ROTATION_MATRIX, sunRotationMatrix);
}
else
{
Matrix4x4 positionToSunUV = Matrix4x4.TRS(
-sunDirection,
Quaternion.LookRotation(sunDirection),
Profile.SunSize * Vector3.one).inverse;
Profile.Material.SetVector(JMat.SUN_DIRECTION, sunDirection);
Profile.Material.SetMatrix(JMat.SUN_TRANSFORM_MATRIX, positionToSunUV);
}
}
if (Profile.EnableMoon)
{
if (MoonLightSource != null)
{
JDayNightCycleProfile dncProfile = DNC ? DNC.Profile : null;
bool isMoonLightColorOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.MoonLightColor));
if (!isMoonLightColorOverridden)
{
MoonLightSource.color = Profile.MoonLightColor;
}
bool isMoonLightIntensityOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.MoonLightIntensity));
if (!isMoonLightIntensityOverridden)
{
MoonLightSource.intensity = Profile.MoonLightIntensity;
}
}
Vector3 moonDirection = MoonLightSource ? MoonLightSource.transform.forward : DefaultMoonDirection;
if (Profile.UseBakedMoon)
{
Matrix4x4 moonRotationMatrix = Matrix4x4.Rotate(
Quaternion.FromToRotation(moonDirection, DefaultMoonDirection));
Profile.Material.SetMatrix(JMat.MOON_ROTATION_MATRIX, moonRotationMatrix);
}
else
{
Matrix4x4 positionToMoonUV = Matrix4x4.TRS(
-moonDirection,
Quaternion.LookRotation(moonDirection),
Profile.MoonSize * Vector3.one).inverse;
Profile.Material.SetVector(JMat.MOON_DIRECTION, moonDirection);
Profile.Material.SetMatrix(JMat.MOON_TRANSFORM_MATRIX, positionToMoonUV);
}
}
}
private void SyncFog()
{
if (Profile == null)
return;
if (Profile.FogSyncOption == JFogSyncOption.DontSync)
return;
if (Profile.FogSyncOption == JFogSyncOption.SkyColor)
{
RenderSettings.fogColor = Profile.Material.GetColor(JMat.SKY_COLOR);
}
else if (Profile.FogSyncOption == JFogSyncOption.HorizonColor)
{
RenderSettings.fogColor = Profile.Material.GetColor(JMat.HORIZON_COLOR);
}
else if (Profile.FogSyncOption == JFogSyncOption.GroundColor)
{
RenderSettings.fogColor = Profile.Material.GetColor(JMat.GROUND_COLOR);
}
else if (Profile.FogSyncOption == JFogSyncOption.CustomColor)
{
RenderSettings.fogColor = Profile.Material.GetColor(JMat.FOG_COLOR);
}
}
private void RenderShadow(Camera cam)
{
if (Profile == null)
return;
if (Profile.EnableOverheadCloud && Profile.OverheadCloudCastShadow)
{
Profile.ShadowMaterial.SetTexture(JMat.NOISE_TEX, JJupiterSettings.Instance.NoiseTexture);
Profile.ShadowMaterial.SetTexture(JMat.CLOUD_TEX, Profile.CustomCloudTexture ? Profile.CustomCloudTexture : JJupiterSettings.Instance.CloudTexture);
Graphics.DrawMesh(
SphereMesh,
Matrix4x4.TRS(Vector3.zero, Quaternion.identity, 2 * Vector3.one * Profile.OverheadCloudAltitude),
Profile.ShadowMaterial,
0,
cam,
0,
null,
ShadowCastingMode.ShadowsOnly,
false,
null,
LightProbeUsage.Off,
null);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5c868c49d0ac1174e9b4eb2f351c4624
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 100
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fa5278d11d9502245b5cc174a196561b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0a8cc88d832af6b428395b71519ae802
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
namespace Pinwheel.Jupiter
{
[AttributeUsage(AttributeTargets.Property)]
public class JAnimatableAttribute : Attribute
{
public string DisplayName { get; set; }
public JCurveOrGradient CurveOrGradient { get; set; }
public JAnimatableAttribute(string displayName, JCurveOrGradient curveOrGradient)
{
DisplayName = displayName;
CurveOrGradient = curveOrGradient;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43222b7e3b5a4f34eada9ba5e39fdd6c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,115 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
[System.Serializable]
public class JAnimatedProperty
{
[SerializeField]
private string name;
public string Name
{
get
{
if (name == null)
{
name = string.Empty;
}
return name;
}
set
{
name = value;
}
}
[SerializeField]
private string displayName;
public string DisplayName
{
get
{
if (displayName == null)
{
displayName = string.Empty;
}
return displayName;
}
set
{
displayName = value;
}
}
[SerializeField]
private JCurveOrGradient curveOrGradient;
public JCurveOrGradient CurveOrGradient
{
get
{
return curveOrGradient;
}
set
{
curveOrGradient = value;
}
}
[SerializeField]
private AnimationCurve curve;
public AnimationCurve Curve
{
get
{
if (curve == null)
{
curve = AnimationCurve.EaseInOut(0, 0, 1, 0);
}
return curve;
}
set
{
curve = value;
}
}
[SerializeField]
private Gradient gradient;
public Gradient Gradient
{
get
{
if (gradient == null)
{
gradient = JUtilities.CreateFullWhiteGradient();
}
return gradient;
}
set
{
gradient = value;
}
}
public float EvaluateFloat(float t)
{
return Curve.Evaluate(t);
}
public Color EvaluateColor(float t)
{
return Gradient.Evaluate(t);
}
public static JAnimatedProperty Create(string name, string displayName, JCurveOrGradient curveOrGradient)
{
JAnimatedProperty props = new JAnimatedProperty();
props.name = name;
props.displayName = displayName;
props.curveOrGradient = curveOrGradient;
return props;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e4e38c887fd7284caad7fa4eaa1d7ee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
public enum JCurveOrGradient
{
Curve, Gradient
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: efcccc60d3ffd0d429688c1777e9a2a4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,386 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Rendering;
namespace Pinwheel.Jupiter
{
[ExecuteInEditMode]
public class JDayNightCycle : MonoBehaviour
{
[SerializeField]
private JDayNightCycleProfile profile;
public JDayNightCycleProfile Profile
{
get
{
return profile;
}
set
{
profile = value;
}
}
[SerializeField]
private JSky sky;
public JSky Sky
{
get
{
return sky;
}
set
{
sky = value;
}
}
[SerializeField]
private bool useSunPivot;
public bool UseSunPivot
{
get
{
return useSunPivot;
}
set
{
useSunPivot = value;
}
}
[SerializeField]
private Transform sunOrbitPivot;
public Transform SunOrbitPivot
{
get
{
return sunOrbitPivot;
}
set
{
sunOrbitPivot = value;
}
}
[SerializeField]
private bool useMoonPivot;
public bool UseMoonPivot
{
get
{
return useMoonPivot;
}
set
{
useMoonPivot = value;
}
}
[SerializeField]
private Transform moonOrbitPivot;
public Transform MoonOrbitPivot
{
get
{
return moonOrbitPivot;
}
set
{
moonOrbitPivot = value;
}
}
[SerializeField]
private float startTime;
public float StartTime
{
get
{
return startTime;
}
set
{
startTime = Mathf.Clamp(value, 0f, 24f);
}
}
[SerializeField]
private float timeIncrement;
public float TimeIncrement
{
get
{
return timeIncrement;
}
set
{
timeIncrement = Mathf.Max(0, value);
}
}
[SerializeField]
private bool autoTimeIncrement;
public bool AutoTimeIncrement
{
get
{
return autoTimeIncrement;
}
set
{
autoTimeIncrement = value;
}
}
private float time;
public float Time
{
get
{
return time % 24f;
}
set
{
time = value % 24f;
}
}
[SerializeField]
private bool shouldUpdateEnvironmentReflection;
public bool ShouldUpdateEnvironmentReflection
{
get
{
return shouldUpdateEnvironmentReflection;
}
set
{
shouldUpdateEnvironmentReflection = value;
}
}
[SerializeField]
private int environmentReflectionResolution;
public int EnvironmentReflectionResolution
{
get
{
return environmentReflectionResolution;
}
set
{
int oldValue = environmentReflectionResolution;
int newValue = Mathf.Clamp(value, 16, 2048);
environmentReflectionResolution = newValue;
if (oldValue != newValue)
{
if (environmentReflection != null)
{
JUtilities.DestroyObject(environmentReflection);
}
if (environmentProbe != null)
{
JUtilities.DestroyGameobject(environmentProbe.gameObject);
}
}
}
}
[SerializeField]
private ReflectionProbeTimeSlicingMode environmentReflectionTimeSlicingMode;
public ReflectionProbeTimeSlicingMode EnvironmentReflectionTimeSlicingMode
{
get
{
return environmentReflectionTimeSlicingMode;
}
set
{
environmentReflectionTimeSlicingMode = value;
}
}
[SerializeField]
private ReflectionProbe environmentProbe;
private ReflectionProbe EnvironmentProbe
{
get
{
if (environmentProbe == null)
{
GameObject probeGO = new GameObject("~EnvironmentReflectionRenderer");
probeGO.transform.parent = transform;
probeGO.transform.position = new Vector3(0, -1000, 0);
probeGO.transform.rotation = Quaternion.identity;
probeGO.transform.localScale = Vector3.one;
environmentProbe = probeGO.AddComponent<ReflectionProbe>();
environmentProbe.resolution = EnvironmentReflectionResolution;
environmentProbe.size = new Vector3(1, 1, 1);
environmentProbe.cullingMask = 0;
}
environmentProbe.clearFlags = ReflectionProbeClearFlags.Skybox;
environmentProbe.mode = ReflectionProbeMode.Realtime;
environmentProbe.refreshMode = ReflectionProbeRefreshMode.ViaScripting;
environmentProbe.timeSlicingMode = EnvironmentReflectionTimeSlicingMode;
environmentProbe.hdr = false;
return environmentProbe;
}
}
private Cubemap environmentReflection;
private Cubemap EnvironmentReflection
{
get
{
if (environmentReflection == null)
{
environmentReflection = new Cubemap(EnvironmentProbe.resolution, TextureFormat.RGBA32, true);
}
return environmentReflection;
}
}
private int probeRenderId = -1;
private float DeltaTime
{
get
{
if (Application.isPlaying)
return UnityEngine.Time.deltaTime;
else
return 1.0f / 60f;
}
}
private void Reset()
{
Sky = GetComponent<JSky>();
StartTime = 0;
TimeIncrement = 1;
AutoTimeIncrement = true;
Time = 0;
}
private void OnEnable()
{
time = StartTime;
Camera.onPreCull += OnCameraPreCull;
RenderPipelineManager.beginFrameRendering += OnBeginFrameRenderingSRP;
}
private void OnDisable()
{
Camera.onPreCull -= OnCameraPreCull;
RenderPipelineManager.beginFrameRendering -= OnBeginFrameRenderingSRP;
CleanUp();
}
private void OnCameraPreCull(Camera cam)
{
if (!Application.isPlaying)
Update();
}
private void OnBeginFrameRenderingSRP(ScriptableRenderContext context, Camera[] cameras)
{
if (!Application.isPlaying)
Update();
}
private void CleanUp()
{
if (environmentProbe != null)
{
JUtilities.DestroyGameobject(environmentProbe.gameObject);
}
if (environmentReflection != null)
{
JUtilities.DestroyObject(environmentReflection);
}
if (Sky != null)
{
Sky.DNC = null;
}
}
private void Update()
{
AnimateSky();
if (ShouldUpdateEnvironmentReflection)
{
UpdateEnvironmentReflection();
}
else
{
RenderSettings.defaultReflectionMode = DefaultReflectionMode.Skybox;
}
}
private void AnimateSky()
{
if (Profile == null)
return;
if (Sky == null)
return;
if (Sky.Profile == null)
return;
Sky.DNC = this;
if (AutoTimeIncrement)
{
Time += TimeIncrement * DeltaTime;
}
float evalTime = Mathf.InverseLerp(0f, 24f, Time);
Profile.Animate(Sky, evalTime);
if (Sky.Profile.EnableSun && Sky.SunLightSource != null)
{
float angle = evalTime * 360f;
Matrix4x4 localRotationMatrix = Matrix4x4.Rotate(Quaternion.Euler(angle, 0, 0));
Vector3 localDirection = localRotationMatrix.MultiplyVector(Vector3.up);
Transform pivot = (UseSunPivot && SunOrbitPivot != null) ? SunOrbitPivot : transform;
Matrix4x4 localToWorld = pivot.localToWorldMatrix;
Vector3 worldDirection = localToWorld.MultiplyVector(localDirection);
Sky.SunLightSource.transform.forward = worldDirection;
Sky.SunLightSource.color = Sky.Profile.Material.GetColor(JMat.SUN_LIGHT_COLOR);
Sky.SunLightSource.intensity = Sky.Profile.Material.GetFloat(JMat.SUN_LIGHT_INTENSITY);
}
if (Sky.Profile.EnableMoon && Sky.MoonLightSource != null)
{
float angle = evalTime * 360f;
Matrix4x4 localRotationMatrix = Matrix4x4.Rotate(Quaternion.Euler(angle, 0, 0));
Vector3 localDirection = localRotationMatrix.MultiplyVector(Vector3.down);
Transform pivot = (UseMoonPivot && MoonOrbitPivot != null) ? MoonOrbitPivot : transform;
Matrix4x4 localToWorld = pivot.localToWorldMatrix;
Vector3 worldDirection = localToWorld.MultiplyVector(localDirection);
Sky.MoonLightSource.transform.forward = worldDirection;
Sky.MoonLightSource.color = Sky.Profile.Material.GetColor(JMat.MOON_LIGHT_COLOR);
Sky.MoonLightSource.intensity = Sky.Profile.Material.GetFloat(JMat.MOON_LIGHT_INTENSITY);
}
}
private void UpdateEnvironmentReflection()
{
if ((SystemInfo.copyTextureSupport & CopyTextureSupport.RTToTexture) != 0)
{
if (EnvironmentProbe.texture == null)
{
probeRenderId = EnvironmentProbe.RenderProbe();
}
else if (EnvironmentProbe.texture != null || EnvironmentProbe.IsFinishedRendering(probeRenderId))
{
Graphics.CopyTexture(EnvironmentProbe.texture, EnvironmentReflection as Texture);
RenderSettings.customReflection = EnvironmentReflection;
RenderSettings.defaultReflectionMode = DefaultReflectionMode.Custom;
probeRenderId = EnvironmentProbe.RenderProbe();
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f3e972a2c1175484cbffd26bba6fb84f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 200
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,130 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System;
namespace Pinwheel.Jupiter
{
#if UNITY_EDITOR
[UnityEditor.InitializeOnLoad]
#endif
[CreateAssetMenu(menuName = "Jupiter/Day Night Cycle Profile")]
public class JDayNightCycleProfile : ScriptableObject
{
private static Dictionary<string, int> propertyRemap;
private static Dictionary<string, int> PropertyRemap
{
get
{
if (propertyRemap == null)
{
propertyRemap = new Dictionary<string, int>();
}
return propertyRemap;
}
set
{
propertyRemap = value;
}
}
static JDayNightCycleProfile()
{
InitPropertyRemap();
}
private static void InitPropertyRemap()
{
PropertyRemap.Clear();
Type type = typeof(JSkyProfile);
PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo p in props)
{
JAnimatableAttribute animatable = p.GetCustomAttribute(typeof(JAnimatableAttribute), false) as JAnimatableAttribute;
if (animatable == null)
continue;
string name = p.Name;
int id = Shader.PropertyToID("_" + name);
PropertyRemap.Add(name, id);
}
}
[SerializeField]
private List<JAnimatedProperty> animatedProperties;
public List<JAnimatedProperty> AnimatedProperties
{
get
{
if (animatedProperties == null)
{
animatedProperties = new List<JAnimatedProperty>();
}
return animatedProperties;
}
set
{
animatedProperties = value;
}
}
public void AddProperty(JAnimatedProperty p, bool setDefaultValue = true)
{
if (setDefaultValue)
{
JDayNightCycleProfile defaultProfile = JJupiterSettings.Instance.DefaultDayNightCycleProfile;
if (defaultProfile != null)
{
JAnimatedProperty defaultProp = defaultProfile.AnimatedProperties.Find(p0 => p0.Name != null && p0.Name.Equals(p.Name));
if (defaultProp != null)
{
p.Curve = defaultProp.Curve;
p.Gradient = defaultProp.Gradient;
}
}
}
AnimatedProperties.Add(p);
}
public void Animate(JSky sky, float t)
{
CheckDefaultProfileAndThrow(sky.Profile);
for (int i = 0; i < AnimatedProperties.Count; ++i)
{
JAnimatedProperty aProp = AnimatedProperties[i];
int id = 0;
if (!PropertyRemap.TryGetValue(aProp.Name, out id))
{
continue;
}
if (aProp.CurveOrGradient == JCurveOrGradient.Curve)
{
sky.Profile.Material.SetFloat(id, aProp.EvaluateFloat(t));
}
else
{
sky.Profile.Material.SetColor(id, aProp.EvaluateColor(t));
}
}
}
private void CheckDefaultProfileAndThrow(JSkyProfile p)
{
if (p == null)
return;
if (p == JJupiterSettings.Instance.DefaultProfileSunnyDay ||
p == JJupiterSettings.Instance.DefaultProfileStarryNight)
{
throw new ArgumentException("Animating default sky profile is prohibited. You must create a new profile for your sky to animate it.");
}
}
public bool ContainProperty(string propertyName)
{
return AnimatedProperties.Exists((p) => p.Name.Equals(propertyName));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6c1aff3a39ca339468585db555ec032c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 401fa1ab5d5cfd347912eece9fa7aee9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
public static class JCubemapRenderer
{
public static bool Render(JCubemapRendererArgs args)
{
GameObject go = new GameObject("~CubemapRendererCamera");
go.transform.position = args.CameraPosition;
Camera cam = go.AddComponent<Camera>();
cam.clearFlags = args.CameraClearFlag;
cam.nearClipPlane = args.CameraNearPlane;
cam.farClipPlane = args.CameraFarPlane;
cam.backgroundColor = args.CameraBackgroundColor;
bool result = cam.RenderToCubemap(args.Cubemap, (int)args.Face);
JUtilities.DestroyGameobject(go);
return result;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bc3248045e9ae284ab9c156b645a1169
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
public struct JCubemapRendererArgs
{
public Cubemap Cubemap { get; set; }
public Vector3 CameraPosition { get; set; }
public float CameraNearPlane { get; set; }
public float CameraFarPlane { get; set; }
public CameraClearFlags CameraClearFlag { get; set; }
public Color CameraBackgroundColor { get; set; }
public int Resolution { get; set; }
public CubemapFace Face { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 53353c1d12d3cdd40932638701fd1cc4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
namespace Pinwheel.Jupiter
{
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
public class JDisplayName : Attribute
{
public string DisplayName { get; set; }
public JDisplayName(string name)
{
DisplayName = name;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4dd128fb524c0d4f89702d41b4413b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,48 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
public static class JInternalMaterials
{
private static Material copyTextureMaterial;
public static Material CopyTextureMaterial
{
get
{
if (copyTextureMaterial == null)
{
copyTextureMaterial = new Material(JJupiterSettings.Instance.InternalShaders.CopyTextureShader);
}
return copyTextureMaterial;
}
}
private static Material solidColorMaterial;
public static Material SolidColorMaterial
{
get
{
if (solidColorMaterial == null)
{
solidColorMaterial = new Material(JJupiterSettings.Instance.InternalShaders.SolidColorShader);
}
return solidColorMaterial;
}
}
private static Material unlitTextureMaterial;
public static Material UnlitTextureMaterial
{
get
{
if (unlitTextureMaterial == null)
{
unlitTextureMaterial = new Material(Shader.Find("Unlit/Texture"));
}
return unlitTextureMaterial;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 12efcfb958bf73a4d8911da3854ecf1f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,66 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
[System.Serializable]
public struct JInternalShaderSettings
{
[SerializeField]
private Shader skyShader;
public Shader SkyShader
{
get
{
return skyShader;
}
set
{
skyShader = value;
}
}
[SerializeField]
private Shader skyShadowShader;
public Shader SkyShadowShader
{
get
{
return skyShadowShader;
}
set
{
skyShadowShader = value;
}
}
[SerializeField]
private Shader copyTextureShader;
public Shader CopyTextureShader
{
get
{
return copyTextureShader;
}
set
{
copyTextureShader = value;
}
}
[SerializeField]
private Shader solidColorShader;
public Shader SolidColorShader
{
get
{
return solidColorShader;
}
set
{
solidColorShader = value;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 70be7075e30f60041a45426680b4f59f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
namespace Pinwheel.Jupiter
{
public class JProgressCancelledException : Exception
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a76140ed4d92dd241b079d06d7ae2dfb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
public enum JRenderPipelineType
{
Builtin, Lightweight, Universal
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1a10af660232a6040b30f305e2a005a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,757 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Pinwheel.Jupiter
{
/// <summary>
/// Utility class for helper function
/// </summary>
public static class JUtilities
{
public static float DELTA_TIME = 0.0167f;
private static Mesh quadMesh;
public static Mesh QuadMesh
{
get
{
if (quadMesh == null)
{
quadMesh = JUtilities.GetPrimitiveMesh(PrimitiveType.Quad);
}
return quadMesh;
}
}
public static string ListElementsToString<T>(this IEnumerable<T> list, string separator)
{
IEnumerator<T> i = list.GetEnumerator();
System.Text.StringBuilder s = new System.Text.StringBuilder();
if (i.MoveNext())
s.Append(i.Current.ToString());
while (i.MoveNext())
s.Append(separator).Append(i.Current.ToString());
return s.ToString();
}
public static T[][] CreateJaggedArray<T>(int dimension1, int dimension2)
{
T[][] jaggedArray = new T[dimension1][];
for (int i = 0; i < dimension1; ++i)
{
jaggedArray[i] = new T[dimension2];
}
return jaggedArray;
}
public static T[] To1dArray<T>(T[][] jaggedArray)
{
List<T> result = new List<T>();
for (int z = 0; z < jaggedArray.Length; ++z)
{
for (int x = 0; x < jaggedArray[z].Length; ++x)
{
result.Add(jaggedArray[z][x]);
}
}
return result.ToArray();
}
public static T[] To1dArray<T>(T[,] grid)
{
int height = grid.GetLength(0);
int width = grid.GetLength(1);
T[] result = new T[height * width];
for (int z = 0; z < height; ++z)
{
for (int x = 0; x < width; ++x)
{
result[To1DIndex(x, z, width)] = grid[z, x];
}
}
return result;
}
public static void Fill<T>(T[] array, T value)
{
for (int i = 0; i < array.Length; ++i)
{
array[i] = value;
}
}
public static void CopyTo<T>(T[] src, T[] des)
{
int limit = Mathf.Min(src.Length, des.Length);
for (int i = 0; i < limit; ++i)
{
des[i] = src[i];
}
}
public static int Sum(int[,] array)
{
int sum = 0;
int length = array.GetLength(0);
int width = array.GetLength(1);
for (int z = 0; z < length; ++z)
{
for (int x = 0; x < width; ++x)
{
sum += array[z, x];
}
}
return sum;
}
public static int To1DIndex(int x, int z, int width)
{
return z * width + x;
}
public static bool IsInRange(float number, float minValue, float maxValue)
{
return number >= minValue && number <= maxValue;
}
public static bool IsInRangeExclusive(float number, float minValue, float maxValue)
{
return number > minValue && number < maxValue;
}
public static float GetFraction(float value, float floor, float ceil)
{
return (value - floor) / (ceil - floor);
}
public static void ClearChildren(Transform t)
{
int childCount = t.childCount;
for (int i = childCount - 1; i >= 0; --i)
{
#if UNITY_EDITOR
if (!UnityEditor.EditorApplication.isPlaying)
{
GameObject.DestroyImmediate(t.GetChild(i).gameObject);
}
else
{
GameObject.Destroy(t.GetChild(i).gameObject);
}
#else
GameObject.Destroy(t.GetChild(i).gameObject);
#endif
}
}
public static Gradient CreateFullWhiteGradient()
{
Gradient g = new Gradient();
GradientColorKey color = new GradientColorKey(Color.white, 1);
GradientAlphaKey alpha = new GradientAlphaKey(1, 1);
g.SetKeys(new GradientColorKey[] { color }, new GradientAlphaKey[] { alpha });
return g;
}
public static Gradient CreateFullTransparentGradient()
{
Gradient g = new Gradient();
GradientColorKey color = new GradientColorKey(Color.white, 1);
GradientAlphaKey alpha = new GradientAlphaKey(0, 1);
g.SetKeys(new GradientColorKey[] { color }, new GradientAlphaKey[] { alpha });
return g;
}
public static void CalculateBarycentricCoord(Vector2 p, Vector2 p1, Vector2 p2, Vector2 p3, ref Vector3 bary)
{
Vector2 v0 = p2 - p1;
Vector2 v1 = p3 - p1;
Vector2 v2 = p - p1;
float d00 = Vector2.Dot(v0, v0);
float d01 = Vector2.Dot(v0, v1);
float d11 = Vector2.Dot(v1, v1);
float d20 = Vector2.Dot(v2, v0);
float d21 = Vector2.Dot(v2, v1);
float inverseDenom = 1 / (d00 * d11 - d01 * d01);
bary.y = (d11 * d20 - d01 * d21) * inverseDenom;
bary.z = (d00 * d21 - d01 * d20) * inverseDenom;
bary.x = 1.0f - bary.y - bary.z;
}
public static void ExpandTrisUvCoord(Texture2D tex, Vector2[] trisUv)
{
Vector2 texelSize = tex.texelSize;
Vector2 center = (trisUv[0] + trisUv[1] + trisUv[2]) / 3;
trisUv[0] += (trisUv[0] - center).normalized * texelSize.magnitude;
trisUv[0].x = Mathf.Clamp01(trisUv[0].x);
trisUv[0].y = Mathf.Clamp01(trisUv[0].y);
trisUv[1] += (trisUv[1] - center).normalized * texelSize.magnitude;
trisUv[1].x = Mathf.Clamp01(trisUv[1].x);
trisUv[1].y = Mathf.Clamp01(trisUv[1].y);
trisUv[2] += (trisUv[2] - center).normalized * texelSize.magnitude;
trisUv[2].x = Mathf.Clamp01(trisUv[2].x);
trisUv[2].y = Mathf.Clamp01(trisUv[2].y);
}
public static bool ContainIdenticalElements<T>(T[] arr1, T[] arr2)
{
if (arr1 == null && arr2 == null)
return true;
if (arr1 == null && arr2 != null)
return false;
if (arr1 != null && arr2 == null)
return false;
if (arr1.Length != arr2.Length)
return false;
for (int i = 0; i < arr1.Length; ++i)
{
if (!arr1[i].Equals(arr2[i]))
return false;
}
return true;
}
public static float GetNearestMultiple(float number, float multipleOf)
{
int multiplier = 0;
while (multipleOf * multiplier < number)
{
multiplier += 1;
}
float floor = multipleOf * (multiplier - 1);
float ceil = multipleOf * multiplier;
float f0 = number - floor;
float f1 = ceil - number;
if (f0 < f1)
return floor;
else
return ceil;
}
public static Transform GetChildrenWithName(Transform parent, string name)
{
Transform t = parent.Find(name);
if (t == null)
{
GameObject g = new GameObject(name);
g.transform.parent = parent;
ResetTransform(g.transform, parent);
t = g.transform;
}
return t;
}
public static void ResetTransform(Transform t, Transform parent)
{
t.parent = parent;
t.localPosition = Vector3.zero;
t.localRotation = Quaternion.identity;
t.localScale = Vector3.one;
}
public static void DestroyGameobject(GameObject g)
{
#if UNITY_EDITOR
if (UnityEditor.EditorApplication.isPlaying)
GameObject.Destroy(g);
else
GameObject.DestroyImmediate(g);
#else
GameObject.Destroy(g);
#endif
}
public static void DestroyGameObjectWithUndo(GameObject g)
{
#if UNITY_EDITOR
Undo.DestroyObjectImmediate(g);
#else
DestroyGameobject(g);
#endif
}
public static void DestroyObject(Object o)
{
#if UNITY_EDITOR
if (UnityEditor.EditorApplication.isPlaying)
Object.Destroy(o);
else
Object.DestroyImmediate(o, true);
#else
GameObject.Destroy(o);
#endif
}
public static string Repeat(char src, int count)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(src, count);
return sb.ToString();
}
public static void MarkCurrentSceneDirty()
{
#if UNITY_EDITOR
if (!UnityEditor.EditorApplication.isPlaying)
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
#endif
}
public static GameObject[] GetChildrenGameObjects(Transform parent)
{
GameObject[] children = new GameObject[parent.childCount];
for (int i = 0; i < parent.childCount; ++i)
{
children[i] = parent.GetChild(i).gameObject;
}
return children;
}
public static Transform[] GetChildrenTransforms(Transform parent)
{
Transform[] children = new Transform[parent.childCount];
for (int i = 0; i < parent.childCount; ++i)
{
children[i] = parent.GetChild(i);
}
return children;
}
/// <summary>
/// https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula
/// </summary>
/// <param name="vector"></param>
/// <param name="normal"></param>
/// <param name="angleDegree"></param>
/// <returns></returns>
public static Vector3 RotateVectorAroundNormal(Vector3 vector, Vector3 normal, float angleDegree)
{
float sin = Mathf.Sin(angleDegree * Mathf.Deg2Rad);
float cos = Mathf.Cos(angleDegree * Mathf.Deg2Rad);
Vector3 rotatedVector =
vector * cos +
Vector3.Cross(normal, vector) * sin +
normal * Vector3.Dot(normal, vector) * (1 - cos);
return rotatedVector;
}
public static Mesh GetPrimitiveMesh(PrimitiveType type)
{
GameObject g = GameObject.CreatePrimitive(type);
Mesh m = g.GetComponent<MeshFilter>().sharedMesh;
DestroyGameobject(g);
return m;
}
public static void ShuffleList<T>(List<T> list)
{
int length = list.Count;
for (int i = 0; i < length - 1; ++i)
{
int j = UnityEngine.Random.Range(0, length);
T tmp = list[i];
list[i] = list[j];
list[j] = tmp;
}
}
public static int[] GetShuffleIndicesArray(int length)
{
int[] indices = GetIndicesArray(length);
for (int i = 0; i < length - 1; ++i)
{
int j = UnityEngine.Random.Range(0, length);
int tmp = indices[i];
indices[i] = indices[j];
indices[j] = tmp;
}
return indices;
}
public static int[] GetIndicesArray(int length)
{
int[] indices = new int[length];
for (int i = 0; i < length; ++i)
{
indices[i] = i;
}
return indices;
}
public static void ResetArray<T>(ref T[] array, int count, T defaultValue)
{
if (array != null && array.Length == count)
{
JUtilities.Fill(array, defaultValue);
}
else
{
array = new T[count];
}
}
public static bool EnsureArrayLength<T>(ref T[] array, int count)
{
if (array == null || array.Length != count)
{
array = new T[count];
return false;
}
return true;
}
public static float GetValueBilinear(float[] data, int width, int height, Vector2 uv)
{
float value = 0;
Vector2 pixelCoord = new Vector2(
Mathf.Lerp(0, width - 1, uv.x),
Mathf.Lerp(0, height - 1, uv.y));
//apply a bilinear filter
int xFloor = Mathf.FloorToInt(pixelCoord.x);
int xCeil = Mathf.CeilToInt(pixelCoord.x);
int yFloor = Mathf.FloorToInt(pixelCoord.y);
int yCeil = Mathf.CeilToInt(pixelCoord.y);
float f00 = data[JUtilities.To1DIndex(xFloor, yFloor, width)];
float f01 = data[JUtilities.To1DIndex(xFloor, yCeil, width)];
float f10 = data[JUtilities.To1DIndex(xCeil, yFloor, width)];
float f11 = data[JUtilities.To1DIndex(xCeil, yCeil, width)];
Vector2 unitCoord = new Vector2(
pixelCoord.x - xFloor,
pixelCoord.y - yFloor);
value =
f00 * (1 - unitCoord.x) * (1 - unitCoord.y) +
f01 * (1 - unitCoord.x) * unitCoord.y +
f10 * unitCoord.x * (1 - unitCoord.y) +
f11 * unitCoord.x * unitCoord.y;
return value;
}
public static Color GetColorBilinear(Color[] textureData, int width, int height, Vector2 uv)
{
Color color = Color.clear;
Vector2 pixelCoord = new Vector2(
Mathf.Lerp(0, width - 1, uv.x),
Mathf.Lerp(0, height - 1, uv.y));
//apply a bilinear filter
int xFloor = Mathf.FloorToInt(pixelCoord.x);
int xCeil = Mathf.CeilToInt(pixelCoord.x);
int yFloor = Mathf.FloorToInt(pixelCoord.y);
int yCeil = Mathf.CeilToInt(pixelCoord.y);
Color f00 = textureData[JUtilities.To1DIndex(xFloor, yFloor, width)];
Color f01 = textureData[JUtilities.To1DIndex(xFloor, yCeil, width)];
Color f10 = textureData[JUtilities.To1DIndex(xCeil, yFloor, width)];
Color f11 = textureData[JUtilities.To1DIndex(xCeil, yCeil, width)];
Vector2 unitCoord = new Vector2(
pixelCoord.x - xFloor,
pixelCoord.y - yFloor);
color =
f00 * (1 - unitCoord.x) * (1 - unitCoord.y) +
f01 * (1 - unitCoord.x) * unitCoord.y +
f10 * unitCoord.x * (1 - unitCoord.y) +
f11 * unitCoord.x * unitCoord.y;
return color;
}
public static GameObject CreatePreviewGameObject(Mesh m, Material mat, Vector3 position)
{
GameObject g = new GameObject("GO");
g.transform.position = position;
g.transform.rotation = Quaternion.identity;
g.transform.localScale = Vector3.one;
MeshFilter mf = g.AddComponent<MeshFilter>();
mf.sharedMesh = m;
MeshRenderer mr = g.AddComponent<MeshRenderer>();
mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
mr.receiveShadows = false;
mr.sharedMaterial = mat;
return g;
}
public static Camera CreatePreviewCamera(GameObject target, float distance, float padding)
{
GameObject g = new GameObject("CAM");
g.transform.rotation = Quaternion.identity;
g.transform.localScale = Vector3.one;
Camera cam = g.AddComponent<Camera>();
cam.orthographic = true;
cam.clearFlags = CameraClearFlags.Nothing;
cam.aspect = 1;
MeshRenderer mr = target.GetComponent<MeshRenderer>();
Bounds bounds = mr.bounds;
cam.transform.position = bounds.center + new Vector3(-1, 0.5f, -1) * distance;
cam.transform.LookAt(bounds.center);
cam.orthographicSize = Mathf.Max(bounds.size.x, bounds.size.y, bounds.size.z) / 2 + padding;
return cam;
}
public static void EnsureDirectoryExists(string dir)
{
if (!System.IO.Directory.Exists(dir))
{
System.IO.Directory.CreateDirectory(dir);
}
}
public static void SetStaticRecursively(GameObject g, bool isStatic)
{
#if UNITY_EDITOR
g.isStatic = isStatic;
GameObject[] children = GetChildrenGameObjects(g.transform);
for (int i = 0; i < children.Length; ++i)
{
SetStaticRecursively(children[i], isStatic);
}
#endif
}
public static void EnsureLengthSufficient<T>(List<T> list, int preferredLength) where T : Object
{
if (list == null)
list = new List<T>();
while (list.Count < preferredLength)
{
list.Add(null);
}
}
public static void EnsureLengthSufficient(List<string> list, int preferredLength)
{
if (list == null)
list = new List<string>();
while (list.Count < preferredLength)
{
list.Add(string.Empty);
}
}
public static void EnsureLengthSufficient(List<bool> list, int preferredLength)
{
if (list == null)
list = new List<bool>();
while (list.Count < preferredLength)
{
list.Add(false);
}
}
public static string Ellipsis(string s, int length)
{
if (s.Length < length)
return s;
string s0 = s.Substring(0, length);
return s0 + "...";
}
public static bool IsRectContainPointExclusive(Rect r, Vector2 p)
{
return
p.x > r.min.x &&
p.x < r.max.x &&
p.y > r.min.y &&
p.y < r.max.y;
}
public static Color GetColor(Color baseColor, float alpha)
{
return new Color(baseColor.r, baseColor.g, baseColor.b, alpha);
}
public static Rect GetRectContainsPoints(params Vector2[] points)
{
float xMin = float.MaxValue;
float xMax = float.MinValue;
float yMin = float.MaxValue;
float yMax = float.MinValue;
for (int i = 0; i < points.Length; ++i)
{
xMin = points[i].x < xMin ? points[i].x : xMin;
xMax = points[i].x > xMax ? points[i].x : xMax;
yMin = points[i].y < yMin ? points[i].y : yMin;
yMax = points[i].y > yMax ? points[i].y : yMax;
}
return Rect.MinMaxRect(xMin, yMin, xMax, yMax);
}
public static float InverseLerpUnclamped(float a, float b, float value)
{
if (a != b)
{
return (value - a) / (b - a);
}
return 0f;
}
public static Vector2 PointToNormalizedUnclampled(Rect r, Vector2 point)
{
return new Vector2(InverseLerpUnclamped(r.x, r.xMax, point.x), InverseLerpUnclamped(r.y, r.yMax, point.y));
}
public static Rect GetUvRect(Vector2 v0, Vector2 v1, Vector2 v2)
{
return Rect.MinMaxRect(
Mathf.Min(v0.x, v1.x, v2.x),
Mathf.Min(v0.y, v1.y, v2.y),
Mathf.Max(v0.x, v1.x, v2.x),
Mathf.Max(v0.y, v1.y, v2.y));
}
public static Gradient Clone(Gradient src)
{
if (src == null)
return null;
Gradient des = new Gradient();
des.SetKeys(src.colorKeys, src.alphaKeys);
return des;
}
public static AnimationCurve Clone(AnimationCurve src)
{
if (src == null)
return null;
AnimationCurve des = new AnimationCurve();
Keyframe[] keys = src.keys;
for (int i = 0; i < keys.Length; ++i)
{
des.AddKey(keys[i]);
}
des.preWrapMode = src.preWrapMode;
des.postWrapMode = src.postWrapMode;
return des;
}
public static bool IsPointInsideQuadXZ(Vector3 point, Vector3[] quad)
{
Vector3 bary = Vector3.zero;
CalculateBarycentricCoord(
new Vector2(point.x, point.z),
new Vector2(quad[0].x, quad[0].z),
new Vector2(quad[1].x, quad[1].z),
new Vector2(quad[2].x, quad[2].z),
ref bary);
if (bary.x >= 0 && bary.y >= 0 && bary.z >= 0)
return true;
CalculateBarycentricCoord(
new Vector2(point.x, point.z),
new Vector2(quad[0].x, quad[0].z),
new Vector2(quad[2].x, quad[2].z),
new Vector2(quad[3].x, quad[3].z),
ref bary);
if (bary.x >= 0 && bary.y >= 0 && bary.z >= 0)
return true;
return false;
}
public static void DestroyMeshArray(Mesh[] meshes)
{
for (int i = 0; i < meshes.Length; ++i)
{
if (meshes[i] != null)
{
Object.DestroyImmediate(meshes[i], true);
}
}
}
public static Vector2 FlipY(Vector2 v)
{
return new Vector2(v.x, 1 - v.y);
}
/// <summary>
/// https://en.wikipedia.org/wiki/Delaunay_triangulation#Algorithms
/// </summary>
/// <param name="v0"></param>
/// <param name="v1"></param>
/// <param name="v2"></param>
/// <param name="p"></param>
/// <returns></returns>
public static bool IsPointInCircumcircle(Vector2 v0, Vector2 v1, Vector2 v2, Vector2 p)
{
Matrix4x4 mat = new Matrix4x4();
mat.SetRow(0, new Vector4(v0.x, v0.y, v0.x * v0.x + v0.y * v0.y, 1));
mat.SetRow(1, new Vector4(v2.x, v2.y, v2.x * v2.x + v2.y * v2.y, 1)); //a,b,c counterclockwise
mat.SetRow(2, new Vector4(v1.x, v1.y, v1.x * v1.x + v1.y * v1.y, 1));
mat.SetRow(3, new Vector4(p.x, p.y, p.x * p.x + p.y * p.y, 1));
return mat.determinant > 0;
}
public static bool IsPointInCircumcircleXZ(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 p)
{
Matrix4x4 mat = new Matrix4x4();
mat.SetRow(0, new Vector4(v0.x, v0.z, v0.x * v0.x + v0.z * v0.z, 1));
mat.SetRow(1, new Vector4(v2.x, v2.z, v2.x * v2.x + v2.z * v2.z, 1)); //a,b,c counterclockwise
mat.SetRow(2, new Vector4(v1.x, v1.z, v1.x * v1.x + v1.z * v1.z, 1));
mat.SetRow(3, new Vector4(p.x, p.z, p.x * p.x + p.z * p.z, 1));
return mat.determinant > 0;
}
public static bool AreSetEqual(ushort[] setA, ushort[] setB)
{
HashSet<ushort> a = new HashSet<ushort>(setA);
HashSet<ushort> b = new HashSet<ushort>(setB);
return a.SetEquals(b);
}
public static void Distinct<T>(this List<T> list)
{
list.Distinct();
}
public static void AddIfNotContains<T>(this IList<T> list, IEnumerable<T> items)
{
IEnumerator<T> iter = items.GetEnumerator();
while (iter.MoveNext())
{
T current = iter.Current;
if (!list.Contains(current))
{
list.Add(current);
}
}
}
public static void AddIfNotContains<T>(this IList<T> list, T item)
{
if (!list.Contains(item))
{
list.Add(item);
}
}
public static Vector3 ToX0Y(this Vector2 v)
{
return new Vector3(v.x, 0, v.y);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48370f14849abe24da35b53252b7c4fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Pinwheel.Jupiter
{
/// <summary>
/// Utility class contains product info
/// </summary>
public static class JVersionInfo
{
public static string Code
{
get
{
return "1.2.10";
}
}
public static string ProductName
{
get
{
return "Jupiter - Procedural Sky";
}
}
public static string ProductNameAndVersion
{
get
{
return string.Format("{0} v{1}", ProductName, Code);
}
}
public static string ProductNameShort
{
get
{
return "Jupiter";
}
}
public static string ProductNameAndVersionShort
{
get
{
return string.Format("{0} v{1}", ProductNameShort, Code);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a76ff6fe4de9f6a459c7e47a47a1efeb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: db127a625b9ee034baed09d4ebd7176a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d0c6bd41136f28446b665f2d5e279159
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,6 @@
#ifndef FILE_INCLUDED
#define FILE_INCLUDED
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3c059265d03c297408a316f58ccb37a3
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,162 @@
#ifndef COMMON_INCLUDED
#define COMMON_INCLUDED
sampler2D _NoiseTex;
sampler2D _CloudTex;
float NoiseTexFrag(float2 uv)
{
return tex2D(_NoiseTex, uv).r*2 - 1;
}
float NoiseTexVert(float2 uv)
{
return tex2Dlod(_NoiseTex, float4(uv.xy, 0, 0)).r*2 - 1;
}
float CloudTexFrag(float2 uv)
{
return tex2D(_CloudTex, uv).r*2 - 1;
}
float CloudTexLod0(float2 uv)
{
return tex2Dlod(_CloudTex, float4(uv.xy, 0, 0)).r*2 - 1;
}
float CloudTexVert(float2 uv)
{
return CloudTexLod0(uv);
}
float2 GradientNoise_dir(float2 p)
{
p = p % 289;
float x = (34 * p.x + 1) * p.x % 289 + p.y;
x = (34 * x + 1) * x % 289;
x = frac(x / 41) * 2 - 1;
return normalize(float2(x - floor(x + 0.5), abs(x) - 0.5));
}
float GradientNoise(float2 p)
{
float2 ip = floor(p);
float2 fp = frac(p);
float d00 = dot(GradientNoise_dir(ip), fp);
float d01 = dot(GradientNoise_dir(ip + float2(0, 1)), fp - float2(0, 1));
float d10 = dot(GradientNoise_dir(ip + float2(1, 0)), fp - float2(1, 0));
float d11 = dot(GradientNoise_dir(ip + float2(1, 1)), fp - float2(1, 1));
fp = fp * fp * fp * (fp * (fp * 6 - 15) + 10);
return lerp(lerp(d00, d01, fp.y), lerp(d10, d11, fp.y), fp.x);
}
float InverseLerpUnclamped(float a, float b, float value)
{
//adding a==b check if needed
return (value - a) / (b - a + 0.00000001);
}
float RandomValue(float seed)
{
return frac(seed*23.456*(1+ceil(seed)*12.345));
}
float RandomValue(float3 seed)
{
float3 value = frac(seed*23.456*(1+ceil(seed)*12.345));
return max(value.x, min(value.y, value.z));
}
float2 VoronoiRandomVector (float2 UV, float offset)
{
float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);
UV = frac(sin(mul(UV, m)) * 46839.32);
return float2(sin(UV.y*+offset)*0.5+0.5, cos(UV.x*offset)*0.5+0.5);
}
float Voronoi(float2 UV, float AngleOffset, float CellDensity)
{
float2 g = floor(UV * CellDensity);
float2 f = frac(UV * CellDensity);
float t = 8.0;
float3 res = float3(8.0, 0.0, 0.0);
float noiseValue = 0;
for(int y=-1; y<=1; y++)
{
for(int x=-1; x<=1; x++)
{
float2 lattice = float2(x,y);
float2 offset = VoronoiRandomVector(lattice + g, AngleOffset);
float d = distance(lattice + offset, f);
if(d < res.x)
{
res = float3(d, offset.x, offset.y);
noiseValue = res.x;
}
}
}
return noiseValue;
}
float2 PanUV(float2 uv, float2 speed)
{
return uv + _Time.y*speed;
}
half IsOrtho()
{
return unity_OrthoParams.w;
}
half GetNearPlane()
{
return _ProjectionParams.y;
}
half GetFarPlane()
{
return _ProjectionParams.z;
}
float SqrDistance(float3 pt1, float3 pt2)
{
float3 v = pt2 - pt1;
return dot(v,v);
}
fixed SqrDistance(fixed pt1, fixed pt2)
{
fixed v = pt2 - pt1;
return dot(v,v);
}
float SqrMagnitude(float2 p)
{
return p.x*p.x + p.y*p.y;
}
float SqrMagnitude(float3 p)
{
return p.x*p.x + p.y*p.y + p.z*p.z;
}
float StepValue(float v, float count)
{
float step = 1.0/count;
return v-v%step;
}
float TriangleWave(float t)
{
return 2.0 * abs( 2 * (t - floor(0.5 + t)) ) - 1.0;
}
fixed4 BlendOverlay(fixed4 src, fixed4 des)
{
fixed4 result = src*src.a + des*(1-src.a);
result.a = 1 - (1-src.a)*(1-des.a);
return result;
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f0303c57b5706684594ad27c88d2a37d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#ifndef DETAIL_OVERLAY_INCLUDED
#define DETAIL_OVERLAY_INCLUDED
void CalculateDetailOverlayColor(
float4 localPos,
samplerCUBE cubemap,
fixed4 tint,
out fixed4 color)
{
color = texCUBE(cubemap, localPos.xyz);
color *= tint;
}
void CalculateDetailOverlayColor(
float4 localPos,
samplerCUBE cubemap,
fixed4 tint,
float rotationSpeed,
out fixed4 color)
{
float angle = rotationSpeed*_Time.y;
float sinY = sin(radians(angle));
float cosY = cos(radians(angle));
float3x3 ry = float3x3(cosY, 0, sinY,
0, 1, 0,
-sinY, 0, cosY);
localPos.xyz = mul(ry, localPos.xyz);
color = texCUBE(cubemap, localPos.xyz);
color *= tint;
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3b1f874b66731a847b92da319d75fe24
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
#ifndef HORIZON_CLOUD_INCLUDED
#define HORIZON_CLOUD_INCLUDED
#include "JCommon.cginc"
void CalculateHorizonCloudColor(
float4 localPos,
fixed4 cloudColor,
fixed cloudStart, fixed cloudEnd,
fixed cloudSize, fixed cloudStep,
fixed animationSpeed,
out fixed4 color)
{
fixed fadeBottom = InverseLerpUnclamped(cloudStart, 0, localPos.y);
fixed fadeTop = InverseLerpUnclamped(cloudEnd, 0, localPos.y);
fixed fade = saturate(lerp(fadeBottom, fadeTop, localPos.y >= 0));
fade = fade*fade;
fixed loop;
#if SHADER_API_MOBILE
loop = 1;
#else
loop = 2;
#endif
fixed noise = 0;
fixed sample0 = 0;
fixed sample1 = 0;
fixed noiseSize = cloudSize + 0.0001;
fixed noiseAmp = 1;
fixed sign = -1;
fixed2 span = animationSpeed*_Time.y*0.0001;
for (fixed i=0; i<loop; ++i)
{
sample0 = CloudTexLod0((localPos.xy)/noiseSize + sign*span)*noiseAmp;
sample1 = CloudTexLod0((localPos.yz)/noiseSize + sign*span)*noiseAmp;
noise += (sample0 + sample1)*0.5;
noiseSize *= 0.5;
noiseAmp *= 0.5;
sign *= -1;
}
noise = noise*0.5 + 0.5;
#if ALLOW_STEP_EFFECT
noise = StepValue(noise, cloudStep);
#endif
color = fixed4(1, 1, 1, fade*noise*2)*cloudColor;
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: bbd8ba78921750d40b3e4e70613b06a2
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,65 @@
#ifndef OVERHEAD_CLOUD_INCLUDED
#define OVERHEAD_CLOUD_INCLUDED
#include "JCommon.cginc"
void CalculateOverheadCloudColor(
float4 localPos,
fixed4 cloudColor,
fixed cloudAltitude,
fixed cloudSize, fixed cloudStep,
fixed animationSpeed,
fixed flowX, fixed flowZ,
fixed remapMin, fixed remapMax,
out fixed4 color)
{
fixed3 rayDir = localPos.xyz;
float3 cloudPlaneOrigin = float3(0, cloudAltitude, 0);
float3 cloudPlaneNormal = float3(0, 1, 0);
float rayLength = dot(cloudPlaneOrigin, cloudPlaneNormal) / (dot(rayDir, cloudPlaneNormal) + 0.000001);
float3 intersectionPoint = rayDir * rayLength;
fixed loop;
#if SHADER_API_MOBILE
loop = 1;
#else
loop = 2;
#endif
fixed noise = 0;
fixed sample = 0;
fixed noiseSize = cloudSize * 1000 + 0.0001;
fixed noiseAmp = 1;
fixed sign = -1;
fixed2 span = fixed2(flowX, flowZ) * animationSpeed * _Time.y * 0.0001;
for (fixed i = 0; i < loop; ++i)
{
sample = CloudTexLod0((intersectionPoint.xz) / noiseSize + sign * span) * noiseAmp;
noise += sample;
noiseSize *= 0.5;
noiseAmp *= 0.5;
sign *= -1;
}
noise = noise * 0.5 + 0.5;
noise = noise * cloudColor.a;
noise = lerp(remapMin, remapMax, noise);
noise = saturate(noise);
#if ALLOW_STEP_EFFECT
noise = StepValue(noise, cloudStep);
#endif
color = fixed4(cloudColor.rgb, noise);
float sqrCloudDiscRadius = 100000000;
float sqrDistanceToCloudPlaneOrigin = SqrDistance(intersectionPoint, cloudPlaneOrigin);
fixed fDistance = saturate(1 - InverseLerpUnclamped(0, sqrCloudDiscRadius, sqrDistanceToCloudPlaneOrigin));
color.a *= fDistance * fDistance;
fixed4 clear = fixed4(0, 0, 0, 0);
color = lerp(clear, color, localPos.y > 0);
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9512fc8a4d695464590e82d39ec78719
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
#ifndef SKY_GRADIENT_INCLUDED
#define SKY_GRADIENT_INCLUDED
#include "JCommon.cginc"
void CalculateSkyGradientColor(
float4 localPos,
fixed4 skyColor, fixed4 horizonColor, fixed4 groundColor,
fixed horizonThickness, fixed horizonExponent, fixed horizonStep,
out fixed4 skyBlendColor, out fixed4 horizonBlendColor)
{
skyBlendColor = lerp(groundColor, skyColor, localPos.y > 0);
horizonThickness *= lerp(0.25, 1, localPos.y > 0);
#if ALLOW_STEP_EFFECT
localPos.y = StepValue(localPos.y, horizonStep);
#endif
fixed horizonBlendFactor = saturate(1 - InverseLerpUnclamped(0, horizonThickness, abs(localPos.y)));
horizonBlendFactor = pow(horizonBlendFactor, horizonExponent);
//horizon = lerp(color, horizonColor, horizonBlendFactor);
horizonBlendColor = fixed4(horizonColor.xyz, horizonBlendFactor*horizonColor.a);
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6a99e12682a251a418901c7b6f70bb20
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
#ifndef STARS_INCLUDED
#define STARS_INCLUDED
#include "JCommon.cginc"
void CalculateStarsColor(
float4 localPos,
float starsStartPosition, float starsEndPosition,
fixed4 starsColor, fixed starsOpacity,
float starsDensity,
float starsSize,
fixed starsGlow,
fixed starsTwinkle,
out fixed4 color)
{
float cellCount = starsDensity*50;
float cellSize = 1/cellCount;
float3 cellCenter = floor(localPos.xyz/cellSize)*cellSize + 0.5*cellSize*float3(1,1,1);
float rand = RandomValue(cellCenter.xyz) - 0.5;
float3 starPos = cellCenter + float3(1,1,1)*cellSize*rand;
float sqrDistance = SqrDistance(localPos.xyz, starPos);
float sqrDistanceThreshold = 0.00001*starsSize*starsSize;
fixed4 clear = fixed4(0,0,0,0);
fixed4 white = fixed4(1,1,1,1);
color = lerp(clear, white, sqrDistance <= sqrDistanceThreshold);
color *= starsColor;
color.a *= 2*(1 + starsGlow)*(rand + 0.5);
float wave = TriangleWave(rand*_Time.y*starsTwinkle)*0.5 + 0.5;
color.a *= lerp(0.5, 1, (1-wave));
color.a *= starsOpacity;
color = lerp(clear, color, cellCenter.y >= starsStartPosition);
color = lerp(clear, color, cellCenter.y <= starsEndPosition);
color = lerp(clear, color, rand <= starsDensity);
}
void CalculateStarsColorBaked(
float4 localPos,
samplerCUBE starsCubemap,
sampler2D starsTwinkleMap,
fixed starsOpacity,
out fixed4 color)
{
float2 span = float2(1,1)*_Time.y*0.1;
fixed twinkle = tex2D(starsTwinkleMap, localPos.xy + span).r;
color = texCUBE(starsCubemap, localPos.xyz);
color.a *= twinkle;
color.a *= starsOpacity;
}
#endif

Some files were not shown because too many files have changed in this diff Show More