initial commit
This commit is contained in:
267
Assets/Editor/EarthTextureGenerator.cs
Normal file
267
Assets/Editor/EarthTextureGenerator.cs
Normal file
@@ -0,0 +1,267 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public class EarthTextureGenerator : EditorWindow
|
||||
{
|
||||
public Texture2D sourceTexture;
|
||||
public string outputFolder = "Assets/Textures/Earth";
|
||||
|
||||
[MenuItem("Tools/Earth Texture Generator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<EarthTextureGenerator>("Earth Texture Generator");
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Ãåíåðàòîð òåêñòóð Çåìë³", EditorStyles.boldLabel);
|
||||
sourceTexture = (Texture2D)EditorGUILayout.ObjectField("Òåêñòóðà Çåìë³", sourceTexture, typeof(Texture2D), false);
|
||||
outputFolder = EditorGUILayout.TextField("Ïàïêà çáåðåæåííÿ", outputFolder);
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òðîïîñôåðà (âèñèõàííÿ)", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó!", "OK"); return; }
|
||||
GenerateAllTextures("Tropo", GenerateTexture);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Ñòðàòîñôåðà (UV îï³ê)", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó!", "OK"); return; }
|
||||
GenerateAllTextures("Strato", GenerateTextureUV);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òåðìîñôåðà (ïîëþñè ãîðÿòü)", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó!", "OK"); return; }
|
||||
GenerateAllTextures("Thermo", GenerateTextureThermo);
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D GenerateTextureThermo(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color poleGlow = new Color(0.9f, 0.5f, 0.1f);
|
||||
Color poleBurn = new Color(0.8f, 0.2f, 0.05f);
|
||||
Color poleFinal = new Color(0.6f, 0.15f, 0.05f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
int x = p % width;
|
||||
int y = p / width;
|
||||
|
||||
float v = (float)y / height;
|
||||
float poleStrength = Mathf.Clamp01((Mathf.Abs(v - 0.5f) * 2f - 0.5f) * 2f);
|
||||
|
||||
Color col = pixels[p];
|
||||
Color result_col = col;
|
||||
|
||||
if (alive < 1.0f)
|
||||
{
|
||||
float t = Mathf.Clamp01((1.0f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(result_col, poleGlow, poleStrength * t * 0.5f);
|
||||
}
|
||||
|
||||
if (alive < 0.7f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, poleGlow, poleStrength * t);
|
||||
}
|
||||
|
||||
if (alive < 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, poleBurn, poleStrength * t);
|
||||
}
|
||||
|
||||
if (alive < 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(result_col, poleFinal, poleStrength * t);
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
void GenerateAllTextures(string prefix, System.Func<Texture2D, float, Texture2D> generator)
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
float[] levels = { 1.0f, 0.7f, 0.5f, 0.3f, 0.0f };
|
||||
string[] names = { "100", "70", "50", "30", "0" };
|
||||
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Ãåíåðàö³ÿ", prefix + "_" + names[i], (float)i / levels.Length);
|
||||
Texture2D result = generator(sourceTexture, levels[i]);
|
||||
SaveTexture(result, outputFolder + "/" + prefix + "_" + names[i] + ".png");
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðè çáåðåæåíî â " + outputFolder, "OK");
|
||||
}
|
||||
|
||||
Texture2D GenerateTexture(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color greenYellow = new Color(0.68f, 0.60f, 0.12f);
|
||||
Color greenDead = new Color(0.45f, 0.35f, 0.18f);
|
||||
Color oceanLight = new Color(0.82f, 0.92f, 0.94f);
|
||||
Color oceanBoiling = new Color(0.94f, 0.96f, 0.97f);
|
||||
Color oceanGone = new Color(0.55f, 0.48f, 0.35f);
|
||||
Color landDead = new Color(0.52f, 0.42f, 0.28f);
|
||||
Color finalDead = new Color(0.38f, 0.30f, 0.20f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
Color col = pixels[p];
|
||||
|
||||
float isOcean = Mathf.Clamp01(col.b - col.r * 0.5f - col.g * 0.3f);
|
||||
float isGreen = Mathf.Clamp01((col.g - col.r * 0.5f - col.b * 0.4f) * 2f);
|
||||
float isForest = Mathf.Clamp01((col.g - col.r * 0.6f - col.b * 0.5f) * 3f);
|
||||
float isLand = Mathf.Clamp01(1f - isOcean);
|
||||
|
||||
Color result_col = col;
|
||||
|
||||
if (alive < 1.0f)
|
||||
{
|
||||
float t = Mathf.Clamp01((1.0f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(result_col, greenYellow, isGreen * t);
|
||||
}
|
||||
|
||||
if (alive < 0.7f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, greenDead, (isGreen + isForest) * 0.5f * t);
|
||||
result_col = Color.Lerp(result_col, oceanLight, isOcean * t * 0.5f);
|
||||
}
|
||||
|
||||
if (alive < 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, oceanBoiling, isOcean * t);
|
||||
}
|
||||
|
||||
if (alive < 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, oceanGone, isOcean * t);
|
||||
result_col = Color.Lerp(result_col, landDead, isLand * t * 0.4f);
|
||||
}
|
||||
|
||||
if (alive < 0.1f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.1f - alive) / 0.1f);
|
||||
result_col = Color.Lerp(result_col, finalDead, t);
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
Texture2D GenerateTextureUV(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color burnYellow = new Color(0.80f, 0.70f, 0.05f);
|
||||
Color burnOrange = new Color(0.70f, 0.40f, 0.05f);
|
||||
Color burnBrown = new Color(0.50f, 0.28f, 0.05f);
|
||||
Color oceanGray = new Color(0.45f, 0.45f, 0.45f);
|
||||
Color finalAsh = new Color(0.35f, 0.30f, 0.25f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
Color col = pixels[p];
|
||||
|
||||
float isOcean = Mathf.Clamp01(col.b - col.r * 0.5f - col.g * 0.3f);
|
||||
float isGreen = Mathf.Clamp01((col.g - col.r * 0.5f - col.b * 0.4f) * 2f);
|
||||
float isForest = Mathf.Clamp01((col.g - col.r * 0.6f - col.b * 0.5f) * 3f);
|
||||
float isLand = Mathf.Clamp01(1f - isOcean);
|
||||
|
||||
Color result_col = col;
|
||||
|
||||
if (alive < 1.0f)
|
||||
{
|
||||
float t = Mathf.Clamp01((1.0f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(result_col, burnYellow, isGreen * t * 0.7f);
|
||||
}
|
||||
|
||||
if (alive < 0.7f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, burnOrange, (isGreen + isForest) * 0.5f * t);
|
||||
}
|
||||
|
||||
if (alive < 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, burnBrown, isLand * t * 0.8f);
|
||||
result_col = Color.Lerp(result_col, oceanGray, isOcean * t);
|
||||
}
|
||||
|
||||
if (alive < 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(result_col, finalAsh, t);
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
void SaveTexture(Texture2D tex, string path)
|
||||
{
|
||||
byte[] bytes = tex.EncodeToPNG();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
}
|
||||
|
||||
void MakeTextureReadable(Texture2D tex)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(tex);
|
||||
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
if (importer != null && !importer.isReadable)
|
||||
{
|
||||
importer.isReadable = true;
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/EarthTextureGenerator.cs.meta
Normal file
11
Assets/Editor/EarthTextureGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e411ace4f29d75540a30a1faea882768
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
163
Assets/Editor/JupiterTextureGenerator.cs
Normal file
163
Assets/Editor/JupiterTextureGenerator.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public class JupiterTextureGenerator : EditorWindow
|
||||
{
|
||||
public Texture2D sourceTexture;
|
||||
public string outputFolder = "Assets/Textures/Jupiter";
|
||||
|
||||
[MenuItem("Tools/Jupiter Texture Generator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<JupiterTextureGenerator>("Jupiter Texture Generator");
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Ãåíåðàòîð òåêñòóð Þï³òåðà", EditorStyles.boldLabel);
|
||||
sourceTexture = (Texture2D)EditorGUILayout.ObjectField("Òåêñòóðà Þï³òåðà", sourceTexture, typeof(Texture2D), false);
|
||||
outputFolder = EditorGUILayout.TextField("Ïàïêà çáåðåæåííÿ", outputFolder);
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òðîïîñôåðà (çíèêíåííÿ ñìóã)", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó!", "OK"); return; }
|
||||
GenerateAllTextures("Tropo", GenerateTropoTexture);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òåêñòóðà ñìåðò³", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó!", "OK"); return; }
|
||||
GenerateDeadTexture();
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D GenerateTropoTexture(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color fadedOrange = new Color(0.85f, 0.65f, 0.35f);
|
||||
Color paleYellow = new Color(0.9f, 0.82f, 0.6f);
|
||||
Color grayDead = new Color(0.45f, 0.38f, 0.3f);
|
||||
Color darkDead = new Color(0.25f, 0.2f, 0.15f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
Color col = pixels[p];
|
||||
Color result_col = col;
|
||||
|
||||
float isBelt = Mathf.Clamp01((col.r - col.g * 0.5f - col.b * 0.3f) * 2f);
|
||||
float brightness = (col.r + col.g + col.b) / 3f;
|
||||
|
||||
if (alive < 0.7f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, fadedOrange, isBelt * t * 0.4f);
|
||||
}
|
||||
|
||||
if (alive < 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, paleYellow, t * 0.5f);
|
||||
}
|
||||
|
||||
if (alive < 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, grayDead, t * 0.7f);
|
||||
}
|
||||
|
||||
if (alive < 0.1f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.1f - alive) / 0.1f);
|
||||
result_col = Color.Lerp(result_col, darkDead, t);
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
void GenerateDeadTexture()
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
int width = sourceTexture.width;
|
||||
int height = sourceTexture.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
|
||||
Color[] pixels = sourceTexture.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color deadBrown = new Color(0.3f, 0.22f, 0.15f);
|
||||
Color darkGray = new Color(0.18f, 0.15f, 0.12f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
Color col = pixels[p];
|
||||
float brightness = (col.r + col.g + col.b) / 3f;
|
||||
Color result_col = Color.Lerp(darkGray, deadBrown, brightness);
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
|
||||
SaveTexture(result, outputFolder + "/Dead.png");
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðà ñìåðò³ çáåðåæåíà â " + outputFolder, "OK");
|
||||
}
|
||||
|
||||
void GenerateAllTextures(string prefix, System.Func<Texture2D, float, Texture2D> generator)
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
float[] levels = { 1.0f, 0.7f, 0.5f, 0.3f, 0.0f };
|
||||
string[] names = { "100", "70", "50", "30", "0" };
|
||||
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Ãåíåðàö³ÿ", prefix + "_" + names[i], (float)i / levels.Length);
|
||||
Texture2D result = generator(sourceTexture, levels[i]);
|
||||
SaveTexture(result, outputFolder + "/" + prefix + "_" + names[i] + ".png");
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðè çáåðåæåíî â " + outputFolder, "OK");
|
||||
}
|
||||
|
||||
void SaveTexture(Texture2D tex, string path)
|
||||
{
|
||||
byte[] bytes = tex.EncodeToPNG();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
}
|
||||
|
||||
void MakeTextureReadable(Texture2D tex)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(tex);
|
||||
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
if (importer != null && !importer.isReadable)
|
||||
{
|
||||
importer.isReadable = true;
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/JupiterTextureGenerator.cs.meta
Normal file
11
Assets/Editor/JupiterTextureGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 289d9cbc9031d0f4b82d43859897d6be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
204
Assets/Editor/MarsTextureGenerator.cs
Normal file
204
Assets/Editor/MarsTextureGenerator.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public class MarsTextureGenerator : EditorWindow
|
||||
{
|
||||
public Texture2D sourceTexture;
|
||||
public string outputFolder = "Assets/Textures/Mars";
|
||||
|
||||
[MenuItem("Tools/Mars Texture Generator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<MarsTextureGenerator>("Mars Texture Generator");
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Ãåíåðàòîð òåêñòóð Ìàðñà", EditorStyles.boldLabel);
|
||||
sourceTexture = (Texture2D)EditorGUILayout.ObjectField("Òåêñòóðà Ìàðñà", sourceTexture, typeof(Texture2D), false);
|
||||
outputFolder = EditorGUILayout.TextField("Ïàïêà çáåðåæåííÿ", outputFolder);
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òðîïîñôåðà (âèñèõàííÿ + äåíü/í³÷)", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó!", "OK"); return; }
|
||||
GenerateAllTextures("Tropo", GenerateTropoTexture);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òåðìîñôåðà (ñîíÿ÷íèé â³òåð + âòðàòà àòìîñôåðè)", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó!", "OK"); return; }
|
||||
GenerateAllTextures("Thermo", GenerateThermoTexture);
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D GenerateTropoTexture(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color dustyRed = new Color(0.8f, 0.4f, 0.2f);
|
||||
Color dryOrange = new Color(0.6f, 0.3f, 0.1f);
|
||||
Color darkBrown = new Color(0.35f, 0.18f, 0.08f);
|
||||
Color grayDead = new Color(0.25f, 0.22f, 0.20f);
|
||||
Color blackDead = new Color(0.15f, 0.13f, 0.12f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
int x = p % width;
|
||||
int y = p / width;
|
||||
|
||||
Color col = pixels[p];
|
||||
Color result_col = col;
|
||||
|
||||
float isRed = Mathf.Clamp01((col.r - col.b * 0.5f - col.g * 0.3f) * 2f);
|
||||
float isBright = Mathf.Clamp01((col.r + col.g + col.b) / 3f);
|
||||
|
||||
if (alive < 1.0f)
|
||||
{
|
||||
float t = Mathf.Clamp01((1.0f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(result_col, dustyRed, isRed * t * 0.3f);
|
||||
}
|
||||
|
||||
if (alive < 0.7f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, dryOrange, isRed * t * 0.5f);
|
||||
result_col = Color.Lerp(result_col, darkBrown, isBright * t * 0.3f);
|
||||
}
|
||||
|
||||
if (alive < 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, darkBrown, t * 0.6f);
|
||||
}
|
||||
|
||||
if (alive < 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, grayDead, t * 0.7f);
|
||||
}
|
||||
|
||||
if (alive < 0.1f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.1f - alive) / 0.1f);
|
||||
result_col = Color.Lerp(result_col, blackDead, t);
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
Texture2D GenerateThermoTexture(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color burnedDark = new Color(0.2f, 0.15f, 0.12f);
|
||||
Color coldGray = new Color(0.35f, 0.35f, 0.4f);
|
||||
Color spaceBlack = new Color(0.05f, 0.05f, 0.07f);
|
||||
Color solarGlow = new Color(1f, 0.6f, 0.2f);
|
||||
Color ionBlue = new Color(0.4f, 0.7f, 1f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
int x = p % width;
|
||||
int y = p / width;
|
||||
|
||||
Color col = pixels[p];
|
||||
Color result_col = col;
|
||||
|
||||
float heightFactor = (float)y / height;
|
||||
float noise = Mathf.PerlinNoise(x * 0.02f, y * 0.02f);
|
||||
|
||||
if (alive < 0.8f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.8f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(result_col, ionBlue, heightFactor * t * 0.4f);
|
||||
}
|
||||
|
||||
if (alive < 0.6f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.6f - alive) / 0.3f);
|
||||
float glowMask = heightFactor * noise;
|
||||
result_col = Color.Lerp(result_col, solarGlow, glowMask * t * 0.7f);
|
||||
}
|
||||
|
||||
if (alive < 0.4f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.4f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, burnedDark, t * 0.6f);
|
||||
}
|
||||
|
||||
if (alive < 0.2f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.2f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, coldGray, t * 0.7f);
|
||||
}
|
||||
|
||||
if (alive < 0.05f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.05f - alive) / 0.05f);
|
||||
result_col = Color.Lerp(result_col, spaceBlack, t);
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
void GenerateAllTextures(string prefix, System.Func<Texture2D, float, Texture2D> generator)
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
float[] levels = { 1.0f, 0.7f, 0.5f, 0.3f, 0.0f };
|
||||
string[] names = { "100", "70", "50", "30", "0" };
|
||||
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Ãåíåðàö³ÿ", prefix + "_" + names[i], (float)i / levels.Length);
|
||||
Texture2D result = generator(sourceTexture, levels[i]);
|
||||
SaveTexture(result, outputFolder + "/" + prefix + "_" + names[i] + ".png");
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðè çáåðåæåíî â " + outputFolder, "OK");
|
||||
}
|
||||
|
||||
void SaveTexture(Texture2D tex, string path)
|
||||
{
|
||||
byte[] bytes = tex.EncodeToPNG();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
}
|
||||
|
||||
void MakeTextureReadable(Texture2D tex)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(tex);
|
||||
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
if (importer != null && !importer.isReadable)
|
||||
{
|
||||
importer.isReadable = true;
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/MarsTextureGenerator.cs.meta
Normal file
11
Assets/Editor/MarsTextureGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac31927ce28cfb344a1ef8d157662053
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
136
Assets/Editor/MercuryTextureGenerator.cs
Normal file
136
Assets/Editor/MercuryTextureGenerator.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public class MercuryTextureGenerator : EditorWindow
|
||||
{
|
||||
public Texture2D sourceTexture;
|
||||
public string outputFolder = "Assets/Textures/Mercury";
|
||||
|
||||
[MenuItem("Tools/Mercury Texture Generator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<MercuryTextureGenerator>("Mercury Texture Generator");
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Ãåíåðàòîð òåêñòóð Ìåðêóð³ÿ", EditorStyles.boldLabel);
|
||||
sourceTexture = (Texture2D)EditorGUILayout.ObjectField("Òåêñòóðà Ìåðêóð³ÿ", sourceTexture, typeof(Texture2D), false);
|
||||
outputFolder = EditorGUILayout.TextField("Ïàïêà çáåðåæåííÿ", outputFolder);
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Åêçîñôåðà (ìåòåîðèòè + â³òåð)", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó!", "OK"); return; }
|
||||
GenerateAllTextures("Mercury", GenerateTextureMercury);
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D GenerateTextureMercury(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color craterDark = new Color(0.25f, 0.22f, 0.20f);
|
||||
Color heatSide = new Color(0.65f, 0.35f, 0.15f);
|
||||
Color coldSide = new Color(0.30f, 0.32f, 0.40f);
|
||||
Color burnedOut = new Color(0.18f, 0.15f, 0.12f);
|
||||
Color finalDead = new Color(0.10f, 0.08f, 0.07f);
|
||||
|
||||
System.Random rng = new System.Random(42);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
int x = p % width;
|
||||
int y = p / width;
|
||||
|
||||
float u = (float)x / width;
|
||||
float v = (float)y / height;
|
||||
|
||||
Color col = pixels[p];
|
||||
Color result_col = col;
|
||||
|
||||
if (alive < 1.0f)
|
||||
{
|
||||
float t = Mathf.Clamp01((1.0f - alive) / 0.3f);
|
||||
float noise = (float)rng.NextDouble();
|
||||
if (noise < 0.03f * t)
|
||||
result_col = Color.Lerp(result_col, craterDark, t * 0.8f);
|
||||
}
|
||||
|
||||
if (alive < 0.7f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
float heatInfluence = Mathf.Clamp01(1f - u * 2f);
|
||||
float coldInfluence = Mathf.Clamp01(u * 2f - 1f);
|
||||
result_col = Color.Lerp(result_col, heatSide, heatInfluence * t * 0.6f);
|
||||
result_col = Color.Lerp(result_col, coldSide, coldInfluence * t * 0.4f);
|
||||
}
|
||||
|
||||
if (alive < 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, burnedOut, t * 0.7f);
|
||||
float noise = (float)rng.NextDouble();
|
||||
if (noise < 0.06f * t)
|
||||
result_col = Color.Lerp(result_col, craterDark, 0.9f);
|
||||
}
|
||||
|
||||
if (alive < 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(result_col, finalDead, t);
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
void GenerateAllTextures(string prefix, System.Func<Texture2D, float, Texture2D> generator)
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
float[] levels = { 1.0f, 0.7f, 0.5f, 0.3f, 0.0f };
|
||||
string[] names = { "100", "70", "50", "30", "0" };
|
||||
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Ãåíåðàö³ÿ", prefix + "_" + names[i], (float)i / levels.Length);
|
||||
Texture2D result = generator(sourceTexture, levels[i]);
|
||||
SaveTexture(result, outputFolder + "/" + prefix + "_" + names[i] + ".png");
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðè çáåðåæåíî â " + outputFolder, "OK");
|
||||
}
|
||||
|
||||
void SaveTexture(Texture2D tex, string path)
|
||||
{
|
||||
byte[] bytes = tex.EncodeToPNG();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
}
|
||||
|
||||
void MakeTextureReadable(Texture2D tex)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(tex);
|
||||
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
if (importer != null && !importer.isReadable)
|
||||
{
|
||||
importer.isReadable = true;
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/MercuryTextureGenerator.cs.meta
Normal file
11
Assets/Editor/MercuryTextureGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b906137f3018ec74c9b6a44d8b3bc67a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
156
Assets/Editor/NeptuneTextureGenerator.cs
Normal file
156
Assets/Editor/NeptuneTextureGenerator.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public class NeptuneTextureGenerator : EditorWindow
|
||||
{
|
||||
public Texture2D sourceTexture;
|
||||
public string outputFolder = "Assets/Textures/Neptune";
|
||||
|
||||
[MenuItem("Tools/Neptune Texture Generator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<NeptuneTextureGenerator>("Neptune Texture Generator");
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Ãåíåðàòîð òåêñòóð Íåïòóíà", EditorStyles.boldLabel);
|
||||
sourceTexture = (Texture2D)EditorGUILayout.ObjectField("Òåêñòóðà Íåïòóíà", sourceTexture, typeof(Texture2D), false);
|
||||
outputFolder = EditorGUILayout.TextField("Ïàïêà çáåðåæåííÿ", outputFolder);
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òðîïîñôåðà", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó Íåïòóíà!", "OK"); return; }
|
||||
GenerateAllTextures();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òåêñòóðà ñìåðò³", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó Íåïòóíà!", "OK"); return; }
|
||||
GenerateDeadTexture();
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D GenerateTropoTexture(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color stage70 = new Color(0.35f, 0.45f, 0.75f);
|
||||
Color stage50 = new Color(0.45f, 0.42f, 0.65f);
|
||||
Color stage30 = new Color(0.4f, 0.38f, 0.5f);
|
||||
Color stage0 = new Color(0.22f, 0.2f, 0.28f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
Color col = pixels[p];
|
||||
Color result_col = col;
|
||||
|
||||
if (alive <= 1f && alive > 0.7f)
|
||||
{
|
||||
result_col = col;
|
||||
}
|
||||
else if (alive <= 0.7f && alive > 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(col, stage70, t * 0.8f);
|
||||
}
|
||||
else if (alive <= 0.5f && alive > 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(stage70, stage50, t);
|
||||
}
|
||||
else if (alive <= 0.3f && alive > 0f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(stage50, stage30, t);
|
||||
}
|
||||
else if (alive <= 0f)
|
||||
{
|
||||
result_col = stage0;
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
void GenerateDeadTexture()
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
int width = sourceTexture.width;
|
||||
int height = sourceTexture.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
Color[] pixels = sourceTexture.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color deadColor = new Color(0.22f, 0.2f, 0.28f);
|
||||
Color darkColor = new Color(0.1f, 0.09f, 0.14f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
float brightness = (pixels[p].r + pixels[p].g + pixels[p].b) / 3f;
|
||||
output[p] = Color.Lerp(darkColor, deadColor, brightness);
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
|
||||
SaveTexture(result, outputFolder + "/Dead.png");
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðà ñìåðò³ çáåðåæåíà!", "OK");
|
||||
}
|
||||
|
||||
void GenerateAllTextures()
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
float[] levels = { 1.0f, 0.7f, 0.5f, 0.3f, 0.0f };
|
||||
string[] names = { "100", "70", "50", "30", "0" };
|
||||
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Ãåíåðàö³ÿ", "Tropo_" + names[i], (float)i / levels.Length);
|
||||
Texture2D result = GenerateTropoTexture(sourceTexture, levels[i]);
|
||||
SaveTexture(result, outputFolder + "/Tropo_" + names[i] + ".png");
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðè çáåðåæåíî â " + outputFolder, "OK");
|
||||
}
|
||||
|
||||
void SaveTexture(Texture2D tex, string path)
|
||||
{
|
||||
byte[] bytes = tex.EncodeToPNG();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
}
|
||||
|
||||
void MakeTextureReadable(Texture2D tex)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(tex);
|
||||
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
if (importer != null && !importer.isReadable)
|
||||
{
|
||||
importer.isReadable = true;
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/NeptuneTextureGenerator.cs.meta
Normal file
11
Assets/Editor/NeptuneTextureGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31613eb8ff8d76949b5bc3fc0b877c92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
211
Assets/Editor/SaturnTextureGenerator.cs
Normal file
211
Assets/Editor/SaturnTextureGenerator.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public class SaturnTextureGenerator : EditorWindow
|
||||
{
|
||||
public Texture2D sourceTexture;
|
||||
public Texture2D ringsTexture;
|
||||
public string outputFolder = "Assets/Textures/Saturn";
|
||||
|
||||
[MenuItem("Tools/Saturn Texture Generator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<SaturnTextureGenerator>("Saturn Texture Generator");
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Ãåíåðàòîð òåêñòóð Ñàòóðíà", EditorStyles.boldLabel);
|
||||
sourceTexture = (Texture2D)EditorGUILayout.ObjectField("Òåêñòóðà Ñàòóðíà", sourceTexture, typeof(Texture2D), false);
|
||||
ringsTexture = (Texture2D)EditorGUILayout.ObjectField("Òåêñòóðà ê³ëåöü", ringsTexture, typeof(Texture2D), false);
|
||||
outputFolder = EditorGUILayout.TextField("Ïàïêà çáåðåæåííÿ", outputFolder);
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òðîïîñôåðà", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó Ñàòóðíà!", "OK"); return; }
|
||||
GenerateAllTextures("Tropo", sourceTexture, GenerateTropoTexture);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- ʳëüöÿ", GUILayout.Height(35)))
|
||||
{
|
||||
if (ringsTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó ê³ëåöü!", "OK"); return; }
|
||||
GenerateAllTextures("Rings", ringsTexture, GenerateRingsTexture);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òåêñòóðà ñìåðò³", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó Ñàòóðíà!", "OK"); return; }
|
||||
GenerateDeadTexture();
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D GenerateTropoTexture(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color fadedBeige = new Color(0.85f, 0.78f, 0.6f);
|
||||
Color paleYellow = new Color(0.9f, 0.85f, 0.7f);
|
||||
Color grayDead = new Color(0.55f, 0.5f, 0.42f);
|
||||
Color darkDead = new Color(0.3f, 0.27f, 0.22f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
Color col = pixels[p];
|
||||
Color result_col = col;
|
||||
|
||||
if (alive < 0.7f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, fadedBeige, t * 0.4f);
|
||||
}
|
||||
if (alive < 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, paleYellow, t * 0.5f);
|
||||
}
|
||||
if (alive < 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, grayDead, t * 0.7f);
|
||||
}
|
||||
if (alive < 0.1f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.1f - alive) / 0.1f);
|
||||
result_col = Color.Lerp(result_col, darkDead, t);
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
Texture2D GenerateRingsTexture(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color fadedRing = new Color(0.7f, 0.65f, 0.5f);
|
||||
Color paleRing = new Color(0.6f, 0.55f, 0.42f);
|
||||
Color grayRing = new Color(0.4f, 0.37f, 0.3f);
|
||||
Color darkRing = new Color(0.2f, 0.18f, 0.14f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
Color col = pixels[p];
|
||||
Color result_col = col;
|
||||
|
||||
if (alive < 0.7f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, fadedRing, t * 0.5f);
|
||||
}
|
||||
if (alive < 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, paleRing, t * 0.6f);
|
||||
}
|
||||
if (alive < 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(result_col, grayRing, t * 0.8f);
|
||||
}
|
||||
if (alive < 0.1f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.1f - alive) / 0.1f);
|
||||
result_col = Color.Lerp(result_col, darkRing, t);
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
void GenerateDeadTexture()
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
int width = sourceTexture.width;
|
||||
int height = sourceTexture.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
Color[] pixels = sourceTexture.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color deadBeige = new Color(0.35f, 0.3f, 0.22f);
|
||||
Color darkGray = new Color(0.2f, 0.18f, 0.14f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
Color col = pixels[p];
|
||||
float brightness = (col.r + col.g + col.b) / 3f;
|
||||
output[p] = Color.Lerp(darkGray, deadBeige, brightness);
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
|
||||
SaveTexture(result, outputFolder + "/Dead.png");
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðà ñìåðò³ çáåðåæåíà!", "OK");
|
||||
}
|
||||
|
||||
void GenerateAllTextures(string prefix, Texture2D source, System.Func<Texture2D, float, Texture2D> generator)
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(source);
|
||||
|
||||
float[] levels = { 1.0f, 0.7f, 0.5f, 0.3f, 0.0f };
|
||||
string[] names = { "100", "70", "50", "30", "0" };
|
||||
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Ãåíåðàö³ÿ", prefix + "_" + names[i], (float)i / levels.Length);
|
||||
Texture2D result = generator(source, levels[i]);
|
||||
SaveTexture(result, outputFolder + "/" + prefix + "_" + names[i] + ".png");
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðè çáåðåæåíî â " + outputFolder, "OK");
|
||||
}
|
||||
|
||||
void SaveTexture(Texture2D tex, string path)
|
||||
{
|
||||
byte[] bytes = tex.EncodeToPNG();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
}
|
||||
|
||||
void MakeTextureReadable(Texture2D tex)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(tex);
|
||||
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
if (importer != null && !importer.isReadable)
|
||||
{
|
||||
importer.isReadable = true;
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/SaturnTextureGenerator.cs.meta
Normal file
11
Assets/Editor/SaturnTextureGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9a4ff25c6284b44d8fb565747fbd97a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
156
Assets/Editor/UranusTextureGenerator.cs
Normal file
156
Assets/Editor/UranusTextureGenerator.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
public class UranusTextureGenerator : EditorWindow
|
||||
{
|
||||
public Texture2D sourceTexture;
|
||||
public string outputFolder = "Assets/Textures/Uranus";
|
||||
|
||||
[MenuItem("Tools/Uranus Texture Generator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<UranusTextureGenerator>("Uranus Texture Generator");
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Ãåíåðàòîð òåêñòóð Óðàíà", EditorStyles.boldLabel);
|
||||
sourceTexture = (Texture2D)EditorGUILayout.ObjectField("Òåêñòóðà Óðàíà", sourceTexture, typeof(Texture2D), false);
|
||||
outputFolder = EditorGUILayout.TextField("Ïàïêà çáåðåæåííÿ", outputFolder);
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òðîïîñôåðà", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó Óðàíà!", "OK"); return; }
|
||||
GenerateAllTextures();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
if (GUILayout.Button("Çãåíåðóâàòè -- Òåêñòóðà ñìåðò³", GUILayout.Height(35)))
|
||||
{
|
||||
if (sourceTexture == null) { EditorUtility.DisplayDialog("Ïîìèëêà", "Ïåðåòÿãíè òåêñòóðó Óðàíà!", "OK"); return; }
|
||||
GenerateDeadTexture();
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D GenerateTropoTexture(Texture2D source, float alive)
|
||||
{
|
||||
int width = source.width;
|
||||
int height = source.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
Color[] pixels = source.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color stage70 = new Color(0.75f, 0.82f, 0.72f);
|
||||
Color stage50 = new Color(0.78f, 0.72f, 0.55f);
|
||||
Color stage30 = new Color(0.6f, 0.52f, 0.38f);
|
||||
Color stage0 = new Color(0.35f, 0.3f, 0.22f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
Color col = pixels[p];
|
||||
Color result_col = col;
|
||||
|
||||
if (alive <= 1f && alive > 0.7f)
|
||||
{
|
||||
result_col = col;
|
||||
}
|
||||
else if (alive <= 0.7f && alive > 0.5f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.7f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(col, stage70, t * 0.8f);
|
||||
}
|
||||
else if (alive <= 0.5f && alive > 0.3f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.5f - alive) / 0.2f);
|
||||
result_col = Color.Lerp(stage70, stage50, t);
|
||||
}
|
||||
else if (alive <= 0.3f && alive > 0.0f)
|
||||
{
|
||||
float t = Mathf.Clamp01((0.3f - alive) / 0.3f);
|
||||
result_col = Color.Lerp(stage50, stage30, t);
|
||||
}
|
||||
else if (alive <= 0f)
|
||||
{
|
||||
result_col = stage0;
|
||||
}
|
||||
|
||||
output[p] = result_col;
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
void GenerateDeadTexture()
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
int width = sourceTexture.width;
|
||||
int height = sourceTexture.height;
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
Color[] pixels = sourceTexture.GetPixels();
|
||||
Color[] output = new Color[pixels.Length];
|
||||
|
||||
Color deadColor = new Color(0.35f, 0.3f, 0.22f);
|
||||
Color darkColor = new Color(0.18f, 0.15f, 0.1f);
|
||||
|
||||
for (int p = 0; p < pixels.Length; p++)
|
||||
{
|
||||
float brightness = (pixels[p].r + pixels[p].g + pixels[p].b) / 3f;
|
||||
output[p] = Color.Lerp(darkColor, deadColor, brightness);
|
||||
}
|
||||
|
||||
result.SetPixels(output);
|
||||
result.Apply();
|
||||
|
||||
SaveTexture(result, outputFolder + "/Dead.png");
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðà ñìåðò³ çáåðåæåíà!", "OK");
|
||||
}
|
||||
|
||||
void GenerateAllTextures()
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
|
||||
MakeTextureReadable(sourceTexture);
|
||||
|
||||
float[] levels = { 1.0f, 0.7f, 0.5f, 0.3f, 0.0f };
|
||||
string[] names = { "100", "70", "50", "30", "0" };
|
||||
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Ãåíåðàö³ÿ", "Tropo_" + names[i], (float)i / levels.Length);
|
||||
Texture2D result = GenerateTropoTexture(sourceTexture, levels[i]);
|
||||
SaveTexture(result, outputFolder + "/Tropo_" + names[i] + ".png");
|
||||
}
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Ãîòîâî!", "Òåêñòóðè çáåðåæåíî â " + outputFolder, "OK");
|
||||
}
|
||||
|
||||
void SaveTexture(Texture2D tex, string path)
|
||||
{
|
||||
byte[] bytes = tex.EncodeToPNG();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
}
|
||||
|
||||
void MakeTextureReadable(Texture2D tex)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(tex);
|
||||
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||
if (importer != null && !importer.isReadable)
|
||||
{
|
||||
importer.isReadable = true;
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/UranusTextureGenerator.cs.meta
Normal file
11
Assets/Editor/UranusTextureGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76969e06a2f787b4da652a857783007d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user