Outline Area and Particle Effect on Occupying Platform

dev-main-mobile
Ali Sharoz 1 month ago
parent 6e94be8b73
commit b952b03f4c

@ -0,0 +1,51 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Custom_TransparentOutline
m_Shader: {fileID: 4800000, guid: b59e0f7271de96f44aeb59a7632efae2, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 1
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _Texture2DAsset_ed5845bdef6b4ba39ae420b153b33345_Out_0_Texture2D:
m_Texture: {fileID: 2800000, guid: 4a53678acb2214c7aa104d85906b0982, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _OutlineWidth: 0.1
- _QueueControl: 0
- _QueueOffset: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _MainColor: {r: 1, g: 1, b: 1, a: 0.46666667}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6b217239934a46b4c91c867e2079ea81
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 69d9586d668d9e24ab3f720f0d88330b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bc25cfaaf25ea94438f80324b83abeec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,275 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
using System.Collections.Generic;
using System.IO;
// Parse conditional expressions from CFXR_MaterialInspector to show/hide some parts of the UI easily
namespace CartoonFX
{
public static class ExpressionParser
{
public delegate bool EvaluateFunction(string content);
//--------------------------------------------------------------------------------------------------------------------------------
// Main Function to use
static public bool EvaluateExpression(string expression, EvaluateFunction evalFunction)
{
//Remove white spaces and double && ||
string cleanExpr = "";
for(int i = 0; i < expression.Length; i++)
{
switch(expression[i])
{
case ' ': break;
case '&': cleanExpr += expression[i]; i++; break;
case '|': cleanExpr += expression[i]; i++; break;
default: cleanExpr += expression[i]; break;
}
}
List<Token> tokens = new List<Token>();
StringReader reader = new StringReader(cleanExpr);
Token t = null;
do
{
t = new Token(reader);
tokens.Add(t);
} while(t.type != Token.TokenType.EXPR_END);
List<Token> polishNotation = Token.TransformToPolishNotation(tokens);
var enumerator = polishNotation.GetEnumerator();
enumerator.MoveNext();
Expression root = MakeExpression(ref enumerator, evalFunction);
return root.Evaluate();
}
//--------------------------------------------------------------------------------------------------------------------------------
// Expression Token
public class Token
{
static Dictionary<char, KeyValuePair<TokenType, string>> typesDict = new Dictionary<char, KeyValuePair<TokenType, string>>()
{
{'(', new KeyValuePair<TokenType, string>(TokenType.OPEN_PAREN, "(")},
{')', new KeyValuePair<TokenType, string>(TokenType.CLOSE_PAREN, ")")},
{'!', new KeyValuePair<TokenType, string>(TokenType.UNARY_OP, "NOT")},
{'&', new KeyValuePair<TokenType, string>(TokenType.BINARY_OP, "AND")},
{'|', new KeyValuePair<TokenType, string>(TokenType.BINARY_OP, "OR")}
};
public enum TokenType
{
OPEN_PAREN,
CLOSE_PAREN,
UNARY_OP,
BINARY_OP,
LITERAL,
EXPR_END
}
public TokenType type;
public string value;
public Token(StringReader s)
{
int c = s.Read();
if(c == -1)
{
type = TokenType.EXPR_END;
value = "";
return;
}
char ch = (char)c;
//Special case: solve bug where !COND_FALSE_1 && COND_FALSE_2 would return True
bool embeddedNot = (ch == '!' && s.Peek() != '(');
if(typesDict.ContainsKey(ch) && !embeddedNot)
{
type = typesDict[ch].Key;
value = typesDict[ch].Value;
}
else
{
string str = "";
str += ch;
while(s.Peek() != -1 && !typesDict.ContainsKey((char)s.Peek()))
{
str += (char)s.Read();
}
type = TokenType.LITERAL;
value = str;
}
}
static public List<Token> TransformToPolishNotation(List<Token> infixTokenList)
{
Queue<Token> outputQueue = new Queue<Token>();
Stack<Token> stack = new Stack<Token>();
int index = 0;
while(infixTokenList.Count > index)
{
Token t = infixTokenList[index];
switch(t.type)
{
case Token.TokenType.LITERAL:
outputQueue.Enqueue(t);
break;
case Token.TokenType.BINARY_OP:
case Token.TokenType.UNARY_OP:
case Token.TokenType.OPEN_PAREN:
stack.Push(t);
break;
case Token.TokenType.CLOSE_PAREN:
while(stack.Peek().type != Token.TokenType.OPEN_PAREN)
{
outputQueue.Enqueue(stack.Pop());
}
stack.Pop();
if(stack.Count > 0 && stack.Peek().type == Token.TokenType.UNARY_OP)
{
outputQueue.Enqueue(stack.Pop());
}
break;
default:
break;
}
index++;
}
while(stack.Count > 0)
{
outputQueue.Enqueue(stack.Pop());
}
var list = new List<Token>(outputQueue);
list.Reverse();
return list;
}
}
//--------------------------------------------------------------------------------------------------------------------------------
// Boolean Expression Classes
public abstract class Expression
{
public abstract bool Evaluate();
}
public class ExpressionLeaf : Expression
{
private string content;
private EvaluateFunction evalFunction;
public ExpressionLeaf(EvaluateFunction _evalFunction, string _content)
{
this.evalFunction = _evalFunction;
this.content = _content;
}
override public bool Evaluate()
{
//embedded not, see special case in Token declaration
if(content.StartsWith("!"))
{
return !this.evalFunction(content.Substring(1));
}
return this.evalFunction(content);
}
}
public class ExpressionAnd : Expression
{
private Expression left;
private Expression right;
public ExpressionAnd(Expression _left, Expression _right)
{
this.left = _left;
this.right = _right;
}
override public bool Evaluate()
{
return left.Evaluate() && right.Evaluate();
}
}
public class ExpressionOr : Expression
{
private Expression left;
private Expression right;
public ExpressionOr(Expression _left, Expression _right)
{
this.left = _left;
this.right = _right;
}
override public bool Evaluate()
{
return left.Evaluate() || right.Evaluate();
}
}
public class ExpressionNot : Expression
{
private Expression expr;
public ExpressionNot(Expression _expr)
{
this.expr = _expr;
}
override public bool Evaluate()
{
return !expr.Evaluate();
}
}
static public Expression MakeExpression(ref List<Token>.Enumerator polishNotationTokensEnumerator, EvaluateFunction _evalFunction)
{
if(polishNotationTokensEnumerator.Current.type == Token.TokenType.LITERAL)
{
Expression lit = new ExpressionLeaf(_evalFunction, polishNotationTokensEnumerator.Current.value);
polishNotationTokensEnumerator.MoveNext();
return lit;
}
else
{
if(polishNotationTokensEnumerator.Current.value == "NOT")
{
polishNotationTokensEnumerator.MoveNext();
Expression operand = MakeExpression(ref polishNotationTokensEnumerator, _evalFunction);
return new ExpressionNot(operand);
}
else if(polishNotationTokensEnumerator.Current.value == "AND")
{
polishNotationTokensEnumerator.MoveNext();
Expression left = MakeExpression(ref polishNotationTokensEnumerator, _evalFunction);
Expression right = MakeExpression(ref polishNotationTokensEnumerator, _evalFunction);
return new ExpressionAnd(left, right);
}
else if(polishNotationTokensEnumerator.Current.value == "OR")
{
polishNotationTokensEnumerator.MoveNext();
Expression left = MakeExpression(ref polishNotationTokensEnumerator, _evalFunction);
Expression right = MakeExpression(ref polishNotationTokensEnumerator, _evalFunction);
return new ExpressionOr(left, right);
}
}
return null;
}
}
}

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ce7d96d3a4d4f3b4681ab437a9710d60
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,592 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
// Custom material inspector for Stylized FX shaders
// - organize UI using comments in the shader code
// - more flexibility than the material property drawers
// version 2 (dec 2017)
namespace CartoonFX
{
public class MaterialInspector : ShaderGUI
{
//Set by PropertyDrawers to defined if the next properties should be visible
static private Stack<bool> ShowStack = new Stack<bool>();
static public bool ShowNextProperty { get; private set; }
static public void PushShowProperty(bool value)
{
ShowStack.Push(ShowNextProperty);
ShowNextProperty &= value;
}
static public void PopShowProperty()
{
ShowNextProperty = ShowStack.Pop();
}
//--------------------------------------------------------------------------------------------------
const string kGuiCommandPrefix = "//#";
const string kGC_IfKeyword = "IF_KEYWORD";
const string kGC_IfProperty = "IF_PROPERTY";
const string kGC_EndIf = "END_IF";
const string kGC_HelpBox = "HELP_BOX";
const string kGC_Label = "LABEL";
Dictionary<int, List<GUICommand>> guiCommands = new Dictionary<int, List<GUICommand>>();
bool initialized = false;
AssetImporter shaderImporter;
ulong lastTimestamp;
void Initialize(MaterialEditor editor, bool force)
{
if((!initialized || force) && editor != null)
{
initialized = true;
guiCommands.Clear();
//Find the shader and parse the source to find special comments that will organize the GUI
//It's hackish, but at least it allows any character to be used (unlike material property drawers/decorators) and can be used along with property drawers
var materials = new List<Material>();
foreach(var o in editor.targets)
{
var m = o as Material;
if(m != null)
materials.Add(m);
}
if(materials.Count > 0 && materials[0].shader != null)
{
var path = AssetDatabase.GetAssetPath(materials[0].shader);
//get asset importer
shaderImporter = AssetImporter.GetAtPath(path);
if(shaderImporter != null)
{
lastTimestamp = shaderImporter.assetTimeStamp;
}
//remove 'Assets' and replace with OS path
path = Application.dataPath + path.Substring(6);
//convert to cross-platform path
path = path.Replace('/', Path.DirectorySeparatorChar);
//open file for reading
var lines = File.ReadAllLines(path);
bool insideProperties = false;
//regex pattern to find properties, as they need to be counted so that
//special commands can be inserted at the right position when enumerating them
var regex = new Regex(@"[a-zA-Z0-9_]+\s*\([^\)]*\)");
int propertyCount = 0;
bool insideCommentBlock = false;
foreach(var l in lines)
{
var line = l.TrimStart();
if(insideProperties)
{
bool isComment = line.StartsWith("//");
if(line.Contains("/*"))
insideCommentBlock = true;
if(line.Contains("*/"))
insideCommentBlock = false;
//finished properties block?
if(line.StartsWith("}"))
break;
//comment
if(line.StartsWith(kGuiCommandPrefix))
{
string command = line.Substring(kGuiCommandPrefix.Length).TrimStart();
//space
if(string.IsNullOrEmpty(command))
AddGUICommand(propertyCount, new GC_Space());
//separator
else if(command.StartsWith("---"))
AddGUICommand(propertyCount, new GC_Separator());
//separator
else if(command.StartsWith("==="))
AddGUICommand(propertyCount, new GC_SeparatorDouble());
//if keyword
else if(command.StartsWith(kGC_IfKeyword))
{
var expr = command.Substring(command.LastIndexOf(kGC_IfKeyword) + kGC_IfKeyword.Length + 1);
AddGUICommand(propertyCount, new GC_IfKeyword() { expression = expr, materials = materials.ToArray() });
}
//if property
else if(command.StartsWith(kGC_IfProperty))
{
var expr = command.Substring(command.LastIndexOf(kGC_IfProperty) + kGC_IfProperty.Length + 1);
AddGUICommand(propertyCount, new GC_IfProperty() { expression = expr, materials = materials.ToArray() });
}
//end if
else if(command.StartsWith(kGC_EndIf))
{
AddGUICommand(propertyCount, new GC_EndIf());
}
//help box
else if(command.StartsWith(kGC_HelpBox))
{
var messageType = MessageType.Error;
var message = "Invalid format for HELP_BOX:\n" + command;
var cmd = command.Substring(command.LastIndexOf(kGC_HelpBox) + kGC_HelpBox.Length + 1).Split(new string[] { "::" }, System.StringSplitOptions.RemoveEmptyEntries);
if(cmd.Length == 1)
{
message = cmd[0];
messageType = MessageType.None;
}
else if(cmd.Length == 2)
{
try
{
var msgType = (MessageType)System.Enum.Parse(typeof(MessageType), cmd[0], true);
message = cmd[1].Replace(" ", "\n");
messageType = msgType;
}
catch { }
}
AddGUICommand(propertyCount, new GC_HelpBox()
{
message = message,
messageType = messageType
});
}
//label
else if(command.StartsWith(kGC_Label))
{
var label = command.Substring(command.LastIndexOf(kGC_Label) + kGC_Label.Length + 1);
AddGUICommand(propertyCount, new GC_Label() { label = label });
}
//header: plain text after command
else
{
AddGUICommand(propertyCount, new GC_Header() { label = command });
}
}
else
//property
{
if(regex.IsMatch(line) && !insideCommentBlock && !isComment)
propertyCount++;
}
}
//start properties block?
if(line.StartsWith("Properties"))
{
insideProperties = true;
}
}
}
}
}
void AddGUICommand(int propertyIndex, GUICommand command)
{
if(!guiCommands.ContainsKey(propertyIndex))
guiCommands.Add(propertyIndex, new List<GUICommand>());
guiCommands[propertyIndex].Add(command);
}
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
{
initialized = false;
base.AssignNewShaderToMaterial(material, oldShader, newShader);
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
//init:
//- read metadata in properties comment to generate ui layout
//- force update if timestamp doesn't match last (= file externally updated)
bool force = (shaderImporter != null && shaderImporter.assetTimeStamp != lastTimestamp);
Initialize(materialEditor, force);
var shader = (materialEditor.target as Material).shader;
materialEditor.SetDefaultGUIWidths();
//show all properties by default
ShowNextProperty = true;
ShowStack.Clear();
for(int i = 0; i < properties.Length; i++)
{
if(guiCommands.ContainsKey(i))
{
for(int j = 0; j < guiCommands[i].Count; j++)
{
guiCommands[i][j].OnGUI();
}
}
//Use custom properties to enable/disable groups based on keywords
if(ShowNextProperty)
{
if((properties[i].flags & (MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData)) == MaterialProperty.PropFlags.None)
{
DisplayProperty(properties[i], materialEditor);
}
}
}
//make sure to show gui commands that are after properties
int index = properties.Length;
if(guiCommands.ContainsKey(index))
{
for(int j = 0; j < guiCommands[index].Count; j++)
{
guiCommands[index][j].OnGUI();
}
}
//Special fields
Styles.MaterialDrawSeparatorDouble();
materialEditor.RenderQueueField();
materialEditor.EnableInstancingField();
}
virtual protected void DisplayProperty(MaterialProperty property, MaterialEditor materialEditor)
{
float propertyHeight = materialEditor.GetPropertyHeight(property, property.displayName);
Rect controlRect = EditorGUILayout.GetControlRect(true, propertyHeight, EditorStyles.layerMaskField, new GUILayoutOption[0]);
materialEditor.ShaderProperty(controlRect, property, property.displayName);
}
}
// Same as Toggle drawer, but doesn't set any keyword
// This will avoid adding unnecessary shader keyword to the project
internal class MaterialToggleNoKeywordDrawer : MaterialPropertyDrawer
{
private static bool IsPropertyTypeSuitable(MaterialProperty prop)
{
return prop.type == MaterialProperty.PropType.Float || prop.type == MaterialProperty.PropType.Range;
}
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
float height;
if (!MaterialToggleNoKeywordDrawer.IsPropertyTypeSuitable(prop))
{
height = 40f;
}
else
{
height = base.GetPropertyHeight(prop, label, editor);
}
return height;
}
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
{
if (!MaterialToggleNoKeywordDrawer.IsPropertyTypeSuitable(prop))
{
EditorGUI.HelpBox(position, "Toggle used on a non-float property: " + prop.name, MessageType.Warning);
}
else
{
EditorGUI.BeginChangeCheck();
bool flag = Mathf.Abs(prop.floatValue) > 0.001f;
EditorGUI.showMixedValue = prop.hasMixedValue;
flag = EditorGUI.Toggle(position, label, flag);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
{
prop.floatValue = ((!flag) ? 0f : 1f);
}
}
}
}
// Same as KeywordEnum drawer, but uses the keyword supplied as is rather than adding a prefix to them
internal class MaterialKeywordEnumNoPrefixDrawer : MaterialPropertyDrawer
{
private readonly GUIContent[] labels;
private readonly string[] keywords;
public MaterialKeywordEnumNoPrefixDrawer(string lbl1, string kw1) : this(new[] { lbl1 }, new[] { kw1 }) { }
public MaterialKeywordEnumNoPrefixDrawer(string lbl1, string kw1, string lbl2, string kw2) : this(new[] { lbl1, lbl2 }, new[] { kw1, kw2 }) { }
public MaterialKeywordEnumNoPrefixDrawer(string lbl1, string kw1, string lbl2, string kw2, string lbl3, string kw3) : this(new[] { lbl1, lbl2, lbl3 }, new[] { kw1, kw2, kw3 }) { }
public MaterialKeywordEnumNoPrefixDrawer(string lbl1, string kw1, string lbl2, string kw2, string lbl3, string kw3, string lbl4, string kw4) : this(new[] { lbl1, lbl2, lbl3, lbl4 }, new[] { kw1, kw2, kw3, kw4 }) { }
public MaterialKeywordEnumNoPrefixDrawer(string lbl1, string kw1, string lbl2, string kw2, string lbl3, string kw3, string lbl4, string kw4, string lbl5, string kw5) : this(new[] { lbl1, lbl2, lbl3, lbl4, lbl5 }, new[] { kw1, kw2, kw3, kw4, kw5 }) { }
public MaterialKeywordEnumNoPrefixDrawer(string lbl1, string kw1, string lbl2, string kw2, string lbl3, string kw3, string lbl4, string kw4, string lbl5, string kw5, string lbl6, string kw6) : this(new[] { lbl1, lbl2, lbl3, lbl4, lbl5, lbl6 }, new[] { kw1, kw2, kw3, kw4, kw5, kw6 }) { }
public MaterialKeywordEnumNoPrefixDrawer(string[] labels, string[] keywords)
{
this.labels= new GUIContent[keywords.Length];
this.keywords = new string[keywords.Length];
for (int i = 0; i < keywords.Length; ++i)
{
this.labels[i] = new GUIContent(labels[i]);
this.keywords[i] = keywords[i];
}
}
static bool IsPropertyTypeSuitable(MaterialProperty prop)
{
return prop.type == MaterialProperty.PropType.Float || prop.type == MaterialProperty.PropType.Range;
}
void SetKeyword(MaterialProperty prop, int index)
{
for (int i = 0; i < keywords.Length; ++i)
{
string keyword = GetKeywordName(prop.name, keywords[i]);
foreach (Material material in prop.targets)
{
if (index == i)
material.EnableKeyword(keyword);
else
material.DisableKeyword(keyword);
}
}
}
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
if (!IsPropertyTypeSuitable(prop))
{
return EditorGUIUtility.singleLineHeight * 2.5f;
}
return base.GetPropertyHeight(prop, label, editor);
}
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
{
if (!IsPropertyTypeSuitable(prop))
{
EditorGUI.HelpBox(position, "Toggle used on a non-float property: " + prop.name, MessageType.Warning);
return;
}
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = prop.hasMixedValue;
var value = (int)prop.floatValue;
value = EditorGUI.Popup(position, label, value, labels);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
{
prop.floatValue = value;
SetKeyword(prop, value);
}
}
public override void Apply(MaterialProperty prop)
{
base.Apply(prop);
if (!IsPropertyTypeSuitable(prop))
return;
if (prop.hasMixedValue)
return;
SetKeyword(prop, (int)prop.floatValue);
}
// Final keyword name: property name + "_" + display name. Uppercased,
// and spaces replaced with underscores.
private static string GetKeywordName(string propName, string name)
{
// Just return the supplied name
return name;
// Original code:
/*
string n = propName + "_" + name;
return n.Replace(' ', '_').ToUpperInvariant();
*/
}
}
//================================================================================================================================================================================================
// GUI Commands System
//
// Workaround to Material Property Drawers limitations:
// - uses shader comments to organize the GUI, and show/hide properties based on conditions
// - can use any character (unlike property drawers)
// - parsed once at material editor initialization
internal class GUICommand
{
public virtual bool Visible() { return true; }
public virtual void OnGUI() { }
}
internal class GC_Separator : GUICommand { public override void OnGUI() { if(MaterialInspector.ShowNextProperty) Styles.MaterialDrawSeparator(); } }
internal class GC_SeparatorDouble : GUICommand { public override void OnGUI() { if(MaterialInspector.ShowNextProperty) Styles.MaterialDrawSeparatorDouble(); } }
internal class GC_Space : GUICommand { public override void OnGUI() { if(MaterialInspector.ShowNextProperty) GUILayout.Space(8); } }
internal class GC_HelpBox : GUICommand
{
public string message { get; set; }
public MessageType messageType { get; set; }
public override void OnGUI()
{
if(MaterialInspector.ShowNextProperty)
Styles.HelpBoxRichText(message, messageType);
}
}
internal class GC_Header : GUICommand
{
public string label { get; set; }
GUIContent guiContent;
public override void OnGUI()
{
if(guiContent == null)
guiContent = new GUIContent(label);
if(MaterialInspector.ShowNextProperty)
Styles.MaterialDrawHeader(guiContent);
}
}
internal class GC_Label : GUICommand
{
public string label { get; set; }
GUIContent guiContent;
public override void OnGUI()
{
if(guiContent == null)
guiContent = new GUIContent(label);
if(MaterialInspector.ShowNextProperty)
GUILayout.Label(guiContent);
}
}
internal class GC_IfKeyword : GUICommand
{
public string expression { get; set; }
public Material[] materials { get; set; }
public override void OnGUI()
{
bool show = ExpressionParser.EvaluateExpression(expression, (string s) =>
{
foreach(var m in materials)
{
if(m.IsKeywordEnabled(s))
return true;
}
return false;
});
MaterialInspector.PushShowProperty(show);
}
}
internal class GC_EndIf : GUICommand { public override void OnGUI() { MaterialInspector.PopShowProperty(); } }
internal class GC_IfProperty : GUICommand
{
string _expression;
public string expression
{
get { return _expression; }
set { _expression = value.Replace("!=", "<>"); }
}
public Material[] materials { get; set; }
public override void OnGUI()
{
bool show = ExpressionParser.EvaluateExpression(expression, EvaluatePropertyExpression);
MaterialInspector.PushShowProperty(show);
}
bool EvaluatePropertyExpression(string expr)
{
//expression is expected to be in the form of: property operator value
var reader = new StringReader(expr);
string property = "";
string op = "";
float value = 0f;
int overflow = 0;
while(true)
{
char c = (char)reader.Read();
//operator
if(c == '=' || c == '>' || c == '<' || c == '!')
{
op += c;
//second operator character, if any
char c2 = (char)reader.Peek();
if(c2 == '=' || c2 == '>')
{
reader.Read();
op += c2;
}
//end of string is the value
var end = reader.ReadToEnd();
if(!float.TryParse(end, out value))
{
Debug.LogError("Couldn't parse float from property expression:\n" + end);
return false;
}
break;
}
//property name
property += c;
overflow++;
if(overflow >= 9999)
{
Debug.LogError("Expression parsing overflow!\n");
return false;
}
}
//evaluate property
bool conditionMet = false;
foreach(var m in materials)
{
float propValue = 0f;
if(property.Contains(".x") || property.Contains(".y") || property.Contains(".z") || property.Contains(".w"))
{
string[] split = property.Split('.');
string component = split[1];
switch(component)
{
case "x": propValue = m.GetVector(split[0]).x; break;
case "y": propValue = m.GetVector(split[0]).y; break;
case "z": propValue = m.GetVector(split[0]).z; break;
case "w": propValue = m.GetVector(split[0]).w; break;
default: Debug.LogError("Invalid component for vector property: '" + property + "'"); break;
}
}
else
propValue = m.GetFloat(property);
switch(op)
{
case ">=": conditionMet = propValue >= value; break;
case "<=": conditionMet = propValue <= value; break;
case ">": conditionMet = propValue > value; break;
case "<": conditionMet = propValue < value; break;
case "<>": conditionMet = propValue != value; break; //not equal, "!=" is replaced by "<>" to prevent bug with leading ! ("not" operator)
case "==": conditionMet = propValue == value; break;
default:
Debug.LogError("Invalid property expression:\n" + expr);
break;
}
if(conditionMet)
return true;
}
return false;
}
}
}

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4fb4c15e772a1cc4baecc7a958bf9cc7
timeCreated: 1486392341
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,423 @@
// #define SHOW_EXPORT_BUTTON
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using UnityEditor;
using UnityEditor.Rendering;
using UnityEngine;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
using UnityEditor.Experimental.AssetImporters;
#endif
using UnityEngine.Rendering;
namespace CartoonFX
{
namespace CustomShaderImporter
{
static class Utils
{
public static bool IsUsingURP()
{
#if UNITY_2019_3_OR_NEWER
var renderPipeline = GraphicsSettings.currentRenderPipeline;
#else
var renderPipeline = GraphicsSettings.renderPipelineAsset;
#endif
return renderPipeline != null && renderPipeline.GetType().Name.Contains("Universal");
}
}
[ScriptedImporter(0, FILE_EXTENSION)]
public class CFXR_ShaderImporter : ScriptedImporter
{
public enum RenderPipeline
{
Auto,
ForceBuiltInRenderPipeline,
ForceUniversalRenderPipeline
}
public const string FILE_EXTENSION = "cfxrshader";
[Tooltip("In case of errors when building the project or with addressables, you can try forcing a specific render pipeline")]
public RenderPipeline renderPipelineDetection = RenderPipeline.Auto;
public string detectedRenderPipeline = "Built-In Render Pipeline";
public int strippedLinesCount = 0;
public string shaderSourceCode;
public string shaderName;
public string[] shaderErrors;
public ulong variantCount;
public ulong variantCountUsed;
enum ComparisonOperator
{
Equal,
Greater,
GreaterOrEqual,
Less,
LessOrEqual
}
#if UNITY_2022_2_OR_NEWER
const int URP_VERSION = 14;
#elif UNITY_2021_2_OR_NEWER
const int URP_VERSION = 12;
#elif UNITY_2021_1_OR_NEWER
const int URP_VERSION = 11;
#elif UNITY_2020_3_OR_NEWER
const int URP_VERSION = 10;
#else
const int URP_VERSION = 7;
#endif
static ComparisonOperator ParseComparisonOperator(string symbols)
{
switch (symbols)
{
case "==": return ComparisonOperator.Equal;
case "<=": return ComparisonOperator.LessOrEqual;
case "<": return ComparisonOperator.Less;
case ">": return ComparisonOperator.Greater;
case ">=": return ComparisonOperator.GreaterOrEqual;
default: throw new Exception("Invalid comparison operator: " + symbols);
}
}
static bool CompareWithOperator(int value1, int value2, ComparisonOperator comparisonOperator)
{
switch (comparisonOperator)
{
case ComparisonOperator.Equal: return value1 == value2;
case ComparisonOperator.Greater: return value1 > value2;
case ComparisonOperator.GreaterOrEqual: return value1 >= value2;
case ComparisonOperator.Less: return value1 < value2;
case ComparisonOperator.LessOrEqual: return value1 <= value2;
default: throw new Exception("Invalid comparison operator value: " + comparisonOperator);
}
}
bool StartsOrEndWithSpecialTag(string line)
{
bool startsWithTag = (line.Length > 4 && line[0] == '/' && line[1] == '*' && line[2] == '*' && line[3] == '*');
if (startsWithTag) return true;
int l = line.Length-1;
bool endsWithTag = (line.Length > 4 && line[l] == '/' && line[l-1] == '*' && line[l-2] == '*' && line[l-3] == '*');
return endsWithTag;
}
public override void OnImportAsset(AssetImportContext context)
{
bool isUsingURP;
switch (renderPipelineDetection)
{
default:
case RenderPipeline.Auto:
{
isUsingURP = Utils.IsUsingURP();
detectedRenderPipeline = isUsingURP ? "Universal Render Pipeline" : "Built-In Render Pipeline";
break;
}
case RenderPipeline.ForceBuiltInRenderPipeline:
{
detectedRenderPipeline = "Built-In Render Pipeline";
isUsingURP = false;
break;
}
case RenderPipeline.ForceUniversalRenderPipeline:
{
detectedRenderPipeline = "Universal Render Pipeline";
isUsingURP = true;
break;
}
}
StringWriter shaderSource = new StringWriter();
string[] sourceLines = File.ReadAllLines(context.assetPath);
Stack<bool> excludeCurrentLines = new Stack<bool>();
strippedLinesCount = 0;
for (int i = 0; i < sourceLines.Length; i++)
{
bool excludeThisLine = excludeCurrentLines.Count > 0 && excludeCurrentLines.Peek();
string line = sourceLines[i];
if (StartsOrEndWithSpecialTag(line))
{
if (line.StartsWith("/*** BIRP ***/"))
{
excludeCurrentLines.Push(excludeThisLine || isUsingURP);
}
else if (line.StartsWith("/*** URP ***/"))
{
excludeCurrentLines.Push(excludeThisLine || !isUsingURP);
}
else if (line.StartsWith("/*** URP_VERSION "))
{
string subline = line.Substring("/*** URP_VERSION ".Length);
int spaceIndex = subline.IndexOf(' ');
string version = subline.Substring(spaceIndex, subline.LastIndexOf(' ') - spaceIndex);
string op = subline.Substring(0, spaceIndex);
var compOp = ParseComparisonOperator(op);
int compVersion = int.Parse(version);
bool isCorrectURP = CompareWithOperator(URP_VERSION, compVersion, compOp);
excludeCurrentLines.Push(excludeThisLine || !isCorrectURP);
}
else if (excludeThisLine && line.StartsWith("/*** END"))
{
excludeCurrentLines.Pop();
}
else if (!excludeThisLine && line.StartsWith("/*** #define URP_VERSION ***/"))
{
shaderSource.WriteLine("\t\t\t#define URP_VERSION " + URP_VERSION);
}
}
else
{
if (excludeThisLine)
{
strippedLinesCount++;
continue;
}
shaderSource.WriteLine(line);
}
}
// Get source code and extract name
shaderSourceCode = shaderSource.ToString();
int idx = shaderSourceCode.IndexOf("Shader \"", StringComparison.InvariantCulture) + 8;
int idx2 = shaderSourceCode.IndexOf('"', idx);
shaderName = shaderSourceCode.Substring(idx, idx2 - idx);
shaderErrors = null;
Shader shader = ShaderUtil.CreateShaderAsset(context, shaderSourceCode, true);
if (ShaderUtil.ShaderHasError(shader))
{
string[] shaderSourceLines = shaderSourceCode.Split(new [] {'\n'}, StringSplitOptions.None);
var errors = ShaderUtil.GetShaderMessages(shader);
shaderErrors = Array.ConvertAll(errors, err => $"{err.message} (line {err.line})");
foreach (ShaderMessage error in errors)
{
string message = error.line <= 0 ?
string.Format("Shader Error in '{0}' (in file '{2}')\nError: {1}\n", shaderName, error.message, error.file) :
string.Format("Shader Error in '{0}' (line {2} in file '{3}')\nError: {1}\nLine: {4}\n", shaderName, error.message, error.line, error.file, shaderSourceLines[error.line-1]);
if (error.severity == ShaderCompilerMessageSeverity.Warning)
{
Debug.LogWarning(message);
}
else
{
Debug.LogError(message);
}
}
}
else
{
ShaderUtil.ClearShaderMessages(shader);
}
context.AddObjectToAsset("MainAsset", shader);
context.SetMainObject(shader);
// Try to count variant using reflection:
// internal static extern ulong GetVariantCount(Shader s, bool usedBySceneOnly);
variantCount = 0;
variantCountUsed = 0;
MethodInfo getVariantCountReflection = typeof(ShaderUtil).GetMethod("GetVariantCount", BindingFlags.Static | BindingFlags.NonPublic);
if (getVariantCountReflection != null)
{
try
{
object result = getVariantCountReflection.Invoke(null, new object[] {shader, false});
variantCount = (ulong)result;
result = getVariantCountReflection.Invoke(null, new object[] {shader, true});
variantCountUsed = (ulong)result;
}
catch
{
// ignored
}
}
}
}
namespace Inspector
{
[CustomEditor(typeof(CFXR_ShaderImporter)), CanEditMultipleObjects]
public class TCP2ShaderImporter_Editor : Editor
{
CFXR_ShaderImporter Importer => (CFXR_ShaderImporter) this.target;
// From: UnityEditor.ShaderInspectorPlatformsPopup
static string FormatCount(ulong count)
{
bool flag = count > 1000000000uL;
string result;
if (flag)
{
result = (count / 1000000000.0).ToString("f2", CultureInfo.InvariantCulture.NumberFormat) + "B";
}
else
{
bool flag2 = count > 1000000uL;
if (flag2)
{
result = (count / 1000000.0).ToString("f2", CultureInfo.InvariantCulture.NumberFormat) + "M";
}
else
{
bool flag3 = count > 1000uL;
if (flag3)
{
result = (count / 1000.0).ToString("f2", CultureInfo.InvariantCulture.NumberFormat) + "k";
}
else
{
result = count.ToString();
}
}
}
return result;
}
static GUIStyle _HelpBoxRichTextStyle;
static GUIStyle HelpBoxRichTextStyle
{
get
{
if (_HelpBoxRichTextStyle == null)
{
_HelpBoxRichTextStyle = new GUIStyle("HelpBox");
_HelpBoxRichTextStyle.richText = true;
_HelpBoxRichTextStyle.margin = new RectOffset(4, 4, 0, 0);
_HelpBoxRichTextStyle.padding = new RectOffset(4, 4, 4, 4);
}
return _HelpBoxRichTextStyle;
}
}
public override void OnInspectorGUI()
{
bool multipleValues = serializedObject.isEditingMultipleObjects;
CFXR_ShaderImporter.RenderPipeline detection = ((CFXR_ShaderImporter)target).renderPipelineDetection;
bool isUsingURP = Utils.IsUsingURP();
serializedObject.Update();
GUILayout.Label(Importer.shaderName);
string variantsText = "";
if (Importer.variantCount > 0 && Importer.variantCountUsed > 0)
{
string variantsCount = multipleValues ? "-" : FormatCount(Importer.variantCount);
string variantsCountUsed = multipleValues ? "-" : FormatCount(Importer.variantCountUsed);
variantsText = $"\nVariants (currently used): <b>{variantsCountUsed}</b>\nVariants (including unused): <b>{variantsCount}</b>";
}
string strippedLinesCount = multipleValues ? "-" : Importer.strippedLinesCount.ToString();
string renderPipeline = Importer.detectedRenderPipeline;
if (targets is { Length: > 1 })
{
foreach (CFXR_ShaderImporter importer in targets)
{
if (importer.detectedRenderPipeline != renderPipeline)
{
renderPipeline = "-";
break;
}
}
}
GUILayout.Label($"{(detection == CFXR_ShaderImporter.RenderPipeline.Auto ? "Detected" : "Forced")} render pipeline: <b>{renderPipeline}</b>\nStripped lines: <b>{strippedLinesCount}</b>{variantsText}", HelpBoxRichTextStyle);
if (Importer.shaderErrors != null && Importer.shaderErrors.Length > 0)
{
GUILayout.Space(4);
var color = GUI.color;
GUI.color = new Color32(0xFF, 0x80, 0x80, 0xFF);
GUILayout.Label($"<b>Errors:</b>\n{string.Join("\n", Importer.shaderErrors)}", HelpBoxRichTextStyle);
GUI.color = color;
}
bool shouldReimportShader = false;
bool compiledForURP = Importer.detectedRenderPipeline.Contains("Universal");
if (detection == CFXR_ShaderImporter.RenderPipeline.Auto
&& ((isUsingURP && !compiledForURP) || (!isUsingURP && compiledForURP)))
{
GUILayout.Space(4);
Color guiColor = GUI.color;
GUI.color *= Color.yellow;
EditorGUILayout.HelpBox("The detected render pipeline doesn't match the pipeline this shader was compiled for!\nPlease reimport the shaders for them to work in the current render pipeline.", MessageType.Warning);
if (GUILayout.Button("Reimport Shader"))
{
shouldReimportShader = true;
}
GUI.color = guiColor;
}
GUILayout.Space(4);
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CFXR_ShaderImporter.renderPipelineDetection)));
if (EditorGUI.EndChangeCheck())
{
shouldReimportShader = true;
}
if (GUILayout.Button("View Source", GUILayout.ExpandWidth(false)))
{
string path = Application.temporaryCachePath + "/" + Importer.shaderName.Replace("/", "-") + "_Source.shader";
if (File.Exists(path))
{
File.SetAttributes(path, FileAttributes.Normal);
}
File.WriteAllText(path, Importer.shaderSourceCode);
File.SetAttributes(path, FileAttributes.ReadOnly);
UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(path, 0);
}
#if SHOW_EXPORT_BUTTON
GUILayout.Space(8);
EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(importer.shaderSourceCode));
{
if (GUILayout.Button("Export .shader file", GUILayout.ExpandWidth(false)))
{
string savePath = EditorUtility.SaveFilePanel("Export CFXR shader", Application.dataPath, "CFXR Shader","shader");
if (!string.IsNullOrEmpty(savePath))
{
File.WriteAllText(savePath, importer.shaderSourceCode);
}
}
}
EditorGUI.EndDisabledGroup();
#endif
serializedObject.ApplyModifiedProperties();
if (shouldReimportShader)
{
ReimportShader();
}
}
void ReimportShader()
{
foreach (UnityEngine.Object t in targets)
{
string path = AssetDatabase.GetAssetPath(t);
AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceSynchronousImport);
}
}
}
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fe56ec25963759b49955809beeb4324b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,38 @@
using System;
using UnityEditor;
using UnityEngine;
namespace CartoonFX
{
namespace CustomShaderImporter
{
public class CFXR_ShaderPostProcessor : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
CleanCFXRShaders(importedAssets);
}
static void CleanCFXRShaders(string[] paths)
{
foreach (var assetPath in paths)
{
if (!assetPath.EndsWith(CFXR_ShaderImporter.FILE_EXTENSION, StringComparison.InvariantCultureIgnoreCase))
{
continue;
}
var shader = AssetDatabase.LoadMainAssetAtPath(assetPath) as Shader;
if (shader != null)
{
ShaderUtil.ClearShaderMessages(shader);
if (!ShaderUtil.ShaderHasError(shader))
{
ShaderUtil.RegisterShader(shader);
}
}
}
}
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 29d46695388f9a84d9ae71b5140727a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,362 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEditor;
// GUI Styles and UI methods
namespace CartoonFX
{
public static class Styles
{
//================================================================================================================================
// GUI Styles
//================================================================================================================================
//================================================================================================================================
// (x) close button
static GUIStyle _closeCrossButton;
public static GUIStyle CloseCrossButton
{
get
{
if(_closeCrossButton == null)
{
//Try to load GUISkin according to its GUID
//Assumes that its .meta file should always stick with it!
string guiSkinPath = AssetDatabase.GUIDToAssetPath("02d396fa782e5d7438e231ea9f8be23c");
var gs = AssetDatabase.LoadAssetAtPath<GUISkin>(guiSkinPath);
if(gs != null)
{
_closeCrossButton = System.Array.Find<GUIStyle>(gs.customStyles, x => x.name == "CloseCrossButton");
}
//Else fall back to minibutton
if(_closeCrossButton == null)
_closeCrossButton = EditorStyles.miniButton;
}
return _closeCrossButton;
}
}
//================================================================================================================================
// Shuriken Toggle with label alignment fix
static GUIStyle _shurikenToggle;
public static GUIStyle ShurikenToggle
{
get
{
if(_shurikenToggle == null)
{
_shurikenToggle = new GUIStyle("ShurikenToggle");
_shurikenToggle.fontSize = 9;
_shurikenToggle.contentOffset = new Vector2(16, -1);
if(EditorGUIUtility.isProSkin)
{
var textColor = new Color(.8f, .8f, .8f);
_shurikenToggle.normal.textColor = textColor;
_shurikenToggle.active.textColor = textColor;
_shurikenToggle.focused.textColor = textColor;
_shurikenToggle.hover.textColor = textColor;
_shurikenToggle.onNormal.textColor = textColor;
_shurikenToggle.onActive.textColor = textColor;
_shurikenToggle.onFocused.textColor = textColor;
_shurikenToggle.onHover.textColor = textColor;
}
}
return _shurikenToggle;
}
}
//================================================================================================================================
// Bold mini-label (the one from EditorStyles isn't actually "mini")
static GUIStyle _miniBoldLabel;
public static GUIStyle MiniBoldLabel
{
get
{
if(_miniBoldLabel == null)
{
_miniBoldLabel = new GUIStyle(EditorStyles.boldLabel);
_miniBoldLabel.fontSize = 10;
_miniBoldLabel.margin = new RectOffset(0, 0, 0, 0);
}
return _miniBoldLabel;
}
}
//================================================================================================================================
// Bold mini-foldout
static GUIStyle _miniBoldFoldout;
public static GUIStyle MiniBoldFoldout
{
get
{
if(_miniBoldFoldout == null)
{
_miniBoldFoldout = new GUIStyle(EditorStyles.foldout);
_miniBoldFoldout.fontSize = 10;
_miniBoldFoldout.fontStyle = FontStyle.Bold;
_miniBoldFoldout.margin = new RectOffset(0, 0, 0, 0);
}
return _miniBoldFoldout;
}
}
//================================================================================================================================
// Gray right-aligned label for Orderable List (Material Animator)
static GUIStyle _PropertyTypeLabel;
public static GUIStyle PropertyTypeLabel
{
get
{
if(_PropertyTypeLabel == null)
{
_PropertyTypeLabel = new GUIStyle(EditorStyles.label);
_PropertyTypeLabel.alignment = TextAnchor.MiddleRight;
_PropertyTypeLabel.normal.textColor = Color.gray;
_PropertyTypeLabel.fontSize = 9;
}
return _PropertyTypeLabel;
}
}
// Dark Gray right-aligned label for Orderable List (Material Animator)
static GUIStyle _PropertyTypeLabelFocused;
public static GUIStyle PropertyTypeLabelFocused
{
get
{
if(_PropertyTypeLabelFocused == null)
{
_PropertyTypeLabelFocused = new GUIStyle(EditorStyles.label);
_PropertyTypeLabelFocused.alignment = TextAnchor.MiddleRight;
_PropertyTypeLabelFocused.normal.textColor = new Color(.2f, .2f, .2f);
_PropertyTypeLabelFocused.fontSize = 9;
}
return _PropertyTypeLabelFocused;
}
}
//================================================================================================================================
// Rounded Box
static GUIStyle _roundedBox;
public static GUIStyle RoundedBox
{
get
{
if(_roundedBox == null)
{
_roundedBox = new GUIStyle(EditorStyles.helpBox);
}
return _roundedBox;
}
}
//================================================================================================================================
// Center White Label ("Editing Spline" label in Scene View)
static GUIStyle _CenteredWhiteLabel;
public static GUIStyle CenteredWhiteLabel
{
get
{
if(_CenteredWhiteLabel == null)
{
_CenteredWhiteLabel = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
_CenteredWhiteLabel.fontSize = 20;
_CenteredWhiteLabel.normal.textColor = Color.white;
}
return _CenteredWhiteLabel;
}
}
//================================================================================================================================
// Used to draw lines for separators
static public GUIStyle _LineStyle;
static public GUIStyle LineStyle
{
get
{
if(_LineStyle == null)
{
_LineStyle = new GUIStyle();
_LineStyle.normal.background = EditorGUIUtility.whiteTexture;
_LineStyle.stretchWidth = true;
}
return _LineStyle;
}
}
//================================================================================================================================
// HelpBox with rich text formatting support
static GUIStyle _HelpBoxRichTextStyle;
static public GUIStyle HelpBoxRichTextStyle
{
get
{
if(_HelpBoxRichTextStyle == null)
{
_HelpBoxRichTextStyle = new GUIStyle("HelpBox");
_HelpBoxRichTextStyle.richText = true;
}
return _HelpBoxRichTextStyle;
}
}
//================================================================================================================================
// Material Blue Header
static public GUIStyle _MaterialHeaderStyle;
static public GUIStyle MaterialHeaderStyle
{
get
{
if(_MaterialHeaderStyle == null)
{
_MaterialHeaderStyle = new GUIStyle(EditorStyles.label);
_MaterialHeaderStyle.fontStyle = FontStyle.Bold;
_MaterialHeaderStyle.fontSize = 11;
_MaterialHeaderStyle.padding.top = 0;
_MaterialHeaderStyle.padding.bottom = 0;
_MaterialHeaderStyle.normal.textColor = EditorGUIUtility.isProSkin ? new Color32(75, 128, 255, 255) : new Color32(0, 50, 230, 255);
_MaterialHeaderStyle.stretchWidth = true;
}
return _MaterialHeaderStyle;
}
}
//================================================================================================================================
// Material Header emboss effect
static public GUIStyle _MaterialHeaderStyleHighlight;
static public GUIStyle MaterialHeaderStyleHighlight
{
get
{
if(_MaterialHeaderStyleHighlight == null)
{
_MaterialHeaderStyleHighlight = new GUIStyle(MaterialHeaderStyle);
_MaterialHeaderStyleHighlight.contentOffset = new Vector2(1, 1);
_MaterialHeaderStyleHighlight.normal.textColor = EditorGUIUtility.isProSkin ? new Color32(255, 255, 255, 16) : new Color32(255, 255, 255, 32);
}
return _MaterialHeaderStyleHighlight;
}
}
//================================================================================================================================
// Filled rectangle
static private GUIStyle _WhiteRectangleStyle;
static public void DrawRectangle(Rect position, Color color)
{
var col = GUI.color;
GUI.color *= color;
DrawRectangle(position);
GUI.color = col;
}
static public void DrawRectangle(Rect position)
{
if(_WhiteRectangleStyle == null)
{
_WhiteRectangleStyle = new GUIStyle();
_WhiteRectangleStyle.normal.background = EditorGUIUtility.whiteTexture;
}
if(Event.current != null && Event.current.type == EventType.Repaint)
{
_WhiteRectangleStyle.Draw(position, false, false, false, false);
}
}
//================================================================================================================================
// Methods
//================================================================================================================================
static public void DrawLine(float height = 2f)
{
DrawLine(Color.black, height);
}
static public void DrawLine(Color color, float height = 1f)
{
Rect position = GUILayoutUtility.GetRect(0f, float.MaxValue, height, height, LineStyle);
DrawLine(position, color);
}
static public void DrawLine(Rect position, Color color)
{
if(Event.current.type == EventType.Repaint)
{
Color orgColor = GUI.color;
GUI.color = orgColor * color;
LineStyle.Draw(position, false, false, false, false);
GUI.color = orgColor;
}
}
static public void MaterialDrawHeader(GUIContent guiContent)
{
var rect = GUILayoutUtility.GetRect(guiContent, MaterialHeaderStyle);
GUI.Label(rect, guiContent, MaterialHeaderStyleHighlight);
GUI.Label(rect, guiContent, MaterialHeaderStyle);
}
static public void MaterialDrawSeparator()
{
GUILayout.Space(4);
if(EditorGUIUtility.isProSkin)
DrawLine(new Color(.3f, .3f, .3f, 1f), 1);
else
DrawLine(new Color(.6f, .6f, .6f, 1f), 1);
GUILayout.Space(4);
}
static public void MaterialDrawSeparatorDouble()
{
GUILayout.Space(6);
if(EditorGUIUtility.isProSkin)
{
DrawLine(new Color(.1f, .1f, .1f, 1f), 1);
DrawLine(new Color(.4f, .4f, .4f, 1f), 1);
}
else
{
DrawLine(new Color(.3f, .3f, .3f, 1f), 1);
DrawLine(new Color(.9f, .9f, .9f, 1f), 1);
}
GUILayout.Space(6);
}
//built-in console icons, also used in help box
static Texture2D warnIcon;
static Texture2D infoIcon;
static Texture2D errorIcon;
static public void HelpBoxRichText(Rect position, string message, MessageType msgType)
{
Texture2D icon = null;
switch(msgType)
{
case MessageType.Warning: icon = warnIcon ?? (warnIcon = EditorGUIUtility.Load("console.warnicon") as Texture2D); break;
case MessageType.Info: icon = infoIcon ?? (infoIcon = EditorGUIUtility.Load("console.infoicon") as Texture2D); break;
case MessageType.Error: icon = errorIcon ?? (errorIcon = EditorGUIUtility.Load("console.erroricon") as Texture2D); break;
}
EditorGUI.LabelField(position, GUIContent.none, new GUIContent(message, icon), HelpBoxRichTextStyle);
}
static public void HelpBoxRichText(string message, MessageType msgType)
{
Texture2D icon = null;
switch(msgType)
{
case MessageType.Warning: icon = warnIcon ?? (warnIcon = EditorGUIUtility.Load("console.warnicon") as Texture2D); break;
case MessageType.Info: icon = infoIcon ?? (infoIcon = EditorGUIUtility.Load("console.infoicon") as Texture2D); break;
case MessageType.Error: icon = errorIcon ?? (errorIcon = EditorGUIUtility.Load("console.erroricon") as Texture2D); break;
}
EditorGUILayout.LabelField(GUIContent.none, new GUIContent(message, icon), HelpBoxRichTextStyle);
}
}
}

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 26306333afc273640814fd7a7b3968e0
timeCreated: 1501149213
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8406aaacddc00584da67f20f62c179bd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,113 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: cfxr aura runic hdr ab nosp
m_Shader: {fileID: -6465566751694194690, guid: 1a29b4d27eb8b04479ef89c00dea533d,
type: 3}
m_ValidKeywords:
- _ALPHABLEND_ON
- _CFXR_HDR_BOOST
- _CFXR_SINGLE_CHANNEL
m_InvalidKeywords:
- _
- _CFXR_DITHERED_SHADOWS_OFF
- _CFXR_OVERLAYBLEND_RGBA
- _CFXR_OVERLAYTEX_OFF
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DissolveTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DitherCustom:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: ccb58def4933d4e46b7a1fc023bf6259, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OverlayTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SecondColorTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BacklightTransmittance: 1
- _BlendingType: 0
- _BumpScale: 1
- _CFXR_DITHERED_SHADOWS: 0
- _CFXR_OVERLAYBLEND: 0
- _CFXR_OVERLAYTEX: 0
- _Cutoff: 0.1
- _DirLightScreenAtten: 1
- _DirectLightingRamp: 1
- _DissolveSmooth: 0.1
- _Distort: 0.1
- _DoubleDissolve: 0
- _DstBlend: 10
- _EdgeFadePow: 1
- _FadeAlongU: 0
- _HdrBoost: 1
- _HdrMultiply: 2
- _IndirectLightingMix: 0.5
- _InvertDissolveTex: 0
- _LightingWorldPosStrength: 0.2
- _OVERLAYBLEND: 0
- _OVERLAYTEX: 0
- _SecondColorSmooth: 0.2
- _ShadowStrength: 1
- _SingleChannel: 1
- _SoftParticlesFadeDistanceFar: 1
- _SoftParticlesFadeDistanceNear: 0
- _SrcBlend: 5
- _UVDistortionAdd: 0
- _UseAlphaClip: 0
- _UseBackLighting: 0
- _UseDissolve: 0
- _UseDissolveOffsetUV: 0
- _UseEF: 0
- _UseEmission: 0
- _UseFB: 0
- _UseFontColor: 0
- _UseLighting: 0
- _UseLightingWorldPosOffset: 0
- _UseNormalMap: 0
- _UseSP: 0
- _UseSecondColor: 0
- _UseUV2Distortion: 0
- _UseUVDistortion: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 4.237095, g: 4.237095, b: 4.237095, a: 1}
- _DissolveScroll: {r: 0, g: 0, b: 0, a: 0}
- _DistortScrolling: {r: 0, g: 0, b: 1, a: 1}
- _OverlayTex_Scroll: {r: 0.1, g: 0.1, b: 1, a: 1}
- _ShadowColor: {r: 0, g: 0, b: 0, a: 1}
- _SoftParticlesFadeDistance: {r: 0, g: 1, b: 0, a: 0}
m_BuildTextureStacks: []

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cbb6f419bbe7c6e4d9ce7e0322aa267d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

