Skip to content

Commit

Permalink
Added warning about transparency when exporting to jpg
Browse files Browse the repository at this point in the history
  • Loading branch information
Error-mdl committed Nov 8, 2021
1 parent 7e8f1e9 commit 63dc3da
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions GaussianTex/Editor/Scripts/GaussTexUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ void OnGUI()
InputTex = EditorGUILayout.ObjectField("Texture to Convert", InputTex, typeof(Texture2D), false, GUILayout.Width(EditorGUIUtility.currentViewWidth - SCROLL_WIDTH)) as Texture2D;

fileType = (FileType)EditorGUILayout.EnumPopup("Save as: ", fileType, GUILayout.Width(EditorGUIUtility.currentViewWidth - SCROLL_WIDTH));
if (fileType == FileType.jpg)
{
TextureImporter texImp = (TextureImporter)AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(InputTex));
if (texImp?.textureType == TextureImporterType.NormalMap)
{
EditorGUILayout.HelpBox("Jpg format cannot store normal maps as they use an alpha channel", MessageType.Error, true);
}
else
{
EditorGUILayout.HelpBox("Jpg format cannot store an alpha channel, only use this for textures with no alpha", MessageType.Warning, true);
}
}

EditorGUILayout.BeginHorizontal(GUILayout.Width(EditorGUIUtility.currentViewWidth - SCROLL_WIDTH));
EditorGUILayout.LabelField(new GUIContent("Decorrolate Colorspace (Albedo, Specular only)","Prevents colors from appearing that aren't in the input image, but may slightly" +
Expand Down Expand Up @@ -150,8 +162,9 @@ void OnGUI()
string inputNameAndPath = AssetDatabase.GetAssetPath(InputTex);
string inputName = Path.GetFileNameWithoutExtension(inputNameAndPath);
string inputPath = Path.GetDirectoryName(inputNameAndPath);
string outputImagePath = Path.Combine(inputPath, inputName + "_gauss.png");
string outputLUTPath = Path.Combine(inputPath, inputName + "_lut.png");

string outputImagePath = Path.Combine(inputPath, inputName + "_gauss" + TexToGaussian.FileTypeToString(fileType));
string outputLUTPath = Path.Combine(inputPath, inputName + "_lut.asset");
string outputColorspacePath = Path.Combine(inputPath, inputName + "_Colorspace.asset");
EditorGUIUtility.PingObject(AssetDatabase.LoadMainAssetAtPath(outputImagePath));
EditorUtility.DisplayDialog("Textures Successfully Created",
Expand Down

0 comments on commit 63dc3da

Please sign in to comment.