mirror of
https://github.com/maxartz15/SceneDebugViewer.git
synced 2024-11-23 04:05:36 +01:00
MipMapTextureCreator.
Added MipMapTextureCreator script to samples.
This commit is contained in:
parent
9f0566f358
commit
583373b050
@ -1,5 +1,9 @@
|
||||
# Change Log:
|
||||
|
||||
## 1.2.0
|
||||
|
||||
- Added texel density preset.
|
||||
|
||||
## 1.1.0
|
||||
|
||||
- Added vertex color preset.
|
||||
|
8
Samples~/MipMapTextureCreator/Editor.meta
Normal file
8
Samples~/MipMapTextureCreator/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2d81576eefc15844914163790c174a5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
61
Samples~/MipMapTextureCreator/Editor/MipMapTextureCreator.cs
Normal file
61
Samples~/MipMapTextureCreator/Editor/MipMapTextureCreator.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class MipMapTextureCreator : ScriptableWizard
|
||||
{
|
||||
public int texSize = 32;
|
||||
public bool autoColor = true;
|
||||
public Color[] mipMapColors;
|
||||
public int mipMaps;
|
||||
|
||||
[MenuItem("Window/Analysis/SceneDebugViewer/MipMapTextureCreator")]
|
||||
static void CreateWizard()
|
||||
{
|
||||
DisplayWizard<MipMapTextureCreator>("Create MipMap Texture", "Create").OnValidate();
|
||||
}
|
||||
|
||||
void OnWizardCreate()
|
||||
{
|
||||
Texture2D tex = new Texture2D(texSize, texSize, TextureFormat.RGBAFloat, mipMaps, false);
|
||||
|
||||
for (int m = 0; m < tex.mipmapCount; m++)
|
||||
{
|
||||
Color[] c = tex.GetPixels(m);
|
||||
|
||||
for (int i = 0; i < c.Length; ++i)
|
||||
{
|
||||
c[i] = mipMapColors[m];
|
||||
}
|
||||
|
||||
tex.SetPixels(c, m);
|
||||
}
|
||||
|
||||
//Texture2D tex = new Texture2D(2, 2, TextureFormat.RGBAFloat, mipMaps, false);
|
||||
|
||||
//for (int m = 0; m < mipMaps; m++)
|
||||
//{
|
||||
// tex.SetPixels(new Color[] { mipMapColors[m], mipMapColors[m], mipMapColors[m], mipMapColors[m] }, m);
|
||||
//}
|
||||
|
||||
tex.Apply(false, true);
|
||||
|
||||
AssetDatabase.CreateAsset(tex, "Assets/MipMap.asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
if (autoColor)
|
||||
{
|
||||
mipMaps = 1 + Mathf.FloorToInt(Mathf.Log(texSize, 2));
|
||||
mipMapColors = new Color[mipMaps];
|
||||
|
||||
for (int c = 0; c < mipMaps; c++)
|
||||
{
|
||||
mipMapColors[c] = Color.HSVToRGB(0.6f - (0.6f / mipMaps * c), 1, 1);
|
||||
// mipMapColors[c].a = Mathf.Sin(1.0f / mipMaps * c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fba1e8247a5d08d4792462dd31b1646c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.tech_art_outsource.scene_debug_viewer",
|
||||
"displayName": "TAO Scene Debug Viewer",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"unity": "2019.4",
|
||||
"description": "View your scene with custom shaders to enhance debugging/development.",
|
||||
"category": "Tool",
|
||||
@ -15,5 +15,12 @@
|
||||
"keywords": [
|
||||
"tech art outsource",
|
||||
"debug viewer"
|
||||
],
|
||||
"samples": [
|
||||
{
|
||||
"displayName": "MipMapTextureCreator",
|
||||
"description": "Create colored mip maps.",
|
||||
"path": "Samples~/MipMapTextureCreator"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user