[Add] All in one shader
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AtlasPackerTool
|
||||
{
|
||||
public AtlasPackerValues values;
|
||||
|
||||
//public int atlasXCount;
|
||||
//public int atlasYCount;
|
||||
|
||||
//public TextureSizes atlasSizesX;
|
||||
//public TextureSizes atlasSizesY;
|
||||
|
||||
//public FilterMode atlasFiltering;
|
||||
|
||||
//public bool squareAtlas;
|
||||
|
||||
//public Texture2D[] atlas;
|
||||
|
||||
//public Texture2D createdAtlas;
|
||||
|
||||
public AtlasPackerTool()
|
||||
{
|
||||
ResetValues();
|
||||
|
||||
values.atlasXCount = 1;
|
||||
values.atlasYCount = 1;
|
||||
|
||||
values.atlasSizesX = TextureSizes._1024;
|
||||
values.atlasSizesY = TextureSizes._1024;
|
||||
|
||||
values.squareAtlas = true;
|
||||
|
||||
values.atlasFiltering = FilterMode.Bilinear;
|
||||
}
|
||||
|
||||
public void ResetValues()
|
||||
{
|
||||
values = ScriptableObject.CreateInstance<AtlasPackerValues>();
|
||||
values.atlas = new Texture2D[0];
|
||||
}
|
||||
|
||||
public void CreateAtlas()
|
||||
{
|
||||
int atlasElements = values.atlasXCount * values.atlasYCount;
|
||||
int atlasWidth = (int)values.atlasSizesX;
|
||||
int atlasHeight = (int)values.atlasSizesY;
|
||||
|
||||
Texture2D[] AtlasCopy = (Texture2D[])values.atlas.Clone();
|
||||
int textureXTargetWidth = atlasWidth / values.atlasXCount;
|
||||
int textureYTargetHeight = atlasHeight / values.atlasYCount;
|
||||
values.createdAtlas = new Texture2D(atlasWidth, atlasHeight);
|
||||
for (int i = 0; i < values.atlasYCount; i++)
|
||||
{
|
||||
for (int j = 0; j < values.atlasXCount; j++)
|
||||
{
|
||||
int currIndex = (i * values.atlasXCount) + j;
|
||||
bool hasImageForThisIndex = currIndex < AtlasCopy.Length && AtlasCopy[currIndex] != null;
|
||||
if (hasImageForThisIndex)
|
||||
{
|
||||
EditorUtils.SetTextureReadWrite(AssetDatabase.GetAssetPath(AtlasCopy[currIndex]), true);
|
||||
Texture2D copyTexture = new Texture2D(AtlasCopy[currIndex].width, AtlasCopy[currIndex].height);
|
||||
copyTexture.SetPixels(AtlasCopy[currIndex].GetPixels());
|
||||
copyTexture.Apply();
|
||||
AtlasCopy[currIndex] = copyTexture;
|
||||
AtlasCopy[currIndex] = EditorUtils.ScaleTexture(AtlasCopy[currIndex], textureXTargetWidth, textureYTargetHeight);
|
||||
AtlasCopy[currIndex].Apply();
|
||||
}
|
||||
|
||||
for (int y = 0; y < textureYTargetHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < textureXTargetWidth; x++)
|
||||
{
|
||||
if (hasImageForThisIndex) values.createdAtlas.SetPixel((j * textureXTargetWidth) + x, (i * textureYTargetHeight) + y, AtlasCopy[currIndex].GetPixel(x, y));
|
||||
else values.createdAtlas.SetPixel((j * textureXTargetWidth) + x, (i * textureYTargetHeight) + y, new Color(0, 0, 0, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
values.createdAtlas.Apply();
|
||||
}
|
||||
|
||||
public int GetAtlasElements()
|
||||
{
|
||||
int res = values.atlasXCount * values.atlasYCount;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22cf4eeb2432eff42a008c7a5c157f0f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/AtlasPackerTool.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AtlasPackerValues : ScriptableObject
|
||||
{
|
||||
public int atlasXCount;
|
||||
public int atlasYCount;
|
||||
|
||||
public TextureSizes atlasSizesX;
|
||||
public TextureSizes atlasSizesY;
|
||||
|
||||
public FilterMode atlasFiltering;
|
||||
|
||||
public bool squareAtlas;
|
||||
|
||||
public Texture2D[] atlas;
|
||||
|
||||
public Texture2D createdAtlas;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4c373390afce2e47a4129d7a5b822d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/AtlasPackerValues.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,150 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class GradientCreatorTool
|
||||
{
|
||||
public const int HEIGHT_GRADIENT = 16;
|
||||
|
||||
public Texture2D gradientTex;
|
||||
|
||||
public TextureSizes gradientSizes;
|
||||
public FilterMode gradientFiltering;
|
||||
public Gradient gradient;
|
||||
|
||||
public GradientCreatorTool()
|
||||
{
|
||||
gradientSizes = TextureSizes._128;
|
||||
gradientFiltering = FilterMode.Bilinear;
|
||||
gradient = new Gradient();
|
||||
|
||||
int size = (int)gradientSizes;
|
||||
gradientTex = new Texture2D(size, size);
|
||||
}
|
||||
|
||||
public Texture2D CreateGradientTexture(TextureSizes gradientSizes, FilterMode gradientFiltering, Gradient gradient)
|
||||
{
|
||||
this.gradientSizes = gradientSizes;
|
||||
this.gradientFiltering = gradientFiltering;
|
||||
this.gradient = gradient;
|
||||
|
||||
return CreateGradientTexture();
|
||||
}
|
||||
|
||||
public Texture2D CreateGradientTexture(Gradient gradient)
|
||||
{
|
||||
this.gradientSizes = TextureSizes._256;
|
||||
this.gradientFiltering = FilterMode.Bilinear;
|
||||
this.gradient = gradient;
|
||||
|
||||
return CreateGradientTexture();
|
||||
}
|
||||
|
||||
public Texture2D CreateGradientTexture()
|
||||
{
|
||||
int textureSize = (int)gradientSizes;
|
||||
this.gradientTex = new Texture2D(textureSize, HEIGHT_GRADIENT, TextureFormat.RGBA32, false);
|
||||
this.gradientTex.wrapMode = TextureWrapMode.Clamp;
|
||||
|
||||
for (int i = 0; i < textureSize; i++)
|
||||
{
|
||||
Color col = gradient.Evaluate((float)i / (float)textureSize);
|
||||
for (int j = 0; j < HEIGHT_GRADIENT; j++)
|
||||
{
|
||||
gradientTex.SetPixel(i, j, gradient.Evaluate((float)i / (float)textureSize));
|
||||
}
|
||||
}
|
||||
|
||||
gradientTex.Apply();
|
||||
return gradientTex;
|
||||
}
|
||||
|
||||
public Texture SaveGradientTexture(GradientTexture gradientTextureAsset, bool createNewSO)
|
||||
{
|
||||
string texName = "RampTexture";
|
||||
if(gradientTextureAsset != null)
|
||||
{
|
||||
texName = gradientTextureAsset.texture.name;
|
||||
}
|
||||
|
||||
string directoryPath = GlobalConfiguration.instance.GradientSavePath;
|
||||
if (gradientTextureAsset != null && AssetDatabase.IsMainAsset(gradientTextureAsset.texture) && !createNewSO)
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(gradientTextureAsset.texture);
|
||||
directoryPath = Path.GetDirectoryName(assetPath);
|
||||
}
|
||||
Texture tex = EditorUtils.SaveTextureAsPNG(directoryPath, texName, "Ramp Texture", gradientTex,
|
||||
FilterMode.Bilinear, TextureImporterType.Default, TextureWrapMode.Clamp, false, createNewSO);
|
||||
|
||||
if (createNewSO)
|
||||
{
|
||||
GradientTexture gradientTexture = ScriptableObject.CreateInstance<GradientTexture>();
|
||||
gradientTexture.texture = tex;
|
||||
gradientTexture.gradient = new Gradient();
|
||||
CopyGradient(gradient, gradientTexture.gradient);
|
||||
|
||||
string gradientTextureAssetPath = Path.Combine(GlobalConfiguration.instance.GradientSavePath, $"GradientAsset_{tex.name}.asset");
|
||||
gradientTextureAssetPath = AssetDatabase.GenerateUniqueAssetPath(gradientTextureAssetPath);
|
||||
|
||||
AssetDatabase.CreateAsset(gradientTexture, gradientTextureAssetPath);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
gradientTextureAsset.texture = tex;
|
||||
|
||||
gradientTextureAsset.gradient = new Gradient();
|
||||
CopyGradient(gradient, gradientTextureAsset.gradient);
|
||||
|
||||
EditorUtility.SetDirty(gradientTextureAsset);
|
||||
}
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
public static void CopyGradient(Gradient from, Gradient to)
|
||||
{
|
||||
GradientColorKey[] newColorKeys = new GradientColorKey[from.colorKeys.Length];
|
||||
GradientAlphaKey[] newAlphaKeys = new GradientAlphaKey[from.alphaKeys.Length];
|
||||
|
||||
for (int i = 0; i < from.colorKeys.Length; i++)
|
||||
{
|
||||
newColorKeys[i] = from.colorKeys[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < from.alphaKeys.Length; i++)
|
||||
{
|
||||
newAlphaKeys[i] = from.alphaKeys[i];
|
||||
}
|
||||
|
||||
to.colorKeys = newColorKeys;
|
||||
to.alphaKeys = newAlphaKeys;
|
||||
to.mode = from.mode;
|
||||
}
|
||||
|
||||
public static GradientTexture FindGradientTexureByTex(Texture selectedTex)
|
||||
{
|
||||
GradientTexture res = null;
|
||||
string[] guids = AssetDatabase.FindAssets("t:GradientTexture");
|
||||
|
||||
for (int i = 0; i < guids.Length; i++)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
|
||||
GradientTexture gradientTexture = AssetDatabase.LoadAssetAtPath<GradientTexture>(path);
|
||||
|
||||
if (gradientTexture.name.StartsWith("GradientAsset_"))
|
||||
{
|
||||
if (gradientTexture.texture == selectedTex)
|
||||
{
|
||||
res = gradientTexture;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9a976b4a21c9a34884e574c601d7e55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/GradientCreatorTool.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,126 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class NoiseCreatorTool
|
||||
{
|
||||
private const string SHADER_NAME_FRACTAL_NOISE = "AllIn13DShaderFractalNoise";
|
||||
private const string SHADER_NAME_WORLEY_NOISE = "AllIn13DShaderWorleyNoise";
|
||||
|
||||
public enum NoiseTypes
|
||||
{
|
||||
Fractal,
|
||||
Perlin,
|
||||
Billow,
|
||||
Voronoi,
|
||||
Water,
|
||||
Cellular,
|
||||
Cells1,
|
||||
Cells2
|
||||
}
|
||||
|
||||
public NoiseCreatorValues values;
|
||||
|
||||
public NoiseCreatorTool()
|
||||
{
|
||||
values = new NoiseCreatorValues();
|
||||
|
||||
NoiseSetMaterial();
|
||||
CheckCreationNoiseTextures();
|
||||
UpdateNoiseMatAndRender();
|
||||
CreateNoiseTex();
|
||||
}
|
||||
|
||||
public void CreateNoiseTex()
|
||||
{
|
||||
int texSize = (int)values.noiseSize;
|
||||
values.finalNoiseTex = new Texture2D(texSize, texSize);
|
||||
RenderTexture finalRenderTarget = new RenderTexture(values.finalNoiseTex.width, values.finalNoiseTex.height, 0, RenderTextureFormat.ARGB32);
|
||||
Graphics.Blit(values.finalNoiseTex, finalRenderTarget, values.noiseMaterial);
|
||||
values.finalNoiseTex.ReadPixels(new Rect(0, 0, finalRenderTarget.width, finalRenderTarget.height), 0, 0);
|
||||
values.finalNoiseTex.Apply();
|
||||
}
|
||||
|
||||
public void CheckCreationNoiseTextures()
|
||||
{
|
||||
if (values.noisePreview == null)
|
||||
{
|
||||
values.noisePreview = new Texture2D(256, 256);
|
||||
}
|
||||
|
||||
if (values.noiseRenderTarget == null)
|
||||
{
|
||||
values.noiseRenderTarget = new RenderTexture(values.noisePreview.width, values.noisePreview.height, 0, RenderTextureFormat.ARGB32);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateNoiseMatAndRender()
|
||||
{
|
||||
if (values.noiseType == NoiseTypes.Fractal || values.noiseType == NoiseTypes.Perlin || values.noiseType == NoiseTypes.Billow)
|
||||
{
|
||||
values.noiseMaterial.SetFloat("_EndBand", values.noiseFractalAmount);
|
||||
}
|
||||
else values.noiseMaterial.SetFloat("_Jitter", values.noiseJitter);
|
||||
|
||||
values.noiseMaterial.SetFloat("_ScaleX", values.noiseScaleX);
|
||||
values.noiseMaterial.SetFloat("_ScaleY", values.noiseScaleY);
|
||||
values.noiseMaterial.SetFloat("_Offset", (float)values.noiseSeed);
|
||||
values.noiseMaterial.SetFloat("_Contrast", values.noiseContrast);
|
||||
values.noiseMaterial.SetFloat("_Brightness", values.noiseBrightness);
|
||||
values.noiseMaterial.SetFloat("_Invert", values.noiseInverted ? 1f : 0f);
|
||||
|
||||
Graphics.Blit(values.noisePreview, values.noiseRenderTarget, values.noiseMaterial);
|
||||
values.noisePreview.ReadPixels(new Rect(0, 0, values.noiseRenderTarget.width, values.noiseRenderTarget.height), 0, 0);
|
||||
values.noisePreview.Apply();
|
||||
}
|
||||
|
||||
public void NoiseSetMaterial()
|
||||
{
|
||||
if (values.noiseType == NoiseTypes.Fractal || values.noiseType == NoiseTypes.Perlin || values.noiseType == NoiseTypes.Billow)
|
||||
{
|
||||
values.isFractalNoise = true;
|
||||
values.noiseMaterial = new Material(EditorUtils.FindShader(SHADER_NAME_FRACTAL_NOISE));
|
||||
values.noiseScaleX = 4f;
|
||||
values.noiseScaleY = 4f;
|
||||
}
|
||||
else
|
||||
{
|
||||
values.isFractalNoise = false;
|
||||
values.noiseMaterial = new Material(EditorUtils.FindShader(SHADER_NAME_WORLEY_NOISE));
|
||||
values.noiseScaleX = 10f;
|
||||
values.noiseScaleY = 10f;
|
||||
}
|
||||
|
||||
switch (values.noiseType)
|
||||
{
|
||||
case NoiseTypes.Fractal:
|
||||
values.noiseFractalAmount = 8f;
|
||||
values.noiseMaterial.SetFloat("_Fractal", 1);
|
||||
break;
|
||||
case NoiseTypes.Perlin:
|
||||
values.noiseFractalAmount = 1f;
|
||||
values.noiseMaterial.SetFloat("_Fractal", 1);
|
||||
break;
|
||||
case NoiseTypes.Billow:
|
||||
values.noiseFractalAmount = 4f;
|
||||
values.noiseMaterial.SetFloat("_Fractal", 0);
|
||||
break;
|
||||
case NoiseTypes.Voronoi:
|
||||
values.noiseMaterial.SetFloat("_NoiseType", 0f);
|
||||
break;
|
||||
case NoiseTypes.Water:
|
||||
values.noiseMaterial.SetFloat("_NoiseType", 3f);
|
||||
break;
|
||||
case NoiseTypes.Cellular:
|
||||
values.noiseMaterial.SetFloat("_NoiseType", 4f);
|
||||
break;
|
||||
case NoiseTypes.Cells1:
|
||||
values.noiseMaterial.SetFloat("_NoiseType", 1f);
|
||||
break;
|
||||
case NoiseTypes.Cells2:
|
||||
values.noiseMaterial.SetFloat("_NoiseType", 2f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e268a0b97ec21eb4181d17530e323c9b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/NoiseCreatorTool.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,107 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class NormalMapCreatorTool
|
||||
{
|
||||
public Texture2D targetNormalImage;
|
||||
public int normalSmoothing;
|
||||
public float normalStrength;
|
||||
public int isComputingNormals;
|
||||
|
||||
public Texture2D CreateNormalMap(bool invertDirection)
|
||||
{
|
||||
int width = targetNormalImage.width;
|
||||
int height = targetNormalImage.height;
|
||||
Color[] sourcePixels = targetNormalImage.GetPixels();
|
||||
Color[] resultPixels = new Color[width * height];
|
||||
Vector3 vScale = new Vector3(0.3333f, 0.3333f, 0.3333f);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int index = x + y * width;
|
||||
Vector3 cSampleNegXNegY = GetPixelClamped(sourcePixels, x - 1, y - 1, width, height);
|
||||
Vector3 cSampleZerXNegY = GetPixelClamped(sourcePixels, x, y - 1, width, height);
|
||||
Vector3 cSamplePosXNegY = GetPixelClamped(sourcePixels, x + 1, y - 1, width, height);
|
||||
Vector3 cSampleNegXZerY = GetPixelClamped(sourcePixels, x - 1, y, width, height);
|
||||
Vector3 cSamplePosXZerY = GetPixelClamped(sourcePixels, x + 1, y, width, height);
|
||||
Vector3 cSampleNegXPosY = GetPixelClamped(sourcePixels, x - 1, y + 1, width, height);
|
||||
Vector3 cSampleZerXPosY = GetPixelClamped(sourcePixels, x, y + 1, width, height);
|
||||
Vector3 cSamplePosXPosY = GetPixelClamped(sourcePixels, x + 1, y + 1, width, height);
|
||||
|
||||
float fSampleNegXNegY = Vector3.Dot(cSampleNegXNegY, vScale);
|
||||
float fSampleZerXNegY = Vector3.Dot(cSampleZerXNegY, vScale);
|
||||
float fSamplePosXNegY = Vector3.Dot(cSamplePosXNegY, vScale);
|
||||
float fSampleNegXZerY = Vector3.Dot(cSampleNegXZerY, vScale);
|
||||
float fSamplePosXZerY = Vector3.Dot(cSamplePosXZerY, vScale);
|
||||
float fSampleNegXPosY = Vector3.Dot(cSampleNegXPosY, vScale);
|
||||
float fSampleZerXPosY = Vector3.Dot(cSampleZerXPosY, vScale);
|
||||
float fSamplePosXPosY = Vector3.Dot(cSamplePosXPosY, vScale);
|
||||
|
||||
float edgeX = (fSampleNegXNegY - fSamplePosXNegY) * 0.25f + (fSampleNegXZerY - fSamplePosXZerY) * 0.5f + (fSampleNegXPosY - fSamplePosXPosY) * 0.25f;
|
||||
float edgeY = (fSampleNegXNegY - fSampleNegXPosY) * 0.25f + (fSampleZerXNegY - fSampleZerXPosY) * 0.5f + (fSamplePosXNegY - fSamplePosXPosY) * 0.25f;
|
||||
|
||||
if(invertDirection) edgeY = -edgeY;
|
||||
|
||||
Vector2 vEdge = new Vector2(edgeX, edgeY) * normalStrength;
|
||||
Vector3 norm = new Vector3(vEdge.x, vEdge.y, 1.0f).normalized;
|
||||
resultPixels[index] = new Color(norm.x * 0.5f + 0.5f, norm.y * 0.5f + 0.5f, norm.z * 0.5f + 0.5f, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (normalSmoothing > 0)
|
||||
{
|
||||
resultPixels = SmoothNormals(resultPixels, width, height, normalSmoothing);
|
||||
}
|
||||
|
||||
Texture2D texNormal = new Texture2D(width, height, TextureFormat.RGB24, false, false);
|
||||
texNormal.SetPixels(resultPixels);
|
||||
texNormal.Apply();
|
||||
return texNormal;
|
||||
}
|
||||
|
||||
private Vector3 GetPixelClamped(Color[] pixels, int x, int y, int width, int height)
|
||||
{
|
||||
x = Mathf.Clamp(x, 0, width - 1);
|
||||
y = Mathf.Clamp(y, 0, height - 1);
|
||||
Color c = pixels[x + y * width];
|
||||
return new Vector3(c.r, c.g, c.b);
|
||||
}
|
||||
|
||||
private Color[] SmoothNormals(Color[] pixels, int width, int height, int normalSmooth)
|
||||
{
|
||||
Color[] smoothedPixels = new Color[pixels.Length];
|
||||
float step = 0.00390625f * normalSmooth;
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
float pixelsToAverage = 0.0f;
|
||||
Color c = pixels[x + y * width];
|
||||
pixelsToAverage++;
|
||||
|
||||
for (int offsetY = -normalSmooth; offsetY <= normalSmooth; offsetY++)
|
||||
{
|
||||
for (int offsetX = -normalSmooth; offsetX <= normalSmooth; offsetX++)
|
||||
{
|
||||
if (offsetX == 0 && offsetY == 0) continue;
|
||||
|
||||
int sampleX = Mathf.Clamp(x + offsetX, 0, width - 1);
|
||||
int sampleY = Mathf.Clamp(y + offsetY, 0, height - 1);
|
||||
|
||||
c += pixels[sampleX + sampleY * width];
|
||||
pixelsToAverage++;
|
||||
}
|
||||
}
|
||||
|
||||
smoothedPixels[x + y * width] = c / pixelsToAverage;
|
||||
}
|
||||
}
|
||||
|
||||
return smoothedPixels;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 377ab8b8193dc364ba6f648292b747d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/NormalMapCreatorTool.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,83 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class RGBAPackerTool
|
||||
{
|
||||
public RGBAPackerValues values;
|
||||
|
||||
public RGBAPackerTool()
|
||||
{
|
||||
values = ScriptableObject.CreateInstance<RGBAPackerValues>();
|
||||
}
|
||||
|
||||
public void CreateRGBATexture()
|
||||
{
|
||||
int textureSize = (int)values.textureSizes;
|
||||
Texture2D rgbaTexture = new Texture2D(textureSize, textureSize, TextureFormat.RGBA32, false);
|
||||
|
||||
// Get readable copies of input textures
|
||||
Texture2D readableR = GetReadableTexture(values.rChannelTexture, textureSize);
|
||||
Texture2D readableG = GetReadableTexture(values.gChannelTexture, textureSize);
|
||||
Texture2D readableB = GetReadableTexture(values.bChannelTexture, textureSize);
|
||||
Texture2D readableA = GetReadableTexture(values.aChannelTexture, textureSize);
|
||||
|
||||
// Pack channels
|
||||
for(int x = 0; x < textureSize; x++)
|
||||
{
|
||||
for(int y = 0; y < textureSize; y++)
|
||||
{
|
||||
float r = readableR != null ? readableR.GetPixel(x, y).r : (values.rChannelDefaultWhite ? 1f : 0f);
|
||||
float g = readableG != null ? readableG.GetPixel(x, y).r : (values.gChannelDefaultWhite ? 1f : 0f);
|
||||
float b = readableB != null ? readableB.GetPixel(x, y).r : (values.bChannelDefaultWhite ? 1f : 0f);
|
||||
float a = readableA != null ? readableA.GetPixel(x, y).r : (values.aChannelDefaultWhite ? 1f : 0f);
|
||||
|
||||
rgbaTexture.SetPixel(x, y, new Color(r, g, b, a));
|
||||
}
|
||||
}
|
||||
|
||||
rgbaTexture.Apply();
|
||||
values.createdRGBATexture = rgbaTexture;
|
||||
|
||||
// Clean up temporary textures
|
||||
if(readableR != values.rChannelTexture && readableR != null) Object.DestroyImmediate(readableR);
|
||||
if(readableG != values.gChannelTexture && readableG != null) Object.DestroyImmediate(readableG);
|
||||
if(readableB != values.bChannelTexture && readableB != null) Object.DestroyImmediate(readableB);
|
||||
if(readableA != values.aChannelTexture && readableA != null) Object.DestroyImmediate(readableA);
|
||||
}
|
||||
|
||||
private Texture2D GetReadableTexture(Texture2D source, int targetSize)
|
||||
{
|
||||
if(source == null) return null;
|
||||
|
||||
// Check if texture is already readable
|
||||
try
|
||||
{
|
||||
source.GetPixel(0, 0);
|
||||
// If we get here, texture is readable, but we might need to resize
|
||||
if(source.width == targetSize && source.height == targetSize)
|
||||
return source;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Texture is not readable, need to make a copy
|
||||
}
|
||||
|
||||
// Create readable copy
|
||||
RenderTexture renderTexture = RenderTexture.GetTemporary(targetSize, targetSize, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
|
||||
Graphics.Blit(source, renderTexture);
|
||||
|
||||
RenderTexture previous = RenderTexture.active;
|
||||
RenderTexture.active = renderTexture;
|
||||
|
||||
Texture2D readableTexture = new Texture2D(targetSize, targetSize, TextureFormat.RGBA32, false);
|
||||
readableTexture.ReadPixels(new Rect(0, 0, targetSize, targetSize), 0, 0);
|
||||
readableTexture.Apply();
|
||||
|
||||
RenderTexture.active = previous;
|
||||
RenderTexture.ReleaseTemporary(renderTexture);
|
||||
|
||||
return readableTexture;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61842b6b60900c643ae3c6e441a44852
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/RGBAPackerTool.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[CreateAssetMenu(fileName = "RGBAPackerValues", menuName = "AllIn1 3D Shader/RGBA Packer Values")]
|
||||
public class RGBAPackerValues : ScriptableObject
|
||||
{
|
||||
[SerializeField] public Texture2D rChannelTexture;
|
||||
[SerializeField] public bool rChannelDefaultWhite = false;
|
||||
[SerializeField] public Texture2D gChannelTexture;
|
||||
[SerializeField] public bool gChannelDefaultWhite = false;
|
||||
[SerializeField] public Texture2D bChannelTexture;
|
||||
[SerializeField] public bool bChannelDefaultWhite = false;
|
||||
[SerializeField] public Texture2D aChannelTexture;
|
||||
[SerializeField] public bool aChannelDefaultWhite = false;
|
||||
|
||||
[SerializeField] public TextureSizes textureSizes = TextureSizes._512;
|
||||
[SerializeField] public FilterMode filtering = FilterMode.Bilinear;
|
||||
|
||||
[System.NonSerialized] public Texture2D createdRGBATexture;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 528fe3f4f6615d447a0ee01d2fc83aba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/RGBAPackerValues.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class RenderMaterialToImageTool
|
||||
{
|
||||
public static void RenderAndSaveTexture(Material targetMaterial, Texture targetTexture, float scaleSlider, string folderPath, string fileName)
|
||||
{
|
||||
RenderTexture renderTarget = new RenderTexture((int)(targetTexture.width * scaleSlider),
|
||||
(int)(targetTexture.height * scaleSlider), 0, RenderTextureFormat.ARGB32);
|
||||
Graphics.Blit(targetTexture, renderTarget, targetMaterial);
|
||||
Texture2D resultTex = new Texture2D(renderTarget.width, renderTarget.height, TextureFormat.ARGB32, false);
|
||||
resultTex.ReadPixels(new Rect(0, 0, renderTarget.width, renderTarget.height), 0, 0);
|
||||
resultTex.Apply();
|
||||
|
||||
if (!Directory.Exists(folderPath))
|
||||
{
|
||||
EditorUtility.DisplayDialog("The desired Material to Image Save Path doesn't exist",
|
||||
"Go to Window -> AllIn1VfxWindow and set a valid folder", "Ok");
|
||||
return;
|
||||
}
|
||||
|
||||
string fullPath = Path.Combine(folderPath, fileName + ".png");
|
||||
fullPath = AssetDatabase.GenerateUniqueAssetPath(fullPath);
|
||||
|
||||
string correctedFileName = fullPath.Replace(folderPath, string.Empty);
|
||||
|
||||
fullPath = EditorUtility.SaveFilePanel("Save Render Image", folderPath, fileName, "png");
|
||||
|
||||
byte[] bytes = resultTex.EncodeToPNG();
|
||||
File.WriteAllBytes(fullPath, bytes);
|
||||
AssetDatabase.ImportAsset(fullPath);
|
||||
AssetDatabase.Refresh();
|
||||
GameObject.DestroyImmediate(resultTex);
|
||||
|
||||
EditorUtils.PingPath(fullPath);
|
||||
|
||||
EditorUtils.ShowNotification("Render Image saved to: " + fullPath + " with scale: " + scaleSlider +
|
||||
" (it can be changed in Tools -> AllIn1 -> 3DShaderWindow)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 543c3fdde2688b6428241f7df95a671a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/RenderMaterialToImageTool.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16946208f34cf7840a03e45bed00c4a0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,155 @@
|
||||
Shader "AllIn13DShader/Noises/AllIn13DShaderFractalNoise"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_ScaleX("Scale X", Range(0.1, 100)) = 4
|
||||
_ScaleY("Scale Y", Range(0.1, 100)) = 4
|
||||
_StartBand("Start Band", Range(0.1, 10)) = 1
|
||||
_EndBand("End Band", Range(0.1, 10)) = 8
|
||||
_Offset("Offset", Range(-100, 100)) = 1
|
||||
_Contrast("Contrast", Range (0, 10)) = 1
|
||||
_Brightness("Brightness", Range (-1, 1)) = 0
|
||||
[MaterialToggle] _Invert("Invert?", Float) = 0
|
||||
[MaterialToggle] _Fractal("Fractal?", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Cull Off
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 Mod289(float4 x)
|
||||
{
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
float4 PermuteFloat4(float4 x)
|
||||
{
|
||||
return Mod289(((x * 34.0) + 1.0) * x);
|
||||
}
|
||||
|
||||
float4 TaylorInvSqrt(float4 r)
|
||||
{
|
||||
return 1.79284291400159 - 0.85373472095314 * r;
|
||||
}
|
||||
|
||||
float2 FadeFloat2(float2 t)
|
||||
{
|
||||
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
|
||||
}
|
||||
|
||||
float3 FadeFloat3(float3 t)
|
||||
{
|
||||
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
|
||||
}
|
||||
|
||||
float PerlinNoise(float2 P, float2 rep)
|
||||
{
|
||||
float4 Pi = floor(P.xyxy) + float4(0.0, 0.0, 1.0, 1.0);
|
||||
float4 Pf = frac(P.xyxy) - float4(0.0, 0.0, 1.0, 1.0);
|
||||
Pi = fmod(Pi, rep.xyxy);
|
||||
Pi = Mod289(Pi);
|
||||
float4 ix = Pi.xzxz;
|
||||
float4 iy = Pi.yyww;
|
||||
float4 fx = Pf.xzxz;
|
||||
float4 fy = Pf.yyww;
|
||||
|
||||
float4 i = PermuteFloat4(PermuteFloat4(ix) + iy);
|
||||
|
||||
float4 gx = frac(i * (1.0 / 41.0)) * 2.0 - 1.0;
|
||||
float4 gy = abs(gx) - 0.5;
|
||||
float4 tx = floor(gx + 0.5);
|
||||
gx = gx - tx;
|
||||
|
||||
float2 g00 = float2(gx.x, gy.x);
|
||||
float2 g10 = float2(gx.y, gy.y);
|
||||
float2 g01 = float2(gx.z, gy.z);
|
||||
float2 g11 = float2(gx.w, gy.w);
|
||||
|
||||
float4 norm = TaylorInvSqrt(float4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
|
||||
g00 *= norm.x;
|
||||
g01 *= norm.y;
|
||||
g10 *= norm.z;
|
||||
g11 *= norm.w;
|
||||
|
||||
float n00 = dot(g00, float2(fx.x, fy.x));
|
||||
float n10 = dot(g10, float2(fx.y, fy.y));
|
||||
float n01 = dot(g01, float2(fx.z, fy.z));
|
||||
float n11 = dot(g11, float2(fx.w, fy.w));
|
||||
|
||||
float2 fade_xy = FadeFloat2(Pf.xy);
|
||||
float2 n_x = lerp(float2(n00, n01), float2(n10, n11), fade_xy.x);
|
||||
float n_xy = lerp(n_x.x, n_x.y, fade_xy.y);
|
||||
return 2.3 * n_xy;
|
||||
}
|
||||
|
||||
float NoiseManger(float2 st, int scale_x, int scale_y, float seed, float scale_value, int start_band, int end_band, float persistance, int type)
|
||||
{
|
||||
float accum = 0.0;
|
||||
float sx = scale_x;
|
||||
float sy = scale_y;
|
||||
float sv = scale_value;
|
||||
for (int i = 1; i <= 16; i += 1)
|
||||
{
|
||||
if (i >= start_band && i <= end_band)
|
||||
{
|
||||
if (type == 0)
|
||||
accum += (PerlinNoise(float3(st.x * sx, st.y * sy, seed), float3(sx, sy, 1000.)) * 0.5 + 0.5) * sv;
|
||||
else
|
||||
accum += abs(PerlinNoise(float3(st.x * sx, st.y * sy, seed), float3(sx, sy, 1000.))) * sv;
|
||||
sv *= persistance;
|
||||
seed += 1.;
|
||||
}
|
||||
sx *= 2.0;
|
||||
sy *= 2.0;
|
||||
}
|
||||
|
||||
if (type == 2)
|
||||
accum = 1 - accum;
|
||||
|
||||
return accum;
|
||||
}
|
||||
|
||||
half _ScaleX, _ScaleY, _Offset, _StartBand, _EndBand, _Fractal, _Invert, _Contrast, _Brightness;
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
i.uv.x += _Offset * 1.3234;
|
||||
i.uv.y += _Offset * 0.8734;
|
||||
|
||||
float result = NoiseManger(i.uv, _ScaleX, _ScaleY, _Offset * 9745, 0.7, _StartBand, _EndBand, 0.5, 1 - _Fractal);
|
||||
if(_Invert) result = 1 - result;
|
||||
result = saturate((result - 0.5) * _Contrast + 0.5 + _Brightness);
|
||||
|
||||
return half4(result, result, result, 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ad3a3d3df8cd5747b9956fe00a3ed7b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/Shaders/AllIn13DShaderFractalNoise.shader
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,234 @@
|
||||
Shader "AllIn13DShader/Noises/AllIn13DShaderWorleyNoise"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_ScaleX("Scale X", Range(0.1, 100)) = 10
|
||||
_ScaleY("Scale Y", Range(0.1, 100)) = 10
|
||||
_Jitter("Jitter", Range(0.0, 2.0)) = 1
|
||||
_NoiseType("Noise Type", Range(0.0, 4.0)) = 0
|
||||
_Offset("Offset", Range(-100, 100)) = 1
|
||||
_Contrast("Contrast", Range (0, 10)) = 1
|
||||
_Brightness("Brightness", Range (-1, 1)) = 0
|
||||
[MaterialToggle] _Invert("Invert?", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Cull Off
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
float3 Mod(float3 x, float y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float3 Mod3(float3 x, float3 y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float3 Permute(float3 x)
|
||||
{
|
||||
return Mod((34.0 * x + 1.0) * x, 289.0);
|
||||
}
|
||||
|
||||
float3 Distance(float3 x, float3 y, float3 z, bool manhattanDistance)
|
||||
{
|
||||
return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
float2 WorleyNoise(float3 P, float3 rep, float jitter, bool manhattanDistance)
|
||||
{
|
||||
float K = 0.142857142857;
|
||||
float Ko = 0.428571428571;
|
||||
float K2 = 0.020408163265306;
|
||||
float Kz = 0.166666666667;
|
||||
float Kzo = 0.416666666667;
|
||||
|
||||
float3 Pi = Mod3(floor(P), rep);
|
||||
float3 Pf = frac(P) - 0.5;
|
||||
|
||||
float3 Pfx = Pf.x + float3(1.0, 0.0, -1.0);
|
||||
float3 Pfy = Pf.y + float3(1.0, 0.0, -1.0);
|
||||
float3 Pfz = Pf.z + float3(1.0, 0.0, -1.0);
|
||||
|
||||
float3 p = Permute(Mod(Pi.x + float3(-1.0, 0.0, 1.0), rep.x));
|
||||
float3 p1 = Permute(Mod(p + Pi.y - 1.0, rep.y));
|
||||
float3 p2 = Permute(Mod(p + Pi.y, rep.y));
|
||||
float3 p3 = Permute(Mod(p + Pi.y + 1.0, rep.y));
|
||||
|
||||
float3 p11 = Permute(p1 + Pi.z - 1.0);
|
||||
float3 p12 = Permute(p1 + Pi.z);
|
||||
float3 p13 = Permute(p1 + Pi.z + 1.0);
|
||||
|
||||
float3 p21 = Permute(p2 + Pi.z - 1.0);
|
||||
float3 p22 = Permute(p2 + Pi.z);
|
||||
float3 p23 = Permute(p2 + Pi.z + 1.0);
|
||||
|
||||
float3 p31 = Permute(p3 + Pi.z - 1.0);
|
||||
float3 p32 = Permute(p3 + Pi.z);
|
||||
float3 p33 = Permute(p3 + Pi.z + 1.0);
|
||||
|
||||
float3 ox11 = frac(p11 * K) - Ko;
|
||||
float3 oy11 = Mod(floor(p11 * K), 7.0) * K - Ko;
|
||||
float3 oz11 = floor(p11 * K2) * Kz - Kzo;
|
||||
|
||||
float3 ox12 = frac(p12 * K) - Ko;
|
||||
float3 oy12 = Mod(floor(p12 * K), 7.0) * K - Ko;
|
||||
float3 oz12 = floor(p12 * K2) * Kz - Kzo;
|
||||
|
||||
float3 ox13 = frac(p13 * K) - Ko;
|
||||
float3 oy13 = Mod(floor(p13 * K), 7.0) * K - Ko;
|
||||
float3 oz13 = floor(p13 * K2) * Kz - Kzo;
|
||||
|
||||
float3 ox21 = frac(p21 * K) - Ko;
|
||||
float3 oy21 = Mod(floor(p21 * K), 7.0) * K - Ko;
|
||||
float3 oz21 = floor(p21 * K2) * Kz - Kzo;
|
||||
|
||||
float3 ox22 = frac(p22 * K) - Ko;
|
||||
float3 oy22 = Mod(floor(p22 * K), 7.0) * K - Ko;
|
||||
float3 oz22 = floor(p22 * K2) * Kz - Kzo;
|
||||
|
||||
float3 ox23 = frac(p23 * K) - Ko;
|
||||
float3 oy23 = Mod(floor(p23 * K), 7.0) * K - Ko;
|
||||
float3 oz23 = floor(p23 * K2) * Kz - Kzo;
|
||||
|
||||
float3 ox31 = frac(p31 * K) - Ko;
|
||||
float3 oy31 = Mod(floor(p31 * K), 7.0) * K - Ko;
|
||||
float3 oz31 = floor(p31 * K2) * Kz - Kzo;
|
||||
|
||||
float3 ox32 = frac(p32 * K) - Ko;
|
||||
float3 oy32 = Mod(floor(p32 * K), 7.0) * K - Ko;
|
||||
float3 oz32 = floor(p32 * K2) * Kz - Kzo;
|
||||
|
||||
float3 ox33 = frac(p33 * K) - Ko;
|
||||
float3 oy33 = Mod(floor(p33 * K), 7.0) * K - Ko;
|
||||
float3 oz33 = floor(p33 * K2) * Kz - Kzo;
|
||||
|
||||
float3 dx11 = Pfx + jitter * ox11;
|
||||
float3 dy11 = Pfy.x + jitter * oy11;
|
||||
float3 dz11 = Pfz.x + jitter * oz11;
|
||||
|
||||
float3 dx12 = Pfx + jitter * ox12;
|
||||
float3 dy12 = Pfy.x + jitter * oy12;
|
||||
float3 dz12 = Pfz.y + jitter * oz12;
|
||||
|
||||
float3 dx13 = Pfx + jitter * ox13;
|
||||
float3 dy13 = Pfy.x + jitter * oy13;
|
||||
float3 dz13 = Pfz.z + jitter * oz13;
|
||||
|
||||
float3 dx21 = Pfx + jitter * ox21;
|
||||
float3 dy21 = Pfy.y + jitter * oy21;
|
||||
float3 dz21 = Pfz.x + jitter * oz21;
|
||||
|
||||
float3 dx22 = Pfx + jitter * ox22;
|
||||
float3 dy22 = Pfy.y + jitter * oy22;
|
||||
float3 dz22 = Pfz.y + jitter * oz22;
|
||||
|
||||
float3 dx23 = Pfx + jitter * ox23;
|
||||
float3 dy23 = Pfy.y + jitter * oy23;
|
||||
float3 dz23 = Pfz.z + jitter * oz23;
|
||||
|
||||
float3 dx31 = Pfx + jitter * ox31;
|
||||
float3 dy31 = Pfy.z + jitter * oy31;
|
||||
float3 dz31 = Pfz.x + jitter * oz31;
|
||||
|
||||
float3 dx32 = Pfx + jitter * ox32;
|
||||
float3 dy32 = Pfy.z + jitter * oy32;
|
||||
float3 dz32 = Pfz.y + jitter * oz32;
|
||||
|
||||
float3 dx33 = Pfx + jitter * ox33;
|
||||
float3 dy33 = Pfy.z + jitter * oy33;
|
||||
float3 dz33 = Pfz.z + jitter * oz33;
|
||||
|
||||
float3 d11 = Distance(dx11, dy11, dz11, manhattanDistance);
|
||||
float3 d12 = Distance(dx12, dy12, dz12, manhattanDistance);
|
||||
float3 d13 = Distance(dx13, dy13, dz13, manhattanDistance);
|
||||
float3 d21 = Distance(dx21, dy21, dz21, manhattanDistance);
|
||||
float3 d22 = Distance(dx22, dy22, dz22, manhattanDistance);
|
||||
float3 d23 = Distance(dx23, dy23, dz23, manhattanDistance);
|
||||
float3 d31 = Distance(dx31, dy31, dz31, manhattanDistance);
|
||||
float3 d32 = Distance(dx32, dy32, dz32, manhattanDistance);
|
||||
float3 d33 = Distance(dx33, dy33, dz33, manhattanDistance);
|
||||
|
||||
float3 d1a = min(d11, d12);
|
||||
d12 = max(d11, d12);
|
||||
d11 = min(d1a, d13);
|
||||
d13 = max(d1a, d13);
|
||||
d12 = min(d12, d13);
|
||||
float3 d2a = min(d21, d22);
|
||||
d22 = max(d21, d22);
|
||||
d21 = min(d2a, d23);
|
||||
d23 = max(d2a, d23);
|
||||
d22 = min(d22, d23);
|
||||
float3 d3a = min(d31, d32);
|
||||
d32 = max(d31, d32);
|
||||
d31 = min(d3a, d33);
|
||||
d33 = max(d3a, d33);
|
||||
d32 = min(d32, d33);
|
||||
float3 da = min(d11, d21);
|
||||
d21 = max(d11, d21);
|
||||
d11 = min(da, d31);
|
||||
d31 = max(da, d31);
|
||||
d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;
|
||||
d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx;
|
||||
d12 = min(d12, d21);
|
||||
d12 = min(d12, d22);
|
||||
d12 = min(d12, d31);
|
||||
d12 = min(d12, d32);
|
||||
d11.yz = min(d11.yz, d12.xy);
|
||||
d11.y = min(d11.y, d12.z);
|
||||
d11.y = min(d11.y, d11.z);
|
||||
return sqrt(d11.xy);
|
||||
}
|
||||
|
||||
half _ScaleX, _ScaleY, _Jitter, _NoiseType, _Offset, _Fractal, _Invert, _Contrast, _Brightness;
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float2 s = float2(_ScaleX, _ScaleY);
|
||||
float2 f = WorleyNoise(float3(i.uv * s, _Offset), float3(s, 1000), _Jitter, false) * 0.5;
|
||||
|
||||
//Add if for each Type
|
||||
float result = 0;
|
||||
if (_NoiseType < 0.1) result = f.x; //F1 - Voronoi
|
||||
else if (_NoiseType < 1.1) result = f.y; //F2 - Cells 1
|
||||
else if (_NoiseType < 2.1) result = f.y - f.x; //Distance Sub - Cells 2
|
||||
else if (_NoiseType < 3.1) result = f.x * f.y; //Distance Mul - Water Voronoi
|
||||
else if (_NoiseType < 4.1) result = 1 - f.x; //One Minus F - Cellular Noise
|
||||
|
||||
if (_Invert) result = 1 - result;
|
||||
result = saturate((result - 0.5) * _Contrast + 0.5 + _Brightness);
|
||||
|
||||
return half4(result, result, result, 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8cc5605d565f314e941622c9473162a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/Shaders/AllIn13DShaderWorleyNoise.shader
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,306 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class TextureEditorTool
|
||||
{
|
||||
public Texture2D editorTexInput;
|
||||
public Texture2D editorTex;
|
||||
public Texture2D cleanEditorTex;
|
||||
|
||||
public TextureEditorValues values;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
EditorUtils.SetTextureReadWrite(AssetDatabase.GetAssetPath(editorTexInput), true);
|
||||
|
||||
editorTex = new Texture2D(editorTexInput.width, editorTexInput.height);
|
||||
editorTex.SetPixels(editorTexInput.GetPixels());
|
||||
editorTex.Apply();
|
||||
|
||||
float aspectRatio = (float)editorTex.width / (float)editorTex.height;
|
||||
int width = Mathf.Min(editorTex.width, 256);
|
||||
editorTex = ScaleTexture(editorTex, width, (int)(width / aspectRatio));
|
||||
|
||||
cleanEditorTex = new Texture2D(editorTex.width, editorTex.height);
|
||||
cleanEditorTex.SetPixels(editorTex.GetPixels());
|
||||
cleanEditorTex.Apply();
|
||||
|
||||
values = new TextureEditorValues();
|
||||
|
||||
RecalculateEditorTexture();
|
||||
}
|
||||
|
||||
//private void SetTextureReadWrite(string assetPath, bool enable)
|
||||
//{
|
||||
// TextureImporter tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
|
||||
// if (tImporter != null)
|
||||
// {
|
||||
// tImporter.isReadable = enable;
|
||||
// tImporter.SaveAndReimport();
|
||||
// }
|
||||
//}
|
||||
|
||||
private Texture2D ScaleTexture(Texture2D source, int targetWidth, int targetHeight)
|
||||
{
|
||||
targetWidth = Mathf.ClosestPowerOfTwo(targetWidth);
|
||||
targetHeight = Mathf.ClosestPowerOfTwo(targetHeight);
|
||||
|
||||
Texture2D result = new Texture2D(targetWidth, targetHeight, source.format, true);
|
||||
Color[] scaledPixels = result.GetPixels(0);
|
||||
float incX = ((float)1 / source.width) * ((float)source.width / targetWidth);
|
||||
float incY = ((float)1 / source.height) * ((float)source.height / targetHeight);
|
||||
for (int px = 0; px < scaledPixels.Length; px++) scaledPixels[px] = source.GetPixelBilinear(incX * ((float)px % targetWidth), incY * (float)Mathf.Floor(px / targetWidth));
|
||||
|
||||
result.SetPixels(scaledPixels, 0);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void RecalculateEditorTexture()
|
||||
{
|
||||
Color[] pixels = cleanEditorTex.GetPixels();
|
||||
int texWidth = cleanEditorTex.width;
|
||||
int texHeight = cleanEditorTex.height;
|
||||
|
||||
ComputeImageColorFilters(pixels);
|
||||
|
||||
editorTex = new Texture2D(texWidth, texHeight);
|
||||
editorTex.SetPixels(pixels);
|
||||
editorTex.Apply();
|
||||
}
|
||||
|
||||
private void ComputeImageColorFilters(Color[] pixels)
|
||||
{
|
||||
float cosHsv = values.saturation * Mathf.Cos(values.hue * 3.14159265f / 180f);
|
||||
float sinHsv = values.saturation * Mathf.Sin(values.hue * 3.14159265f / 180f);
|
||||
|
||||
for (int i = 0; i < pixels.Length; i++)
|
||||
{
|
||||
pixels[i].r = Mathf.Clamp01(((pixels[i].r - 0.5f) * values.contrast) + 0.5f);
|
||||
pixels[i].g = Mathf.Clamp01(((pixels[i].g - 0.5f) * values.contrast) + 0.5f);
|
||||
pixels[i].b = Mathf.Clamp01(((pixels[i].b - 0.5f) * values.contrast) + 0.5f);
|
||||
|
||||
pixels[i] = new Color(Mathf.Clamp01(pixels[i].r * (1 + values.brightness)), Mathf.Clamp01(pixels[i].g * (1 + values.brightness)), Mathf.Clamp01(pixels[i].b * (1 + values.brightness)), pixels[i].a);
|
||||
|
||||
pixels[i].r = Mathf.Pow(Mathf.Abs(pixels[i].r), values.gamma);
|
||||
pixels[i].g = Mathf.Pow(Mathf.Abs(pixels[i].g), values.gamma);
|
||||
pixels[i].b = Mathf.Pow(Mathf.Abs(pixels[i].b), values.gamma);
|
||||
|
||||
pixels[i].r = Mathf.Clamp01(pixels[i].r * Mathf.Pow(2, values.exposure));
|
||||
pixels[i].g = Mathf.Clamp01(pixels[i].g * Mathf.Pow(2, values.exposure));
|
||||
pixels[i].b = Mathf.Clamp01(pixels[i].b * Mathf.Pow(2, values.exposure));
|
||||
|
||||
pixels[i] *= values.editorColorTint;
|
||||
|
||||
Color hueShiftColor = pixels[i];
|
||||
hueShiftColor.r = Mathf.Clamp01((.299f + .701f * cosHsv + .168f * sinHsv) * pixels[i].r + (.587f - .587f * cosHsv + .330f * sinHsv) * pixels[i].g + (.114f - .114f * cosHsv - .497f * sinHsv) * pixels[i].b);
|
||||
hueShiftColor.g = Mathf.Clamp01((.299f - .299f * cosHsv - .328f * sinHsv) * pixels[i].r + (.587f + .413f * cosHsv + .035f * sinHsv) * pixels[i].g + (.114f - .114f * cosHsv + .292f * sinHsv) * pixels[i].b);
|
||||
hueShiftColor.b = Mathf.Clamp01((.299f - .3f * cosHsv + 1.25f * sinHsv) * pixels[i].r + (.587f - .588f * cosHsv - 1.05f * sinHsv) * pixels[i].g + (.114f + .886f * cosHsv - .203f * sinHsv) * pixels[i].b);
|
||||
pixels[i] = hueShiftColor;
|
||||
|
||||
if (values.invert) pixels[i] = new Color(1 - pixels[i].r, 1 - pixels[i].g, 1 - pixels[i].b, pixels[i].a);
|
||||
|
||||
if (values.greyscale || values.fullWhite || values.alphaGreyscale)
|
||||
{
|
||||
float greyScale = pixels[i].r * 0.59f + pixels[i].g * 0.3f + pixels[i].b * 0.11f;
|
||||
|
||||
if (values.fullWhite) pixels[i] = new Color(1, 1, 1, greyScale);
|
||||
else if (values.greyscale) pixels[i] = new Color(greyScale, greyScale, greyScale, pixels[i].a);
|
||||
|
||||
if (values.alphaGreyscale) pixels[i] = new Color(pixels[i].r, pixels[i].g, pixels[i].b, greyScale);
|
||||
}
|
||||
|
||||
if (values.alphaIsOne) pixels[i] = new Color(pixels[i].r, pixels[i].g, pixels[i].b, 1f);
|
||||
|
||||
if (values.blackBackground)
|
||||
{
|
||||
if (pixels[i].a < 0.05f) pixels[i] = new Color(pixels[i].a, pixels[i].a, pixels[i].a, 1);
|
||||
else pixels[i] = new Color(pixels[i].r, pixels[i].g, pixels[i].b, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void FlipEditorTexture(bool isHorizontal)
|
||||
{
|
||||
Color[] pixels = editorTex.GetPixels();
|
||||
Color[] pixelsClean = cleanEditorTex.GetPixels();
|
||||
int texWidth = editorTex.width;
|
||||
int texHeight = editorTex.height;
|
||||
|
||||
if (isHorizontal)
|
||||
{
|
||||
pixels = FlipHorizontal(pixels, texWidth, texHeight);
|
||||
pixelsClean = FlipHorizontal(pixelsClean, texWidth, texHeight);
|
||||
values.isFlipHorizontal = !values.isFlipHorizontal;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixels = FlipVertical(pixels, texWidth, texHeight);
|
||||
pixelsClean = FlipVertical(pixelsClean, texWidth, texHeight);
|
||||
values.isFlipVertical = !values.isFlipVertical;
|
||||
}
|
||||
|
||||
editorTex = new Texture2D(texWidth, texHeight);
|
||||
editorTex.SetPixels(pixels);
|
||||
editorTex.Apply();
|
||||
cleanEditorTex = new Texture2D(texWidth, texHeight);
|
||||
cleanEditorTex.SetPixels(pixelsClean);
|
||||
cleanEditorTex.Apply();
|
||||
}
|
||||
|
||||
private Color[] FlipHorizontal(Color[] pixels, int width, int height)
|
||||
{
|
||||
Color[] outputPixels = new Color[pixels.Length];
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int i1 = GetPixelIndex(x, y, width);
|
||||
int i2 = GetPixelIndex(width - 1 - x, y, width);
|
||||
outputPixels[i1] = pixels[i2];
|
||||
}
|
||||
}
|
||||
|
||||
return outputPixels;
|
||||
}
|
||||
|
||||
private Color[] FlipVertical(Color[] pixels, int width, int height)
|
||||
{
|
||||
Color[] outputPixels = new Color[pixels.Length];
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int i1 = GetPixelIndex(x, y, width);
|
||||
int i2 = GetPixelIndex(x, height - 1 - y, width);
|
||||
outputPixels[i1] = pixels[i2];
|
||||
}
|
||||
}
|
||||
|
||||
return outputPixels;
|
||||
}
|
||||
|
||||
private int GetPixelIndex(int x, int y, int width)
|
||||
{
|
||||
return y * width + x;
|
||||
}
|
||||
|
||||
public void RotateEditorTextureLeft()
|
||||
{
|
||||
Color[] pixels = editorTex.GetPixels();
|
||||
Color[] pixelsClean = cleanEditorTex.GetPixels();
|
||||
int texWidth = editorTex.width;
|
||||
int texHeight = editorTex.height;
|
||||
|
||||
pixels = RotateClockWise(pixels, texWidth, texHeight);
|
||||
pixelsClean = RotateClockWise(pixelsClean, texWidth, texHeight);
|
||||
|
||||
editorTex = new Texture2D(texHeight, texWidth); //Width and Height get swapped to account for rotation
|
||||
editorTex.SetPixels(pixels);
|
||||
editorTex.Apply();
|
||||
cleanEditorTex = new Texture2D(texHeight, texWidth); //Width and Height get swapped to account for rotation
|
||||
cleanEditorTex.SetPixels(pixelsClean);
|
||||
cleanEditorTex.Apply();
|
||||
|
||||
values.rotationAmount = (values.rotationAmount + 1) % 4;
|
||||
}
|
||||
|
||||
public Color[] RotateClockWise(Color[] pixels, int width, int height)
|
||||
{
|
||||
Color[] outputPixels = new Color[pixels.Length];
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int i1 = GetPixelIndex(x, height - y - 1, width);
|
||||
int i2 = GetPixelIndex(y, x, height);
|
||||
outputPixels[i2] = pixels[i1];
|
||||
}
|
||||
}
|
||||
|
||||
return outputPixels;
|
||||
}
|
||||
|
||||
private void ComputeFinalTexture()
|
||||
{
|
||||
Color[] pixels;
|
||||
int texWidth, texHeight;
|
||||
|
||||
for (int i = 0; i < values.rotationAmount; i++)
|
||||
{
|
||||
texWidth = editorTexInput.width;
|
||||
texHeight = editorTexInput.height;
|
||||
pixels = editorTexInput.GetPixels();
|
||||
pixels = RotateClockWise(pixels, texWidth, texHeight);
|
||||
editorTexInput = new Texture2D(texHeight, texWidth);
|
||||
editorTexInput.SetPixels(pixels);
|
||||
editorTexInput.Apply();
|
||||
}
|
||||
|
||||
pixels = editorTexInput.GetPixels();
|
||||
texWidth = editorTexInput.width;
|
||||
texHeight = editorTexInput.height;
|
||||
if (values.isFlipHorizontal)
|
||||
{
|
||||
pixels = FlipHorizontal(pixels, texWidth, texHeight);
|
||||
}
|
||||
if (values.isFlipVertical)
|
||||
{
|
||||
pixels = FlipVertical(pixels, texWidth, texHeight);
|
||||
}
|
||||
|
||||
ComputeImageColorFilters(pixels);
|
||||
editorTexInput = new Texture2D(texWidth, texHeight);
|
||||
editorTexInput.SetPixels(pixels);
|
||||
editorTexInput.Apply();
|
||||
|
||||
if (Math.Abs(values.exportScale - 1f) > 0.05f)
|
||||
{
|
||||
editorTexInput = ScaleTexture(editorTexInput, (int)(texWidth * values.exportScale), (int)(texHeight * values.exportScale));
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAsPNG()
|
||||
{
|
||||
string fullPath = AssetDatabase.GetAssetPath(editorTexInput);
|
||||
string path = fullPath.Replace(Path.GetFileName(fullPath), "");
|
||||
|
||||
fullPath = AssetDatabase.GenerateUniqueAssetPath(fullPath);
|
||||
|
||||
string fileName = fullPath.Replace(path, "");
|
||||
fileName = fileName.Replace(".png", "");
|
||||
fullPath = EditorUtility.SaveFilePanel("Save Image", path, fileName, "png");
|
||||
if (fullPath.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string pingPath = fullPath;
|
||||
|
||||
ComputeFinalTexture();
|
||||
|
||||
byte[] bytes = editorTexInput.EncodeToPNG();
|
||||
File.WriteAllBytes(pingPath, bytes);
|
||||
AssetDatabase.ImportAsset(pingPath);
|
||||
AssetDatabase.Refresh();
|
||||
EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(pingPath, typeof(Texture)));
|
||||
|
||||
EditorUtils.ShowNotification("Edited Image saved to: " + fullPath);
|
||||
|
||||
editorTexInput = null;
|
||||
editorTex = null;
|
||||
cleanEditorTex = null;
|
||||
|
||||
SetTextureEditorDefaultValues();
|
||||
}
|
||||
|
||||
private void SetTextureEditorDefaultValues()
|
||||
{
|
||||
values.SetDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d7236daca41e9541a940c4cb32fca47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/TextureEditorTool.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class TextureEditorValues
|
||||
{
|
||||
public Color editorColorTint;
|
||||
public float brightness;
|
||||
public float contrast;
|
||||
public float gamma;
|
||||
public float exposure;
|
||||
public float saturation;
|
||||
public float hue;
|
||||
public bool invert;
|
||||
public bool greyscale;
|
||||
public bool fullWhite;
|
||||
public bool blackBackground;
|
||||
public bool alphaGreyscale;
|
||||
public bool alphaIsOne;
|
||||
public bool showOriginalImage;
|
||||
public bool isFlipHorizontal;
|
||||
public bool isFlipVertical;
|
||||
public int rotationAmount;
|
||||
public float exportScale;
|
||||
|
||||
public TextureEditorValues()
|
||||
{
|
||||
SetDefault();
|
||||
}
|
||||
|
||||
public void SetDefault()
|
||||
{
|
||||
editorColorTint = Color.white;
|
||||
brightness = 0f;
|
||||
contrast = 1f;
|
||||
gamma = 1f;
|
||||
exposure = 0f;
|
||||
saturation = 1f;
|
||||
hue = 0f;
|
||||
invert = false;
|
||||
greyscale = false;
|
||||
fullWhite = false;
|
||||
blackBackground = false;
|
||||
alphaGreyscale = false;
|
||||
showOriginalImage = false;
|
||||
isFlipHorizontal = false;
|
||||
isFlipVertical = false;
|
||||
rotationAmount = 0;
|
||||
exportScale = 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32d12b4e3bfea4e42bca81b1abfb8e7b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Editor/Tools/TextureEditorValues.cs
|
||||
uploadId: 865720
|
||||
Reference in New Issue
Block a user