@ -0,0 +1,121 @@
fileFormatVersion: 2
guid: ccb58def4933d4e46b7a1fc023bf6259
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
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
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 1
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: 2
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 10
textureShape: 1
singleChannelComponent: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 63
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,120 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: cfxr magic star hdr ab
m_Shader: {fileID: -6465566751694194690, guid: 1a29b4d27eb8b04479ef89c00dea533d,
type: 3}
m_ValidKeywords:
- _ALPHABLEND_ON
- _CFXR_DITHERED_SHADOWS_ON
- _FADING_ON
m_InvalidKeywords:
- _
- _CFXR_HDR_BOOST
- _CFXR_OVERLAYBLEND_RGBA
- _CFXR_OVERLAYTEX_OFF
- _CFXR_SINGLE_CHANNEL
- _SINGLECHANNEL_ON
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DissolveTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DitherCustom:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _GradientMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 081073d8f2209c949819e1e5872845b3, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OverlayTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SecondColorTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BacklightTransmittance: 1
- _BlendingType: 0
- _BumpScale: 1
- _CFXR_DITHERED_SHADOWS: 1
- _CFXR_OVERLAYBLEND: 0
- _CFXR_OVERLAYTEX: 0
- _Cutoff: 0.1
- _DirLightScreenAtten: 1
- _DirectLightingRamp: 1
- _DissolveSmooth: 0.1
- _Distort: 0.1
- _DoubleDissolve: 0
- _DstBlend: 10
- _EdgeFadePow: 1
- _FadeAlongU: 0
- _HdrBoost: 1
- _HdrMultiply: 10
- _IndirectLightingMix: 0.5
- _InvertDissolveTex: 0
- _LightingWorldPosStrength: 0.2
- _OVERLAYBLEND: 0
- _OVERLAYTEX: 0
- _SecondColorSmooth: 0.2
- _ShadowStrength: 0.5
- _SingleChannel: 1
- _SoftParticlesFadeDistanceFar: 2
- _SoftParticlesFadeDistanceNear: 0
- _SrcBlend: 5
- _UVDistortionAdd: 0
- _UseAlphaClip: 0
- _UseBackLighting: 0
- _UseDissolve: 0
- _UseDissolveOffsetUV: 0
- _UseEF: 0
- _UseEmission: 0
- _UseFB: 0
- _UseFontColor: 0
- _UseGradientMap: 0
- _UseLighting: 0
- _UseLightingWorldPosOffset: 0
- _UseNormalMap: 0
- _UseSP: 1
- _UseSecondColor: 0
- _UseUV2Distortion: 0
- _UseUVDistortion: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 3.8792846, g: 3.8792846, b: 3.8792846, a: 0}
- _DissolveScroll: {r: 0, g: 0, b: 0, a: 0}
- _DistortScrolling: {r: 0, g: 0, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 0}
- _OverlayTex_Scroll: {r: 0.1, g: 0.1, b: 1, a: 1}
- _ShadowColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 41e018a6cf0c896418fc0b89dda748c6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,162 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!43 &4300000
Mesh:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: cfxr magic star mesh
serializedVersion: 9
m_SubMeshes:
- serializedVersion: 2
firstByte: 0
indexCount: 78
topology: 0
baseVertex: 0
firstVertex: 0
vertexCount: 28
localAABB:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0.4375, y: 0.4375, z: 0}
m_Shapes:
vertices: []
shapes: []
channels: []
fullWeights: []
m_BindPose: []
m_BoneNameHashes:
m_RootBoneNameHash: 0
m_MeshCompression: 0
m_IsReadable: 1
m_KeepVertices: 1
m_KeepIndices: 1
m_IndexFormat: 0
m_IndexBuffer: 120005001a001a001300120012000b000500050004001a001a001400130012000c000b000b000a00050004001b001a001a001700140012000f000c000a0006000500040002001b001a0019001700170015001400120011000f000f000d000c000a0008000600020000001b00190018001700170016001500110010000f000f000e000d000a0009000800080007000600040003000200020001000000
m_VertexData:
serializedVersion: 2
m_VertexCount: 28
m_Channels:
- stream: 0
offset: 0
format: 0
dimension: 3
- stream: 0
offset: 12
format: 0
dimension: 3
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 24
format: 0
dimension: 2
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
m_DataSize: 896
_typelessdata: 0000b43e000000bd000000000000000000000000000080bf00005a3f0000f03e0000dc3e0000c0bc000000000000000000000000000080bf00006e3f0000f43e0000e03e000000bc000000000000000000000000000080bf0000703f0000fc3e0000e03e0000c03c000000000000000000000000000080bf0000703f0000063f0000703e0000903d000000000000000000000000000080bf00003c3f0000123f0000c03d0000083e000000000000000000000000000080bf0000183f0000223f0000603d0000703e000000000000000000000000ffff7fbf00000e3f00003c3f0000c03c0000d83e000000000000000000000000000080bf0000063f00006c3f0000003c0000e03e000000000000000000000000000080bf0000023f0000703f0000c0bc0000e03e000000000000000000000000000080bf0000f43e0000703f000090bd0000703e000000000000000000000000000080bf0000dc3e00003c3f000008be0000c03d000000000000000000000000000080bf0000bc3e0000183f000070be0000603d000000000000000000000000000080bf0000883e00000e3f0000b4be0000003d000000000000000000000000000080bf0000183e0000083f0000dcbe0000003d000000000000000000000000000080bf0000903d0000083f0000e0be0000003c000000000000000000000000000080bf0000803d0000023f0000e0be000080bc000000000000000000000000000080bf0000803d0000f83e0000d8be0000c0bc000000000000000000000000ffff7fbf0000a03d0000f43e000050be000060bd000000000000000000000000000080bf0000983e0000e43e0000c0bd000008be000000000000000000000000000080bf0000d03e0000bc3e000060bd000070be000000000000000000000000000080bf0000e43e0000883e000000bd0000b4be000000000000000000000000000080bf0000f03e0000183e000000bd0000dcbe000000000000000000000000000080bf0000f03e0000903d000000bc0000e0be000000000000000000000000000080bf0000fc3e0000803d0000803c0000e0be000000000000000000000000000080bf0000043f0000803d0000c03c0000d8be000000000000000000000000ffff7fbf0000063f0000a03d0000603d000050be000000000000000000000000000080bf00000e3f0000983e0000303e0000a0bd000000000000000000000000000080bf00002c3f0000d83e
m_CompressedMesh:
m_Vertices:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_UV:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Normals:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Tangents:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Weights:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_NormalSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_TangentSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_FloatColors:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_BoneIndices:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_Triangles:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_UVInfo: 0
m_LocalAABB:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0.4375, y: 0.4375, z: 0}
m_MeshUsageFlags: 0
m_BakedConvexCollisionMesh:
m_BakedTriangleCollisionMesh:
m_MeshMetrics[0]: 1
m_MeshMetrics[1]: 1
m_MeshOptimized: 0
m_StreamData:
offset: 0
size: 0
path:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bd8a92b47db41f644ae7188f06a986a2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4300000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

