Add beautify post process to project
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "BeautifyEditor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:15fc0a57446b3144c949da3e2b9737a9",
|
||||
"GUID:df380645f10b7bc4b97d4f5eb6303d95",
|
||||
"GUID:3eae0364be2026648bf74846acb8a731"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46738d4e05ff8486984c82d3b38218aa
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,740 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Beautify.Universal {
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
[CustomEditor(typeof(Beautify))]
|
||||
#else
|
||||
[VolumeComponentEditor(typeof(Beautify))]
|
||||
#endif
|
||||
public class BeautifyEditor : VolumeComponentEditor {
|
||||
|
||||
Beautify beautify;
|
||||
GUIStyle sectionGroupStyle, foldoutStyle, blackBack;
|
||||
PropertyFetcher<Beautify> propertyFetcher;
|
||||
Texture2D headerTex;
|
||||
bool pixelateExpanded;
|
||||
|
||||
// Cached BeautifySettings instances to avoid frequent FindObjectsOfType calls
|
||||
BeautifySettings[] cachedBeautifySettingsInstances;
|
||||
|
||||
// settings group <setting, property reference>
|
||||
class SectionContents {
|
||||
public Dictionary<Beautify.SettingsGroup, List<MemberInfo>> groups = new Dictionary<Beautify.SettingsGroup, List<MemberInfo>>();
|
||||
public List<MemberInfo> singleFields = new List<MemberInfo>();
|
||||
}
|
||||
|
||||
class FieldMeta {
|
||||
public Beautify.DisplayConditionEnum displayConditionEnum;
|
||||
public Beautify.DisplayConditionBool displayConditionBool;
|
||||
public Beautify.DisplayName displayName;
|
||||
public Beautify.GlobalOverride globalOverride;
|
||||
public TooltipAttribute tooltip;
|
||||
public Beautify.ShowStrippedLabel showStrippedLabel;
|
||||
public bool hasToggleAllFields;
|
||||
}
|
||||
|
||||
readonly Dictionary<Beautify.SectionGroup, SectionContents> sections = new Dictionary<Beautify.SectionGroup, SectionContents>();
|
||||
readonly Dictionary<Beautify.SettingsGroup, List<MemberInfo>> groupedFields = new Dictionary<Beautify.SettingsGroup, List<MemberInfo>>();
|
||||
readonly Dictionary<MemberInfo, SerializedDataParameter> unpackedFields = new Dictionary<MemberInfo, SerializedDataParameter>();
|
||||
readonly Dictionary<string, bool> sectionFoldStates = new Dictionary<string, bool>();
|
||||
readonly Dictionary<MemberInfo, FieldMeta> fieldMeta = new Dictionary<MemberInfo, FieldMeta>();
|
||||
const string SECTION_FOLD_PREF_PREFIX = "Beautify_SectionFold_";
|
||||
#if !UNITY_2021_2_OR_NEWER
|
||||
public override bool hasAdvancedMode => false;
|
||||
#endif
|
||||
|
||||
public override void OnEnable () {
|
||||
if (target == null) return;
|
||||
|
||||
base.OnEnable();
|
||||
|
||||
headerTex = Resources.Load<Texture2D>("beautifyHeader");
|
||||
blackBack = new GUIStyle();
|
||||
blackBack.normal.background = MakeTex(4, 4, Color.black);
|
||||
blackBack.alignment = TextAnchor.MiddleCenter;
|
||||
|
||||
beautify = (Beautify)target;
|
||||
|
||||
propertyFetcher = new PropertyFetcher<Beautify>(serializedObject);
|
||||
|
||||
// Cache BeautifySettings instances on enable
|
||||
cachedBeautifySettingsInstances = Misc.FindObjectsOfType<BeautifySettings>(true);
|
||||
|
||||
// get volume fx settings
|
||||
var settings = beautify.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
|
||||
.Where(t => t.FieldType.IsSubclassOf(typeof(VolumeParameter)))
|
||||
.Where(t => (t.IsPublic && t.GetCustomAttributes(typeof(NonSerializedAttribute), false).Length == 0) ||
|
||||
(t.GetCustomAttributes(typeof(SerializeField), false).Length > 0))
|
||||
.Where(t => t.GetCustomAttributes(typeof(HideInInspector), false).Length == 0)
|
||||
.Where(t => t.GetCustomAttributes(typeof(Beautify.SectionGroup), false).Any());
|
||||
|
||||
// group by settings first
|
||||
unpackedFields.Clear();
|
||||
sections.Clear();
|
||||
groupedFields.Clear();
|
||||
fieldMeta.Clear();
|
||||
foreach (var setting in settings) {
|
||||
SectionContents sectionContents = null;
|
||||
|
||||
foreach (var section in setting.GetCustomAttributes(typeof(Beautify.SectionGroup)) as IEnumerable<Beautify.SectionGroup>) {
|
||||
if (!sections.TryGetValue(section, out sectionContents)) {
|
||||
sectionContents = sections[section] = new SectionContents();
|
||||
}
|
||||
|
||||
bool isGrouped = false;
|
||||
foreach (var settingGroup in setting.GetCustomAttributes(typeof(Beautify.SettingsGroup)) as IEnumerable<Beautify.SettingsGroup>) {
|
||||
if (!groupedFields.ContainsKey(settingGroup)) {
|
||||
sectionContents.groups[settingGroup] = groupedFields[settingGroup] = new List<MemberInfo>();
|
||||
}
|
||||
groupedFields[settingGroup].Add(setting);
|
||||
isGrouped = true;
|
||||
unpackedFields[setting] = Unpack(propertyFetcher.Find(setting.Name));
|
||||
}
|
||||
|
||||
if (!isGrouped) {
|
||||
sectionContents.singleFields.Add(setting);
|
||||
unpackedFields[setting] = Unpack(propertyFetcher.Find(setting.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDisable() {
|
||||
EditorApplication.delayCall -= RepaintAllViews;
|
||||
cachedBeautifySettingsInstances = null;
|
||||
}
|
||||
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
SetStyles();
|
||||
|
||||
Beautify.TonemapOperator prevTonemap = beautify.tonemap.value;
|
||||
bool prevDirectWrite = beautify.directWrite.value;
|
||||
int prevBloomExclusionLayerMask = beautify.bloomExclusionLayerMask.overrideState ? (int)beautify.bloomExclusionLayerMask.value : 0;
|
||||
int prevAnamorphicFlaresExclusionLayerMask = beautify.anamorphicFlaresExclusionLayerMask.overrideState ? (int)beautify.anamorphicFlaresExclusionLayerMask.value : 0;
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
{
|
||||
GUILayout.BeginHorizontal(blackBack);
|
||||
GUILayout.Label(headerTex, blackBack, GUILayout.ExpandWidth(true));
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button(new GUIContent("Clear Effects", "Clears all effect overrides"), EditorStyles.miniButton)) {
|
||||
if (EditorUtility.DisplayDialog("Clear Effects", "Do you want to clear all effects?", "Yes", "Cancel")) {
|
||||
beautify.sharpenIntensity.overrideState = false;
|
||||
beautify.antialiasStrength.overrideState = false;
|
||||
beautify.ditherIntensity.overrideState = false;
|
||||
beautify.tonemap.overrideState = false;
|
||||
beautify.saturate.Override(0);
|
||||
beautify.brightness.overrideState = false;
|
||||
beautify.contrast.overrideState = false;
|
||||
beautify.daltonize.overrideState = false;
|
||||
beautify.sepia.overrideState = false;
|
||||
beautify.tintColor.overrideState = false;
|
||||
beautify.colorTemp.overrideState = false;
|
||||
beautify.colorTempBlend.overrideState = false;
|
||||
beautify.lut.overrideState = false;
|
||||
beautify.bloomIntensity.overrideState = false;
|
||||
beautify.anamorphicFlaresIntensity.overrideState = false;
|
||||
beautify.sunFlaresIntensity.overrideState = false;
|
||||
beautify.lensDirtIntensity.overrideState = false;
|
||||
beautify.chromaticAberrationIntensity.overrideState = false;
|
||||
beautify.depthOfField.overrideState = false;
|
||||
beautify.eyeAdaptation.overrideState = false;
|
||||
beautify.purkinje.overrideState = false;
|
||||
beautify.vignettingOuterRing.overrideState = false;
|
||||
beautify.vignettingInnerRing.overrideState = false;
|
||||
beautify.vignettingFade.overrideState = false;
|
||||
beautify.vignettingBlink.overrideState = false;
|
||||
beautify.outline.overrideState = false;
|
||||
beautify.nightVision.overrideState = false;
|
||||
beautify.thermalVision.overrideState = false;
|
||||
beautify.frame.overrideState = false;
|
||||
beautify.blurIntensity.overrideState = false;
|
||||
EditorUtility.SetDirty(beautify);
|
||||
}
|
||||
}
|
||||
if (GUILayout.Button(new GUIContent("Quick Settings", "Applies a default set of effects including color improvement, sharpening, vignette and bloom."), EditorStyles.miniButton)) {
|
||||
if (EditorUtility.DisplayDialog("Quick Settings", "Do you want to apply a collection of example effect settings (including color improvements, dithering, sharpening, vignette and bloom)?\nYou can adjust them later as you wish.", "Yes", "No")) {
|
||||
beautify.sharpenIntensity.Override(4f);
|
||||
beautify.ditherIntensity.Override(0.005f);
|
||||
beautify.brightness.Override(1.05f);
|
||||
beautify.saturate.Override(1f);
|
||||
beautify.contrast.Override(1.02f);
|
||||
beautify.bloomIntensity.Override(0.25f);
|
||||
beautify.bloomThreshold.Override(0.75f);
|
||||
beautify.vignettingOuterRing.Override(0.325f);
|
||||
beautify.vignettingInnerRing.Override(0.925f);
|
||||
EditorUtility.SetDirty(beautify);
|
||||
}
|
||||
}
|
||||
if (GUILayout.Button("Online Resources & Support")) {
|
||||
ContactUsWindow.ShowScreen();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
// Add "Configure Build Settings" button after the first section is fully drawn
|
||||
string strippedKeywords = PlayerPrefs.GetString(BeautifyRendererFeature.PLAYER_PREF_KEYNAME, "");
|
||||
if (string.IsNullOrEmpty(strippedKeywords)) {
|
||||
EditorGUILayout.HelpBox("All features are currently included in the build, which may significantly increase compilation time. Click the button below to configure and exclude unnecessary features from the build.", MessageType.Warning);
|
||||
}
|
||||
if (GUILayout.Button("Configure Build Settings >")) {
|
||||
SelectActiveURPRendererAsset();
|
||||
}
|
||||
|
||||
|
||||
// Check for multiple BeautifySettings instances
|
||||
BeautifySettings[] beautifySettingsInstances = cachedBeautifySettingsInstances;
|
||||
if (beautifySettingsInstances != null && beautifySettingsInstances.Length > 1) {
|
||||
EditorGUILayout.HelpBox($"Multiple BeautifySettings instances found in the scene ({beautifySettingsInstances.Length}). It's recommended to keep only one instance.", MessageType.Warning);
|
||||
|
||||
EditorGUILayout.LabelField("Found instances:", EditorStyles.boldLabel);
|
||||
foreach (BeautifySettings settingsInstance in beautifySettingsInstances) {
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(settingsInstance.gameObject.name, GUILayout.ExpandWidth(true));
|
||||
if (GUILayout.Button("Select", GUILayout.Width(60))) {
|
||||
Selection.activeObject = settingsInstance.gameObject;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
|
||||
UniversalRenderPipelineAsset pipe = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||
|
||||
Camera cam = Camera.main;
|
||||
if (cam != null) {
|
||||
UniversalAdditionalCameraData data = cam.GetComponent<UniversalAdditionalCameraData>();
|
||||
if (data != null && !data.renderPostProcessing && !BeautifyRendererFeature.ignoringPostProcessingOption) {
|
||||
EditorGUILayout.HelpBox("Post Processing option is disabled in the camera. Either enable it or enable the option 'Ignore Post Processing Option' in the Beautify Render Feature.", MessageType.Warning);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Go to Camera")) {
|
||||
Selection.activeObject = cam;
|
||||
}
|
||||
if (GUILayout.Button("Go to Universal Rendering Pipeline Asset")) {
|
||||
Selection.activeObject = pipe;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
}
|
||||
|
||||
if (pipe == null) {
|
||||
EditorGUILayout.HelpBox("Universal Rendering Pipeline asset is not set in 'Project Settings / Graphics' !", MessageType.Error);
|
||||
EditorGUILayout.Separator();
|
||||
GUI.enabled = false;
|
||||
}
|
||||
else if (!BeautifyRendererFeature.installed) {
|
||||
EditorGUILayout.HelpBox("Beautify Render Feature must be added to the rendering pipeline renderer.", MessageType.Error);
|
||||
if (GUILayout.Button("Go to Universal Rendering Pipeline Asset")) {
|
||||
Selection.activeObject = pipe;
|
||||
}
|
||||
EditorGUILayout.Separator();
|
||||
GUI.enabled = false;
|
||||
}
|
||||
else if (beautify.RequiresDepthTexture()) {
|
||||
#if !UNITY_2021_3_OR_NEWER
|
||||
if (!pipe.supportsCameraDepthTexture) {
|
||||
EditorGUILayout.HelpBox("Depth Texture option may be required for certain effects. Check Universal Rendering Pipeline asset!", MessageType.Warning);
|
||||
if (GUILayout.Button("Go to Universal Rendering Pipeline Asset")) {
|
||||
Selection.activeObject = pipe;
|
||||
}
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool usesHDREffect = beautify.tonemap.value != Beautify.TonemapOperator.Linear;
|
||||
if (usesHDREffect && (QualitySettings.activeColorSpace != ColorSpace.Linear || (Camera.main != null && !Camera.main.allowHDR))) {
|
||||
EditorGUILayout.HelpBox("Some effects, like bloom or tonemapping, works better with Linear Color Space and HDR enabled. Enable Linear color space in Player Settings and check your camera and pipeline HDR setting.", MessageType.Warning);
|
||||
}
|
||||
|
||||
if ((bool)beautify.directWrite) {
|
||||
#if !UNITY_2022_3_OR_NEWER
|
||||
if (UnityEngine.XR.XRSettings.enabled) {
|
||||
EditorGUILayout.HelpBox("Direct Write To Camera option is not compatible with VR.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// sections
|
||||
foreach (var section in sections) {
|
||||
string sectionName = ObjectNames.NicifyVariableName(section.Key.GetType().Name);
|
||||
bool sectionExpanded = GetSectionFoldState(sectionName);
|
||||
|
||||
GUILayout.Space(6.0f);
|
||||
Rect rect = GUILayoutUtility.GetRect(16f, 22f, sectionGroupStyle);
|
||||
|
||||
// Draw foldout arrow
|
||||
Rect foldoutRect = new Rect(rect.x + 4f, rect.y + 3f, 13f, 13f);
|
||||
if (Event.current.type == EventType.Repaint) {
|
||||
EditorStyles.foldout.Draw(foldoutRect, false, false, sectionExpanded, false);
|
||||
}
|
||||
|
||||
// Draw section header with offset for arrow
|
||||
GUIStyle headerStyle = new GUIStyle(sectionGroupStyle);
|
||||
headerStyle.contentOffset = new Vector2(12f, -2f);
|
||||
GUI.Box(rect, sectionName, headerStyle);
|
||||
|
||||
// Handle click on header
|
||||
if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition)) {
|
||||
sectionExpanded = !sectionExpanded;
|
||||
SetSectionFoldState(sectionName, sectionExpanded);
|
||||
Event.current.Use();
|
||||
}
|
||||
|
||||
EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);
|
||||
|
||||
if (!sectionExpanded) continue;
|
||||
|
||||
// individual properties
|
||||
EditorGUI.indentLevel++;
|
||||
foreach (var field in section.Value.singleFields) {
|
||||
if (!unpackedFields.TryGetValue(field, out var parameter)) continue;
|
||||
|
||||
bool indent;
|
||||
if (!IsVisible(parameter, field, out indent)) {
|
||||
if (GetMeta(field).showStrippedLabel != null) {
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUI.enabled = false;
|
||||
DrawPropertyField(parameter, field, indent);
|
||||
GUILayout.Label("(Not available - Check General Options)");
|
||||
GUI.enabled = true;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
DrawPropertyField(parameter, field, indent);
|
||||
|
||||
if (beautify.disabled.value) GUI.enabled = false;
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
GUILayout.Space(6.0f);
|
||||
|
||||
// grouped properties
|
||||
foreach (var group in section.Value.groups) {
|
||||
Beautify.SettingsGroup settingsGroup = group.Key;
|
||||
string groupName = ObjectNames.NicifyVariableName(settingsGroup.GetType().Name);
|
||||
bool printGroupFoldout = true;
|
||||
bool firstField = true;
|
||||
bool groupHasContent = false;
|
||||
|
||||
foreach (var field in group.Value) {
|
||||
if (!unpackedFields.TryGetValue(field, out var parameter)) continue;
|
||||
|
||||
bool indent;
|
||||
if (!IsVisible(parameter, field, out indent)) {
|
||||
if (firstField) {
|
||||
if (GetMeta(field).showStrippedLabel != null) {
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.Foldout(false, groupName, true, foldoutStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label("(Not available - Check General Options)");
|
||||
GUI.enabled = true;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
GUILayout.Space(6.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
firstField = false;
|
||||
|
||||
if (printGroupFoldout) {
|
||||
printGroupFoldout = false;
|
||||
settingsGroup.IsExpanded = EditorGUILayout.Foldout(settingsGroup.IsExpanded, groupName, true, foldoutStyle);
|
||||
if (!settingsGroup.IsExpanded)
|
||||
break;
|
||||
EditorGUI.indentLevel++;
|
||||
}
|
||||
|
||||
DrawPropertyField(parameter, field, indent);
|
||||
groupHasContent = true;
|
||||
|
||||
if (parameter.value.propertyType == SerializedPropertyType.Boolean) {
|
||||
if (!parameter.value.boolValue) {
|
||||
var hasToggleSectionBegin = GetMeta(field).hasToggleAllFields;
|
||||
if (hasToggleSectionBegin) break;
|
||||
}
|
||||
}
|
||||
else if (field.Name.Equals("depthOfFieldFocusMode")) {
|
||||
if (BeautifySettings.instance != null && BeautifySettings.instance.depthOfFieldTarget == null) {
|
||||
SerializedProperty prop = serializedObject.FindProperty(field.Name);
|
||||
if (prop != null) {
|
||||
var value = prop.FindPropertyRelative("m_Value");
|
||||
if (value != null && value.enumValueIndex == (int)Beautify.DoFFocusMode.FollowTarget) {
|
||||
EditorGUILayout.HelpBox("Assign target in the Beautify Settings component.", MessageType.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (groupHasContent) {
|
||||
EditorGUI.indentLevel--;
|
||||
GUILayout.Space(6.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
if (GetSectionFoldState("Artistic Choices")) {
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Space(6.0f);
|
||||
pixelateExpanded = EditorGUILayout.Foldout(pixelateExpanded, "Pixelate", true, foldoutStyle);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
if (pixelateExpanded) {
|
||||
EditorGUILayout.HelpBox("Use the Downsampling option in General Settings to apply a pixelate effect.", MessageType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties()) {
|
||||
if (beautify.directWrite.value != prevDirectWrite || (beautify.bloomExclusionLayerMask.overrideState ? (int)beautify.bloomExclusionLayerMask.value : 0) != prevBloomExclusionLayerMask || (beautify.anamorphicFlaresExclusionLayerMask.overrideState ? (int)beautify.anamorphicFlaresExclusionLayerMask.value : 0) != prevAnamorphicFlaresExclusionLayerMask || beautify.outline.value) {
|
||||
EditorApplication.delayCall += RepaintAllViews;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevTonemap != beautify.tonemap.value && beautify.tonemap.value != Beautify.TonemapOperator.Linear) {
|
||||
beautify.saturate.value = 0;
|
||||
beautify.saturate.overrideState = true;
|
||||
beautify.contrast.value = 1f;
|
||||
beautify.contrast.overrideState = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void RepaintAllViews() {
|
||||
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
|
||||
}
|
||||
|
||||
FieldMeta GetMeta (MemberInfo field) {
|
||||
if (!fieldMeta.TryGetValue(field, out var meta)) {
|
||||
meta = new FieldMeta {
|
||||
displayConditionEnum = field.GetCustomAttribute(typeof(Beautify.DisplayConditionEnum)) as Beautify.DisplayConditionEnum,
|
||||
displayConditionBool = field.GetCustomAttribute(typeof(Beautify.DisplayConditionBool)) as Beautify.DisplayConditionBool,
|
||||
displayName = field.GetCustomAttribute(typeof(Beautify.DisplayName)) as Beautify.DisplayName,
|
||||
globalOverride = field.GetCustomAttribute(typeof(Beautify.GlobalOverride)) as Beautify.GlobalOverride,
|
||||
tooltip = field.GetCustomAttribute(typeof(TooltipAttribute)) as TooltipAttribute,
|
||||
showStrippedLabel = field.GetCustomAttribute(typeof(Beautify.ShowStrippedLabel)) as Beautify.ShowStrippedLabel,
|
||||
hasToggleAllFields = field.GetCustomAttribute(typeof(Beautify.ToggleAllFields)) != null
|
||||
};
|
||||
fieldMeta[field] = meta;
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
bool IsVisible (SerializedDataParameter property, MemberInfo field, out bool indent) {
|
||||
bool visible = true;
|
||||
indent = false;
|
||||
|
||||
FieldMeta meta = GetMeta(field);
|
||||
Beautify.DisplayConditionEnum enumCondition = meta.displayConditionEnum;
|
||||
Beautify.DisplayConditionBool boolCondition = meta.displayConditionBool;
|
||||
bool isEnumCondition = enumCondition != null;
|
||||
bool isBoolCondition = boolCondition != null;
|
||||
bool canIndent = isEnumCondition ^ isBoolCondition;
|
||||
|
||||
if (isEnumCondition) {
|
||||
SerializedProperty condProp = propertyFetcher.Find(enumCondition.field);
|
||||
if (condProp != null) {
|
||||
var value = condProp.FindPropertyRelative("m_Value");
|
||||
if (value != null) {
|
||||
visible = false;
|
||||
if (enumCondition.isEqual) {
|
||||
if (value.enumValueIndex == enumCondition.enumValueIndex) {
|
||||
indent = canIndent;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (value.enumValueIndex != enumCondition.enumValueIndex) {
|
||||
indent = canIndent;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* OR */
|
||||
if (isBoolCondition) {
|
||||
SerializedProperty condProp = propertyFetcher.Find(boolCondition.field);
|
||||
if (condProp != null) {
|
||||
var value = condProp.FindPropertyRelative("m_Value");
|
||||
if (value != null) {
|
||||
if (value.boolValue != boolCondition.value) {
|
||||
return false;
|
||||
}
|
||||
indent = value.boolValue;
|
||||
}
|
||||
}
|
||||
/* AND */
|
||||
SerializedProperty condProp2 = propertyFetcher.Find(boolCondition.field2);
|
||||
if (condProp2 != null) {
|
||||
var value2 = condProp2.FindPropertyRelative("m_Value");
|
||||
if (value2 != null) {
|
||||
if (value2.boolValue != boolCondition.value2) {
|
||||
return false;
|
||||
}
|
||||
indent = indent || value2.boolValue;
|
||||
}
|
||||
}
|
||||
indent &= canIndent;
|
||||
visible = true;
|
||||
}
|
||||
|
||||
return visible;
|
||||
}
|
||||
|
||||
void DrawPropertyField (SerializedDataParameter property, MemberInfo field, bool indent) {
|
||||
|
||||
if (indent) {
|
||||
EditorGUI.indentLevel++;
|
||||
}
|
||||
|
||||
FieldMeta meta = GetMeta(field);
|
||||
var displayName = property.displayName;
|
||||
if (meta.displayName != null) {
|
||||
displayName = meta.displayName.name;
|
||||
}
|
||||
|
||||
if (property.value.propertyType == SerializedPropertyType.Boolean) {
|
||||
|
||||
if (meta.globalOverride != null) {
|
||||
|
||||
BoolParameter pr = property.GetObjectRef<BoolParameter>();
|
||||
bool prev = pr.value;
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
float w = 17f;
|
||||
if (EditorGUI.indentLevel > 0) w += 8f;
|
||||
var overrideRect = GUILayoutUtility.GetRect(w, 20f, GUILayout.ExpandWidth(false));
|
||||
overrideRect.yMin += 4f;
|
||||
if (EditorGUI.indentLevel > 0) {
|
||||
overrideRect.xMin += 12f;
|
||||
}
|
||||
bool value = GUI.Toggle(overrideRect, prev, GUIContent.none);
|
||||
|
||||
string tooltip = null;
|
||||
if (meta.tooltip != null) {
|
||||
tooltip = meta.tooltip.tooltip;
|
||||
}
|
||||
|
||||
using (new EditorGUI.DisabledScope(!prev)) {
|
||||
EditorGUILayout.LabelField(new GUIContent(displayName, tooltip));
|
||||
}
|
||||
|
||||
if (value != prev) {
|
||||
pr.value = value;
|
||||
SerializedProperty prop = serializedObject.FindProperty(field.Name);
|
||||
if (prop != null) {
|
||||
var boolProp = prop.FindPropertyRelative("m_Value");
|
||||
if (boolProp != null) {
|
||||
boolProp.boolValue = value;
|
||||
}
|
||||
if (value) {
|
||||
var overrideProp = prop.FindPropertyRelative("m_OverrideState");
|
||||
if (overrideProp != null) {
|
||||
overrideProp.boolValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
PropertyField(property, new GUIContent(displayName));
|
||||
}
|
||||
}
|
||||
else {
|
||||
PropertyField(property, new GUIContent(displayName));
|
||||
}
|
||||
|
||||
if (indent) {
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Add warning messages for stripped features
|
||||
if (meta.showStrippedLabel != null) {
|
||||
|
||||
string strippedKeywords = PlayerPrefs.GetString(BeautifyRendererFeature.PLAYER_PREF_KEYNAME, "");
|
||||
bool isEnabled = false;
|
||||
bool isOverridden = property.overrideState.boolValue;
|
||||
if (isOverridden) {
|
||||
if (property.value.propertyType == SerializedPropertyType.Boolean) {
|
||||
isEnabled = property.value.boolValue;
|
||||
}
|
||||
else if (property.value.propertyType == SerializedPropertyType.Float) {
|
||||
isEnabled = property.value.floatValue > 0;
|
||||
}
|
||||
else if (property.value.propertyType == SerializedPropertyType.Enum) {
|
||||
isEnabled = property.value.enumValueIndex > 0;
|
||||
}
|
||||
else if (property.value.propertyType == SerializedPropertyType.LayerMask) {
|
||||
isEnabled = property.value.intValue != 0;
|
||||
}
|
||||
else if (property.value.propertyType == SerializedPropertyType.ObjectReference) {
|
||||
isEnabled = property.value.objectReferenceValue != null;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnabled) {
|
||||
string warningMessage = null;
|
||||
string fieldName = field.Name;
|
||||
|
||||
// Check each stripped feature against the keywords in PlayerPrefs
|
||||
if ((fieldName == "sharpenIntensity" && strippedKeywords.Contains(ShaderParams.SKW_SHARPEN)) ||
|
||||
(fieldName == "sharpenExclusionLayerMask" && strippedKeywords.Contains(ShaderParams.SKW_SHARPEN_EXCLUSION_MASK)) ||
|
||||
(fieldName == "ditherIntensity" && strippedKeywords.Contains(ShaderParams.SKW_DITHER)) ||
|
||||
(fieldName == "tonemap" &&
|
||||
((property.value.enumValueIndex == (int)Beautify.TonemapOperator.ACES && strippedKeywords.Contains(ShaderParams.SKW_TONEMAP_ACES)) ||
|
||||
(property.value.enumValueIndex == (int)Beautify.TonemapOperator.ACESFitted && strippedKeywords.Contains(ShaderParams.SKW_TONEMAP_ACES_FITTED)) ||
|
||||
(property.value.enumValueIndex == (int)Beautify.TonemapOperator.AGX && strippedKeywords.Contains(ShaderParams.SKW_TONEMAP_AGX)))) ||
|
||||
(fieldName == "lut" && strippedKeywords.Contains(ShaderParams.SKW_LUT3D) && strippedKeywords.Contains(ShaderParams.SKW_LUT)) ||
|
||||
((fieldName == "bloomIntensity" || fieldName == "anamorphicFlaresIntensity" || fieldName == "sunFlaresIntensity") && strippedKeywords.Contains(ShaderParams.SKW_BLOOM)) ||
|
||||
(fieldName == "outline" && strippedKeywords.Contains(ShaderParams.SKW_OUTLINE)) ||
|
||||
(fieldName == "nightVision" && strippedKeywords.Contains(ShaderParams.SKW_NIGHT_VISION)) ||
|
||||
(fieldName == "thermalVision" && strippedKeywords.Contains(ShaderParams.SKW_THERMAL_VISION)) ||
|
||||
(fieldName == "chromaticAberrationIntensity" && strippedKeywords.Contains(ShaderParams.SKW_CHROMATIC_ABERRATION)) ||
|
||||
(fieldName == "depthOfField" && strippedKeywords.Contains(ShaderParams.SKW_DEPTH_OF_FIELD)) ||
|
||||
(fieldName == "depthOfFieldTransparentSupport" && strippedKeywords.Contains(ShaderParams.SKW_DEPTH_OF_FIELD_TRANSPARENT)) ||
|
||||
(fieldName == "depthOfFieldAlphaTestSupport" && strippedKeywords.Contains(ShaderParams.SKW_DEPTH_OF_FIELD_TRANSPARENT)) ||
|
||||
(fieldName == "eyeAdaptation" && strippedKeywords.Contains(ShaderParams.SKW_EYE_ADAPTATION)) ||
|
||||
(fieldName == "purkinje" && strippedKeywords.Contains(ShaderParams.SKW_PURKINJE)) ||
|
||||
(fieldName == "vignettingOuterRing" && strippedKeywords.Contains(ShaderParams.SKW_VIGNETTING)) ||
|
||||
(fieldName == "vignettingMask" && strippedKeywords.Contains(ShaderParams.SKW_VIGNETTING_MASK)) ||
|
||||
(fieldName == "filmGrainIntensity" && strippedKeywords.Contains(ShaderParams.SKW_FILM_GRAIN)) ||
|
||||
(fieldName == "filmGrainEnabled" && strippedKeywords.Contains(ShaderParams.SKW_FILM_GRAIN)) ||
|
||||
(fieldName == "frame" && strippedKeywords.Contains(ShaderParams.SKW_FRAME)) ||
|
||||
(fieldName == "lensDirtIntensity" && strippedKeywords.Contains(ShaderParams.SKW_DIRT)) ||
|
||||
(fieldName == "antialiasStrength" && strippedKeywords.Contains(ShaderParams.SKW_EDGE_ANTIALIASING)) ||
|
||||
((fieldName == "sepia" || fieldName == "daltonize" || fieldName == "colorTemp") && strippedKeywords.Contains(ShaderParams.SKW_COLOR_TWEAKS))) {
|
||||
warningMessage = "This feature is stripped in the build.";
|
||||
}
|
||||
|
||||
if (warningMessage != null) {
|
||||
var linkContent = new GUIContent("(click to configure)");
|
||||
var linkSize = EditorStyles.linkLabel.CalcSize(linkContent);
|
||||
var height = EditorGUIUtility.singleLineHeight + 8;
|
||||
|
||||
var warningRect = EditorGUILayout.GetControlRect(false, height);
|
||||
warningRect.xMin += 8;
|
||||
warningRect.xMax -= 8;
|
||||
EditorGUI.HelpBox(warningRect, "", MessageType.Warning);
|
||||
|
||||
var textRect = warningRect;
|
||||
textRect.xMin += 24f;
|
||||
textRect.xMax -= linkSize.x + 8;
|
||||
EditorGUI.LabelField(textRect, warningMessage);
|
||||
|
||||
var linkRect = warningRect;
|
||||
linkRect.xMin = textRect.xMax;
|
||||
linkRect.y = textRect.y + 3;
|
||||
|
||||
if (GUI.Button(linkRect, linkContent, EditorStyles.linkLabel)) {
|
||||
SelectActiveURPRendererAsset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SetStyles () {
|
||||
|
||||
// section header style
|
||||
Color titleColor = EditorGUIUtility.isProSkin ? new Color(0.52f, 0.66f, 0.9f) : new Color(0.12f, 0.16f, 0.4f);
|
||||
GUIStyle skurikenModuleTitleStyle = "ShurikenModuleTitle";
|
||||
sectionGroupStyle = new GUIStyle(skurikenModuleTitleStyle);
|
||||
sectionGroupStyle.contentOffset = new Vector2(5f, -2f);
|
||||
sectionGroupStyle.normal.textColor = titleColor;
|
||||
sectionGroupStyle.fixedHeight = 22;
|
||||
sectionGroupStyle.fontStyle = FontStyle.Bold;
|
||||
|
||||
// foldout style
|
||||
foldoutStyle = new GUIStyle(EditorStyles.foldout);
|
||||
foldoutStyle.margin = new RectOffset(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
bool GetSectionFoldState(string sectionName) {
|
||||
if (!sectionFoldStates.TryGetValue(sectionName, out bool state)) {
|
||||
state = EditorPrefs.GetBool(SECTION_FOLD_PREF_PREFIX + sectionName, true);
|
||||
sectionFoldStates[sectionName] = state;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
void SetSectionFoldState(string sectionName, bool expanded) {
|
||||
sectionFoldStates[sectionName] = expanded;
|
||||
EditorPrefs.SetBool(SECTION_FOLD_PREF_PREFIX + sectionName, expanded);
|
||||
}
|
||||
|
||||
[VolumeParameterDrawer(typeof(Beautify.MinMaxFloatParameter))]
|
||||
public class MinMaxFloatParameterDrawer : VolumeParameterDrawer {
|
||||
public override bool OnGUI (SerializedDataParameter parameter, GUIContent title) {
|
||||
if (parameter.value.propertyType == SerializedPropertyType.Vector2) {
|
||||
var o = parameter.GetObjectRef<Beautify.MinMaxFloatParameter>();
|
||||
var range = o.value;
|
||||
float x = range.x;
|
||||
float y = range.y;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.MinMaxSlider(title, ref x, ref y, o.min, o.max);
|
||||
x = EditorGUILayout.FloatField(x, GUILayout.Width(40));
|
||||
y = EditorGUILayout.FloatField(y, GUILayout.Width(40));
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
range.x = x;
|
||||
range.y = y;
|
||||
o.SetValue(new Beautify.MinMaxFloatParameter(range, o.min, o.max));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
EditorGUILayout.PropertyField(parameter.value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D MakeTex (int width, int height, Color col) {
|
||||
Color[] pix = new Color[width * height];
|
||||
|
||||
for (int i = 0; i < pix.Length; i++)
|
||||
pix[i] = col;
|
||||
|
||||
TextureFormat tf = SystemInfo.SupportsTextureFormat(TextureFormat.RGBAFloat) ? TextureFormat.RGBAFloat : TextureFormat.RGBA32;
|
||||
Texture2D result = new Texture2D(width, height, tf, false);
|
||||
result.hideFlags = HideFlags.DontSave;
|
||||
result.SetPixels(pix);
|
||||
result.Apply();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SelectActiveURPRendererAsset () {
|
||||
var urpAsset = UniversalRenderPipeline.asset;
|
||||
if (urpAsset != null && urpAsset.scriptableRenderer is UniversalRenderer urpRenderer) {
|
||||
var rendererDataField = typeof(UniversalRenderPipelineAsset).GetField("m_RendererDataList", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var rendererDataList = rendererDataField?.GetValue(urpAsset) as ScriptableRendererData[];
|
||||
if (rendererDataList?.Length > 0) {
|
||||
Selection.activeObject = rendererDataList[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f254be33cd84f4341a7ea1deab7213b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Beautify.Universal {
|
||||
|
||||
class BeautifyOptCompiler : IPreprocessShaders {
|
||||
|
||||
public const string PLAYER_PREF_KEYNAME = "BeautifyStripKeywordSet";
|
||||
|
||||
public int callbackOrder => 1;
|
||||
|
||||
public void OnProcessShader(
|
||||
Shader shader, ShaderSnippetData snippet, IList<ShaderCompilerData> shaderCompilerData) {
|
||||
|
||||
try {
|
||||
if (shaderCompilerData == null) return;
|
||||
|
||||
if (!"Hidden/Universal Render Pipeline/UberPost".Equals(shader.name) && !"Hidden/Kronnect/Beautify".Equals(shader.name)) return;
|
||||
|
||||
string strippedKeywords = PlayerPrefs.GetString(PLAYER_PREF_KEYNAME);
|
||||
if (string.IsNullOrEmpty(strippedKeywords)) return;
|
||||
|
||||
for (int k = shaderCompilerData.Count - 1; k >= 0; k--) {
|
||||
ShaderCompilerData data = shaderCompilerData[k];
|
||||
ShaderKeyword[] keywords = data.shaderKeywordSet.GetShaderKeywords();
|
||||
for (int s = 0; s < keywords.Length; s++) {
|
||||
ShaderKeyword keyword = keywords[s];
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
string keywordName = keyword.name;
|
||||
#else
|
||||
string keywordName;
|
||||
if (ShaderKeyword.IsKeywordLocal(keyword)) {
|
||||
keywordName = ShaderKeyword.GetKeywordName(shader, keyword);
|
||||
} else {
|
||||
keywordName = ShaderKeyword.GetGlobalKeywordName(keyword);
|
||||
}
|
||||
#endif
|
||||
if (keywordName.Length > 0 && strippedKeywords.Contains(keywordName)) {
|
||||
shaderCompilerData.RemoveAt(k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch { }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e44552cb4a254ddd9e75bd9d95f0a0a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Beautify.Universal {
|
||||
|
||||
[CustomEditor(typeof(BeautifyRendererFeature))]
|
||||
public class BeautifyRenderFeatureEditor : Editor {
|
||||
|
||||
SerializedProperty renderPassEvent, ignorePostProcessingOption;
|
||||
#if ENABLE_VR && ENABLE_XR_MODULE
|
||||
SerializedProperty clearXRColorBuffer;
|
||||
#endif
|
||||
SerializedProperty cameraLayerMask;
|
||||
SerializedProperty stripSettings;
|
||||
|
||||
Editor internalStripSettingsEditor;
|
||||
|
||||
void OnEnable () {
|
||||
renderPassEvent = serializedObject.FindProperty("renderPassEvent");
|
||||
ignorePostProcessingOption = serializedObject.FindProperty("ignorePostProcessingOption");
|
||||
#if ENABLE_VR && ENABLE_XR_MODULE
|
||||
clearXRColorBuffer = serializedObject.FindProperty("clearXRColorBuffer");
|
||||
#endif
|
||||
cameraLayerMask = serializedObject.FindProperty("cameraLayerMask");
|
||||
stripSettings = serializedObject.FindProperty("stripSettings");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(renderPassEvent);
|
||||
EditorGUILayout.PropertyField(ignorePostProcessingOption);
|
||||
#if ENABLE_VR && ENABLE_XR_MODULE
|
||||
EditorGUILayout.PropertyField(clearXRColorBuffer);
|
||||
#endif
|
||||
EditorGUILayout.PropertyField(cameraLayerMask);
|
||||
|
||||
BeautifyRendererFeature feature = (BeautifyRendererFeature)target;
|
||||
if (stripSettings.objectReferenceValue == null) {
|
||||
feature.UpdateInternalStripSettings();
|
||||
}
|
||||
BeautifyStripSettings currentSettings = feature.settings;
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Beautify Shader Features Stripping", EditorStyles.boldLabel);
|
||||
EditorGUILayout.HelpBox("Optimize shader compilation time by stripping unused Beautify features. Select the features you wish to exclude from the build.", MessageType.Info);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PropertyField(stripSettings);
|
||||
if (GUILayout.Button("Create Config Asset", GUILayout.Width(150))) {
|
||||
CreateConfigAsset(feature, currentSettings);
|
||||
GUIUtility.ExitGUI();
|
||||
return;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (currentSettings != null) {
|
||||
Editor.CreateCachedEditor(currentSettings, typeof(BeautifyStripSettingsEditor), ref internalStripSettingsEditor);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
internalStripSettingsEditor.OnInspectorGUI();
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
if (stripSettings.objectReferenceValue == null) {
|
||||
Undo.RecordObject(feature, "Change Strip Settings");
|
||||
feature.SyncInternalToLegacy();
|
||||
EditorUtility.SetDirty(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
|
||||
if (GUILayout.Button("Select Beautify Volume >")) {
|
||||
var volumes = Misc.FindObjectsOfType<Volume>();
|
||||
|
||||
foreach (var volume in volumes) {
|
||||
if (volume.sharedProfile != null && volume.sharedProfile.TryGet<Beautify>(out var beautify)) {
|
||||
Selection.activeObject = volume.gameObject;
|
||||
EditorGUIUtility.PingObject(volume.gameObject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
void CreateConfigAsset (BeautifyRendererFeature feature, BeautifyStripSettings source) {
|
||||
string path = EditorUtility.SaveFilePanelInProject("Create Strip Settings", "BeautifyStripSettings", "asset", "Please enter a file name to save the strip settings to");
|
||||
if (string.IsNullOrEmpty(path)) return;
|
||||
|
||||
BeautifyStripSettings newSettings = ScriptableObject.CreateInstance<BeautifyStripSettings>();
|
||||
// Copy values
|
||||
EditorUtility.CopySerialized(source, newSettings);
|
||||
|
||||
AssetDatabase.CreateAsset(newSettings, path);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
feature.stripSettings = newSettings;
|
||||
EditorUtility.SetDirty(feature);
|
||||
serializedObject.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f7286e18c946445284b04f79b720134
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,129 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Beautify.Universal {
|
||||
|
||||
[CustomEditor(typeof(BeautifySettings))]
|
||||
public class BeautifySettingsEditor : Editor {
|
||||
|
||||
SerializedProperty sun;
|
||||
SerializedProperty depthOfFieldTarget;
|
||||
SerializedProperty depthOfFieldFocusPositionEnabled;
|
||||
SerializedProperty depthOfFieldFocusPosition;
|
||||
|
||||
static GUIStyle sectionHeaderStyle;
|
||||
static GUIStyle boxStyle;
|
||||
static bool sunFoldout = true;
|
||||
static bool dofFoldout = true;
|
||||
|
||||
void OnEnable() {
|
||||
sun = serializedObject.FindProperty("sun");
|
||||
depthOfFieldTarget = serializedObject.FindProperty("depthOfFieldTarget");
|
||||
depthOfFieldFocusPositionEnabled = serializedObject.FindProperty("depthOfFieldFocusPositionEnabled");
|
||||
depthOfFieldFocusPosition = serializedObject.FindProperty("depthOfFieldFocusPosition");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
|
||||
SetupStyles();
|
||||
|
||||
// Header
|
||||
EditorGUILayout.Space(5);
|
||||
EditorGUILayout.LabelField("Beautify Scene Settings", EditorStyles.boldLabel);
|
||||
EditorGUILayout.HelpBox("Configure scene-specific settings for Beautify effects. These settings override or complement the Volume profile settings.", MessageType.Info);
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
// Sun Section
|
||||
sunFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(sunFoldout, "Sun & Lighting");
|
||||
if (sunFoldout) {
|
||||
EditorGUILayout.BeginVertical(boxStyle);
|
||||
EditorGUILayout.PropertyField(sun, new GUIContent("Sun Transform", "The directional light used for sun flares and other lighting effects"));
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
// Depth of Field Section
|
||||
dofFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(dofFoldout, "Depth of Field");
|
||||
if (dofFoldout) {
|
||||
EditorGUILayout.BeginVertical(boxStyle);
|
||||
|
||||
// Target Transform
|
||||
EditorGUILayout.LabelField("Follow Target Mode", EditorStyles.miniBoldLabel);
|
||||
EditorGUILayout.PropertyField(depthOfFieldTarget, new GUIContent("Target", "Transform to focus on when using Follow Target focus mode. Sets the focal plane distance; foreground and background blur are computed relative to this distance."));
|
||||
|
||||
EditorGUILayout.Space(8);
|
||||
|
||||
// Focus Position
|
||||
EditorGUILayout.LabelField("Follow Position Mode", EditorStyles.miniBoldLabel);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PropertyField(depthOfFieldFocusPositionEnabled, new GUIContent("Override Focus Position", "Enable to use this position instead of the Volume's Focus Position setting"));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!depthOfFieldFocusPositionEnabled.boolValue);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(depthOfFieldFocusPosition, new GUIContent("Focus Position", "World position to focus on when using FollowPosition focus mode"));
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
// Utility buttons
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Select Beautify Volume")) {
|
||||
SelectBeautifyVolume();
|
||||
}
|
||||
if (GUILayout.Button("Reset to Defaults")) {
|
||||
ResetToDefaults();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
void SetupStyles() {
|
||||
if (sectionHeaderStyle == null) {
|
||||
sectionHeaderStyle = new GUIStyle(EditorStyles.foldoutHeader) {
|
||||
fontStyle = FontStyle.Bold,
|
||||
fontSize = 12
|
||||
};
|
||||
}
|
||||
|
||||
if (boxStyle == null) {
|
||||
boxStyle = new GUIStyle("box") {
|
||||
padding = new RectOffset(10, 10, 10, 10),
|
||||
margin = new RectOffset(0, 0, 5, 5)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void SelectBeautifyVolume() {
|
||||
var volumes = Misc.FindObjectsOfType<UnityEngine.Rendering.Volume>();
|
||||
foreach (var volume in volumes) {
|
||||
if (volume.sharedProfile != null && volume.sharedProfile.TryGet<Beautify>(out var beautify)) {
|
||||
Selection.activeObject = volume.gameObject;
|
||||
EditorGUIUtility.PingObject(volume.gameObject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResetToDefaults() {
|
||||
Undo.RecordObject(target, "Reset Beautify Settings");
|
||||
BeautifySettings settings = (BeautifySettings)target;
|
||||
settings.sun = null;
|
||||
settings.depthOfFieldTarget = null;
|
||||
settings.depthOfFieldFocusPositionEnabled = false;
|
||||
settings.depthOfFieldFocusPosition = Vector3.zero;
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 481931e89af9a499a839a88210a6bd5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,249 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Beautify.Universal {
|
||||
|
||||
[CustomEditor(typeof(BeautifyStripSettings))]
|
||||
public class BeautifyStripSettingsEditor : Editor {
|
||||
|
||||
SerializedProperty stripBeautifyTonemappingACES, stripBeautifyTonemappingACESFitted, stripBeautifyTonemappingAGX;
|
||||
SerializedProperty stripBeautifySharpen, stripBeautifySharpenExclusionMask;
|
||||
SerializedProperty stripBeautifyDithering, stripBeautifyEdgeAA;
|
||||
SerializedProperty stripBeautifyLUT, stripBeautifyLUT3D, stripBeautifyColorTweaks;
|
||||
SerializedProperty stripBeautifyBloom, stripBeautifyLensDirt, stripBeautifyChromaticAberration;
|
||||
SerializedProperty stripBeautifyDoF, stripBeautifyDoFTransparentSupport;
|
||||
SerializedProperty stripBeautifyEyeAdaptation, stripBeautifyPurkinje;
|
||||
SerializedProperty stripBeautifyVignetting, stripBeautifyVignettingMask;
|
||||
SerializedProperty stripBeautifyOutline;
|
||||
SerializedProperty stripBeautifyNightVision, stripBeautifyThermalVision;
|
||||
SerializedProperty stripBeautifyFrame;
|
||||
SerializedProperty stripBeautifyFilmGrain;
|
||||
SerializedProperty stripUnityFilmGrain, stripUnityDithering, stripUnityTonemapping;
|
||||
SerializedProperty stripUnityBloom, stripUnityChromaticAberration;
|
||||
SerializedProperty stripUnityDistortion, stripUnityDebugVariants;
|
||||
|
||||
void OnEnable() {
|
||||
try {
|
||||
stripBeautifyTonemappingACES = serializedObject.FindProperty("stripBeautifyTonemappingACES");
|
||||
stripBeautifyTonemappingACESFitted = serializedObject.FindProperty("stripBeautifyTonemappingACESFitted");
|
||||
stripBeautifyTonemappingAGX = serializedObject.FindProperty("stripBeautifyTonemappingAGX");
|
||||
stripBeautifySharpen = serializedObject.FindProperty("stripBeautifySharpen");
|
||||
stripBeautifySharpenExclusionMask = serializedObject.FindProperty("stripBeautifySharpenExclusionMask");
|
||||
stripBeautifyDithering = serializedObject.FindProperty("stripBeautifyDithering");
|
||||
stripBeautifyEdgeAA = serializedObject.FindProperty("stripBeautifyEdgeAA");
|
||||
stripBeautifyLUT = serializedObject.FindProperty("stripBeautifyLUT");
|
||||
stripBeautifyLUT3D = serializedObject.FindProperty("stripBeautifyLUT3D");
|
||||
stripBeautifyColorTweaks = serializedObject.FindProperty("stripBeautifyColorTweaks");
|
||||
stripBeautifyBloom = serializedObject.FindProperty("stripBeautifyBloom");
|
||||
stripBeautifyLensDirt = serializedObject.FindProperty("stripBeautifyLensDirt");
|
||||
stripBeautifyChromaticAberration = serializedObject.FindProperty("stripBeautifyChromaticAberration");
|
||||
stripBeautifyDoF = serializedObject.FindProperty("stripBeautifyDoF");
|
||||
stripBeautifyDoFTransparentSupport = serializedObject.FindProperty("stripBeautifyDoFTransparentSupport");
|
||||
stripBeautifyEyeAdaptation = serializedObject.FindProperty("stripBeautifyEyeAdaptation");
|
||||
stripBeautifyPurkinje = serializedObject.FindProperty("stripBeautifyPurkinje");
|
||||
stripBeautifyVignetting = serializedObject.FindProperty("stripBeautifyVignetting");
|
||||
stripBeautifyVignettingMask = serializedObject.FindProperty("stripBeautifyVignettingMask");
|
||||
stripBeautifyOutline = serializedObject.FindProperty("stripBeautifyOutline");
|
||||
stripBeautifyNightVision = serializedObject.FindProperty("stripBeautifyNightVision");
|
||||
stripBeautifyThermalVision = serializedObject.FindProperty("stripBeautifyThermalVision");
|
||||
stripBeautifyFrame = serializedObject.FindProperty("stripBeautifyFrame");
|
||||
stripBeautifyFilmGrain = serializedObject.FindProperty("stripBeautifyFilmGrain");
|
||||
stripUnityFilmGrain = serializedObject.FindProperty("stripUnityFilmGrain");
|
||||
stripUnityDithering = serializedObject.FindProperty("stripUnityDithering");
|
||||
stripUnityTonemapping = serializedObject.FindProperty("stripUnityTonemapping");
|
||||
stripUnityBloom = serializedObject.FindProperty("stripUnityBloom");
|
||||
stripUnityChromaticAberration = serializedObject.FindProperty("stripUnityChromaticAberration");
|
||||
stripUnityDistortion = serializedObject.FindProperty("stripUnityDistortion");
|
||||
stripUnityDebugVariants = serializedObject.FindProperty("stripUnityDebugVariants");
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
void DrawStripToggle(SerializedProperty property, string label) {
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
property.boolValue = GUILayout.Toggle(property.boolValue, "", GUILayout.Width(20));
|
||||
GUILayout.Label(label);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Autoselect Unused Beautify Features", EditorStyles.miniButton)) {
|
||||
if (EditorUtility.DisplayDialog("Autoselect Unused Beautify Features", "This will disable features not used in the current scene. Do you want to proceed?", "Yes", "No")) {
|
||||
|
||||
var beautifyVolumes = Misc.FindObjectsOfType<Beautify>();
|
||||
|
||||
bool isFeatureUsed(System.Func<Beautify, bool> predicate) {
|
||||
foreach (var volume in beautifyVolumes) {
|
||||
if (predicate(volume)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
stripBeautifySharpen.boolValue = !isFeatureUsed(b => b.sharpenIntensity.value > 0f);
|
||||
stripBeautifySharpenExclusionMask.boolValue = !isFeatureUsed(b => b.sharpenIntensity.value > 0f && b.sharpenExclusionLayerMask.value != 0);
|
||||
stripBeautifyDithering.boolValue = !isFeatureUsed(b => b.ditherIntensity.value > 0f);
|
||||
stripBeautifyEdgeAA.boolValue = !isFeatureUsed(b => b.antialiasStrength.value > 0f);
|
||||
stripBeautifyTonemappingACES.boolValue = !isFeatureUsed(b => b.tonemap.value == Beautify.TonemapOperator.ACES);
|
||||
stripBeautifyTonemappingACESFitted.boolValue = !isFeatureUsed(b => b.tonemap.value == Beautify.TonemapOperator.ACESFitted);
|
||||
stripBeautifyTonemappingAGX.boolValue = !isFeatureUsed(b => b.tonemap.value == Beautify.TonemapOperator.AGX);
|
||||
stripBeautifyLUT.boolValue = !isFeatureUsed(b => b.lut.value && b.lutIntensity.value > 0 && b.lutTexture.value != null && !(b.lutTexture.value is Texture3D));
|
||||
stripBeautifyLUT3D.boolValue = !isFeatureUsed(b => b.lut.value && b.lutIntensity.value > 0 && b.lutTexture.value is Texture3D);
|
||||
stripBeautifyColorTweaks.boolValue = !isFeatureUsed(b => b.sepia.value > 0 || b.daltonize.value > 0 || b.colorTempBlend.value > 0);
|
||||
stripBeautifyBloom.boolValue = !isFeatureUsed(b => b.bloomIntensity.value > 0f);
|
||||
stripBeautifyLensDirt.boolValue = !isFeatureUsed(b => b.lensDirtIntensity.value > 0);
|
||||
stripBeautifyChromaticAberration.boolValue = !isFeatureUsed(b => b.chromaticAberrationIntensity.value > 0f);
|
||||
stripBeautifyDoF.boolValue = !isFeatureUsed(b => b.depthOfField.value);
|
||||
stripBeautifyDoFTransparentSupport.boolValue = !isFeatureUsed(b => b.depthOfFieldTransparentSupport.value);
|
||||
stripBeautifyEyeAdaptation.boolValue = !isFeatureUsed(b => b.eyeAdaptation.value);
|
||||
stripBeautifyPurkinje.boolValue = !isFeatureUsed(b => b.purkinje.value);
|
||||
stripBeautifyVignetting.boolValue = !isFeatureUsed(b => b.vignettingOuterRing.value > 0f);
|
||||
stripBeautifyVignettingMask.boolValue = !isFeatureUsed(b => b.vignettingOuterRing.value > 0f && b.vignettingMask.value != null);
|
||||
stripBeautifyOutline.boolValue = !isFeatureUsed(b => b.outline.value);
|
||||
stripBeautifyNightVision.boolValue = !isFeatureUsed(b => b.nightVision.value);
|
||||
stripBeautifyThermalVision.boolValue = !isFeatureUsed(b => b.thermalVision.value);
|
||||
stripBeautifyFrame.boolValue = !isFeatureUsed(b => b.frame.value);
|
||||
stripBeautifyFilmGrain.boolValue = !isFeatureUsed(b => b.filmGrainEnabled.value && (b.filmGrainIntensity.value > 0f || b.filmGrainDirtSpotsAmount.value > 0f || b.filmGrainScratchesAmount.value > 0f));
|
||||
}
|
||||
}
|
||||
|
||||
// Image Enhancement section
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Image Enhancement", EditorStyles.boldLabel);
|
||||
if (GUILayout.Button("Toggle All", EditorStyles.miniButton, GUILayout.Width(80))) {
|
||||
bool allStripped = stripBeautifySharpen.boolValue &&
|
||||
stripBeautifySharpenExclusionMask.boolValue &&
|
||||
stripBeautifyDithering.boolValue &&
|
||||
stripBeautifyEdgeAA.boolValue;
|
||||
stripBeautifySharpen.boolValue = !allStripped;
|
||||
stripBeautifySharpenExclusionMask.boolValue = !allStripped;
|
||||
stripBeautifyDithering.boolValue = !allStripped;
|
||||
stripBeautifyEdgeAA.boolValue = !allStripped;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
DrawStripToggle(stripBeautifySharpen, "Strip Sharpen");
|
||||
DrawStripToggle(stripBeautifySharpenExclusionMask, "Strip Sharpen Exclusion Mask");
|
||||
DrawStripToggle(stripBeautifyDithering, "Strip Dithering");
|
||||
DrawStripToggle(stripBeautifyEdgeAA, "Strip Edge AA");
|
||||
|
||||
// Tonemapping section
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Tonemapping", EditorStyles.boldLabel);
|
||||
if (GUILayout.Button("Toggle All", EditorStyles.miniButton, GUILayout.Width(80))) {
|
||||
bool allStripped = stripBeautifyTonemappingACES.boolValue &&
|
||||
stripBeautifyTonemappingACESFitted.boolValue &&
|
||||
stripBeautifyTonemappingAGX.boolValue;
|
||||
stripBeautifyTonemappingACES.boolValue = !allStripped;
|
||||
stripBeautifyTonemappingACESFitted.boolValue = !allStripped;
|
||||
stripBeautifyTonemappingAGX.boolValue = !allStripped;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
DrawStripToggle(stripBeautifyTonemappingACES, "Strip ACES Tonemapping");
|
||||
DrawStripToggle(stripBeautifyTonemappingACESFitted, "Strip ACES Fitted Tonemapping");
|
||||
DrawStripToggle(stripBeautifyTonemappingAGX, "Strip AGX Tonemapping");
|
||||
|
||||
// Color Grading section
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Color Grading", EditorStyles.boldLabel);
|
||||
if (GUILayout.Button("Toggle All", EditorStyles.miniButton, GUILayout.Width(80))) {
|
||||
bool allStripped = stripBeautifyLUT.boolValue &&
|
||||
stripBeautifyLUT3D.boolValue &&
|
||||
stripBeautifyColorTweaks.boolValue;
|
||||
stripBeautifyLUT.boolValue = !allStripped;
|
||||
stripBeautifyLUT3D.boolValue = !allStripped;
|
||||
stripBeautifyColorTweaks.boolValue = !allStripped;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
DrawStripToggle(stripBeautifyLUT, "Strip LUT");
|
||||
DrawStripToggle(stripBeautifyLUT3D, "Strip LUT 3D");
|
||||
DrawStripToggle(stripBeautifyColorTweaks, new GUIContent("Strip Color Tweaks", "Refers to sepia, daltonize and color temperature").text);
|
||||
|
||||
// Effects section
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Effects", EditorStyles.boldLabel);
|
||||
if (GUILayout.Button("Toggle All", EditorStyles.miniButton, GUILayout.Width(80))) {
|
||||
bool allStripped = stripBeautifyBloom.boolValue &&
|
||||
stripBeautifyLensDirt.boolValue &&
|
||||
stripBeautifyChromaticAberration.boolValue &&
|
||||
stripBeautifyDoF.boolValue &&
|
||||
stripBeautifyDoFTransparentSupport.boolValue &&
|
||||
stripBeautifyEyeAdaptation.boolValue &&
|
||||
stripBeautifyPurkinje.boolValue &&
|
||||
stripBeautifyVignetting.boolValue &&
|
||||
stripBeautifyVignettingMask.boolValue &&
|
||||
stripBeautifyOutline.boolValue &&
|
||||
stripBeautifyNightVision.boolValue &&
|
||||
stripBeautifyThermalVision.boolValue &&
|
||||
stripBeautifyFrame.boolValue &&
|
||||
stripBeautifyFilmGrain.boolValue;
|
||||
stripBeautifyBloom.boolValue = !allStripped;
|
||||
stripBeautifyLensDirt.boolValue = !allStripped;
|
||||
stripBeautifyChromaticAberration.boolValue = !allStripped;
|
||||
stripBeautifyDoF.boolValue = !allStripped;
|
||||
stripBeautifyDoFTransparentSupport.boolValue = !allStripped;
|
||||
stripBeautifyEyeAdaptation.boolValue = !allStripped;
|
||||
stripBeautifyPurkinje.boolValue = !allStripped;
|
||||
stripBeautifyVignetting.boolValue = !allStripped;
|
||||
stripBeautifyVignettingMask.boolValue = !allStripped;
|
||||
stripBeautifyOutline.boolValue = !allStripped;
|
||||
stripBeautifyNightVision.boolValue = !allStripped;
|
||||
stripBeautifyThermalVision.boolValue = !allStripped;
|
||||
stripBeautifyFrame.boolValue = !allStripped;
|
||||
stripBeautifyFilmGrain.boolValue = !allStripped;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
DrawStripToggle(stripBeautifyBloom, "Strip Bloom, Anamorphic & Sun Flares");
|
||||
DrawStripToggle(stripBeautifyLensDirt, "Strip Lens Dirt");
|
||||
DrawStripToggle(stripBeautifyChromaticAberration, "Strip Chromatic Aberration");
|
||||
DrawStripToggle(stripBeautifyDoF, "Strip Depth of Field");
|
||||
DrawStripToggle(stripBeautifyDoFTransparentSupport, "Strip DoF Transparent Support");
|
||||
DrawStripToggle(stripBeautifyEyeAdaptation, "Strip Eye Adaptation");
|
||||
DrawStripToggle(stripBeautifyPurkinje, "Strip Purkinje");
|
||||
DrawStripToggle(stripBeautifyVignetting, "Strip Vignetting");
|
||||
DrawStripToggle(stripBeautifyVignettingMask, "Strip Vignetting Mask");
|
||||
DrawStripToggle(stripBeautifyOutline, "Strip Outline");
|
||||
DrawStripToggle(stripBeautifyNightVision, "Strip Night Vision");
|
||||
DrawStripToggle(stripBeautifyThermalVision, "Strip Thermal Vision");
|
||||
DrawStripToggle(stripBeautifyFrame, "Strip Frame");
|
||||
DrawStripToggle(stripBeautifyFilmGrain, "Strip Film Grain");
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
// Unity Post Processing section
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Unity Post Processing Stripping", EditorStyles.boldLabel);
|
||||
if (GUILayout.Button("Toggle All", EditorStyles.miniButton, GUILayout.Width(80))) {
|
||||
bool allStripped = stripUnityFilmGrain.boolValue &&
|
||||
stripUnityDithering.boolValue &&
|
||||
stripUnityTonemapping.boolValue &&
|
||||
stripUnityBloom.boolValue &&
|
||||
stripUnityChromaticAberration.boolValue &&
|
||||
stripUnityDistortion.boolValue &&
|
||||
stripUnityDebugVariants.boolValue;
|
||||
stripUnityFilmGrain.boolValue = !allStripped;
|
||||
stripUnityDithering.boolValue = !allStripped;
|
||||
stripUnityTonemapping.boolValue = !allStripped;
|
||||
stripUnityBloom.boolValue = !allStripped;
|
||||
stripUnityChromaticAberration.boolValue = !allStripped;
|
||||
stripUnityDistortion.boolValue = !allStripped;
|
||||
stripUnityDebugVariants.boolValue = !allStripped;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
DrawStripToggle(stripUnityFilmGrain, "Strip Film Grain");
|
||||
DrawStripToggle(stripUnityDithering, "Strip Dithering");
|
||||
DrawStripToggle(stripUnityTonemapping, "Strip Tonemapping");
|
||||
DrawStripToggle(stripUnityBloom, "Strip Bloom");
|
||||
DrawStripToggle(stripUnityChromaticAberration, "Strip Chromatic Aberration");
|
||||
DrawStripToggle(stripUnityDistortion, "Strip Distortion");
|
||||
DrawStripToggle(stripUnityDebugVariants, "Strip Debug Variants");
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties()) {
|
||||
BeautifyRendererFeature.StripBeautifyFeatures();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cbc8d2d8ee56446389e96b61118a5dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,212 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Beautify.Universal {
|
||||
|
||||
public class ContactUsWindow : EditorWindow {
|
||||
const string OnlineGuidesUrl = "https://kronnect.com/guides";
|
||||
const string SupportUrl = "https://kronnect.com/support";
|
||||
const string YoutubeUrl = "https://youtube.com/@kronnect";
|
||||
const string TwitterUrl = "https://twitter.com/kronnect";
|
||||
const string KronnectUrl = "https://assetstore.unity.com/publishers/15018?aid=1101lGsd";
|
||||
const string ReferralInfo = "?aid=1101lGsd&pubref=beautify";
|
||||
Texture2D kronnectLogo, welcomeBanner;
|
||||
GUIStyle headerStyle, bannerStyle;
|
||||
|
||||
readonly List<AssetCategory> assetCategories = new List<AssetCategory>
|
||||
{
|
||||
new AssetCategory
|
||||
{
|
||||
name = "Image Effects",
|
||||
assets = new List<Asset>
|
||||
{
|
||||
new Asset { name = "Beautify 3 - Advanced Post Processing", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/beautify-3-advanced-post-processing-233073" },
|
||||
new Asset { name = "Frame Pack for Beautify", url = "https://assetstore.unity.com/packages/2d/gui/frame-pack-204058" },
|
||||
new Asset { name = "LUT Pack for Beautify", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/lut-pack-for-beautify-202502" },
|
||||
new Asset { name = "Beautify HDRP", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/beautify-hdrp-165411" },
|
||||
new Asset { name = "Cloud Shadows FX", url = "https://assetstore.unity.com/packages/vfx/shaders/cloud-shadows-fx-267702" },
|
||||
new Asset { name = "Dynamic Fog & Mist 2", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/dynamic-fog-mist-2-48200" },
|
||||
new Asset { name = "Edge Fusion", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/edge-fusion-smooth-surface-contacts-334484" },
|
||||
new Asset { name = "Global Snow 2", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/global-snow-2-248191" },
|
||||
new Asset { name = "Luma Based Ambient Occlusion (SSAO 2D)", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/luma-based-ambient-occlusion-2-ssao-2d-249066" },
|
||||
new Asset { name = "Radiant Global Illumination", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/radiant-global-illumination-225934" },
|
||||
new Asset { name = "Shiny SSR 2", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/shiny-ssr-2-screen-space-reflections-188638" },
|
||||
new Asset { name = "Sun Flares HDRP", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/sun-flares-hdrp-171177" },
|
||||
new Asset { name = "Umbra Soft Shadows", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/umbra-soft-shadows-better-directional-contact-shadows-for-urp-282485" },
|
||||
new Asset { name = "Volumetric Fog & Mist 2", url = "https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/volumetric-fog-mist-2-162694" },
|
||||
new Asset { name = "Volumetric Lights 2", url = "https://assetstore.unity.com/packages/vfx/shaders/volumetric-lights-2-234539" },
|
||||
new Asset { name = "Volumetric Lights Set", url = "https://assetstore.unity.com/packages/3d/props/volumetric-lights-set-237873" },
|
||||
new Asset { name = "Volumetric Lights 2 HDRP", url = "https://assetstore.unity.com/packages/vfx/shaders/volumetric-lights-2-hdrp-243807" },
|
||||
}
|
||||
},
|
||||
new AssetCategory
|
||||
{
|
||||
name = "Tools & Shaders",
|
||||
assets = new List<Asset>
|
||||
{
|
||||
new Asset { name = "Compass Navigator Pro 2", url = "https://assetstore.unity.com/packages/tools/gui/compass-navigator-pro-2-273662" },
|
||||
new Asset { name = "Highlight Plus", url = "https://assetstore.unity.com/packages/vfx/shaders/highlight-plus-all-in-one-outline-selection-effects-134149" },
|
||||
new Asset { name = "Highlight Plus 2D", url = "https://assetstore.unity.com/packages/vfx/shaders/highlight-plus-2d-138383" },
|
||||
new Asset { name = "Liquid Volume 2", url = "https://assetstore.unity.com/packages/vfx/shaders/liquid-volume-2-249127" },
|
||||
new Asset { name = "Liquid Volume Pro 2", url = "https://assetstore.unity.com/packages/vfx/shaders/liquid-volume-pro-2-129967" },
|
||||
new Asset { name = "Liquid Volume Pro 2 HDRP", url = "https://assetstore.unity.com/packages/vfx/shaders/liquid-volume-pro-2-hdrp-253786" },
|
||||
new Asset { name = "Potions & Volumetric Liquid", url = "https://assetstore.unity.com/packages/slug/123474" },
|
||||
new Asset { name = "Shader Control", url = "https://assetstore.unity.com/packages/vfx/shaders/shader-control-74817" },
|
||||
new Asset { name = "Split Screen Pro", url = "https://assetstore.unity.com/packages/tools/camera/split-screen-pro-207149" },
|
||||
new Asset { name = "Skybox Plus", url = "https://assetstore.unity.com/packages/2d/environments/skybox-plus-182966" },
|
||||
new Asset { name = "Trails FX", url = "https://assetstore.unity.com/packages/vfx/shaders/trails-fx-146898" },
|
||||
new Asset { name = "Transitions Plus", url = "https://assetstore.unity.com/packages/tools/camera/transitions-plus-266067" },
|
||||
new Asset { name = "Tunnel FX 2", url = "https://assetstore.unity.com/packages/vfx/shaders/tunnel-fx-2-86544" },
|
||||
new Asset { name = "Voxel Play 3", url = "https://assetstore.unity.com/packages/tools/game-toolkits/voxel-play-3-310775" },
|
||||
new Asset { name = "Pirates of Voxel Play", url = "https://assetstore.unity.com/packages/tools/game-toolkits/pirates-of-voxel-play-189096" },
|
||||
new Asset { name = "X-Frame FPS Accelerator", url = "https://assetstore.unity.com/packages/tools/camera/x-frame-fps-accelerator-63965" }
|
||||
}
|
||||
},
|
||||
new AssetCategory
|
||||
{
|
||||
name = "Grids & Maps",
|
||||
assets = new List<Asset>
|
||||
{
|
||||
new Asset { name = "Grids 2D", url = "https://assetstore.unity.com/packages/tools/game-toolkits/grids-2d-59981" },
|
||||
new Asset { name = "Hexasphere Grid System", url = "https://assetstore.unity.com/packages/tools/modeling/hexasphere-grid-system-89112" },
|
||||
new Asset { name = "Terrain Grid System 2", url = "https://assetstore.unity.com/packages/tools/terrain/terrain-grid-system-2-244921" },
|
||||
new Asset { name = "World Map 2D Edition 2", url = "https://assetstore.unity.com/packages/tools/gui/world-map-2d-edition-2-151238" },
|
||||
new Asset { name = "World Map Globe Edition 2", url = "https://assetstore.unity.com/packages/tools/gui/world-map-globe-edition-2-150643" },
|
||||
new Asset { name = "World Map Strategy Kit 2", url = "https://assetstore.unity.com/packages/tools/game-toolkits/world-map-strategy-kit-2-150938" },
|
||||
new Asset { name = "World Maps & Weather Symbols", url = "https://assetstore.unity.com/packages/2d/textures-materials/world-flags-and-weather-symbols-69010" },
|
||||
new Asset { name = "Military Units 2D", url = "https://assetstore.unity.com/packages/2d/textures-materials/military-units-the-stylized-art-collection-187769" },
|
||||
new Asset { name = "Military Units 3D", url = "https://assetstore.unity.com/packages/3d/vehicles/military-units-3d-246876" },
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void OnEnable () {
|
||||
kronnectLogo = Resources.Load<Texture2D>("kronnectLogo");
|
||||
welcomeBanner = Resources.Load<Texture2D>("welcomeBanner");
|
||||
}
|
||||
|
||||
void DrawHeader (string title) {
|
||||
if (headerStyle == null) {
|
||||
GUIStyle skurikenModuleTitleStyle = "ShurikenModuleTitle";
|
||||
headerStyle = new GUIStyle(skurikenModuleTitleStyle) {
|
||||
contentOffset = new Vector2(5f, -2f),
|
||||
normal = { textColor = Color.white },
|
||||
fixedHeight = 24,
|
||||
fontSize = 13
|
||||
};
|
||||
}
|
||||
|
||||
GUILayout.Label(title, headerStyle);
|
||||
}
|
||||
|
||||
void OnGUI () {
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(10);
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Space(10);
|
||||
|
||||
DrawHeader("Online Resources");
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(10);
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
if (GUILayout.Button("Asset Documentation", EditorStyles.linkLabel)) {
|
||||
Application.OpenURL(OnlineGuidesUrl);
|
||||
}
|
||||
if (GUILayout.Button("Support & Community", EditorStyles.linkLabel)) {
|
||||
Application.OpenURL(SupportUrl);
|
||||
}
|
||||
if (GUILayout.Button("YouTube Channel", EditorStyles.linkLabel)) {
|
||||
Application.OpenURL(YoutubeUrl);
|
||||
}
|
||||
if (GUILayout.Button("X / Twitter", EditorStyles.linkLabel)) {
|
||||
Application.OpenURL(TwitterUrl);
|
||||
}
|
||||
if (GUILayout.Button("Kronnect Asset Store", EditorStyles.linkLabel)) {
|
||||
Application.OpenURL(KronnectUrl);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (bannerStyle == null) {
|
||||
bannerStyle = new GUIStyle(GUI.skin.button);
|
||||
bannerStyle.normal.background = welcomeBanner;
|
||||
bannerStyle.normal.scaledBackgrounds = new[] { welcomeBanner };
|
||||
}
|
||||
const float width = 1100 / 2;
|
||||
const float height = 200 / 2;
|
||||
|
||||
if (GUILayout.Button("", bannerStyle, GUILayout.Width(width), GUILayout.Height(height))) {
|
||||
Application.OpenURL(KronnectUrl);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(20);
|
||||
|
||||
DrawHeader("Kronnect Assets");
|
||||
|
||||
GUIStyle textStyle = new GUIStyle(EditorStyles.wordWrappedLabel) {
|
||||
fontSize = 11
|
||||
};
|
||||
GUILayout.Label("Thank you for using this asset!\nWe invite you to explore more assets and complete your collection by visiting the affiliated links below to the Asset Store:", textStyle);
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
foreach (var category in assetCategories) {
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(category.name, EditorStyles.boldLabel);
|
||||
foreach (var asset in category.assets) {
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(10);
|
||||
if (GUILayout.Button(asset.name, EditorStyles.linkLabel)) {
|
||||
Application.OpenURL(asset.url + ReferralInfo);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Close", GUILayout.Width(60))) {
|
||||
Close();
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.Label(new GUIContent(kronnectLogo), GUILayout.Width(100), GUILayout.Height(30));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(10);
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.Space(10);
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
public static void ShowScreen () {
|
||||
ContactUsWindow window = GetWindow<ContactUsWindow>(true, "Online Resources", true);
|
||||
window.minSize = window.maxSize = new Vector2(750, 640);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class AssetCategory {
|
||||
public string name;
|
||||
public List<Asset> assets;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class Asset {
|
||||
public string name;
|
||||
public string url;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1afc11f03842d43bfa05390519730021
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,191 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Beautify.Universal {
|
||||
|
||||
public class CubeLUTImporter : EditorWindow {
|
||||
|
||||
[MenuItem("Window/Kronnect/Beautify/Import CUBE LUT")]
|
||||
public static void ShowBrowser() {
|
||||
string path = EditorUtility.OpenFilePanel("Select .CUBE file", "", "cube");
|
||||
if (string.IsNullOrEmpty(path)) return;
|
||||
Texture tex = Import(path);
|
||||
if (tex != null) {
|
||||
Beautify b = BeautifySettings.sharedSettings;
|
||||
b.lutIntensity.Override(1);
|
||||
b.lutTexture.Override(tex);
|
||||
b.lut.Override(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static Texture3D Import(string path) {
|
||||
|
||||
// Check if path is within assets folder
|
||||
string assetPath = path;
|
||||
int k = path.IndexOf("Assets/");
|
||||
if (k >= 0) {
|
||||
assetPath = assetPath.Substring(k);
|
||||
} else {
|
||||
assetPath = "Assets/Imported CUBE LUTs/" + Path.GetFileName(assetPath);
|
||||
}
|
||||
|
||||
assetPath = Path.Combine(Path.GetDirectoryName(assetPath), Path.GetFileNameWithoutExtension(assetPath));
|
||||
if (!assetPath.ToUpper().EndsWith("_LUT")) {
|
||||
assetPath += "_LUT";
|
||||
}
|
||||
assetPath += ".asset";
|
||||
var tex = AssetDatabase.LoadAssetAtPath<Texture3D>(assetPath);
|
||||
|
||||
if (tex != null) return tex; // safe behaviour: if file exists, do not change anything
|
||||
|
||||
// Read the lut data
|
||||
string[] lines = File.ReadAllLines(path);
|
||||
|
||||
// Start parsing
|
||||
int i = 0;
|
||||
int size = -1;
|
||||
int sizeCube = -1;
|
||||
var table = new List<Color>();
|
||||
var domainMin = Color.black;
|
||||
var domainMax = Color.white;
|
||||
|
||||
while (true) {
|
||||
if (i >= lines.Length) {
|
||||
if (table.Count != sizeCube)
|
||||
Debug.LogError("Premature end of file");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
string line = FilterLine(lines[i]);
|
||||
|
||||
if (string.IsNullOrEmpty(line))
|
||||
goto next;
|
||||
|
||||
// Header data
|
||||
if (line.StartsWith("TITLE"))
|
||||
goto next; // Skip the title tag, we don't need it
|
||||
|
||||
if (line.StartsWith("LUT_3D_SIZE")) {
|
||||
string sizeStr = line.Substring(11).TrimStart();
|
||||
|
||||
if (!int.TryParse(sizeStr, out size)) {
|
||||
Debug.LogError("Invalid data on line " + i);
|
||||
break;
|
||||
}
|
||||
|
||||
if (size < 2 || size > 256) {
|
||||
Debug.LogError("LUT size out of range");
|
||||
break;
|
||||
}
|
||||
|
||||
sizeCube = size * size * size;
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (line.StartsWith("DOMAIN_MIN")) {
|
||||
if (!ParseDomain(i, line, ref domainMin)) break;
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (line.StartsWith("DOMAIN_MAX")) {
|
||||
if (!ParseDomain(i, line, ref domainMax)) break;
|
||||
goto next;
|
||||
}
|
||||
|
||||
// Table
|
||||
string[] row = line.Split();
|
||||
|
||||
if (row.Length != 3) {
|
||||
Debug.LogError("Invalid data on line " + i);
|
||||
break;
|
||||
}
|
||||
|
||||
var color = Color.black;
|
||||
for (int j = 0; j < 3; j++) {
|
||||
float d;
|
||||
if (!float.TryParse(row[j], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out d)) {
|
||||
Debug.LogError("Invalid data on line " + i);
|
||||
break;
|
||||
}
|
||||
|
||||
color[j] = d;
|
||||
}
|
||||
|
||||
table.Add(color);
|
||||
|
||||
next:
|
||||
i++;
|
||||
}
|
||||
|
||||
if (sizeCube != table.Count) {
|
||||
Debug.LogError("Wrong table size - Expected " + sizeCube + " elements, got " + table.Count);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Generate a new Texture3D
|
||||
tex = new Texture3D(size, size, size, TextureFormat.RGBAHalf, false) {
|
||||
anisoLevel = 0,
|
||||
filterMode = FilterMode.Bilinear,
|
||||
wrapMode = TextureWrapMode.Clamp,
|
||||
};
|
||||
|
||||
tex.SetPixels(table.ToArray(), 0);
|
||||
tex.Apply();
|
||||
|
||||
// Save to disk
|
||||
AssetDatabase.CreateAsset(tex, assetPath);
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
tex = AssetDatabase.LoadAssetAtPath<Texture3D>(assetPath);
|
||||
return tex;
|
||||
}
|
||||
|
||||
static string FilterLine(string line) {
|
||||
var filtered = new StringBuilder();
|
||||
line = line.TrimStart().TrimEnd();
|
||||
int len = line.Length;
|
||||
int i = 0;
|
||||
|
||||
while (i < len) {
|
||||
char c = line[i];
|
||||
|
||||
if (c == '#') // Filters comment out
|
||||
break;
|
||||
|
||||
filtered.Append(c);
|
||||
i++;
|
||||
}
|
||||
|
||||
return filtered.ToString();
|
||||
}
|
||||
|
||||
static bool ParseDomain(int i, string line, ref Color domain) {
|
||||
string[] domainStrs = line.Substring(10).TrimStart().Split();
|
||||
|
||||
if (domainStrs.Length != 3) {
|
||||
Debug.LogError("Invalid data on line " + i);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
float d;
|
||||
if (!float.TryParse(domainStrs[j], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out d)) {
|
||||
Debug.LogError("Invalid data on line " + i);
|
||||
return false;
|
||||
}
|
||||
|
||||
domain[j] = d;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 880fcc03372614592baab50db0731b13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,229 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
namespace Beautify.Universal {
|
||||
|
||||
public class FrameBrowser : EditorWindow {
|
||||
|
||||
const string MASTER_FOLDER_NAME = "Frame Pack";
|
||||
|
||||
Material referenceMaterial;
|
||||
Vector2 scrollPos;
|
||||
static int columnCount = 4;
|
||||
|
||||
struct FrameEntry {
|
||||
public Material mat;
|
||||
public Texture2D frameMask;
|
||||
}
|
||||
|
||||
struct FrameGroup {
|
||||
public string categoryPath;
|
||||
public string categoryName;
|
||||
public List<FrameEntry> frames;
|
||||
public bool visible;
|
||||
}
|
||||
FrameGroup[] groups;
|
||||
|
||||
|
||||
[MenuItem("Window/Kronnect/Beautify/Frame Browser")]
|
||||
public static void ShowBrowser() {
|
||||
GetWindow<FrameBrowser>("Frame Browser");
|
||||
}
|
||||
|
||||
static class ShaderParams {
|
||||
public static int frameMaskTexture = Shader.PropertyToID("_FrameMask");
|
||||
public static int lutPreview = Shader.PropertyToID("_LUTPreview");
|
||||
}
|
||||
|
||||
private void OnEnable() {
|
||||
RefreshFrames();
|
||||
ClearBackground();
|
||||
}
|
||||
|
||||
void ClearBackground() {
|
||||
Shader.SetGlobalTexture(ShaderParams.lutPreview, Texture2D.whiteTexture);
|
||||
}
|
||||
|
||||
private void OnGUI() {
|
||||
|
||||
if (groups == null) {
|
||||
EditorGUILayout.HelpBox("Frame Pack not found.", MessageType.Info);
|
||||
if (GUILayout.Button("View Frame Pack on the Unity Asset Store")) {
|
||||
Application.OpenURL("https://assetstore.unity.com/packages/slug/204058");
|
||||
}
|
||||
if (GUILayout.Button("Reload Frame Pack")) {
|
||||
RefreshFrames();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Find Frames")) {
|
||||
RefreshFrames();
|
||||
}
|
||||
if (GUILayout.Button("Capture SceneView")) {
|
||||
RequestCapture(CameraType.SceneView);
|
||||
}
|
||||
if (GUILayout.Button("Capture GameView")) {
|
||||
RequestCapture(CameraType.Game);
|
||||
}
|
||||
if (GUILayout.Button("White Background")) {
|
||||
ClearBackground();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
columnCount = EditorGUILayout.IntSlider("Columns:", columnCount, 1, 5);
|
||||
|
||||
Texture2D wt = Texture2D.whiteTexture;
|
||||
float rowHeight = 0.5f * EditorGUIUtility.currentViewWidth / columnCount;
|
||||
|
||||
EditorGUILayout.HelpBox("Click on the name of a Frame to toggle it on/off.", MessageType.Info);
|
||||
scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
|
||||
Beautify b = BeautifySettings.sharedSettings;
|
||||
if (b == null) {
|
||||
EditorGUILayout.HelpBox("Beautify not found in the scene.", MessageType.Warning);
|
||||
} else {
|
||||
for (int k = 0; k < groups.Length; k++) {
|
||||
groups[k].visible = EditorGUILayout.Foldout(groups[k].visible, "Category: " + groups[k].categoryName);
|
||||
if (groups[k].visible) {
|
||||
int c = groups[k].frames.Count;
|
||||
int matIndex = 0;
|
||||
while (matIndex < c) {
|
||||
EditorGUILayout.BeginVertical();
|
||||
Rect rect = EditorGUILayout.GetControlRect();
|
||||
float w = rect.width / columnCount;
|
||||
rect.width = w - 5;
|
||||
for (int col = 0; col < columnCount; col++) {
|
||||
if (matIndex < c) {
|
||||
FrameEntry frameEntry = groups[k].frames[matIndex];
|
||||
if (frameEntry.mat != null) {
|
||||
rect.height = rowHeight;
|
||||
frameEntry.mat.SetTexture(ShaderParams.frameMaskTexture, frameEntry.frameMask);
|
||||
EditorGUI.DrawPreviewTexture(rect, wt, frameEntry.mat);
|
||||
rect.y += rowHeight;
|
||||
rect.height = 15;
|
||||
string frameName;
|
||||
if (b.frame.value && b.frame.overrideState && b.frameMask == frameEntry.frameMask) {
|
||||
frameName = "✔ " + frameEntry.mat.name;
|
||||
} else {
|
||||
frameName = frameEntry.mat.name;
|
||||
}
|
||||
if (GUI.Button(rect, frameName)) {
|
||||
if (b.frame.value && b.frame.overrideState && b.frameMask == frameEntry.frameMask) {
|
||||
b.frame.Override(false);
|
||||
} else {
|
||||
b.frame.Override(true);
|
||||
b.frameMask.Override(frameEntry.frameMask);
|
||||
b.frameThickness.Override(1.0f);
|
||||
b.frameSharpness.Override(255f);
|
||||
b.frameColor.Override(Color.white);
|
||||
}
|
||||
EditorUtility.SetDirty(b);
|
||||
if (!Application.isPlaying) {
|
||||
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEngine.SceneManagement.SceneManager.GetActiveScene());
|
||||
}
|
||||
}
|
||||
rect.y -= rowHeight;
|
||||
rect.x += w;
|
||||
}
|
||||
matIndex++;
|
||||
}
|
||||
}
|
||||
GUILayout.Space(rowHeight);
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
private void OnDestroy() {
|
||||
ReleaseGroups();
|
||||
}
|
||||
|
||||
void ReleaseGroups() {
|
||||
if (groups != null) {
|
||||
foreach (FrameGroup g in groups) {
|
||||
if (g.frames != null) {
|
||||
foreach (FrameEntry l in g.frames) {
|
||||
if (l.mat != null) {
|
||||
DestroyImmediate(l.mat);
|
||||
}
|
||||
}
|
||||
g.frames.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
groups = null;
|
||||
}
|
||||
|
||||
void RequestCapture(CameraType cameraType) {
|
||||
|
||||
BeautifySettings b;
|
||||
b = Misc.FindObjectOfType<BeautifySettings>();
|
||||
|
||||
if (b == null) {
|
||||
Debug.LogError("Beautify not found. It's requred for the LUT Browser functionality.");
|
||||
return;
|
||||
}
|
||||
BeautifyRendererFeature.captureCameraType = cameraType;
|
||||
BeautifyRendererFeature.requestScreenCapture = true;
|
||||
EditorUtility.SetDirty(BeautifySettings.sharedSettings);
|
||||
}
|
||||
|
||||
|
||||
void RefreshFrames() {
|
||||
|
||||
RequestCapture(BeautifyRendererFeature.captureCameraType);
|
||||
ReleaseGroups();
|
||||
if (referenceMaterial == null) {
|
||||
referenceMaterial = new Material(Shader.Find("Hidden/Beautify/FrameThumbnail"));
|
||||
}
|
||||
string[] res = Directory.GetDirectories(Application.dataPath, "*" + MASTER_FOLDER_NAME + "*", SearchOption.AllDirectories);
|
||||
string path = null;
|
||||
for (int k = 0; k < res.Length; k++) {
|
||||
if (res[k].Contains("Frame Pack")) {
|
||||
path = res[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
string[] categories = Directory.GetDirectories(path, "*", SearchOption.AllDirectories);
|
||||
groups = new FrameGroup[categories.Length];
|
||||
for (int c = 0; c < categories.Length; c++) {
|
||||
FrameGroup group = new FrameGroup();
|
||||
group.categoryPath = categories[c];
|
||||
group.categoryName = Path.GetFileName(group.categoryPath);
|
||||
group.frames = new List<FrameEntry>();
|
||||
string[] frames = Directory.GetFiles(group.categoryPath, "*.png", SearchOption.AllDirectories);
|
||||
if (frames != null) {
|
||||
for (int l = 0; l < frames.Length; l++) {
|
||||
string framePath = frames[l];
|
||||
int i = framePath.IndexOf("/Assets");
|
||||
if (i < 0) continue;
|
||||
framePath = framePath.Substring(i + 1);
|
||||
Texture2D frameMask = AssetDatabase.LoadAssetAtPath<Texture>(framePath) as Texture2D;
|
||||
if (frameMask != null) {
|
||||
Material mat = Instantiate(referenceMaterial);
|
||||
mat.name = Path.GetFileNameWithoutExtension(framePath);
|
||||
FrameEntry entry = new FrameEntry();
|
||||
entry.mat = mat;
|
||||
entry.frameMask = frameMask;
|
||||
group.frames.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
groups[c] = group;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b48e93dd24694f528b5e755ab766cad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,233 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Beautify.Universal {
|
||||
|
||||
public class LUTBrowser : EditorWindow {
|
||||
|
||||
const string MASTER_FOLDER_NAME = "LUT Pack";
|
||||
|
||||
Material referenceMaterial;
|
||||
Vector2 scrollPos;
|
||||
static int columnCount = 4;
|
||||
VolumeProfile profile;
|
||||
|
||||
struct LUTEntry {
|
||||
public Material mat;
|
||||
public Texture2D lutTex;
|
||||
}
|
||||
|
||||
struct LUTGroup {
|
||||
public string categoryPath;
|
||||
public string categoryName;
|
||||
public List<LUTEntry> luts;
|
||||
public bool visible;
|
||||
}
|
||||
LUTGroup[] groups;
|
||||
|
||||
|
||||
[MenuItem("Window/Kronnect/Beautify/LUT Browser")]
|
||||
public static void ShowBrowser() {
|
||||
GetWindow<LUTBrowser>("LUT Browser");
|
||||
}
|
||||
|
||||
static class ShaderParams {
|
||||
public static int lutTex = Shader.PropertyToID("_LUTTex");
|
||||
}
|
||||
|
||||
private void OnEnable() {
|
||||
RefreshLUTs();
|
||||
}
|
||||
|
||||
private void OnGUI() {
|
||||
|
||||
if (groups == null) {
|
||||
EditorGUILayout.HelpBox("LUT Pack not found.", MessageType.Info);
|
||||
if (GUILayout.Button("View LUT Pack on the Unity Asset Store")) {
|
||||
Application.OpenURL("https://assetstore.unity.com/packages/slug/202502");
|
||||
}
|
||||
if (GUILayout.Button("Reload LUT Pack")) {
|
||||
RefreshLUTs();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Find LUTs")) {
|
||||
RefreshLUTs();
|
||||
}
|
||||
if (GUILayout.Button("Capture SceneView")) {
|
||||
RequestCapture(CameraType.SceneView);
|
||||
}
|
||||
if (GUILayout.Button("Capture GameView")) {
|
||||
RequestCapture(CameraType.Game);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (profile == null) {
|
||||
profile = BeautifySettings.currentProfile;
|
||||
}
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
profile = (VolumeProfile)EditorGUILayout.ObjectField("Current Profile:", profile, typeof(VolumeProfile), false);
|
||||
if (GUILayout.Button(new GUIContent("Auto Select", "Automatically selects the profile used in a scene volume using Beautify"), GUILayout.Width(90))) {
|
||||
profile = null;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
Texture2D wt = Texture2D.whiteTexture;
|
||||
float rowHeight = 0.5f * EditorGUIUtility.currentViewWidth / columnCount;
|
||||
|
||||
scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
|
||||
Beautify b = null;
|
||||
if (profile != null) {
|
||||
profile.TryGet(out b);
|
||||
}
|
||||
if (b == null) {
|
||||
EditorGUILayout.HelpBox("Beautify not found in the seleced profile.", MessageType.Warning);
|
||||
} else {
|
||||
columnCount = EditorGUILayout.IntSlider("Columns:", columnCount, 1, 5);
|
||||
EditorGUILayout.HelpBox("Click on the name of a LUT to toggle it on/off. Use the Intensity slider in Beautify inspector to customize the LUT strength.", MessageType.Info);
|
||||
for (int k = 0; k < groups.Length; k++) {
|
||||
groups[k].visible = EditorGUILayout.Foldout(groups[k].visible, "Category: " + groups[k].categoryName);
|
||||
if (groups[k].visible) {
|
||||
int c = groups[k].luts.Count;
|
||||
int matIndex = 0;
|
||||
while (matIndex < c) {
|
||||
EditorGUILayout.BeginVertical();
|
||||
Rect rect = EditorGUILayout.GetControlRect();
|
||||
float w = rect.width / columnCount;
|
||||
rect.width = w - 5;
|
||||
for (int col = 0; col < columnCount; col++) {
|
||||
if (matIndex < c) {
|
||||
LUTEntry lutEntry = groups[k].luts[matIndex];
|
||||
if (lutEntry.mat != null) {
|
||||
rect.height = rowHeight;
|
||||
lutEntry.mat.SetTexture(ShaderParams.lutTex, lutEntry.lutTex);
|
||||
EditorGUI.DrawPreviewTexture(rect, wt, lutEntry.mat);
|
||||
rect.y += rowHeight;
|
||||
rect.height = 15;
|
||||
string lutName;
|
||||
if (b.lut.value && b.lut.overrideState && b.lutTexture == lutEntry.lutTex) {
|
||||
lutName = "✔ " + lutEntry.mat.name;
|
||||
} else {
|
||||
lutName = lutEntry.mat.name;
|
||||
}
|
||||
if (GUI.Button(rect, lutName)) {
|
||||
if (b.lut.value && b.lut.overrideState && b.lutTexture == lutEntry.lutTex) {
|
||||
b.lut.Override(false);
|
||||
} else {
|
||||
b.lut.Override(true);
|
||||
if (!b.lutIntensity.overrideState) {
|
||||
b.lutIntensity.Override(1f);
|
||||
}
|
||||
b.lutTexture.Override(lutEntry.lutTex);
|
||||
}
|
||||
EditorUtility.SetDirty(b);
|
||||
if (!Application.isPlaying) {
|
||||
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEngine.SceneManagement.SceneManager.GetActiveScene());
|
||||
}
|
||||
}
|
||||
rect.y -= rowHeight;
|
||||
rect.x += w;
|
||||
}
|
||||
matIndex++;
|
||||
}
|
||||
}
|
||||
GUILayout.Space(rowHeight);
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
private void OnDestroy() {
|
||||
ReleaseGroups();
|
||||
}
|
||||
|
||||
void ReleaseGroups() {
|
||||
if (groups != null) {
|
||||
foreach (LUTGroup g in groups) {
|
||||
if (g.luts != null) {
|
||||
foreach (LUTEntry l in g.luts) {
|
||||
if (l.mat != null) {
|
||||
DestroyImmediate(l.mat);
|
||||
}
|
||||
}
|
||||
g.luts.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
groups = null;
|
||||
}
|
||||
|
||||
void RequestCapture(CameraType cameraType) {
|
||||
|
||||
BeautifySettings b;
|
||||
b = Misc.FindObjectOfType<BeautifySettings>();
|
||||
if (b == null) {
|
||||
Debug.LogError("Beautify not found. It's requred for the LUT Browser functionality.");
|
||||
return;
|
||||
}
|
||||
BeautifyRendererFeature.captureCameraType = cameraType;
|
||||
BeautifyRendererFeature.requestScreenCapture = true;
|
||||
EditorUtility.SetDirty(BeautifySettings.sharedSettings);
|
||||
}
|
||||
|
||||
|
||||
void RefreshLUTs() {
|
||||
|
||||
RequestCapture(BeautifyRendererFeature.captureCameraType);
|
||||
ReleaseGroups();
|
||||
if (referenceMaterial == null) {
|
||||
referenceMaterial = new Material(Shader.Find("Hidden/Beautify/LUTThumbnail"));
|
||||
}
|
||||
string[] res = Directory.GetDirectories(Application.dataPath, "*" + MASTER_FOLDER_NAME + "*", SearchOption.AllDirectories);
|
||||
string path = null;
|
||||
for (int k = 0; k < res.Length; k++) {
|
||||
if (res[k].Contains("LUT Pack")) {
|
||||
path = res[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
string[] categories = Directory.GetDirectories(path, "*", SearchOption.AllDirectories);
|
||||
groups = new LUTGroup[categories.Length];
|
||||
for (int c = 0; c < categories.Length; c++) {
|
||||
LUTGroup group = new LUTGroup();
|
||||
group.categoryPath = categories[c];
|
||||
group.categoryName = Path.GetFileName(group.categoryPath);
|
||||
group.luts = new List<LUTEntry>();
|
||||
string[] luts = Directory.GetFiles(group.categoryPath, "*.png", SearchOption.AllDirectories);
|
||||
if (luts != null) {
|
||||
for (int l = 0; l < luts.Length; l++) {
|
||||
string lutPath = luts[l];
|
||||
int i = lutPath.IndexOf("/Assets");
|
||||
if (i < 0) continue;
|
||||
lutPath = lutPath.Substring(i + 1);
|
||||
Texture2D lutTex = AssetDatabase.LoadAssetAtPath<Texture>(lutPath) as Texture2D;
|
||||
if (lutTex != null) {
|
||||
Material mat = Instantiate(referenceMaterial);
|
||||
mat.name = Path.GetFileNameWithoutExtension(lutPath);
|
||||
LUTEntry entry = new LUTEntry();
|
||||
entry.mat = mat;
|
||||
entry.lutTex = lutTex;
|
||||
group.luts.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
groups[c] = group;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ea90863c340046bab9e7c20c63fb798
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 587d57227e82a414c91432f5d37dfc30
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
Shader "Hidden/Beautify/FrameThumbnail"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_Color ("Color", color) = (1,1,1,1)
|
||||
_FrameMask ("Frame Mask", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
|
||||
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;
|
||||
float2 clipUV : TEXCOORD1;
|
||||
};
|
||||
|
||||
sampler2D _LUTPreview;
|
||||
float4 _LUTPreview_ST;
|
||||
sampler2D _GUIClipTexture;
|
||||
uniform float4x4 unity_GUIClipTextureMatrix;
|
||||
|
||||
sampler2D _FrameMask;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
float3 eyePos = UnityObjectToViewPos(v.vertex);
|
||||
o.clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0));
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
clip( tex2D(_GUIClipTexture, i.clipUV).a - 0.1);
|
||||
|
||||
half3 rgb = tex2D(_LUTPreview, i.uv);
|
||||
|
||||
half4 frameMask = tex2D(_FrameMask, i.uv);
|
||||
rgb = lerp(rgb, frameMask.rgb, frameMask.a);
|
||||
|
||||
return half4(rgb, 1.0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 930de39fd5ebb4036af9ebca77f535be
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
Shader "Hidden/Beautify/LUTThumbnail"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_Color ("Color", color) = (1,1,1,1)
|
||||
_LUTTex ("LUT Texture", 2D) = "black" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
|
||||
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;
|
||||
float2 clipUV : TEXCOORD1;
|
||||
};
|
||||
|
||||
sampler2D _LUTPreview;
|
||||
float4 _LUTPreview_ST;;
|
||||
sampler2D _GUIClipTexture;
|
||||
uniform float4x4 unity_GUIClipTextureMatrix;
|
||||
|
||||
sampler2D _LUTTex;
|
||||
float4 _LUTTex_TexelSize;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
float3 eyePos = UnityObjectToViewPos(v.vertex);
|
||||
o.clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0));
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
clip( tex2D(_GUIClipTexture, i.clipUV).a - 0.1);
|
||||
|
||||
half3 rgb = tex2D(_LUTPreview, i.uv);
|
||||
|
||||
#if !UNITY_COLORSPACE_GAMMA
|
||||
rgb = LinearToGammaSpace(rgb);
|
||||
#endif
|
||||
|
||||
float3 lutST = float3(_LUTTex_TexelSize.x, _LUTTex_TexelSize.y, _LUTTex_TexelSize.w - 1);
|
||||
float3 lookUp = saturate(rgb) * lutST.zzz;
|
||||
lookUp.xy = lutST.xy * (lookUp.xy + 0.5);
|
||||
float slice = floor(lookUp.z);
|
||||
lookUp.x += slice * lutST.y;
|
||||
float2 lookUpNextSlice = float2(lookUp.x + lutST.y, lookUp.y);
|
||||
rgb = lerp(tex2D(_LUTTex, lookUp.xy).rgb, tex2D(_LUTTex, lookUpNextSlice).rgb, lookUp.z - slice);
|
||||
|
||||
return half4(rgb, 1.0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76e6e0fd1d4ad4cf7a9e2bd30b1675e1
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,55 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dd9cc9aaf47c43bea25b8a6e9df73d9
|
||||
timeCreated: 1462519611
|
||||
licenseType: Store
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
linearTexture: 1
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: 2
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,111 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e631d30559be7400bafa5c6d66ad4824
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,111 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad40dcebc3b024c5eabbae1b82de8979
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user