-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
156 changed files
with
4,352 additions
and
634 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
_PoiyomiShaders/Scripts/TextureArrayCreator/Editor/GifImporter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Drawing.Imaging; | ||
using System.Linq; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace UwU | ||
{ | ||
public class GifImporter | ||
{ | ||
|
||
[MenuItem("Assets/Poiyomi/Texture Array/From GIF")] | ||
static void GifImport() | ||
{ | ||
string path = AssetDatabase.GetAssetPath(Selection.activeObject); | ||
List<Texture2D> array = GetGifFrames(path); | ||
Texture2DArray arrayTexture = new Texture2DArray(array.First().width, array.First().height, array.Count, TextureFormat.RGBA32, true, false); | ||
for (int i = 0; i < array.Count; i++) | ||
{ | ||
arrayTexture.SetPixels(array[i].GetPixels(0), i, 0); | ||
} | ||
arrayTexture.Apply(); | ||
AssetDatabase.CreateAsset(arrayTexture, path.Replace(".gif", ".asset")); | ||
} | ||
|
||
[MenuItem("Assets/Poiyomi/Texture Array/From GIF", true)] | ||
static bool ValidateGifImport() | ||
{ | ||
if (Selection.activeObject == null) | ||
return false; | ||
string path = AssetDatabase.GetAssetPath(Selection.activeObject).ToLower(); | ||
return path.EndsWith(".gif"); | ||
} | ||
|
||
public static List<Texture2D> GetGifFrames(string path) | ||
{ | ||
List<Texture2D> gifFrames = new List<Texture2D>(); | ||
var gifImage = Image.FromFile(path); | ||
var dimension = new FrameDimension(gifImage.FrameDimensionsList[0]); | ||
|
||
int frameCount = gifImage.GetFrameCount(dimension); | ||
for (int i = 0; i < frameCount; i++) | ||
{ | ||
gifImage.SelectActiveFrame(dimension, i); | ||
var frame = new Bitmap(gifImage.Width, gifImage.Height); | ||
System.Drawing.Graphics.FromImage(frame).DrawImage(gifImage, Point.Empty); | ||
var frameTexture = new Texture2D(frame.Width, frame.Height); | ||
|
||
for (int x = 0; x < frame.Width; x++) | ||
{ | ||
for (int y = 0; y < frame.Height; y++) | ||
{ | ||
System.Drawing.Color sourceColor = frame.GetPixel(x, y); | ||
frameTexture.SetPixel(x,frame.Height - 1 - y, new Color32(sourceColor.R, sourceColor.G, sourceColor.B, sourceColor.A)); | ||
} | ||
} | ||
|
||
frameTexture.Apply(); | ||
gifFrames.Add(frameTexture); | ||
} | ||
return gifFrames; | ||
} | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
_PoiyomiShaders/Scripts/TextureArrayCreator/Editor/GifImporter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
_PoiyomiShaders/Scripts/TextureArrayCreator/Editor/Texture2DArrayData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/// Date : 12/06/2018 | ||
/// Company : Fantastic, yes | ||
/// Author : Maximilian Rötzler | ||
/// License : This code is licensed under MIT license | ||
|
||
using UnityEngine; | ||
using UnityEditor; | ||
using System; | ||
|
||
namespace UwU | ||
{ | ||
public class Texture2DArrayData : ScriptableObject | ||
{ | ||
#region Create Asset Menu | ||
[MenuItem("Assets/Poiyomi/Texture Array/From Images", false, 303)] | ||
private static void TextureArrayItem() | ||
{ | ||
Texture2D[] wew = Selection.GetFiltered<Texture2D>(SelectionMode.TopLevel); | ||
Array.Sort(wew, (UnityEngine.Object one, UnityEngine.Object two) => one.name.CompareTo(two.name)); | ||
Selection.objects = wew; | ||
Texture2DArray texture2DArray = new Texture2DArray(wew[0].width, wew[0].height, wew.Length, wew[0].format, true); | ||
|
||
string assetPath = AssetDatabase.GetAssetPath(wew[0]); | ||
assetPath = assetPath.Remove(assetPath.LastIndexOf('/')) + "/Texture2DArray.asset"; | ||
|
||
for (int i = 0; i < wew.Length; i++) | ||
{ | ||
for (int m = 0; m < wew[i].mipmapCount; m++) | ||
{ | ||
Graphics.CopyTexture(wew[i], 0, m, texture2DArray, i, m); | ||
} | ||
} | ||
|
||
texture2DArray.anisoLevel = wew[0].anisoLevel; | ||
texture2DArray.wrapModeU = wew[0].wrapModeU; | ||
texture2DArray.wrapModeV = wew[0].wrapModeV; | ||
texture2DArray.Apply(false, true); | ||
|
||
AssetDatabase.CreateAsset(texture2DArray, assetPath); | ||
AssetDatabase.SaveAssets(); | ||
|
||
Selection.activeObject = texture2DArray; | ||
} | ||
|
||
[MenuItem("Assets/Poiyomi/Create Texture Array", true)] | ||
private static bool TextureArrayItemValidation() | ||
{ | ||
return Selection.GetFiltered<Texture2D>(SelectionMode.TopLevel).Length > 0; | ||
} | ||
#endregion | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
_PoiyomiShaders/Scripts/TextureArrayCreator/Editor/Texture2DArrayData.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef POI_SPAWN_IN_FRAG | ||
#define POI_SPAWN_FRAG | ||
|
||
#ifndef SPAWN_IN_VARIABLES | ||
#define SPAWN_IN_VARIABLES | ||
|
||
float3 _SpawnInGradientStart; | ||
float3 _SpawnInGradientFinish; | ||
fixed _SpawnInAlpha; | ||
fixed _SpawnInNoiseIntensity; | ||
float3 _SpawnInEmissionColor; | ||
float _SpawnInEmissionOffset; | ||
float _SpawnInVertOffset; | ||
float _SpawnInVertOffsetOffset; | ||
float _EnableScifiSpawnIn; | ||
#endif | ||
|
||
UNITY_DECLARE_TEX2D_NOSAMPLER(_SpawnInNoise); float4 _SpawnInNoise_ST; | ||
|
||
float calculateGradientValueFrag(float3 start, float3 finish, float3 localPos) | ||
{ | ||
return inverseLerp3(start, finish, localPos); | ||
} | ||
|
||
void applySpawnIn(inout float4 finalColor, inout float3 spawnInEmission, float2 uv, float3 localPos) | ||
{ | ||
UNITY_BRANCH | ||
if (_EnableScifiSpawnIn) | ||
{ | ||
float noise = UNITY_SAMPLE_TEX2D_SAMPLER(_SpawnInNoise, _MainTex, TRANSFORM_TEX(uv, _SpawnInNoise)).r * _SpawnInAlpha * _SpawnInNoiseIntensity; | ||
float gradient = calculateGradientValueFrag(_SpawnInGradientStart, _SpawnInGradientFinish, localPos); | ||
float inverseGradient = 1 - gradient; | ||
float alpha = gradient - _SpawnInAlpha - noise; | ||
spawnInEmission = saturate(inverseGradient + _SpawnInAlpha + _SpawnInEmissionOffset +noise - 1) * _SpawnInEmissionColor; | ||
#if defined(TRANSPARENT) || defined(CUTOUT) | ||
clip(ceil(alpha) - 0.001); | ||
#endif | ||
} | ||
} | ||
|
||
void applySpawnInShadow(float2 uv, float3 localPos) | ||
{ | ||
UNITY_BRANCH | ||
if(_EnableScifiSpawnIn) | ||
{ | ||
float noise = UNITY_SAMPLE_TEX2D_SAMPLER(_SpawnInNoise, _MainTex, TRANSFORM_TEX(uv, _SpawnInNoise)).r * _SpawnInAlpha * _SpawnInNoiseIntensity; | ||
float gradient = calculateGradientValueFrag(_SpawnInGradientStart, _SpawnInGradientFinish, localPos); | ||
float alpha = gradient - _SpawnInAlpha - noise + length(_SpawnInVertOffset); | ||
#if defined(TRANSPARENT) || defined(CUTOUT) | ||
clip(ceil(alpha) - 0.001); | ||
#endif | ||
} | ||
} | ||
#endif |
9 changes: 9 additions & 0 deletions
9
_PoiyomiShaders/Shaders/Includes/CGI_PoiSpawnInFrag.cginc.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef POI_SPAWN_IN_FRAG | ||
#define POI_SPAWN_FRAG | ||
|
||
#ifndef SPAWN_IN_VARIABLES | ||
#define SPAWN_IN_VARIABLES | ||
|
||
float3 _SpawnInGradientStart; | ||
float3 _SpawnInGradientFinish; | ||
fixed _SpawnInAlpha; | ||
fixed _SpawnInNoiseIntensity; | ||
float3 _SpawnInEmissionColor; | ||
float _SpawnInEmissionOffset; | ||
float _SpawnInVertOffset; | ||
float _SpawnInVertOffsetOffset; | ||
float _EnableScifiSpawnIn; | ||
|
||
#endif | ||
//sampler2D _SpawnInNoiseVert; float4 _SpawnInNoiseVert_ST; | ||
|
||
float calculateGradientValueVert(float3 start, float3 finish, float3 localPos) | ||
{ | ||
return inverseLerp3(start, finish, localPos); | ||
} | ||
|
||
void applySpawnInVert(inout float4 worldPos, inout float4 localPos, float2 uv) | ||
{ | ||
UNITY_BRANCH | ||
if (_EnableScifiSpawnIn) | ||
{ | ||
float noise = 0; | ||
float gradient = calculateGradientValueVert(_SpawnInGradientStart, _SpawnInGradientFinish, localPos); | ||
float inverseGradient = 1 - gradient; | ||
float alpha = gradient - _SpawnInAlpha - noise; | ||
worldPos.xyz += saturate(inverseGradient + _SpawnInAlpha + _SpawnInVertOffsetOffset -1) * float3(0, _SpawnInVertOffset, 0); | ||
localPos.xyz = mul(unity_WorldToObject, worldPos); | ||
} | ||
//float noise = tex2Dlod(_SpawnInNoise, float4(TRANSFORM_TEX(uv, _SpawnInNoise))).r * _SpawnInAlpha * _SpawnInNoiseIntensity; | ||
} | ||
|
||
#endif |
9 changes: 9 additions & 0 deletions
9
_PoiyomiShaders/Shaders/Includes/CGI_PoiSpawnInVert.cginc.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.