@ -0,0 +1,121 @@
fileFormatVersion: 2
guid: 081073d8f2209c949819e1e5872845b3
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
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
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 1
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: 2
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 10
textureShape: 1
singleChannelComponent: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 128
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 128
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 128
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 128
resizeAlgorithm: 0
textureFormat: 63
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,122 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: cfxr stretch ray blur hdr ab
m_Shader: {fileID: -6465566751694194690, guid: 1a29b4d27eb8b04479ef89c00dea533d,
type: 3}
m_ValidKeywords:
- _ALPHABLEND_ON
- _CFXR_HDR_BOOST
- _CFXR_SINGLE_CHANNEL
- _FADING_ON
m_InvalidKeywords:
- _
- _CFXR_DITHERED_SHADOWS_OFF
- _CFXR_OVERLAYBLEND_RGBA
- _CFXR_OVERLAYTEX_OFF
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DissolveTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DitherCustom:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _GradientMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: ea08f0da7f459e147ba80e6dd6e38bb9, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OverlayTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SecondColorTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AmbientColor: 0.5
- _AmbientIntensity: 1
- _BacklightTransmittance: 1
- _BlendingType: 0
- _BumpScale: 1
- _CFXR_DITHERED_SHADOWS: 0
- _CFXR_OVERLAYBLEND: 0
- _CFXR_OVERLAYTEX: 0
- _Cutoff: 0.1
- _DirLightScreenAtten: 1
- _DirectLightingRamp: 1
- _DissolveSmooth: 0.1
- _Distort: 0.1
- _DoubleDissolve: 0
- _DstBlend: 10
- _EdgeFadePow: 1
- _FadeAlongU: 0
- _HdrBoost: 1
- _HdrMultiply: 4
- _IndirectLightingMix: 0.5
- _InvertDissolveTex: 0
- _LightingWorldPosStrength: 0.2
- _OVERLAYBLEND: 0
- _OVERLAYTEX: 0
- _ReceivedShadowsStrength: 0.5
- _SecondColorSmooth: 0.2
- _ShadowStrength: 0.5
- _SingleChannel: 1
- _SoftParticlesFadeDistanceFar: 1
- _SoftParticlesFadeDistanceNear: 0
- _SrcBlend: 5
- _UVDistortionAdd: 0
- _UseAlphaClip: 0
- _UseBackLighting: 0
- _UseDissolve: 0
- _UseDissolveOffsetUV: 0
- _UseEF: 0
- _UseEmission: 0
- _UseFB: 0
- _UseFontColor: 0
- _UseGradientMap: 0
- _UseLighting: 0
- _UseLightingWorldPosOffset: 0
- _UseNormalMap: 0
- _UseSP: 1
- _UseSecondColor: 0
- _UseUV2Distortion: 0
- _UseUVDistortion: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 2, g: 2, b: 2, a: 0}
- _DissolveScroll: {r: 0, g: 0, b: 0, a: 0}
- _DistortScrolling: {r: 0, g: 0, b: 1, a: 1}
- _OverlayTex_Scroll: {r: 0.1, g: 0.1, b: 1, a: 1}
- _ShadowColor: {r: 0, g: 0, b: 0, a: 1}
- _SoftParticlesFadeDistance: {r: 0, g: 1, b: 0, a: 0}
m_BuildTextureStacks: []

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 935ab430b9a17de4caf00054e74116f4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@ -0,0 +1,121 @@
fileFormatVersion: 2
guid: ea08f0da7f459e147ba80e6dd6e38bb9
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
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
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 1
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: 2
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 10
textureShape: 1
singleChannelComponent: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: 63
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 01151e36115d4404180e5c816ab7907b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,287 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace CartoonFX
{
public partial class CFXR_Effect : MonoBehaviour
{
[System.Serializable]
public class CameraShake
{
public enum ShakeSpace
{
Screen,
World
}
static public bool editorPreview = true;
//--------------------------------------------------------------------------------------------------------------------------------
public bool enabled = false;
[Space]
public bool useMainCamera = true;
public List<Camera> cameras = new List<Camera>();
[Space]
public float delay = 0.0f;
public float duration = 1.0f;
public ShakeSpace shakeSpace = ShakeSpace.Screen;
public Vector3 shakeStrength = new Vector3(0.1f, 0.1f, 0.1f);
public AnimationCurve shakeCurve = AnimationCurve.Linear(0, 1, 1, 0);
[Space]
[Range(0, 0.1f)] public float shakesDelay = 0;
[System.NonSerialized] public bool isShaking;
Dictionary<Camera, Vector3> camerasPreRenderPosition = new Dictionary<Camera, Vector3>();
Vector3 shakeVector;
float delaysTimer;
//--------------------------------------------------------------------------------------------------------------------------------
// STATIC
// Use static methods to dispatch the Camera callbacks, to ensure that ScreenShake components are called in an order in PreRender,
// and in the _reverse_ order for PostRender, so that the final Camera position is the same as it is originally (allowing concurrent
// screen shake to be active)
static bool s_CallbackRegistered;
static List<CameraShake> s_CameraShakes = new List<CameraShake>();
#if UNITY_2019_1_OR_NEWER
static void OnPreRenderCamera_Static_URP(ScriptableRenderContext context, Camera cam)
{
OnPreRenderCamera_Static(cam);
}
static void OnPostRenderCamera_Static_URP(ScriptableRenderContext context, Camera cam)
{
OnPostRenderCamera_Static(cam);
}
#endif
static void OnPreRenderCamera_Static(Camera cam)
{
int count = s_CameraShakes.Count;
for (int i = 0; i < count; i++)
{
var ss = s_CameraShakes[i];
ss.onPreRenderCamera(cam);
}
}
static void OnPostRenderCamera_Static(Camera cam)
{
int count = s_CameraShakes.Count;
for (int i = count-1; i >= 0; i--)
{
var ss = s_CameraShakes[i];
ss.onPostRenderCamera(cam);
}
}
static void RegisterStaticCallback(CameraShake cameraShake)
{
s_CameraShakes.Add(cameraShake);
if (!s_CallbackRegistered)
{
#if UNITY_2019_1_OR_NEWER
#if UNITY_2019_3_OR_NEWER
if (GraphicsSettings.currentRenderPipeline == null)
#else
if (GraphicsSettings.renderPipelineAsset == null)
#endif
{
// Built-in Render Pipeline
Camera.onPreRender += OnPreRenderCamera_Static;
Camera.onPostRender += OnPostRenderCamera_Static;
}
else
{
// URP
RenderPipelineManager.beginCameraRendering += OnPreRenderCamera_Static_URP;
RenderPipelineManager.endCameraRendering += OnPostRenderCamera_Static_URP;
}
#else
Camera.onPreRender += OnPreRenderCamera_Static;
Camera.onPostRender += OnPostRenderCamera_Static;
#endif
s_CallbackRegistered = true;
}
}
static void UnregisterStaticCallback(CameraShake cameraShake)
{
s_CameraShakes.Remove(cameraShake);
if (s_CallbackRegistered && s_CameraShakes.Count == 0)
{
#if UNITY_2019_1_OR_NEWER
#if UNITY_2019_3_OR_NEWER
if (GraphicsSettings.currentRenderPipeline == null)
#else
if (GraphicsSettings.renderPipelineAsset == null)
#endif
{
// Built-in Render Pipeline
Camera.onPreRender -= OnPreRenderCamera_Static;
Camera.onPostRender -= OnPostRenderCamera_Static;
}
else
{
// URP
RenderPipelineManager.beginCameraRendering -= OnPreRenderCamera_Static_URP;
RenderPipelineManager.endCameraRendering -= OnPostRenderCamera_Static_URP;
}
#else
Camera.onPreRender -= OnPreRenderCamera_Static;
Camera.onPostRender -= OnPostRenderCamera_Static;
#endif
s_CallbackRegistered = false;
}
}
//--------------------------------------------------------------------------------------------------------------------------------
void onPreRenderCamera(Camera cam)
{
#if UNITY_EDITOR
//add scene view camera if necessary
if (SceneView.currentDrawingSceneView != null && SceneView.currentDrawingSceneView.camera == cam && !camerasPreRenderPosition.ContainsKey(cam))
{
camerasPreRenderPosition.Add(cam, cam.transform.localPosition);
}
#endif
if (isShaking && camerasPreRenderPosition.ContainsKey(cam))
{
camerasPreRenderPosition[cam] = cam.transform.localPosition;
if (Time.timeScale <= 0) return;
switch (shakeSpace)
{
case ShakeSpace.Screen: cam.transform.localPosition += cam.transform.rotation * shakeVector; break;
case ShakeSpace.World: cam.transform.localPosition += shakeVector; break;
}
}
}
void onPostRenderCamera(Camera cam)
{
if (camerasPreRenderPosition.ContainsKey(cam))
{
cam.transform.localPosition = camerasPreRenderPosition[cam];
}
}
public void fetchCameras()
{
#if UNITY_EDITOR
if (!EditorApplication.isPlayingOrWillChangePlaymode)
{
return;
}
#endif
foreach (var cam in cameras)
{
if (cam == null) continue;
camerasPreRenderPosition.Remove(cam);
}
cameras.Clear();
if (useMainCamera && Camera.main != null)
{
cameras.Add(Camera.main);
}
foreach (var cam in cameras)
{
if (cam == null) continue;
if (!camerasPreRenderPosition.ContainsKey(cam))
{
camerasPreRenderPosition.Add(cam, Vector3.zero);
}
}
}
public void StartShake()
{
if (isShaking)
{
StopShake();
}
isShaking = true;
RegisterStaticCallback(this);
}
public void StopShake()
{
isShaking = false;
shakeVector = Vector3.zero;
UnregisterStaticCallback(this);
}
public void animate(float time)
{
#if UNITY_EDITOR
if (!editorPreview && !EditorApplication.isPlaying)
{
shakeVector = Vector3.zero;
return;
}
#endif
float totalDuration = duration + delay;
if (time < totalDuration)
{
if (time < delay)
{
return;
}
if (!isShaking)
{
this.StartShake();
}
// duration of the camera shake
float delta = Mathf.Clamp01(time/totalDuration);
// delay between each camera move
if (shakesDelay > 0)
{
delaysTimer += Time.deltaTime;
if (delaysTimer < shakesDelay)
{
return;
}
else
{
while (delaysTimer >= shakesDelay)
{
delaysTimer -= shakesDelay;
}
}
}
var randomVec = new Vector3(Random.value, Random.value, Random.value);
var shakeVec = Vector3.Scale(randomVec, shakeStrength) * (Random.value > 0.5f ? -1 : 1);
shakeVector = shakeVec * shakeCurve.Evaluate(delta) * GLOBAL_CAMERA_SHAKE_MULTIPLIER;
}
else if (isShaking)
{
StopShake();
}
}
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04efd1cc0f5c31c4da57d931c6665976
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,878 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------
// Use the defines below to globally disable features:
//#define DISABLE_CAMERA_SHAKE
//#define DISABLE_LIGHTS
//#define DISABLE_CLEAR_BEHAVIOR
//--------------------------------------------------------------------------------------------------------------------------------
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace CartoonFX
{
[RequireComponent(typeof(ParticleSystem))]
[DisallowMultipleComponent]
public partial class CFXR_Effect : MonoBehaviour
{
// Change this value to easily tune the camera shake strength for all effects
const float GLOBAL_CAMERA_SHAKE_MULTIPLIER = 1.0f;
#if UNITY_EDITOR
[InitializeOnLoadMethod]
static void InitGlobalOptions()
{
AnimatedLight.editorPreview = EditorPrefs.GetBool("CFXR Light EditorPreview", true);
#if !DISABLE_CAMERA_SHAKE
CameraShake.editorPreview = EditorPrefs.GetBool("CFXR CameraShake EditorPreview", true);
#endif
}
#endif
public enum ClearBehavior
{
None,
Disable,
Destroy
}
[System.Serializable]
public class AnimatedLight
{
static public bool editorPreview = true;
public Light light;
public bool loop;
public bool animateIntensity;
public float intensityStart = 8f;
public float intensityEnd = 0f;
public float intensityDuration = 0.5f;
public AnimationCurve intensityCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
public bool perlinIntensity;
public float perlinIntensitySpeed = 1f;
public bool fadeIn;
public float fadeInDuration = 0.5f;
public bool fadeOut;
public float fadeOutDuration = 0.5f;
public bool animateRange;
public float rangeStart = 8f;
public float rangeEnd = 0f;
public float rangeDuration = 0.5f;
public AnimationCurve rangeCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
public bool perlinRange;
public float perlinRangeSpeed = 1f;
public bool animateColor;
public Gradient colorGradient;
public float colorDuration = 0.5f;
public AnimationCurve colorCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
public bool perlinColor;
public float perlinColorSpeed = 1f;
public void animate(float time)
{
#if UNITY_EDITOR
if (!editorPreview && !EditorApplication.isPlaying)
{
return;
}
#endif
if (light != null)
{
if (animateIntensity)
{
float delta = loop ? Mathf.Clamp01((time % intensityDuration)/intensityDuration) : Mathf.Clamp01(time/intensityDuration);
delta = perlinIntensity ? Mathf.PerlinNoise(Time.time * perlinIntensitySpeed, 0f) : intensityCurve.Evaluate(delta);
light.intensity = Mathf.LerpUnclamped(intensityEnd, intensityStart, delta);
if (fadeIn && time < fadeInDuration)
{
light.intensity *= Mathf.Clamp01(time / fadeInDuration);
}
}
if (animateRange)
{
float delta = loop ? Mathf.Clamp01((time % rangeDuration)/rangeDuration) : Mathf.Clamp01(time/rangeDuration);
delta = perlinRange ? Mathf.PerlinNoise(Time.time * perlinRangeSpeed, 10f) : rangeCurve.Evaluate(delta);
light.range = Mathf.LerpUnclamped(rangeEnd, rangeStart, delta);
}
if (animateColor)
{
float delta = loop ? Mathf.Clamp01((time % colorDuration)/colorDuration) : Mathf.Clamp01(time/colorDuration);
delta = perlinColor ? Mathf.PerlinNoise(Time.time * perlinColorSpeed, 0f) : colorCurve.Evaluate(delta);
light.color = colorGradient.Evaluate(delta);
}
}
}
public void animateFadeOut(float time)
{
if (fadeOut && light != null)
{
light.intensity *= 1.0f - Mathf.Clamp01(time / fadeOutDuration);
}
}
public void reset()
{
if (light != null)
{
if (animateIntensity)
{
light.intensity = (fadeIn || fadeOut) ? 0 : intensityEnd;
}
if (animateRange)
{
light.range = rangeEnd;
}
if (animateColor)
{
light.color = colorGradient.Evaluate(1f);
}
}
}
#region Animated Light Property Drawer
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(AnimatedLight))]
public class AnimatedLightDrawer : PropertyDrawer
{
SerializedProperty light;
SerializedProperty loop;
SerializedProperty animateIntensity;
SerializedProperty intensityStart;
SerializedProperty intensityEnd;
SerializedProperty intensityDuration;
SerializedProperty intensityCurve;
SerializedProperty perlinIntensity;
SerializedProperty perlinIntensitySpeed;
SerializedProperty fadeIn;
SerializedProperty fadeInDuration;
SerializedProperty fadeOut;
SerializedProperty fadeOutDuration;
SerializedProperty animateRange;
SerializedProperty rangeStart;
SerializedProperty rangeEnd;
SerializedProperty rangeDuration;
SerializedProperty rangeCurve;
SerializedProperty perlinRange;
SerializedProperty perlinRangeSpeed;
SerializedProperty animateColor;
SerializedProperty colorGradient;
SerializedProperty colorDuration;
SerializedProperty colorCurve;
SerializedProperty perlinColor;
SerializedProperty perlinColorSpeed;
void fetchProperties(SerializedProperty property)
{
light = property.FindPropertyRelative("light");
loop = property.FindPropertyRelative("loop");
animateIntensity = property.FindPropertyRelative("animateIntensity");
intensityStart = property.FindPropertyRelative("intensityStart");
intensityEnd = property.FindPropertyRelative("intensityEnd");
intensityDuration = property.FindPropertyRelative("intensityDuration");
intensityCurve = property.FindPropertyRelative("intensityCurve");
perlinIntensity = property.FindPropertyRelative("perlinIntensity");
perlinIntensitySpeed = property.FindPropertyRelative("perlinIntensitySpeed");
fadeIn = property.FindPropertyRelative("fadeIn");
fadeInDuration = property.FindPropertyRelative("fadeInDuration");
fadeOut = property.FindPropertyRelative("fadeOut");
fadeOutDuration = property.FindPropertyRelative("fadeOutDuration");
animateRange = property.FindPropertyRelative("animateRange");
rangeStart = property.FindPropertyRelative("rangeStart");
rangeEnd = property.FindPropertyRelative("rangeEnd");
rangeDuration = property.FindPropertyRelative("rangeDuration");
rangeCurve = property.FindPropertyRelative("rangeCurve");
perlinRange = property.FindPropertyRelative("perlinRange");
perlinRangeSpeed = property.FindPropertyRelative("perlinRangeSpeed");
animateColor = property.FindPropertyRelative("animateColor");
colorGradient = property.FindPropertyRelative("colorGradient");
colorDuration = property.FindPropertyRelative("colorDuration");
colorCurve = property.FindPropertyRelative("colorCurve");
perlinColor = property.FindPropertyRelative("perlinColor");
perlinColorSpeed = property.FindPropertyRelative("perlinColorSpeed");
}
static GUIContent[] ModePopupLabels = new GUIContent[] { new GUIContent("Curve"), new GUIContent("Perlin Noise") };
static GUIContent IntensityModeLabel = new GUIContent("Intensity Mode");
static GUIContent RangeModeLabel = new GUIContent("Range Mode");
static GUIContent ColorModeLabel = new GUIContent("Color Mode");
const float INDENT_WIDTH = 15f;
const float PADDING = 4f;
void startIndent(ref Rect rect)
{
EditorGUIUtility.labelWidth -= INDENT_WIDTH;
rect.xMin += INDENT_WIDTH;
}
void endIndent(ref Rect rect)
{
EditorGUIUtility.labelWidth += INDENT_WIDTH;
rect.xMin -= INDENT_WIDTH;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
fetchProperties(property);
Rect rect = EditorGUI.IndentedRect(position);
//Rect lineRect = rect;
//lineRect.height = 1;
//lineRect.y -= 2;
//EditorGUI.DrawRect(lineRect, Color.gray);
if (Event.current.type == EventType.Repaint)
{
EditorStyles.helpBox.Draw(rect, GUIContent.none, 0);
}
EditorGUIUtility.labelWidth -= INDENT_WIDTH;
rect.height = EditorGUIUtility.singleLineHeight;
rect.xMax -= PADDING;
rect.y += PADDING;
float propSpace = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(rect, light); rect.y += propSpace;
EditorGUI.PropertyField(rect, loop); rect.y += propSpace;
EditorGUI.PropertyField(rect, animateIntensity); rect.y += propSpace;
if (animateIntensity.boolValue)
{
startIndent(ref rect);
{
EditorGUI.PropertyField(rect, intensityStart); rect.y += propSpace;
EditorGUI.PropertyField(rect, intensityEnd); rect.y += propSpace;
int val = EditorGUI.Popup(rect, IntensityModeLabel, perlinIntensity.boolValue ? 1 : 0, ModePopupLabels); rect.y += propSpace;
if (val == 1 && !perlinIntensity.boolValue)
{
perlinIntensity.boolValue = true;
}
else if (val == 0 && perlinIntensity.boolValue)
{
perlinIntensity.boolValue = false;
}
startIndent(ref rect);
{
if (perlinIntensity.boolValue)
{
EditorGUI.PropertyField(rect, perlinIntensitySpeed); rect.y += propSpace;
}
else
{
EditorGUI.PropertyField(rect, intensityDuration); rect.y += propSpace;
EditorGUI.PropertyField(rect, intensityCurve); rect.y += propSpace;
}
}
endIndent(ref rect);
EditorGUI.PropertyField(rect, fadeIn); rect.y += propSpace;
if (fadeIn.boolValue)
{
startIndent(ref rect);
EditorGUI.PropertyField(rect, fadeInDuration); rect.y += propSpace;
endIndent(ref rect);
}
EditorGUI.PropertyField(rect, fadeOut); rect.y += propSpace;
if (fadeOut.boolValue)
{
startIndent(ref rect);
EditorGUI.PropertyField(rect, fadeOutDuration); rect.y += propSpace;
endIndent(ref rect);
}
}
endIndent(ref rect);
}
EditorGUI.PropertyField(rect, animateRange); rect.y += propSpace;
if (animateRange.boolValue)
{
startIndent(ref rect);
{
EditorGUI.PropertyField(rect, rangeStart); rect.y += propSpace;
EditorGUI.PropertyField(rect, rangeEnd); rect.y += propSpace;
int val = EditorGUI.Popup(rect, RangeModeLabel, perlinRange.boolValue ? 1 : 0, ModePopupLabels); rect.y += propSpace;
if (val == 1 && !perlinRange.boolValue)
{
perlinRange.boolValue = true;
}
else if (val == 0 && perlinRange.boolValue)
{
perlinRange.boolValue = false;
}
startIndent(ref rect);
{
if (perlinRange.boolValue)
{
EditorGUI.PropertyField(rect, perlinRangeSpeed); rect.y += propSpace;
}
else
{
EditorGUI.PropertyField(rect, rangeDuration); rect.y += propSpace;
EditorGUI.PropertyField(rect, rangeCurve); rect.y += propSpace;
}
}
endIndent(ref rect);
}
endIndent(ref rect);
}
EditorGUI.PropertyField(rect, animateColor); rect.y += propSpace;
if (animateColor.boolValue)
{
startIndent(ref rect);
{
EditorGUI.PropertyField(rect, colorGradient); rect.y += propSpace;
int val = EditorGUI.Popup(rect, ColorModeLabel, perlinColor.boolValue ? 1 : 0, ModePopupLabels); rect.y += propSpace;
if (val == 1 && !perlinColor.boolValue)
{
perlinColor.boolValue = true;
}
else if (val == 0 && perlinColor.boolValue)
{
perlinColor.boolValue = false;
}
startIndent(ref rect);
{
if (perlinColor.boolValue)
{
EditorGUI.PropertyField(rect, perlinColorSpeed); rect.y += propSpace;
}
else
{
EditorGUI.PropertyField(rect, colorDuration); rect.y += propSpace;
EditorGUI.PropertyField(rect, colorCurve); rect.y += propSpace;
}
}
endIndent(ref rect);
}
endIndent(ref rect);
}
EditorGUIUtility.labelWidth += INDENT_WIDTH;
if (GUI.changed)
{
property.serializedObject.ApplyModifiedProperties();
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
fetchProperties(property);
float propSpace = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
int count = 5;
if (animateIntensity.boolValue)
{
count += 3;
count += perlinIntensity.boolValue ? 1 : 2;
count += 1;
count += fadeIn.boolValue ? 1 : 0;
count += 1;
count += fadeOut.boolValue ? 1 : 0;
}
if (animateRange.boolValue)
{
count += 3;
count += perlinRange.boolValue ? 1 : 2;
}
if (animateColor.boolValue)
{
count += 2;
count += perlinColor.boolValue ? 1 : 2;
}
return count * propSpace + PADDING * 2;
}
}
#endif
#endregion
}
// ================================================================================================================================
// Globally disable features
public static bool GlobalDisableCameraShake;
public static bool GlobalDisableLights;
// ================================================================================================================================
[Tooltip("Defines an action to execute when the Particle System has completely finished playing and emitting particles.")]
public ClearBehavior clearBehavior = ClearBehavior.Destroy;
[Space]
public CameraShake cameraShake;
[Space]
public AnimatedLight[] animatedLights;
[Tooltip("Defines which Particle System to track to trigger light fading out.\nLeave empty if not using fading out.")]
public ParticleSystem fadeOutReference;
float time;
ParticleSystem rootParticleSystem;
[System.NonSerialized] MaterialPropertyBlock materialPropertyBlock;
[System.NonSerialized] Renderer particleRenderer;
// ================================================================================================================================
public void ResetState()
{
time = 0f;
fadingOutStartTime = 0f;
isFadingOut = false;
#if !DISABLE_LIGHTS
if (animatedLights != null)
{
foreach (var animLight in animatedLights)
{
animLight.reset();
}
}
#endif
#if !DISABLE_CAMERA_SHAKE
if (cameraShake != null && cameraShake.enabled)
{
cameraShake.StopShake();
}
#endif
}
#if !DISABLE_CAMERA_SHAKE || !DISABLE_CLEAR_BEHAVIOR
void Awake()
{
#if !DISABLE_CAMERA_SHAKE
if (cameraShake != null && cameraShake.enabled)
{
cameraShake.fetchCameras();
}
#endif
#if !DISABLE_CLEAR_BEHAVIOR
startFrameOffset = GlobalStartFrameOffset++;
#endif
// Detect if world position needs to be passed to the shader
particleRenderer = this.GetComponent<ParticleSystemRenderer>();
if (particleRenderer.sharedMaterial != null && particleRenderer.sharedMaterial.IsKeywordEnabled("_CFXR_LIGHTING_WPOS_OFFSET"))
{
materialPropertyBlock = new MaterialPropertyBlock();
}
}
#endif
void OnEnable()
{
foreach (var animLight in animatedLights)
{
if (animLight.light != null)
{
#if !DISABLE_LIGHTS
animLight.light.enabled = !GlobalDisableLights;
#else
animLight.light.enabled = false;
#endif
}
}
}
void OnDisable()
{
ResetState();
}
#if !DISABLE_LIGHTS || !DISABLE_CAMERA_SHAKE || !DISABLE_CLEAR_BEHAVIOR
const int CHECK_EVERY_N_FRAME = 20;
static int GlobalStartFrameOffset = 0;
int startFrameOffset;
void Update()
{
#if !DISABLE_LIGHTS || !DISABLE_CAMERA_SHAKE
time += Time.deltaTime;
Animate(time);
if (fadeOutReference != null && !fadeOutReference.isEmitting && (fadeOutReference.isPlaying || isFadingOut))
{
FadeOut(time);
}
#endif
#if !DISABLE_CLEAR_BEHAVIOR
if (clearBehavior != ClearBehavior.None)
{
if (rootParticleSystem == null)
{
rootParticleSystem = this.GetComponent<ParticleSystem>();
}
// Check isAlive every N frame, with an offset so that all active effects aren't checked at once
if ((Time.renderedFrameCount + startFrameOffset) % CHECK_EVERY_N_FRAME == 0)
{
if (!rootParticleSystem.IsAlive(true))
{
if (clearBehavior == ClearBehavior.Destroy)
{
GameObject.Destroy(this.gameObject);
}
else
{
this.gameObject.SetActive(false);
}
}
}
}
#endif
if (materialPropertyBlock != null)
{
particleRenderer.GetPropertyBlock(materialPropertyBlock);
materialPropertyBlock.SetVector("_GameObjectWorldPosition", this.transform.position);
particleRenderer.SetPropertyBlock(materialPropertyBlock);
}
}
#endif
#if !DISABLE_LIGHTS || !DISABLE_CAMERA_SHAKE
public void Animate(float time)
{
#if !DISABLE_LIGHTS
if (animatedLights != null && !GlobalDisableLights)
{
foreach (var animLight in animatedLights)
{
animLight.animate(time);
}
}
#endif
#if !DISABLE_CAMERA_SHAKE
if (cameraShake != null && cameraShake.enabled && !GlobalDisableCameraShake)
{
#if UNITY_EDITOR
if (!cameraShake.isShaking)
{
cameraShake.fetchCameras();
}
#endif
cameraShake.animate(time);
}
#endif
}
#endif
#if !DISABLE_LIGHTS
bool isFadingOut;
float fadingOutStartTime;
public void FadeOut(float time)
{
if (animatedLights == null)
{
return;
}
if (!isFadingOut)
{
isFadingOut = true;
fadingOutStartTime = time;
}
foreach (var animLight in animatedLights)
{
animLight.animateFadeOut(time - fadingOutStartTime);
}
}
#endif
#if UNITY_EDITOR
// Editor preview
// Detect when the Particle System is previewing and trigger this animation too
[System.NonSerialized] ParticleSystem _parentParticle;
ParticleSystem parentParticle
{
get
{
if (_parentParticle == null)
{
_parentParticle = this.GetComponent<ParticleSystem>();
}
return _parentParticle;
}
}
[System.NonSerialized] public bool editorUpdateRegistered;
[System.NonSerialized] bool particleWasStopped;
[System.NonSerialized] float particleTime;
[System.NonSerialized] float particleTimeUnwrapped;
void OnDestroy()
{
UnregisterEditorUpdate();
}
public void RegisterEditorUpdate()
{
var type = PrefabUtility.GetPrefabAssetType(this.gameObject);
var status = PrefabUtility.GetPrefabInstanceStatus(this.gameObject);
// Prefab in Project window
if ((type == PrefabAssetType.Regular || type == PrefabAssetType.Variant) && status == PrefabInstanceStatus.NotAPrefab)
{
return;
}
if (!editorUpdateRegistered)
{
EditorApplication.update += onEditorUpdate;
editorUpdateRegistered = true;
}
}
public void UnregisterEditorUpdate()
{
if (editorUpdateRegistered)
{
editorUpdateRegistered = false;
EditorApplication.update -= onEditorUpdate;
}
ResetState();
}
void onEditorUpdate()
{
if (EditorApplication.isPlayingOrWillChangePlaymode)
{
return;
}
if (this == null)
{
return;
}
var renderer = this.GetComponent<ParticleSystemRenderer>();
if (renderer.sharedMaterial != null && renderer.sharedMaterial.IsKeywordEnabled("_CFXR_LIGHTING_WPOS_OFFSET"))
{
if (materialPropertyBlock == null)
{
materialPropertyBlock = new MaterialPropertyBlock();
}
renderer.GetPropertyBlock(materialPropertyBlock);
materialPropertyBlock.SetVector("_GameObjectWorldPosition", this.transform.position);
renderer.SetPropertyBlock(materialPropertyBlock);
}
// Need to track unwrapped time when playing back from Editor
// because the parentParticle.time will be reset at each loop
float delta = parentParticle.time - particleTime;
if (delta < 0 && parentParticle.isPlaying)
{
delta = parentParticle.main.duration + delta;
if (delta > 0.1 || delta < 0)
{
// try to detect when "Restart" is pressed
ResetState();
particleTimeUnwrapped = 0;
delta = 0;
}
}
particleTimeUnwrapped += delta;
if (particleTime != parentParticle.time)
{
#if !DISABLE_CAMERA_SHAKE
if (cameraShake != null && cameraShake.enabled && parentParticle.time < particleTime && parentParticle.time < 0.05f)
{
cameraShake.StartShake();
}
#endif
#if !DISABLE_LIGHTS || !DISABLE_CAMERA_SHAKES
Animate(particleTimeUnwrapped);
if (!parentParticle.isEmitting)
{
FadeOut(particleTimeUnwrapped);
}
#endif
}
if (particleWasStopped != parentParticle.isStopped)
{
if (parentParticle.isStopped)
{
ResetState();
}
particleTimeUnwrapped = 0;
}
particleWasStopped = parentParticle.isStopped;
particleTime = parentParticle.time;
}
#endif
}
#if UNITY_EDITOR
[CustomEditor(typeof(CFXR_Effect))]
[CanEditMultipleObjects]
public class CFXR_Effect_Editor : Editor
{
bool? lightEditorPreview;
bool? shakeEditorPreview;
GUIStyle _PaddedRoundedRect;
GUIStyle PaddedRoundedRect
{
get
{
if (_PaddedRoundedRect == null)
{
_PaddedRoundedRect = new GUIStyle(EditorStyles.helpBox);
_PaddedRoundedRect.padding = new RectOffset(4, 4, 4, 4);
}
return _PaddedRoundedRect;
}
}
public override void OnInspectorGUI()
{
GlobalOptionsGUI();
#if DISABLE_CAMERA_SHAKE
EditorGUILayout.HelpBox("Camera Shake has been globally disabled in the code.\nThe properties remain to avoid data loss but the shaking won't be applied for any effect.", MessageType.Info);
#endif
base.OnInspectorGUI();
}
void GlobalOptionsGUI()
{
EditorGUILayout.BeginVertical(PaddedRoundedRect);
{
GUILayout.Label("Editor Preview:", EditorStyles.boldLabel);
if (lightEditorPreview == null)
{
lightEditorPreview = EditorPrefs.GetBool("CFXR Light EditorPreview", true);
}
bool lightPreview = EditorGUILayout.Toggle("Light Animations", lightEditorPreview.Value);
if (lightPreview != lightEditorPreview.Value)
{
lightEditorPreview = lightPreview;
EditorPrefs.SetBool("CFXR Light EditorPreview", lightPreview);
CFXR_Effect.AnimatedLight.editorPreview = lightPreview;
}
#if !DISABLE_CAMERA_SHAKE
if (shakeEditorPreview == null)
{
shakeEditorPreview = EditorPrefs.GetBool("CFXR CameraShake EditorPreview", true);
}
bool shakePreview = EditorGUILayout.Toggle("Camera Shake", shakeEditorPreview.Value);
if (shakePreview != shakeEditorPreview.Value)
{
shakeEditorPreview = shakePreview;
EditorPrefs.SetBool("CFXR CameraShake EditorPreview", shakePreview);
CFXR_Effect.CameraShake.editorPreview = shakePreview;
}
#endif
}
EditorGUILayout.EndVertical();
}
void OnEnable()
{
if (this.targets == null)
{
return;
}
foreach (var t in this.targets)
{
var cfxr_effect = t as CFXR_Effect;
if (cfxr_effect != null)
{
if (isPrefabSource(cfxr_effect.gameObject))
{
return;
}
cfxr_effect.RegisterEditorUpdate();
}
}
}
void OnDisable()
{
if (this.targets == null)
{
return;
}
foreach (var t in this.targets)
{
// Can be null if GameObject has been destroyed
var cfxr_effect = t as CFXR_Effect;
if (cfxr_effect != null)
{
if (isPrefabSource(cfxr_effect.gameObject))
{
return;
}
cfxr_effect.UnregisterEditorUpdate();
}
}
}
static bool isPrefabSource(GameObject gameObject)
{
var assetType = PrefabUtility.GetPrefabAssetType(gameObject);
var prefabType = PrefabUtility.GetPrefabInstanceStatus(gameObject);
return ((assetType == PrefabAssetType.Regular || assetType == PrefabAssetType.Variant) && prefabType == PrefabInstanceStatus.NotAPrefab);
}
}
#endif
}
;

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9205bc1bbacc90040a998067b5643d16
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,195 @@
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace CartoonFX
{
[RequireComponent(typeof(ParticleSystem))]
public class CFXR_EmissionBySurface : MonoBehaviour
{
public bool active = true;
public float particlesPerUnit = 10;
[Tooltip("This is to avoid slowdowns in the Editor if the value gets too high")] public float maxEmissionRate = 5000;
[HideInInspector] public float density = 0;
bool attachedToEditor;
ParticleSystem ps;
#if UNITY_EDITOR
void OnValidate()
{
this.hideFlags = HideFlags.DontSaveInBuild;
CalculateAndUpdateEmission();
}
internal void AttachToEditor()
{
if (attachedToEditor) return;
EditorApplication.update += OnEditorUpdate;
attachedToEditor = true;
}
internal void DetachFromEditor()
{
if (!attachedToEditor) return;
EditorApplication.update -= OnEditorUpdate;
attachedToEditor = false;
}
void OnEditorUpdate()
{
CalculateAndUpdateEmission();
if (!System.Array.Exists(Selection.gameObjects, item => item == this.gameObject))
{
DetachFromEditor();
}
}
void CalculateAndUpdateEmission()
{
if (!active) return;
if (this == null) return;
if (ps == null) ps = this.GetComponent<ParticleSystem>();
density = CalculateShapeDensity(ps.shape, ps.main.scalingMode == ParticleSystemScalingMode.Shape, this.transform);
if (density == 0) return;
float emissionOverTime = density * particlesPerUnit;
ParticleSystem.EmissionModule emission = ps.emission;
if (Math.Abs(emission.rateOverTime.constant - emissionOverTime) > 0.1f)
{
emission.rateOverTime = Mathf.Min(maxEmissionRate, emissionOverTime);
}
}
float CalculateShapeDensity(ParticleSystem.ShapeModule shapeModule, bool isShapeScaling, Transform transform)
{
float arcPercentage = Mathf.Max(0.01f, shapeModule.arc / 360f);
float thicknessPercentage = Mathf.Max(0.01f, 1.0f - shapeModule.radiusThickness);
float scaleX = shapeModule.scale.x;
float scaleY = shapeModule.scale.y;
float scaleZ = shapeModule.scale.z;
if (isShapeScaling)
{
Vector3 localScale = Quaternion.Euler(shapeModule.rotation) * transform.localScale;
scaleX = scaleX * localScale.x;
scaleY = scaleY * localScale.y;
scaleZ = scaleZ * localScale.z;
}
scaleX = Mathf.Abs(scaleX);
scaleY = Mathf.Abs(scaleY);
scaleZ = Mathf.Abs(scaleZ);
switch (shapeModule.shapeType)
{
case ParticleSystemShapeType.Hemisphere:
case ParticleSystemShapeType.Sphere:
{
float rX = shapeModule.radius * scaleX;
float rY = shapeModule.radius * scaleY;
float rZ = shapeModule.radius * scaleZ;
float rmX = rX * thicknessPercentage;
float rmY = rY * thicknessPercentage;
float rmZ = rZ * thicknessPercentage;
float volume = (rX * rY * rZ - rmX * rmY * rmZ) * Mathf.PI;
if (shapeModule.shapeType == ParticleSystemShapeType.Hemisphere)
{
volume /= 2.0f;
}
return volume * arcPercentage;
}
case ParticleSystemShapeType.Cone:
{
float innerDisk = shapeModule.radius * scaleX * thicknessPercentage * shapeModule.radius * scaleY * thicknessPercentage * Mathf.PI;
float outerDisk = shapeModule.radius *scaleX * shapeModule.radius * scaleY * Mathf.PI;
return outerDisk - innerDisk;
}
case ParticleSystemShapeType.ConeVolume:
{
// cylinder volume, changing the angle doesn't actually extend the area from where the particles are emitted
float innerCylinder = shapeModule.radius * scaleX * thicknessPercentage * shapeModule.radius * scaleY * thicknessPercentage * Mathf.PI * shapeModule.length * scaleZ;
float outerCylinder = shapeModule.radius * scaleX * shapeModule.radius * scaleY * Mathf.PI * shapeModule.length * scaleZ;
return outerCylinder - innerCylinder;
}
case ParticleSystemShapeType.BoxEdge:
case ParticleSystemShapeType.BoxShell:
case ParticleSystemShapeType.Box:
{
return scaleX * scaleY * scaleZ;
}
case ParticleSystemShapeType.Circle:
{
float radiusX = shapeModule.radius * scaleX;
float radiusY = shapeModule.radius * scaleY;
float radiusMinX = radiusX * thicknessPercentage;
float radiusMinY = radiusY * thicknessPercentage;
float area = (radiusX * radiusY - radiusMinX * radiusMinY) * Mathf.PI;
return area * arcPercentage;
}
case ParticleSystemShapeType.SingleSidedEdge:
{
return shapeModule.radius * scaleX;
}
case ParticleSystemShapeType.Donut:
{
float outerDonutVolume = 2 * Mathf.PI * Mathf.PI * shapeModule.donutRadius * shapeModule.donutRadius * shapeModule.radius * arcPercentage;
float innerDonutVolume = 2 * Mathf.PI * Mathf.PI * shapeModule.donutRadius * thicknessPercentage * thicknessPercentage * shapeModule.donutRadius * shapeModule.radius * arcPercentage;
return (outerDonutVolume - innerDonutVolume) * scaleX * scaleY * scaleZ;
}
case ParticleSystemShapeType.Rectangle:
{
return scaleX * scaleY;
}
case ParticleSystemShapeType.Mesh:
case ParticleSystemShapeType.SkinnedMeshRenderer:
case ParticleSystemShapeType.MeshRenderer:
{
Debug.LogWarning( string.Format("[{0}] Calculating volume for a mesh is unsupported.", nameof(CFXR_EmissionBySurface)));
this.active = false;
return 0;
}
case ParticleSystemShapeType.Sprite:
case ParticleSystemShapeType.SpriteRenderer:
{
Debug.LogWarning( string.Format("[{0}] Calculating volume for a sprite is unsupported.", nameof(CFXR_EmissionBySurface)));
this.active = false;
return 0;
}
}
return 0;
}
#endif
}
#if UNITY_EDITOR
[CustomEditor(typeof(CFXR_EmissionBySurface))]
class CFXR_EmissionBySurface_Editor : Editor
{
CFXR_EmissionBySurface Target { get { return target as CFXR_EmissionBySurface; } }
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
GUILayout.Space(10);
EditorGUILayout.HelpBox("This Editor script will adapt the particle emission based on its shape density, so that you can resize it to fit a specific situation and the overall number of particles won't change.\n\nYou can scale the object to change the emission area, and you can open the 'Shape' module in the Particle System to visualize the emission area.", MessageType.Info);
EditorGUILayout.HelpBox("Calculated Density: " + Target.density, MessageType.None);
}
void OnEnable()
{
Target.AttachToEditor();
}
void OnDisable()
{
Target.DetachFromEditor();
}
}
#endif
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 403cb51292a8b3c4c870cccfc0e68659
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,419 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2022 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
using System.Collections.Generic;
using UnityEngine;
using Object = UnityEngine.Object;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace CartoonFX
{
[RequireComponent(typeof(ParticleSystem))]
public class CFXR_ParticleText : MonoBehaviour
{
[Header("Dynamic")]
[Tooltip("Allow changing the text at runtime with the 'UpdateText' method. If disabled, this script will be excluded from the build.")]
public bool isDynamic;
[Header("Text")]
[SerializeField] string text;
[SerializeField] float size = 1f;
[SerializeField] float letterSpacing = 0.44f;
[Header("Colors")]
[SerializeField] Color backgroundColor = new Color(0, 0, 0, 1);
[SerializeField] Color color1 = new Color(1, 1, 1, 1);
[SerializeField] Color color2 = new Color(0, 0, 1, 1);
[Header("Delay")]
[SerializeField] float delay = 0.05f;
[SerializeField] bool cumulativeDelay = false;
[Range(0f, 2f)] [SerializeField] float compensateLifetime = 0;
[Header("Misc")]
[SerializeField] float lifetimeMultiplier = 1f;
[Range(-90f, 90f)] [SerializeField] float rotation = -5f;
[SerializeField] float sortingFudgeOffset = 0.1f;
#pragma warning disable 0649
[SerializeField] CFXR_ParticleTextFontAsset font;
#pragma warning restore 0649
#if UNITY_EDITOR
[HideInInspector] [SerializeField] bool autoUpdateEditor = true;
void OnValidate()
{
if (text == null || font == null)
{
return;
}
// parse text to only allow valid characters
List<char> allowed = new List<char>(font.CharSequence.ToCharArray());
allowed.Add(' ');
char[] chars;
switch (font.letterCase)
{
case CFXR_ParticleTextFontAsset.LetterCase.Lower: chars = text.ToLowerInvariant().ToCharArray(); break;
case CFXR_ParticleTextFontAsset.LetterCase.Upper: chars = text.ToUpperInvariant().ToCharArray(); break;
default:
case CFXR_ParticleTextFontAsset.LetterCase.Both: chars = text.ToCharArray(); break;
}
string newText = "";
foreach (var c in chars)
{
if (allowed.Contains(c))
{
newText += c;
}
}
text = newText;
// prevent negative or 0 size
size = Mathf.Max(0.001f, size);
// delay so that we are allowed to destroy GameObjects
if (autoUpdateEditor && !EditorApplication.isPlayingOrWillChangePlaymode)
{
EditorApplication.delayCall += () => { UpdateText(null); };
}
}
#endif
void Awake()
{
if (!isDynamic)
{
Destroy(this);
return;
}
InitializeFirstParticle();
}
float baseLifetime;
float baseScaleX;
float baseScaleY;
float baseScaleZ;
Vector3 basePivot;
void InitializeFirstParticle()
{
if (isDynamic && this.transform.childCount == 0)
{
throw new System.Exception("[CFXR_ParticleText] A disabled GameObject with a ParticleSystem component is required as the first child when 'isDyanmic' is enabled, so that its settings can be used as a base for the generated characters.");
}
var ps = isDynamic ? this.transform.GetChild(0).GetComponent<ParticleSystem>() : this.GetComponent<ParticleSystem>();
var main = ps.main;
baseLifetime = main.startLifetime.constant;
baseScaleX = main.startSizeXMultiplier;
baseScaleY = main.startSizeYMultiplier;
baseScaleZ = main.startSizeZMultiplier;
basePivot = ps.GetComponent<ParticleSystemRenderer>().pivot;
if (isDynamic)
{
basePivot.x = 0; // make sure to not offset the text horizontally
ps.gameObject.SetActive(false); // ensure first child is inactive
ps.gameObject.name = "MODEL";
}
}
public void UpdateText(
string newText = null,
float? newSize = null,
Color? newColor1 = null, Color? newColor2 = null, Color? newBackgroundColor = null,
float? newLifetimeMultiplier = null
)
{
#if UNITY_EDITOR
// Only allow updating text for GameObjects that aren't prefabs, since we are possibly destroying/adding GameObjects
if (this == null)
{
return;
}
var prefabInstanceStatus = PrefabUtility.GetPrefabInstanceStatus(this);
var prefabAssetType = PrefabUtility.GetPrefabAssetType(this);
if (!(prefabInstanceStatus == PrefabInstanceStatus.NotAPrefab && prefabAssetType == PrefabAssetType.NotAPrefab))
{
return;
}
if (!Application.isPlaying)
{
InitializeFirstParticle();
}
#endif
if (Application.isPlaying && !isDynamic)
{
throw new System.Exception("[CFXR_ParticleText] You cannot update the text at runtime if it's not marked as dynamic.");
}
if (newText != null)
{
switch (font.letterCase)
{
case CFXR_ParticleTextFontAsset.LetterCase.Lower:
newText = newText.ToLowerInvariant();
break;
case CFXR_ParticleTextFontAsset.LetterCase.Upper:
newText = newText.ToUpperInvariant();
break;
}
// Verify that new text doesn't contain invalid characters
foreach (char c in newText)
{
if (char.IsWhiteSpace(c)) continue;
if (font.CharSequence.IndexOf(c) < 0)
{
throw new System.Exception("[CFXR_ParticleText] Invalid character supplied for the dynamic text: '" + c + "'\nThe allowed characters from the selected font are: " + font.CharSequence);
}
}
this.text = newText;
}
if (newSize != null) this.size = newSize.Value;
if (newColor1 != null) this.color1 = newColor1.Value;
if (newColor2 != null) this.color2 = newColor2.Value;
if (newBackgroundColor != null) this.backgroundColor = newBackgroundColor.Value;
if (newLifetimeMultiplier != null) this.lifetimeMultiplier = newLifetimeMultiplier.Value;
if (text == null || font == null || !font.IsValid())
{
return;
}
if (this.transform.childCount == 0)
{
throw new System.Exception("[CFXR_ParticleText] A disabled GameObject with a ParticleSystem component is required as the first child when 'isDyanmic' is enabled, so that its settings can be used as a base for the generated characters.");
}
// process text and calculate total width offset
float totalWidth = 0f;
int charCount = 0;
for (int i = 0; i < text.Length; i++)
{
if (char.IsWhiteSpace(text[i]))
{
if (i > 0)
{
totalWidth += letterSpacing * size;
}
}
else
{
charCount++;
if (i > 0)
{
int index = font.CharSequence.IndexOf(text[i]);
var sprite = font.CharSprites[index];
float charWidth = sprite.rect.width + font.CharKerningOffsets[index].post + font.CharKerningOffsets[index].pre;
totalWidth += (charWidth * 0.01f + letterSpacing) * size;
}
}
}
#if UNITY_EDITOR
// delete all children in editor, to make sure we refresh the particle systems based on the first one
if (!Application.isPlaying)
{
int length = this.transform.childCount;
int overflow = 0;
while (this.transform.childCount > 1)
{
Object.DestroyImmediate(this.transform.GetChild(this.transform.childCount - 1).gameObject);
overflow++;
if (overflow > 1000)
{
// just in case...
Debug.LogError("Overflow!");
break;
}
}
}
#endif
if (charCount > 0)
{
// calculate needed instances
int childCount = this.transform.childCount - (isDynamic ? 1 : 0); // first one is the particle source and always deactivated
if (childCount < charCount)
{
// instantiate new letter GameObjects if needed
GameObject model = isDynamic ? this.transform.GetChild(0).gameObject : null;
for (int i = childCount; i < charCount; i++)
{
var newLetter = isDynamic ? Instantiate(model, this.transform) : new GameObject();
if (!isDynamic)
{
newLetter.transform.SetParent(this.transform);
newLetter.AddComponent<ParticleSystem>();
}
newLetter.transform.localPosition = Vector3.zero;
newLetter.transform.localRotation = Quaternion.identity;
}
}
// update each letter
float offset = totalWidth / 2f;
totalWidth = 0f;
int currentChild = isDynamic ? 0 : -1;
// when not dynamic, we use CopySerialized to propagate the settings to the instances
var sourceParticle = isDynamic ? null : this.GetComponent<ParticleSystem>();
var sourceParticleRenderer = this.GetComponent<ParticleSystemRenderer>();
for (int i = 0; i < text.Length; i++)
{
var letter = text[i];
if (char.IsWhiteSpace(letter))
{
totalWidth += letterSpacing * size;
}
else
{
currentChild++;
int index = font.CharSequence.IndexOf(text[i]);
var sprite = font.CharSprites[index];
// calculate char particle size ratio
var ratio = size * sprite.rect.width / 50f;
// calculate char position
totalWidth += font.CharKerningOffsets[index].pre * 0.01f * size;
var position = (totalWidth - offset) / ratio;
float charWidth = sprite.rect.width + font.CharKerningOffsets[index].post;
totalWidth += (charWidth * 0.01f + letterSpacing) * size;
// update particle system for this letter
var letterObj = this.transform.GetChild(currentChild).gameObject;
letterObj.name = letter.ToString();
var ps = letterObj.GetComponent<ParticleSystem>();
#if UNITY_EDITOR
if (!isDynamic)
{
EditorUtility.CopySerialized(sourceParticle, ps);
ps.gameObject.SetActive(true);
}
#endif
var mainModule = ps.main;
mainModule.startSizeXMultiplier = baseScaleX * ratio;
mainModule.startSizeYMultiplier = baseScaleY * ratio;
mainModule.startSizeZMultiplier = baseScaleZ * ratio;
ps.textureSheetAnimation.SetSprite(0, sprite);
mainModule.startRotation = Mathf.Deg2Rad * rotation;
mainModule.startColor = backgroundColor;
var customData = ps.customData;
customData.enabled = true;
customData.SetColor(ParticleSystemCustomData.Custom1, color1);
customData.SetColor(ParticleSystemCustomData.Custom2, color2);
if (cumulativeDelay)
{
mainModule.startDelay = delay * i;
mainModule.startLifetime = Mathf.LerpUnclamped(baseLifetime, baseLifetime + (delay * (text.Length - i)), compensateLifetime / lifetimeMultiplier);
}
else
{
mainModule.startDelay = delay;
}
mainModule.startLifetime = mainModule.startLifetime.constant * lifetimeMultiplier;
// particle system renderer parameters
var particleRenderer = ps.GetComponent<ParticleSystemRenderer>();
#if UNITY_EDITOR
if (!isDynamic)
{
EditorUtility.CopySerialized(sourceParticleRenderer, particleRenderer);
}
#endif
particleRenderer.enabled = true;
particleRenderer.pivot = new Vector3(basePivot.x + position, basePivot.y, basePivot.z);
particleRenderer.sortingFudge += i * sortingFudgeOffset;
}
}
}
// set active state for needed letters only
for (int i = 1, l = this.transform.childCount; i < l; i++)
{
this.transform.GetChild(i).gameObject.SetActive(i <= charCount);
}
#if UNITY_EDITOR
// automatically play the effect in Editor
if (!Application.isPlaying)
{
this.GetComponent<ParticleSystem>().Clear(true);
this.GetComponent<ParticleSystem>().Play(true);
}
#endif
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(CFXR_ParticleText))]
public class ParticleTextEditor : Editor
{
CFXR_ParticleText CastTarget
{
get { return (CFXR_ParticleText) this.target; }
}
GUIContent GUIContent_AutoUpdateToggle = new GUIContent("Auto-update", "Automatically regenerate the text when a property is changed.");
GUIContent GUIContent_UpdateTextButton = new GUIContent(" Update Text ", "Regenerate the text and create new letter GameObjects if needed.");
public override void OnInspectorGUI()
{
var prefab = PrefabUtility.GetPrefabInstanceStatus(target);
if (prefab != PrefabInstanceStatus.NotAPrefab)
{
EditorGUILayout.HelpBox("Cartoon FX Particle Text doesn't work on Prefab Instances, as it needs to destroy/create children GameObjects.\nYou can right-click on the object, and select \"Unpack Prefab\" to make it an independent Game Object.",
MessageType.Warning);
return;
}
base.OnInspectorGUI();
serializedObject.Update();
SerializedProperty autoUpdateBool = serializedObject.FindProperty("autoUpdateEditor");
GUILayout.Space(8);
GUILayout.BeginHorizontal();
{
GUILayout.FlexibleSpace();
autoUpdateBool.boolValue = GUILayout.Toggle(autoUpdateBool.boolValue, GUIContent_AutoUpdateToggle, GUILayout.Height(30));
if (GUILayout.Button(GUIContent_UpdateTextButton, GUILayout.Height(30)))
{
CastTarget.UpdateText(null);
}
}
GUILayout.EndHorizontal();
if (GUI.changed)
{
serializedObject.ApplyModifiedProperties();
}
}
}
#endif
}

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 03c8102322ad0d04fa6ae3f17887e967
timeCreated: 1535104615
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,128 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace CartoonFX
{
public class CFXR_ParticleTextFontAsset : ScriptableObject
{
public enum LetterCase
{
Both,
Upper,
Lower
}
public string CharSequence = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?-.#@$ ";
public LetterCase letterCase = LetterCase.Upper;
public Sprite[] CharSprites;
public Kerning[] CharKerningOffsets;
[System.Serializable]
public class Kerning
{
public string name = "A";
public float pre = 0f;
public float post = 0f;
}
void OnValidate()
{
this.hideFlags = HideFlags.None;
if (CharKerningOffsets == null || CharKerningOffsets.Length != CharSequence.Length)
{
CharKerningOffsets = new Kerning[CharSequence.Length];
for (int i = 0; i < CharKerningOffsets.Length; i++)
{
CharKerningOffsets[i] = new Kerning() { name = CharSequence[i].ToString() };
}
}
}
public bool IsValid()
{
bool valid = !string.IsNullOrEmpty(CharSequence) && CharSprites != null && CharSprites.Length == CharSequence.Length && CharKerningOffsets != null && CharKerningOffsets.Length == CharSprites.Length;
if (!valid)
{
Debug.LogError(string.Format("Invalid ParticleTextFontAsset: '{0}'\n", this.name), this);
}
return valid;
}
#if UNITY_EDITOR
// [MenuItem("Tools/Create font asset")]
static void CreateFontAsset()
{
var instance = CreateInstance<CFXR_ParticleTextFontAsset>();
AssetDatabase.CreateAsset(instance, "Assets/Font.asset");
}
#endif
}
#if UNITY_EDITOR
[CustomEditor(typeof(CFXR_ParticleTextFontAsset))]
public class ParticleTextFontAssetEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
GUILayout.BeginHorizontal();
if (GUILayout.Button("Export Kerning"))
{
var ptfa = this.target as CFXR_ParticleTextFontAsset;
var path = EditorUtility.SaveFilePanel("Export Kerning Settings", Application.dataPath, ptfa.name + " kerning", ".txt");
if (!string.IsNullOrEmpty(path))
{
string output = "";
foreach (var k in ptfa.CharKerningOffsets)
{
output += k.name + "\t" + k.pre + "\t" + k.post + "\n";
}
System.IO.File.WriteAllText(path, output);
}
}
if (GUILayout.Button("Import Kerning"))
{
var path = EditorUtility.OpenFilePanel("Import Kerning Settings", Application.dataPath, "txt");
if (!string.IsNullOrEmpty(path))
{
var text = System.IO.File.ReadAllText(path);
var split = text.Split(new string[] { "\n" }, System.StringSplitOptions.RemoveEmptyEntries);
var ptfa = this.target as CFXR_ParticleTextFontAsset;
Undo.RecordObject(ptfa, "Import Kerning Settings");
List<CFXR_ParticleTextFontAsset.Kerning> kerningList = new List<CFXR_ParticleTextFontAsset.Kerning>(ptfa.CharKerningOffsets);
for (int i = 0; i < split.Length; i++)
{
var data = split[i].Split('\t');
foreach (var cko in kerningList)
{
if (cko.name == data[0])
{
cko.pre = float.Parse(data[1]);
cko.post = float.Parse(data[2]);
break;
}
}
}
ptfa.CharKerningOffsets = kerningList.ToArray();
}
}
GUILayout.EndHorizontal();
}
}
#endif
}

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: ffbf5f8b3f8ff3e49bbbf5495becc6b3
timeCreated: 1535104615
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8cae0f0a83438824eb3829def92d2ae6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,422 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
Shader "Cartoon FX/Remaster/Particle Ubershader"
{
Properties
{
//# Blending
//#
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Blend Source", Float) = 5
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Blend Destination", Float) = 10
[KeywordEnumNoPrefix(Alpha Blending, _ALPHABLEND_ON, Alpha Blending Premultiplied, _ALPHAPREMULTIPLY_ON, Multiplicative, _ALPHAMODULATE_ON, Additive, _CFXR_ADDITIVE)] _BlendingType ("Blending Type", Float) = 0
//#
[ToggleNoKeyword] _ZWrite ("Depth Write", Float) = 0
[Toggle(_ALPHATEST_ON)] _UseAlphaClip ("Alpha Clipping (Cutout)", Float) = 0
//# IF_KEYWORD _ALPHATEST_ON
_Cutoff ("Cutoff Threshold", Range(0.001,1)) = 0.1
//# END_IF
//# --------------------------------------------------------
[Toggle(_FADING_ON)] _UseSP ("Soft Particles", Float) = 0
//# IF_KEYWORD _FADING_ON
_SoftParticlesFadeDistanceNear ("Near Fade", Float) = 0
_SoftParticlesFadeDistanceFar ("Far Fade", Float) = 1
//# END_IF
//#
[Toggle(_CFXR_EDGE_FADING)] _UseEF ("Edge Fade", Float) = 0
//# IF_KEYWORD _CFXR_EDGE_FADING
_EdgeFadePow ("Edge Fade Power", Float) = 1
//# END_IF
//#
//# ========================================================
//# Effects
//#
[Toggle(_CFXR_DISSOLVE)] _UseDissolve ("Enable Dissolve", Float) = 0
//# IF_KEYWORD _CFXR_DISSOLVE
_DissolveTex ("Dissolve Texture", 2D) = "gray" {}
_DissolveSmooth ("Dissolve Smoothing", Range(0.0001,0.5)) = 0.1
[ToggleNoKeyword] _InvertDissolveTex ("Invert Dissolve Texture", Float) = 0
[ToggleNoKeyword] _DoubleDissolve ("Double Dissolve", Float) = 0
[Toggle] _UseDissolveOffsetUV ("Dissolve offset along X", Float) = 0
//# IF_PROPERTY _UseDissolveOffsetUV > 0
_DissolveScroll ("UV Scrolling", Vector) = (0,0,0,0)
//# END_IF
//# END_IF
//# --------------------------------------------------------
[Toggle(_CFXR_UV_DISTORTION)] _UseUVDistortion ("Enable UV Distortion", Float) = 0
//# IF_KEYWORD _CFXR_UV_DISTORTION
[NoScaleOffset] _DistortTex ("Distortion Texture", 2D) = "gray" {}
_DistortScrolling ("Scroll (XY) Tile (ZW)", Vector) = (0,0,1,1)
[Toggle] _UseUV2Distortion ("Use UV2", Float) = 0
_Distort ("Distortion Strength", Range(0,2.0)) = 0.1
[ToggleNoKeyword] _FadeAlongU ("Fade along Y", Float) = 0
[Toggle] _UVDistortionAdd ("Add to base UV", Float) = 0
//# END_IF
//# ========================================================
//# Colors
//#
[NoScaleOffset] _MainTex ("Texture", 2D) = "white" {}
[Toggle] _SingleChannel ("Single Channel Texture", Float) = 0
//# --------------------------------------------------------
[KeywordEnum(Off,1x,2x)] _CFXR_OVERLAYTEX ("Enable Overlay Texture", Float) = 0
//# IF_KEYWORD _CFXR_OVERLAYTEX_1X || _CFXR_OVERLAYTEX_2X
[Enum(RGBA,0,RGB,1,A,2)] _CFXR_OVERLAYBLEND ("Overlay Blend Channels", Float) = 0
[NoScaleOffset] _OverlayTex ("Overlay Texture", 2D) = "white" {}
_OverlayTex_Scroll ("Overlay Scrolling / Scale", Vector) = (0.1,0.1,1,1)
//# END_IF
//# --------------------------------------------------------
[Toggle(_FLIPBOOK_BLENDING)] _UseFB ("Flipbook Blending", Float) = 0
//# --------------------------------------------------------
[Toggle(_CFXR_SECONDCOLOR_LERP)] _UseSecondColor ("Secondary Vertex Color (TEXCOORD2)", Float) = 0
//# IF_KEYWORD _CFXR_SECONDCOLOR_LERP
[NoScaleOffset] _SecondColorTex ("Second Color Map", 2D) = "black" {}
_SecondColorSmooth ("Second Color Smoothing", Range(0.0001,0.5)) = 0.2
//# END_IF
//# --------------------------------------------------------
[Toggle(_CFXR_FONT_COLORS)] _UseFontColor ("Use Font Colors", Float) = 0
// //# --------------------------------------------------------
//
// [Toggle(_CFXR_GRADIENTMAP)] _UseGradientMap ("Gradient Map", Float) = 0
// //# IF_KEYWORD _CFXR_GRADIENTMAP
// [NoScaleOffset] _GradientMap ("Gradient Map", 2D) = "black" {}
// //# END_IF
//# --------------------------------------------------------
_HdrMultiply ("HDR Multiplier", Float) = 1
//# --------------------------------------------------------
//# Lighting
//#
[KeywordEnumNoPrefix(Off, _, Direct, _CFXR_LIGHTING_DIRECT, Indirect, _CFXR_LIGHTING_INDIRECT, Both, _CFXR_LIGHTING_ALL)] _UseLighting ("Mode", Float) = 0
//# IF_KEYWORD _CFXR_LIGHTING_DIRECT || _CFXR_LIGHTING_ALL
_DirectLightingRamp ("Direct Lighting Ramp", Range(0,1)) = 1.0
//# END_IF
//#
//# IF_KEYWORD _CFXR_LIGHTING_DIRECT || _CFXR_LIGHTING_INDIRECT || _CFXR_LIGHTING_ALL
[Toggle(_NORMALMAP)] _UseNormalMap ("Enable Normal Map", Float) = 0
//# IF_KEYWORD _NORMALMAP
[NoScaleOffset] _BumpMap ("Normal Map", 2D) = "bump" {}
_BumpScale ("Normal Scale", Range(-1, 1)) = 1.0
//# END_IF
//#
[Toggle(_EMISSION)] _UseEmission ("Enable Emission (TEXCOORD2)", Float) = 0
//#
[Toggle(_CFXR_LIGHTING_WPOS_OFFSET)] _UseLightingWorldPosOffset ("Enable World Pos. Offset", Float) = 0
//# IF_KEYWORD _CFXR_LIGHTING_WPOS_OFFSET
_LightingWorldPosStrength ("Offset Strength", Range(0,1)) = 0.2
//# END_IF
//#
[Toggle(_CFXR_LIGHTING_BACK)] _UseBackLighting ("Enable Backlighting", Float) = 0
//# IF_KEYWORD _CFXR_LIGHTING_BACK
_DirLightScreenAtten ("Dir. Light Screen Attenuation", Range(0, 5)) = 1.0
_BacklightTransmittance ("Backlight Transmittance", Range(0, 2)) = 1.0
//# END_IF
//#
//# IF_KEYWORD _CFXR_LIGHTING_INDIRECT || _CFXR_LIGHTING_ALL
_IndirectLightingMix ("Indirect Lighting Mix", Range(0,1)) = 0.5
//# END_IF
_ShadowColor ("Shadow Color", Color) = (0,0,0,1)
//#
//# END_IF
//# ========================================================
//# Shadows
//#
[KeywordEnum(Off,On,CustomTexture)] _CFXR_DITHERED_SHADOWS ("Dithered Shadows", Float) = 0
//# IF_KEYWORD _CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
_ShadowStrength ("Shadows Strength Max", Range(0,1)) = 1.0
//# IF_KEYWORD _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
_DitherCustom ("Dithering 3D Texture", 3D) = "black" {}
//# END_IF
//# END_IF
// _ReceivedShadowsStrength ("Received Shadows Strength", Range(0,1)) = 0.5
}
Category
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
}
Blend [_SrcBlend] [_DstBlend], One One
ZWrite [_ZWrite]
Cull Off
/*** URP ***/
//====================================================================================================================================
// Universal Rendering Pipeline
Subshader
{
Pass
{
Name "BASE_URP"
Tags { "LightMode"="UniversalForward" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:ParticleInstancingSetup
#pragma multi_compile_fog
//#pragma multi_compile_fwdbase
//#pragma multi_compile SHADOWS_SCREEN
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local_fragment _ _CFXR_UV_DISTORTION
// #pragma shader_feature_local _ _CFXR_GRADIENTMAP
#pragma shader_feature_local _ _CFXR_SECONDCOLOR_LERP _CFXR_FONT_COLORS
#pragma shader_feature_local_fragment _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local _ _CFXR_EDGE_FADING
#pragma shader_feature_local _ _CFXR_LIGHTING_DIRECT _CFXR_LIGHTING_INDIRECT _CFXR_LIGHTING_ALL
#pragma shader_feature_local _ _CFXR_LIGHTING_WPOS_OFFSET
#pragma shader_feature_local _ _CFXR_LIGHTING_BACK
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _NORMALMAP
#pragma shader_feature_local _ _EMISSION
#pragma shader_feature_local_fragment _ _FLIPBOOK_BLENDING
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local_fragment _ _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#define CFXR_URP
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
// Same as above with 'Universal2D' instead and DISABLE_SOFT_PARTICLES keyword
Pass
{
Name "BASE_URP"
Tags { "LightMode"="Universal2D" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:ParticleInstancingSetup
#pragma multi_compile_fog
//#pragma multi_compile_fwdbase
//#pragma multi_compile SHADOWS_SCREEN
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local_fragment _ _CFXR_UV_DISTORTION
// #pragma shader_feature_local _ _CFXR_GRADIENTMAP
#pragma shader_feature_local _ _CFXR_SECONDCOLOR_LERP _CFXR_FONT_COLORS
#pragma shader_feature_local_fragment _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local _ _CFXR_EDGE_FADING
#pragma shader_feature_local _ _CFXR_LIGHTING_DIRECT _CFXR_LIGHTING_INDIRECT _CFXR_LIGHTING_ALL
#pragma shader_feature_local _ _CFXR_LIGHTING_WPOS_OFFSET
#pragma shader_feature_local _ _CFXR_LIGHTING_BACK
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _NORMALMAP
#pragma shader_feature_local _ _EMISSION
#pragma shader_feature_local_fragment _ _FLIPBOOK_BLENDING
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local_fragment _ _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#define CFXR_UPR
#define DISABLE_SOFT_PARTICLES
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
//--------------------------------------------------------------------------------------------------------------------------------
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local_fragment _ _CFXR_UV_DISTORTION
#pragma shader_feature_local_fragment _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local_fragment _ _FLIPBOOK_BLENDING
#pragma shader_feature_local_fragment _ _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#pragma multi_compile_shadowcaster
#pragma shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
#pragma target 3.0 //needed for VPOS
#endif
#define CFXR_UPR
#define PASS_SHADOW_CASTER
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
/*** END URP ***/
/*** BIRP ***/
//====================================================================================================================================
// Built-in Rendering Pipeline
SubShader
{
Pass
{
Name "BASE"
Tags { "LightMode"="ForwardBase" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
//vertInstancingSetup writes to global, not allowed with DXC
// #pragma never_use_dxc
// #pragma target 2.5
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:vertInstancingSetup
#pragma multi_compile_particles
#pragma multi_compile_fog
//#pragma multi_compile_fwdbase
//#pragma multi_compile SHADOWS_SCREEN
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local_fragment _ _CFXR_UV_DISTORTION
// #pragma shader_feature_local _ _CFXR_GRADIENTMAP
#pragma shader_feature_local _ _CFXR_SECONDCOLOR_LERP _CFXR_FONT_COLORS
#pragma shader_feature_local_fragment _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local _ _CFXR_EDGE_FADING
#pragma shader_feature_local _ _CFXR_LIGHTING_DIRECT _CFXR_LIGHTING_INDIRECT _CFXR_LIGHTING_ALL
#pragma shader_feature_local _ _CFXR_LIGHTING_WPOS_OFFSET
#pragma shader_feature_local _ _CFXR_LIGHTING_BACK
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _NORMALMAP
#pragma shader_feature_local _ _EMISSION
#pragma shader_feature_local_fragment _ _FLIPBOOK_BLENDING
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local_fragment _ _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#include "UnityStandardParticleInstancing.cginc"
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
//--------------------------------------------------------------------------------------------------------------------------------
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
//vertInstancingSetup writes to global, not allowed with DXC
// #pragma never_use_dxc
// #pragma target 2.5
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:vertInstancingSetup
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local_fragment _ _CFXR_UV_DISTORTION
#pragma shader_feature_local_fragment _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local_fragment _ _FLIPBOOK_BLENDING
#pragma shader_feature_local_fragment _ _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#pragma multi_compile_shadowcaster
#pragma shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
#pragma target 3.0 //needed for VPOS
#endif
#include "UnityStandardParticleInstancing.cginc"
#define PASS_SHADOW_CASTER
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
/*** END BIRP ***/
}
CustomEditor "CartoonFX.MaterialInspector"
}

@ -0,0 +1,206 @@
fileFormatVersion: 2
guid: 1a29b4d27eb8b04479ef89c00dea533d
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: fe56ec25963759b49955809beeb4324b, type: 3}
detectedRenderPipeline: Built-In Render Pipeline
strippedLinesCount: 0
shaderSourceCode: "//--------------------------------------------------------------------------------------------------------------------------------\r\n//
Cartoon FX\r\n// (c) 2012-2020 Jean Moreno\r\n//--------------------------------------------------------------------------------------------------------------------------------\r\n\r\nShader
\"Cartoon FX/Remaster/Particle Ubershader\"\r\n{\r\n\tProperties\r\n\t{\r\n\t//#
Blending\r\n\t//#\r\n\t\t[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend (\"Blend
Source\", Float) = 5\r\n\t\t[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend
(\"Blend Destination\", Float) = 10\r\n\t\t[KeywordEnumNoPrefix(Alpha Blending,
_ALPHABLEND_ON, Alpha Blending Premultiplied, _ALPHAPREMULTIPLY_ON, Multiplicative,
_ALPHAMODULATE_ON, Additive, _CFXR_ADDITIVE)] _BlendingType (\"Blending Type\",
Float) = 0\r\n\r\n\t//# \r\n\t\t[ToggleNoKeyword] _ZWrite (\"Depth Write\", Float)
= 0\r\n\t\t[Toggle(_ALPHATEST_ON)] _UseAlphaClip (\"Alpha Clipping (Cutout)\",
Float) = 0\r\n\t//# IF_KEYWORD _ALPHATEST_ON\r\n\t\t_Cutoff (\"Cutoff Threshold\",
Range(0.001,1)) = 0.1\r\n\t//# END_IF\r\n\t\r\n\t//# --------------------------------------------------------\r\n\t\r\n\t\t[Toggle(_FADING_ON)]
_UseSP (\"Soft Particles\", Float) = 0\r\n\t//# IF_KEYWORD _FADING_ON\r\n\t\t_SoftParticlesFadeDistanceNear
(\"Near Fade\", Float) = 0\r\n\t\t_SoftParticlesFadeDistanceFar (\"Far Fade\",
Float) = 1\r\n\t//# END_IF\r\n\r\n\t//# \r\n\r\n\t\t[Toggle(_CFXR_EDGE_FADING)]
_UseEF (\"Edge Fade\", Float) = 0\r\n\t//# IF_KEYWORD _CFXR_EDGE_FADING\r\n\t\t_EdgeFadePow
(\"Edge Fade Power\", Float) = 1\r\n\t//# END_IF\r\n\r\n\t//# \r\n\r\n\t//# ========================================================\r\n\r\n\t//#
Effects\r\n\t//#\r\n\r\n\t\t[Toggle(_CFXR_DISSOLVE)] _UseDissolve (\"Enable Dissolve\",
Float) = 0\r\n\t//# IF_KEYWORD _CFXR_DISSOLVE\r\n\t\t_DissolveTex (\"Dissolve
Texture\", 2D) = \"gray\" {}\r\n\t\t_DissolveSmooth (\"Dissolve Smoothing\",
Range(0.0001,0.5)) = 0.1\r\n\t\t[ToggleNoKeyword] _InvertDissolveTex (\"Invert
Dissolve Texture\", Float) = 0\r\n\t\t[ToggleNoKeyword] _DoubleDissolve (\"Double
Dissolve\", Float) = 0\r\n\t\t[Toggle(_CFXR_DISSOLVE_ALONG_UV_X)] _UseDissolveOffsetUV
(\"Dissolve offset along X\", Float) = 0\r\n\t//# IF_KEYWORD _CFXR_DISSOLVE_ALONG_UV_X\r\n\t\t_DissolveScroll
(\"UV Scrolling\", Vector) = (0,0,0,0)\r\n\t//# END_IF\r\n\t//# END_IF\r\n\r\n\t//#
--------------------------------------------------------\r\n\r\n\t\t[Toggle(_CFXR_UV_DISTORTION)]
_UseUVDistortion (\"Enable UV Distortion\", Float) = 0\r\n\t//# IF_KEYWORD _CFXR_UV_DISTORTION\r\n\t\t\r\n\t\t[NoScaleOffset]
_DistortTex (\"Distortion Texture\", 2D) = \"gray\" {}\r\n\t\t_DistortScrolling
(\"Scroll (XY) Tile (ZW)\", Vector) = (0,0,1,1)\r\n\t\t[Toggle(_CFXR_UV2_DISTORTION)]
_UseUV2Distortion (\"Use UV2\", Float) = 0\r\n\t\t_Distort (\"Distortion Strength\",
Range(0,2.0)) = 0.1\r\n\t\t[ToggleNoKeyword] _FadeAlongU (\"Fade along Y\", Float)
= 0\r\n\t\t[Toggle(_CFXR_UV_DISTORTION_ADD)] _UVDistortionAdd (\"Add to base
UV\", Float) = 0\r\n\t//# END_IF\r\n\r\n\t//# ========================================================\r\n\r\n\t//#
Colors\r\n\t//#\r\n\r\n\t\t[NoScaleOffset] _MainTex (\"Texture\", 2D) = \"white\"
{}\r\n\t\t[Toggle(_CFXR_SINGLE_CHANNEL)] _SingleChannel (\"Single Channel Texture\",
Float) = 0\r\n\r\n\t//# --------------------------------------------------------\r\n\r\n\t\t[KeywordEnum(Off,1x,2x)]
_CFXR_OVERLAYTEX (\"Enable Overlay Texture\", Float) = 0\r\n\t//# IF_KEYWORD
_CFXR_OVERLAYTEX_1X || _CFXR_OVERLAYTEX_2X\r\n\t\t[KeywordEnum(RGBA,RGB,A)] _CFXR_OVERLAYBLEND
(\"Overlay Blend Channels\", Float) = 0\r\n\t\t[NoScaleOffset] _OverlayTex (\"Overlay
Texture\", 2D) = \"white\" {}\r\n\t\t_OverlayTex_Scroll (\"Overlay Scrolling
/ Scale\", Vector) = (0.1,0.1,1,1)\r\n\t//# END_IF\r\n\r\n\t//# --------------------------------------------------------\r\n\r\n\t\t[Toggle(_FLIPBOOK_BLENDING)]
_UseFB (\"Flipbook Blending\", Float) = 0\r\n\r\n\t//# --------------------------------------------------------\r\n\r\n\t\t[Toggle(_CFXR_SECONDCOLOR_LERP)]
_UseSecondColor (\"Secondary Vertex Color (TEXCOORD2)\", Float) = 0\r\n\t//#
IF_KEYWORD _CFXR_SECONDCOLOR_LERP\r\n\t\t[NoScaleOffset] _SecondColorTex (\"Second
Color Map\", 2D) = \"black\" {}\r\n\t\t_SecondColorSmooth (\"Second Color Smoothing\",
Range(0.0001,0.5)) = 0.2\r\n\t//# END_IF\r\n\r\n\t//# --------------------------------------------------------\r\n\r\n\t\t[Toggle(_CFXR_FONT_COLORS)]
_UseFontColor (\"Use Font Colors\", Float) = 0\r\n\r\n//\t//# --------------------------------------------------------\r\n//\r\n//\t[Toggle(_CFXR_GRADIENTMAP)]
_UseGradientMap (\"Gradient Map\", Float) = 0\r\n//\t//# IF_KEYWORD _CFXR_GRADIENTMAP\r\n//\t\t[NoScaleOffset]
_GradientMap (\"Gradient Map\", 2D) = \"black\" {}\r\n//\t//# END_IF\r\n\r\n\t//#
--------------------------------------------------------\r\n\r\n\t\t[Toggle(_CFXR_HDR_BOOST)]
_HdrBoost (\"Enable HDR Multiplier\", Float) = 0\r\n\t//# IF_KEYWORD _CFXR_HDR_BOOST\r\n\t\t
_HdrMultiply (\"HDR Multiplier\", Float) = 2\r\n\t//# END_IF\r\n\r\n\t//# --------------------------------------------------------\r\n\t\r\n\t//#
Lighting\r\n\t//#\r\n\r\n\t\t[KeywordEnumNoPrefix(Off, _, Direct, _CFXR_LIGHTING_DIRECT,
Indirect, _CFXR_LIGHTING_INDIRECT, Both, _CFXR_LIGHTING_ALL)] _UseLighting (\"Mode\",
Float) = 0\r\n\t//# IF_KEYWORD _CFXR_LIGHTING_DIRECT || _CFXR_LIGHTING_ALL\r\n\t\t_DirectLightingRamp
(\"Direct Lighting Ramp\", Range(0,1)) = 1.0\r\n\t//# END_IF\r\n\t//# \r\n\t//#
IF_KEYWORD _CFXR_LIGHTING_DIRECT || _CFXR_LIGHTING_INDIRECT || _CFXR_LIGHTING_ALL\r\n\t\t[Toggle(_NORMALMAP)]
_UseNormalMap (\"Enable Normal Map\", Float) = 0\r\n\t//# IF_KEYWORD _NORMALMAP\r\n\t\t[NoScaleOffset]
_BumpMap (\"Normal Map\", 2D) = \"bump\" {}\r\n\t\t_BumpScale (\"Normal Scale\",
Range(-1, 1)) = 1.0\r\n\t//# END_IF\r\n\t//# \r\n\t\t[Toggle(_EMISSION)] _UseEmission
(\"Enable Emission (TEXCOORD2)\", Float) = 0\r\n\t//# \r\n\t\t[Toggle(_CFXR_LIGHTING_WPOS_OFFSET)]
_UseLightingWorldPosOffset (\"Enable World Pos. Offset\", Float) = 0\r\n\t//#
IF_KEYWORD _CFXR_LIGHTING_WPOS_OFFSET\r\n\t\t_LightingWorldPosStrength (\"Offset
Strength\", Range(0,1)) = 0.2\r\n\t//# END_IF\r\n\t//# \r\n\t\t[Toggle(_CFXR_LIGHTING_BACK)]
_UseBackLighting (\"Enable Backlighting\", Float) = 0\r\n\t//# IF_KEYWORD _CFXR_LIGHTING_BACK\r\n\t\t_DirLightScreenAtten
(\"Dir. Light Screen Attenuation\", Range(0, 5)) = 1.0\r\n\t\t_BacklightTransmittance
(\"Backlight Transmittance\", Range(0, 2)) = 1.0\r\n\t//# END_IF\r\n\t//# \r\n\t//#
IF_KEYWORD _CFXR_LIGHTING_INDIRECT || _CFXR_LIGHTING_ALL\r\n\t\t_IndirectLightingMix
(\"Indirect Lighting Mix\", Range(0,1)) = 0.5\r\n\t//# END_IF\r\n\t\t_ShadowColor
(\"Shadow Color\", Color) = (0,0,0,1)\r\n\t//# \r\n\t//# END_IF\r\n\r\n\t//#
========================================================\r\n\t//# Shadows\r\n\t//#\r\n\r\n\t\t[KeywordEnum(Off,On,CustomTexture)]
_CFXR_DITHERED_SHADOWS (\"Dithered Shadows\", Float) = 0\r\n\t//# IF_KEYWORD
_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE\r\n\t\t_ShadowStrength\t\t(\"Shadows
Strength Max\", Range(0,1)) = 1.0\r\n\t\t//#\tIF_KEYWORD _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE\r\n\t\t_DitherCustom\t\t(\"Dithering
3D Texture\", 3D) = \"black\" {}\r\n\t\t//#\tEND_IF\r\n\t//# END_IF\r\n\r\n//\t\t_ReceivedShadowsStrength
(\"Received Shadows Strength\", Range(0,1)) = 0.5\r\n\t}\r\n\t\r\n\tCategory\r\n\t{\r\n\t\tTags\r\n\t\t{\r\n\t\t\t\"Queue\"=\"Transparent\"\r\n\t\t\t\"IgnoreProjector\"=\"True\"\r\n\t\t\t\"RenderType\"=\"Transparent\"\r\n\t\t\t\"PreviewType\"=\"Plane\"\r\n\t\t}\r\n\r\n\t\tBlend
[_SrcBlend] [_DstBlend], One One\r\n\t\tZWrite [_ZWrite]\r\n\t\tCull Off\r\n\r\n\t\t//====================================================================================================================================\r\n\t\t//
Universal Rendering Pipeline\r\n\r\n\t\tSubshader\r\n\t\t{\r\n\t\t\tPass\r\n\t\t\t{\r\n\t\t\t\tName
\"BASE_URP\"\r\n\t\t\t\tTags { \"LightMode\"=\"UniversalForward\" }\r\n\r\n\t\t\t\tCGPROGRAM\r\n\r\n\t\t\t\t#pragma
vertex vertex_program\r\n\t\t\t\t#pragma fragment fragment_program\r\n\t\t\t\t\r\n\t\t\t\t#pragma
target 2.0\r\n\t\t\t\t\r\n\t\t\t\t// #pragma multi_compile_instancing\r\n\t\t\t\t//
#pragma instancing_options procedural:ParticleInstancingSetup\r\n\r\n\t\t\t\t#pragma
multi_compile_fog\r\n\t\t\t\t//#pragma multi_compile_fwdbase\r\n\t\t\t\t//#pragma
multi_compile SHADOWS_SCREEN\r\n\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_DISSOLVE\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_DISSOLVE_ALONG_UV_X\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_UV_DISTORTION\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_UV2_DISTORTION\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_UV_DISTORTION_ADD\r\n\t\t\t\t// #pragma shader_feature_local _ _CFXR_GRADIENTMAP\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_SECONDCOLOR_LERP _CFXR_FONT_COLORS\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_HDR_BOOST\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_EDGE_FADING\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_LIGHTING_DIRECT
_CFXR_LIGHTING_INDIRECT _CFXR_LIGHTING_ALL\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_LIGHTING_WPOS_OFFSET\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_LIGHTING_BACK\r\n\r\n\t\t\t\t//
Using the same keywords as Unity's Standard Particle shader to minimize project-wide
keyword usage\r\n\t\t\t\t#pragma shader_feature_local _ _NORMALMAP\r\n\t\t\t\t#pragma
shader_feature_local _ _EMISSION\r\n\t\t\t\t#pragma shader_feature_local _ _FLIPBOOK_BLENDING\r\n\t\t\t\t#pragma
shader_feature_local _ _FADING_ON\r\n\t\t\t\t#pragma shader_feature_local _ _ALPHATEST_ON\r\n\t\t\t\t#pragma
shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
_CFXR_ADDITIVE\r\n\r\n\t\t\t\t#define CFXR_URP\r\n\t\t\t\t#define CFXR_UBERSHADER\r\n\t\t\t\t#include
\"CFXR_PASSES.cginc\"\r\n\r\n\t\t\t\tENDCG\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Same
as above with 'Universal2D' instead and DISABLE_SOFT_PARTICLES keyword\r\n\t\t\tPass\r\n\t\t\t{\r\n\t\t\t\tName
\"BASE_URP\"\r\n\t\t\t\tTags { \"LightMode\"=\"Universal2D\" }\r\n\r\n\t\t\t\tCGPROGRAM\r\n\r\n\t\t\t\t#pragma
vertex vertex_program\r\n\t\t\t\t#pragma fragment fragment_program\r\n\t\t\t\t\r\n\t\t\t\t#pragma
target 2.0\r\n\t\t\t\t\r\n\t\t\t\t// #pragma multi_compile_instancing\r\n\t\t\t\t//
#pragma instancing_options procedural:ParticleInstancingSetup\r\n\r\n\t\t\t\t#pragma
multi_compile_fog\r\n\t\t\t\t//#pragma multi_compile_fwdbase\r\n\t\t\t\t//#pragma
multi_compile SHADOWS_SCREEN\r\n\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_DISSOLVE\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_DISSOLVE_ALONG_UV_X\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_UV_DISTORTION\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_UV2_DISTORTION\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_UV_DISTORTION_ADD\r\n\t\t\t\t// #pragma shader_feature_local _ _CFXR_GRADIENTMAP\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_SECONDCOLOR_LERP _CFXR_FONT_COLORS\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_HDR_BOOST\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_EDGE_FADING\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_LIGHTING_DIRECT
_CFXR_LIGHTING_INDIRECT _CFXR_LIGHTING_ALL\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_LIGHTING_WPOS_OFFSET\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_LIGHTING_BACK\r\n\r\n\t\t\t\t//
Using the same keywords as Unity's Standard Particle shader to minimize project-wide
keyword usage\r\n\t\t\t\t#pragma shader_feature_local _ _NORMALMAP\r\n\t\t\t\t#pragma
shader_feature_local _ _EMISSION\r\n\t\t\t\t#pragma shader_feature_local _ _FLIPBOOK_BLENDING\r\n\t\t\t\t#pragma
shader_feature_local _ _FADING_ON\r\n\t\t\t\t#pragma shader_feature_local _ _ALPHATEST_ON\r\n\t\t\t\t#pragma
shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
_CFXR_ADDITIVE\r\n\r\n\t\t\t\t#define CFXR_UPR\r\n\t\t\t\t#define DISABLE_SOFT_PARTICLES\r\n\t\t\t\t#define
CFXR_UBERSHADER\r\n\t\t\t\t#include \"CFXR_PASSES.cginc\"\r\n\r\n\t\t\t\tENDCG\r\n\t\t\t}\r\n\r\n\t\t\t//--------------------------------------------------------------------------------------------------------------------------------\r\n\r\n\t\t\tPass\r\n\t\t\t{\r\n\t\t\t\tName
\"ShadowCaster\"\r\n\t\t\t\tTags { \"LightMode\" = \"ShadowCaster\" }\r\n\r\n\t\t\t\tBlendOp
Add\r\n\t\t\t\tBlend One Zero\r\n\t\t\t\tZWrite On\r\n\t\t\t\tCull Off\r\n\r\n\t\t\t\tCGPROGRAM\r\n\r\n\t\t\t\t#pragma
vertex vertex_program\r\n\t\t\t\t#pragma fragment fragment_program\r\n\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_SINGLE_CHANNEL\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_DISSOLVE\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_DISSOLVE_ALONG_UV_X\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_UV_DISTORTION\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_UV2_DISTORTION\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_UV_DISTORTION_ADD\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB\r\n\t\t\t\t#pragma
shader_feature_local _ _FLIPBOOK_BLENDING\r\n\r\n\t\t\t\t#pragma shader_feature_local
_ _ALPHATEST_ON\r\n\t\t\t\t#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
_ALPHAMODULATE_ON _CFXR_ADDITIVE\r\n\r\n\t\t\t\t#pragma multi_compile_shadowcaster\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE\r\n\r\n\t\t\t#if
(_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)\r\n\t\t\t\t#pragma
target 3.0\t\t//needed for VPOS\r\n\t\t\t#endif\r\n\r\n\t\t\t\t#define CFXR_UPR\r\n\t\t\t\t#define
PASS_SHADOW_CASTER\r\n\t\t\t\t#define CFXR_UBERSHADER\r\n\t\t\t\t#include \"CFXR_PASSES.cginc\"\r\n\r\n\t\t\t\tENDCG\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//====================================================================================================================================\r\n\t\t//
Built-in Rendering Pipeline\r\n\r\n\t\tSubShader\r\n\t\t{\r\n\t\t\tPass\r\n\t\t\t{\r\n\t\t\t\tName
\"BASE\"\r\n\t\t\t\tTags { \"LightMode\"=\"ForwardBase\" }\r\n\r\n\t\t\t\tCGPROGRAM\r\n\r\n\t\t\t\t#pragma
vertex vertex_program\r\n\t\t\t\t#pragma fragment fragment_program\r\n\r\n\t\t\t\t//vertInstancingSetup
writes to global, not allowed with DXC\r\n\t\t\t\t// #pragma never_use_dxc\r\n\t\t\t\t//
#pragma target 2.5\r\n\t\t\t\t// #pragma multi_compile_instancing\r\n\t\t\t\t//
#pragma instancing_options procedural:vertInstancingSetup\r\n\r\n\t\t\t\t#pragma
multi_compile_particles\r\n\t\t\t\t#pragma multi_compile_fog\r\n\t\t\t\t//#pragma
multi_compile_fwdbase\r\n\t\t\t\t//#pragma multi_compile SHADOWS_SCREEN\r\n\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_SINGLE_CHANNEL\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_DISSOLVE\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_DISSOLVE_ALONG_UV_X\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_UV_DISTORTION\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_UV2_DISTORTION\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_UV_DISTORTION_ADD\r\n\t\t\t\t//
#pragma shader_feature_local _ _CFXR_GRADIENTMAP\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_SECONDCOLOR_LERP _CFXR_FONT_COLORS\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_HDR_BOOST\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_EDGE_FADING\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_LIGHTING_DIRECT _CFXR_LIGHTING_INDIRECT _CFXR_LIGHTING_ALL\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_LIGHTING_WPOS_OFFSET\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_LIGHTING_BACK\r\n\r\n\t\t\t\t// Using the same keywords as Unity's Standard
Particle shader to minimize project-wide keyword usage\r\n\t\t\t\t#pragma shader_feature_local
_ _NORMALMAP\r\n\t\t\t\t#pragma shader_feature_local _ _EMISSION\r\n\t\t\t\t#pragma
shader_feature_local _ _FLIPBOOK_BLENDING\r\n\t\t\t\t#pragma shader_feature_local
_ _FADING_ON\r\n\t\t\t\t#pragma shader_feature_local _ _ALPHATEST_ON\r\n\t\t\t\t#pragma
shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
_CFXR_ADDITIVE\r\n\r\n\t\t\t\t#include \"UnityStandardParticleInstancing.cginc\"\r\n\t\t\t\t#define
CFXR_UBERSHADER\r\n\t\t\t\t#include \"CFXR_PASSES.cginc\"\r\n\r\n\t\t\t\tENDCG\r\n\t\t\t}\r\n\r\n\t\t\t//--------------------------------------------------------------------------------------------------------------------------------\r\n\r\n\t\t\tPass\r\n\t\t\t{\r\n\t\t\t\tName
\"ShadowCaster\"\r\n\t\t\t\tTags { \"LightMode\" = \"ShadowCaster\" }\r\n\r\n\t\t\t\tBlendOp
Add\r\n\t\t\t\tBlend One Zero\r\n\t\t\t\tZWrite On\r\n\t\t\t\tCull Off\r\n\r\n\t\t\t\tCGPROGRAM\r\n\r\n\t\t\t\t#pragma
vertex vertex_program\r\n\t\t\t\t#pragma fragment fragment_program\r\n\r\n\t\t\t\t//vertInstancingSetup
writes to global, not allowed with DXC\r\n\t\t\t\t// #pragma never_use_dxc\r\n\t\t\t\t//
#pragma target 2.5\r\n\t\t\t\t// #pragma multi_compile_instancing\r\n\t\t\t\t//
#pragma instancing_options procedural:vertInstancingSetup\r\n\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_SINGLE_CHANNEL\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_DISSOLVE\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_DISSOLVE_ALONG_UV_X\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_UV_DISTORTION\r\n\t\t\t\t#pragma shader_feature_local
_ _CFXR_UV2_DISTORTION\r\n\t\t\t\t#pragma shader_feature_local _ _CFXR_UV_DISTORTION_ADD\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB\r\n\t\t\t\t#pragma
shader_feature_local _ _FLIPBOOK_BLENDING\r\n\r\n\t\t\t\t#pragma shader_feature_local
_ _ALPHATEST_ON\r\n\t\t\t\t#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
_ALPHAMODULATE_ON _CFXR_ADDITIVE\r\n\r\n\t\t\t\t#pragma multi_compile_shadowcaster\r\n\t\t\t\t#pragma
shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE\r\n\r\n\t\t\t#if
(_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)\r\n\t\t\t\t#pragma
target 3.0\t\t//needed for VPOS\r\n\t\t\t#endif\r\n\r\n\t\t\t\t#include \"UnityStandardParticleInstancing.cginc\"\r\n\r\n\t\t\t\t#define
PASS_SHADOW_CASTER\r\n\t\t\t\t#define CFXR_UBERSHADER\r\n\t\t\t\t#include \"CFXR_PASSES.cginc\"\r\n\r\n\t\t\t\tENDCG\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tCustomEditor
\"CartoonFX.MaterialInspector\"\r\n}\r\n\r\n"
shaderName: Cartoon FX/Remaster/Particle Ubershader
shaderErrors: []
variantCount: 283253760
variantCountUsed: 8

@ -0,0 +1,366 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
#pragma exclude_renderers gles
#endif
#if defined(GLOBAL_DISABLE_SOFT_PARTICLES) && !defined(DISABLE_SOFT_PARTICLES)
#define DISABLE_SOFT_PARTICLES
#endif
#if defined(CFXR_URP)
float LinearEyeDepthURP(float depth, float4 zBufferParam)
{
return 1.0 / (zBufferParam.z * depth + zBufferParam.w);
}
float SoftParticles(float near, float far, float4 projection)
{
float sceneZ = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(projection)).r;
if (unity_OrthoParams.w == 1)
{
// orthographic camera
#if defined(UNITY_REVERSED_Z)
sceneZ = 1.0f - sceneZ;
#endif
sceneZ = (sceneZ * _ProjectionParams.z) + _ProjectionParams.y;
}
else
{
// perspective camera
sceneZ = LinearEyeDepthURP(sceneZ, _ZBufferParams);
}
float fade = saturate (far * ((sceneZ - near) - projection.z));
return fade;
}
#else
float SoftParticles(float near, float far, float4 projection)
{
float sceneZ = (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(projection)));
if (unity_OrthoParams.w == 1)
{
// orthographic camera
#if defined(UNITY_REVERSED_Z)
sceneZ = 1.0f - sceneZ;
#endif
sceneZ = (sceneZ * _ProjectionParams.z) + _ProjectionParams.y;
}
else
{
// perspective camera
sceneZ = LinearEyeDepth(sceneZ);
}
float fade = saturate (far * ((sceneZ - near) - projection.z));
return fade;
}
#endif
float LinearToGammaSpaceApprox(float value)
{
return max(1.055h * pow(value, 0.416666667h) - 0.055h, 0.h);
}
// Same as UnityStandardUtils.cginc, but without the SHADER_TARGET limitation
half3 UnpackScaleNormal_CFXR(half4 packednormal, half bumpScale)
{
#if defined(UNITY_NO_DXT5nm)
half3 normal = packednormal.xyz * 2 - 1;
// #if (SHADER_TARGET >= 30)
// SM2.0: instruction count limitation
// SM2.0: normal scaler is not supported
normal.xy *= bumpScale;
// #endif
return normal;
#else
// This do the trick
packednormal.x *= packednormal.w;
half3 normal;
normal.xy = (packednormal.xy * 2 - 1);
// #if (SHADER_TARGET >= 30)
// SM2.0: instruction count limitation
// SM2.0: normal scaler is not supported
normal.xy *= bumpScale;
// #endif
normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
return normal;
#endif
}
//Macros
// Project Position
#if !defined(PASS_SHADOW_CASTER) && !defined(GLOBAL_DISABLE_SOFT_PARTICLES) && !defined(DISABLE_SOFT_PARTICLES) && ( (defined(SOFTPARTICLES_ON) || defined(CFXR_URP) || defined(SOFT_PARTICLES_ORTHOGRAPHIC)) && defined(_FADING_ON) )
#define vertProjPos(o, clipPos) \
o.projPos = ComputeScreenPos(clipPos); \
COMPUTE_EYEDEPTH(o.projPos.z);
#else
#define vertProjPos(o, clipPos)
#endif
// Soft Particles
#if !defined(PASS_SHADOW_CASTER) && !defined(GLOBAL_DISABLE_SOFT_PARTICLES) && !defined(DISABLE_SOFT_PARTICLES) && ((defined(SOFTPARTICLES_ON) || defined(CFXR_URP) || defined(SOFT_PARTICLES_ORTHOGRAPHIC)) && defined(_FADING_ON))
#define fragSoftParticlesFade(i, color) \
color *= SoftParticles(_SoftParticlesFadeDistanceNear, _SoftParticlesFadeDistanceFar, i.projPos);
#else
#define fragSoftParticlesFade(i, color)
#endif
// Edge fade (note: particle meshes are already in world space)
#if !defined(PASS_SHADOW_CASTER) && defined(_CFXR_EDGE_FADING)
#define vertEdgeFade(v, color) \
float3 viewDir = UnityWorldSpaceViewDir(v.vertex); \
float ndv = abs(dot(normalize(viewDir), v.normal.xyz)); \
color *= saturate(pow(ndv, _EdgeFadePow));
#else
#define vertEdgeFade(v, color)
#endif
// Fog
#if _ALPHABLEND_ON
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, unity_FogColor);
#elif _ALPHAPREMULTIPLY_ON
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, alpha * unity_FogColor);
#elif _CFXR_ADDITIVE
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, half4(0, 0, 0, 0));
#elif _ALPHAMODULATE_ON
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, half4(1, 1, 1, 1));
#else
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, unity_FogColor);
#endif
// Vertex program
#if defined(PASS_SHADOW_CASTER)
void vert(appdata v, v2f_shadowCaster o, out float4 opos)
#else
v2f vert(appdata v, v2f o)
#endif
{
UNITY_TRANSFER_FOG(o, o.pos);
vertProjPos(o, o.pos);
vertEdgeFade(v, o.color.a);
#if defined(PASS_SHADOW_CASTER)
TRANSFER_SHADOW_CASTER_NOPOS(o, opos);
#else
return o;
#endif
}
// Fragment program
#if defined(PASS_SHADOW_CASTER)
float4 frag(v2f_shadowCaster i, UNITY_VPOS_TYPE vpos, half3 particleColor, half particleAlpha, half dissolve, half dissolveTime, half doubleDissolveWidth) : SV_Target
#else
half4 frag(v2f i, half3 particleColor, half particleAlpha, half dissolve, half dissolveTime, half doubleDissolveWidth) : SV_Target
#endif
{
#if _CFXR_DISSOLVE
// Dissolve
half time = lerp(-_DissolveSmooth, 1+_DissolveSmooth, dissolveTime);
particleAlpha *= smoothstep(dissolve - _DissolveSmooth, dissolve + _DissolveSmooth, time);
if (doubleDissolveWidth > 0)
{
half dissolveSubtract = smoothstep(dissolve - _DissolveSmooth, dissolve + _DissolveSmooth, time - doubleDissolveWidth);
particleAlpha = saturate(particleAlpha - dissolveSubtract);
}
#endif
//Blending
#if _ALPHAPREMULTIPLY_ON
particleColor *= particleAlpha;
#endif
#if _ALPHAMODULATE_ON
particleColor.rgb = lerp(float3(1,1,1), particleColor.rgb, particleAlpha);
#endif
#if _ALPHATEST_ON
clip(particleAlpha - _Cutoff);
#endif
#if !defined(PASS_SHADOW_CASTER)
// Fog & Soft Particles
applyFog(i, particleColor, particleAlpha);
fragSoftParticlesFade(i, particleAlpha);
#endif
// Prevent alpha from exceeding 1
particleAlpha = min(particleAlpha, 1.0);
#if !defined(PASS_SHADOW_CASTER)
return float4(particleColor, particleAlpha);
#else
//--------------------------------------------------------------------------------------------------------------------------------
// Shadow Caster Pass
#if _CFXR_ADDITIVE
half alpha = max(particleColor.r, max(particleColor.g, particleColor.b)) * particleAlpha;
#else
half alpha = particleAlpha;
#endif
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
alpha = min(alpha, _ShadowStrength);
// Use dither mask for alpha blended shadows, based on pixel position xy
// and alpha level. Our dither texture is 4x4x16.
#if _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
half texSize = _DitherCustom_TexelSize.z;
alpha = tex3D(_DitherCustom, float3(vpos.xy*(1 / texSize), alpha*(1 - (1 / (texSize*texSize))))).a;
#else
alpha = tex3D(_DitherMaskLOD, float3(vpos.xy*0.25, alpha*0.9375)).a;
#endif
#endif
clip(alpha - 0.01);
SHADOW_CASTER_FRAGMENT(i)
#endif
}
// ================================================================================================================================
// ParticlesInstancing.hlsl
// ================================================================================================================================
#if defined(CFXR_URP)
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED) && !defined(SHADER_TARGET_SURFACE_ANALYSIS)
#define UNITY_PARTICLE_INSTANCING_ENABLED
#endif
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
#ifndef UNITY_PARTICLE_INSTANCE_DATA
#define UNITY_PARTICLE_INSTANCE_DATA DefaultParticleInstanceData
#endif
struct DefaultParticleInstanceData
{
float3x4 transform;
uint color;
float animFrame;
};
StructuredBuffer<UNITY_PARTICLE_INSTANCE_DATA> unity_ParticleInstanceData;
float4 unity_ParticleUVShiftData;
float unity_ParticleUseMeshColors;
void ParticleInstancingMatrices(out float4x4 objectToWorld, out float4x4 worldToObject)
{
UNITY_PARTICLE_INSTANCE_DATA data = unity_ParticleInstanceData[unity_InstanceID];
// transform matrix
objectToWorld._11_21_31_41 = float4(data.transform._11_21_31, 0.0f);
objectToWorld._12_22_32_42 = float4(data.transform._12_22_32, 0.0f);
objectToWorld._13_23_33_43 = float4(data.transform._13_23_33, 0.0f);
objectToWorld._14_24_34_44 = float4(data.transform._14_24_34, 1.0f);
// inverse transform matrix (TODO: replace with a library implementation if/when available)
float3x3 worldToObject3x3;
worldToObject3x3[0] = objectToWorld[1].yzx * objectToWorld[2].zxy - objectToWorld[1].zxy * objectToWorld[2].yzx;
worldToObject3x3[1] = objectToWorld[0].zxy * objectToWorld[2].yzx - objectToWorld[0].yzx * objectToWorld[2].zxy;
worldToObject3x3[2] = objectToWorld[0].yzx * objectToWorld[1].zxy - objectToWorld[0].zxy * objectToWorld[1].yzx;
float det = dot(objectToWorld[0].xyz, worldToObject3x3[0]);
worldToObject3x3 = transpose(worldToObject3x3);
worldToObject3x3 *= rcp(det);
float3 worldToObjectPosition = mul(worldToObject3x3, -objectToWorld._14_24_34);
worldToObject._11_21_31_41 = float4(worldToObject3x3._11_21_31, 0.0f);
worldToObject._12_22_32_42 = float4(worldToObject3x3._12_22_32, 0.0f);
worldToObject._13_23_33_43 = float4(worldToObject3x3._13_23_33, 0.0f);
worldToObject._14_24_34_44 = float4(worldToObjectPosition, 1.0f);
}
void ParticleInstancingSetup()
{
ParticleInstancingMatrices(unity_ObjectToWorld, unity_WorldToObject);
}
#else
void ParticleInstancingSetup() {}
#endif
#endif
// ================================================================================================================================
// Instancing functions
// ================================================================================================================================
float4 UnpackFromR8G8B8A8(uint rgba)
{
return float4(rgba & 255, (rgba >> 8) & 255, (rgba >> 16) & 255, (rgba >> 24) & 255) * (1.0 / 255);
}
half4 GetParticleColor(half4 color)
{
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
#if !defined(UNITY_PARTICLE_INSTANCE_DATA_NO_COLOR)
UNITY_PARTICLE_INSTANCE_DATA data = unity_ParticleInstanceData[unity_InstanceID];
color = lerp(half4(1.0, 1.0, 1.0, 1.0), color, unity_ParticleUseMeshColors);
color *= UnpackFromR8G8B8A8(data.color);
#endif
#endif
return color;
}
void GetParticleTexcoords(out float2 outputTexcoord, out float2 outputTexcoord2, inout float outputBlend, in float4 inputTexcoords, in float inputBlend)
{
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
if (unity_ParticleUVShiftData.x != 0.0)
{
UNITY_PARTICLE_INSTANCE_DATA data = unity_ParticleInstanceData[unity_InstanceID];
float numTilesX = unity_ParticleUVShiftData.y;
float2 animScale = unity_ParticleUVShiftData.zw;
#ifdef UNITY_PARTICLE_INSTANCE_DATA_NO_ANIM_FRAME
float sheetIndex = 0.0;
#else
float sheetIndex = data.animFrame;
#endif
float index0 = floor(sheetIndex);
float vIdx0 = floor(index0 / numTilesX);
float uIdx0 = floor(index0 - vIdx0 * numTilesX);
float2 offset0 = float2(uIdx0 * animScale.x, (1.0 - animScale.y) - vIdx0 * animScale.y); // Copied from built-in as is and it looks like upside-down flip
outputTexcoord = inputTexcoords.xy * animScale.xy + offset0.xy;
#ifdef _FLIPBOOKBLENDING_ON
float index1 = floor(sheetIndex + 1.0);
float vIdx1 = floor(index1 / numTilesX);
float uIdx1 = floor(index1 - vIdx1 * numTilesX);
float2 offset1 = float2(uIdx1 * animScale.x, (1.0 - animScale.y) - vIdx1 * animScale.y);
outputTexcoord2.xy = inputTexcoords.xy * animScale.xy + offset1.xy;
outputBlend = frac(sheetIndex);
#endif
}
else
#endif
{
outputTexcoord = inputTexcoords.xy;
#ifdef _FLIPBOOKBLENDING_ON
outputTexcoord2.xy = inputTexcoords.zw;
outputBlend = inputBlend;
#endif
}
#ifndef _FLIPBOOKBLENDING_ON
outputTexcoord2.xy = inputTexcoords.xy;
//outputBlend = 0.5;
#endif
}
void GetParticleTexcoords(out float2 outputTexcoord, in float2 inputTexcoord)
{
float2 dummyTexcoord2 = 0.0;
float dummyBlend = 0.0;
GetParticleTexcoords(outputTexcoord, dummyTexcoord2, dummyBlend, inputTexcoord.xyxy, 0.0);
}

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b3dab2eb6bcf5df42a6c45d4638e0f46
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0abf89ecb90eb024cbbc2a2dee76edf1
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,22 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
// Global settings for the Cartoon FX Remaster shaders
//--------------------------------------------------------------------------------------------------------------------------------
/* Uncomment this line if you want to globally disable soft particles */
// #define GLOBAL_DISABLE_SOFT_PARTICLES
/* Change this value if you want to globally scale the HDR effects */
/* (e.g. if your bloom effect is too strong or too weak on the effects) */
#define GLOBAL_HDR_MULTIPLIER 1
/* Comment this line if you want to disable point lights for lit particles */
#define ENABLE_POINT_LIGHTS
//--------------------------------------------------------------------------------------------------------------------------------

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 12c0fc6ff46c9b64a99fb4b921970883
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,232 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
// Copy of URP specific variables needed for lighting
// ================================================================================================================================
// Input.hlsl:
// ================================================================================================================================
#if defined(SHADER_API_MOBILE) || (defined(SHADER_API_GLCORE) && !defined(SHADER_API_SWITCH)) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) // Workaround for bug on Nintendo Switch where SHADER_API_GLCORE is mistakenly defined
#define MAX_VISIBLE_LIGHTS 32
#else
#define MAX_VISIBLE_LIGHTS 256
#endif
// --------------------------------
float4 _MainLightPosition;
half4 _MainLightColor;
// --------------------------------
half4 _AdditionalLightsCount;
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA
StructuredBuffer<LightData> _AdditionalLightsBuffer;
StructuredBuffer<int> _AdditionalLightsIndices;
#else
// GLES3 causes a performance regression in some devices when using CBUFFER.
#ifndef SHADER_API_GLES3
CBUFFER_START(AdditionalLights)
#endif
float4 _AdditionalLightsPosition[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightsColor[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightsAttenuation[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightsSpotDir[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightsOcclusionProbes[MAX_VISIBLE_LIGHTS];
#ifndef SHADER_API_GLES3
CBUFFER_END
#endif
#endif
// ================================================================================================================================
// UnityInput.hlsl:
// ================================================================================================================================
half4 unity_LightData;
half4 unity_LightIndices[2];
// --------------------------------
// ================================================================================================================================
// Macros.hlsl
// ================================================================================================================================
#define HALF_MIN 6.103515625e-5 // 2^-14, the same value for 10, 11 and 16-bit: https://www.khronos.org/opengl/wiki/Small_Float_Formats
// ================================================================================================================================
// Lighting.hlsl
// ================================================================================================================================
// Abstraction over Light shading data.
struct Light
{
half3 direction;
half3 color;
half distanceAttenuation;
half shadowAttenuation;
};
// Matches Unity Vanila attenuation
// Attenuation smoothly decreases to light range.
float DistanceAttenuation(float distanceSqr, half2 distanceAttenuation)
{
// We use a shared distance attenuation for additional directional and puctual lights
// for directional lights attenuation will be 1
float lightAtten = rcp(distanceSqr);
#if SHADER_HINT_NICE_QUALITY
// Use the smoothing factor also used in the Unity lightmapper.
half factor = distanceSqr * distanceAttenuation.x;
half smoothFactor = saturate(1.0h - factor * factor);
smoothFactor = smoothFactor * smoothFactor;
#else
// We need to smoothly fade attenuation to light range. We start fading linearly at 80% of light range
// Therefore:
// fadeDistance = (0.8 * 0.8 * lightRangeSq)
// smoothFactor = (lightRangeSqr - distanceSqr) / (lightRangeSqr - fadeDistance)
// We can rewrite that to fit a MAD by doing
// distanceSqr * (1.0 / (fadeDistanceSqr - lightRangeSqr)) + (-lightRangeSqr / (fadeDistanceSqr - lightRangeSqr)
// distanceSqr * distanceAttenuation.y + distanceAttenuation.z
half smoothFactor = saturate(distanceSqr * distanceAttenuation.x + distanceAttenuation.y);
#endif
return lightAtten * smoothFactor;
}
half AngleAttenuation(half3 spotDirection, half3 lightDirection, half2 spotAttenuation)
{
// Spot Attenuation with a linear falloff can be defined as
// (SdotL - cosOuterAngle) / (cosInnerAngle - cosOuterAngle)
// This can be rewritten as
// invAngleRange = 1.0 / (cosInnerAngle - cosOuterAngle)
// SdotL * invAngleRange + (-cosOuterAngle * invAngleRange)
// SdotL * spotAttenuation.x + spotAttenuation.y
// If we precompute the terms in a MAD instruction
half SdotL = dot(spotDirection, lightDirection);
half atten = saturate(SdotL * spotAttenuation.x + spotAttenuation.y);
return atten * atten;
}
// Fills a light struct given a perObjectLightIndex
Light GetAdditionalPerObjectLight(int perObjectLightIndex, float3 positionWS)
{
// Abstraction over Light input constants
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA
float4 lightPositionWS = _AdditionalLightsBuffer[perObjectLightIndex].position;
half3 color = _AdditionalLightsBuffer[perObjectLightIndex].color.rgb;
half4 distanceAndSpotAttenuation = _AdditionalLightsBuffer[perObjectLightIndex].attenuation;
half4 spotDirection = _AdditionalLightsBuffer[perObjectLightIndex].spotDirection;
half4 lightOcclusionProbeInfo = _AdditionalLightsBuffer[perObjectLightIndex].occlusionProbeChannels;
#else
float4 lightPositionWS = _AdditionalLightsPosition[perObjectLightIndex];
half3 color = _AdditionalLightsColor[perObjectLightIndex].rgb;
half4 distanceAndSpotAttenuation = _AdditionalLightsAttenuation[perObjectLightIndex];
half4 spotDirection = _AdditionalLightsSpotDir[perObjectLightIndex];
half4 lightOcclusionProbeInfo = _AdditionalLightsOcclusionProbes[perObjectLightIndex];
#endif
// Directional lights store direction in lightPosition.xyz and have .w set to 0.0.
// This way the following code will work for both directional and punctual lights.
float3 lightVector = lightPositionWS.xyz - positionWS * lightPositionWS.w;
float distanceSqr = max(dot(lightVector, lightVector), HALF_MIN);
half3 lightDirection = half3(lightVector * rsqrt(distanceSqr));
half attenuation = DistanceAttenuation(distanceSqr, distanceAndSpotAttenuation.xy) * AngleAttenuation(spotDirection.xyz, lightDirection, distanceAndSpotAttenuation.zw);
Light light;
light.direction = lightDirection;
light.distanceAttenuation = attenuation;
/// light.shadowAttenuation = AdditionalLightRealtimeShadow(perObjectLightIndex, positionWS);
light.shadowAttenuation = 1;
light.color = color;
// In case we're using light probes, we can sample the attenuation from the `unity_ProbesOcclusion`
#if defined(LIGHTMAP_ON) || defined(_MIXED_LIGHTING_SUBTRACTIVE)
// First find the probe channel from the light.
// Then sample `unity_ProbesOcclusion` for the baked occlusion.
// If the light is not baked, the channel is -1, and we need to apply no occlusion.
// probeChannel is the index in 'unity_ProbesOcclusion' that holds the proper occlusion value.
int probeChannel = lightOcclusionProbeInfo.x;
// lightProbeContribution is set to 0 if we are indeed using a probe, otherwise set to 1.
half lightProbeContribution = lightOcclusionProbeInfo.y;
half probeOcclusionValue = unity_ProbesOcclusion[probeChannel];
light.distanceAttenuation *= max(probeOcclusionValue, lightProbeContribution);
#endif
return light;
}
uint GetPerObjectLightIndexOffset()
{
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA
return unity_LightData.x;
#else
return 0;
#endif
}
// Returns a per-object index given a loop index.
// This abstract the underlying data implementation for storing lights/light indices
int GetPerObjectLightIndex(uint index)
{
/////////////////////////////////////////////////////////////////////////////////////////////
// Structured Buffer Path /
// /
// Lights and light indices are stored in StructuredBuffer. We can just index them. /
// Currently all non-mobile platforms take this path :( /
// There are limitation in mobile GPUs to use SSBO (performance / no vertex shader support) /
/////////////////////////////////////////////////////////////////////////////////////////////
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA
uint offset = unity_LightData.x;
return _AdditionalLightsIndices[offset + index];
/////////////////////////////////////////////////////////////////////////////////////////////
// UBO path /
// /
// We store 8 light indices in float4 unity_LightIndices[2]; /
// Due to memory alignment unity doesn't support int[] or float[] /
// Even trying to reinterpret cast the unity_LightIndices to float[] won't work /
// it will cast to float4[] and create extra register pressure. :( /
/////////////////////////////////////////////////////////////////////////////////////////////
#elif !defined(SHADER_API_GLES)
// since index is uint shader compiler will implement
// div & mod as bitfield ops (shift and mask).
// TODO: Can we index a float4? Currently compiler is
// replacing unity_LightIndicesX[i] with a dp4 with identity matrix.
// u_xlat16_40 = dot(unity_LightIndices[int(u_xlatu13)], ImmCB_0_0_0[u_xlati1]);
// This increases both arithmetic and register pressure.
return unity_LightIndices[index / 4][index % 4];
#else
// Fallback to GLES2. No bitfield magic here :(.
// We limit to 4 indices per object and only sample unity_4LightIndices0.
// Conditional moves are branch free even on mali-400
// small arithmetic cost but no extra register pressure from ImmCB_0_0_0 matrix.
half2 lightIndex2 = (index < 2.0h) ? unity_LightIndices[0].xy : unity_LightIndices[0].zw;
half i_rem = (index < 2.0h) ? index : index - 2.0h;
return (i_rem < 1.0h) ? lightIndex2.x : lightIndex2.y;
#endif
}
// Fills a light struct given a loop i index. This will convert the i
// index to a perObjectLightIndex
Light GetAdditionalLight(uint i, float3 positionWS)
{
int perObjectLightIndex = GetPerObjectLightIndex(i);
return GetAdditionalPerObjectLight(perObjectLightIndex, positionWS);
}
int GetAdditionalLightsCount()
{
// TODO: we need to expose in SRP api an ability for the pipeline cap the amount of lights
// in the culling. This way we could do the loop branch with an uniform
// This would be helpful to support baking exceeding lights in SH as well
return min(_AdditionalLightsCount.x, unity_LightData.y);
}

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3eab241579cd5514388d88f452714385
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f58436457f0f8304baefde53ca9c9f89
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1c15cd9011f407b4697938c3cc979717
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a71be3e7990efb040a07565c43cbb198
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 77c0e73f53dcc1a4bac867af138898cf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,270 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
namespace CartoonFX
{
public class CFXR_Demo : MonoBehaviour
{
//----------------------------------------------------------------------------------------------------------------------------
// UI
public void NextEffect()
{
index++;
WrapIndex();
PlayAtIndex();
}
public void PreviousEffect()
{
index--;
WrapIndex();
PlayAtIndex();
}
public void ToggleSlowMo()
{
slowMotion = !slowMotion;
Time.timeScale = slowMotion ? 0.33f : 1.0f;
var color = Color.white;
color.a = slowMotion ? 1f : 0.33f;
btnSlowMotion.color = color;
lblSlowMotion.color = color;
}
public void ToggleCamera()
{
rotateCamera = !rotateCamera;
var color = Color.white;
color.a = rotateCamera ? 1f : 0.33f;
btnCameraRotation.color = color;
lblCameraRotation.color = color;
}
public void ToggleGround()
{
showGround = !showGround;
ground.SetActive(showGround);
var color = Color.white;
color.a = showGround ? 1f : 0.33f;
btnShowGround.color = color;
lblShowGround.color = color;
}
public void ToggleCameraShake()
{
CFXR_Effect.GlobalDisableCameraShake = !CFXR_Effect.GlobalDisableCameraShake;
var color = Color.white;
color.a = CFXR_Effect.GlobalDisableCameraShake ? 0.33f : 1.0f;
btnCamShake.color = color;
lblCamShake.color = color;
}
public void ToggleEffectsLights()
{
CFXR_Effect.GlobalDisableLights = !CFXR_Effect.GlobalDisableLights;
var color = Color.white;
color.a = CFXR_Effect.GlobalDisableLights ? 0.33f : 1.0f;
btnLights.color = color;
lblLights.color = color;
}
public void ToggleBloom()
{
bloom.enabled = !bloom.enabled;
var color = Color.white;
color.a = !bloom.enabled ? 0.33f : 1.0f;
btnBloom.color = color;
lblBloom.color = color;
}
public void ResetCam()
{
Camera.main.transform.position = camInitialPosition;
Camera.main.transform.rotation = camInitialRotation;
}
//----------------------------------------------------------------------------------------------------------------------------
public Image btnSlowMotion;
public Text lblSlowMotion;
public Image btnCameraRotation;
public Text lblCameraRotation;
public Image btnShowGround;
public Text lblShowGround;
public Image btnCamShake;
public Text lblCamShake;
public Image btnLights;
public Text lblLights;
public Image btnBloom;
public Text lblBloom;
[Space]
public Text labelEffect;
public Text labelIndex;
[Space]
public GameObject groundURP;
public GameObject groundBIRP;
GameObject ground;
public Transform demoCamera;
public MonoBehaviour bloom;
public float rotationSpeed = 10f;
public float zoomFactor = 1f;
bool slowMotion = false;
bool rotateCamera = false;
bool showGround = true;
//----------------------------------------------------------------------------------------------------------------------------
[System.NonSerialized] public GameObject currentEffect;
GameObject[] effectsList;
int index = 0;
Vector3 camInitialPosition;
Quaternion camInitialRotation;
void Awake()
{
camInitialPosition = Camera.main.transform.position;
camInitialRotation = Camera.main.transform.rotation;
var list = new List<GameObject>();
for (int i = 0; i < this.transform.childCount; i++)
{
var effect = this.transform.GetChild(i).gameObject;
list.Add(effect);
var cfxrEffect= effect.GetComponent<CFXR_Effect>();
if (cfxrEffect != null) cfxrEffect.clearBehavior = CFXR_Effect.ClearBehavior.Disable;
}
effectsList = list.ToArray();
PlayAtIndex();
UpdateLabels();
bool isURP = GraphicsSettings.currentRenderPipeline != null;
ground = isURP ? groundURP : groundBIRP;
groundURP.SetActive(isURP);
groundBIRP.SetActive(!isURP);
}
void Update()
{
if (rotateCamera)
{
demoCamera.RotateAround(Vector3.zero, Vector3.up, rotationSpeed * Time.deltaTime);
}
if (Input.GetKeyDown(KeyCode.Space))
{
if (currentEffect != null)
{
var ps = currentEffect.GetComponent<ParticleSystem>();
if (ps.isEmitting)
{
ps.Stop(true);
}
else
{
if (!currentEffect.gameObject.activeSelf)
{
currentEffect.SetActive(true);
}
else
{
ps.Play(true);
var cfxrEffects = currentEffect.GetComponentsInChildren<CFXR_Effect>();
foreach (var cfxr in cfxrEffects)
{
cfxr.ResetState();
}
}
}
}
}
if (Input.GetKeyDown(KeyCode.Delete) || Input.GetKeyDown(KeyCode.Backspace))
{
if (currentEffect != null)
{
currentEffect.SetActive(false);
currentEffect.SetActive(true);
}
}
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
PreviousEffect();
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
NextEffect();
}
if (Input.GetMouseButtonDown(0))
{
var ray = demoCamera.GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray))
{
if (currentEffect != null)
{
currentEffect.SetActive(false);
currentEffect.SetActive(true);
}
}
}
if (Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
{
ResetCam();
}
float scroll = Input.GetAxis("Mouse ScrollWheel");
if (scroll != 0f)
{
Camera.main.transform.Translate(Vector3.forward * (scroll < 0f ? -1f : 1f) * zoomFactor, Space.Self);
}
}
public void PlayAtIndex()
{
if (currentEffect != null)
{
currentEffect.SetActive(false);
}
currentEffect = effectsList[index];
currentEffect.SetActive(true);
UpdateLabels();
}
void WrapIndex()
{
if (index < 0) index = effectsList.Length - 1;
if (index >= effectsList.Length) index = 0;
}
void UpdateLabels()
{
labelEffect.text = currentEffect.name;
labelIndex.text = string.Format("{0}/{1}", (index+1), effectsList.Length);
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 35e9f6a6071b4f44fa2cf94b59d33251
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,21 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
using UnityEngine;
namespace CartoonFX
{
public class CFXR_Demo_Rotate : MonoBehaviour
{
public Vector3 axis = new Vector3(0,1,0);
public Vector3 center;
public float speed = 1.0f;
void Update()
{
this.transform.RotateAround(center, axis, speed * Time.deltaTime);
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1529372f6ddbfb0429260b50bc9d1aa8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,42 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
using UnityEngine;
namespace CartoonFX
{
public class CFXR_Demo_Translate : MonoBehaviour
{
public Vector3 direction = new Vector3(0,1,0);
public bool randomRotation;
bool initialized;
Vector3 initialPosition;
void Awake()
{
if (!initialized)
{
initialized = true;
initialPosition = this.transform.position;
}
}
void OnEnable()
{
this.transform.position = initialPosition;
if (randomRotation)
{
this.transform.eulerAngles = Vector3.Lerp(Vector3.zero, Vector3.up * 360, Random.value);
}
}
void Update()
{
this.transform.Translate(direction * Time.deltaTime);
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fd81627723031224baf6eef1b52a3f50
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d7f093702247b5648a3c062d5ee0c6de
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,272 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// Modified by Jean Moreno for Cartoon FX Remaster Demo
// - effect previews in SceneView
// - disabled a code warning
using UnityEngine;
namespace Kino
{
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[ImageEffectAllowedInSceneView]
public class Bloom : MonoBehaviour
{
#region Public Properties
/// Prefilter threshold (gamma-encoded)
/// Filters out pixels under this level of brightness.
public float thresholdGamma
{
get { return Mathf.Max(_threshold, 0); }
set { _threshold = value; }
}
/// Prefilter threshold (linearly-encoded)
/// Filters out pixels under this level of brightness.
public float thresholdLinear
{
get { return GammaToLinear(thresholdGamma); }
set { _threshold = LinearToGamma(value); }
}
[SerializeField]
[Tooltip("Filters out pixels under this level of brightness.")]
float _threshold = 0.8f;
/// Soft-knee coefficient
/// Makes transition between under/over-threshold gradual.
public float softKnee
{
get { return _softKnee; }
set { _softKnee = value; }
}
[SerializeField, Range(0, 1)]
[Tooltip("Makes transition between under/over-threshold gradual.")]
float _softKnee = 0.5f;
/// Bloom radius
/// Changes extent of veiling effects in a screen
/// resolution-independent fashion.
public float radius
{
get { return _radius; }
set { _radius = value; }
}
[SerializeField, Range(1, 7)]
[Tooltip("Changes extent of veiling effects\n" +
"in a screen resolution-independent fashion.")]
float _radius = 2.5f;
/// Bloom intensity
/// Blend factor of the result image.
public float intensity
{
get { return Mathf.Max(_intensity, 0); }
set { _intensity = value; }
}
[SerializeField]
[Tooltip("Blend factor of the result image.")]
float _intensity = 0.8f;
/// High quality mode
/// Controls filter quality and buffer resolution.
public bool highQuality
{
get { return _highQuality; }
set { _highQuality = value; }
}
[SerializeField]
[Tooltip("Controls filter quality and buffer resolution.")]
bool _highQuality = true;
/// Anti-flicker filter
/// Reduces flashing noise with an additional filter.
[SerializeField]
[Tooltip("Reduces flashing noise with an additional filter.")]
bool _antiFlicker = true;
public bool antiFlicker
{
get { return _antiFlicker; }
set { _antiFlicker = value; }
}
#endregion
#region Private Members
#pragma warning disable 0649
[SerializeField, HideInInspector]
Shader _shader;
#pragma warning restore 0649
Material _material;
const int kMaxIterations = 16;
RenderTexture[] _blurBuffer1 = new RenderTexture[kMaxIterations];
RenderTexture[] _blurBuffer2 = new RenderTexture[kMaxIterations];
float LinearToGamma(float x)
{
#if UNITY_5_3_OR_NEWER
return Mathf.LinearToGammaSpace(x);
#else
if (x <= 0.0031308f)
return 12.92f * x;
else
return 1.055f * Mathf.Pow(x, 1 / 2.4f) - 0.055f;
#endif
}
float GammaToLinear(float x)
{
#if UNITY_5_3_OR_NEWER
return Mathf.GammaToLinearSpace(x);
#else
if (x <= 0.04045f)
return x / 12.92f;
else
return Mathf.Pow((x + 0.055f) / 1.055f, 2.4f);
#endif
}
#endregion
#region MonoBehaviour Functions
void OnEnable()
{
var shader = _shader ? _shader : Shader.Find("Hidden/Kino/Bloom");
_material = new Material(shader);
_material.hideFlags = HideFlags.DontSave;
}
void OnDisable()
{
DestroyImmediate(_material);
}
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
var useRGBM = Application.isMobilePlatform;
// source texture size
var tw = source.width;
var th = source.height;
// halve the texture size for the low quality mode
if (!_highQuality)
{
tw /= 2;
th /= 2;
}
// blur buffer format
var rtFormat = useRGBM ?
RenderTextureFormat.Default : RenderTextureFormat.DefaultHDR;
// determine the iteration count
var logh = Mathf.Log(th, 2) + _radius - 8;
var logh_i = (int)logh;
var iterations = Mathf.Clamp(logh_i, 1, kMaxIterations);
// update the shader properties
var lthresh = thresholdLinear;
_material.SetFloat("_Threshold", lthresh);
var knee = lthresh * _softKnee + 1e-5f;
var curve = new Vector3(lthresh - knee, knee * 2, 0.25f / knee);
_material.SetVector("_Curve", curve);
var pfo = !_highQuality && _antiFlicker;
_material.SetFloat("_PrefilterOffs", pfo ? -0.5f : 0.0f);
_material.SetFloat("_SampleScale", 0.5f + logh - logh_i);
_material.SetFloat("_Intensity", intensity);
// prefilter pass
var prefiltered = RenderTexture.GetTemporary(tw, th, 0, rtFormat);
var pass = _antiFlicker ? 1 : 0;
Graphics.Blit(source, prefiltered, _material, pass);
// construct a mip pyramid
var last = prefiltered;
for (var level = 0; level < iterations; level++)
{
_blurBuffer1[level] = RenderTexture.GetTemporary(
last.width / 2, last.height / 2, 0, rtFormat
);
pass = (level == 0) ? (_antiFlicker ? 3 : 2) : 4;
Graphics.Blit(last, _blurBuffer1[level], _material, pass);
last = _blurBuffer1[level];
}
// upsample and combine loop
for (var level = iterations - 2; level >= 0; level--)
{
var basetex = _blurBuffer1[level];
_material.SetTexture("_BaseTex", basetex);
_blurBuffer2[level] = RenderTexture.GetTemporary(
basetex.width, basetex.height, 0, rtFormat
);
pass = _highQuality ? 6 : 5;
Graphics.Blit(last, _blurBuffer2[level], _material, pass);
last = _blurBuffer2[level];
}
// finish process
_material.SetTexture("_BaseTex", source);
pass = _highQuality ? 8 : 7;
Graphics.Blit(last, destination, _material, pass);
// release the temporary buffers
for (var i = 0; i < kMaxIterations; i++)
{
if (_blurBuffer1[i] != null)
RenderTexture.ReleaseTemporary(_blurBuffer1[i]);
if (_blurBuffer2[i] != null)
RenderTexture.ReleaseTemporary(_blurBuffer2[i]);
_blurBuffer1[i] = null;
_blurBuffer2[i] = null;
}
RenderTexture.ReleaseTemporary(prefiltered);
}
#endregion
}
}

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 6363bba448bf64e60a763433f9ddf81b
timeCreated: 1445671165
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences:
- _shader: {fileID: 4800000, guid: 5a711a01011934ebcb58ef5ad52159d6, type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b40be1dd63cf4e94a83d27ec56ac0644
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,76 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
using UnityEngine;
using UnityEditor;
namespace Kino
{
[CanEditMultipleObjects]
[CustomEditor(typeof(Bloom))]
public class BloomEditor : Editor
{
BloomGraphDrawer _graph;
SerializedProperty _threshold;
SerializedProperty _softKnee;
SerializedProperty _radius;
SerializedProperty _intensity;
SerializedProperty _highQuality;
SerializedProperty _antiFlicker;
static GUIContent _textThreshold = new GUIContent("Threshold (gamma)");
void OnEnable()
{
_graph = new BloomGraphDrawer();
_threshold = serializedObject.FindProperty("_threshold");
_softKnee = serializedObject.FindProperty("_softKnee");
_radius = serializedObject.FindProperty("_radius");
_intensity = serializedObject.FindProperty("_intensity");
_highQuality = serializedObject.FindProperty("_highQuality");
_antiFlicker = serializedObject.FindProperty("_antiFlicker");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
if (!serializedObject.isEditingMultipleObjects) {
EditorGUILayout.Space();
_graph.Prepare((Bloom)target);
_graph.DrawGraph();
EditorGUILayout.Space();
}
EditorGUILayout.PropertyField(_threshold, _textThreshold);
EditorGUILayout.PropertyField(_softKnee);
EditorGUILayout.PropertyField(_intensity);
EditorGUILayout.PropertyField(_radius);
EditorGUILayout.PropertyField(_highQuality);
EditorGUILayout.PropertyField(_antiFlicker);
serializedObject.ApplyModifiedProperties();
}
}
}

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 036bc30d96c3349ce86bfc8d95667da7
timeCreated: 1435816745
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,183 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
using UnityEngine;
using UnityEditor;
namespace Kino
{
// Class used for drawing the brightness response curve
public class BloomGraphDrawer
{
#region Public Methods
// Update internal state with a given bloom instance.
public void Prepare(Bloom bloom)
{
#if UNITY_5_6_OR_NEWER
if (bloom.GetComponent<Camera>().allowHDR)
#else
if (bloom.GetComponent<Camera>().hdr)
#endif
{
_rangeX = 6;
_rangeY = 1.5f;
}
else
{
_rangeX = 1;
_rangeY = 1;
}
_threshold = bloom.thresholdLinear;
_knee = bloom.softKnee * _threshold + 1e-5f;
// Intensity is capped to prevent sampling errors.
_intensity = Mathf.Min(bloom.intensity, 10);
}
// Draw the graph at the current position.
public void DrawGraph()
{
_rectGraph = GUILayoutUtility.GetRect(128, 80);
// Background
DrawRect(0, 0, _rangeX, _rangeY, 0.1f, 0.4f);
// Soft-knee range
DrawRect(_threshold - _knee, 0, _threshold + _knee, _rangeY, 0.25f, -1);
// Horizontal lines
for (var i = 1; i < _rangeY; i++)
DrawLine(0, i, _rangeX, i, 0.4f);
// Vertical lines
for (var i = 1; i < _rangeX; i++)
DrawLine(i, 0, i, _rangeY, 0.4f);
// Label
Handles.Label(
PointInRect(0, _rangeY) + Vector3.right,
"Brightness Response (linear)", EditorStyles.miniLabel
);
// Threshold line
DrawLine(_threshold, 0, _threshold, _rangeY, 0.6f);
// Response curve
var vcount = 0;
while (vcount < _curveResolution)
{
var x = _rangeX * vcount / (_curveResolution - 1);
var y = ResponseFunction(x);
if (y < _rangeY)
{
_curveVertices[vcount++] = PointInRect(x, y);
}
else
{
if (vcount > 1)
{
// Extend the last segment to the top edge of the rect.
var v1 = _curveVertices[vcount - 2];
var v2 = _curveVertices[vcount - 1];
var clip = (_rectGraph.y - v1.y) / (v2.y - v1.y);
_curveVertices[vcount - 1] = v1 + (v2 - v1) * clip;
}
break;
}
}
if (vcount > 1)
{
Handles.color = Color.white * 0.9f;
Handles.DrawAAPolyLine(2.0f, vcount, _curveVertices);
}
}
#endregion
#region Response Function
float _threshold;
float _knee;
float _intensity;
float ResponseFunction(float x)
{
var rq = Mathf.Clamp(x - _threshold + _knee, 0, _knee * 2);
rq = rq * rq * 0.25f / _knee;
return Mathf.Max(rq, x - _threshold) * _intensity;
}
#endregion
#region Graph Functions
// Number of vertices in curve
const int _curveResolution = 96;
// Vertex buffers
Vector3[] _rectVertices = new Vector3[4];
Vector3[] _lineVertices = new Vector3[2];
Vector3[] _curveVertices = new Vector3[_curveResolution];
Rect _rectGraph;
float _rangeX;
float _rangeY;
// Transform a point into the graph rect.
Vector3 PointInRect(float x, float y)
{
x = Mathf.Lerp(_rectGraph.x, _rectGraph.xMax, x / _rangeX);
y = Mathf.Lerp(_rectGraph.yMax, _rectGraph.y, y / _rangeY);
return new Vector3(x, y, 0);
}
// Draw a line in the graph rect.
void DrawLine(float x1, float y1, float x2, float y2, float grayscale)
{
_lineVertices[0] = PointInRect(x1, y1);
_lineVertices[1] = PointInRect(x2, y2);
Handles.color = Color.white * grayscale;
Handles.DrawAAPolyLine(2.0f, _lineVertices);
}
// Draw a rect in the graph rect.
void DrawRect(float x1, float y1, float x2, float y2, float fill, float line)
{
_rectVertices[0] = PointInRect(x1, y1);
_rectVertices[1] = PointInRect(x2, y1);
_rectVertices[2] = PointInRect(x2, y2);
_rectVertices[3] = PointInRect(x1, y2);
Handles.DrawSolidRectangleWithOutline(
_rectVertices,
fill < 0 ? Color.clear : Color.white * fill,
line < 0 ? Color.clear : Color.white * line
);
}
#endregion
}
}

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4afcb2949e7fb42679b587b8848b7e02
timeCreated: 1457674915
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c04a0ddd8381aa04ab37bc4596459abb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,251 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#include "UnityCG.cginc"
// Mobile: use RGBM instead of float/half RGB
#define USE_RGBM defined(SHADER_API_MOBILE)
sampler2D _MainTex;
sampler2D _BaseTex;
float2 _MainTex_TexelSize;
float2 _BaseTex_TexelSize;
half4 _MainTex_ST;
half4 _BaseTex_ST;
float _PrefilterOffs;
half _Threshold;
half3 _Curve;
float _SampleScale;
half _Intensity;
// Brightness function
half Brightness(half3 c)
{
return max(max(c.r, c.g), c.b);
}
// 3-tap median filter
half3 Median(half3 a, half3 b, half3 c)
{
return a + b + c - min(min(a, b), c) - max(max(a, b), c);
}
// Clamp HDR value within a safe range
half3 SafeHDR(half3 c) { return min(c, 65000); }
half4 SafeHDR(half4 c) { return min(c, 65000); }
// RGBM encoding/decoding
half4 EncodeHDR(float3 rgb)
{
#if USE_RGBM
rgb *= 1.0 / 8;
float m = max(max(rgb.r, rgb.g), max(rgb.b, 1e-6));
m = ceil(m * 255) / 255;
return half4(rgb / m, m);
#else
return half4(rgb, 0);
#endif
}
float3 DecodeHDR(half4 rgba)
{
#if USE_RGBM
return rgba.rgb * rgba.a * 8;
#else
return rgba.rgb;
#endif
}
// Downsample with a 4x4 box filter
half3 DownsampleFilter(float2 uv)
{
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1);
half3 s;
s = DecodeHDR(tex2D(_MainTex, uv + d.xy));
s += DecodeHDR(tex2D(_MainTex, uv + d.zy));
s += DecodeHDR(tex2D(_MainTex, uv + d.xw));
s += DecodeHDR(tex2D(_MainTex, uv + d.zw));
return s * (1.0 / 4);
}
// Downsample with a 4x4 box filter + anti-flicker filter
half3 DownsampleAntiFlickerFilter(float2 uv)
{
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1);
half3 s1 = DecodeHDR(tex2D(_MainTex, uv + d.xy));
half3 s2 = DecodeHDR(tex2D(_MainTex, uv + d.zy));
half3 s3 = DecodeHDR(tex2D(_MainTex, uv + d.xw));
half3 s4 = DecodeHDR(tex2D(_MainTex, uv + d.zw));
// Karis's luma weighted average (using brightness instead of luma)
half s1w = 1 / (Brightness(s1) + 1);
half s2w = 1 / (Brightness(s2) + 1);
half s3w = 1 / (Brightness(s3) + 1);
half s4w = 1 / (Brightness(s4) + 1);
half one_div_wsum = 1 / (s1w + s2w + s3w + s4w);
return (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * one_div_wsum;
}
half3 UpsampleFilter(float2 uv)
{
#if HIGH_QUALITY
// 9-tap bilinear upsampler (tent filter)
float4 d = _MainTex_TexelSize.xyxy * float4(1, 1, -1, 0) * _SampleScale;
half3 s;
s = DecodeHDR(tex2D(_MainTex, uv - d.xy));
s += DecodeHDR(tex2D(_MainTex, uv - d.wy)) * 2;
s += DecodeHDR(tex2D(_MainTex, uv - d.zy));
s += DecodeHDR(tex2D(_MainTex, uv + d.zw)) * 2;
s += DecodeHDR(tex2D(_MainTex, uv )) * 4;
s += DecodeHDR(tex2D(_MainTex, uv + d.xw)) * 2;
s += DecodeHDR(tex2D(_MainTex, uv + d.zy));
s += DecodeHDR(tex2D(_MainTex, uv + d.wy)) * 2;
s += DecodeHDR(tex2D(_MainTex, uv + d.xy));
return s * (1.0 / 16);
#else
// 4-tap bilinear upsampler
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1) * (_SampleScale * 0.5);
half3 s;
s = DecodeHDR(tex2D(_MainTex, uv + d.xy));
s += DecodeHDR(tex2D(_MainTex, uv + d.zy));
s += DecodeHDR(tex2D(_MainTex, uv + d.xw));
s += DecodeHDR(tex2D(_MainTex, uv + d.zw));
return s * (1.0 / 4);
#endif
}
//
// Vertex shader
//
v2f_img vert(appdata_img v)
{
v2f_img o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
return o;
}
struct v2f_multitex
{
float4 pos : SV_POSITION;
float2 uvMain : TEXCOORD0;
float2 uvBase : TEXCOORD1;
};
v2f_multitex vert_multitex(appdata_img v)
{
v2f_multitex o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uvMain = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
o.uvBase = UnityStereoScreenSpaceUVAdjust(v.texcoord, _BaseTex_ST);
#if UNITY_UV_STARTS_AT_TOP
if (_BaseTex_TexelSize.y < 0.0)
o.uvBase.y = 1.0 - v.texcoord.y;
#endif
return o;
}
//
// fragment shader
//
half4 frag_prefilter(v2f_img i) : SV_Target
{
float2 uv = i.uv + _MainTex_TexelSize.xy * _PrefilterOffs;
#if ANTI_FLICKER
float3 d = _MainTex_TexelSize.xyx * float3(1, 1, 0);
half4 s0 = SafeHDR(tex2D(_MainTex, uv));
half3 s1 = SafeHDR(tex2D(_MainTex, uv - d.xz).rgb);
half3 s2 = SafeHDR(tex2D(_MainTex, uv + d.xz).rgb);
half3 s3 = SafeHDR(tex2D(_MainTex, uv - d.zy).rgb);
half3 s4 = SafeHDR(tex2D(_MainTex, uv + d.zy).rgb);
half3 m = Median(Median(s0.rgb, s1, s2), s3, s4);
#else
half4 s0 = SafeHDR(tex2D(_MainTex, uv));
half3 m = s0.rgb;
#endif
#if UNITY_COLORSPACE_GAMMA
m = GammaToLinearSpace(m);
#endif
// Pixel brightness
half br = Brightness(m);
// Under-threshold part: quadratic curve
half rq = clamp(br - _Curve.x, 0, _Curve.y);
rq = _Curve.z * rq * rq;
// Combine and apply the brightness response curve.
m *= max(rq, br - _Threshold) / max(br, 1e-5);
return EncodeHDR(m);
}
half4 frag_downsample1(v2f_img i) : SV_Target
{
#if ANTI_FLICKER
return EncodeHDR(DownsampleAntiFlickerFilter(i.uv));
#else
return EncodeHDR(DownsampleFilter(i.uv));
#endif
}
half4 frag_downsample2(v2f_img i) : SV_Target
{
return EncodeHDR(DownsampleFilter(i.uv));
}
half4 frag_upsample(v2f_multitex i) : SV_Target
{
half3 base = DecodeHDR(tex2D(_BaseTex, i.uvBase));
half3 blur = UpsampleFilter(i.uvMain);
return EncodeHDR(base + blur);
}
half4 frag_upsample_final(v2f_multitex i) : SV_Target
{
half4 base = tex2D(_BaseTex, i.uvBase);
half3 blur = UpsampleFilter(i.uvMain);
#if UNITY_COLORSPACE_GAMMA
base.rgb = GammaToLinearSpace(base.rgb);
#endif
half3 cout = base.rgb + blur * _Intensity;
#if UNITY_COLORSPACE_GAMMA
cout = LinearToGammaSpace(cout);
#endif
return half4(cout, base.a);
}

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1b8325918052c4c5492831d116e3ed27
timeCreated: 1463470294
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,141 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
Shader "Hidden/Kino/Bloom"
{
Properties
{
_MainTex("", 2D) = "" {}
_BaseTex("", 2D) = "" {}
}
SubShader
{
// 0: Prefilter
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#include "Bloom.cginc"
#pragma vertex vert
#pragma fragment frag_prefilter
#pragma target 3.0
ENDCG
}
// 1: Prefilter with anti-flicker
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#define ANTI_FLICKER 1
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#include "Bloom.cginc"
#pragma vertex vert
#pragma fragment frag_prefilter
#pragma target 3.0
ENDCG
}
// 2: First level downsampler
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#include "Bloom.cginc"
#pragma vertex vert
#pragma fragment frag_downsample1
#pragma target 3.0
ENDCG
}
// 3: First level downsampler with anti-flicker
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#define ANTI_FLICKER 1
#include "Bloom.cginc"
#pragma vertex vert
#pragma fragment frag_downsample1
#pragma target 3.0
ENDCG
}
// 4: Second level downsampler
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#include "Bloom.cginc"
#pragma vertex vert
#pragma fragment frag_downsample2
#pragma target 3.0
ENDCG
}
// 5: Upsampler
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#include "Bloom.cginc"
#pragma vertex vert_multitex
#pragma fragment frag_upsample
#pragma target 3.0
ENDCG
}
// 6: High quality upsampler
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#define HIGH_QUALITY 1
#include "Bloom.cginc"
#pragma vertex vert_multitex
#pragma fragment frag_upsample
#pragma target 3.0
ENDCG
}
// 7: Combiner
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#include "Bloom.cginc"
#pragma vertex vert_multitex
#pragma fragment frag_upsample_final
#pragma target 3.0
ENDCG
}
// 8: High quality combiner
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#define HIGH_QUALITY 1
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#include "Bloom.cginc"
#pragma vertex vert_multitex
#pragma fragment frag_upsample_final
#pragma target 3.0
ENDCG
}
}
}

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5a711a01011934ebcb58ef5ad52159d6
timeCreated: 1435809878
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 866207198cc5f5446bdcb6bf04622938
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,6 @@
fileFormatVersion: 2
guid: cedc53e91a163eb498a6434b79d244de
MonoAssemblyImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fefa6bf75d5e8aa4f874e2d532120b42
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,75 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace CartoonFX
{
[InitializeOnLoad]
public class CFXR_WelcomeScreen : EditorWindow
{
static CFXR_WelcomeScreen()
{
EditorApplication.delayCall += () =>
{
if (SessionState.GetBool("CFXR_WelcomeScreen_Shown", false))
{
return;
}
SessionState.SetBool("CFXR_WelcomeScreen_Shown", true);
var importer = AssetImporter.GetAtPath(AssetDatabase.GUIDToAssetPath("bfd03f272fe010b4ba558a3bc456ffeb"));
if (importer != null && importer.userData == "dontshow")
{
return;
}
Open();
};
}
[MenuItem("Tools/Cartoon FX Remaster FREE - Welcome Screen")]
static void Open()
{
var window = GetWindow<CFXR_WelcomeScreen>(true, "Cartoon FX Remaster FREE", true);
window.minSize = new Vector2(516, 370);
window.maxSize = new Vector2(516, 370);
}
private void CreateGUI()
{
VisualElement root = rootVisualElement;
root.style.height = new StyleLength(new Length(100, LengthUnit.Percent));
// UXML
var uxmlDocument = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(AssetDatabase.GUIDToAssetPath("bfd03f272fe010b4ba558a3bc456ffeb"));
root.Add(uxmlDocument.Instantiate());
// USS
var styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>(AssetDatabase.GUIDToAssetPath("f8b971f10a610844f968f582415df874"));
root.styleSheets.Add(styleSheet);
// Background image
root.style.backgroundImage = new StyleBackground(AssetDatabase.LoadAssetAtPath<Texture2D>(AssetDatabase.GUIDToAssetPath("fed1b64fd853f994c8d504720a0a6d44")));
root.style.unityBackgroundScaleMode = ScaleMode.ScaleAndCrop;
// Logo image
var titleImage = root.Q<Image>("img_title");
titleImage.image = AssetDatabase.LoadAssetAtPath<Texture2D>(AssetDatabase.GUIDToAssetPath("a665b2e53088caa4c89dd09f9c889f62"));
// Buttons
root.Q<Label>("btn_cfxr1").AddManipulator(new Clickable(evt => { Application.OpenURL("https://assetstore.unity.com/packages/slug/4010"); }));
root.Q<Label>("btn_cfxr2").AddManipulator(new Clickable(evt => { Application.OpenURL("https://assetstore.unity.com/packages/slug/4274"); }));
root.Q<Label>("btn_cfxr3").AddManipulator(new Clickable(evt => { Application.OpenURL("https://assetstore.unity.com/packages/slug/10172"); }));
root.Q<Label>("btn_cfxr4").AddManipulator(new Clickable(evt => { Application.OpenURL("https://assetstore.unity.com/packages/slug/23634"); }));
root.Q<Label>("btn_cfxrbundle").AddManipulator(new Clickable(evt => { Application.OpenURL("https://assetstore.unity.com/packages/slug/232385"); }));
root.Q<Button>("close_dontshow").RegisterCallback<ClickEvent>(evt =>
{
this.Close();
var importer = AssetImporter.GetAtPath(AssetDatabase.GUIDToAssetPath("bfd03f272fe010b4ba558a3bc456ffeb"));
importer.userData = "dontshow";
importer.SaveAndReimport();
});
root.Q<Button>("close").RegisterCallback<ClickEvent>(evt => { this.Close(); });
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9c4fcce295aee5d4fb38ac4f82c8e664
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -88,7 +88,7 @@ Material:
m_Floats:
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 2
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
@ -97,8 +97,8 @@ Material:
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 1
- _DstBlendAlpha: 1
- _DstBlend: 10
- _DstBlendAlpha: 10
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
@ -117,8 +117,8 @@ Material:
- _WorkflowMode: 1
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 0.048973173, g: 0.9773584, b: 0, a: 0.54509807}
- _Color: {r: 0.04897315, g: 0.9773584, b: 0, a: 0.54509807}
- _BaseColor: {r: 0, g: 0, b: 0, a: 0}
- _Color: {r: 0, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

@ -0,0 +1,90 @@
Shader "Custom/TransparentOutline"
{
Properties
{
_MainColor ("Main Color", Color) = (1,1,1,0.5)
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Width", Range(0.001, 0.1)) = 0.02
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 100
// First Pass: Render the Outline Behind the Mesh
Pass {
Name "Outline"
Cull Front
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct appdata_t {
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
};
struct v2f {
float4 positionCS : SV_POSITION;
};
float _OutlineWidth;
float4 _OutlineColor;
v2f vert(appdata_t v) {
v2f o;
float3 normalWS = TransformObjectToWorldNormal(v.normalOS);
float3 positionWS = TransformObjectToWorld(v.positionOS.xyz);
positionWS += normalWS * _OutlineWidth;
o.positionCS = TransformWorldToHClip(positionWS);
return o;
}
half4 frag(v2f i) : SV_Target {
return _OutlineColor;
}
ENDHLSL
}
// Second Pass: Render the Transparent Mesh on Top
Pass {
Name "Main"
Cull Back
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct appdata_t {
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f {
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
};
float4 _MainColor;
v2f vert(appdata_t v) {
v2f o;
o.positionCS = TransformObjectToHClip(v.positionOS);
o.uv = v.uv;
return o;
}
half4 frag(v2f i) : SV_Target {
return _MainColor;
}
ENDHLSL
}
}
}

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b59e0f7271de96f44aeb59a7632efae2
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

@ -196,7 +196,7 @@ Material:
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 2.297397, g: 2.297397, b: 2.297397, a: 1}
- _HColor: {r: 0.785, g: 0.785, b: 0.785, a: 1}
- _OutlineColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
- _RimColor: {r: 0.8, g: 0.8, b: 0.8, a: 0.6}

@ -27,8 +27,8 @@ Transform:
m_GameObject: {fileID: 3201343961422696852}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 0, z: 1}
m_LocalPosition: {x: 0, y: -0.02, z: 0}
m_LocalScale: {x: 1, y: 0.3, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6009713983291384766}
@ -61,6 +61,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd, type: 2}
- {fileID: 2100000, guid: 3a415e4b90d5e7346a544b94fa0f34bd, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
@ -159,6 +160,18 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 6009713983291384766}
m_Modifications:
- target: {fileID: 1322199249233456991, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_Materials.Array.size
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1322199249233456991, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 7d59a0e48d5e5a34bbc8919ff8e3cecd, type: 2}
- target: {fileID: 1322199249233456991, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_Materials.Array.data[1]
value:
objectReference: {fileID: 2100000, guid: 3a415e4b90d5e7346a544b94fa0f34bd, type: 2}
- target: {fileID: 3764456690617734740, guid: bfc4217c8584ae04385dcac0be33d77e, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -377,6 +390,10 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5109095020609682098, guid: d3e4ffd5da62ee94e9eccf3ab52ec129, type: 3}
propertyPath: GlobalObjectIdHash
value: 3177087589
objectReference: {fileID: 0}
- target: {fileID: 5935320730402577130, guid: d3e4ffd5da62ee94e9eccf3ab52ec129, type: 3}
propertyPath: m_Name
value: Crow
@ -450,7 +467,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
propertyPath: GlobalObjectIdHash
value: 3737985212
value: 3177087589
objectReference: {fileID: 0}
- target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
propertyPath: PrefabHashGenerator

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 44e40926b9b189e4ab7438cc8356e2aa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,37 @@
Quick Outline
=============
Developed by Chris Nolet (c) 2018
Instructions
------------
To add an outline to an object, drag-and-drop the Outline.cs
script onto the object. The outline materials will be loaded
at runtime.
You can also add outlines programmatically with:
var outline = gameObject.AddComponent<Outline>();
outline.OutlineMode = Outline.Mode.OutlineAll;
outline.OutlineColor = Color.yellow;
outline.OutlineWidth = 5f;
The outline script does a small amount of work in Awake().
For best results, use outline.enabled to toggle the outline.
Avoid removing and re-adding the component if possible.
For large meshes, you may also like to enable 'Precompute
Outline' in the editor. This will reduce the amount of work
performed in Awake().
Troubleshooting
---------------
If the outline appears off-center, please try the following:
1. Set 'Read/Write Enabled' on each model's import settings.
2. Disable 'Optimize Mesh Data' in the player settings.

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5933bfd39d7a5b843a0ed821f85bca19
timeCreated: 1522619008
licenseType: Store
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 70fd40674751a8042a8b9b2e8d9f915f
folderAsset: yes
timeCreated: 1522559128
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 80ac8e52d3c31a94babd161e86bc6b97
folderAsset: yes
timeCreated: 1522559139
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: OutlineFill
m_Shader: {fileID: 4800000, guid: 4e76d4023d7e0411297c670f878973e2, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Floats:
- _OutlineWidth: 2
- _ZTest: 8
m_Colors:
- _OutlineColor: {r: 1, g: 1, b: 1, a: 1}

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 311313efa011949e98b6761d652ad13c
timeCreated: 1520576285
licenseType: Store
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,23 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: OutlineMask
m_Shader: {fileID: 4800000, guid: 341b058cd7dee4f5cba5cc59a513619e, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Floats:
- _ZTest: 8
m_Colors: []

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 106f3ff43a17d4967a2b64c7a92e49ec
timeCreated: 1520576276
licenseType: Store
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6a63caa2b0e993043a42c11f35ff2d1a
folderAsset: yes
timeCreated: 1522559134
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,81 @@
//
// OutlineFill.shader
// QuickOutline
//
// Created by Chris Nolet on 2/21/18.
// Copyright © 2018 Chris Nolet. All rights reserved.
//
Shader "Custom/Outline Fill" {
Properties {
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 0
_OutlineColor("Outline Color", Color) = (1, 1, 1, 1)
_OutlineWidth("Outline Width", Range(0, 10)) = 2
}
SubShader {
Tags {
"Queue" = "Transparent+110"
"RenderType" = "Transparent"
"DisableBatching" = "True"
}
Pass {
Name "Fill"
Cull Off
ZTest [_ZTest]
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
Stencil {
Ref 1
Comp NotEqual
}
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
struct appdata {
float4 vertex : POSITION;
float3 normal : NORMAL;
float3 smoothNormal : TEXCOORD3;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 position : SV_POSITION;
fixed4 color : COLOR;
UNITY_VERTEX_OUTPUT_STEREO
};
uniform fixed4 _OutlineColor;
uniform float _OutlineWidth;
v2f vert(appdata input) {
v2f output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float3 normal = any(input.smoothNormal) ? input.smoothNormal : input.normal;
float3 viewPosition = UnityObjectToViewPos(input.vertex);
float3 viewNormal = normalize(mul((float3x3)UNITY_MATRIX_IT_MV, normal));
output.position = UnityViewToClipPos(viewPosition + viewNormal * -viewPosition.z * _OutlineWidth / 1000.0);
output.color = _OutlineColor;
return output;
}
fixed4 frag(v2f input) : SV_Target {
return input.color;
}
ENDCG
}
}
}

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4e76d4023d7e0411297c670f878973e2
timeCreated: 1520575782
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,33 @@
//
// OutlineMask.shader
// QuickOutline
//
// Created by Chris Nolet on 2/21/18.
// Copyright © 2018 Chris Nolet. All rights reserved.
//
Shader "Custom/Outline Mask" {
Properties {
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 0
}
SubShader {
Tags {
"Queue" = "Transparent+100"
"RenderType" = "Transparent"
}
Pass {
Name "Mask"
Cull Off
ZTest [_ZTest]
ZWrite Off
ColorMask 0
Stencil {
Ref 1
Pass Replace
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save