Skip to content

Commit

Permalink
5.6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
poiyomi committed Jul 15, 2020
1 parent 0e20505 commit 596b244
Show file tree
Hide file tree
Showing 156 changed files with 4,352 additions and 634 deletions.
8 changes: 0 additions & 8 deletions _PoiyomiShaders/Scripts/Editor.meta

This file was deleted.

67 changes: 67 additions & 0 deletions _PoiyomiShaders/Scripts/TextureArrayCreator/Editor/GifImporter.cs
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;
}

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 20 additions & 7 deletions _PoiyomiShaders/Shaders/Includes/CGI_PoiRGBMask.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,36 @@
float4 _RedColor;
float4 _GreenColor;
float4 _BlueColor;

float _RGBBlendMultiplicative;

uint _RGBMaskUV;
uint _RGBRed_UV;
uint _RGBGreen_UV;
uint _RGBBlue_UV;

float3 calculateRGBMask(float3 baseColor)
{
float3 rgbMask = UNITY_SAMPLE_TEX2D_SAMPLER(_RGBMask, _MainTex, TRANSFORM_TEX(poiMesh.uv[_RGBMaskUV], _RGBMask)).rgb;
float4 red = UNITY_SAMPLE_TEX2D_SAMPLER(_RedTexure, _MainTex, TRANSFORM_TEX(poiMesh.uv[_RGBRed_UV], _RedTexure));
float4 green = UNITY_SAMPLE_TEX2D_SAMPLER(_GreenTexture, _MainTex, TRANSFORM_TEX(poiMesh.uv[_RGBGreen_UV], _GreenTexture));
float4 blue = UNITY_SAMPLE_TEX2D_SAMPLER(_BlueTexture, _MainTex, TRANSFORM_TEX(poiMesh.uv[_RGBBlue_UV], _BlueTexture));

baseColor = lerp(baseColor, red.rgb * _RedColor.rgb, rgbMask.r * red.a * _RedColor.a);
baseColor = lerp(baseColor, green.rgb * _GreenColor.rgb, rgbMask.g * green.a * _GreenColor.a);
baseColor = lerp(baseColor, blue.rgb * _BlueColor.rgb, rgbMask.b * blue.a * _BlueColor.a);


UNITY_BRANCH
if (_RGBBlendMultiplicative)
{
float3 RGBColor = 1;
RGBColor = lerp(RGBColor, red.rgb * _RedColor.rgb, rgbMask.r * red.a * _RedColor.a);
RGBColor = lerp(RGBColor, green.rgb * _GreenColor.rgb, rgbMask.g * green.a * _GreenColor.a);
RGBColor = lerp(RGBColor, blue.rgb * _BlueColor.rgb, rgbMask.b * blue.a * _BlueColor.a);
baseColor *= RGBColor;
}
else
{
baseColor = lerp(baseColor, red.rgb * _RedColor.rgb, rgbMask.r * red.a * _RedColor.a);
baseColor = lerp(baseColor, green.rgb * _GreenColor.rgb, rgbMask.g * green.a * _GreenColor.a);
baseColor = lerp(baseColor, blue.rgb * _BlueColor.rgb, rgbMask.b * blue.a * _BlueColor.a);
}

return baseColor;
}

Expand Down
54 changes: 54 additions & 0 deletions _PoiyomiShaders/Shaders/Includes/CGI_PoiSpawnInFrag.cginc
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions _PoiyomiShaders/Shaders/Includes/CGI_PoiSpawnInVert.cginc
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 596b244

Please sign in to comment.