diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code.meta b/Shader Forge/Assets/ShaderForge/Editor/Code.meta deleted file mode 100644 index da46b9b3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: bda2643522b22874ea0704332ec6d288 -folderAsset: yes -timeCreated: 1443376891 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Blending.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Blending.cs deleted file mode 100644 index 67a2d6fb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Blending.cs +++ /dev/null @@ -1,941 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - - public enum DepthTestStencil { Less, Greater, LEqual, GEqual, Equal, NotEqual, Always, Never }; - public enum StencilOp { Keep, Zero, Replace, Invert, IncrSat, DecrSat, IncrWrap, DecrWrap }; - public enum DepthTest { Less, Greater, LEqual, GEqual, Equal, NotEqual, Always }; - public enum RenderType { None, Opaque, Transparent, TransparentCutout, Background, Overlay, TreeOpaque, TreeTransparentCutout, TreeBillboard, Grass, GrassBillboard }; - public enum BlendModePreset { - Opaque, - AlphaBlended, - AlphaBlendedPremultiplied, - Additive, - Screen, - Multiplicative, - Custom - }; - public enum ShaderFogMode{ Global, Linear, Exp, Exp2 }; - public enum BlendMode { One, Zero, SrcColor, SrcAlpha, DstColor, DstAlpha, OneMinusSrcColor, OneMinusSrcAlpha, OneMinusDstColor, OneMinusDstAlpha }; - public enum Queue { Background, Geometry, AlphaTest, Transparent, Overlay }; - - public enum Dithering { Off, Dither2x2, Dither3x3, Dither4x4 }; - - - [System.Serializable] - public class SFPSC_Blending : SFPS_Category { - - public static string[] strDepthTestStencil = new string[] { "<", ">", "\u2264", "\u2265", "=", "\u2260", "Always (Default)", "Never" }; - public static string[] strStencilOp = new string[] { "Keep (Default)", "Zero", "Replace", "Invert", "Increase (Clamped)", "Decrease (Clamped)", "Increase (Wrapped)", "Decrease (Wrapped)" }; - public static string[] strDepthTest = new string[] { "<", ">", "\u2264 (Default)", "\u2265", "=", "\u2260", "Always" }; - public static int[] queueNumbers = new int[] { 1000, 2000, 2450, 3000, 4000 }; - public static string[] strQueue = new string[] { "Background (1000)", "Opaque Geometry (2000)", "Alpha Clip (2450)", "Transparent (3000)", "Overlay (4000)" }; - public static string[] strDithering = new string[] { "Off", "2x2 matrix", "3x3 matrix", "4x4 matrix" }; - - public static string[] strBlendModePreset = new string[] { - "Opaque", - "Alpha Blended", - "Alpha Blended (Premultiplied)", - "Additive", - "Screen", - "Multiplicative", - "" - }; - - - // Vars - - public BlendModePreset blendModePreset = BlendModePreset.Opaque; - public BlendMode blendSrc = BlendMode.One; - public BlendMode blendDst = BlendMode.Zero; - public DepthTest depthTest = DepthTest.LEqual; - - - public byte stencilValue = 128; - public byte stencilMaskRead = 255; - public byte stencilMaskWrite = 255; - public DepthTestStencil stencilComparison = DepthTestStencil.Always; - public StencilOp stencilPass = StencilOp.Keep; - public StencilOp stencilFail = StencilOp.Keep; - public StencilOp stencilFailZ = StencilOp.Keep; - - public int offsetFactor = 0; - public int offsetUnits = 0; - - // colorMask is a bitmask - // 0 = ____ - // 1 = ___A - // 2 = __B_ - // 3 = __BA - // 4 = _G__ - // 5 = _G_A - // 6 = _GB_ - // 7 = _GBA - // 8 = R___ - // 9 = R__A - // 10 = R_B_ - // 11 = R_BA - // 12 = RG__ - // 13 = RG_A - // 14 = RGB_ - // 15 = RGBA - public int colorMask = 15; - - public Dithering dithering = Dithering.Off; - public bool alphaToCoverage = false; - - public bool writeDepth = true; - - public bool useFog = true; - - public bool perObjectRefraction = true; - public string refractionPassName = "Refraction"; - - - public bool autoSort = true; - public Queue queuePreset = (Queue)1; - public int queueOffset = 0; - public RenderType renderType = RenderType.Opaque; - public bool ignoreProjector = false; - - - // Fog - public bool fogOverrideMode = false; - public ShaderFogMode fogMode = ShaderFogMode.Global; - - public bool fogOverrideColor = false; - public Color fogColor; - - public bool fogOverrideDensity = false; - public float fogDensity; - - public bool fogOverrideRange = false; - public Vector2 fogRange; - - - public bool useStencilBuffer = false; - public bool allowStencilWriteThroughProperties = false; - - - new void OnEnable() { - fogColor = RenderSettings.fogColor; - fogDensity = RenderSettings.fogDensity; - fogRange = new Vector2( RenderSettings.fogStartDistance, RenderSettings.fogEndDistance ); - base.hideFlags = HideFlags.HideAndDontSave; - } - - - public override string Serialize(){ - string s = ""; - - //s += Serialize( "blpr", ( (int)blendModePreset ).ToString() ); - s += Serialize( "bsrc", ( (int)blendSrc ).ToString() ); - s += Serialize( "bdst", ( (int)blendDst ).ToString() ); - s += Serialize( "dpts", ( (int)depthTest ).ToString() ); - s += Serialize( "wrdp", writeDepth.ToString() ); - - s += Serialize( "dith", ( (int)dithering ).ToString() ); - s += Serialize( "atcv", alphaToCoverage.ToString() ); // bool - - s += Serialize( "rfrpo", perObjectRefraction.ToString() ); - s += Serialize( "rfrpn", refractionPassName ); - - s += Serialize( "coma", colorMask.ToString() ); - - s += Serialize( "ufog", useFog.ToString() ); - s += Serialize( "aust", autoSort.ToString() ); - s += Serialize( "igpj", ignoreProjector.ToString() ); - s += Serialize( "qofs", queueOffset.ToString() ); - - s += Serialize( "qpre", ((int)queuePreset).ToString() ); - s += Serialize( "rntp", ( (int)renderType ).ToString() ); - s += Serialize( "fgom", fogOverrideMode.ToString()); // bool - s += Serialize( "fgoc", fogOverrideColor.ToString()); // bool - s += Serialize( "fgod", fogOverrideDensity.ToString()); // bool - s += Serialize( "fgor", fogOverrideRange.ToString()); // bool - - s += Serialize( "fgmd", ((int)fogMode).ToString()); // FogMode - s += Serialize( "fgcr", fogColor.r.ToString()); // Fog Color - s += Serialize( "fgcg", fogColor.g.ToString()); // Fog Color - s += Serialize( "fgcb", fogColor.b.ToString()); // Fog Color - s += Serialize( "fgca", fogColor.a.ToString()); // Fog Color - s += Serialize( "fgde", fogDensity.ToString()); // float - s += Serialize( "fgrn", fogRange.x.ToString()); // Fog range X (Near) - s += Serialize( "fgrf", fogRange.y.ToString()); // Fog range Y (Far) - - - // Stencil buffer: - s += Serialize ( "stcl", useStencilBuffer.ToString()); - s += Serialize ( "atwp", allowStencilWriteThroughProperties.ToString()); - s += Serialize ( "stva", stencilValue.ToString()); - s += Serialize ( "stmr", stencilMaskRead.ToString()); - s += Serialize ( "stmw", stencilMaskWrite.ToString()); - s += Serialize ( "stcp", ((int)stencilComparison).ToString()); - s += Serialize ( "stps", ((int)stencilPass).ToString()); - s += Serialize ( "stfa", ((int)stencilFail).ToString()); - s += Serialize ( "stfz", ((int)stencilFailZ).ToString()); - - - // Offset - s += Serialize ( "ofsf", offsetFactor.ToString()); - s += Serialize ( "ofsu", offsetUnits.ToString()); - - return s; - } - - bool lockSrcDstRead = false; - - public override void Deserialize(string key, string value){ - - - - switch( key ) { - - case "blpr": // This is no longer saved, but in old shaders, we have to read it with old enum indices - - // 0 "Opaque", - // 1 "Alpha Blended", - // - "Alpha Blended (Premultiplied)", - // 2 "Additive", - // 3 "Screen", - // 4 "Multiplicative", - - int iVal = int.Parse( value ); - if( iVal > 1 ) // Offset due to adding premul - iVal++; - blendModePreset = (BlendModePreset)iVal; - ConformBlendsToPreset(); - - lockSrcDstRead = true; - break; - case "bsrc": - if( lockSrcDstRead ) - break; - blendSrc = (BlendMode)int.Parse( value ); - break; - case "bdst": - if( lockSrcDstRead ) { - lockSrcDstRead = false; - break; - } - blendDst = (BlendMode)int.Parse( value ); - ConformPresetToBlend(); - break; - case "dpts": - depthTest = (DepthTest)int.Parse( value ); - break; - case "wrdp": - writeDepth = bool.Parse( value ); - break; - case "dith": - dithering = (Dithering)int.Parse( value ); - break; - case "atcv": - alphaToCoverage = bool.Parse( value ); - break; - case "rfrpo": - perObjectRefraction = bool.Parse( value ); - break; - case "rfrpn": - refractionPassName = value; - break; - case "coma": - colorMask = int.Parse( value ); - break; - case "ufog": - useFog = bool.Parse( value ); - break; - case "aust": - autoSort = bool.Parse( value ); - break; - case "igpj": - ignoreProjector = bool.Parse( value ); - break; - case "qofs": - queueOffset = int.Parse( value ); - break; - - case "qpre": - queuePreset = (Queue)int.Parse( value ); - break; - - case "rntp": - renderType = (RenderType)int.Parse( value ); - break; - // Fog booleans - case "fgom": - fogOverrideMode = bool.Parse( value ); - break; - case "fgoc": - fogOverrideColor = bool.Parse( value ); - break; - case "fgod": - fogOverrideDensity = bool.Parse( value ); - break; - case "fgor": - fogOverrideRange = bool.Parse( value ); - break; - - // Fog values - case "fgmd": - fogMode = (ShaderFogMode)int.Parse( value ); - break; - case "fgcr": - fogColor.r = float.Parse( value ); - break; - case "fgcg": - fogColor.g = float.Parse( value ); - break; - case "fgcb": - fogColor.b = float.Parse( value ); - break; - case "fgca": - fogColor.a = float.Parse( value ); - break; - case "fgde": - fogDensity = float.Parse( value ); - break; - case "fgrn": - fogRange.x = float.Parse( value ); - break; - case "fgrf": - fogRange.y = float.Parse( value ); - break; - // Stencil buffer: - case "stcl": - useStencilBuffer = bool.Parse(value); - break; - case "atwp": - allowStencilWriteThroughProperties = bool.Parse( value ); - break; - case "stva": - stencilValue = byte.Parse(value); - break; - case "stmr": - stencilMaskRead = byte.Parse(value); - break; - case "stmw": - stencilMaskWrite = byte.Parse(value); - break; - case "stcp": - stencilComparison = (DepthTestStencil)int.Parse(value); - break; - case "stps": - stencilPass = (StencilOp)int.Parse(value); - break; - case "stfa": - stencilFail = (StencilOp)int.Parse(value); - break; - case "stfz": - stencilFailZ = (StencilOp)int.Parse(value); - break; - - // Offset - case "ofsf": - offsetFactor = int.Parse(value); - break; - case "ofsu": - offsetUnits = int.Parse(value); - break; - } - - } - - - public string GetGrabTextureName() { - if( perObjectRefraction ) { - return "_GrabTexture"; - } else { - return refractionPassName; - } - } - - - - public override float DrawInner(ref Rect r){ - - - float prevYpos = r.y; - r.y = 0; - - r.y += 20; - r.xMin += 20; // Indent - - BlendModePreset before = blendModePreset; - GUI.enabled = ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Forward; - blendModePreset = (BlendModePreset)UndoableLabeledEnumPopupNamed( r, "Blend Mode", blendModePreset, strBlendModePreset, "blend mode"); - GUI.enabled = true; - if( blendModePreset != before ) { - ConformBlendsToPreset(); - } - if( blendModePreset == BlendModePreset.Custom ) { - GUI.color = new Color(1f,1f,1f,0.5f); - GUI.Label(r.PadLeft(70).PadTop(-1), "Custom blending. Click select preset", EditorStyles.miniLabel); - GUI.color = Color.white; - } - - r.y += 20; - - //if( blendModePreset != BlendModePreset.Opaque ) { - //if( blendModePreset != BlendModePreset.Custom ) - //GUI.enabled = false; - //EditorGUILayout.BeginHorizontal( GUILayout.Width( maxWidth ) ); - //{ - //Indent(); - - string srcStr = "Source * "; - string dstStr = " + Destination * "; - int srcStrWidth = SF_GUI.WidthOf(srcStr,EditorStyles.miniLabel); - int dstStrWidth = SF_GUI.WidthOf(dstStr,EditorStyles.miniLabel); - int fieldWidth = Mathf.FloorToInt((r.width - srcStrWidth - dstStrWidth)/2); - - Rect rSrcLb = new Rect(r); rSrcLb.width = srcStrWidth; - Rect rSrcField = new Rect(r); rSrcField.x = rSrcLb.xMax; rSrcField.width = fieldWidth; - Rect rDstLb = new Rect(r); rDstLb.x = rSrcField.xMax; rDstLb.width = dstStrWidth; - Rect rDstField = new Rect(rSrcField); rDstField.x = rDstLb.xMax; - - EditorGUI.BeginChangeCheck(); - - GUI.Label( rSrcLb, srcStr, EditorStyles.miniLabel ); - blendSrc = (BlendMode)UndoableEnumPopup(rSrcField, blendSrc, "blend source" ); - GUI.Label( rDstLb, dstStr, EditorStyles.miniLabel ); - blendDst = (BlendMode)UndoableEnumPopup(rDstField, blendDst, "blend destination" ); - - if( EditorGUI.EndChangeCheck() ) { - ConformPresetToBlend(); - } - - //if( blendModePreset != BlendModePreset.Custom ) - //GUI.enabled = true; - - r.y += 20; - //} - - - UndoableColorMask( r, "Color Mask", ref colorMask ); - r.y += 20; - - bool canEditDithering = editor.mainNode.alphaClip.IsConnectedAndEnabled(); - EditorGUI.BeginDisabledGroup( !canEditDithering ); - if( canEditDithering ) - dithering = (Dithering)UndoableLabeledEnumPopupNamed( r, "Dithered alpha clip", dithering, strDithering, "dithered alpha clip" ); - else - UndoableLabeledEnumPopup( r, "Dithered alpha clip", Dithering.Off, "dithered alpha clip" ); - EditorGUI.EndDisabledGroup(); - r.y += 20; - - bool canEditAlphaToCoverage = editor.mainNode.alphaClip.IsConnectedAndEnabled() || editor.mainNode.alpha.IsConnectedAndEnabled(); - EditorGUI.BeginDisabledGroup( !canEditAlphaToCoverage ); - if( canEditAlphaToCoverage ) - alphaToCoverage = UndoableToggle( r, alphaToCoverage, "Alpha to coverage (forward with MSAA only)", "alpha to coverage" ); - else - GUI.Toggle( r, false, "Alpha to coverage (forward with MSAA only)" ); - EditorGUI.EndDisabledGroup(); - r.y += 20; - - - OffsetBlock (ref r); - - - RefractionBlock( ref r ); - - - FogBlock(ref r); - - SortingBlock(ref r); - - - - StencilBlock(ref r); - - r.y += prevYpos; - - return (int)r.yMax; - } - - static string[] rgba = new string[]{"R","G","B","A"}; - - public void UndoableColorMask(Rect r, string label, ref int mask) { - - GUIStyle[] rgbaStyles = new GUIStyle[] { - EditorStyles.miniButtonLeft, - EditorStyles.miniButtonMid, - EditorStyles.miniButtonMid, - EditorStyles.miniButtonRight - }; - - Rect[] rects = r.SplitFromLeft( 65 ); - - GUI.Label( rects[0], label, EditorStyles.miniLabel ); - - - Rect buttonRect = rects[1]; - buttonRect.width = 23;// Mathf.FloorToInt( buttonRect.width / 4 ); - buttonRect.height = 17; - - for( int i = 0; i < 4; i++ ) { - //GUI.color = rgbaCols[i]; - bool bitVal = mask.GetBit( 3 - i ); - bool newBit = GUI.Toggle( buttonRect, bitVal, rgba[i], rgbaStyles[i] ); - if( newBit != bitVal ) { - Undo.RecordObject( this, "edit Color Mask" ); - mask = mask.SetBit( 3 - i, newBit ); - } - buttonRect = buttonRect.MovedRight(); - } - - buttonRect.width *= 4; - buttonRect.x += 6; - GUI.color = Color.gray; - GUI.Label( buttonRect, mask.ToColorMaskString(), EditorStyles.miniLabel ); - GUI.color = Color.white; - - - - - } - - - - - public void SetQueuePreset( Queue in_queue ) { - queuePreset = in_queue; - } - - public void ConformPresetToBlend() { - - - bool matched = false; - matched |= ApplyIfMatch(BlendModePreset.Opaque, BlendMode.One, BlendMode.Zero ); - matched |= ApplyIfMatch(BlendModePreset.Additive, BlendMode.One, BlendMode.One ); - matched |= ApplyIfMatch(BlendModePreset.Screen, BlendMode.OneMinusDstColor, BlendMode.One ); - matched |= ApplyIfMatch(BlendModePreset.Screen, BlendMode.One, BlendMode.OneMinusSrcColor ); - matched |= ApplyIfMatch(BlendModePreset.AlphaBlended, BlendMode.SrcAlpha, BlendMode.OneMinusSrcAlpha ); - matched |= ApplyIfMatch(BlendModePreset.AlphaBlendedPremultiplied, BlendMode.One, BlendMode.OneMinusSrcAlpha ); - matched |= ApplyIfMatch(BlendModePreset.Multiplicative, BlendMode.DstColor, BlendMode.Zero ); - matched |= ApplyIfMatch(BlendModePreset.Multiplicative, BlendMode.Zero, BlendMode.SrcColor ); - - if(!matched){ - blendModePreset = BlendModePreset.Custom; - } - - } - - - public bool ApplyIfMatch(BlendModePreset preset, BlendMode src, BlendMode dst) { - if( blendSrc == src && blendDst == dst ) { - blendModePreset = preset; - UpdateAutoSettings(); - return true; - } - return false; - - } - - public void ConformBlendsToPreset() { - switch( blendModePreset ) { - case BlendModePreset.Opaque: - blendSrc = BlendMode.One; - blendDst = BlendMode.Zero; - break; - case BlendModePreset.Additive: - blendSrc = BlendMode.One; - blendDst = BlendMode.One; - break; - case BlendModePreset.Screen: - blendSrc = BlendMode.One; - blendDst = BlendMode.OneMinusSrcColor; - break; - case BlendModePreset.AlphaBlended: - blendSrc = BlendMode.SrcAlpha; - blendDst = BlendMode.OneMinusSrcAlpha; - break; - case BlendModePreset.AlphaBlendedPremultiplied: - blendSrc = BlendMode.One; - blendDst = BlendMode.OneMinusSrcAlpha; - break; - case BlendModePreset.Multiplicative: - blendSrc = BlendMode.DstColor; - blendDst = BlendMode.Zero; - break; - } - editor.preview.InternalMaterial.renderQueue = -1; - } - - - public string GetStencilContent(){ - - string s = ""; - if( allowStencilWriteThroughProperties ) { - s += "Ref [_Stencil]\n"; - s += "ReadMask [_StencilReadMask]\n"; - s += "WriteMask [_StencilWriteMask]\n"; - s += "Comp [_StencilComp]\n"; - s += "Pass [_StencilOp]\n"; - s += "Fail [_StencilOpFail]\n"; - s += "ZFail [_StencilOpZFail]"; - } else { - s += "Ref " + stencilValue + "\n"; - if( stencilMaskRead != (byte)255 ) - s += "ReadMask " + stencilMaskRead + "\n"; - if( stencilMaskWrite != (byte)255 ) - s += "WriteMask " + stencilMaskWrite + "\n"; - if( stencilComparison != DepthTestStencil.Always ) - s += "Comp " + stencilComparison + "\n"; - if( stencilPass != StencilOp.Keep ) - s += "Pass " + stencilPass + "\n"; - if( stencilFail != StencilOp.Keep ) - s += "Fail " + stencilFail + "\n"; - if( stencilFailZ != StencilOp.Keep ) - s += "ZFail " + stencilFailZ + "\n"; - s = s.Substring( 0, s.Length - 1 ); - } - return s; - } - - public void RefractionBlock( ref Rect r ) { - - - - perObjectRefraction = UndoableToggle( r, perObjectRefraction, "Per-object refraction/scene color (expensive)", "per-object refraction", null ); - r.y += 20; - - ps.StartIgnoreChangeCheck(); - r.xMin += 20; - Rect right = r; - right.xMin += 126; - right.width -= 18; - Rect left = r; - left.width -= right.width; - GUI.enabled = !perObjectRefraction; - GUI.Label(left, "Texture name/group"); - EditorGUI.BeginChangeCheck(); - refractionPassName = UndoableTextField( right, refractionPassName, "refraction pass name", null, null, true ); - if( EditorGUI.EndChangeCheck() ) { - editor.ShaderOutdated = UpToDateState.OutdatedSoft; - SF_Tools.FormatAlphanumeric( ref refractionPassName ); - } - GUI.enabled = true; - r.y += 20; - r.xMin -= 20; - - - - ps.EndIgnoreChangeCheck(); - } - - - public void OffsetBlock(ref Rect r){ - ps.StartIgnoreChangeCheck(); - Rect rOfs = r; - rOfs.xMax -= 4; // Margin - rOfs.width = 80; - GUI.Label(rOfs, "Offset Factor"); - rOfs = rOfs.MovedRight(); - rOfs.width /= 2; - offsetFactor = UndoableIntField(rOfs,offsetFactor,"offset factor"); - rOfs = rOfs.MovedRight(); - rOfs.width *= 2; - GUI.Label(rOfs.PadLeft(4), "Offset Units"); - rOfs = rOfs.MovedRight(); - rOfs.width /= 2; - offsetUnits = UndoableIntField(rOfs,offsetUnits,"offset units"); - r.y += 20; - ps.EndIgnoreChangeCheck(); - } - - - public void StencilBlock(ref Rect r){ - - bool prevUseStencilBuffer = useStencilBuffer; - useStencilBuffer = GUI.Toggle(r, useStencilBuffer, useStencilBuffer ? "Stencil Buffer" : "Stencil Buffer..."); - if( useStencilBuffer != prevUseStencilBuffer ) - UpdateAutoSettings(); - r.y += 20; - if(!useStencilBuffer) - return; - r.xMin += 20; - - allowStencilWriteThroughProperties = UndoableToggle( r, allowStencilWriteThroughProperties, "Expose stencil as properties", "toggle expose stencil as properties" ); - r.y += 20; - - EditorGUI.BeginDisabledGroup( allowStencilWriteThroughProperties ); - - Rect rTmp = r; - rTmp.width = 88; - GUI.Label(rTmp,"Reference Value", EditorStyles.miniLabel); - rTmp = rTmp.MovedRight(); - rTmp.width -= 48; - stencilValue = (byte)UndoableIntField( rTmp.PadRight( 4 ).PadTop( 1 ).PadBottom( 2 ), stencilValue, "reference value" ); - rTmp = rTmp.MovedRight(); - rTmp.width = r.width-128; - stencilComparison = (DepthTestStencil)UndoableLabeledEnumPopupNamed( rTmp.PadRight( 4 ).ClampWidth( 32, 140 ), "Comparison", stencilComparison, strDepthTestStencil, "stencil comparison" ); - r.y += 20; - - StencilBitfield(r, "Read Mask", ref stencilMaskRead); - r.y += 20; - StencilBitfield(r, "Write Mask", ref stencilMaskWrite); - r.y += 23; - stencilPass = (StencilOp)UndoableLabeledEnumPopupNamed( r.PadRight( 4 ), "Pass", stencilPass, strStencilOp, "stencil pass" ); - r.y += 20; - stencilFail = (StencilOp)UndoableLabeledEnumPopupNamed( r.PadRight( 4 ), "Fail", stencilFail, strStencilOp, "stencil fail" ); - r.y += 20; - stencilFailZ = (StencilOp)UndoableLabeledEnumPopupNamed( r.PadRight( 4 ), "Fail Z", stencilFailZ, strStencilOp, "stencil fail Z" ); - r.y += 20; - r.xMin -= 20; - r.y += 20; - - EditorGUI.EndDisabledGroup(); - } - - - - public void StencilBitfield( Rect r, string label, ref byte b ){ - ps.StartIgnoreChangeCheck(); - Rect tmp = r; - tmp.width = 62; - - GUI.Label(tmp,label, SF_Styles.MiniLabelRight); - - tmp = tmp.MovedRight(); - tmp.width = 36; - b = (byte)EditorGUI.IntField(tmp.PadTop(1).PadBottom(2).PadRight(2).PadLeft(2),b); - - Rect bitField = r; - bitField.xMin += 57+36 + 4 + 8; - bitField.xMax -= 4; - - - bitField.width /= 8; // 8 bits - for (int i = 8 - 1; i >= 0; i--) { - - GUIStyle btnStyle; - - if(i==0) - btnStyle = EditorStyles.miniButtonRight; - else if(i==7) - btnStyle = EditorStyles.miniButtonLeft; - else - btnStyle = EditorStyles.miniButtonMid; - - bool bit = ( (1< 0 && !expanded ) { - r = r.MovedRight(); - r.width = SF_Styles.IconErrorSmall.width; - r = r.MovedLeft(); - r.height = SF_Styles.IconErrorSmall.height; - r.x -= 1; - r.y += 1; - - bool hasError = false; - for( int i = 0; i < treeStatus.Errors.Count; i++ ) { - if( treeStatus.Errors[i].isWarning == false ) { - hasError = true; - break; - } - } - - GUI.DrawTexture( r, hasError ? SF_Styles.IconErrorSmall : SF_Styles.IconWarningSmall ); - } - - } - - - public override float DrawInner(ref Rect r){ - - float prevYpos = r.y; - r.y = 0; - - - - - r.xMin += 20; - r.y += 20; - //GUI.DrawTexture(r.ClampSize(0,SF_Styles.IconWarningSmall.width),SF_Styles.IconWarningSmall); - //r.xMin += 20; - //GUI.Label(r, "Experimental features may not work"); - //r.xMin -= 20; - // r.height += 20; - - r.height = 20; - - for( int i = 0; i < treeStatus.Errors.Count; i++ ) { - - bool isNode = treeStatus.Errors[i].node != null; - - Texture2D icon = treeStatus.Errors[i].icon; - - Rect blockRect = r; - blockRect.height = treeStatus.Errors[i].rows * 14f + 6; - - - Rect iconRect = blockRect; - iconRect.width = icon.width; - iconRect.height = icon.height; - //iconRect.x += 1; - //iconRect.y += 1; - - Rect textRect = blockRect; - textRect.xMin += iconRect.width + 3; - - iconRect.center = new Vector2( iconRect.center.x, textRect.center.y ); - - bool hasAction = treeStatus.Errors[i].action != null; - - if( isNode || hasAction ) { - if( GUI.Button( iconRect.Pad( -2 ).PadHorizontal(-3), "" ) ) { - if( hasAction ) { - treeStatus.Errors[i].OnPress(); - break; - } else if( isNode ) { - editor.nodeView.selection.DeselectAll( true ); - treeStatus.Errors[i].node.Select( true ); - } - } - } - - GUI.DrawTexture( iconRect, icon ); - EditorGUI.SelectableLabel( textRect, treeStatus.Errors[i].error, SF_Styles.SmallTextArea ); - - r.y += textRect.height; - } - - - r.y += prevYpos; - - return (int)r.yMax; - } - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Console.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Console.cs.meta deleted file mode 100644 index 96b68382..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Console.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 82fffb1e4de9ece4095359142f8821a4 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Experimental.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Experimental.cs deleted file mode 100644 index 991a760b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Experimental.cs +++ /dev/null @@ -1,79 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - - [System.Serializable] - public class SFPSC_Experimental : SFPS_Category { - - - public bool force2point0 = false; - public bool forceNoShadowPass = false; - public bool forceNoFallback = false; - public bool forceSkipModelProjection = false; - - - public override string Serialize(){ - string s = ""; - s += Serialize( "f2p0", force2point0.ToString() ); - s += Serialize( "fnsp", forceNoShadowPass.ToString() ); - s += Serialize( "fnfb", forceNoFallback.ToString() ); - s += Serialize( "fsmp", forceSkipModelProjection.ToString() ); - return s; - } - - public override void Deserialize(string key, string value){ - - switch( key ) { - case "f2p0": - force2point0 = bool.Parse( value ); - break; - case "fnsp": - forceNoShadowPass = bool.Parse( value ); - break; - case "fnfb": - forceNoFallback = bool.Parse( value ); - break; - case "fsmp": - forceSkipModelProjection = bool.Parse( value ); - break; - } - - } - - - - public override float DrawInner(ref Rect r){ - - float prevYpos = r.y; - r.y = 0; - - - r.xMin += 20; - r.y += 20; - GUI.DrawTexture(r.ClampSize(0,SF_Styles.IconWarningSmall.width),SF_Styles.IconWarningSmall); - r.xMin += 20; - GUI.Label(r, "Experimental features may not work"); - r.xMin -= 20; - r.y += 20; - force2point0 = UndoableToggle( r, force2point0, "Force Shader Model 2.0", "shader model 2.0 forcing", null ); - r.y += 20; - forceNoShadowPass = UndoableToggle( r, forceNoShadowPass, "Force no custom shadow pass", "force no custom shadow pass", null ); - r.y += 20; - forceNoFallback = UndoableToggle( r, forceNoFallback, "Force no fallback", "force no fallback", null ); - r.y += 20; - forceSkipModelProjection = UndoableToggle( r, forceSkipModelProjection, "Force skip model projection", "force skip model projection", null ); - r.y += 20; - - r.y += prevYpos; - - return (int)r.yMax; - } - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Experimental.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Experimental.cs.meta deleted file mode 100644 index 9f5d378e..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Experimental.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bb31a79ea298f4f939ce86ad39dc270a -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Geometry.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Geometry.cs deleted file mode 100644 index 523f5038..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Geometry.cs +++ /dev/null @@ -1,163 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - - [System.Serializable] - public class SFPSC_Geometry : SFPS_Category { - - public enum VertexPositioning { LocalSpace, ClipSpace, Billboard }; - public string[] strVertexPositioning = new string[] { "Local space", "Clip space", "Billboard" }; - public enum NormalQuality { Interpolated, Normalized }; - public string[] strNormalQuality = new string[] { "Interpolated", "Normalized" }; - public enum NormalSpace { Tangent, Object, World }; - public string[] strNormalSpace = new string[] { "Tangent", "Object", "World" }; - public enum TessellationMode { Regular, EdgeLength/*, EdgeLengthCulled*/}; - public string[] tessModeStr = new string[] { "Regular", "Edge length based"/*, "Edge length based with frustrum culling"*/}; - public enum VertexOffsetMode { Relative, Absolute } - public string[] vertexOffsetModeStr = new string[] { "Relative", "Absolute" }; - public enum OutlineMode { FromOrigin, VertexNormals, VertexColors }; - public string[] outlineModeStr = new string[] { "From origin", "Vertex normals", "Vertex colors" }; - public enum CullMode { BackfaceCulling, FrontfaceCulling, DoubleSided }; - public static string[] strCullMode = new string[] { "Back", "Front", "Off" }; - - public VertexPositioning vertexPositioning = VertexPositioning.LocalSpace; - public NormalQuality normalQuality = NormalQuality.Normalized; - public NormalSpace normalSpace = NormalSpace.Tangent; - public VertexOffsetMode vertexOffsetMode = VertexOffsetMode.Relative; - public bool showPixelSnap = false; - public bool highQualityScreenCoords = true; - public TessellationMode tessellationMode = TessellationMode.Regular; - public OutlineMode outlineMode = OutlineMode.VertexNormals; - public CullMode cullMode = CullMode.BackfaceCulling; - - - - public override string Serialize(){ - string s = ""; - s += Serialize( "vtps", ( (int)vertexPositioning ).ToString() ); - s += Serialize( "hqsc", highQualityScreenCoords.ToString()); - s += Serialize( "nrmq", ( (int)normalQuality ).ToString() ); - s += Serialize( "nrsp", ( (int)normalSpace ).ToString() ); - s += Serialize( "vomd", ( (int)vertexOffsetMode ).ToString() ); - s += Serialize( "spxs", showPixelSnap.ToString()); - s += Serialize( "tesm", ((int)tessellationMode).ToString()); - s += Serialize( "olmd", ( (int)outlineMode ).ToString() ); - s += Serialize( "culm", ( (int)cullMode ).ToString() ); - return s; - } - - public override void Deserialize(string key, string value){ - - switch( key ) { - case "vtps": - vertexPositioning = (VertexPositioning)int.Parse( value ); - break; - case "nrmq": - normalQuality = (NormalQuality)int.Parse( value ); - break; - case "nrsp": - normalSpace = (NormalSpace)int.Parse( value ); - break; - case "vomd": - vertexOffsetMode = (VertexOffsetMode)int.Parse( value ); - break; - case "hqsc": - highQualityScreenCoords = bool.Parse( value ); - break; - case "spxs": - showPixelSnap = bool.Parse( value ); - break; - case "tesm": - tessellationMode = (TessellationMode)int.Parse( value ); - break; - case "olmd": - outlineMode = (OutlineMode)int.Parse( value ); - break; - case "culm": - cullMode = (CullMode)int.Parse( value ); - break; - } - - } - - - public override float DrawInner(ref Rect r){ - - float prevYpos = r.y; - r.y = 0; - - - r.xMin += 20; - r.y += 20; - - - cullMode = (CullMode)UndoableLabeledEnumPopup( r, "Face Culling", cullMode, "face culling" ); - r.y += 20; - - GUI.enabled = ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Forward; - normalQuality = (NormalQuality)UndoableContentScaledToolbar( r, "Normal Quality", (int)normalQuality, strNormalQuality, "normal quality" ); - GUI.enabled = true; - r.y += 20; - - vertexPositioning = (VertexPositioning)UndoableContentScaledToolbar( r, "Vertex Positioning", (int)vertexPositioning, strVertexPositioning, "vertex positioning" ); - r.y += 20; - - GUI.enabled = ps.mOut.normal.IsConnectedEnabledAndAvailable(); - normalSpace = (NormalSpace)UndoableContentScaledToolbar( r, "Normal Space", (int)normalSpace, strNormalSpace, "normal space" ); - GUI.enabled = true; - r.y += 20; - - vertexOffsetMode = (VertexOffsetMode)UndoableContentScaledToolbar( r, "Vertex offset mode", (int)vertexOffsetMode, vertexOffsetModeStr, "vertex offset mode" ); - r.y += 20; - - GUI.enabled = ps.HasTessellation(); - tessellationMode = (TessellationMode)UndoableLabeledEnumPopupNamed( r, "Tessellation Mode", tessellationMode, tessModeStr, "tessellation mode" ); - GUI.enabled = true; - r.y += 20; - - GUI.enabled = ps.HasOutline(); - outlineMode = (OutlineMode)UndoableLabeledEnumPopupNamed( r, "Outline Extrude Direction", outlineMode, outlineModeStr, "outline mode" ); - GUI.enabled = true; - r.y += 20; - - highQualityScreenCoords = UndoableToggle( r, highQualityScreenCoords, "Per-pixel screen coordinates", "per-pixel screen coordinates", null ); - r.y += 20; - - showPixelSnap = UndoableToggle( r, showPixelSnap, "Show 2D sprite pixel snap option in material", "show pixel snap", null ); - r.y += 20; - - r.y += prevYpos; - - return (int)r.yMax; - } - - - - // TODO: Double sided support - public string GetNormalSign() { - if( cullMode == CullMode.BackfaceCulling ) - return ""; - if( cullMode == CullMode.FrontfaceCulling ) - return "-"; - //if( cullMode == CullMode.DoubleSided ) - return ""; - } - - public bool UseCulling() { - return ( cullMode != CullMode.BackfaceCulling ); - } - public string GetCullString() { - return "Cull " + strCullMode[(int)cullMode]; - } - public bool IsDoubleSided() { - return ( cullMode == CullMode.DoubleSided ); - } - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Geometry.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Geometry.cs.meta deleted file mode 100644 index f50aa7e1..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Geometry.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d931c87bc14d34c86a08c0428175c5a6 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Lighting.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Lighting.cs deleted file mode 100644 index 899e7ad7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Lighting.cs +++ /dev/null @@ -1,365 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - - [System.Serializable] - public class SFPSC_Lighting : SFPS_Category { - - public RenderPath renderPath = RenderPath.Forward; - public LightPrecision lightPrecision = LightPrecision.Fragment; - public LightMode lightMode = LightMode.BlinnPhong; - public SpecularMode specularMode = SpecularMode.Metallic; - public TransparencyMode transparencyMode = TransparencyMode.Fade; - public GlossRoughMode glossRoughMode = GlossRoughMode.Gloss; - public LightCount lightCount = LightCount.Multi; - - public bool useAmbient = true; - public bool maskedSpec = true; - public bool geometricAntiAliasing = false; - //public bool shadowCast = true; - //public bool shadowReceive = true; - public bool bakedLight = false; - public bool highQualityLightProbes = false; - public bool reflectprobed = false; - public bool energyConserving = false; - public bool remapGlossExponentially = true; - public bool includeMetaPass = true; - - public enum RenderPath { Forward, Deferred }; - public string[] strRenderPath = new string[] { "Forward", "Deferred" }; - - - public enum LightPrecision { Vertex, Fragment }; - public string[] strLightPrecision = new string[] { "Per-Vertex", "Per-Fragment" }; - public enum LightMode { Unlit, BlinnPhong, Phong, PBL }; - public string[] strLightMode = new string[] { "Unlit/Custom", "Blinn-Phong", "Phong", "PBL" }; - public enum SpecularMode { Specular, Metallic }; - public string[] strSpecularMode = new string[] { "Specular", "Metallic" }; - public enum TransparencyMode { Fade, Reflective }; - public string[] strTransparencyMode = new string[] { "Fade", "Reflective" }; - public enum GlossRoughMode { Gloss, Roughness }; - public string[] strGlossRoughMode = new string[] { "Gloss", "Roughness" }; - public enum LightCount { Single, Multi }; - public string[] strLightCount = new string[] { "Single Directional", "Multi-light"}; - - - - public override string Serialize(){ - string s = ""; - s += Serialize( "lico", ( (int)lightCount ).ToString() ); - s += Serialize( "lgpr", ( (int)lightPrecision ).ToString() ); - s += Serialize( "limd", ( (int)lightMode ).ToString() ); - s += Serialize( "spmd", ( (int)specularMode ).ToString() ); - s += Serialize( "trmd", ( (int)transparencyMode ).ToString() ); - s += Serialize( "grmd", ( (int)glossRoughMode ).ToString() ); - s += Serialize( "uamb", useAmbient.ToString() ); - s += Serialize( "mssp", maskedSpec.ToString() ); - s += Serialize( "bkdf", bakedLight.ToString() ); - s += Serialize( "hqlp", highQualityLightProbes.ToString() ); - s += Serialize( "rprd", reflectprobed.ToString() ); - s += Serialize( "enco", energyConserving.ToString()); - s += Serialize( "rmgx", remapGlossExponentially.ToString()); - s += Serialize( "imps", includeMetaPass.ToString() ); - s += Serialize( "rpth", ((int)renderPath).ToString() ); - - //s += Serialize( "shdc", shadowCast.ToString() ); - //s += Serialize( "shdr", shadowReceive.ToString() ); - return s; - } - - public override void Deserialize(string key, string value){ - - - switch( key ) { - case "lgpr": - lightPrecision = (LightPrecision)int.Parse( value ); - break; - case "limd": - lightMode = (LightMode)int.Parse( value ); - break; - case "uamb": - useAmbient = bool.Parse( value ); - break; - case "mssp": - maskedSpec = bool.Parse( value ); - break; - case "bkdf": - bakedLight = bool.Parse( value ); - break; - case "spmd": - specularMode = (SpecularMode)int.Parse( value ); - break; - case "trmd": - transparencyMode = (TransparencyMode)int.Parse( value ); - break; - case "grmd": - glossRoughMode = (GlossRoughMode)int.Parse( value ); - break; - - /*case "shdc": - shadowCast = bool.Parse( value ); - break; - case "shdr": - shadowReceive = bool.Parse( value ); - break;*/ - case "lico": - lightCount = (LightCount)int.Parse( value ); - break; - case "lmpd": - bakedLight |= bool.Parse( value ); - break; - case "lprd": - bakedLight |= bool.Parse( value ); - break; - case "hqlp": - highQualityLightProbes = bool.Parse( value ); - break; - case "rprd": - reflectprobed = bool.Parse( value ); - break; - case "enco": - energyConserving = bool.Parse( value ); - break; - - - case "rmgx": - remapGlossExponentially = bool.Parse( value ); - break; - case "imps": - includeMetaPass = bool.Parse( value ); - break; - case "rpth": - renderPath = (RenderPath)int.Parse( value ); - break; - } - - } - - - - public override float DrawInner(ref Rect r){ - - float prevYpos = r.y; - r.y = 0; - - - r.xMin += 20; - r.y += 20; - - renderPath = (RenderPath)UndoableContentScaledToolbar( r, "Render Path", (int)renderPath, strRenderPath, "render path" ); - - - if(renderPath == RenderPath.Deferred){ - if(lightMode != LightMode.PBL) - lightMode = LightMode.PBL; - if(ps.catBlending.autoSort == false){ - ps.catBlending.autoSort = true; - } - if(ps.catBlending.blendModePreset != BlendModePreset.Opaque){ - ps.catBlending.blendModePreset = BlendModePreset.Opaque; - ps.catBlending.ConformBlendsToPreset(); - } - } - r.y += 20; - if(renderPath == RenderPath.Deferred){ - GUI.enabled = false; - UndoableContentScaledToolbar( r, "Light Mode", (int)LightMode.PBL, strLightMode, "light mode" ); - GUI.enabled = true; - } else { - lightMode = (LightMode)UndoableContentScaledToolbar( r, "Light Mode", (int)lightMode, strLightMode, "light mode" ); - } - r.y += 20; - - if( IsPBL() ) { - specularMode = (SpecularMode)UndoableContentScaledToolbar( r, "Specular Mode", (int)specularMode, strSpecularMode, "specular mode" ); - r.y += 20; - } - - GUI.enabled = ps.HasSpecular(); - glossRoughMode = (GlossRoughMode)UndoableContentScaledToolbar( r, "Gloss Mode", (int)glossRoughMode, strGlossRoughMode, "gloss mode" ); - r.y += 20; - GUI.enabled = true; - - GUI.enabled = ps.HasAlpha(); // Has Opacity connected - transparencyMode = (TransparencyMode)UndoableContentScaledToolbar( r, "Transparency Mode", (int)transparencyMode, strTransparencyMode, "transparency mode" ); - r.y += 20; - GUI.enabled = true; - - - - if( ps.catLighting.IsPBL() == false ) { - UndoableConditionalToggle( r, ref remapGlossExponentially, - usableIf: ps.HasGloss() && renderPath != RenderPath.Deferred, - disabledDisplayValue: renderPath == RenderPath.Deferred ? true : false, - label: "Remap gloss from [0-1] to " + ( ( renderPath == RenderPath.Deferred ) ? "[0-128]" : "[1-2048]" ), - undoSuffix: "gloss remap" - ); - r.y += 20; - } - - - - if( lightMode == LightMode.Unlit || lightMode == LightMode.PBL ) - GUI.enabled = false; - { - - //bool b = energyConserving; - if( lightMode == LightMode.PBL ) - GUI.Toggle( r, true, "Energy Conserving" ); // Dummy display of a checked energy conserve - else - energyConserving = UndoableToggle( r, energyConserving, "Energy Conserving", "energy conservation", null ); - //energyConserving = GUI.Toggle( r, energyConserving, "Energy Conserving" ); - - r.y += 20; - GUI.enabled = true; - } - - - GUI.enabled = renderPath == RenderPath.Forward; - lightCount = (LightCount)UndoableContentScaledToolbar(r, "Light Count", (int)lightCount, strLightCount, "light count" ); - GUI.enabled = true; - r.y += 20; - - - //lightPrecision = (LightPrecision)ContentScaledToolbar(r, "Light Quality", (int)lightPrecision, strLightPrecision ); // TODO: Too unstable for release - //r.y += 20; - - - UndoableConditionalToggle(r, ref bakedLight, - usableIf: ps.HasDiffuse() && lightMode != LightMode.Unlit, - disabledDisplayValue: false, - label: "Lightmap & light probes", - undoSuffix: "lightmap & light probes" - ); - r.y += 20; - - - bool wantsMetaPass = ps.catLighting.bakedLight && ( ps.HasDiffuse() || ps.HasEmissive() ); - UndoableConditionalToggle( r, ref includeMetaPass, - usableIf: wantsMetaPass, - disabledDisplayValue: false, - label: "Write meta pass (light bounce coloring)", - undoSuffix: "write meta pass" - ); - r.y += 20; - - //includeMetaPass = UndoableToggle( r, includeMetaPass, "Write meta pass (light bounce coloring)", "write meta pass", null ); - //r.y += 20; - - highQualityLightProbes = UndoableToggle( r, highQualityLightProbes, "Per-pixel light probe sampling", "per-pixel light probe sampling", null ); - r.y += 20; - - - - UndoableConditionalToggle( r, ref reflectprobed, - usableIf: ps.HasSpecular() && lightMode != LightMode.Unlit, - disabledDisplayValue: false, - label: "Reflection probe support", - undoSuffix: "reflection probe support" - ); - r.y += 20; - - - - - /*shadowCast = GUI.Toggle( r, shadowCast, "Cast shadows" ); - r.y += 20; - shadowReceive = GUI.Toggle( r, shadowReceive, "Receive shadows" ); - r.y += 20;*/ - - - - - //GUI.enabled = IsLit(); - /* - UndoableConditionalToggle( r, ref geometricAntiAliasing, - usableIf: ps.HasSpecular() && ps.catLighting.IsPBL(), - disabledDisplayValue: false, - label: "Geometric specular anti-aliasing", - undoSuffix: "geometric specular anti-aliasing" - ); - r.y += 20; - */ - - UndoableConditionalToggle(r, ref useAmbient, - usableIf: !bakedLight && ps.catLighting.IsLit(), - disabledDisplayValue: bakedLight, - label: "Receive Ambient Light", - undoSuffix: "receive ambient light" - ); - r.y += 20; - - /* - if(lightprobed){ - GUI.enabled = false; - GUI.Toggle( r, true, "Receive Ambient Light" ); - GUI.enabled = true; - }else{ - useAmbient = GUI.Toggle( r, useAmbient, "Receive Ambient Light" ); - }*/ - - - //r.y += 20; - - /* DISABLED DUE TO CAUSING TOO MANY ARTIFACTS - if(ps.catLighting.HasSpecular() && renderPath == RenderPath.Forward){ - maskedSpec = UndoableToggle( r, maskedSpec, "Mask directional light specular by shadows", "directional light specular shadow masking", null ); - } else { - GUI.enabled = false; - GUI.Toggle( r, false, "Mask directional light specular by shadows" ); - GUI.enabled = true; - } - r.y += 20;*/ - - r.y += prevYpos; - - return (int)r.yMax; - } - - - - - - - - public bool UseMultipleLights() { - return lightCount == LightCount.Multi; - } - - public bool IsVertexLit() { - return ( IsLit() && ( lightPrecision == LightPrecision.Vertex ) ); - } - - public bool IsFragmentLit() { - return ( IsLit() && ( lightPrecision == LightPrecision.Fragment ) ); - } - - public bool IsLit() { - return ( lightMode != LightMode.Unlit && ( ps.HasDiffuse() || HasSpecular()) ); - } - - public bool IsEnergyConserving() { - return IsLit() && (energyConserving || lightMode == LightMode.PBL); - } - - public bool IsPBL() { - return lightMode == LightMode.PBL; - } - - public bool HasSpecular() { - return ( lightMode == LightMode.BlinnPhong || lightMode == LightMode.Phong || lightMode == LightMode.PBL ) && ( ps.mOut.specular.IsConnectedAndEnabled() ); - } - - - - - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Lighting.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Lighting.cs.meta deleted file mode 100644 index d812b109..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Lighting.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8ef77982e74294fc4b12878b1651f3d9 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Meta.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Meta.cs deleted file mode 100644 index 5a4fe813..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Meta.cs +++ /dev/null @@ -1,340 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; - -namespace ShaderForge { - - - [System.Serializable] - public class SFPSC_Meta : SFPS_Category { - - public enum Inspector3DPreviewType { Sphere, Plane, Skybox }; - public string[] strInspector3DPreviewType = new string[] { "3D object", "2D sprite", "Sky"}; - public enum BatchingMode { Enabled, Disabled, DisableDuringLODFade }; - public string[] strBatchingMode = new string[] { "Enabled", "Disabled", "Disabled during LOD fade" }; - public Inspector3DPreviewType previewType = Inspector3DPreviewType.Sphere; - - public BatchingMode batchingMode = BatchingMode.Enabled; - public bool canUseSpriteAtlas = false; - public bool[] usedRenderers; // TODO: Serialization? - public string fallback = ""; - public int LOD = 0; // TODO: Serialization? - - public List cgIncludes = new List(); - - /* - d3d9 = 0, // - Direct3D 9 - d3d11 = 1, // - Direct3D 11 - glcore = 2, // - OpenGL Core - gles = 3, // - OpenGL ES 2.0 - gles3 = 4, // - OpenGL ES 3.0 - metal = 5, // - iOS Metal - d3d11_9x = 6, // - Direct3D 11 windows RT - xboxone = 7, // - Xbox One - ps4 = 8, // - PlayStation 4 - psp2 = 10 // - PlayStation Vita - n3ds = 11 // - Nintendo 3DS - wiiu = 12, // - Nintendo Wii U - */ - - public override SFPS_Category PostInitialize (){ - usedRenderers = new bool[12]{ // TODO: Load from project settings - true, // - Direct3D 9 - true, // - Direct3D 11 - true, // - OpenGL Core - true, // - OpenGL ES 2.0 - false, // - OpenGL ES 3.0 - false, // - iOS Metal - false, // - Direct3D 11 windows RT - false, // - Xbox One - false, // - PlayStation 4 - false, // - PlayStation Vita - false, // - Nintendo 3DS - false // - Wii U - }; - return this; - } - - - char[] splitChars = new char[] { '|' }; - string SerializeCgIncludes() { - string serialized = ""; - for( int i = 0; i < cgIncludes.Count; i++ ) { - serialized += cgIncludes[i]; - if( i < cgIncludes.Count - 1 ) - serialized += splitChars[0]; - } - string encoded = SF_Tools.StringToBase64String( serialized ); - - return encoded; - } - - void DeserializeCgIncludes( string serialized ) { - string decoded = SF_Tools.Base64StringToString( serialized ); - cgIncludes = new List( decoded.Split( splitChars ) ); - - // Remove empty entries - for( int i = cgIncludes.Count - 1; i >= 0; i-- ) - if( cgIncludes[i] == string.Empty ) - cgIncludes.RemoveAt( i ); - } - - public override string Serialize(){ - string s = ""; - s += Serialize( "flbk", fallback ); - s += Serialize( "iptp", ((int)previewType).ToString() ); - s += Serialize( "cusa", canUseSpriteAtlas.ToString() ); - s += Serialize( "bamd", ( (int)batchingMode ).ToString() ); - s += Serialize( "cgin", SerializeCgIncludes() ); - return s; - } - - public override void Deserialize(string key, string value){ - - switch( key ) { - case "flbk": - fallback = value; - break; - case "iptp": - previewType = (Inspector3DPreviewType)int.Parse(value); - break; - case "cusa": - canUseSpriteAtlas = bool.Parse(value); - break; - case "bamd": - batchingMode = (BatchingMode)int.Parse( value ); - break; - case "cgin": - DeserializeCgIncludes( value ); - break; - } - - } - - - public override float DrawInner(ref Rect r){ - - float prevYpos = r.y; - r.y = 0; - - - r.xMin += 20; - r.y += 20; - - - EditorGUI.LabelField( r, "Path", EditorStyles.miniLabel ); - r.xMin += 30; - r.height = 17; - r.xMax -= 3; - ps.StartIgnoreChangeCheck(); - GUI.SetNextControlName( "shdrpath" ); - string prev = editor.currentShaderPath; - //editor.currentShaderPath = GUI.TextField( r, editor.currentShaderPath,EditorStyles.textField ); - editor.currentShaderPath = UndoableTextField( r, editor.currentShaderPath, "shader path", null, editor, showContent:false ); - if( editor.currentShaderPath != prev ) { - SF_Tools.FormatShaderPath( ref editor.currentShaderPath ); - } - if( Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl() == "shdrpath" ) { - editor.Defocus(); - editor.OnShaderModified( NodeUpdateType.Hard ); - } - ps.EndIgnoreChangeCheck(); - r.xMin -= 30; - r.height = 20; - r.xMax += 3; - r.y += 20; - - - - - EditorGUI.LabelField( r, "Fallback", EditorStyles.miniLabel ); - Rect rStart = new Rect( r ); - r.xMin += 50; - r.height = 17; - r.xMax -= 47; - ps.StartIgnoreChangeCheck(); - GUI.SetNextControlName( "shdrpath" ); - prev = fallback; - fallback = UndoableTextField( r, fallback, "shader fallback", null, null, showContent:false ); - r.x += r.width + 2; - r.width = 42; - ShaderPicker( r, "Pick"); - if( fallback != prev ) { - SF_Tools.FormatShaderPath( ref fallback ); - } - if( Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl() == "shdrpath" ) { - editor.Defocus(); - editor.OnShaderModified( NodeUpdateType.Hard ); - } - ps.EndIgnoreChangeCheck(); - r = rStart; - r.y += r.height; - - - EditorGUI.LabelField( r, "LOD", EditorStyles.miniLabel ); - r.xMin += 30; - r.height = 17; - r.xMax -= 3; - LOD = UndoableIntField( r, LOD, "LOD"); - r.xMin -= 30; - r.height = 20; - r.xMax += 3; - r.y += 20; - - - canUseSpriteAtlas = UndoableToggle( r, canUseSpriteAtlas, "Allow using atlased sprites", "allow using atlased sprites", null ); - r.y += 20; - - batchingMode = (BatchingMode)UndoableLabeledEnumPopupNamed( r, "Draw call batching", batchingMode, strBatchingMode, "draw call batching" ); - r.y += 20; - - previewType = (Inspector3DPreviewType)UndoableLabeledEnumPopupNamed( r, "Inspector preview mode", previewType, strInspector3DPreviewType, "inspector preview mode" ); - r.y += 20; - - r.y += 10; - - - if( cgIncludes.Count == 0 ) { - Rect rBtn = r; - rBtn.height -= 4; - rBtn.width = 100; - if( GUI.Button( rBtn, "Add CG Include", EditorStyles.miniButton ) ) { - Undo.RecordObject( this, "add CG include" ); - cgIncludes.Add( "" ); - } - //r.y += 20; - } else { - EditorGUI.LabelField( r, "CG Includes:" ); - r.y += 20; - - - int removeTarget = -1; - - for( int i = 0; i < cgIncludes.Count; i++ ) { - - Rect smallRect = r; - smallRect.width = 20; - smallRect.height -= 2; - - if( GUI.Button( smallRect, "-" ) ) { - removeTarget = i; - } - - r.xMin += 22; - - Rect textFieldRect = r; - textFieldRect.height -= 2; - textFieldRect.width -= 3; - cgIncludes[i] = UndoableTextField( textFieldRect, cgIncludes[i], "cg include", null ); - textFieldRect.x += 1; - GUI.color = new Color( 1f, 1f, 1f, 0.3f ); - GUI.Label( textFieldRect, "" + cgIncludes[i] + ".cginc", SF_Styles.RichLabel ); - GUI.color = Color.white; - r.y += 20; - - r.xMin -= 22; - } - - if( removeTarget != -1 ) { - Undo.RecordObject( this, "remove CG include" ); - cgIncludes.RemoveAt( removeTarget ); - } - - Rect buttonRect = r; - buttonRect.width = 20; - buttonRect.height -= 2; - if( GUI.Button( buttonRect, "+" ) ) { - Undo.RecordObject( this, "add CG include" ); - cgIncludes.Add( "" ); - } - } - - - - r.y += 40; - - - - EditorGUI.LabelField( r, "Target renderers:" ); - r.xMin += 20; - r.y += 20; - r.height = 17; - float pWidth = r.width; - - - bool onlyDX11GlCore = ps.mOut.tessellation.IsConnectedAndEnabled(); - - - for(int i=0;i propertyList = editor.nodeView.treeStatus.propertyList; - - //GUI.Label( r.MovedUp(), "propertyList.Count = " + propertyList.Count ); - - int propCount = propertyList.Count; - - bool multiple = propCount > 1; - - - float prevYpos = r.y; - r.y = 0; - - - if( propCount == 0 ) { - r.y += 16; - GUI.enabled = false; - GUI.Label( r, "No properties in this shader yet" ); - GUI.enabled = true; - r.y -= 16; - } - - - r.y += 23; - r.xMin += 20; // Indent - r.xMax -= 3; - - - - r.height = propertyHeight; - - - - - // On drop... - if( draggingProperty != null && SF_GUI.ReleasedRawLMB()) { - - - int moveDist = Mathf.RoundToInt( ( Event.current.mousePosition.y - startMouseY ) / propertyHeight ); - - // Execute reordering! - if( moveDist != 0 ) { // See if it actually moved to another slot - int newIndex = Mathf.Clamp( dragStartIndex + moveDist, 0, propCount - 1 ); - Undo.RecordObject(editor.nodeView.treeStatus,"property reorder"); - editor.nodeView.treeStatus.propertyList.RemoveAt( dragStartIndex ); - //if( newIndex > dragStartIndex ) - // newIndex--; - editor.nodeView.treeStatus.propertyList.Insert( newIndex, draggingProperty ); - } - - draggingProperty = null; - - - } - - float yStart = r.y; - - - int i = 0; - - - for(int j=0;j dragStartIndex) { - r.y -= propertyHeight - SF_Tools.Smoother( Mathf.Clamp( r.y - DragRectPosY, 0, propertyHeight ) / propertyHeight ) * propertyHeight; - } - } - - - - - - GUI.Box( r, string.Empty, draggingThis ? SF_Styles.HighlightStyle : SF_Styles.NodeStyle ); - bool mouseOver = r.Contains( Event.current.mousePosition ); - - - - - - // We're now in the property box - // We need: Grabber, Text field, Internal label - - - - bool imagePreview = (prop.property is SFP_Tex2d || prop.property is SFP_Cubemap); - bool colorInput = ( prop.property is SFP_Color ); - bool checkboxInput = (prop.property is SFP_ToggleProperty || prop.property is SFP_SwitchProperty); - - - // GRABBER - Rect gRect = SF_Tools.GetExpanded( r, -6); - gRect.width = gRect.height/2f; - - gRect.yMin += 8; - - Rect gRectCoords = new Rect( gRect ); - - gRectCoords.x = 0; - gRectCoords.y = 0; - gRectCoords.width /= SF_GUI.Handle_drag.width; - gRectCoords.height /= SF_GUI.Handle_drag.height; - if(multiple) - GUI.DrawTextureWithTexCoords( gRect, SF_GUI.Handle_drag, gRectCoords ); - gRect.yMin -= 8; - /* - if( propCount > 1 ) { - if( gRect.Contains( Event.current.mousePosition ) && SF_GUI.PressedLMB() && !dragging ) { - dragStartOffsetY = r.y - Event.current.mousePosition.y; - draggingProperty = prop; - dragStartIndex = i; - startMouseY = Event.current.mousePosition.y; - } - SF_GUI.AssignCursor( gRect,MouseCursor.Pan); - GUI.DrawTextureWithTexCoords(gRect, SF_GUI.Handle_drag, gRectCoords ); - } - */ - - - - - // Property type name - Color c = GUI.color; - c.a = 0.5f; - GUI.color = c; - Rect propTypeNameRect = new Rect( gRect ); - //propTypeNameRect.x += propTypeNameRect.width + 8; - propTypeNameRect.y -= 5; - if( imagePreview || colorInput || checkboxInput ) - propTypeNameRect.width = r.width - r.height - 38; - else - propTypeNameRect.width = r.width - 48; - propTypeNameRect.height = 16; - //if( prop.property != null ) - GUI.Label( propTypeNameRect, prop.property.nameType, EditorStyles.miniLabel ); - propTypeNameRect.x += gRect.width + 8; - c.a = 1f; - GUI.color = c; - //else - //return (int)r.yMax; - - - // INTERNAL NAME - - if( mouseOver ) { - c.a = 0.5f; - GUI.color = c; - Rect intRect = new Rect( propTypeNameRect ); - intRect.xMin += intRect.width - SF_GUI.WidthOf( prop.property.nameInternal, EditorStyles.label ); - //SF_GUI.AssignCursor( intRect, MouseCursor.Text ); - GUI.Label( intRect, prop.property.nameInternal, EditorStyles.label ); - c.a = 1f; - GUI.color = c; - } - - - - // DISPLAY NAME - Rect dispNameRect = new Rect( propTypeNameRect ); - dispNameRect.y += 18; - //dispNameRect.x += dispNameRect.width + 4; - //dispNameRect.height = 16; - //dispNameRect.y += 10; - //dispNameRect.width = ( r.width - dispNameRect.width - texRect.width - 20 ) * 0.5f; - - ps.StartIgnoreChangeCheck(); - string bef = prop.property.nameDisplay; - SF_GUI.AssignCursor( dispNameRect, MouseCursor.Text ); - //if( mouseOver ) - UndoableEnterableNodeTextField(prop.property.node, dispNameRect, ref prop.property.nameDisplay, "change property name", update:false, extra:prop.property); - //else - //GUI.Label( dispNameRect, prop.property.nameDisplay, EditorStyles.boldLabel ); - if( prop.property.nameDisplay != bef ) { // Changed - prop.property.UpdateInternalName(); - } - ps.EndIgnoreChangeCheck(); - - - - - - - // Texture preview - Rect texRect = new Rect( 0, 0, 0, 0 ); - c = GUI.color; - if( imagePreview ) { - texRect = SF_Tools.GetExpanded(new Rect( r ), -4); - texRect.xMin += texRect.width - texRect.height; - //texRect.x += gRect.width + 4; - //texRect.width = texRect.height; - GUI.Box( SF_Tools.GetExpanded( texRect, 1f ), string.Empty, SF_Styles.NodeStyle ); - GUI.color = Color.white; - GUI.DrawTexture( texRect, prop.texture.texture ); - GUI.color = c; - } - - - if( prop.property is SFP_Slider ) { - - SFN_Slider slider = ( prop as SFN_Slider ); - - ps.StartIgnoreChangeCheck(); - Rect sR = new Rect( dispNameRect ); - sR.y += sR.height+5; - sR.width = 28; - GUI.Label( sR, "Min" ); - //sR.x += sR.width; - sR = sR.MovedRight(); - prop.UndoableEnterableFloatField(sR, ref slider.min, "min value",null); - - - sR = sR.MovedRight(); - - sR.width = r.width - 164; - - float beforeSlider = slider.current; - - string sliderName = "slider" + slider.id; - GUI.SetNextControlName( sliderName ); - - sR.xMin += 4; - sR.xMax -= 4; - - slider.current = prop.UndoableHorizontalSlider(sR, slider.current, slider.min, slider.max, "value"); - if( beforeSlider != slider.current ) { - GUI.FocusControl( sliderName ); - slider.OnValueChanged(); - } - //SF_GUI.AssignCursor( sR, MouseCursor.Arrow ); - - sR.x += sR.width+4; - sR.width = 32; - prop.UndoableEnterableFloatField(sR, ref slider.max, "max value",null); - sR.x += sR.width; - GUI.Label( sR, "Max" ); - - ps.EndIgnoreChangeCheck(); - - } else if( colorInput ) { - - - SFN_Color colNode = ( prop as SFN_Color ); - - texRect = SF_Tools.GetExpanded( new Rect( r ), -4 ); - texRect.xMin += texRect.width - texRect.height; - //GUI.Box( SF_Tools.GetExpanded( texRect, 1f ), string.Empty, SF_Styles.NodeStyle ); - GUI.color = Color.white; - texRect.yMax -= 21; - texRect.yMin += 15; - texRect.xMin += 2; - //texRect.xMax -= 2; - - SF_GUI.AssignCursor( texRect, MouseCursor.Arrow ); - - ps.StartIgnoreChangeCheck(); - //Color col = EditorGUI.ColorField( texRect, colNode.texture.dataUniform ); - Color col = colNode.UndoableColorField(texRect, colNode.texture.dataUniform, "set color of " + colNode.property.nameDisplay); - ps.EndIgnoreChangeCheck(); - colNode.SetColor( col ); - GUI.color = c; - } else if( prop.property is SFP_Vector4Property ) { - - SFN_Vector4Property vec4 = ( prop as SFN_Vector4Property ); - - ps.StartIgnoreChangeCheck(); - Rect sR = new Rect( dispNameRect ); - sR.y += sR.height + 5; - sR.width = 20; - - int lbWidth = 12; - - - //string channelStr = "XYZW"; - - - - sR.width = lbWidth; - GUI.Label( sR, "X", EditorStyles.miniLabel ); - sR.x += sR.width; - sR.width = 32; - prop.UndoableEnterableFloatField(sR, ref vec4.texture.dataUniform.x, "X channel", EditorStyles.textField ); - SF_GUI.AssignCursor( sR, MouseCursor.Text ); - sR.x += sR.width + 3; - - - sR.width = lbWidth; - GUI.Label( sR, "Y", EditorStyles.miniLabel ); - sR.x += sR.width; - sR.width = 32; - prop.UndoableEnterableFloatField(sR, ref vec4.texture.dataUniform.y, "Y channel", EditorStyles.textField ); - SF_GUI.AssignCursor( sR, MouseCursor.Text ); - sR.x += sR.width+3; - - - sR.width = lbWidth; - GUI.Label( sR, "Z", EditorStyles.miniLabel ); - sR.x += sR.width; - sR.width = 32; - prop.UndoableEnterableFloatField(sR, ref vec4.texture.dataUniform.z, "Z channel", EditorStyles.textField ); - SF_GUI.AssignCursor( sR, MouseCursor.Text ); - sR.x += sR.width + 3; - - - sR.width = lbWidth; - GUI.Label( sR, "W", EditorStyles.miniLabel ); - sR.x += sR.width; - sR.width = 32; - prop.UndoableEnterableFloatField(sR, ref vec4.texture.dataUniform.w, "W channel", EditorStyles.textField ); - SF_GUI.AssignCursor( sR, MouseCursor.Text ); - - - - - ps.EndIgnoreChangeCheck(); - - } else if( prop.property is SFP_ValueProperty ) { - - SFN_ValueProperty val = ( prop as SFN_ValueProperty ); - - ps.StartIgnoreChangeCheck(); - Rect sR = new Rect( dispNameRect ); - sR.y += sR.height + 5; - sR.width = 20; - - sR.width = 35; - GUI.Label( sR, "Value", EditorStyles.miniLabel ); - sR.x += sR.width; - sR.width = 55; - //SF_GUI.EnterableFloatField( prop, sR, ref val.texture.dataUniform.r, EditorStyles.textField ); - prop.UndoableEnterableFloatField(sR, ref val.texture.dataUniform.x, "value", EditorStyles.textField); - SF_GUI.AssignCursor( sR, MouseCursor.Text ); - ps.EndIgnoreChangeCheck(); - } else if (checkboxInput){ - - bool isToggle = (prop.property is SFP_ToggleProperty); - - bool prevValue = isToggle ? (prop.property.node as SFN_ToggleProperty).on : (prop.property.node as SFN_SwitchProperty).on; - - - - - ps.StartIgnoreChangeCheck(); - - texRect = SF_Tools.GetExpanded( new Rect( r ), -4 ); - texRect.xMin += texRect.width - texRect.height; - //GUI.Box( SF_Tools.GetExpanded( texRect, 1f ), string.Empty, SF_Styles.NodeStyle ); - - texRect.yMax -= 21; - texRect.yMin += 15; - texRect.xMin += 2; - //texRect.xMax -= 2; - - SF_GUI.AssignCursor( texRect, MouseCursor.Arrow ); - - bool newValue = prevValue; - - if(isToggle){ - prop.property.node.UndoableToggle(texRect, ref (prop.property.node as SFN_ToggleProperty).on, "", "property checkbox", EditorStyles.toggle); - newValue = (prop.property.node as SFN_ToggleProperty).on; - } else { - prop.property.node.UndoableToggle(texRect, ref (prop.property.node as SFN_SwitchProperty).on, "", "property checkbox", EditorStyles.toggle); - newValue = (prop.property.node as SFN_SwitchProperty).on; - } - - if(newValue != prevValue){ - //if(isToggle){ - // (prop.property.node as SFN_ToggleProperty).on = newValue; - //} else { - // (prop.property.node as SFN_SwitchProperty).on = newValue; - ////} - if(isToggle){ - prop.property.node.texture.dataUniform = Color.white * (newValue ? 1f : 0f); - } else { - //prop.property.node.texture.UpdateColorPreview("",true); - } - prop.property.node.OnUpdateNode(NodeUpdateType.Soft); - } - ps.EndIgnoreChangeCheck(); - - } - - - - - - if( r.Contains( Event.current.mousePosition ) && SF_GUI.PressedLMB() && !dragging && multiple) { - dragStartOffsetY = r.y - Event.current.mousePosition.y; - draggingProperty = prop; - dragStartIndex = i; - startMouseY = Event.current.mousePosition.y; - editor.Defocus(); - } - if(multiple) - SF_GUI.AssignCursor( r, MouseCursor.Pan ); - - - - - - - - - if( draggingThis ) - r.x += 5; - - //GUI.Label( r, "prop.property.nameType = " + prop.property.nameType ); - - r.y += propertyHeight; - i++; - } - - - - r.y = yStart + propCount * propertyHeight; - r.height = 20; - - r.y += prevYpos; - - return r.yMax; - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Properties.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Properties.cs.meta deleted file mode 100644 index 26a6981b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPSC_Properties.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d4bb19d25405c413ea8307d77806a00b -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPS_Category.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPS_Category.cs deleted file mode 100644 index d0ce25c4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPS_Category.cs +++ /dev/null @@ -1,347 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - - [System.Serializable] - public class SFPS_Category : ScriptableObject { - - public SF_Editor editor; - public SF_PassSettings ps; - - public string labelExpanded; - public string labelContracted; - - public bool expanded = false; - - public float targetHeight = 0f; - public float smoothHeight = 0f; - - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - - public SFPS_Category Initialize( SF_Editor editor, SF_PassSettings ps, string label ) { - this.editor = editor; - this.ps = ps; - this.labelExpanded = label; - this.labelContracted = label + "..."; - return PostInitialize(); - } - - public virtual SFPS_Category PostInitialize(){ - return this; // Override - } - - public virtual string Serialize(){ - return ""; - } - - protected string Serialize( string key, string value, bool last = false ) { - return key + ":" + value + (last ? "" : ","); - } - - public virtual void Deserialize(string key, string value){ - } - - public virtual void ToggleExpansion(){ - - } - - public virtual void PreDraw(Rect r){ - - } - - - public int Draw(float yOffset){ - - if(Event.current.type == EventType.Repaint){ - if(Mathf.Abs(smoothHeight-targetHeight) > 0.1f) - smoothHeight = Mathf.Lerp(smoothHeight,targetHeight,0.5f); - else - smoothHeight = targetHeight; - } - - Rect topRect = new Rect( 0f, yOffset, ps.maxWidth, 20 ); - Rect r = new Rect( topRect ); - - PreDraw(r); - - if( !StartExpanderChangeCheck( r, ref expanded, labelContracted, labelExpanded ) ) { - //ps.guiChanged = EndExpanderChangeCheck(); - //GUI.color = Color.white; - targetHeight = 0f; - //return (int)(topRect.yMax+smoothHeight); - } - Rect gRect = r; - gRect.height = smoothHeight + 20; - GUI.BeginGroup(gRect); - yOffset = DrawInner(ref r ); - GUI.EndGroup(); - if(expanded) - targetHeight = yOffset-topRect.yMax; - if( EndExpanderChangeCheck() ) - ps.guiChanged = true; - - GUI.color = Color.white; - return (int)(topRect.yMax+smoothHeight); - } - - public virtual float DrawInner(ref Rect r){ - - return 0f; - } - - public string GetLabelString() { - return expanded ? labelExpanded : labelContracted; - } - - public virtual void DrawExtraTitleContent( Rect r ) { - // Override. Currently only used by Console - } - - - - public bool StartExpanderChangeCheck(Rect r, ref bool foldVar, string labelContracted, string labelExpanded ) { - - // TOOD: COLOR RECT BEHIND - Color prev = GUI.color; - GUI.color = new Color(0,0,0,0); - if( GUI.Button( r, string.Empty , EditorStyles.foldout ) ){ - Event.current.Use(); - Undo.RecordObject(this, foldVar ? "collapse " + labelExpanded : "expand " + labelExpanded); - foldVar = !foldVar; - } - GUI.color = prev; - //EditorGUI.Foldout( r, foldVar, foldVar ? smoothHeight + " " + labelExpanded : smoothHeight + " " + labelContracted ); - EditorGUI.Foldout( r, foldVar, GetLabelString() ); - DrawExtraTitleContent( r ); - - EditorGUI.BeginChangeCheck(); - if( !foldVar ) - return false; - return true; - } - - public bool EndExpanderChangeCheck() { - return EditorGUI.EndChangeCheck(); - } - - - public void CheckboxEnableLine(ref bool b, ref Rect r){ - Rect rCopy = r; - rCopy.width = r.height; - b = GUI.Toggle(rCopy,b,string.Empty); - GUI.enabled = b; - r.xMin += 20; - } - - public void CheckboxEnableLineEnd(ref Rect r){ - r.y += 20; - r.xMin -= 20; - GUI.enabled = true; - } - - - - - - - - - - - - - - - - public int UndoableContentScaledToolbar(Rect r, string label, int selected, string[] labels, string undoInfix){ - int newValue = SF_GUI.ContentScaledToolbar( r, label, selected, labels ); - if(newValue != selected){ - string undoName = "set " + undoInfix + " to " + labels[newValue]; - Undo.RecordObject(this,undoName); - return newValue; - } - return selected; - } - - - public void UndoableConditionalToggle(Rect r, ref bool value, bool usableIf, bool disabledDisplayValue, string label, string undoSuffix){ - bool nextValue = value; - SF_GUI.ConditionalToggle(r,ref nextValue, usableIf,disabledDisplayValue,label); - if(nextValue != value){ - string undoName = (nextValue ? "enable" : "disable") + " " + undoSuffix; - Undo.RecordObject(this,undoName); - value = nextValue; - } - } - - - public bool UndoableToggle(Rect r, bool boolVar, string label, string undoActionName, GUIStyle style = null){ - if(style == null) - style = EditorStyles.toggle; - bool newValue = GUI.Toggle(r, boolVar, label, style); - if(newValue != boolVar){ - string undoName = (newValue ? "enable" : "disable") + " " + undoActionName; - Undo.RecordObject(this,undoName); - return newValue; - } - return boolVar; - } - - public bool UndoableToggle(Rect r, bool boolVar, string undoActionName, GUIStyle style = null){ - if(style == null) - style = EditorStyles.toggle; - bool newValue = GUI.Toggle(r, boolVar, new GUIContent("")); - if(newValue != boolVar){ - string undoName = (newValue ? "enable" : "disable") + " " + undoActionName; - Undo.RecordObject(this,undoName); - return newValue; - } - return boolVar; - } - - - public Enum UndoableEnumPopup(Rect r, Enum enumValue, string undoInfix){ - Enum nextEnum = EditorGUI.EnumPopup( r, enumValue ); - - if(nextEnum.ToString() != enumValue.ToString()){ - string undoName = "set " + undoInfix + " to " + nextEnum; - Undo.RecordObject(this,undoName); - enumValue = nextEnum; - } - return enumValue; - } - - - public Enum UndoableLabeledEnumPopup(Rect r, string label, Enum enumValue, string undoInfix){ - Enum nextEnum = SF_GUI.LabeledEnumField( r, label, enumValue, EditorStyles.miniLabel ); - if(nextEnum.ToString() != enumValue.ToString()){ - string undoName = "set " + undoInfix + " to " + nextEnum; - Undo.RecordObject(this,undoName); - enumValue = nextEnum; - } - return enumValue; - } - - - public int UndoableEnumPopupNamed(Rect r, Enum enumValue, string[] displayedOptions, string undoInfix){ - int nextEnum = EditorGUI.Popup( r, (int)((object)enumValue), displayedOptions); - if(nextEnum != ((int)((object)enumValue))){ - string undoName = "set " + undoInfix + " to " + displayedOptions[nextEnum]; - Undo.RecordObject(this,undoName); - return nextEnum; - } - return (int)((object)enumValue); - } - - public int UndoableLabeledEnumPopupNamed(Rect r, string label, Enum enumValue, string[] displayedOptions, string undoInfix){ - int nextEnum = SF_GUI.LabeledEnumFieldNamed( r, displayedOptions, new GUIContent(label), (int)((object)enumValue), EditorStyles.miniLabel); - if(nextEnum != ((int)((object)enumValue))){ - string undoName = "set " + undoInfix + " to " + displayedOptions[nextEnum]; - Undo.RecordObject(this,undoName); - return nextEnum; - } - return (int)((object)enumValue); - } - - - //UndoablePopup - - public float UndoableFloatField(Rect r, float value, string undoInfix, GUIStyle style = null){ - if(style == null) - style = EditorStyles.textField; - float newValue = EditorGUI.FloatField( r, value, style ); - if(newValue != value){ - string undoName = "set " + undoInfix + " to " + newValue; - Undo.RecordObject(this,undoName); - return newValue; - } - return value; - } - - public int UndoableIntField(Rect r, int value, string undoInfix, GUIStyle style = null){ - if(style == null) - style = EditorStyles.textField; - int newValue = EditorGUI.IntField( r, value, style ); - if(newValue != value){ - string undoName = "set " + undoInfix + " to " + newValue; - Undo.RecordObject(this,undoName); - return newValue; - } - return value; - } - - - - - public string UndoableTextField(Rect r, string value, string undoInfix, GUIStyle style = null){ - if(style == null) - style = EditorStyles.textField; - string newValue = EditorGUI.TextField( r, value, style ); - if(newValue != value){ - string undoName = "change " + undoInfix + " to " + newValue; - Undo.RecordObject(this,undoName); - return newValue; - } - return value; - } - - - public string UndoableTextField(Rect r, string value, string undoInfix, GUIStyle style = null, UnityEngine.Object extra = null, bool showContent = true){ - if(style == null) - style = EditorStyles.textField; - string newValue = EditorGUI.TextField( r, value, style ); - if(newValue != value){ - string undoName = "change " + undoInfix; - if(showContent) - undoName += " to " + newValue; - Undo.RecordObject(this, undoName); - if(extra != null) - Undo.RecordObject(extra, undoName); - return newValue; - } - return value; - } - - - public void UndoableEnterableNodeTextField(SF_Node node, Rect r, ref string value, string undoMsg, bool update = true, UnityEngine.Object extra = null){ - string nextValue = value; - SF_GUI.EnterableTextField(node, r, ref nextValue, EditorStyles.textField, update ); - if(nextValue != value){ - Undo.RecordObject(this, undoMsg ); - if(extra != null) - Undo.RecordObject(extra, undoMsg); - value = nextValue; - } - } - - - - - - - - - - - - - - - - - - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPS_Category.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SFPS_Category.cs.meta deleted file mode 100644 index 21bd72b3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SFPS_Category.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3cc113fa7d2a64fe09c009b1f5f47983 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Dependencies.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Dependencies.cs deleted file mode 100755 index ceedc837..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Dependencies.cs +++ /dev/null @@ -1,306 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; - - -namespace ShaderForge { - - - - - - public class SF_Dependencies { - - private int vert_out_texcoordNumber = 0; - - public bool uv0 = false; - public bool uv0_frag = false; - public bool uv1 = false; - public bool uv1_frag = false; - public bool uv2 = false; - public bool uv2_frag = false; - public bool uv3 = false; - public bool uv3_frag = false; - public bool uv0_float4 = false; - public bool uv1_float4 = false; - public bool uv2_float4 = false; - public bool uv3_float4 = false; - - public bool vertexColor = false; - public bool lightColor = false; - public bool time = false; - public bool grabPass = false; - public bool scene_uvs = false; - public bool tessellation = false; - public bool displacement = false; - - public bool frag_facing = false; - - public bool vert_out_worldPos = false; - public bool vert_out_screenPos = false; - public bool vert_out_normals = false; - public bool vert_out_tangents = false; - public bool vert_out_bitangents = false; - public bool vert_in_normals = false; - public bool vert_in_tangents = false; - public bool vert_in_vertexColor = false; - public bool vert_out_vertexColor = false; - public bool frag_viewReflection = false; - public bool frag_viewDirection = false; - public bool frag_normalDirection = false; - public bool frag_lightDirection = false; - public bool frag_lightColor = false; - public bool frag_halfDirection = false; - public bool frag_attenuation = false; - public bool frag_tangentTransform = false; - public bool frag_screenPos = false; - public bool frag_pixelDepth = false; - public bool vert_screenPos = false; - - public bool reflection_probes = false; - public bool fog_color = false; - - - public bool vert_viewReflection = false; - public bool vert_viewDirection = false; - public bool vert_normalDirection = false; - public bool vert_lightDirection = false; - public bool vert_halfDirection = false; - public bool vert_tangentTransform = false; - - public bool frag_objectPos = false; - public bool vert_objectPos = false; - - public bool objectScale = false; - public bool objectScaleReciprocal = false; - - public bool frag_sceneDepth = false; - public bool depthTexture = false; - //public bool frag_pixelDepth = false; - - public bool frag_projPos = false; - - - public bool const_pi = false; - public bool const_tau = false; - public bool const_root2 = false; - public bool const_e = false; - public bool const_phi = false; - - public bool pragmaGlsl = false; - - - int shaderTarget = 3; // Shader target: #pragma target 3.0 - public List includeRenderers; - - public SF_Dependencies(SF_PassSettings ps) { - includeRenderers = new List(); - for( int i = 0; i < ps.catMeta.usedRenderers.Length; i++ ) { - if( ps.catMeta.usedRenderers[i] ) { - includeRenderers.Add( (RenderPlatform)i ); - } - } - - - - //excludeRenderers.Add( RenderPlatform.flash ); - //excludeRenderers.Add( RenderPlatform.gles ); - //excludeRenderers.Add( RenderPlatform.xbox360 ); - //excludeRenderers.Add( RenderPlatform.ps3 ); - } - - public void NeedSceneAndFragDepth(){ - frag_pixelDepth = true; - NeedSceneDepth(); - } - - public void NeedSceneDepth(){ - frag_projPos = true; - frag_sceneDepth = true; - depthTexture = true; - } - - public void IncrementTexCoord( int num ) { - vert_out_texcoordNumber += num; - } - - public bool UsesLightNodes() { - return frag_attenuation || frag_lightDirection || frag_halfDirection || lightColor; - } - - public void NeedFragVertexColor() { - vert_in_vertexColor = true; - vert_out_vertexColor = true; - } - - public void NeedFragObjPos() { - frag_objectPos = true; - } - public void NeedVertObjPos(){ - vert_objectPos = true; - } - - public void NeedVertScreenPos() { - vert_screenPos = true; - } - - public void NeedLightColor() { - lightColor = true; - frag_lightColor = true; - } - - public void NeedFragAttenuation(){ - frag_attenuation = true; - } - - public void NeedRefraction() { - NeedGrabPass(); - NeedSceneUVs(); - } - - public void NeedSceneUVs(){ - frag_projPos = true; - scene_uvs = true; - } - - public void NeedFragPixelDepth(){ - NeedFragWorldPos(); - frag_projPos = true; - frag_pixelDepth = true; - } - - public void NeedGrabPass() { - NeedSceneUVs(); // TODO: Really? - grabPass = true; - } - - public void NeedTessellation(){ - shaderTarget = Mathf.Max( shaderTarget, 5); - vert_in_tangents = true; - vert_in_normals = true; - tessellation = true; - } - - - public void NeedDisplacement() { - displacement = true; - } - - public void NeedFragWorldPos() { - vert_out_worldPos = true; - } - public void NeedVertWorldPos() { - vert_out_worldPos = true; // TODO ? - } - - public void NeedFragHalfDir() { - frag_halfDirection = true; - NeedFragLightDir(); - NeedFragViewDirection(); - } - public void NeedVertHalfDir() { - vert_halfDirection = true; - NeedVertLightDir(); - NeedVertViewDirection(); - } - - public void NeedFragLightDir() { - frag_lightDirection = true; - NeedFragWorldPos(); - } - public void NeedVertLightDir() { - vert_lightDirection = true; - NeedVertWorldPos(); - } - - public void NeedFragViewDirection() { - frag_viewDirection = true; - NeedFragWorldPos(); - } - public void NeedVertViewDirection() { - vert_viewDirection = true; - NeedVertWorldPos(); - } - - - - - public void NeedFragViewReflection() { - NeedFragViewDirection(); - NeedFragNormals(); - frag_viewReflection = true; - } - - public void NeedFragNormals() { - vert_in_normals = true; - vert_out_normals = true; - frag_normalDirection = true; - } - - public void NeedFragTangents() { - vert_in_tangents = true; - vert_out_tangents = true; - } - public void NeedFragBitangents() { - vert_in_normals = true; - vert_out_normals = true; - vert_in_tangents = true; - vert_out_tangents = true; - vert_out_bitangents = true; - } - - public void NeedFragTangentTransform() { - frag_tangentTransform = true; - frag_normalDirection = true; - vert_in_normals = true; - vert_out_normals = true; - vert_in_tangents = true; - vert_out_tangents = true; - vert_out_bitangents = true; - } - - - - public void IncludeRenderPlatform( RenderPlatform plat ) { - if( includeRenderers.Contains( plat ) == false ) { - includeRenderers.Add( plat ); - } - } - - public bool DoesIncludePlatforms() { - return includeRenderers.Count > 0; - } - - public bool IsTargetingAboveDefault() { - return ( shaderTarget > 2 ); - } - - public string GetIncludedPlatforms() { - string s = ""; - foreach( RenderPlatform plat in includeRenderers ) - s += plat.ToString() + " "; - //Debug.Log("Exclude Str: " + s); - return s; - } - - public void SetMinimumShaderTarget( int x ) { - if( x > shaderTarget ) - shaderTarget = x; - } - public string GetShaderTarget() { - return ( shaderTarget + ".0" ); - } - - public string GetVertOutTexcoord() { - string s = vert_out_texcoordNumber.ToString(); - vert_out_texcoordNumber++; - return s; - } - - public void ResetTexcoordNumbers() { - //vert_in_texcoordNumber = 0; - vert_out_texcoordNumber = 0; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Dependencies.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Dependencies.cs.meta deleted file mode 100755 index ee2a43c7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Dependencies.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 318a4bbf6b13c47e1ac8085a2ebc9850 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Editor.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Editor.cs deleted file mode 100755 index 0c30384f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Editor.cs +++ /dev/null @@ -1,2179 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml; -using System.Reflection; -using System.Net; -using System.Collections; - - - - -namespace ShaderForge { - - - public delegate T Func(); - - public enum UpToDateState{UpToDate, OutdatedSoft, OutdatedHard}; - - [Serializable] - public class SF_Editor : EditorWindow { - [SerializeField] - public SF_Evaluator shaderEvaluator; - [SerializeField] - public SF_PreviewWindow preview; - [SerializeField] - public SF_EditorNodeView nodeView; - [SerializeField] - public SF_EditorNodeBrowser nodeBrowser; - [SerializeField] - public SF_PassSettings ps; // TODO: Move - - [System.NonSerialized] - public static SF_Editor instance; - [SerializeField] - public SFN_Final mainNode; - [SerializeField] - public SF_StatusBox statusBox; - - [SerializeField] - public List nodes; - - [SerializeField] - DateTime startTime = DateTime.UtcNow; - - [SerializeField] - GUIStyle windowStyle; - [SerializeField] - GUIStyle titleStyle; - [SerializeField] - GUIStyle versionStyle; - [SerializeField] - GUIStyle nodeScrollbarStyle; - - [SerializeField] - public SF_DraggableSeparator separatorLeft; - - [SerializeField] - public SF_DraggableSeparator separatorRight; - - public Vector2 mousePosition = Vector2.zero; - - [SerializeField] - public Shader currentShaderAsset; - [SerializeField] - public string currentShaderPath; - - [SerializeField] - public List nodeTemplates; - - [SerializeField] - private UpToDateState shaderOutdated = UpToDateState.UpToDate; - public UpToDateState ShaderOutdated{ - get{ - return shaderOutdated; - } - set{ - if(shaderOutdated != value){ - //Debug.Log("Changed outdated state to " + value); - shaderOutdated = value; - } - } - } - - [NonSerialized] - public bool initialized = false; - - - - - public SF_Editor() { - if(SF_Debug.window) - Debug.Log( "[SF_LOG] - SF_Editor CONSTRUCTOR SF_Editor()" ); - SF_Editor.instance = this; - } - - [MenuItem( "Window/Shader Forge" )] - static void InitEmpty() { - if( SF_Editor.instance == null ) - Init( null ); - else { - EditorWindow.GetWindow( typeof( SF_Editor ) ); // Focus - } - } - - void OnEnable() { - SF_Settings.LoadAllFromDisk(); - titleContent = new GUIContent( "Shader Forge", (Texture)SF_GUI.Icon ); - if( this.preview != null ) - preview.OnEnable(); - } - - void OnDisable(){ - - if(shaderOutdated != UpToDateState.UpToDate){ - - fullscreenMessage = "Saving..."; - Repaint(); - shaderEvaluator.Evaluate(); - } - - if( this.preview != null ) - preview.OnDisable(); - - SF_Settings.SaveAllToDisk(); - - } - - - void OnDestroy(){ - DestroyImmediate( preview.internalMaterial ); - } - - public static bool Init( Shader initShader = null ) { - - // To make sure you get periods as decimal separators - System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); - - if(SF_Debug.evalFlow || SF_Debug.dynamicNodeLoad) - Debug.Log( "[SF_LOG] - SF_Editor Init(" + initShader + ")" ); - SF_Editor materialEditor = (SF_Editor)EditorWindow.GetWindow( typeof( SF_Editor ) ); - SF_Editor.instance = materialEditor; - updateCheck = ""; - bool loaded = materialEditor.InitializeInstance( initShader ); - if( !loaded ) - return false; - return true; - } - - public int GetUniqueNodeID() { - - int[] occupiedIDs = nodes.Select( x => x.id ).ToArray(); - int id = -1; - int limit = 1000000; - - do { - id = UnityEngine.Random.Range(1,9999); - limit--; - } while( occupiedIDs.Contains( id ) && limit > 0 ); - - if( limit <= 0 ) - Debug.LogError("Ran out of attempts to find a unique node ID"); - - return id; - } - - - - - - public void InitializeNodeTemplates() { - nodeTemplates = new List(); - - - // AddTemplate( typeof( SFN_CommentBox ), "Comment Box" ); - - string catArithmetic = "Arithmetic/"; - AddTemplate( typeof( SFN_Abs ), catArithmetic + "Abs" ); - AddTemplate( typeof( SFN_Add ), catArithmetic + "Add", KeyCode.A ); - AddTemplate( typeof( SFN_Blend ), catArithmetic + "Blend", KeyCode.B ); - AddTemplate( typeof( SFN_Ceil ), catArithmetic + "Ceil" ); - AddTemplate( typeof( SFN_Clamp ), catArithmetic + "Clamp" ); - AddTemplate( typeof( SFN_Clamp01 ), catArithmetic + "Clamp 0-1" ); - AddTemplate( typeof( SFN_ConstantClamp ), catArithmetic + "Clamp (Simple)",KeyCode.None, "Clamp Simple" ); - AddTemplate( typeof( SFN_Divide ), catArithmetic + "Divide", KeyCode.D ); - AddTemplate( typeof( SFN_Exp ), catArithmetic + "Exp" ); - AddTemplate( typeof( SFN_Floor ), catArithmetic + "Floor" ); - AddTemplate( typeof( SFN_Fmod ), catArithmetic + "Fmod" ); - AddTemplate( typeof( SFN_Frac ), catArithmetic + "Frac" ); - AddTemplate( typeof( SFN_HsvToRgb ), catArithmetic + "HSV to RGB" ); - AddTemplate( typeof( SFN_Hue ), catArithmetic + "Hue" ); - AddTemplate( typeof( SFN_If ), catArithmetic + "If", KeyCode.I ); - AddTemplate( typeof( SFN_InverseLerp ), catArithmetic + "Inverse Lerp" ); - AddTemplate( typeof( SFN_Lerp ), catArithmetic + "Lerp", KeyCode.L ); - AddTemplate( typeof( SFN_ConstantLerp ), catArithmetic + "Lerp (Simple)", KeyCode.None, "Lerp Simple" ); - AddTemplate( typeof( SFN_Log ), catArithmetic + "Log" ); - AddTemplate( typeof( SFN_Max ), catArithmetic + "Max" ); - AddTemplate( typeof( SFN_Min ), catArithmetic + "Min" ); - AddTemplate( typeof( SFN_Multiply ), catArithmetic + "Multiply", KeyCode.M ); - AddTemplate( typeof( SFN_MultiplyMatrix ), catArithmetic + "Multiply Matrix" ); - AddTemplate( typeof( SFN_Negate ), catArithmetic + "Negate" ); - AddTemplate( typeof( SFN_Noise ), catArithmetic + "Noise" ); - AddTemplate( typeof( SFN_OneMinus ), catArithmetic + "One Minus", KeyCode.O ); - AddTemplate( typeof( SFN_Posterize ), catArithmetic + "Posterize" ); - AddTemplate( typeof( SFN_Power ), catArithmetic + "Power", KeyCode.E ); - AddTemplate( typeof( SFN_Reciprocal ), catArithmetic + "Reciprocal" ); - AddTemplate( typeof( SFN_RemapRangeAdvanced),catArithmetic+ "Remap" ); - AddTemplate( typeof( SFN_RemapRange ), catArithmetic + "Remap (Simple)", KeyCode.R, "Remap Simple" ); - AddTemplate( typeof( SFN_RgbToHsv ), catArithmetic + "RGB to HSV" ); - AddTemplate( typeof( SFN_Round ), catArithmetic + "Round" ); - AddTemplate( typeof( SFN_Sign ), catArithmetic + "Sign" ); - AddTemplate( typeof( SFN_Smoothstep ), catArithmetic + "Smoothstep" ).MarkAsNewNode(); - AddTemplate( typeof( SFN_Sqrt ), catArithmetic + "Sqrt" ); - AddTemplate( typeof( SFN_Step ), catArithmetic + "Step (A <= B)", KeyCode.None, "Step" ); - AddTemplate( typeof( SFN_Subtract ), catArithmetic + "Subtract", KeyCode.S ); - AddTemplate( typeof( SFN_Trunc ), catArithmetic + "Trunc" ); - - string catConstVecs = "Constant Vectors/"; - AddTemplate( typeof( SFN_Vector1 ), catConstVecs + "Value", KeyCode.Alpha1 ); - AddTemplate( typeof( SFN_Vector2 ), catConstVecs + "Vector 2", KeyCode.Alpha2 ); - AddTemplate( typeof( SFN_Vector3 ), catConstVecs + "Vector 3", KeyCode.Alpha3 ); - AddTemplate( typeof( SFN_Vector4 ), catConstVecs + "Vector 4", KeyCode.Alpha4 ); - AddTemplate( typeof( SFN_Matrix4x4 ), catConstVecs + "Matrix 4x4" ); - - string catProps = "Properties/"; - AddTemplate( typeof( SFN_Color ), catProps + "Color" ); - AddTemplate( typeof( SFN_Cubemap ), catProps + "Cubemap" ); - AddTemplate( typeof( SFN_Matrix4x4Property ), catProps + "Matrix 4x4" ); - AddTemplate( typeof( SFN_Slider ), catProps + "Slider" ); - AddTemplate( typeof( SFN_SwitchProperty ), catProps + "Switch" ); - AddTemplate( typeof( SFN_Tex2d ), catProps + "Texture 2D", KeyCode.T ); - AddTemplate( typeof( SFN_Tex2dAsset ), catProps + "Texture Asset" ); - AddTemplate( typeof( SFN_ToggleProperty ), catProps + "Toggle" ); - AddTemplate( typeof( SFN_ValueProperty ), catProps + "Value" ); - AddTemplate( typeof( SFN_Vector4Property ), catProps + "Vector 4" ); - - //string catBranching = "Branching/"; - //AddTemplate( typeof( SFN_StaticBranch ), catBranching + "Static Branch" ); - - string catVecOps = "Vector Operations/"; - AddTemplate( typeof( SFN_Append ), catVecOps + "Append", KeyCode.Q ); - AddTemplate( typeof( SFN_ChannelBlend ), catVecOps + "Channel Blend"); - AddTemplate( typeof( SFN_ComponentMask ), catVecOps + "Component Mask", KeyCode.C ); - AddTemplate( typeof( SFN_Cross ), catVecOps + "Cross Product" ); - AddTemplate( typeof( SFN_Desaturate ), catVecOps + "Desaturate" ); - AddTemplate( typeof( SFN_DDX ), catVecOps + "DDX" ); - AddTemplate( typeof( SFN_DDXY ), catVecOps + "DDXY" ).MarkAsNewNode(); - AddTemplate( typeof( SFN_DDY ), catVecOps + "DDY" ); - AddTemplate( typeof( SFN_Distance ), catVecOps + "Distance" ); - AddTemplate( typeof( SFN_Dot ), catVecOps + "Dot Product" ); - AddTemplate( typeof( SFN_Length ), catVecOps + "Length" ); - AddTemplate( typeof( SFN_Normalize ), catVecOps + "Normalize", KeyCode.N ); - AddTemplate( typeof( SFN_NormalBlend ), catVecOps + "Normal Blend" ); - AddTemplate( typeof( SFN_Reflect ), catVecOps + "Reflect" ); - AddTemplate( typeof( SFN_Transform ), catVecOps + "Transform" ); - AddTemplate( typeof( SFN_Transpose ), catVecOps + "Transpose" ); - AddTemplate( typeof( SFN_VectorProjection ),catVecOps + "Vector Projection" ); - AddTemplate( typeof( SFN_VectorRejection ), catVecOps + "Vector Rejection" ); - - - string catUvOps = "UV Operations/"; - AddTemplate( typeof( SFN_Panner ), catUvOps + "Panner", KeyCode.P ); - AddTemplate( typeof( SFN_Parallax ), catUvOps + "Parallax" ); - AddTemplate( typeof( SFN_Rotator ), catUvOps + "Rotator" ); - AddTemplate( typeof( SFN_UVTile ), catUvOps + "UV Tile" ); - - string catGeoData = "Geometry Data/"; - AddTemplate( typeof( SFN_Bitangent ), catGeoData + "Bitangent Dir."); - AddTemplate( typeof( SFN_Depth ), catGeoData + "Depth"); - AddTemplate( typeof( SFN_FaceSign ), catGeoData + "Face Sign" ); - AddTemplate( typeof( SFN_Fresnel ), catGeoData + "Fresnel", KeyCode.F ); - AddTemplate( typeof( SFN_NormalVector ), catGeoData + "Normal Dir." ); - AddTemplate( typeof( SFN_ObjectPosition ), catGeoData + "Object Position"); - AddTemplate( typeof( SFN_ObjectScale ), catGeoData + "Object Scale" ); - AddTemplate( typeof( SFN_ScreenPos ), catGeoData + "Screen Position" ); - AddTemplate( typeof( SFN_Tangent ), catGeoData + "Tangent Dir." ); - AddTemplate( typeof( SFN_TexCoord ), catGeoData + "UV Coordinates", KeyCode.U ); - AddTemplate( typeof( SFN_VertexColor ), catGeoData + "Vertex Color", KeyCode.V ); - AddTemplate( typeof( SFN_ViewVector ), catGeoData + "View Dir." ); - AddTemplate( typeof( SFN_ViewReflectionVector ), catGeoData + "View Refl. Dir.", KeyCode.None, "View Reflection" ); - AddTemplate( typeof( SFN_FragmentPosition ), catGeoData + "World Position", KeyCode.W ); - - string catLighting = "Lighting/"; - AddTemplate( typeof( SFN_AmbientLight ), catLighting + "Ambient Light" ); - AddTemplate( typeof( SFN_HalfVector ), catLighting + "Half Direction", KeyCode.H ).UavailableInDeferredPrePass(); - AddTemplate( typeof( SFN_LightAttenuation ), catLighting + "Light Attenuation" ).UavailableInDeferredPrePass(); - AddTemplate( typeof( SFN_LightColor ), catLighting + "Light Color" ).UavailableInDeferredPrePass(); - AddTemplate( typeof( SFN_LightVector ), catLighting + "Light Direction" ).UavailableInDeferredPrePass(); - AddTemplate( typeof( SFN_LightPosition ), catLighting + "Light Position" ).UavailableInDeferredPrePass(); - - string catExtData = "External Data/"; - AddTemplate( typeof( SFN_PixelSize ), catExtData + "Pixel Size" ); - AddTemplate( typeof( SFN_ProjectionParameters ), catExtData + "Projection Parameters" ); - AddTemplate( typeof( SFN_ScreenParameters ), catExtData + "Screen Parameters" ); - AddTemplate( typeof( SFN_Time ), catExtData + "Time" ); - AddTemplate( typeof( SFN_ViewPosition ), catExtData + "View Position" ); - - string catSceneData = "Scene Data/"; - AddTemplate( typeof(SFN_DepthBlend), catSceneData + "Depth Blend" ); - AddTemplate( typeof( SFN_FogColor ), catSceneData + "Fog Color" ); - AddTemplate( typeof(SFN_SceneColor), catSceneData + "Scene Color" ); - AddTemplate( typeof(SFN_SceneDepth), catSceneData + "Scene Depth" ); - - string catMathConst = "Math Constants/"; - AddTemplate( typeof( SFN_E ), catMathConst + "e", KeyCode.None, "EulersConstant" ); - AddTemplate( typeof( SFN_Phi ), catMathConst + "Phi" ); - AddTemplate( typeof( SFN_Pi ), catMathConst + "Pi" ); - AddTemplate( typeof( SFN_Root2 ), catMathConst + "Root 2" ); - AddTemplate( typeof( SFN_Tau ), catMathConst + "Tau (2 Pi)", KeyCode.None, "Tau" ); - - string catTrig = "Trigonometry/"; - AddTemplate( typeof( SFN_ArcCos ), catTrig + "ArcCos" ); - AddTemplate( typeof( SFN_ArcSin ), catTrig + "ArcSin" ); - AddTemplate( typeof( SFN_ArcTan ), catTrig + "ArcTan" ); - AddTemplate( typeof( SFN_ArcTan2 ), catTrig + "ArcTan2" ); - AddTemplate( typeof( SFN_Cos ), catTrig + "Cos" ); - AddTemplate( typeof( SFN_Sin ), catTrig + "Sin" ); - AddTemplate( typeof( SFN_Tan ), catTrig + "Tan" ); - - string catCode = "Code/"; - AddTemplate( typeof( SFN_Code ), catCode + "Code" ); - - string catUtility = "Utility/"; - AddTemplate( typeof( SFN_Relay ), catUtility + "Relay" ); - AddTemplate( typeof( SFN_Get ), catUtility + "Get", KeyCode.G ).MarkAsNewNode(); - AddTemplate( typeof( SFN_Set ), catUtility + "Set" ).MarkAsNewNode(); - - - - SF_EditorNodeData ssDiff = TryAddTemplateDynamic( "SFN_SkyshopDiff", "Skyshop/" + "Skyshop Diffuse" ); - if(ssDiff != null) - ssDiff.MarkAsNewNode(); - - SF_EditorNodeData ssSpec = TryAddTemplateDynamic( "SFN_SkyshopSpec", "Skyshop/" + "Skyshop Specular" ); - if( ssSpec != null ) - ssSpec.MarkAsNewNode(); - - - - - } - - - public static bool NodeExistsAndIs(SF_Node node, string nodeName){ - if(NodeExists(nodeName)) - if(node.GetType() == GetNodeType(nodeName)) - return true; - return false; - } - - public static bool NodeExists(string nodeName){ - return GetNodeType(nodeName) != null; - } - - - static Assembly editorAssembly; - public static Assembly EditorAssembly { - get { - if( editorAssembly == null ) { - - Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); - - foreach( Assembly assembly in assemblies ) { - if( assembly.FullName.Split( ',' )[0].Trim() == "Assembly-CSharp-Editor" ) { - editorAssembly = assembly; - return editorAssembly; - } - } - //if( SF_Debug.dynamicNodeLoad ) - // Debug.LogError("Unable to find the editor assembly" ); - } - return editorAssembly; - } - } - - - public static Type GetNodeType(string nodeName){ - - Assembly asm = EditorAssembly; - if( asm == null ) - return null; - string fullNodeName = nodeName; - if(!nodeName.StartsWith("ShaderForge.")) - fullNodeName = "ShaderForge." + nodeName; - if( SF_Debug.dynamicNodeLoad ) - Debug.Log( "Trying to dynamically load [" + fullNodeName + "]" + " in assembly [" + asm.FullName + "]" ); - - return asm.GetType( fullNodeName ); - } - - public SF_EditorNodeData TryAddTemplateDynamic(string type, string label, KeyCode keyCode = KeyCode.None, string searchName = null ){ - - Type dynType = GetNodeType(type); - - if(dynType != null){ - if(SF_Debug.dynamicNodeLoad) - Debug.Log( "TryAddTemplateDynamic of " + type ); - return AddTemplate( dynType, label, keyCode, searchName ); - } - if( SF_Debug.dynamicNodeLoad ) - Debug.Log( "TryAddTemplateDynamic of " + type + " was null" ); - return null; - } - - public SF_EditorNodeData AddTemplate( Type type, string label, KeyCode keyCode = KeyCode.None, string searchName = null ) { - SF_EditorNodeData item = ScriptableObject.CreateInstance().Initialize( type.FullName, label, keyCode ); - - if(!string.IsNullOrEmpty(searchName)){ - item.SearchName = searchName; - } - - this.nodeTemplates.Add( item ); - return item; - } - - - - public SF_EditorNodeData GetTemplate() { - foreach( SF_EditorNodeData sft in nodeTemplates ) { - if( sft.type == typeof(T).FullName ) - return sft; - } - return null; - } - - public SF_EditorNodeData GetTemplate( string typeName ) { - foreach( SF_EditorNodeData sft in nodeTemplates ) { - if( sft.type == typeName ) - return sft; - } - return null; - } - - - public void OnShaderModified(NodeUpdateType updType) { - //Debug.Log("OnShaderModified: " + updType.ToString() ); - if( updType == NodeUpdateType.Hard && nodeView.treeStatus.CheckCanCompile() ){ - nodeView.lastChangeTime = (float)EditorApplication.timeSinceStartup; - ShaderOutdated = UpToDateState.OutdatedHard; - } - if(updType == NodeUpdateType.Soft && ShaderOutdated == UpToDateState.UpToDate) - ShaderOutdated = UpToDateState.OutdatedSoft; - - ps.fChecker.UpdateAvailability(); - ps.UpdateAutoSettings(); - } - - public void ResetRunningOutdatedTimer(){ - if(ShaderOutdated == UpToDateState.UpToDate) - return; - if(ShaderOutdated == UpToDateState.OutdatedSoft) // Might not want to have this later - return; - - nodeView.lastChangeTime = (float)EditorApplication.timeSinceStartup; - - } - - /* - public Vector3 GetMouseWorldPos( Vector3 playerPos ) { - - Vector3 camDir = Camera.main.transform.forward; - Ray r = Camera.main.ScreenPointToRay( Input.mousePosition ); - Plane p = new Plane( camDir * -1, playerPos ); - - float dist = 0f; - if( p.Raycast( r, out dist ) ) { - return r.GetPoint( dist ); - } - - Debug.LogError( "Mouse ray did not hit the plane" ); - return Vector3.zero; - }*/ - - public bool InitializeInstance( Shader initShader = null ) { - if(SF_Debug.evalFlow) - Debug.Log( "[SF_LOG] - SF_Editor InitializeInstance(" + initShader + ")" ); - //this.title = ; - - SF_Settings.InitializeSettings(); - this.initialized = true; - this.ps = ScriptableObject.CreateInstance().Initialize( this ); - this.shaderEvaluator = new SF_Evaluator( this ); - this.preview = new SF_PreviewWindow( this ); - this.statusBox = new SF_StatusBox( /*this*/ ); - statusBox.Initialize(this); - - InitializeNodeTemplates(); - - windowStyle = new GUIStyle( EditorStyles.textField ); - windowStyle.margin = new RectOffset( 0, 0, 0, 0 ); - windowStyle.padding = new RectOffset( 0, 0, 0, 0 ); - - titleStyle = new GUIStyle( EditorStyles.largeLabel ); - titleStyle.fontSize = 24; - - versionStyle = new GUIStyle( EditorStyles.miniBoldLabel ); - versionStyle.alignment = TextAnchor.MiddleLeft; - versionStyle.fontSize = 9; - versionStyle.normal.textColor = Color.gray; - versionStyle.padding.left = 1; - versionStyle.padding.top = 1; - versionStyle.padding.bottom = 1; - versionStyle.margin.left = 1; - versionStyle.margin.top = 3; - versionStyle.margin.bottom = 1; - - this.nodes = new List(); - - // Create main output node and add to list - this.nodeView = ScriptableObject.CreateInstance().Initialize( this ); - this.ps.catConsole.treeStatus = this.nodeView.treeStatus; - this.nodeBrowser = ScriptableObject.CreateInstance().Initialize( this ); - this.separatorLeft = ScriptableObject.CreateInstance(); - this.separatorRight = ScriptableObject.CreateInstance(); - - separatorLeft.rect = new Rect(340, 0, 0, 0); - separatorRight.rect = new Rect(Screen.width - 130f, 0, 0, 0); - - this.previousPosition = position; - - if( initShader == null ) { - // TODO: New menu etc - //CreateOutputNode(); - } else { - currentShaderAsset = initShader; - - bool loaded = SF_Parser.ParseNodeDataFromShader( this, initShader ); - if( !loaded ) { - initShader = null; - DestroyImmediate( this ); - return false; - } - - // Make preview material use this shader - //preview.material.shader = currentShaderAsset; - Material m = preview.InternalMaterial; - SF_Tools.AssignShaderToMaterialAsset( ref m, currentShaderAsset ); - } - - // Load data if it was set to initialize things - return true; // Successfully loaded - } - - - - - - public SF_Node CreateOutputNode() { - //Debug.Log ("Creating output node"); - this.mainNode = ScriptableObject.CreateInstance().Initialize( this );//new SFN_Final(); - this.nodes.Add( mainNode ); - return mainNode; - } - - public SF_Node GetNodeByID( int id ) { - for( int i = 0; i < nodes.Count; i++ ) { - if( nodes[i].id == id ) - return nodes[i]; - } - return null; - } - - - - - - public void UpdateKeyHoldEvents(bool mouseOverSomeNode) { - if( nodeTemplates == null || nodeTemplates.Count == 0 ) { - InitializeNodeTemplates(); - } - - //Debug.Log( "nodeTemplates.Count = " + nodeTemplates.Count ); - - foreach( SF_EditorNodeData nData in nodeTemplates ) { - - if( nData == null ) { - InitializeNodeTemplates(); - return; - } - SF_EditorNodeData requestedNode = nData.CheckHotkeyInput(mouseOverSomeNode); - if( requestedNode != null ) { - AddNode( requestedNode, true ); - return; - } - } - /*foreach(KeyValuePair> entry in inputInstancers){ - if(entry.Key.CheckHotkeyInput()){ - AddNode( entry.Key ); - } - }*/ - } - - public T AddNode() where T:SF_Node { - return AddNode(GetTemplate()) as T; - } - - public SF_Node AddNode(string typeName) { - //Debug.Log( "Searching for " + typeName ); - return AddNode( GetTemplate( typeName ) ); - } - - public SF_Node AddNode( SF_EditorNodeData nodeData, bool registerUndo = false ) { - - if( nodeData == null ){ - Debug.Log("Null node data passed into AddNode"); - } - - SF_Node node = nodeData.CreateInstance(); - - if( SF_Debug.dynamicNodeLoad ) { - if( node == null ) - Debug.Log( "nodeData failed to create a node of full path: " + nodeData.fullPath ); - else - Debug.Log( "Created a node of full path: " + nodeData.fullPath ); - } - - if(registerUndo){ - Undo.RecordObject(this, "add node " + node.nodeName); - } - - - nodes.Add( node ); - if(Event.current != null) - Event.current.Use(); - //Repaint(); - return node; - } - - - bool Clicked() { - return Event.current.type == EventType.mouseDown; - } - - float fps = 0; - double prevFrameTime = 1; - public double deltaTime = 0.02; - - - - - - - List coroutines = new List(); - - //double corLastTime; - // double corDeltaTime; - void UpdateCoroutines(){ - //corDeltaTime = EditorApplication.timeSinceStartup - corLastTime; - //corLastTime = EditorApplication.timeSinceStartup; - for(int i = 0; i < coroutines.Count; i++){ - IEnumerator routine = coroutines[i]; - if(!routine.MoveNext()){ - coroutines.RemoveAt(i--); - } - } - } - void StartCoroutine (IEnumerator routine){ - coroutines.Add(routine); - } - - - - - void Update() { - - - - if( closeMe ) { - base.Close(); - return; - } - - - double now = Now(); - double deltaTime = now-prevFrameTime; - fps = 1f/(float)deltaTime; - - - - if(fps > 60) - return; // Wait for target FPS - - - prevFrameTime = now; - - preview.UpdateRot(); - - - - for (int i = nodes.Count - 1; i >= 0; i--) { - if(nodes[i] == null) - nodes.Remove(nodes[i]); - else - nodes[i].Update(); - } - - - // Refresh node previews - int maxUpdatesPerFrame = 80; - int updatedNodes = 0; - - while( updatedNodes < maxUpdatesPerFrame ) { - bool anyUpdated = false; - for( int i = 0; i < nodes.Count; i++ ) { - if( nodes[i].CheckIfDirty() ) { - anyUpdated = true; - updatedNodes++; - } - } - if( !anyUpdated ) { - break; - } - } - - - - - - - if( ShaderOutdated == UpToDateState.OutdatedHard && SF_Settings.autoCompile && nodeView.GetTimeSinceChanged() >= 1f) { - shaderEvaluator.Evaluate(); - } - - - //UpdateCameraZoomValue(); - if(focusedWindow == this) - Repaint(); // Update GUI every frame if focused - - } - - - - MethodInfo isDockedMethod; - const float dockedCheckInterval = 1f; - public float dockedLastUpdate = -100f; - public bool _docked = false; - public bool Docked{ - get{ - if( EditorApplication.timeSinceStartup - dockedLastUpdate > dockedCheckInterval ) { - dockedLastUpdate = (float)EditorApplication.timeSinceStartup; - if( isDockedMethod == null ) { - BindingFlags fullBinding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; - isDockedMethod = typeof( EditorWindow ).GetProperty( "docked", fullBinding ).GetGetMethod( true ); - } - _docked = ( bool ) isDockedMethod.Invoke(this, null); - } - return _docked; - } - } - - public int TabOffset{ - get{ - return Docked ? 19 : 22; - } - } - - - - public double Now(){ - TimeSpan t = ( DateTime.UtcNow - startTime ); - return t.TotalSeconds; - } - - - - - void OnWindowResized( int deltaXsize, int deltaYsize ) { - if(separatorRight == null) - ForceClose(); - separatorRight.rect.x += deltaXsize; - } - - void ForceClose() { - //Debug.Log("Force close"); - closeMe = true; - GUIUtility.ExitGUI(); - } - - void AddDependenciesHierarchally(SF_Node node, DependencyTree tree){ - node.ReadDependencies(); - tree.Add(node); - foreach(SF_Node n in ((IDependable)node).Dependencies){ - AddDependenciesHierarchally(n, tree); - } - } - - public List GetDepthSortedDependencyTreeForConnectedNodes(bool reverse = false){ - DependencyTree tree = new DependencyTree(); - - AddDependenciesHierarchally(mainNode, tree); - //Debug.Log(tree.tree.Count); - tree.Sort(); - - List list = tree.tree.Select(x=>(SF_Node)x).ToList(); - if(reverse) - list.Reverse(); - return list; - } - - string fullscreenMessage = ""; - public Rect previousPosition; - public bool closeMe = false; - void OnGUI() { - - //Debug.Log("SF_Editor OnGUI()"); - - //SF_AllDependencies.DrawDependencyTree(new Rect(0, 0, Screen.width, Screen.height)); - //return; - -// if(Event.current.keyCode == KeyCode.Space && Event.current.type == EventType.keyDown){ -// Debug.Log("Beep"); -// Event.current.Use(); -// -// -// -// } - - if(SF_Parser.quickLoad) // Don't draw while loading - return; - - if(SF_Debug.performance) - GUI.Label(new Rect(500,64,128,64),"fps: "+fps.ToString()); - - if( position != previousPosition ) { - OnWindowResized( (int)(position.width - previousPosition.width), (int)(position.height - previousPosition.height) ); - previousPosition = position; - } - - Rect fullRect = new Rect( 0, 0, Screen.width, Screen.height); - //Debug.Log( fullRect ); - - if( currentShaderAsset == null ) { - DrawMainMenu(); - return; - } - - if(!string.IsNullOrEmpty(fullscreenMessage)){ - GUI.Box(fullRect,fullscreenMessage); - return; - } - - - - //UpdateCameraZoomInput(); - - - if(Event.current.rawType == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed"){ - Defocus(deselectNodes:false); - CheckForDirtyNodes(); // When undoing, some nodes will come back as dirty, which means they need to update their values - shaderEvaluator.ps.fChecker.UpdateAvailability(); - ResetRunningOutdatedTimer(); - } - - - if( nodes != null ) { - - //foreach( SF_Node n in nodes ) { - for( int i = 0; i < nodes.Count;i++ ) { - SF_Node n = nodes[i]; - - if( n == null ) { - // THIS MEANS YOU STARTED UNITY WITH SF OPEN - ForceClose(); - return; - } else{ - n.DrawConnections(); - } - } - - } - - if(separatorLeft == null){ - // THIS MEANS YOU STARTED UNITY WITH SF OPEN - ForceClose(); - return; - } - - - - - //EditorGUILayout.BeginHorizontal(); - //{ - //float wPreview = leftSeparator; - //float wNodeBrowser = 130; - - Rect pRect = new Rect( fullRect ); - pRect.height /= EditorGUIUtility.pixelsPerPoint; - pRect.width /= EditorGUIUtility.pixelsPerPoint; - pRect.width = separatorLeft.rect.x; - SF_GUI.FillBackground( pRect ); - DrawPreviewPanel( pRect ); - Rect previewPanelRect = pRect; - - //pRect.x += leftWidth; - //pRect.width = wSeparator; - //VerticalSeparatorDraggable(ref leftWidth, pRect ); - separatorLeft.MinX = 320; - separatorLeft.MaxX = (int)( fullRect.width / 2f - separatorLeft.rect.width ); - separatorLeft.Draw( (int)pRect.y, (int)pRect.height ); - pRect.x = separatorLeft.rect.x + separatorLeft.rect.width; - - - if(SF_Settings.showNodeSidebar) - pRect.width = separatorRight.rect.x - separatorLeft.rect.x - separatorLeft.rect.width; - else - pRect.width = Screen.width - separatorLeft.rect.x - separatorLeft.rect.width; - //GUI.Box( new Rect( 300, 0, 512, 32 ), pRect.ToString() ); - - if( SF_Debug.nodes ) { - Rect r = pRect; r.width = 256; r.height = 16; - for( int i = 0; i < nodes.Count; i++ ) { - GUI.Label( r, "Node[" + i + "] at {" + nodes[i].rect.x + ", " + nodes[i].rect.y + "}", EditorStyles.label ); // nodes[i] - r = r.MovedDown(); - } - } - - if( Event.current.rawType == EventType.keyUp ){ - foreach(SF_EditorNodeData nd in nodeTemplates){ - nd.holding = false; - } - } - - - nodeView.OnLocalGUI( pRect.PadTop(TabOffset) ); // 22 when not docked, 19 if docked - //GUI.EndGroup(); - - //pRect.yMin -= 3; // if docked - - - - - - //pRect.x += pRect.width; - //pRect.width = wSeparator; - //VerticalSeparatorDraggable(ref rightWidth, pRect ); - if(SF_Settings.showNodeSidebar){ - separatorRight.MinX = (int)(fullRect.width / EditorGUIUtility.pixelsPerPoint) - 150; - separatorRight.MaxX = (int)(fullRect.width / EditorGUIUtility.pixelsPerPoint) - 32; - separatorRight.Draw( (int)pRect.y, (int)pRect.height ); - - pRect.x += pRect.width + separatorRight.rect.width; - pRect.width = (fullRect.width / EditorGUIUtility.pixelsPerPoint) - separatorRight.rect.x - separatorRight.rect.width; - - SF_GUI.FillBackground( pRect ); - nodeBrowser.OnLocalGUI( pRect ); - } - - - - - // Last thing, right? - - ssButtonColor = Color.Lerp(ssButtonColor,ssButtonColorTarget, (float)deltaTime*ssButtonFadeSpeed); - - if(previewPanelRect.Contains(Event.current.mousePosition)){ - - ssButtonColorTarget = Color.white; - ssButtonFadeSpeed = 0.4f; - - - } else { - ssButtonColorTarget = new Color(1f,1f,1f,0f); // TODO LERP - ssButtonFadeSpeed = 1.5f; - } - Rect ssRect = new Rect(8,previewButtonHeightOffset,32,19); - GUI.color = ssButtonColor; - if(GUI.Button(ssRect, SF_GUI.Screenshot_icon)){ - GenericMenu menu = new GenericMenu(); - menu.AddItem( new GUIContent("Take screenshot of node tree"), false, ContextClickScreenshot, "ss_standard" ); - menu.AddItem( new GUIContent("Take screenshot of node tree without 3D preview"), false, ContextClickScreenshot, "ss_nopreview" ); - menu.ShowAsContext(); - - } - GUI.color = Color.white; - - //Rect ssRectIcon = new Rect(0f, 0f, SF_GUI.Screenshot_icon.width, SF_GUI.Screenshot_icon.height); - ////ssRectIcon.center = ssRect.center; - //GUI.DrawTexture(ssRectIcon, SF_GUI.Screenshot_icon); - - - if(Event.current.type == EventType.repaint) - UpdateCoroutines(); - - - DrawTooltip(); - - } - - - public void CheckForDirtyNodes(){ - - for(int i=0;i 0){ - shaderTitle = split[split.Length-1]; - } - } - } - - - - - - for(int ix=0;ix nodeRects = new List(); - List lines = new List(); - for(int i=0;i longestDist){ - longestDist = shortest; - longestDistPt = testPt; - //pixel = Color.red; - }// else { - //pixel = Color.white * Mathf.Clamp01(shortest/(Mathf.Max(nodeWrap.width,nodeWrap.height)*0.2f)); - //} - - - - //pixel.a = 1f; - //newMaskPixels[i] = pixel; - } - //mask.SetPixels(newMaskPixels); - //mask.Apply(); - radius = longestDist; - return longestDistPt; - } - - - - - // TOOLTIP, Draw this last - public void DrawTooltip() { - /* - if( !string.IsNullOrEmpty( GUI.tooltip ) ) { - //Debug.Log( "TOOLTIP" ); - GUIStyle tooltipStyle = EditorStyles.miniButton; - GUI.Box( - new Rect( - Event.current.mousePosition.x + 32, - Event.current.mousePosition.y, - tooltipStyle.CalcSize( new GUIContent( GUI.tooltip ) ).x * 1.1f, - tooltipStyle.CalcSize( new GUIContent( GUI.tooltip ) ).y * 1.2f - ), - GUI.tooltip, tooltipStyle - ); - } - GUI.tooltip = null;*/ - } - - public void Defocus(bool deselectNodes = false) { - //Debug.Log("DEFOCUS"); -// string currentFocus = GUI.GetNameOfFocusedControl(); -// if( currentFocus != "defocus"){ - GUI.FocusControl("null"); -// } - - if( deselectNodes ) - nodeView.selection.DeselectAll(registerUndo:true); - } - - - public bool DraggingAnySeparator() { - return separatorLeft.dragging || separatorRight.dragging; - } - - - - public void FlexHorizontal(Action func){ - GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); - func(); - GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); - } - - public void FlexHorizontal(Action func, float width){ - GUILayout.BeginHorizontal(GUILayout.Width(width)); GUILayout.Space(Screen.width/2f - 335); - func(); - GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); - } - - - public static string updateCheck = ""; - public static bool outOfDate = false; - - public static void CheckForUpdates(){ - updateCheck = "Checking for updates..."; - //Debug.Log(updateCheck); - - WebClient wc = new WebClient(); - - string latestVersion; - - try{ - latestVersion = wc.DownloadString("http://www.acegikmo.com/shaderforge/latestversion.php"); - string[] split = latestVersion.Split('.'); - int latestMajor = int.Parse(split[0]); - int latestMinor = int.Parse(split[1]); - - if(latestMajor > SF_Tools.versionNumPrimary){ - outOfDate = true; - } else if(latestMajor == SF_Tools.versionNumPrimary && latestMinor > SF_Tools.versionNumSecondary){ - outOfDate = true; - } else { - outOfDate = false; - } - - if(outOfDate){ - updateCheck = "Shader Forge is out of date!\nYou are running " + SF_Tools.version + ", the latest version is " + latestVersion; - } else { - updateCheck = "Shader Forge is up to date!"; - } - - - - - } catch ( WebException e){ - updateCheck = "Couldn't check for updates: " + e.Status; - } - - - } - - - private enum MainMenuState{Main, Credits, PresetPick} - - private MainMenuState menuState = MainMenuState.Main; - - - public void DrawMainMenu() { - - - //SF_AllDependencies.DrawDependencyTree(new Rect(0f,0f,Screen.width,Screen.height)); - //return; - - if(string.IsNullOrEmpty(updateCheck)){ - CheckForUpdates(); - } - - GUILayout.BeginVertical(); - { - GUILayout.FlexibleSpace(); - - - FlexHorizontal(()=>{ - GUILayout.Label( SF_GUI.Logo ); - if(outOfDate) - GUI.color = Color.red; - GUILayout.Label( SF_Tools.versionStage + " v" + SF_Tools.version, EditorStyles.boldLabel ); - if(outOfDate) - GUI.color = Color.white; - }); - - - if(menuState == MainMenuState.Main){ - minSize = new Vector2(500,400); - DrawPrimaryMainMenuGUI(); - } else if( menuState == MainMenuState.PresetPick ) { - minSize = new Vector2( 128*(shaderPresetNames.Length + 1), 560 ); - DrawPresetPickGUI(); - } else if(menuState == MainMenuState.Credits){ - - //Vector2 centerPrev = position.center; - - minSize = new Vector2(740,560); - - //Rect rWnd = position; - //rWnd.center = new Vector2( 800,800); - //position = rWnd; - - - DrawCreditsGUI(); - } - - - - - GUILayout.FlexibleSpace(); - } - GUILayout.EndVertical(); - - - } - - public void DrawCreditsGUI(){ - EditorGUILayout.Separator(); - FlexHorizontal(()=>{ - GUILayout.Label( "Thanks for purchasing Shader Forge <3" ); - }); - EditorGUILayout.Separator(); - EditorGUILayout.Separator(); - FlexHorizontal(()=>{ - GUILayout.Label( "Created by ", SF_Styles.CreditsLabelText); - GUILayout.Label( "Freya 'Acegikmo' Holm" + '\u00e9' + "r", EditorStyles.boldLabel); - }); - EditorGUILayout.Separator(); - EditorGUILayout.Separator(); - FlexHorizontal(()=>{ - GUILayout.Label( "Special thanks:", EditorStyles.boldLabel ); - }); - CreditsLine("All of the alpha & beta testers","For their amazing feedback during the early days!" ); - CreditsLine( "Jenny 'sranine' Nordenborg", "For creating the Shader Forge logo and for supporting me throughout the development time!" ); - CreditsLine( "Peter Cornelius", "For convincing me that I should have started creating SF in the first place" ); - CreditsLine( "Robert Briscoe", "For actively testing SF and providing excellent feedback" ); - CreditsLine( "Thomas Pasieka", "For helping out immensely in getting the word out, as well as motivating me to continue" ); - CreditsLine( "Aras Pranckevi" +'\u010D'+ "ius", "For helping out with various shader code issues"); - CreditsLine( "Renaldas 'ReJ' Zioma", "For assisting in the Unity 5 transition" ); - CreditsLine( "Tim 'Stramit' Cooper & David 'Texel' Jones", "For giving helpful tips"); - CreditsLine( "Sander 'Zerot' Homan", "For helping out stealing Unity's internal RT code"); - CreditsLine( "Carlos 'Darkcoder' Wilkes", "For helping out with various serialization issues"); - CreditsLine( "Ville 'wiliz' Mäkynen", "For helping out with the undo system"); - CreditsLine( "Daniele Giardini", "For his editor window icon script (also, check out his plugin DOTween!)"); - CreditsLine( "Beck Sebenius", "For helping out getting coroutines to run in the Editor"); - CreditsLine( "James 'Farfarer' O'Hare", "For asking all the advanced shader questions on the forums so I didn't have to"); - CreditsLine( "Tenebrous", "For helping with... Something... (I can't remember)"); - CreditsLine( "Alex Telford", "For his fragment shader tutorials"); - CreditsLine( "Shawn White", "For helping out finding how to access compiled shaders from code"); - CreditsLine( "Colin Barr"+ '\u00e9' +"-Brisebois & Stephen Hill", "For their research on normal map blending"); - CreditsLine( "Andrew Baldwin", "For his articles on pseudorandom numbers" ); - - - EditorGUILayout.Separator(); - FlexHorizontal(()=>{ - if( GUILayout.Button( "Return to menu", GUILayout.Height( 30f ), GUILayout.Width( 190f ) ) ) { - menuState = MainMenuState.Main; - } - }); - } - - public void CreditsLine(string author, string reason){ - FlexHorizontal(()=>{ - GUILayout.Label( author, EditorStyles.boldLabel ); - GUILayout.Label(" - ", SF_Styles.CreditsLabelText ); - GUILayout.Label( reason, SF_Styles.CreditsLabelText ); - },400f); - } - - public enum ShaderPresets { Unlit, LitPBR, LitBasic, Custom, Sprite, ParticleAdditive, ParticleAlphaBlended, ParticleMultiplicative, Sky, PostEffect } - public string[] shaderPresetNames = new string[] { - "Unlit", - "Lit\n(PBR)", - "Lit\n(Basic)", - "Custom Lighting", - "Sprite", - "Particle\n(Additive)", - "Particle\n(Alpha-Blended)", - "Particle\n(Multiplicative)", - "Sky", - "Post-Effect" - }; - - public string[] shaderPresetShaders = new string[] { - "Unlit", - "PBR", - "Basic", - "CustomLighting", - "Sprite", - "ParticleAdditive", - "ParticleAlphaBlended", - "ParticleMultiplicative", - "Sky", - "PostEffect" - }; - - public string GetShaderPresetPath(ShaderPresets preset) { - int i = (int)preset; - string file = "preset" + shaderPresetShaders[i] + ".shader"; - return SF_Resources.InternalResourcesPath + "Shader Presets/" + file; - } - - - public string[] shaderPresetDescriptions = new string[] { - "Unlit means that light sources will not affect this shader, it will simply have the color you give it, regardless of the scene setup.", - "Lit (PBR) is set up to match Unity's Physically Based shader, affected by lightmaps, light probes, reflection probes etc.", - "Lit (Basic) is the old-school Blinn-Phong lighting model. Direct lighting only, no lightmap or probe data.", - "Custom Lighting is set up with a simple example of how you can create your own lighting models. The initial setup is a Blinn-Phong shader.", - "Sprite is for creating 2D shaders to be used on sprites. These will have the pixel-perfect option and sort properly with other 2D sprites.", - "Particle (Additive) is generally for glow effects, lightshafts, sparks etc. Primarily used in particle systems.", - "Particle (Alpha-Blended) is generally for debris effects, dusty smoke etc. Primarily used in particle systems.", - "Particle (Multiplicative) is generally for darkening effects, black smoke, evil-looking anti-glow etc. Primarily used in particle systems.", - "Sky is for creating shaders to be used with a sky material in your scene. It will render behind everything else.", - "Post-Effect is for creating shaders meant to render full-screen rather than at a position in the world, commonly used for post-process effects" - }; - - string desc = ""; - - public void DrawPresetPickGUI() { - - GUIStyle centerLabel = new GUIStyle( EditorStyles.boldLabel ); - GUIStyle centerLabelSmall = new GUIStyle( EditorStyles.miniLabel ); - centerLabel.alignment = centerLabelSmall.alignment = TextAnchor.MiddleCenter; - - - EditorGUILayout.Separator(); - FlexHorizontal( () => { - GUILayout.BeginVertical(); - GUILayout.Label( "What kind of shader do you want to forge?", centerLabel ); - GUI.color = new Color(1f,1f,1f,0.4f); - GUILayout.Label( "This will simply affect the initial configuration of the shader. It will not \"lock-in\" any features", centerLabelSmall ); - GUI.color = Color.white; - GUILayout.EndVertical(); - } ); - EditorGUILayout.Separator(); - - - - FlexHorizontal( () => { - - GUILayoutOption[] btnLayout = new GUILayoutOption[2] { GUILayout.Width( 128 ), GUILayout.Height( 128 ) }; - - GUIStyle style = new GUIStyle( EditorStyles.boldLabel ); - style.alignment = TextAnchor.UpperCenter; - - //if( Event.current.type == EventType.mouseMove) - //desc = ""; - - //GUILayout.BeginVertical(); - for(int i=0;i { - GUILayout.Label( desc, centerLabelSmall ); - }); - - EditorGUILayout.Separator(); - EditorGUILayout.Separator(); - - FlexHorizontal( () => { - if( GUILayout.Button( "Back" ) ) { - menuState = MainMenuState.Main; - } - } ); - - - - - } - - - public Texture2D GetShaderPresetIcon(ShaderPresets preset) { - - switch( preset ) { - - case ShaderPresets.Custom: - return SF_GUI.Shader_preset_icon_custom; - case ShaderPresets.LitBasic: - return SF_GUI.Shader_preset_icon_litbasic; - case ShaderPresets.LitPBR: - return SF_GUI.Shader_preset_icon_litpbr; - case ShaderPresets.ParticleAdditive: - return SF_GUI.Shader_preset_icon_particleadditive; - case ShaderPresets.ParticleAlphaBlended: - return SF_GUI.Shader_preset_icon_particlealphablended; - case ShaderPresets.ParticleMultiplicative: - return SF_GUI.Shader_preset_icon_particlemultiplicative; - case ShaderPresets.Sky: - return SF_GUI.Shader_preset_icon_sky; - case ShaderPresets.Sprite: - return SF_GUI.Shader_preset_icon_sprite; - case ShaderPresets.Unlit: - return SF_GUI.Shader_preset_icon_unlit; - case ShaderPresets.PostEffect: - return SF_GUI.Shader_preset_icon_posteffect; - - } - - Debug.LogError("No preset icon found"); - - return null; - - - } - - - public void DrawPrimaryMainMenuGUI(){ - - - - FlexHorizontal(()=>{ - GUI.color = new Color( 0.7f, 0.7f, 0.7f ); - if( GUILayout.Button( '\u00a9' + " Freya 'Acegikmo' Holm" + '\u00e9' + "r", EditorStyles.miniLabel ) ) { - Application.OpenURL("https://twitter.com/FreyaHolmer"); - } - - SF_GUI.AssignCursorForPreviousRect( MouseCursor.Link ); - GUI.color = Color.white; - }); - - EditorGUILayout.Separator(); - - /* - FlexHorizontal(()=>{ - if( GUILayout.Button(SF_Tools.manualLabel , GUILayout.Height( 32f ), GUILayout.Width( 190f ) ) ) { - Application.OpenURL( SF_Tools.manualURL ); - } - }); - */ - - FlexHorizontal(()=>{ - - if(SF_Tools.CanRunShaderForge()){ - if( GUILayout.Button( "New Shader", GUILayout.Width( 128 ), GUILayout.Height( 64 ) ) ) { - menuState = MainMenuState.PresetPick; - } - if( GUILayout.Button( "Load Shader", GUILayout.Width( 128 ), GUILayout.Height( 64 ) ) ) { - OpenLoadDialog(); - } - } else { - GUILayout.BeginVertical(); - SF_Tools.UnityOutOfDateGUI(); - GUILayout.EndVertical(); - } - }); - - - - FlexHorizontal(()=>{ - if( GUILayout.Button( "Polycount thread" ) ) { - Application.OpenURL( "http://www.polycount.com/forum/showthread.php?t=123439" ); - } - if( GUILayout.Button( "Unity thread" ) ) { - Application.OpenURL( "http://forum.unity3d.com/threads/222049-Shader-Forge-A-visual-node-based-shader-editor" ); - } - if( GUILayout.Button( SF_Tools.documentationLabel ) ) { - Application.OpenURL( SF_Tools.documentationURL ); - } - if( GUILayout.Button( "Wiki" ) ) { - Application.OpenURL( "http://acegikmo.com/shaderforge/wiki" ); - } - if( GUILayout.Button("Credits") ){ - menuState = MainMenuState.Credits; - } - }); - - - FlexHorizontal( () => { - if( GUILayout.Button( SF_Tools.bugReportLabel, GUILayout.Height( 32f ), GUILayout.Width( 180f ) ) ) { - Application.OpenURL( SF_Tools.bugReportURL ); - } - } ); - - FlexHorizontal( () => { - if( GUILayout.Button( "Forums", GUILayout.Height( 32f ), GUILayout.Width( 120f ) ) ) { - Application.OpenURL( "http://neatcorporation.com/forums/viewforum.php?f=1" ); - } - } ); - - EditorGUILayout.Separator(); - FlexHorizontal(()=>{ - GUILayout.Label(updateCheck); - }); - if(outOfDate){ - float t = (Mathf.Sin((float)EditorApplication.timeSinceStartup*Mathf.PI*2f)*0.5f)+0.5f; - GUI.color = Color.Lerp(Color.white, new Color(0.4f,0.7f,1f),t); - FlexHorizontal(()=>{ - if(GUILayout.Button("Download latest version")){ - Application.OpenURL( "https://www.assetstore.unity3d.com/#/content/14147" ); - } - }); - t = (Mathf.Sin((float)EditorApplication.timeSinceStartup*Mathf.PI*2f-1)*0.5f)+0.5f; - GUI.color = Color.Lerp(Color.white, new Color(0.4f,0.7f,1f),t); - FlexHorizontal(()=>{ - if(GUILayout.Button("What's new?")){ - Application.OpenURL( "http://acegikmo.com/shaderforge/changelog/" ); - } - }); - GUI.color = Color.green; - } - } - - - - public bool PropertyNameTaken(SF_ShaderProperty sProp){ - foreach(SF_Node n in nodes){ - if(n == sProp.node) - continue; - if(n.IsProperty()) - if(n.property.nameDisplay == sProp.nameDisplay || n.property.nameInternal == sProp.nameInternal) - return true; - } - return false; - } - - - public void OpenLoadDialog(){ - string path = EditorUtility.OpenFilePanel( - "Load Shader", - "Assets", - "shader" - ); - - if( string.IsNullOrEmpty( path ) ) { - //Debug.LogError("No path selected"); - return; - } else { - - // Found file! Make sure it's a shader - - path = SF_Tools.PathFromAbsoluteToProject( path ); - Shader loadedShader = (Shader)AssetDatabase.LoadAssetAtPath(path, typeof(Shader)); - if( loadedShader == null ) { - Debug.LogError( "Selected shader not found" ); - return; - } - - - - bool isSFshader = SF_Parser.ContainsShaderForgeData(loadedShader); - - bool allowEdit = isSFshader; - if(!allowEdit) - allowEdit = SF_GUI.AcceptedNewShaderReplaceDialog(); - - - if( allowEdit ) { - SF_Editor.Init( loadedShader ); - } else { - //Debug.LogError( "User cancelled loading operation" ); - } - - } - - } - - - - public bool TryCreateNewShader(SF_Editor.ShaderPresets preset) { - - - - - - //Shader s = (Shader)AssetDatabase.LoadAssetAtPath( presetPath, typeof(Shader) ); - //Debug.Log( s); - - - - string savePath = EditorUtility.SaveFilePanel( - "Save new shader", - "Assets", - "NewShader", - "shader" - ); - - if( string.IsNullOrEmpty( savePath ) ) { - return false; - } - - string presetPath = GetShaderPresetPath( preset ); - StreamReader presetReader = new StreamReader( Application.dataPath + presetPath.Substring( 6 ) ); - - // So we now have the path to save it, let's save - StreamWriter sw; - if( !File.Exists( savePath ) ) { - sw = File.CreateText( savePath ); - } else { - sw = new StreamWriter(savePath); - } - - // Read from preset - string[] presetLines = presetReader.ReadToEnd().Split( '\n' ); - for( int i=0; i < presetLines.Length; i++ ) { - if( presetLines[i].StartsWith( "Shader \"Hidden/" ) ) { - - // Extract name of the file to put in the shader path - string[] split = savePath.Split( '/' ); - currentShaderPath = split[split.Length - 1].Split( '.' )[0]; - currentShaderPath = "Shader Forge/" + currentShaderPath; - - // Write to the line - presetLines[i] = "Shader \"" + currentShaderPath + "\" {"; - - break; - } - } - - // Read from the preset - for( int i=0; i < presetLines.Length; i++ ) { - sw.WriteLine( presetLines[i] ); - } - - sw.Flush(); - sw.Close(); - presetReader.Close(); - AssetDatabase.Refresh(); - - // Shorten it to a relative path - string dataPath = Application.dataPath; - string assetPath = "Assets/" + savePath.Substring( dataPath.Length + 1 ); - - // Assign a reference to the file - currentShaderAsset = (Shader)AssetDatabase.LoadAssetAtPath( assetPath, typeof( Shader ) ); - - if( currentShaderAsset == null ) { - Debug.LogError( "Couldn't load shader asset" ); - Debug.Break(); - return false; - } - - - - // Make sure the preview material is using the shader - preview.InternalMaterial.shader = currentShaderAsset; - - // That's about it for the file/asset management. - //CreateOutputNode(); - SF_Editor.Init( currentShaderAsset ); - //shaderEvaluator.Evaluate(); // And we're off! - - //nodeView.CenterCamera(); - - return true; - } - - public string GetShaderFilePath() { - - if( currentShaderAsset == null ) { - Debug.LogError( "Tried to find path of null shader asset!" ); - Debug.Break(); - return null; - } - return AssetDatabase.GetAssetPath( currentShaderAsset ); - } - - public bool displaySettings = false; - - public void DrawPreviewPanel( Rect r ) { - // Left side shader preview - - //Rect logoRect = new Rect( 1, 0, SF_GUI.Logo.width, SF_GUI.Logo.height ); - - //GUI.DrawTexture( logoRect, SF_GUI.Logo ); - - Rect btnRect = new Rect(r); - btnRect.y += 4; - btnRect.x += 2; - //btnRect.xMin += logoRect.width; - - int wDiff = 8; - - btnRect.height = 17; - btnRect.width /= 4; - btnRect.width += wDiff; - - GUIStyle btnStyle = EditorStyles.miniButton; - - if(GUI.Button(btnRect,"Return to menu",btnStyle)){ - OnPressBackToMenuButton(); - } - btnRect.x += btnRect.width; - btnRect.xMax -= wDiff*2; - btnRect.width *= 0.75f; - displaySettings = GUI.Toggle(btnRect, displaySettings, "Settings",btnStyle); - - btnRect.x += btnRect.width; - btnRect.width *= 2f; - - GUI.color = SF_GUI.outdatedStateColors[(int)ShaderOutdated]; - if( GUI.Button( btnRect, "Compile shader", btnStyle ) ) { - if(nodeView.treeStatus.CheckCanCompile()) - shaderEvaluator.Evaluate(); - } - GUI.color = Color.white; - - nodeView.DrawRecompileTimer(btnRect); - btnRect.x += btnRect.width; - btnRect.width *= 0.5f; - - SF_Settings.autoCompile = GUI.Toggle( btnRect, SF_Settings.autoCompile, "Auto" ); - - btnRect.y += 4; - - - - // SETTINGS EXPANSION - if(displaySettings){ - btnRect.y += btnRect.height; - btnRect.x = r.x - 4; - btnRect.width = r.width / 4f; - btnRect.x += btnRect.width; - btnRect.width *= 2.55f; - - /*Rect[] splitRects = btnRect.SplitHorizontal( 0.5f, 1 ); // Node render mode control - GUI.Label( splitRects[1], "Node rendering" ); - EditorGUI.BeginChangeCheck(); - SF_Settings.nodeRenderMode = (NodeRenderMode)EditorGUI.EnumPopup( splitRects[0], SF_Settings.nodeRenderMode ); - if( EditorGUI.EndChangeCheck() ) { - RegenerateNodeBaseData(); - } - btnRect = btnRect.MovedDown();*/ - if( SF_Settings.nodeRenderMode == NodeRenderMode.Viewport ) { - EditorGUI.BeginDisabledGroup( true ); - GUI.Toggle( btnRect, true, "Real-time node rendering" ); - EditorGUI.EndDisabledGroup(); - } else { - EditorGUI.BeginChangeCheck(); - SF_Settings.realtimeNodePreviews = GUI.Toggle( btnRect, SF_Settings.realtimeNodePreviews, "Real-time node rendering" ); - if( EditorGUI.EndChangeCheck() ) { - RegenerateNodeBaseData(); - } - } - - btnRect = btnRect.MovedDown(); - SF_Settings.quickPickScrollWheel = GUI.Toggle( btnRect, SF_Settings.quickPickScrollWheel, "Use scroll in the quickpicker" ); - btnRect = btnRect.MovedDown(); - SF_Settings.showVariableSettings = GUI.Toggle( btnRect, SF_Settings.showVariableSettings, "Show variable name & precision" ); - btnRect = btnRect.MovedDown(); - SF_Settings.showNodeSidebar = GUI.Toggle( btnRect, SF_Settings.showNodeSidebar, "Show node browser panel" ); - btnRect = btnRect.MovedDown(); - if( SF_GUI.HoldingControl() ) { - EditorGUI.BeginDisabledGroup( true ); - GUI.Toggle( btnRect, !SF_Settings.hierarchalNodeMove, "Hierarchal Node Move" ); - EditorGUI.EndDisabledGroup(); - } else { - SF_Settings.hierarchalNodeMove = GUI.Toggle( btnRect, SF_Settings.hierarchalNodeMove, "Hierarchal Node Move" ); - } - - btnRect.y += 4; - } - - - - - //GUI.Box( new Rect(203,10,128,19), SF_Tools.versionStage+" "+SF_Tools.version, versionStyle ); - previewButtonHeightOffset = (int)btnRect.yMax + 24; - int previewOffset = preview.OnGUI( (int)btnRect.yMax, (int)r.width ); - int statusBoxOffset = statusBox.OnGUI( previewOffset, (int)r.width ); - - - ps.OnLocalGUI(statusBoxOffset, (int)r.width ); - if( SF_Debug.nodes ) { - GUILayout.Label( "Node count: " + nodes.Count ); - } - - } - - void RegenerateNodeBaseData() { - for( int i = 0; i < nodes.Count; i++ ) { - nodes[i].GenerateBaseData(); - } - } - - int previewButtonHeightOffset; - - public void OnPressBackToMenuButton(){ - shaderEvaluator.SaveShaderAsset(); - Close(); - Init(); - } - - - public void OnPressSettingsButton(){ - - } - - - - - - - - public void OnShaderEvaluated() { - // statusBox.UpdateInstructionCount( preview.InternalMaterial.shader ); - } - - - - public void CheckForBrokenConnections() { - foreach( SF_Node node in nodes ) - node.CheckForBrokenConnections(); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Editor.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Editor.cs.meta deleted file mode 100755 index 16805ea1..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Editor.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 74496bb1dec304ba59a268d77032e300 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeBrowser.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeBrowser.cs deleted file mode 100755 index 7e263f83..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeBrowser.cs +++ /dev/null @@ -1,411 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; - -namespace ShaderForge { - - [System.Serializable] - public class SF_EditorNodeBrowser : ScriptableObject { - - - [SerializeField] - public SF_Editor editor; - [SerializeField] - public Vector2 scrollPos; - - [SerializeField] - GUIStyle styleToolbar; - [SerializeField] - GUIStyle styleSearchField; - [SerializeField] - GUIStyle styleSearchCancel; - [SerializeField] - GUIStyle styleCategory; - [SerializeField] - GUIStyle styleButton; - - [SerializeField] - bool showFiltered = false; - //[SerializeField] SerializableDictionary> unfiltered; - //[SerializeField] SerializableDictionary> filtered; - [SerializeField] - List unfiltered; - [SerializeField] - List filtered; - - bool initializedStyles = false; - - [SerializeField] - SF_EditorNodeData dragNode = null; - - [SerializeField] - public string searchString = ""; - - - public SF_EditorNodeBrowser() { - initializedStyles = false; - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - - - - public SF_EditorNodeBrowser Initialize( SF_Editor editor ) { - this.editor = editor; - unfiltered = editor.nodeTemplates; - filtered = new List(); - dragNode = null; - return this; - } - - - public void CheckInitializeStyles() { - if( initializedStyles && styleCategory.fixedHeight == 24 && styleButton.fixedHeight == 24 ) - return; - InitializeStyles(); - } - - private void InitializeStyles() { - styleToolbar = new GUIStyle( GUI.skin.FindStyle( "Toolbar" ) ); - styleSearchField = new GUIStyle( GUI.skin.FindStyle( "ToolbarSeachTextField" ) ); - styleSearchCancel = new GUIStyle( GUI.skin.FindStyle( "ToolbarSeachCancelButton" ) ); - styleCategory = new GUIStyle( EditorStyles.toolbarButton ); - styleCategory.alignment = TextAnchor.MiddleLeft; - styleCategory.fixedHeight = 24; - styleCategory.fontStyle = FontStyle.Bold; - styleCategory.fontSize = 9; - styleCategory.margin.top = 0; - styleCategory.margin.bottom = 0; - - styleButton = new GUIStyle( GUI.skin.textField ); - styleButton.alignment = TextAnchor.MiddleLeft; - styleButton.normal.textColor = SF_GUI.ProSkin ? new Color( 0.8f, 0.8f, 0.8f ) : new Color( 0.2f, 0.2f, 0.2f ); - styleButton.fontSize = 10; - styleButton.fixedHeight = 24; - styleButton.fontSize = 10; - styleButton.margin.top = 0; - styleButton.margin.bottom = 0; - - initializedStyles = true; - } - - - - [SerializeField] - string prevString; - - [SerializeField] - string prevCategory; - - [SerializeField] - float innerHeight = 256; - - const string searchBoxName = "sf_search_box"; - - public void OnLocalGUI( Rect rect ) { - - if( IsPlacing() && Event.current.type == EventType.mouseUp && Event.current.button == 1 ) { - CancelDrag(); - Event.current.Use(); - } - - CheckInitializeStyles(); - //EditorGUIUtility.LookLikeInspector(); - - if( styleCategory.alignment != TextAnchor.MiddleLeft ) - InitializeStyles(); - - - Rect toolbarRect = new Rect( rect ); - toolbarRect.height = 19; - - - Rect searchRect = new Rect( toolbarRect ); - searchRect.width -= 19; - searchRect.y += 1; - - Rect searchCancelRect = new Rect( searchRect ); - searchCancelRect.x += searchCancelRect.width; - searchCancelRect.width = 19; - - // Command/ctrl + F // TODO - /* - if( SF_GUI.HoldingControl() && - Event.current.keyCode == KeyCode.F && - Event.current.type == EventType.keyDown && - GUI.GetNameOfFocusedControl() != searchBoxName){ - - Event.current.character = (char)0; // We're done using F now - Event.current.Use(); - GUI.FocusControl(searchBoxName); // Focus search field - Event.current.character = (char)0; // Stop! No more characters! Please! - } - */ - - - // Draw Toolbar - GUI.Box( toolbarRect, "", styleToolbar ); - - prevString = searchString.Trim(); - GUI.SetNextControlName( searchBoxName ); - searchString = EditorGUI.TextField( searchRect, searchString, styleSearchField ); - if( GUI.Button(searchCancelRect, "", styleSearchCancel ) ) { - searchString = ""; - GUI.FocusControl( null ); - } - if( searchString.Trim() != prevString ) - OnSearchStringChanged(); - - - - - - // Scroll view stuff - Rect panelRect = new Rect( rect ); - panelRect.yMin += toolbarRect.height - 1; - panelRect.height -= toolbarRect.height; - - Rect scrollRect = new Rect( panelRect ); - scrollRect.y = scrollPos.y; - - - - // Calc insides height - //Debug.Log(panelRect.height); - scrollRect.height = Mathf.Max( panelRect.height, innerHeight ); - scrollRect.width -= 15; - - Rect btnRect = new Rect( panelRect.x, panelRect.y - toolbarRect.height, rect.width - 16, styleCategory.fixedHeight ); - innerHeight = 0; - float innerStartY = 0f; - - scrollPos = GUI.BeginScrollView( panelRect, scrollPos, scrollRect, false, true /*GUILayout.Width( rect.wi )*/ ); - { - if(Event.current.type == EventType.layout) - innerStartY = btnRect.y; - if( GetNodeList().Count > 0 ) { - foreach( SF_EditorNodeData entry in GetNodeList() ) { - - if( entry.category != prevCategory ) { - DrawCategory(entry.category, ref btnRect ); - prevCategory = entry.category; - } - - DrawButton( entry, ref btnRect ); - } - } else { - GUI.color = Color.gray; - GUI.Label(btnRect, "No nodes matched" ); - GUI.color = Color.white; - } - - if(Event.current.type == EventType.layout){ - innerHeight = btnRect.yMax - innerStartY; - //Debug.Log ("Inner: " + innerHeight + ", Panel: " + panelRect.height); - } - - } - GUI.EndScrollView(); - - - - - UpdateDrag(); - - } - - public void DrawCategory( string label, ref Rect btnRect ) { - GUI.Label( btnRect, label + ":", styleCategory ); - btnRect.y += btnRect.height; - } - - public void DrawButton( SF_EditorNodeData entry, ref Rect btnRect ) { - GUI.color = entry.isProperty ? SF_Node.colorExposed : Color.white; - - bool usable = !(!entry.availableInDeferredPrePass && editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred); - - if(!usable){ - //GUI.color = Color.red; - GUI.enabled = false; - } - - bool mouseOver = btnRect.Contains(Event.current.mousePosition); - - - if(usable){ - if( dragNode == entry ) - GUI.color = SF_GUI.selectionColorBright; - else if( mouseOver && dragNode == null ) - GUI.color = SF_GUI.selectionColorBrighter; - } - - - GUI.Label( btnRect, (usable ? string.Empty : " ") + entry.nodeName, styleButton ); - - - if( mouseOver && Event.current.type == EventType.mouseDown && Event.current.button == 0 && usable) { - OnStartDrag( entry ); - } else if( Event.current.type == EventType.ContextClick ) { - Vector2 mousePos = Event.current.mousePosition; - if( btnRect.Contains( mousePos ) ) { - // Now create the menu, add items and show it - GenericMenu menu = new GenericMenu(); - editor.ResetRunningOutdatedTimer(); - //menu.AddItem( new GUIContent("Edit Comment"), false, ContextClick, "cmt_edit" ); - menu.AddItem( new GUIContent("What does " + entry.nodeName + " do?"), false, ContextClick, entry ); - menu.ShowAsContext(); - Event.current.Use(); - } - } - - - - GUI.color = Color.white; - if( entry.isNew || entry.isUnstable) { - GUIStyle miniStyle = new GUIStyle( EditorStyles.miniBoldLabel ); - miniStyle.alignment = TextAnchor.UpperRight; - miniStyle.normal.textColor = Color.red; - GUI.Label( btnRect, entry.isNew ? "New" : "Unstable", miniStyle ); - } - - if(usable){ - SF_GUI.AssignCursor( btnRect, MouseCursor.Pan ); - } else { - if(Event.current.type == EventType.repaint){ - GUI.enabled = true; - SF_GUI.DrawLock(btnRect.PadTop(4),"Forward rendering only", TextAlignment.Right); - //Draw(btnRect.PadTop(4), false, true, true, false); // Draw lock - GUI.enabled = false; - } - } - GUI.enabled = true; - btnRect.y += btnRect.height; - } - - public void ContextClick( object o ) { - SF_EditorNodeData entry = o as SF_EditorNodeData; - SF_Web.OpenDocumentationForNode(entry); - } - - - - public void OnStartDrag( SF_EditorNodeData nodeData ) { - //if( IsPlacing() ) - // return; - //Debug.Log( "DRAG BUTTON: " + nodeData.name ); - dragNode = nodeData; - } - - public SF_Node OnStopDrag() { - if( !IsPlacing() ) - return null; - SF_Node newNode = null; - if(editor.nodeView.rect.Contains(Event.current.mousePosition)) - newNode = editor.AddNode( dragNode, registerUndo:true ); - dragNode = null; - return newNode; - } - - public void UpdateDrag() { - if( !IsPlacing() ) - return; - - editor.Repaint(); - - //Debug.Log( "Drag exists: " + ( dragNode != null ) + "\nDrag name: " + dragNode.name + "\nDrag type: " + dragNode.type.ToString() ); - - //float preScale = (float)(editor.separatorRight.rect.x - Event.current.mousePosition.x); - //preScale /= 48f; // Distance to animate in - //preScale = Mathf.Clamp01(preScale); - - //Rect boxRect = new Rect( 0, 0, SF_Node.NODE_SIZE, SF_Node.NODE_SIZE ).ScaleSizeBy(preScale).ClampSize((int)styleCategory.fixedHeight,SF_Node.NODE_SIZE); - Rect boxRect = new Rect( 0, 0, SF_Node.NODE_SIZE, SF_Node.NODE_SIZE ); - boxRect.center = Event.current.mousePosition; - - GUI.Box( boxRect, dragNode.nodeName ); - // Debug.Log( Event.current.type.ToString()); - if( Event.current.rawType == EventType.mouseUp ) - OnStopDrag(); - - - } - - public void CancelDrag() { - dragNode = null; - } - - public bool IsPlacing() { - if( dragNode == null ) - return false; - if( string.IsNullOrEmpty( dragNode.nodeName ) ) { - dragNode = null; - return false; - } - return true; - } - - - public bool DragButton( Rect r, string label, GUIStyle style ) { - bool clicked = ( Event.current.type == EventType.mouseDown && Event.current.button == 0 ); - GUI.Button( r, label, style ); - bool hover = r.Contains( Event.current.mousePosition ); - return ( hover && clicked ); - } - - - - public List GetNodeList() { - return showFiltered ? filtered : unfiltered; - } - - - public void OnSearchStringChanged() { - if( string.IsNullOrEmpty( searchString ) ) { - OnSearchStringCleared(); - return; - } - showFiltered = true; - - RefreshFilter(); - - } - - public void OnSearchStringCleared() { - showFiltered = false; - } - - - - public void RefreshFilter() { - filtered.Clear(); - - /*foreach( KeyValuePair> entry in unfiltered ) { - if( Match(entry.Key.name, searchString) ) { - filtered.Add(entry.Key,entry.Value); - } - }*/ - - foreach( SF_EditorNodeData entry in unfiltered ) { - if( Match( entry.nodeName, searchString ) ) { - filtered.Add( entry ); - } - } - - } - - private bool Match( string a, string b ) { - return Clean( a ).Contains( Clean( b ) ); - } - - private string Clean( string s ) { - return s.Trim().Replace( " ", string.Empty ).ToLower(); - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeBrowser.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeBrowser.cs.meta deleted file mode 100755 index a8dd3895..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeBrowser.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8317eafd51c2b41ee9f29c20218164f3 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeData.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeData.cs deleted file mode 100755 index 852eb163..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeData.cs +++ /dev/null @@ -1,354 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SF_EditorNodeData : ScriptableObject { - - [SerializeField] - KeyCode key; - [SerializeField] - public bool holding = false; - [SerializeField] - public string nodeName; - [SerializeField] - private string nodeNameSearch; - - public string SearchName{ - get{ - if(string.IsNullOrEmpty(nodeNameSearch)){ - return nodeName; - } else { - return nodeNameSearch; - } - } - set{ - nodeNameSearch = value; - } - } - - [SerializeField] - public string type; - [SerializeField] - public bool isNew = false; - [SerializeField] - public bool isUnstable = false; - [SerializeField] - public string fullPath; - [SerializeField] - public string category; - [SerializeField] - public bool isProperty = false; - [SerializeField] - public bool availableInDeferredPrePass = true; - - - - public SF_EditorNodeData() { - - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - public SF_EditorNodeData Initialize( string type, string fullPath, KeyCode key = KeyCode.None ) { - holding = false; - this.type = type; - ParseCategoryAndName( fullPath ); - this.key = key; - - if( type.Contains( "SFN_Color" ) || - type.Contains( "SFN_Cubemap" ) || - type.Contains( "SFN_Slider" ) || - type.Contains( "SFN_Tex2d" ) || - type.Contains( "SFN_Tex2dAsset" ) || - type.Contains( "SFN_Vector4Property" ) || - type.Contains( "SFN_ValueProperty" ) || - type.Contains( "SFN_ToggleProperty" ) || - type.Contains( "SFN_SwitchProperty" ) || - type.Contains( "SFN_Matrix4x4Property" ) - ) - isProperty = true; - - return this; - } - - public void ParseCategoryAndName(string fullPath) { - - this.fullPath = fullPath; - - string[] split = fullPath.Split( '/' ); - if( split.Length > 1 ) { - this.category = split[0]; - this.nodeName = split[1]; - } else { - this.nodeName = fullPath; - } - - } - - - public SF_Node CreateInstance() { - - Type fType = Type.GetType( type ); - - // Might be dynamic... - if( fType == null ) { - if(SF_Debug.dynamicNodeLoad) - Debug.Log( "CreateInstance couldn't use GetType, attempting dynamic load..." ); - fType = SF_Editor.GetNodeType( type ); - if( SF_Debug.dynamicNodeLoad && fType == null ) - Debug.Log( "Failed to load dynamic load fType is null" ); - } - - - SF_Node node = (SF_Node)ScriptableObject.CreateInstance( fType ); - node.Initialize(); - return node; - } - - public SF_EditorNodeData MarkAsNewNode() { - isNew = true; - return this; - } - - public SF_EditorNodeData MarkAsUnstableNode() { - isUnstable = true; - return this; - } - - public SF_EditorNodeData UavailableInDeferredPrePass(){ - availableInDeferredPrePass = false; - return this; - } - - public float smoothHotkeySelectorIndex = 0f; - public int defaultHotkeySelectorIndex = 0; - public int hotkeySelectorIndex = 0; - [SerializeField] - private List hotkeyFriends; - public List HotkeyFriends{ - get{ - if(hotkeyFriends == null){ - hotkeyFriends = new List(); - } - - if(hotkeyFriends.Count == 0){ - int i=0; - foreach( SF_EditorNodeData node in SF_Editor.instance.nodeTemplates){ - if(node == this) - smoothHotkeySelectorIndex = hotkeySelectorIndex = defaultHotkeySelectorIndex = i; - if(node.key == key || KeyCodeToChar(key) == char.ToUpper(node.nodeName[0])){ - hotkeyFriends.Add(node); - i++; - } - - } - } - return hotkeyFriends; - } - } - - - public char KeyCodeToChar(KeyCode kc){ - string s = kc.ToString(); - if(s.StartsWith("Alpha")) // Numbers 0 to 9 are called "Alpha5" etc. Extract just the numeral as the returned character - return s[5]; - return s[0]; - } - - [SerializeField] - private static GUIStyle popupButtonStyle; - public static GUIStyle PopupButtonStyle{ - get{ - if(popupButtonStyle == null){ - popupButtonStyle = new GUIStyle(SF_Styles.NodeStyle); - popupButtonStyle.alignment = TextAnchor.UpperLeft; - RectOffset ro = popupButtonStyle.padding; - ro.left = 4; - popupButtonStyle.padding = ro; - } - return popupButtonStyle; - } - } - - public Vector2 quickpickerStartPosition = Vector2.zero; - - public SF_EditorNodeData CheckHotkeyInput(bool mouseOverSomeNode) { - - bool mouseInNodeView = SF_Editor.instance.nodeView.MouseInsideNodeView(false); - - - if(Event.current.type == EventType.repaint){ - smoothHotkeySelectorIndex = Mathf.Lerp(smoothHotkeySelectorIndex, hotkeySelectorIndex, 0.5f); - } - - bool useScroll = SF_Settings.quickPickScrollWheel; - - if(holding && Event.current.type == EventType.scrollWheel && HotkeyFriends.Count > 0 && mouseInNodeView){ - - if(useScroll){ - hotkeySelectorIndex += (int)Mathf.Sign(Event.current.delta.y); - hotkeySelectorIndex = Mathf.Clamp(hotkeySelectorIndex, 0, HotkeyFriends.Count-1); - } - - - // hotkeySelectorIndex = ( hotkeySelectorIndex + HotkeyFriends.Count ) % HotkeyFriends.Count; // Wrap - Event.current.Use(); - } - - if( key == KeyCode.None ) - return null; - - if( Event.current.keyCode == key ) { - if( Event.current.type == EventType.keyDown && !SF_GUI.HoldingControl() && holding == false && mouseInNodeView ){ - - hotkeySelectorIndex = defaultHotkeySelectorIndex; - smoothHotkeySelectorIndex = defaultHotkeySelectorIndex; - - quickpickerStartPosition = Event.current.mousePosition; - - holding = true; - } - if( Event.current.rawType == EventType.keyUp ){ - holding = false; - } - } - - - - if(holding && !mouseOverSomeNode){ - - - - - float width = 166f; // nodeName.Length*8 + 10; - Rect dispPos = new Rect(0, 0, width, 36); - - Vector2 centerPos = useScroll ? Event.current.mousePosition : quickpickerStartPosition; - - dispPos.center = centerPos; - dispPos.y -= dispPos.height*0.3333f; - - // - //GUI.Box(dispPos, nodeName, GUI.skin.button); - // - - - - // Draw hotkey node picker - //if(Event.current.type == EventType.keyDown){ - //Debug.Log(Event.current.keyCode); - Rect nRect = dispPos; //new Rect(0,0,128,32); - nRect.center = centerPos - Vector2.up*nRect.height*0.3333f; - //nRect = nRect.MovedRight(); - if(useScroll) - nRect.y -= nRect.height * smoothHotkeySelectorIndex; - else - nRect.y -= nRect.height * defaultHotkeySelectorIndex; - //if(Event.current.keyCode != KeyCode.None){ - - Color prevCol = GUI.color; - - - - int i = 0; - foreach( SF_EditorNodeData node in HotkeyFriends){ - //float dist = Mathf.Abs(smoothHotkeySelectorIndex - i); - //float alpha = Mathf.Clamp(1f-Mathf.Clamp01(dist*0.25f), 0.2f, 0.8f); - - - float offset = 0f;//(dist*dist)/3f; - - - - - //if(i == hotkeySelectorIndex){ - //alpha = 1; - //offset -= 8f; - //GUI.Box(nRect, node.nodeName, PopupButtonStyle); - //} - Rect newNRect = nRect; - newNRect.x += offset; - - - if(!useScroll && newNRect.Contains(Event.current.mousePosition)){ - hotkeySelectorIndex = i; - } - - bool selected = (i == hotkeySelectorIndex); - - if( selected ) - GUI.color = new Color(1f,1f,1f,1f); - else - GUI.color = new Color(0.6f,0.6f,0.6f,0.5f); - - if(node.isProperty){ - GUI.color *= SF_Node.colorExposed; - } - - - Texture2D icon = SF_Resources.LoadNodeIcon( node.type.Split('.')[1].ToLower() ); - - if(icon != null){ - newNRect.width -= newNRect.height; - } - - //if(useScroll){ - GUI.Box(newNRect, node.nodeName, PopupButtonStyle); - //} else { - //if(GUI.Button(newNRect, node.nodeName, PopupButtonStyle)){ - //hotkeySelectorIndex = i; - //} - //} - - - - - if(icon != null){ - Rect iconRect = newNRect; - iconRect = iconRect.MovedRight(); - iconRect.width = iconRect.height; - GUI.color = selected ? Color.white : new Color(1f,1f,1f,0.4f); - GUI.DrawTexture(iconRect, icon); - - } - - - - - nRect = nRect.MovedDown(); - - i++; - } - GUI.color = prevCol; - - - - //} - if(Event.current.type == EventType.keyDown/* && Event.current.type == EventType.layout*/ /*&& GUI.GetNameOfFocusedControl() == "defocus"*/){ - Event.current.Use(); - } - //} - - //} - - //GUI.Label(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 256,32),"currentindex = " + hotkeySelectorIndex); - } - - - - - bool clicked = Event.current.type == EventType.mouseDown; - if(holding && clicked){ - return HotkeyFriends[hotkeySelectorIndex]; - } else { - return null; - } - } - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeData.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeData.cs.meta deleted file mode 100755 index 31f08f62..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeData.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 89068dde132014929a5aa4e450ff685b -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeView.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeView.cs deleted file mode 100755 index e744c5de..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeView.cs +++ /dev/null @@ -1,953 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; -using System.Xml; -using System.IO; -using System.Linq; - -namespace ShaderForge { - - public enum ConnectionLineStyle { Bezier, Linear, Rectilinear }; - - [System.Serializable] - public class SF_SetNodeSource { - - public SF_NodeConnector con; - - public SF_SetNodeSource( SF_Node node ) { - con = node.connectors[0]; - } - - public int NodeID { - get { return con.node.id; } - } - - public string Name { - get { return con.node.variableName; } - } - - } - - [System.Serializable] - public class SF_EditorNodeView : ScriptableObject { - - SF_Editor editor; - - const int TOOLBAR_HEIGHT = 18; - [SerializeField] - public Vector2 cameraPos = Vector3.zero; - - [SerializeField] - bool panCamera = false; - - [SerializeField] - Vector2 mousePosStart; - public Rect rect; - public GUIStyle toolbarStyle; - - public List relayInSources; - public string[] relayInNames; - - public SF_SelectionManager selection; - - public SF_NodeTreeStatus treeStatus; - - - - - - public SF_EditorNodeView() { - - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - - public void RefreshRelaySources() { - relayInSources = new List(); - for( int i = 0; i < editor.nodes.Count; i++ ) { - if( editor.nodes[i] is SFN_Set ) { - relayInSources.Add( new SF_SetNodeSource(editor.nodes[i]) ); - } - } - relayInSources.Sort( ( a, b ) => a.Name.CompareTo( b.Name ) ); - relayInNames = relayInSources.Select( x => x.Name ).ToArray(); - } - - // Only the node ID is serialized - this is used to ensure proper display in the GUI - // Returns -1 if the relay ID is missing - public int NodeIdToRelayId(int nodeId) { - if( relayInSources != null ) { - for( int i = 0; i < relayInSources.Count; i++ ) { - if( relayInSources[i].NodeID == nodeId ) { - return i; - } - } - } - return -1; - } - - public SF_EditorNodeView Initialize( SF_Editor editor ) { - this.editor = editor; - selection = ScriptableObject.CreateInstance().Initialize( editor ); - treeStatus = ScriptableObject.CreateInstance().Initialize(editor); - rect = new Rect(); - cameraPos = new Vector2( 32768 - 400, 32768 - 300 ); - toolbarStyle = new GUIStyle( EditorStyles.toolbar ); - toolbarStyle.fixedHeight = TOOLBAR_HEIGHT; - return this; - } - - - // Erasing nodes with cut line: (alt+RMB) - - public Vector2 cutStart = Vector3.zero; - public bool isCutting = false; - - public void StartCutting(){ - isCutting = true; - cutStart = editor.nodeView.GetNodeSpaceMousePos(); - } - - public void StopCutting(){ - List disconnectors = new List(); - for (int i = 0; i < editor.nodes.Count; i++) { - SF_Node n = editor.nodes [i]; - for (int j = 0; j < n.connectors.Length; j++) { - SF_NodeConnector con = n.connectors [j]; - if (con.IsConnected () && con.conType == ConType.cInput) { - if (con.conLine.aboutToBeDeleted) { - disconnectors.Add(con); - } - } - } - } - - if(disconnectors.Count == 0){ - isCutting = false; - return; - } - - UnmarkDeleteHighlights(); - - //Undo.RecordObject((Object)con, "cut" - string undoMsg = "cut "; - if(disconnectors.Count > 1){ - undoMsg += disconnectors.Count + " "; - undoMsg += "connections"; - } else { - undoMsg += "connection: "; - undoMsg += disconnectors[0].node.nodeName; - undoMsg += "[" + disconnectors[0].label + "]"; - undoMsg += " <--- "; - undoMsg += "[" + disconnectors[0].inputCon.label + "]"; - undoMsg += disconnectors[0].inputCon.node.nodeName; - } // = disconnectors.Count > 1 ? "cut "+disconnectors.Count+" connections" : "cut connection " + disconnectors[i].node.name + "[" + - - foreach(SF_NodeConnector con in disconnectors){ - Undo.RecordObject(con, undoMsg); - } - - foreach(SF_NodeConnector con in disconnectors){ - con.Disconnect(); - } - - isCutting = false; - - } - - public void UnmarkDeleteHighlights(){ - foreach(SF_Node n in editor.nodes){ - foreach(SF_NodeConnector con in n.connectors){ - if(con.IsConnected() && con.conType == ConType.cInput){ - con.conLine.aboutToBeDeleted = false; - } - } - } - } - - - public float zoom = 1f; - public float zoomTarget = 1f; - - public void SetZoom(float setZoom){ - Vector2 oldWidth = new Vector2(rect.width,rect.height)/zoom; - zoom = ClampZoom(setZoom); - Vector2 newWidth = new Vector2(rect.width,rect.height)/zoom; - Vector2 delta = newWidth - oldWidth; - - Vector2 normalizedMouseCoords = (Event.current.mousePosition - new Vector2(editor.separatorLeft.rect.xMax,editor.TabOffset)); - - normalizedMouseCoords.x /= rect.width; - normalizedMouseCoords.y /= rect.height; - - - - cameraPos -= Vector2.Scale(delta, normalizedMouseCoords); - - if(delta.sqrMagnitude != 0f){ - - - // Correct in here to prevent going outside the bounds - BoundsAdjustCamera(); - } - - - if(zoom == 1f) - SnapCamera(); - - } - - - - public void BoundsAdjustCamera(){ - /* - Rect wrapped = GetNodeEncapsulationRect().Margin(256); - Rect view = ScreenSpaceToZoomSpace(rect); - - Vector2 toCenter = (view.center - wrapped.center)*0.5f; - - float camBottom = cameraPos.y + rect.height/zoom - 22; - float camTop = cameraPos.y; - float camRight = cameraPos.x + rect.width/zoom - editor.separatorLeft.rect.xMax; - float camLeft = cameraPos.x - editor.separatorLeft.rect.xMax; - - Vector2 deltaTotal = Vector2.zero; - - if( camBottom > wrapped.yMax) - deltaTotal -= new Vector2(0f,camBottom-wrapped.yMax); - if(camTop < wrapped.yMin){ - deltaTotal -= new Vector2(0f,camTop-wrapped.yMin); - } - if(camRight > wrapped.xMax) - deltaTotal -= new Vector2(camRight-wrapped.xMax,0f); - if(camLeft < wrapped.xMin) - deltaTotal -= new Vector2(camLeft-wrapped.xMin,0f); - - cameraPos += deltaTotal; - -*/ - - } - - - public float ClampZoom(float in_zoom){ - return Mathf.Clamp(in_zoom,0.125f,1f); - } - - - public void OnLocalGUI( Rect r ) { - - - //r = r.PadTop(Mathf.CeilToInt(22*zoom)); - - - - - - editor.mousePosition = Event.current.mousePosition; - rect = r; - - - - // TOOLBAR - //DrawToolbar( new Rect( rect.x, rect.y, rect.width, TOOLBAR_HEIGHT ) ); - - - - Rect localRect = new Rect( r ); - localRect.x = 0; - localRect.y = 0; - - //rect.y += TOOLBAR_HEIGHT; - //rect.height -= TOOLBAR_HEIGHT; - - - - - // VIEW - Rect rectInner = new Rect( rect ); - rectInner.width = float.MaxValue / 2f; - rectInner.height = float.MaxValue / 2f; - - - // TEMP: -// Rect btn = rectInner; -// btn.width = 64; -// btn.height = 24; -// if(SF_Debug.renderDataNodes){ -// if(selection.Selection.Count > 0){ -// if(GUI.Button(btn,"NSS")){ -// editor.TakeNodePreviewScreenshot(); -// } -// } -// } - - - - if(Event.current.type == EventType.repaint){ - nodeSpaceMousePos = ScreenSpaceToZoomSpace( Event.current.mousePosition ); - - } - - - - - - bool mouseOverNode = false; - - - - - SF_ZoomArea.Begin(zoom,rect,cameraPos); - { - selection.OnGUI(); // To detect if you press things - if(editor.nodeView != null) - editor.nodeView.selection.DrawBoxSelection(); - - if(Event.current.type == EventType.repaint){ - viewSpaceMousePos = ZoomSpaceToScreenSpace( Event.current.mousePosition ); - } - // NODES - if( editor.nodes != null ) { - - // If we're repainting, draw in reverse to sort properly - //if(Event.current.rawType == EventType.repaint){ - for (int i = editor.nodes.Count - 1; i >= 0; i--) { - if( !editor.nodes[i].Draw() ) - break; - } - /*} else { - for(int i=0;i 0 ) { - Object dragObj = DragAndDrop.objectReferences[0]; - if( dragObj is Texture2D || dragObj is ProceduralTexture || dragObj is RenderTexture ) { - DragAndDrop.visualMode = DragAndDropVisualMode.Link; - if( !editor.nodeBrowser.IsPlacing() ) - editor.nodeBrowser.OnStartDrag( editor.GetTemplate() ); - else - editor.nodeBrowser.UpdateDrag(); - } else if(dragObj is ProceduralMaterial){ - DragAndDrop.visualMode = DragAndDropVisualMode.Link; - } else { - DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; - } - } else { - DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; - } - } - - - - - - - // If release - if( MouseInsideNodeView( false ) && Event.current.type == EventType.mouseUp) { - bool ifCursorStayed = Vector2.SqrMagnitude( mousePosStart - Event.current.mousePosition ) < SF_Tools.stationaryCursorRadius; - - if( ifCursorStayed && !SF_GUI.MultiSelectModifierHeld() ) - selection.DeselectAll(registerUndo:true); - - - //editor.Defocus( deselectNodes: ifCursorStayed ); - } - - if( SF_GUI.ReleasedRawLMB() ) { - SF_NodeConnector.pendingConnectionSource = null; - } - - // If press - if( Event.current.type == EventType.mouseDown && MouseInsideNodeView( false ) ) { - //bool ifNotHoldingModifier = !SF_GUI.MultiSelectModifierHeld(); - mousePosStart = Event.current.mousePosition; - editor.Defocus(); - } - - - if(!editor.screenshotInProgress){ - - Rect logoRect = rect; - logoRect.y -= 14; - logoRect.x += 1; - logoRect.width = SF_GUI.Logo.width; - logoRect.height = SF_GUI.Logo.height; - GUI.color = new Color(1f,1f,1f,0.5f); - GUI.DrawTexture( logoRect, SF_GUI.Logo ); - - logoRect.y += logoRect.height; - logoRect.height = 16; - - GUI.Label(logoRect, "v"+SF_Tools.version, EditorStyles.boldLabel); - GUI.color = Color.white; - - - } - - - } - - - public void OnDroppedSubstance(ProceduralMaterial procMat){ - - Texture diffuse = TryGetProceduralTexture(procMat, "_MainTex"); - Texture normal = TryGetProceduralTexture(procMat, "_BumpMap"); - //Texture parallax = TryGetProceduralTexture(procMat, "_ParallaxMap"); - //Texture emission = TryGetProceduralTexture(procMat, "_Illum"); - //TryGetProceduralTexture("_MainTex"); - - SF_Node prevNode = TryLinkIfExistsAndOpenSlotAvailable(diffuse, "MainTex", editor.mainNode.diffuse, "RGB"); - TryLinkIfExistsAndOpenSlotAvailable(normal, "BumpMap", editor.mainNode.normal, "RGB", prevNode); - - - } - - // For connecting procedural materials to the main node - public SF_Node TryLinkIfExistsAndOpenSlotAvailable(Texture tex, string propertyName, SF_NodeConnector connector, string outChannel, SF_Node prevNode = null){ - - if(tex){ - SFN_Tex2d tNode = editor.AddNode(); - if(prevNode != null){ - Rect r = tNode.rect; - r = r.MovedDown(1); - r.y += 64; - tNode.rect = r; - } - tNode.TextureAsset = tex; - tNode.property.SetName(propertyName); - tNode.OnAssignedTexture(); - if(connector.enableState == EnableState.Enabled && connector.availableState == AvailableState.Available && !connector.IsConnected()){ - connector.LinkTo(tNode[outChannel]); - } - return tNode; - } - return null; - } - - public Texture TryGetProceduralTexture(ProceduralMaterial procMat, string propName){ - Texture returnTex = null; - try{ - if(procMat.HasProperty(propName)) - returnTex = procMat.GetTexture(propName); - } catch (UnityException e){ - e.Equals(e); - } - return returnTex; - } - - - - - public void UpdateCutLine(){ - - if(SF_GUI.HoldingAlt() && Event.current.type == EventType.mouseDown && Event.current.button == 1){ // Alt + RMB drag - StartCutting(); - } else if(SF_GUI.ReleasedRawRMB()){ - StopCutting(); - } - - if(isCutting){ - Vector2 cutEnd = GetNodeSpaceMousePos(); - - GUILines.DrawDashedLine(editor, cutStart, cutEnd, Color.white, 5f); - - - foreach(SF_Node n in editor.nodes){ - foreach(SF_NodeConnector con in n.connectors){ - if(con.IsConnected() && con.conType == ConType.cInput && con.enableState != EnableState.Hidden){ - Vector2 intersection = Vector2.zero; - if(con.conLine.Intersects(cutStart, cutEnd, out intersection)){ - - con.conLine.aboutToBeDeleted = true; - - Vector2 hit = editor.nodeView.ScreenSpaceToZoomSpace(intersection); - - float scale = 5f; - float scaleDiff = 0.95f; - //Vector2 rg, up, lf, dn; - - - //Vector2 localRight = (cutStart-cutEnd).normalized; - //Vector2 localUp = new Vector2(localRight.y,-localRight.x); - - //rg = hit + localRight * scale; - //up = hit + localUp * scale; - //lf = hit - localRight * scale; - //dn = hit - localUp * scale; - Color c0 = new Color(1f,0.1f,0.1f,0.9f); - Color c1 = new Color(1f,0.1f,0.1f,0.7f); - Color c2 = new Color(1f,0.1f,0.1f,0.5f); - Color c3 = new Color(1f,0.1f,0.1f,0.3f); - - GUILines.DrawDisc(hit,scale,c0); - GUILines.DrawDisc(hit,scale-scaleDiff,c1); - GUILines.DrawDisc(hit,scale-scaleDiff*2,c2); - GUILines.DrawDisc(hit,scale-scaleDiff*3,c3); - - //GUILines.DrawLine(rg,up,Color.red,2f,true); - //GUILines.DrawLine(up,lf,Color.red,2f,true); - //GUILines.DrawLine(lf,dn,Color.red,2f,true); - //GUILines.DrawLine(dn,rg,Color.red,2f,true); - - - - - - continue; - } else { - con.conLine.aboutToBeDeleted = false; - } - } - } - } - - - } - - } - - - - public Rect GetNodeEncapsulationRect(){ - - Rect r = editor.nodes[0].rect; // No need for null check, there should always be a main node - foreach( SF_Node n in editor.nodes ) { - r = SF_Tools.Encapsulate( r, n.rect ); - } - return r; - - } - - public void CenterCamera() { - - // Find midpoint of all nodes - Rect r = GetNodeEncapsulationRect(); - - // Move Camera - cameraPos = r.center - new Vector2( 0f, Screen.height * 0.5f ); - SnapCamera(); - } - - - - - public void ContextClick( object o ) { - // Add node - SF_EditorNodeData nodeData = o as SF_EditorNodeData; - editor.AddNode( nodeData, true ); - } - - - - public void UpdateDebugInput() { - - if( Event.current.type != EventType.keyDown ) - return; - - if( Event.current.keyCode == KeyCode.UpArrow ) { - HierarchalRefresh(); - } - - - if( Event.current.keyCode == KeyCode.DownArrow ) { - Debug.Log( GetNodeDataSerialized() ); - } - - - } - - - public void AssignDepthValuesToNodes() { - foreach( SF_Node n in editor.nodes ) { - n.depth = 0; - } - // Recurse some depth! - // TODO: Run this for disconnected islands of nodes too - //Debug.Log("SFN_FINAL exists = " + (editor.materialOutput != null)); - AddDepthToChildrenOf( editor.mainNode, 0 ); - } - - void AddDepthToChildrenOf( SF_Node n, int carry ) { - carry++; - n.depth = Mathf.Max( carry, n.depth ); ; - for( int i = 0; i < n.connectors.Length; i++ ) { - if( n.connectors[i].conType == ConType.cOutput ) // Ignore outputs, we came from here! - continue; - if( !n.connectors[i].IsConnected() ) // Ignore unconnected inputs - continue; - AddDepthToChildrenOf( n.connectors[i].inputCon.node, carry ); - } - } - - public void HierarchalRefresh() { - -// AssignDepthValuesToNodes(); -// -// int maxDepth = 0; // Deepest level -// foreach( SF_Node n in editor.nodes ) { -// if( maxDepth < n.depth ) -// maxDepth = n.depth; -// } -// -// -// // Relink everything -// int depth = maxDepth; -// while( depth > 0 ) { -// for(int i=0; i 0 ) { - foreach( SF_Node n in editor.nodes ) { - if( n.depth == depth ) { - //n.RefreshValue(); - //n.OnUpdateNode( NodeUpdateType.Soft ); - } - - } - depth--; - } - * */ - - } - - - public void ReconnectConnectedPending() { - AssignDepthValuesToNodes(); - - int maxDepth = 0; // Deepest level - foreach( SF_Node n in editor.nodes ) { - if( maxDepth < n.depth ) - maxDepth = n.depth; - } - - - int depth = maxDepth; - while( depth > 0 ) { - //foreach( SF_Node n in editor.nodes ) { - for( int i = 0; i < editor.nodes.Count; i++ ) { - SF_Node n = editor.nodes[i]; - if( n.depth == depth ) { - foreach( SF_NodeConnector con in n.connectors ) { - if( con.conType == ConType.cOutput ) - continue; - if( !con.IsConnectedAndEnabled() ) - continue; - if( con.valueType != ValueType.VTvPending ) - continue; - con.inputCon.LinkTo( con, LinkingMethod.Default ); - } - } - } - depth--; - } - } - - - - - public string GetNodeDataSerialized() { - - // TODO; move parts of this to their respective places - - string header = ""; - header += "// Shader created with " + SF_Tools.versionString + " \n"; - header += "// Shader Forge (c) Freya Holmer - http://www.acegikmo.com/shaderforge/\n"; - header += "// Note: Manually altering this data may prevent you from opening it in Shader Forge\n"; - header += "/" + "*"; // Hurgh! - - string sData = ""; - sData += "SF_DATA;"; // TODO: Multi-pass, shader settings etc - sData += "ver:" + SF_Tools.version + ";"; - sData += "sub:START;"; - sData += "pass:START;"; - sData += editor.ps.Serialize() + ";"; - - foreach( SF_Node node in editor.nodes ) - sData += node.Serialize(false,useSuffixPrefix:true); - - if(editor.nodeView.treeStatus.propertyList.Count > 0) - sData += editor.nodeView.treeStatus.SerializeProps() + ";"; - - string footer = "pass:END;sub:END;"; - footer += "*" + "/"; - return ( header + sData + footer ); - } - - public float lastChangeTime; - - float GetTime(){ - return (float)EditorApplication.timeSinceStartup; - } - - public float GetTimeSinceChanged(){ - return GetTime() - lastChangeTime; - } - - public void DrawRecompileTimer(Rect r){ - - if(!SF_Settings.autoCompile) - return; // Don't draw recompile timer when autoRecompile is unchecked - - float delta = GetTimeSinceChanged(); - - if(delta > 1.12f) - return; - - r.width *= Mathf.Clamp01(delta); - if(SF_GUI.ProSkin){ - GUI.Box(r,string.Empty); - GUI.Box(r,string.Empty); - GUI.Box(r,string.Empty); - } else { - GUI.color = new Color(1f,1f,1f,0.4f); - GUI.Box(r,string.Empty); - GUI.color = Color.white; - } - } - - void DrawToolbar( Rect r ) { - - } - - void UpdateCameraPanning() { - - - if( SF_GUI.ReleasedCameraMove() ) { - panCamera = false; - } - - bool insideNodeView = MouseInsideNodeView( true ); - bool dragging = ( Event.current.type == EventType.MouseDrag && panCamera ); - bool connecting = SF_NodeConnector.IsConnecting(); - bool rotatingPreview = editor.preview.isDraggingLMB; - bool placingNode = editor.nodeBrowser.IsPlacing(); - bool draggingSeparators = editor.DraggingAnySeparator(); - - - if(connecting){ - // Pan camera when cursor nears edges while making a connection - Vector2 mousePosInNodeViewScreenSpace = ZoomSpaceToScreenSpace(Event.current.mousePosition) - Vector2.right*editor.separatorLeft.rect.xMax; - - float areaWidth; - if(SF_Settings.showNodeSidebar) - areaWidth = editor.separatorRight.rect.xMin - editor.separatorLeft.rect.xMax; - else - areaWidth = Screen.width - editor.separatorLeft.rect.xMax; - float areaHeight = editor.nodeView.rect.height; - float dragPanMargin = 32f; - float panSpeed = 0.2f; - float leftMag = Mathf.Clamp(-mousePosInNodeViewScreenSpace.x + dragPanMargin, 0f, dragPanMargin); - float rightMag = Mathf.Clamp( mousePosInNodeViewScreenSpace.x - areaWidth + dragPanMargin, 0f, dragPanMargin); - float topMag = Mathf.Clamp( -mousePosInNodeViewScreenSpace.y + dragPanMargin , 0f, dragPanMargin); - float bottomMag = Mathf.Clamp( mousePosInNodeViewScreenSpace.y - areaHeight + dragPanMargin , 0f, dragPanMargin); - cameraPos += new Vector2(rightMag-leftMag, bottomMag-topMag)*panSpeed; - } - - - bool doingSomethingElse = connecting || rotatingPreview || placingNode || draggingSeparators; - bool dragInside = dragging && insideNodeView; - - if( dragInside && !doingSomethingElse ) { - - //if( !SF_GUI.MultiSelectModifierHeld() ) - // selection.DeselectAll(); - //Debug.Log("Delta: " + Event.current.delta); - cameraPos -= Event.current.delta; - SnapCamera(); - - BoundsAdjustCamera(); - editor.Defocus(); - //Debug.Log( "USING" ); - Event.current.Use(); - } - - - if( SF_GUI.PressedCameraMove() ) { - panCamera = true; - } - - - - } - - public Vector2 nodeSpaceMousePos; - public Vector2 viewSpaceMousePos; - - public Vector2 GetNodeSpaceMousePos() { - return nodeSpaceMousePos; - } - - - public bool MouseInsideNodeView( bool offset = false ) { - - if( offset ) { - return rect.Contains( viewSpaceMousePos/*ZoomSpaceToScreenSpace( Event.current.mousePosition )*/ ); - } else { - return rect.Contains( Event.current.mousePosition ); - } - - } - - void SnapCamera(){ - cameraPos.x = Mathf.Round(cameraPos.x); - cameraPos.y = Mathf.Round(cameraPos.y); - } - - - public Vector2 ZoomSpaceToScreenSpace( Vector2 in_vec ) { - return (in_vec - cameraPos + editor.separatorLeft.rect.TopRight() )*zoom + rect.TopLeft() + (Vector2.up * (editor.TabOffset))*(zoom-1); - } - public Rect ZoomSpaceToScreenSpace( Rect in_rect ) { - Vector2 offset = ZoomSpaceToScreenSpace(in_rect.TopLeft()); - in_rect.x = offset.x; - in_rect.y = offset.y; - in_rect.width /= zoom; - in_rect.height /= zoom; - //in_rect.x += -cameraPos.x; - //in_rect.y += -cameraPos.y; - return in_rect; - } - public Vector2 ScreenSpaceToZoomSpace( Vector2 in_vec ) { - return ( in_vec - (Vector2.up * (editor.TabOffset))*(zoom-1) - rect.TopLeft() ) / zoom - editor.separatorLeft.rect.TopRight() + cameraPos; - //return in_vec + cameraPos; - } - - // az + b + x(z-1) - - - public Rect ScreenSpaceToZoomSpace( Rect in_rect ) { - //in_rect.x -= -cameraPos.x; - //in_rect.y -= -cameraPos.y; - Vector2 offset = ScreenSpaceToZoomSpace(in_rect.TopLeft()); - in_rect.x = offset.x; - in_rect.y = offset.y; - in_rect.width *= zoom; - in_rect.height *= zoom; - - return in_rect; - } - - - } - -} - diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeView.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeView.cs.meta deleted file mode 100755 index 9de7ca8f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_EditorNodeView.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b1e7c52e807954f07b3d3f54461b3cc2 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_ErrorEntry.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_ErrorEntry.cs deleted file mode 100755 index 55372afb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_ErrorEntry.cs +++ /dev/null @@ -1,66 +0,0 @@ -using UnityEngine; -using System.Collections; - - -namespace ShaderForge { - [System.Serializable] - public class SF_ErrorEntry : ScriptableObject { - - public SF_Node node; - public SF_NodeConnector con; - public string error; - public bool isWarning; - public int rows = 1; - public System.Action action; - - void OnEnable() { - hideFlags = HideFlags.HideAndDontSave; - } - - - public static SF_ErrorEntry Create( string error, bool isWarning ) { - SF_ErrorEntry entry = ScriptableObject.CreateInstance(); - entry.isWarning = isWarning; - entry.error = error; - entry.InitializeRows(); - return entry; - } - - public static SF_ErrorEntry Create( string error, SF_Node target, bool isWarning ) { - SF_ErrorEntry entry = ScriptableObject.CreateInstance(); - entry.isWarning = isWarning; - entry.node = target; - entry.error = error; - entry.InitializeRows(); - return entry; - } - - public static SF_ErrorEntry Create( string error, SF_NodeConnector target, bool isWarning ) { - SF_ErrorEntry entry = ScriptableObject.CreateInstance(); - entry.isWarning = isWarning; - entry.con = target; - entry.node = target.node; - entry.error = error; - entry.InitializeRows(); - return entry; - } - - void InitializeRows() { - rows = Mathf.CeilToInt( error.Length / 50f ); - } - - public void OnPress() { - if( action != null ) { - action.Invoke(); - } - } - - public Texture2D icon { - get { - return isWarning ? SF_Styles.IconWarningSmall : SF_Styles.IconErrorSmall; - } - } - - } - -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_ErrorEntry.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_ErrorEntry.cs.meta deleted file mode 100755 index 600d17b3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_ErrorEntry.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 14c91959058f04c62a8e3075652c4638 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_FeatureChecker.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_FeatureChecker.cs deleted file mode 100755 index c4acdfa0..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_FeatureChecker.cs +++ /dev/null @@ -1,141 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - [System.Serializable] - public class SF_FeatureChecker : ScriptableObject { - - [SerializeField] - SF_PassSettings ps; - - [SerializeField] - public SF_Editor editor; - - public SF_FeatureChecker Initialize( SF_PassSettings ps, SF_Editor editor ) { - this.ps = ps; - this.editor = editor; - return this; - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - - - // Diffuse & Diffuse Power - // if light mode is not unlit - - // Specular & Gloss - // if light mode is !(Unlit || Lambert) - - // Transmission - // if light mode is not Unlit - - // Light Wrapping - // if light mode is not Unlit - - public void UpdateAvailability() { - - bool deferredPp = ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred; - bool unlit = (ps.catLighting.lightMode == SFPSC_Lighting.LightMode.Unlit); - bool pbr = (ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL); - bool lit = !unlit; - - // Diffuse makes these available: Transmission, Light Wrapping, Ambient lighting, Diffuse Power - bool diffConnected = editor.mainNode.diffuse.IsConnectedAndEnabled(); - bool specConnected = editor.mainNode.specular.IsConnectedAndEnabled(); - - bool bakedData = ps.catLighting.bakedLight; - bool usesAmbient = ps.catLighting.useAmbient; - bool ambDiffConnected = ps.HasAmbientDiffuse(); - bool ambSpecConnected = ps.HasAmbientSpecular(); - - - - editor.mainNode.diffuse.SetAvailable( lit ); - editor.mainNode.diffusePower.SetAvailable( lit && diffConnected && !deferredPp ); - editor.mainNode.specular.SetAvailable( lit ); - editor.mainNode.gloss.SetAvailable( lit && ( specConnected || ( diffConnected && pbr ) )); - editor.mainNode.normal.SetAvailable( true ); - editor.mainNode.alpha.SetAvailable( !deferredPp ); - editor.mainNode.alphaClip.SetAvailable( true ); - editor.mainNode.refraction.SetAvailable( !deferredPp ); - editor.mainNode.emissive.SetAvailable( true ); - editor.mainNode.transmission.SetAvailable( lit && diffConnected && !deferredPp ); - - - - - - editor.mainNode.diffuseOcclusion.SetAvailable( lit && diffConnected && ( bakedData || usesAmbient || ambDiffConnected ) ); - editor.mainNode.specularOcclusion.SetAvailable( lit && specConnected && ( bakedData || ambSpecConnected ) ); // Masks ambient spec & directional lightmaps - - editor.mainNode.ambientDiffuse.SetAvailable( lit && diffConnected); - editor.mainNode.ambientSpecular.SetAvailable( lit && specConnected ); - editor.mainNode.customLighting.SetAvailable( !lit && !deferredPp ); - - editor.mainNode.lightWrap.SetAvailable( lit && diffConnected && !deferredPp ); - editor.mainNode.displacement.SetAvailable( editor.mainNode.tessellation.IsConnectedAndEnabled() ); - editor.mainNode.outlineColor.SetAvailable( editor.mainNode.outlineWidth.IsConnectedAndEnabled() && !deferredPp ); - editor.mainNode.outlineWidth.SetAvailable( !deferredPp ); - - - // Rename labels based on which lighting mode you're using - if(ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL){ - if( ps.catLighting.specularMode == SFPSC_Lighting.SpecularMode.Metallic ){ - editor.mainNode.diffuse.label = "Base Color"; - editor.mainNode.specular.label = "Metallic"; - } else { - editor.mainNode.diffuse.label = "Albedo"; - editor.mainNode.specular.label = "Specular"; - } - } else { - editor.mainNode.diffuse.label = "Diffuse"; - editor.mainNode.specular.label = "Specular"; - } - - // Metallic is 1 component, specular has 3 components - if(ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL && ps.catLighting.specularMode == SFPSC_Lighting.SpecularMode.Metallic ){ - editor.mainNode.specular.valueTypeDefault = ValueType.VTv1; - editor.mainNode.specular.SetValueType( ValueType.VTv1 ); - editor.mainNode.specular.TypecastTo( 1 ); - } else { - editor.mainNode.specular.valueTypeDefault = ValueType.VTvPending; - editor.mainNode.specular.SetValueType( ValueType.VTvPending ); - editor.mainNode.specular.TypecastTo( 3 ); - } - - - if( ps.catLighting.glossRoughMode == SFPSC_Lighting.GlossRoughMode.Roughness ) { - editor.mainNode.gloss.label = "Roughness"; - } else { - editor.mainNode.gloss.label = "Gloss"; - } - - if( ps.catGeometry.vertexOffsetMode == SFPSC_Geometry.VertexOffsetMode.Relative ) { - editor.mainNode.vertexOffset.label = "Vertex Offset"; - } else if( ps.catGeometry.vertexOffsetMode == SFPSC_Geometry.VertexOffsetMode.Absolute ) { - editor.mainNode.vertexOffset.label = "Vertex Position"; - } - - - - - - //editor.materialOutput.anisotropicDirection.SetAvailable( false ); - //editor.materialOutput.worldPositionOffset.SetAvailable( false ); - - - } - - - - - - - - - - } -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_FeatureChecker.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_FeatureChecker.cs.meta deleted file mode 100755 index 3006abc8..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_FeatureChecker.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e295e3262ddd14ff299ea932442b948f -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_InstructionPass.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_InstructionPass.cs deleted file mode 100755 index 0ca7bb41..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_InstructionPass.cs +++ /dev/null @@ -1,125 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System; - -namespace ShaderForge{ - - - public class SFIns_PassPlat { - public RenderPlatform plat; - public SF_MinMax vert = new SF_MinMax( 0, 0 ); - public SF_MinMax frag = new SF_MinMax( 0, 0 ); - public SF_MinMax vTex = new SF_MinMax( 0, 0 ); - public SF_MinMax fTex = new SF_MinMax( 0, 0 ); - - public SFIns_PassPlat(RenderPlatform plat){ - this.plat = plat; - } - - } - - - public class SFIns_Pass { - - - public List plats = new List(){ - new SFIns_PassPlat(RenderPlatform.d3d9), - new SFIns_PassPlat(RenderPlatform.d3d11), - new SFIns_PassPlat(RenderPlatform.glcore), - new SFIns_PassPlat(RenderPlatform.gles), - new SFIns_PassPlat(RenderPlatform.gles3), - new SFIns_PassPlat(RenderPlatform.metal), - new SFIns_PassPlat(RenderPlatform.d3d11_9x), - new SFIns_PassPlat(RenderPlatform.xboxone), - new SFIns_PassPlat(RenderPlatform.ps4), - new SFIns_PassPlat(RenderPlatform.psp2), - new SFIns_PassPlat(RenderPlatform.n3ds), - new SFIns_PassPlat(RenderPlatform.wiiu) - }; - - public void Parse(ShaderProgram prog, string line, bool ignoreMin ) { - - //Debug.Log("Parsing instruction count: line = " + line); - - // String style: - // "// opengl - ALU: 29 to 35" - // "// opengl - ALU: 7 to 15, TEX: 1 to 3" - - string[] split = line.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); - - if( split.Length != 7 && split.Length != 11 && split.Length != 15 ) { - Debug.LogError( "Error parsing instruction count. Line did not have 7, 11 or 15 elements [" + line + "]. Length is: " + split.Length ); - return; - } - - if( split[1] == "flash" ) { - Debug.LogWarning( "Flash is no longer supported by Unity, and was removed from the shader" ); - return; - } - - if( split[1] == "ps3" ) { - Debug.LogWarning( "PS3 is no longer supported by Unity since 5.5, and was removed from the shader" ); - return; - } - - if( split[1] == "xbox360" ) { - Debug.LogWarning( "Xbox 360 is no longer supported by Unity since 5.5, and was removed from the shader" ); - return; - } - - if( split[1] == "opengl" ) { - split[1] = "glcore"; - } - - bool hasTex = ( split.Length == 11 ); - - object enumObj = Enum.Parse( typeof( RenderPlatform ), split[1] ); - - int enumID; - - if(enumObj != null){ - enumID = (int)enumObj; - } else { - return; - } - - - - if( prog == ShaderProgram.Frag ) { - if( !ignoreMin ) - plats[enumID].frag.min = IntParse( split[4] ); - plats[enumID].frag.max = IntParse( split[6] ); - if( hasTex ) { - if( !ignoreMin ) - plats[enumID].fTex.min = IntParse( split[8] ); - plats[enumID].fTex.max = IntParse( split[10] ); - } - } else if( prog == ShaderProgram.Vert ) { - if( !ignoreMin ) - plats[enumID].vert.min = IntParse( split[4] ); - plats[enumID].vert.max = IntParse( split[6] ); - if( hasTex ) { - if( !ignoreMin ) - plats[enumID].vTex.min = IntParse( split[8] ); - plats[enumID].vTex.max = IntParse( split[10] ); - } - } else { - Debug.LogError( "Tried to parse things in invalid program [" + prog + "]" ); - } - - //Debug.Log("Instr: " + split[1] + " "+ prog + " " + line + " ig: " + ignoreMin); - - - } - - public int IntParse( string s ) { - s = s.Replace(",",""); - return int.Parse(s); - } - - - - } - -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_InstructionPass.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_InstructionPass.cs.meta deleted file mode 100755 index c4a94174..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_InstructionPass.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 31b9629aa3f2942e796d40d1277bab28 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnectionLine.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnectionLine.cs deleted file mode 100755 index f6a68b8f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnectionLine.cs +++ /dev/null @@ -1,345 +0,0 @@ -using UnityEngine; -using System.Collections; - - -namespace ShaderForge{ - - - [System.Serializable] - public class SF_NodeConnectionLine : ScriptableObject { - - - public SF_NodeConnector connector; - public SF_Editor editor; - - public bool aboutToBeDeleted = false; - - public Vector2[] pointsBezier0; - public Vector2[] pointsBezier1; - public Vector2[] pointsBezier2; - public Vector2[] pointsBezier3; - - public Vector2[] pointsLinear0; - public Vector2[] pointsLinear1; - public Vector2[] pointsLinear2; - public Vector2[] pointsLinear3; - - public Vector2[] pointsRectilinear0; - public Vector2[] pointsRectilinear1; - public Vector2[] pointsRectilinear2; - public Vector2[] pointsRectilinear3; - - public Vector2[] this[ConnectionLineStyle style, int id]{ - get{ - switch(style){ - case ConnectionLineStyle.Bezier: - switch(id){ - case 0: - return pointsBezier0; - case 1: - return pointsBezier1; - case 2: - return pointsBezier2; - case 3: - return pointsBezier3; - } - break; - case ConnectionLineStyle.Linear: - switch(id){ - case 0: - return pointsLinear0; - case 1: - return pointsLinear1; - case 2: - return pointsLinear2; - case 3: - return pointsLinear3; - } - break; - case ConnectionLineStyle.Rectilinear: - switch(id){ - case 0: - return pointsRectilinear0; - case 1: - return pointsRectilinear1; - case 2: - return pointsRectilinear2; - case 3: - return pointsRectilinear3; - } - break; - } - Debug.LogError("Invalid this[style,id] attempt on NodeConnectionLink = " + style + " and " + id); - return null; - } - set{ - switch(style){ - case ConnectionLineStyle.Bezier: - switch(id){ - case 0: - pointsBezier0 = value; - return; - case 1: - pointsBezier1 = value; - return; - case 2: - pointsBezier2 = value; - return; - case 3: - pointsBezier3 = value; - return; - } - return; - case ConnectionLineStyle.Linear: - switch(id){ - case 0: - pointsLinear0 = value; - return; - case 1: - pointsLinear1 = value; - return; - case 2: - pointsLinear2 = value; - return; - case 3: - pointsLinear3 = value; - return; - } - return; - case ConnectionLineStyle.Rectilinear: - switch(id){ - case 0: - pointsRectilinear0 = value; - return; - case 1: - pointsRectilinear1 = value; - return; - case 2: - pointsRectilinear2 = value; - return; - case 3: - pointsRectilinear3 = value; - return; - } - return; - } - Debug.LogError("Invalid this[style,id] set attempt on NodeConnectionLink = " + style + " and " + id); - //return null; - } - } - - - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - - public SF_NodeConnectionLine Initialize(SF_Editor editor, SF_NodeConnector connector){ - this.connector = connector; - this.editor = editor; - return this; - } - - public bool DeleteImminent(){ - - bool thisIsPendingInput = (connector.conType == ConType.cInput) && (SF_NodeConnector.pendingConnectionSource == connector); - - return aboutToBeDeleted || connector.IsDeleteHovering(false) || connector.inputCon.IsDeleteHovering(false) || thisIsPendingInput; - } - - - public void Draw(){ - - if(aboutToBeDeleted && !connector.IsConnected()){ // It's disconnected, don't mark it anymore - aboutToBeDeleted = false; - } - - if(!connector.IsConnected()) - return; - - if(Event.current.rawType != EventType.repaint) - return; - - //Vector2 a = connector.GetConnectionPoint(); - //Vector2 b = connector.inputCon.GetConnectionPoint(); - int cc = connector.GetCompCount(); - bool isMatrix4x4 = ( cc == 16 ); - if( isMatrix4x4 ) { - cc = 1; - } - - Color color = DeleteImminent() ? new Color(1f,0f,0f,0.7f) : connector.GetConnectionLineColor(); - - // TEMP: - ReconstructShapes(); - - //GUILines.DrawStyledConnection( editor, a, b, cc, color); - - - //switch(SF_Settings.ConnectionLineStyle){ - //case ConnectionLineStyle.Bezier: - if( isMatrix4x4 ) { - //GUILines.DrawMatrixConnection( editor, connector.GetConnectionPoint(), connector.inputCon.GetConnectionPoint(), color ); - GUILines.DrawLines( editor, this[ConnectionLineStyle.Bezier, 0], color, GetConnectionWidth(), true ); - GUILines.DrawLines( editor, this[ConnectionLineStyle.Bezier, 1], color, GetConnectionWidth(), true, true ); - GUILines.DrawLines( editor, this[ConnectionLineStyle.Bezier, 2], color, GetConnectionWidth(), true ); - } else { - for( int i=0; i < cc; i++ ) { - GUILines.DrawLines( editor, this[ConnectionLineStyle.Bezier, i], color, GetConnectionWidth(), true ); - } - } - - //break; - //} - - - - } - - const float partOffsetFactor = 10f; - const float connectionWidth = 2f; - const int bezierSegments = 25; - - - private float GetConnectionWidth(){ - return DeleteImminent() ? 4f : connectionWidth; - } - - - - //Vector2 lastUpdatePosStart = Vector2.zero; - //Vector2 lastUpdatePosEnd = Vector2.zero; - //float lastUpdateCC = 0; - - - public void ReconstructShapes(){ - - - - //if( Event.current.type != EventType.repaint ) // To trigger it before painting! - // return; - - - float cc = connector.GetCompCount(); - if( cc == 16 ) - cc = 3; - - - - - //if( cc != lastUpdateCC ) { - // lastUpdateCC = cc; - // needsUpdate = true; - //} - - //Vector2 curPosStart = connector.inputCon.node.rect.position; - //Vector2 curPosEnd = connector.node.rect.position; - - //if( lastUpdatePosStart != curPosStart ) { - // lastUpdatePosStart = curPosStart; - // needsUpdate = true; - //} - - //if( lastUpdatePosEnd != curPosEnd ) { - // lastUpdatePosEnd = curPosEnd; - // needsUpdate = true; - //} - - - //if( needsUpdate ) { - //Debug.Log("Updating"); - float partOffset = partOffsetFactor / cc; - float mainOffset = -( cc - 1 ) * 0.5f * partOffset; - - float offset = 0; - - for( int i=0; i < cc; i++ ) { - offset = mainOffset + partOffset * i; - - - // TODO: Style branching - ReconstructBezier( offset, i ); - - - } - //} - - - //Debug.Log(this[ConnectionLineStyle.Bezier,0][0].ToString()); - - - - - } - - - - private void ReconstructBezier(float offset, int id){ - this[ConnectionLineStyle.Bezier,id] = GUILines.ConnectionBezierOffsetArray( - offset, - connector, - connector.inputCon, - bezierSegments - ); - } - - public bool Intersects(Vector2 p0, Vector2 p1, out Vector2 intersection){ - intersection = Vector2.zero; - -// p0 = editor.nodeView.ZoomSpaceToScreenSpace(p0); -// p1 = editor.nodeView.ZoomSpaceToScreenSpace(p1); - p0 = editor.nodeView.ZoomSpaceToScreenSpace(p0); - p1 = editor.nodeView.ZoomSpaceToScreenSpace(p1); // Double, for whatever reason - - float cc = connector.GetCompCount(); - if( cc == 16 || cc == 0 ) // Matrices - cc = 1; - - if(cc == 1){ - if(SF_Tools.LineIntersection(p0, p1, this[0, 0], out intersection)){ - return true; - } - } else if( cc == 2){ - - Vector2 intA = Vector2.zero; - Vector2 intB = Vector2.zero; - - bool hitA = SF_Tools.LineIntersection(p0, p1, this[0, 0], out intA); - bool hitB = SF_Tools.LineIntersection(p0, p1, this[0, 1], out intB); - - if(hitA && hitB){ - intersection = (intA + intB)/2; - return true; - } - - } else if(cc == 3){ - if(SF_Tools.LineIntersection(p0, p1, this[0, 1], out intersection)){ - return true; - } - }else if( cc == 4){ - - Vector2 intA = Vector2.zero; - Vector2 intB = Vector2.zero; - - bool hitA = SF_Tools.LineIntersection(p0, p1, this[0, 1], out intA); - bool hitB = SF_Tools.LineIntersection(p0, p1, this[0, 2], out intB); - - if(hitA && hitB){ - intersection = (intA + intB)/2; - return true; - } - } - - return false; - - - } - - - - - - } - -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnectionLine.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnectionLine.cs.meta deleted file mode 100755 index 9a8b744b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnectionLine.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 584792dc3e3b749a5adc8f6fa95aad34 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnector.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnector.cs deleted file mode 100755 index 3c79480c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnector.cs +++ /dev/null @@ -1,1217 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System; - - -namespace ShaderForge { - - public enum ConType { cInput, cOutput }; - public enum OutChannel { RGB, R, G, B, A, All, RG }; - - public enum EnableState { Enabled, Disabled, Hidden }; - public enum AvailableState { Available, Unavailable }; - - public enum LinkingMethod { Default, NoUpdate }; - - public enum ValueType { VTvPending, VTv1, VTv2, VTv3, VTv4, VTv1v2, VTv1v3, VTv1v4, TexAsset, VTm4x4, VTv4m4x4 }; - - [System.Serializable] - public class SF_NodeConnector : ScriptableObject { - - - public static SF_NodeConnector pendingConnectionSource = null; - public AvailableState availableState = AvailableState.Available; - public EnableState enableState = EnableState.Enabled; - public bool required = false; - - public ConType conType; - public OutChannel outputChannel = OutChannel.All; - public ValueType valueType; - public ValueType valueTypeDefault; - [SerializeField] - private CustomValueType customValueType; - public CustomValueType CustomValueType{ // This is used when dealing with custom nodes - get{ - return customValueType; - } - set{ - CustomValueType cvtBef = customValueType; - customValueType = value; - bool changed = (customValueType != cvtBef); - if(changed){ - switch(customValueType){ - case CustomValueType.Float: - this.TypecastTo(1).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv1); - break; - case CustomValueType.Float2: - this.TypecastTo(2).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv2); - break; - case CustomValueType.Float3: - this.TypecastTo(3).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv3); - break; - case CustomValueType.Float4: - this.TypecastTo(4).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv4); - break; - case CustomValueType.Half: - this.TypecastTo(1).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv1); - break; - case CustomValueType.Half2: - this.TypecastTo(2).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv2); - break; - case CustomValueType.Half3: - this.TypecastTo(3).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv3); - break; - case CustomValueType.Half4: - this.TypecastTo(4).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv4); - break; - case CustomValueType.Fixed: - this.TypecastTo(1).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv1); - break; - case CustomValueType.Fixed2: - this.TypecastTo(2).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv2); - break; - case CustomValueType.Fixed3: - this.TypecastTo(3).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv3); - break; - case CustomValueType.Fixed4: - this.TypecastTo(4).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTv4); - break; - case CustomValueType.Sampler2D: - this.TypecastTo(0).WithColor(SF_Node.colorExposed).SetValueType(this.valueTypeDefault = ValueType.TexAsset); - break; - case CustomValueType.Matrix4x4: - this.TypecastTo(0).WithColor(SF_NodeConnector.colorEnabledDefault).SetValueType(this.valueTypeDefault = ValueType.VTm4x4); - break; - } - - } - - - } - - } - public string label; - public SF_NodeConnector inputCon; - public SF_NodeConnectionLine conLine; - public List outputCons; - public SF_Node node; - public bool outerLabel = false; - public bool displayLockIfDeferredPrePassIsOn = false; - public Rect rect; - public int typecastTarget = 0; // 0 = No typecasting - - public int usageCount = 1; - - public string strID = null; - - [SerializeField] - private ShaderProgram forcedProgram = ShaderProgram.Any; - - [SerializeField] - private List skipPasses; - public List SkipPasses{ - get{ - if(skipPasses == null) - skipPasses = new List(); - return skipPasses; - } - } - - public static Color colorEnabledDefault{ - get{ - if(SF_GUI.ProSkin) - return new Color( 0.6f, 0.6f, 0.6f ); - else - return new Color( 1f, 1f, 1f ); - } - } - public Color color; - public string unconnectedEvaluationValue = null; - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - if(color == default(Color)) - color = colorEnabledDefault; - } - - public SF_NodeConnector() { - //Debug.Log("NODE CONNECTION "); - } - - - public static SF_NodeConnector Create( SF_Node node, string strID, string label, ConType conType, ValueType valueType, bool outerLabel = false, string unconnectedEvaluationValue = null ) { - return ScriptableObject.CreateInstance< SF_NodeConnector>().Initialize(node, strID, label, conType,valueType, outerLabel, unconnectedEvaluationValue); - } - - public SF_NodeConnector Initialize( SF_Node node, string strID, string label, ConType conType, ValueType valueType, bool outerLabel = false, string unconnectedEvaluationValue = null ) { - this.node = node; - this.strID = strID; - this.label = label; - this.conType = conType; - - if(conType == ConType.cInput){ - conLine = ScriptableObject.CreateInstance().Initialize(node.editor, this); - } - - this.valueType = this.valueTypeDefault = valueType; - this.outerLabel = outerLabel; - this.unconnectedEvaluationValue = unconnectedEvaluationValue; - outputCons = new List(); - return this; - } - - // Chaining - public SF_NodeConnector SetRequired( bool b ) { - required = b; - return this; - } - public SF_NodeConnector WithColor( Color c ) { - color = c; - return this; - } - public SF_NodeConnector Outputting( OutChannel channel ) { - outputChannel = channel; - return this; - } - public SF_NodeConnector TypecastTo(int target) { - typecastTarget = target; - //Debug.Log("Typecasting " + label + " to " + target); - return this; - } - public SF_NodeConnector WithUseCount(int count){ - usageCount = count; - return this; - } - public SF_NodeConnector Skip( params PassType[] passes ) { - SkipPasses.AddRange( passes ); - return this; - } - public SF_NodeConnector ForceBlock(ShaderProgram block) { - forcedProgram = block; - return this; - } - public SF_NodeConnector DisplayLockIfDeferredPrePassIsOn(){ - displayLockIfDeferredPrePassIsOn = true; - return this; - } - - public SF_NodeConnector visControlChild; - public SF_NodeConnector visControlParent; - public SF_NodeConnector SetVisChild(SF_NodeConnector child){ // Used to make enable-chains (Connecting B enables the C connector etc) - visControlChild = child; - child.visControlParent = this; - child.enableState = EnableState.Hidden; - return this; - } - - public void SetVisChildVisible(bool visible){ - - if(visControlChild == null){ - return; - } - - EnableState targetState = visible ? EnableState.Enabled : EnableState.Hidden; - - if(visControlChild.enableState == targetState) - return; // Don't do anything if unchanged - - - if(!visible){ - visControlChild.Disconnect(true,false); // Disconnect if it goes invisible when linked - } - - visControlChild.enableState = targetState; - - } - - - - - public string ghostType = null; - public string ghostLinkStrId = null; - public SF_NodeConnector SetGhostNodeLink( Type ghostType, string ghostLinkStrId ) { - this.ghostType = ghostType.FullName; - this.ghostLinkStrId = ghostLinkStrId; - return this; - } - - - // Ghost nodes are default values assigned to unconnected node connectors - // They are instantiated when the shader is being evaluated, and then removed again - public void DefineGhostIfNeeded(ref List ghosts) { - - - // Skip nodes without ghosts - if( string.IsNullOrEmpty(ghostType) ) { - return; - } - - - if( IsConnected() ) // Skip already connected ones - return; - - - SF_Node ghost = null; - - // Search for existing ghost node - foreach( SF_Node exisGhost in ghosts ) { - if( exisGhost.GetType().FullName == ghostType ) { // TODO: Make sure serialized data matches too! - // Found! - ghost = exisGhost; - - if(SF_Debug.ghostNodes) - Debug.Log("Found matching existing ghost"); - break; - } - } - - // If no ghost was found, create one - if( ghost == null ) { - ghost = node.editor.AddNode( ghostType ); - ghost.isGhost = true; - ghosts.Add( ghost ); - if(SF_Debug.ghostNodes){ - Debug.Log("Adding ghost " + ghostType + " with connection count " + ghost.connectors.Length); - Debug.Log("Linked to " + node.nodeName + "["+this.label+"]" ); - Debug.Log("Ghost Count = " + node.editor.shaderEvaluator.ghostNodes.Count); - } - //Debug.Log( "Adding ghost of type " + ghostType ); - //Debug.Log( "Ghost in main node list = " + node.editor.nodes.Contains( ghost ) ); - } - - // Just to make sure... - if( ghost == null ) { - Debug.LogError( "Ghost is null, this should really not happen. Tried to find type " + ghostType ); - } - - // By this point, ghost is surely an existing node! - // Link it: - - //Debug.Log( "Linking ghost of type " + ghostType + " on " + this.node.nodeName + " Is COnnected = " + IsConnected()); - ghost.status.leadsToFinal = true; - ghost[ghostLinkStrId].LinkTo(this,LinkingMethod.NoUpdate); - - } - - // Get the index of this connector in the node array - public string GetIndex() { - if( this.HasID() ) - return strID; - for( int i = 0; i < node.connectors.Length; i++ ) - if( node.connectors[i] == this ) - return i.ToString(); - Debug.LogError( "Couldn't find index of a connector in " + node.nodeName ); - return "0"; - } - - public bool DisplayLock(){ - return displayLockIfDeferredPrePassIsOn && node.editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred; - } - - public bool HasID() { - return !string.IsNullOrEmpty( strID ); - } - - - public ShaderProgram GetProgram() { - if( forcedProgram == ShaderProgram.Any ) - return node.program; - return forcedProgram; - } - - - public int GetCompCount() { - - - if( conType == ConType.cInput){ - if( IsConnected() ) { - return inputCon.GetCompCount(); - } else { - int cc = 0; - if(SF_Tools.CompCountOf(valueType, out cc)){ - return cc; - } else { - Debug.LogWarning("[Shader Forge] - invalid component count in ["+label+"] of " + node.name + ""); - return node.texture.CompCount; // This is super weird, shouldn't read from the max comp count, read from the connection type instead - } - } - - } - - - - OutChannel oc = outputChannel; - if( oc == OutChannel.All ){ - - int cc = 0; - if(SF_Tools.CompCountOf(valueType, out cc)){ - return cc; - } else { - Debug.LogWarning("[Shader Forge] - invalid component count in ["+label+"] of " + node.name + ""); - return node.texture.CompCount; // This is super weird, shouldn't read from the max comp count, read from the connection type instead - } - - } else if( oc == OutChannel.RGB ) - return 3; - if( oc == OutChannel.RG ) - return 2; - - int custCount = SF_Tools.ComponentCountOf(customValueType); - if(custCount != 0){ - return custCount; - } - - return 1; - } - - - - - public string Evaluate() { - - string s = node.PreEvaluate(); - - switch( outputChannel ) { - case OutChannel.RGB: - return s + ".rgb"; - case OutChannel.RG: - return s + ".rg"; - case OutChannel.R: - return s + ".r"; - case OutChannel.G: - return s + ".g"; - case OutChannel.B: - return s + ".b"; - case OutChannel.A: - return s + ".a"; - } - - return s; - - } - - - public bool IsConnected() { - if( conType == ConType.cInput ) { - return inputCon != null; - } else { - if( outputCons == null ) - return false; - return ( outputCons.Count != 0 ); - } - - } - - public bool IsConnectedAndEnabled() { - return IsConnected() && (enableState == EnableState.Enabled || enableState == EnableState.Hidden); - } - - public bool IsConnectedEnabledAndAvailable(){ - return IsConnected() && ( enableState == EnableState.Enabled || enableState == EnableState.Hidden ) && availableState == AvailableState.Available; - } - - public bool IsConnectedEnabledAndAvailableInThisPass(PassType pass){ - if(SkipPasses.Contains(pass)){ - return false; - } - return IsConnectedEnabledAndAvailable(); - } - - - - public bool ConnectionInProgress() { - return ( SF_NodeConnector.pendingConnectionSource == this && IsConnecting() ); - } - - public static bool IsConnecting() { - if( SF_NodeConnector.pendingConnectionSource == null ) - return false; - /*else if( string.IsNullOrEmpty( SF_NodeConnection.pendingConnectionSource.node.name ) ) { - SF_NodeConnection.pendingConnectionSource=null; - return false; - }*/ - - return true; - } - - public bool Hovering(bool world) { - if( !node.editor.nodeView.MouseInsideNodeView(offset:world) ) - return false; - Rect r = SF_Tools.GetExpanded( rect, SF_Tools.connectorMargin ); - return r.Contains( world ? Event.current.mousePosition : MousePos() ); - } - - - - public bool Clicked(int button = 0) { - - - bool hovering = Hovering(world:false); - bool click = ( Event.current.type == EventType.mouseDown && Event.current.button == button ); - bool clickedCont = hovering && click; - //bool clickedCont=cont&&click; - //Debug.Log(); - return clickedCont; - } - - public bool Released() { - bool cont = Hovering(world:false); - bool release = ( Event.current.type == EventType.mouseUp ); - return cont && release; - } - - - public void OnClick() { - Debug.Log( "Clicked Button" ); - } - - public Vector2 MousePos() { - if( node.editor == null ) - return Vector2.zero; - return node.editor.nodeView.GetNodeSpaceMousePos(); - } - - // TODO: Pass nodes into actual line draw thingy - public float GetConnectionCenterY( SF_NodeConnector cA, SF_NodeConnector cB ) { - Rect a = cA.node.rect; - Rect b = cB.node.rect; - if( cA.GetConnectionPoint().y > cB.GetConnectionPoint().y ) - return 0.5f * ( a.yMax + b.yMin ); - else - return 0.5f * ( b.yMax + a.yMin ); - } - - public void CheckConnection( SF_Editor editor ) { - - - - if(ShouldBeInvisible()) - return; - - - - - if( conType == ConType.cInput && Event.current.type == EventType.repaint ) { - DrawConnection( editor ); - } - - if( enableState == EnableState.Disabled || availableState == AvailableState.Unavailable ) - return; - - if( Clicked() ) { - SF_NodeConnector.pendingConnectionSource = this; - editor.nodeView.selection.DeselectAll(registerUndo:false); - foreach( SF_Node iNode in editor.nodes ) { - foreach( SF_NodeConnector con in iNode.connectors ) { - con.UpdateCanValidlyConnectToPending(); - } - } - Event.current.Use(); - } - - if( Clicked(1) && SF_GUI.HoldingAlt()){ - Disconnect(); - } - - if( !ConnectionInProgress() ) { - if( Released() ) - TryMakeConnection(); - return; - } - - - // Active connection: - - editor.ResetRunningOutdatedTimer(); - - //if(Event.current.type == EventType.repaint) - //node.Repaint(); - - - bool hovering = false; - foreach(SF_Node n in editor.nodes){ - foreach(SF_NodeConnector con in n.connectors){ - if(con.CanConnectToPending() && con.Hovering(false)){ - hovering = true; - break; - } - } - if(hovering) - break; - } - - if( Event.current.type == EventType.repaint ) { - Color c = hovering ? Color.green : GetConnectionLineColor(); - - bool input = ( conType == ConType.cInput ); - Vector2 start = input ? GetConnectionPoint() : MousePos(); - Vector2 end = input ? MousePos() : GetConnectionPoint(); ; - - if( valueType == ValueType.VTm4x4 || valueType == ValueType.VTv4m4x4 ) { - GUILines.DrawMatrixConnection( editor, start, end, c ); - } else { - GUILines.DrawStyledConnection( editor, start, end, GetCompCount(), c ); - } - } - - - - - //Drawing.DrawLine(rect.center,MousePos(),Color.white,2,true); - - - } - - public Color GetConnectionLineColor() { - - Color def = EditorGUIUtility.isProSkin ? new Color( 1f, 1f, 1f, 0.3f ) : new Color( 0f, 0f, 0f, 0.4f ); - - - - - Color sel = SF_GUI.selectionColor; - - if( inputCon == null ) - return def; - else if( inputCon.color == SF_Node.colorExposed ) - def = SF_Node.colorExposedDark; - - if( node.selected || inputCon.node.selected ) - return sel; - - - if( !DisplayAsValid() ) - def.a = 0.1f; - - return def; - } - - void DrawConnection( SF_Editor editor ) { - - conLine.Draw(); - - /* - Vector2 a = GetConnectionPoint(); - Vector2 b = inputCon.GetConnectionPoint(); - int cc = GetCompCount(); - - - - GUILines.DrawStyledConnection( editor, a, b, cc, GetConnectionLineColor() ); - */ - - } - - public bool CanEvaluate() { - if( !IsConnectedAndEnabled() ) - if( !string.IsNullOrEmpty( unconnectedEvaluationValue ) ) - return true; - else - return false; // TODO: Something - if(conType == ConType.cInput) - if( !inputCon.node.CanEvaluate() ) - return false; - return true; - } - - public bool CanEvaluateAs( int target ) { - if( !CanEvaluate() ) - return false; - //int source = inputCon.GetCompCount(); - //if( target < source ) // TODO: Allow this? - // return false; - return true; - } - - - public string TryEvaluate() { - - //Debug.Log("TryEvaluate " + label + " typecast = " + typecastTarget); - - if( !IsConnectedAndEnabled() ) - if( !string.IsNullOrEmpty( unconnectedEvaluationValue ) ) - return unconnectedEvaluationValue; - if( !CanEvaluate() ) - return null; - - if( typecastTarget == 0 ){ - if(conType == ConType.cInput) - return inputCon.Evaluate(); - else - return Evaluate(); - } else { - //Debug.Log("Trying to evaluate node " + this.label + " on node " + this.node.nodeName); - return TryEvaluateAs( typecastTarget ); - } - - } - - public string TryEvaluateAs(int target) { - if( !CanEvaluateAs(target) ) - return null; // TODO: Throw errors etc - - int source = inputCon.GetCompCount(); - - int diff = target - source; - - - - if(diff == 0) // Same value type - return inputCon.Evaluate(); - if( diff < 0 ) { // Lowering component count, mask components - switch( target ) { - case 1: - return inputCon.Evaluate() + ".r"; - case 2: - return inputCon.Evaluate() + ".rg"; - case 3: - return inputCon.Evaluate() + ".rgb"; - } - } - - // Increasing component count: - - string cast; - - - if( source != 1 ) { // Evaluate + append zeroes - cast = "float" + target + "(" + inputCon.Evaluate(); - for( int i = 0; i < diff; i++ ) - cast += ",0.0"; - } else { - inputCon.node.DefineVariable(); - cast = "float" + target + "(" + inputCon.Evaluate(); - for( int i = 0; i < diff; i++ ) - cast += "," + inputCon.Evaluate(); - } - - - - cast += ")"; - return cast; - } - - - /* - public bool IsFocused() { - return rect.Contains( Event.current.mousePosition ); - }*/ - - public bool CheckIfDeleted() { - if( (Event.current.keyCode == KeyCode.Delete || Event.current.keyCode == KeyCode.Backspace) && Event.current.type == EventType.keyDown && Hovering( world: true ) ) { - Disconnect(); - return true; - } - return false; - } - - - - - public bool IsDeleted() { - return ( node == null ); - } - - public void Disconnect( bool force = false, bool callback = true, bool reconnection = false ) { - - //Debug.Log( "Attempt to disconnect: " + node.name + "[" + label + "]" ); - - if( !IsConnected() ) { - //Debug.Log( "Aborted " + node.name + "[" + label + "]" ); - return; - } - - - if( conType == ConType.cInput ) { - //Debug.Log( "Input disconnecting " + node.name + "[" + label + "]" ); - ResetValueType(); - if( inputCon != null ) { - inputCon.outputCons.Remove( this ); - if(!reconnection) - SetVisChildVisible(false); // Don't hide the child if this was disconnected by reconnection - //Debug.Log( "Disconnecting " + label + "<--" + inputCon.label ); - } - inputCon = null; - if( callback && !SF_Parser.quickLoad ) - node.OnUpdateNode(); - } else { - //Debug.Log( "Output disconnecting " + node.name + "[" + label + "]" ); - SF_NodeConnector[] outputsArr = outputCons.ToArray(); - for( int i = 0; i < outputsArr.Length; i++ ) { - //Debug.Log( "Disconnecting " + outputsArr[i].label + "<--" + label ); - outputsArr[i].Disconnect( true, callback ); - } - outputCons.Clear(); - } - - // AceMatEditor.instance.CheckForBrokenConnections(); - - // node = null; // What? - } - - public Vector2 GetConnectionPoint() { - if( conType == ConType.cOutput ) - return new Vector2( rect.xMax, rect.center.y ); - else - return new Vector2( rect.xMin+1, rect.center.y ); - } - - - public bool CanConnectTo(SF_NodeConnector other) { - if( other == null ) - return false; - - if( other.node == node ) - return false; // Disallow connecting to self - - if( other.conType == this.conType ) - return false; // Disallow connecting same types (i <- i & o <- o) - - if( conType == ConType.cOutput ) { // Disallow connecting loops - if( node.IsDescendantOf( other.node ) ) { - return false; - } - } else { - if( other.node.IsDescendantOf( node ) ) { - return false; - } - } - - return true; - } - - - - public bool CanValidlyConnectTo(SF_NodeConnector other) { - if(!CanConnectTo(other)) - return false; - - if(this.conType == ConType.cInput) - return SFNCG_Arithmetic.CompatibleTypes( this.valueTypeDefault, other.valueType ); - else - return SFNCG_Arithmetic.CompatibleTypes( other.valueTypeDefault, this.valueType ); - - - } - - - public void TryMakeConnection() { - - if(SF_NodeConnector.pendingConnectionSource == null) - return; - - if( !CanConnectTo( SF_NodeConnector.pendingConnectionSource ) ) { - return; // TODO: Display message - } - - LinkTo( SF_NodeConnector.pendingConnectionSource,LinkingMethod.Default, registerUndo:true ); - - SF_NodeConnector.pendingConnectionSource = null; - } - - public void ThrowLinkError() { - Debug.LogError( "Attempt to connect invalid types" ); - } - - - - - public void ResetValueType() { - //Debug.Log("Resetting value type on " + this.label); - valueType = valueTypeDefault; - } - - public void LinkTo( SF_NodeConnector other, LinkingMethod linkMethod = LinkingMethod.Default, bool registerUndo = false ) { - - - - - if( this.conType == other.conType ) { - Debug.Log("Invalid IO linking: " + other.node.nodeName + " con: " + other.label + " thisnode: " + node.nodeName + " con: " + this.label); - return; - } - - if( conType == ConType.cInput ) { - other.LinkTo( this, linkMethod, registerUndo ); // Reverse connection if dragged other way - return; - } - - if(this.node.isGhost) - linkMethod = LinkingMethod.NoUpdate; - - // Other is the input node - // [other] <---- [this] - - bool registeredUndo = false; - - - // Verify, if default. Not if it's without update - if( linkMethod == LinkingMethod.Default ) { - - if( !SFNCG_Arithmetic.CompatibleTypes( other.valueTypeDefault, this.valueType ) ) { - Debug.LogError( "Incompatible types: Type A: " + other.valueTypeDefault + " Type B: " + this.valueType ); - //ThrowLinkError(); - //other.ResetValueType(); - return; - } - - if(registerUndo && !registeredUndo){ - - string undoMsg = "connect " + other.node.nodeName + "["+other.label+"] <-- ["+ this.label +"]" + this.node.nodeName; - - this.node.UndoRecord(undoMsg); - other.node.UndoRecord(undoMsg); - - //Undo.RecordObject(this,undoMsg); - //Undo.RecordObject(other,undoMsg); - - registeredUndo = true; - - } - - // In case there's an existing one - if( other.IsConnected() ) - other.Disconnect(true,false,reconnection:true); - - } - - if(registerUndo && !registeredUndo){ - string undoMsg = "connect " + other.node.nodeName + "["+other.label+"] <-- ["+ this.label +"]" + this.node.nodeName; - this.node.UndoRecord(undoMsg); - other.node.UndoRecord(undoMsg); - //Undo.RecordObject(this,undoMsg); - //Undo.RecordObject(other,undoMsg); - - registeredUndo = true; - } - - //Debug.Log("Linking " + other.node.nodeName + "["+other.label+"] <--- ["+ this.label +"]" + this.node.nodeName ); - - - - // Connect - other.valueType = this.valueType; - other.inputCon = this; - - - - // TODO: Force types in connector group! - //if( linkMethod == LinkingMethod.Default ) { - if( other.node.conGroup != null ) - other.node.conGroup.Refresh(); - //} - - - this.outputCons.Add( other ); - - other.SetVisChildVisible(true); - - if( linkMethod == LinkingMethod.Default ) { - node.RefreshValue();// OnUpdateNode( NodeUpdateType.Soft, false ); // Update this value - other.node.OnUpdateNode(); // Update other, and following - - } - - other.conLine.ReconstructShapes(); - - } - - - // This is currenly meant to propagate its value type to its link partner - public void SetValueType(ValueType vt){ - if(conType == ConType.cOutput && this.valueType != vt){ - - this.valueType = vt; - foreach(SF_NodeConnector con in this.outputCons){ - if(con.valueTypeDefault == ValueType.VTvPending){ - con.valueType = this.valueType; - con.node.OnUpdateNode(); - } - } - } - } - - public void SetValueTypeAndDefault( ValueType vt ) { - SetValueType( vt ); - valueType = vt; - valueTypeDefault = vt; - } - - public bool IsConnectionHovering(bool world = true){ - - bool active = enableState == EnableState.Enabled && availableState == AvailableState.Available; - //bool free = !IsConnected(); - bool hoveringPending = SF_NodeConnector.IsConnecting() && Hovering(world) && !UnconnectableToPending(); - - return (active && /*free &&*/ hoveringPending); - } - - public bool IsDeleteHovering(bool world = true){ - - if(!IsConnected()) - return false; // There's no link to delete to begin with - if(!Hovering(world)) - return false; // You aren't hovering at all - if(node.editor.nodeView.selection.boxSelecting) - return false; // You're in the middle of a box selection - if(node.editor.nodeView.isCutting) - return false; // We're already doing a cut-deletion, don't mark it for click-deletion - - if(SF_NodeConnector.IsConnecting()){ - - if(SF_NodeConnector.pendingConnectionSource == this) - return false; // Hovering the pending connection, don't mark it for delete - - if(!UnconnectableToPending() && this.conType == ConType.cInput) - return true; // This will be a relink-delete! - } - - - - if(SF_GUI.HoldingAlt()) - return true; // RMB delete - - - return false; - } - - public Color GetConnectorColorRGB() { - - - bool delHov = IsDeleteHovering(); - bool conHov = IsConnectionHovering(true); - - if(conHov){ - return Color.green; - } else if(delHov){ - return Color.red; - } - - if( enableState != EnableState.Enabled ) - return Color.gray; - - //if( IsConnected() ) // DEBUG - // return Color.yellow; - - Color unselected = color; - - if( node.selected ) - return SF_GUI.selectionColor;//Color.Lerp(unselected, SF_GUI.selectionColor, 0.75f); - return unselected; - } - - public Color GetConnectorColor() { - Color c = GetConnectorColorRGB(); - if( DisplayAsValid() ) - c.a = SF_GUI.ProSkin ? 1f : 0.5f; - else - c.a = SF_GUI.ProSkin ? 0.25f : 0.125f; - return c; - } - - - public bool DisplayAsValid() { - return enableState == EnableState.Enabled && availableState == AvailableState.Available && (!UnconnectableToPending() || this == SF_NodeConnector.pendingConnectionSource); - } - - bool canValidlyConnectToPending = false; - - public void UpdateCanValidlyConnectToPending() { - canValidlyConnectToPending = CanValidlyConnectTo( SF_NodeConnector.pendingConnectionSource ); - } - - public bool UnconnectableToPending() { - if(enableState != EnableState.Enabled || availableState == AvailableState.Unavailable) - return true; - if(SF_NodeConnector.pendingConnectionSource == this) - return true; - if( SF_NodeConnector.pendingConnectionSource != null ) { - if( SF_NodeConnector.pendingConnectionSource != this ) - if( !canValidlyConnectToPending ) - return true; - } - return false; - } - - - public bool ValidlyPendingChild(){ - return (IsChild() && visControlParent.IsConnected() && CanConnectToPending() && enableState == EnableState.Enabled); - } - - public bool CanConnectToPending(){ - return SF_NodeConnector.pendingConnectionSource != null && !UnconnectableToPending(); - } - - public bool IsChild(){ - return visControlParent != null; - } - - - - - public bool ShouldBeInvisible(){ - bool hidden = enableState == EnableState.Hidden; - - bool isUnconnectedChild = IsChild() && !IsConnected(); - bool isHiddenExtraConnector = isUnconnectedChild && !ValidlyPendingChild(); - - if( isUnconnectedChild && node.ExhaustedOptionalInputs() ) - return true; - - if( hidden ){ - return true; - } else if(isHiddenExtraConnector){ // If it's flagged as enabled, but is an unconnected child, only draw it when it's either connected or has a pending valid connection - return true; - } else if( node.editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred && !node.availableInDeferredPrePass){ - if(IsConnected()){ - Disconnect(true); - } - return true; - } - return false; - } - - public const int defaultConnectorWidth = 25; - - public void Draw( Vector2 pos ) { - - bool isUnconnectedChild = IsChild() && !IsConnected(); - - if(ShouldBeInvisible()) - return; - - - // Don't draw if invalid - - rect = new Rect( pos.x, pos.y, defaultConnectorWidth, 14 ); - - if( conType == ConType.cInput ) { - rect.x -= node.rect.width + rect.width; - } - - if( conType == ConType.cInput ) { - rect.xMin -= node.extraWidthInput; - } else { - rect.width += node.extraWidthOutput; - } - - - - //GUIStyle cStyle = conType == ConType.cInput ? EditorStyles.miniButtonRight : EditorStyles.miniButtonLeft; - //GUIStyle cStyle = (GUIStyle)"ShurikenModuleTitle"; - - - - - - if(!DisplayLock()){ - GUI.color = GetConnectorColor(); - GUI.Box( rect, string.Empty ); - if( SF_GUI.ProSkin ) { - GUI.Box( rect, string.Empty ); - GUI.Box( rect, string.Empty ); - GUI.Box( rect, string.Empty ); - } - } - - if( SF_GUI.ProSkin ){ - GUI.color = DisplayAsValid() ? Color.white : Color.grey; - } else { - GUI.color = DisplayAsValid() ? Color.white : new Color(1f,1f,1f,0.25f); - } - - bool showConditionA = !(Hovering(true) && canValidlyConnectToPending); - bool showConditionB = !(SF_NodeConnector.pendingConnectionSource == this); - - if( HasErrors() && (showConditionA && showConditionB) ) { - Rect iconRect = new Rect( rect ); - iconRect.x -= SF_Styles.IconErrorSmall.width ; - iconRect.height = iconRect.width = 16; - iconRect.y -= 1; - GUI.DrawTexture( iconRect, SF_Styles.IconErrorSmall ); - } - - - - Rect labelRect = rect; - - - if( SF_Debug.nodes ) { - Rect typeRect = rect; - typeRect.width *= 3f; - - if( conType == ConType.cInput ) { - GUI.skin.label.alignment = TextAnchor.MiddleLeft; - typeRect.x += rect.width; - } else { - GUI.skin.label.alignment = TextAnchor.MiddleRight; - typeRect.x -= typeRect.width; - } - - GUI.Label( typeRect, valueType.ToString() ); - GUI.skin.label.alignment = TextAnchor.MiddleLeft; - } - - - - - if( outerLabel ) { - labelRect.width = node.rect.width; - //labelRect.x -= EditorStyles.miniLabel.CalcSize( new GUIContent( label ) ).x + 4; - labelRect.x += rect.width + 4; - } - - - - GUI.Label( labelRect, isUnconnectedChild ? "+" : label,isUnconnectedChild ? EditorStyles.boldLabel : SF_Styles.MiniLabelOverflow ); - - - if(DisplayLock()){ - Rect lockRect = labelRect; - lockRect.xMin = node.rect.xMin-lockRect.height-3; - lockRect.xMax = node.rect.xMax; - lockRect.yMin -= 3; - lockRect.yMax += 4; - GUI.color = new Color(0.8f,0.8f,0.8f,0.3f); - GUI.Box(lockRect,string.Empty,GUI.skin.button); - GUI.color = Color.white; - //GUI.color = Color.white; - //GUI.Label(lockRect,"//"); - //GUI.drawe - //GUI.Box(lockRect, "", ); - if(Event.current.type == EventType.repaint){ - SF_GUI.DrawLock(lockRect.PadTop(4),"Unavailable when using deferred rendering", TextAlignment.Right ); - - } - - } - - - CheckIfDeleted(); - - GUI.color = Color.white; - } - - - public SF_NodeConnector SetAvailable( bool b ) { - availableState = b ? AvailableState.Available : AvailableState.Unavailable; - return this; - } - - public bool HasErrors() { - if( required && !IsConnectedAndEnabled() ) { - return true; - } - return false; - } - - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnector.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnector.cs.meta deleted file mode 100755 index 3da77e20..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeConnector.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b6b55696f91bd42a186f23376406d9d6 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodePreview.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodePreview.cs deleted file mode 100755 index 0760d8d3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodePreview.cs +++ /dev/null @@ -1,375 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using UnityEditor; -using System; -using System.Linq; - -namespace ShaderForge { - [System.Serializable] - public class SF_NodePreview : ScriptableObject { - - public static int R = 0; - public static int G = 1; - public static int B = 2; - public static int A = 3; - - // The color representation - public RenderTexture texture; // RGBA combined - public RenderTexture[] textureChannels; // RGBA separated, created on-demand - - // Icons, if any - public Texture2D[] icons; - public Texture2D iconActive; - - public void SetIconId(int id){ - iconActive = icons[id]; - } - - - public Color iconColor = Color.white; - - // Whether or not it's uniform - // Vectors (Uniform = Same color regardless of position) - // Textures (Non-Uniform = Different color based on position)) - public bool uniform = false; - public bool coloredAlphaOverlay = false; // Used to render two images on top of eachother, as in the fog node - //public float[] dataUniform; - public Vector4 dataUniform; - public Color dataUniformColor{ - get { return (Color)dataUniform; } - } - - // My material node, used to get operators - public SF_Node node; - - // The amount of components used (1-4) // THIS SHOULDN'T BE USED. USE CONNECTOR COMP COUNT INSTEAD - [SerializeField] - private int compCount = 1; - public int CompCount { - get { return compCount; } - set { - if(compCount == value) - return; - if( value > 4 || value < 1 ) { - //Debug.LogError( "Component count out of range: " + value + " on " + node.nodeName + " " + node.id ); - compCount = 4; - } else { - compCount = value; - } - } - } - - - - public SF_NodePreview() { - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - - if( texture == null ) { - InitializeTexture(); - if(node) - node.RefreshValue(); - } - - } - - public RenderTexture CreateNewNodeRT() { - RenderTexture rt = new RenderTexture( SF_Node.NODE_SIZE, SF_Node.NODE_SIZE, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear ); // TODO: Gamma/Linear? - rt.wrapMode = TextureWrapMode.Clamp; - rt.hideFlags = HideFlags.HideAndDontSave; - return rt; - } - - public SF_NodePreview Initialize( SF_Node node ) { - this.node = node; // Parent - return this; - } - - - public ColorSpace textureColorSpace = ColorSpace.Uninitialized; - - public void InitializeTexture() { - if(texture == null) - texture = CreateNewNodeRT(); - textureColorSpace = QualitySettings.activeColorSpace; - } - - - - public void DestroyTexture() { - if( RenderTexture.active == texture ) - RenderTexture.active = null; - if( texture != null ) { - texture.Release(); - DestroyImmediate( texture ); - } - - if( textureChannels != null ) { - for( int i = 0; i < textureChannels.Length; i++ ) { - if( textureChannels[i] != null ) { - if( RenderTexture.active == textureChannels[i] ) - RenderTexture.active = null; - textureChannels[i].Release(); - DestroyImmediate( textureChannels[i] ); - } - } - } - - iconActive = null; - texture = null; - } - - - - public void LoadAndInitializeIcons(Type type){ - string nodeNameLower = type.Name.ToLower(); - - - iconActive = SF_Resources.LoadNodeIcon(nodeNameLower); // Main icon - - - if(iconActive == null){ - //Debug.Log("No icon found for: " + nodeNameLower); - } else { - // See if additional ones exist, if it found the first - - List iconList = new List(); - iconList.Add(iconActive); - - Texture2D tmp; - for(int i = 2;i<16;i++){ // max 16, to prevent while-loop locking - tmp = SF_Resources.LoadNodeIcon(nodeNameLower + "_" + i); // Search for more - if(tmp == null) - break; - iconList.Add(tmp); - } - - if(iconList.Count > 1) - icons = iconList.ToArray(); - - //while( tmp = - } - } - - public void LoadDataTexture(Type type){ - LoadDataTexture("Data/" + type.Name.ToLower()); - } - - public void LoadDataTexture(Type type, string suffix){ - LoadDataTexture("Data/" + type.Name.ToLower() + "_" + suffix); - } - - public void LoadDataTexture(string path){ - Texture2D nodeIcon = SF_Resources.LoadNodeIcon(path); - SF_Blit.Render( texture, "ReadPackedData", nodeIcon ); - } - - public void GenerateBaseData( bool render3D = true ) { - SF_Blit.mat.SetVector( "_OutputMask", Vector4.one ); - - SF_Blit.currentNode = node; - - if( uniform ) { - BlitUniform(); - return; - } - - if( SF_Settings.nodeRenderMode == NodeRenderMode.Viewport ) { - SF_Blit.RenderUsingViewport( texture, node.GetBlitShaderPath() ); - } else { - if( render3D ) - SF_Blit.RenderUsingViewport( texture, node.GetBlitShaderPath() ); - else - SF_Blit.Render( texture, node.GetBlitShaderPath() ); - } - - - } - - public void BlitUniform() { - SF_Blit.Render(texture, dataUniformColor ); - } - - public void ReadData( Texture2D tex, SF_NodePreview uvTex = null ) { - Graphics.Blit( tex, texture ); - } - - - - - public void OnLostConnection() { - Fill( Color.black ); - } - - public void Fill( Color col ) { - SF_Blit.Render( texture, col ); - } - - public Texture RenderAndGetChannel(int ch){ - if(textureChannels == null) - textureChannels = new RenderTexture[4]; - if( ch < 0 || ch > 3 ) { - Debug.LogError( "RenderAndGetChannel() got invalid channel " + ch + " of node " + node.nodeName + ". Please report this!" ); - } - if( textureChannels[ch] == null ) { - textureChannels[ch] = CreateNewNodeRT(); - } - SF_Blit.matExtractChannel.SetFloat("_Channel", ch); - Graphics.Blit( texture, textureChannels[ch], SF_Blit.matExtractChannel ); - return textureChannels[ch]; - } - - public Texture GetTextureByOutputType( OutChannel ch ) { - if( ch == OutChannel.R ) { - return RenderAndGetChannel( 0 ); - } else if( ch == OutChannel.G ) { - return RenderAndGetChannel( 1 ); - } else if( ch == OutChannel.B ) { - return RenderAndGetChannel( 2 ); - } else if( ch == OutChannel.A ) { - return RenderAndGetChannel( 3 ); - } - return texture; - } - - - // When evaluating nodes, run the overridden operator from the node itself - public void Combine( /*SF_NodePreview a, SF_NodePreview b */) { - - // Check if it can combine first - if( !node.CanEvaluate() ) { - Debug.LogError( "Cannot evaluate" ); - Fill( Color.black ); - return; - } - - CompCount = node.GetEvaluatedComponentCount(); - - // It can combine! Since this node is dynamic, adapt its component count - //CompCount = Mathf.Max( a.CompCount, b.CompCount ); - - - uniform = node.IsUniformOutput(); - - // Combine the node textures, unless we're quickloading or don't want to load them - - dataUniform = node.EvalCPU(); - - SF_Blit.currentNode = node; - - //if( uniform ) { - //BlitUniform(); - //} else { - string shaderPath = node.GetBlitShaderPath(); - Texture[] inputTextures = node.ConnectedInputs.Select( x => x.inputCon.node.texture.GetTextureByOutputType( x.inputCon.outputChannel ) ).ToArray(); - string[] inputNames = node.ConnectedInputs.Select( x => x.strID ).ToArray(); - //OutChannel[] inputChannels = node.ConnectedInputs.Select( x => x.inputCon.outputChannel ).ToArray(); - if( SF_Settings.nodeRenderMode == NodeRenderMode.Viewport ) { - SF_Blit.RenderUsingViewport( texture, shaderPath, inputNames, inputTextures ); - } else if( SF_Settings.nodeRenderMode == NodeRenderMode.Mixed ) { - SF_Blit.Render( texture, shaderPath, inputNames, inputTextures ); - } - - //} - - - - - - - /* - if(!SF_Parser.quickLoad && SF_Settings.DrawNodePreviews) { - for( int y = 0; y < SF_NodeData.RES; y++ ) { - for( int x = 0; x < SF_NodeData.RES; x++ ) { - Color retVector = node.NodeOperator( x, y ); - for( int c = 0; c < 4; c++ ) { - data[x, y, c] = retVector[c]; - } - } - } - }* - - // Combine uniform - /*for( int i = 0; i < 4; i++ ) { - dataUniform[i] = node.NodeOperator( 0, 0, i ); - }*/ - - - - - } - - - - public void Draw( Rect r , bool dim = false) { - if( iconActive != null ) { - if(node is SFN_Final){ // Large node image - Rect tmp = new Rect(r.x,r.y-1, iconActive.width, iconActive.height); - GUI.color = new Color(1f,1f,1f,node.selected ? 1f : 0.5f); - GUI.DrawTexture( tmp, iconActive, ScaleMode.ScaleToFit, true ); - } else if( coloredAlphaOverlay ) { - GUI.DrawTexture( r, icons[0] ); - GUI.color = ConvertToDisplayColor( dataUniform, true ); - GUI.DrawTexture( r, icons[1], ScaleMode.ScaleToFit, true ); - } else { - GUI.color = iconColor; - if( dim ) { - GUI.color = new Color( GUI.color.r, GUI.color.g, GUI.color.b, 0.5f ); - } - GUI.DrawTexture( r, iconActive ); - } - GUI.color = Color.white; - } else if( uniform ) { - GUI.color = ConvertToDisplayColor( dataUniform, true ); - GUI.DrawTexture( r, EditorGUIUtility.whiteTexture ); - GUI.color = Color.white; - } else { - GUI.DrawTexture( r, texture, ScaleMode.ScaleAndCrop, false ); - if(node.displayVectorDataMask){ - GUI.DrawTexture( r, SF_GUI.VectorIconOverlay, ScaleMode.ScaleAndCrop, true); - } - } - - } - - public static float[] ColorToFloatArr( Color c ) { - return new float[] { c.r, c.g, c.b, c.a }; - } - - public Color ConvertToDisplayColor( Color fa, bool forceVisible = false ) { - if( CompCount == 1 ) { - return new Color( fa[0], fa[0], fa[0], forceVisible ? 1f : fa[0] ); - } else if( CompCount == 2 ) { - return new Color( fa[0], fa[1], 0f, forceVisible ? 1f : 0f ); - } else if( CompCount == 3 ) { - return new Color( fa[0], fa[1], fa[2], forceVisible ? 1f : 0f ); - } - return new Color( fa[0], fa[1], fa[2], forceVisible ? 1f : fa[3] ); - } - - - - public bool CanCombine( SF_NodePreview a, SF_NodePreview b ) { - if( a.CompCount == b.CompCount ) - return true; - if( a.CompCount == 1 || b.CompCount == 1 ) - return true; - return false; - } - - - - - - - - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodePreview.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodePreview.cs.meta deleted file mode 100755 index f4c450f6..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodePreview.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 545752616b7004630871f3aba6d251d6 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeStatus.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeStatus.cs deleted file mode 100755 index 5fd90d2c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeStatus.cs +++ /dev/null @@ -1,55 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - [System.Serializable] - public class SF_NodeStatus : ScriptableObject { - - public SF_Node node; - public SF_NodeStatus Initialize( SF_Node node ) { - this.node = node; - Reset(); - return this; - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - - public bool leadsToFinal; // Whether or not this is in the end, used - - public void Reset() { - leadsToFinal = false; - } - - - - - public void SetLeadsToFinalRecursively(bool all = false, bool passDependent = true) { - leadsToFinal = true; - //Debug.Log("Checking if " + node.nodeName + " leads to final..."); - foreach( SF_NodeConnector con in node.connectors ) { - if( con.conType == ConType.cOutput ) - continue; - if( !con.IsConnected() ) - continue; - //if( !con.IsConnectedEnabledAndAvailable() ) // Don't process data in disabled inputs, although maybe we should? - //continue; - if( passDependent && con.SkipPasses.Contains( SF_Evaluator.currentPass ) && !all ) // So it's enabled and all - But does this pass even use it? - continue; - con.inputCon.node.status.SetLeadsToFinalRecursively(); - } - //Debug.Log("Yep, " + node.nodeName + " leads to final!"); - } - - - - - - - - - } - -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeStatus.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeStatus.cs.meta deleted file mode 100755 index e870c69f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeStatus.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 08efc211a31014f9db3606a96039defd -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeTreeStatus.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeTreeStatus.cs deleted file mode 100755 index 40db03be..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeTreeStatus.cs +++ /dev/null @@ -1,494 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System.Linq; - - - -namespace ShaderForge { - - [System.Serializable] - public class SF_NodeTreeStatus : ScriptableObject { - - public SF_Editor editor; - [SerializeField] List errors; - public List Errors { - get { - if( errors == null ) - errors = new List(); - return errors; - } - set { - errors = value; - } - } - - - - public bool mipInputUsed = false; // If this is true, only DX is allowed :< OR: Enable glsl pragma - public bool texturesInVertShader = false; - public bool viewDirectionInVertOffset = false; - public bool usesSceneData = false; - // public bool lightNodesUsed = false; // Used to re-enable light settings when shader is set to unlit - - - - // Contains references to all nodes with properties - // Used in the pass settings listing - public List propertyList = new List(); - - - public bool CanDisplayInstructionCount { - get { - bool dx = ( editor.statusBox.platform == RenderPlatform.d3d9 || editor.statusBox.platform == RenderPlatform.d3d11 ); - return !( mipInputUsed && !dx ); - } - - } - - - - public string SerializeProps() { - string s = "proporder:"; - for( int i = 0; i < propertyList.Count; i++ ) { - if( i != 0 ) - s += "-"; - s += propertyList[i].id.ToString(); - } - return s; - } - - public void DeserializeProps( string s ) { - //Debug.Log("Deserializing properties = " + s); - string[] split = s.Split( '-' ); - propertyList = new System.Collections.Generic.List(); - for( int i = 0; i < split.Length; i++ ) { - //Debug.Log("Found " + GetNodeByID( int.Parse( split[i] )).nodeName); - //Debug.Log ("Attempting deserialization. int parse of ["+split[i]+"]"); - - SF_Node foundNode = GetNodeByID( int.Parse( split[i] ) ); - if( foundNode != null ) - propertyList.Add( foundNode ); - - } - } - - public SF_Node GetNodeByID( int id ) { - foreach( SF_Node n in editor.nodes ) { - if( n.id == id ) - return n; - } - Debug.LogError( "Property node with ID " + id + " not found while deserializing, removing..." ); - return null; - } - - - - - - - public SF_NodeTreeStatus Initialize( SF_Editor editor ) { - this.editor = editor; - return this; - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - - public bool CheckCanCompile() { - - editor.nodeView.RefreshRelaySources(); - - if( Errors == null ){ - Errors = new List(); - } else if( Errors.Count > 0 ) { - for( int i = 0; i < Errors.Count; i++ ) { - DestroyImmediate( Errors[i] ); - } - Errors.Clear(); - } - - - - List cNodes = GetListOfConnectedNodesWithGhosts( out editor.shaderEvaluator.ghostNodes ); - - - // If any properties are now outside the node graph, remove them from the property list - /*if(!SF_Parser.settingUp) - for( int i = propertyList.Count - 1; i >= 0; i-- ) { - if( !cNodes.Contains( propertyList[i] ) ) { - propertyList.RemoveAt( i ); - } - }*/ - - - //if( editor.shaderEvaluator.ghostNodes != null ) - //Debug.Log( "Ghost nodes: " + editor.shaderEvaluator.ghostNodes.Count ); - - texturesInVertShader = false; - bool foundMipUsed = false; - //SF_Node mipNode = null; - usesSceneData = false; - - bool hasFacingNode = false; - - foreach( SF_Node n in cNodes ) { - - // Refresh property list - if( n.IsProperty() ) { - if( !n.IsGlobalProperty() ) { - // Add if it's local and doesn't contain it already - if( !propertyList.Contains( n ) ) { - propertyList.Add( n ); - } - } else { - // Remove it if it's global and inside the list - if( propertyList.Contains( n ) ) { - propertyList.Remove( n ); - } - } - } - - if( n is SFN_SceneColor ) { - usesSceneData = true; - } - - if( n is SFN_FaceSign ) { - hasFacingNode = true; - } - - - if( n is SFN_Tex2d || n is SFN_Cubemap ) { // Check MIP input - if( n.GetInputIsConnected( "MIP" ) ) { - foundMipUsed = true; - //mipNode = n; - } - } - - //if(SF_Debug.dynamicNodeLoad) - if( SF_Editor.NodeExistsAndIs( n, "SFN_SkyshopSpec" ) ) { - //if(n.GetInputIsConnected("GLOSS")){ - foundMipUsed = true; - //mipNode = n; - //} - } - - - - - - foreach( SF_NodeConnector con in n.connectors ) { - if( con.conType == ConType.cOutput ) - continue; - if( con.required && !con.IsConnected() ) { - string err = "Missing required"; - err += string.IsNullOrEmpty( con.label ) ? " " : " [" + con.label + "] "; - err += "input on " + con.node.nodeName; - Errors.Add( SF_ErrorEntry.Create( err, con, false ) ); - } - } - } - - - - // WARNINGS - - if( editor.ps.catBlending.autoSort ) { - - bool alphaConnected = editor.ps.HasAlpha(); - - - - if( editor.ps.catLighting.transparencyMode == SFPSC_Lighting.TransparencyMode.Fade ) { - - bool usingAlphaBlend = editor.ps.catBlending.blendSrc == BlendMode.SrcAlpha && editor.ps.catBlending.blendDst == BlendMode.OneMinusSrcAlpha; - - if( alphaConnected && !usingAlphaBlend ) { - SF_ErrorEntry error = SF_ErrorEntry.Create( "Opacity is connected, but your shader isn't alpha blended, which is required by the fade transparency mode. Click the icon to make it alpha blended!", true ); - error.action = () => { - UnityEditor.Undo.RecordObject( editor.ps.catBlending, "error correction" ); - editor.ps.catBlending.blendModePreset = BlendModePreset.AlphaBlended; - editor.ps.catBlending.ConformBlendsToPreset(); - }; - Errors.Add( error ); - } - - if( !alphaConnected && usingAlphaBlend ) { - SF_ErrorEntry error = SF_ErrorEntry.Create( "Opacity is not connected, but your shader is alpha blended. Click the icon to make it opaque!", true ); - error.action = () => { - UnityEditor.Undo.RecordObject( editor.ps.catBlending, "error correction" ); - editor.ps.catBlending.blendModePreset = BlendModePreset.Opaque; - editor.ps.catBlending.ConformBlendsToPreset(); - }; - Errors.Add( error ); - } - } - - - - - - if( editor.ps.catLighting.transparencyMode == SFPSC_Lighting.TransparencyMode.Reflective ) { - - bool usingAlphaBlendPremul = editor.ps.catBlending.blendSrc == BlendMode.One && editor.ps.catBlending.blendDst == BlendMode.OneMinusSrcAlpha; - - if( alphaConnected && !usingAlphaBlendPremul ) { - SF_ErrorEntry error = SF_ErrorEntry.Create( "Opacity is connected, but your shader isn't using premultiplied alpha blending, which is required by the reflective transparency mode. Click the icon to use premultiplied alpha blending!", true ); - error.action = () => { - UnityEditor.Undo.RecordObject( editor.ps.catBlending, "error correction" ); - editor.ps.catBlending.blendModePreset = BlendModePreset.AlphaBlendedPremultiplied; - editor.ps.catBlending.ConformBlendsToPreset(); - }; - Errors.Add( error ); - } - - if( !alphaConnected && usingAlphaBlendPremul ) { - SF_ErrorEntry error = SF_ErrorEntry.Create( "Opacity is not connected, but your shader is using premultiplied alpha blending. Click the icon to make it opaque!", true ); - error.action = () => { - UnityEditor.Undo.RecordObject( editor.ps.catBlending, "error correction" ); - editor.ps.catBlending.blendModePreset = BlendModePreset.Opaque; - editor.ps.catBlending.ConformBlendsToPreset(); - }; - Errors.Add( error ); - } - } - - - - } - - - - - /* - true, // - Direct3D 9 - true, // - Direct3D 11 - true, // - OpenGL - true, // - OpenGL ES 2.0 - false, // - Xbox 360 - false, // - PlayStation 3 - false, // - Flash - false // - Direct3D 11 for Windows RT - */ - bool osx = Application.platform == RuntimePlatform.OSXEditor; - bool windows = !osx; - bool ogl = editor.ps.catMeta.usedRenderers[2]; - bool dx9 = editor.ps.catMeta.usedRenderers[0]; - bool dx11 = editor.ps.catMeta.usedRenderers[1]; - -#if UNITY_5_0 - bool inDx11Mode = UnityEditor.PlayerSettings.useDirect3D11; -#else - bool inDx11Mode = true; -#endif - - if( osx && !ogl ) { - SF_ErrorEntry error = SF_ErrorEntry.Create( "Your shader will not render properly on your workstation - you need to have OpenGL enabled when working in OSX. Click the icon to enable OpenGL!", true ); - error.action = () => { - UnityEditor.Undo.RecordObject( editor.ps.catMeta, "error correction - enable OpenGL" ); - editor.ps.catMeta.usedRenderers[2] = true; - editor.OnShaderModified( NodeUpdateType.Hard ); - }; - Errors.Add( error ); - } else if( windows ) { - if( inDx11Mode && !dx11 ) { - SF_ErrorEntry error = SF_ErrorEntry.Create( "Your shader might not render properly on your workstation - you need to have Direct3D 11 enabled when working in DX11 mode on Windows. Click the icon to enable Direct3D 11!", true ); - error.action = () => { - UnityEditor.Undo.RecordObject( editor.ps.catMeta, "error correction - enable Direct3D 11" ); - editor.ps.catMeta.usedRenderers[1] = true; - editor.OnShaderModified( NodeUpdateType.Soft ); - }; - Errors.Add( error ); - } else if( !inDx11Mode && !dx9 ) { - SF_ErrorEntry error = SF_ErrorEntry.Create( "Your shader might not render properly on your workstation - you need to have Direct3D 9 enabled when working on Windows. Click the icon to enable Direct3D 9!", true ); - error.action = () => { - UnityEditor.Undo.RecordObject( editor.ps.catMeta, "error correction - enable Direct3D 9" ); - editor.ps.catMeta.usedRenderers[0] = true; - editor.OnShaderModified( NodeUpdateType.Soft ); - }; - Errors.Add( error ); - } - } - - - - - - if( editor.ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL ) { - if( editor.ps.HasDiffuse() && !editor.ps.HasSpecular() ) { - Errors.Add( SF_ErrorEntry.Create( "Using PBL requires metallic/specular to be connected", false ) ); - } - if( !editor.ps.HasDiffuse() && editor.ps.HasSpecular() ) { - Errors.Add( SF_ErrorEntry.Create( "Using PBL requires metallic/specular to be connected", false ) ); - } - } - - - - - - - - - List dupes = new List(); - SF_Node[] propNodes = cNodes.Where(x=>x.IsProperty()).ToArray(); - for( int i = 0; i < propNodes.Length; i++ ) { - for( int j = i+1; j < propNodes.Length; j++ ) { - string nameA = propNodes[i].property.nameInternal; - string nameB = propNodes[j].property.nameInternal; - - if( nameA == nameB ) { - dupes.Add( propNodes[j] ); - } - - } - } - if( dupes.Count > 0 ) { - foreach( SF_Node dupe in dupes ) { - Errors.Add( SF_ErrorEntry.Create( "You have property nodes with conflicting internal names. Please rename one of the " + dupe.property.nameInternal + " nodes", dupe, false ) ); - } - } - - - - - List dupesVarname = new List(); - for( int i = 0; i < cNodes.Count; i++ ) { - for( int j = i + 1; j < cNodes.Count; j++ ) { - - string nameAvar = cNodes[i].variableName; - string nameBvar = cNodes[j].variableName; - - if( nameAvar == nameBvar && dupes.Contains( cNodes[j] ) == false ) { - dupesVarname.Add( cNodes[j] ); - } - } - } - if( dupesVarname.Count > 0 ) { - foreach( SF_Node dupeVarname in dupesVarname ) { - Errors.Add( SF_ErrorEntry.Create( "You have nodes with conflicting variable names. Please rename one of the " + dupeVarname.variableName + " nodes", dupeVarname, false ) ); - } - } - - - // Make sure you set the shader to double sided - if( !editor.ps.catGeometry.IsDoubleSided() && hasFacingNode ) { - SF_ErrorEntry error = SF_ErrorEntry.Create( "You are using the Face Sign node, but your shader isn't double-sided. Click the icon to fix", false ); - error.action = () => { - UnityEditor.Undo.RecordObject( editor.ps.catGeometry, "error correction - fix double sided" ); - editor.ps.catGeometry.cullMode = SFPSC_Geometry.CullMode.DoubleSided; - editor.OnShaderModified( NodeUpdateType.Hard ); - }; - Errors.Add( error ); - } - - - - - - - // Check if there are any textures in the vertex input - texturesInVertShader = HasNodeInput( editor.mainNode.vertexOffset ) || HasNodeInput( editor.mainNode.outlineWidth ); - viewDirectionInVertOffset = HasNodeInput( editor.mainNode.vertexOffset ); - - - - editor.shaderEvaluator.RemoveGhostNodes(); - - - if( foundMipUsed ) { - //if( !mipInputUsed ) // This should be fixed with #pragma glsl - // errors.Add( new SF_ErrorEntry( "MIP input is only supported in Direct X", mipNode ) ); - mipInputUsed = true; - } else { - mipInputUsed = false; - } - - - int errorCount = Errors.Count( x => !x.isWarning ); // Let it compile, even though it has warnings - - if( errorCount == 0 ) - return true; - //DisplayErrors(); - return false; - } - - private bool ConnectedNodeWithInternalNameExists( List cNodes, string s ) { - foreach( SF_Node n in cNodes.Where( x => x.IsProperty() ) ) { - if( n.property.nameInternal == s ) { - return true; - } - } - return false; - } - - - - public bool HasNodeInput( SF_NodeConnector con ) { - - if( con.IsConnectedEnabledAndAvailable() ) { - - if( con.inputCon.node is T ) { - return true; - } - - // Recursively loop through inputs of the connnected node - foreach( SF_NodeConnector c in con.inputCon.node.connectors ) { - if( c.conType == ConType.cOutput ) - continue; - if( !c.IsConnected() ) - continue; - if( HasNodeInput( c ) ) { - return true; - } - } - - } - return false; - } - - - - - - // Returns all nodes connected to the final node - public List GetListOfConnectedNodesWithGhosts( out List ghosts, bool passDependent = false ) { - //Debug.Log ("GetListOfConnectedNodesWithGhosts()"); - ResetAllNodeStatuses(); - editor.mainNode.status.SetLeadsToFinalRecursively( all: false, passDependent: passDependent ); - List filtered = new List(); - foreach( SF_Node n in editor.nodes ) { - if( n.status.leadsToFinal ) - filtered.Add( n ); - } - - // Now that's done, let's return the ghost nodes too, if any - editor.shaderEvaluator.RemoveGhostNodes(); // TODO: Really? - ghosts = new List(); - - foreach( SF_Node n in filtered ) { - n.DefineGhostsIfNeeded( ref ghosts ); - } - - //Debug.Log ("GetListOfConnectedNodesWithGhosts, ghosts.Count: " + ghosts.Count); - - filtered.AddRange( ghosts ); - - return filtered; - } - - // Resets all node statuses - public void ResetAllNodeStatuses() { - foreach( SF_Node n in editor.nodes ) { - n.status.Reset(); - } - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeTreeStatus.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeTreeStatus.cs.meta deleted file mode 100755 index 34b8e4db..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_NodeTreeStatus.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9e9cc643ea4c843b2a52e98a499ad6bc -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Parser.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Parser.cs deleted file mode 100755 index 8927fb0d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Parser.cs +++ /dev/null @@ -1,280 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.IO; -using System; -using System.Linq; -using System.Collections.Generic; - -namespace ShaderForge { - public static class SF_Parser { - - public static SF_Editor editor; - static List links; - public static bool quickLoad = false; - public static bool settingUp = false; - - - - - - /* - static void Temp() { - byte maj = 2; - byte min = 6; - - int combined = InternalVersion(maj,min); - Debug.Log( "Combined: " + combined ); - Debug.Log( "Resplit: " + ExternalVersion( combined ) ); - - } - - public static string ExternalVersion( int internalVersion ) { - byte oMaj = (byte)( internalVersion >> 8 ); - byte oMin = (byte)( internalVersion & 0x0000ffff ); - return oMaj + "." + oMin.ToString( "D2" ); - } - - public static int InternalVersion( byte maj, byte min ) { - return ( ( maj << 8 ) & 0xffff ) | min; - } - * */ - - - public static bool SerializedNodeIsProperty( string s ){ - return s.Contains(",ptlb:"); // Property label - } - - public static bool ParseNodeDataFromShader( SF_Editor editor, Shader s ) { - SF_Parser.editor = editor; - SF_Parser.links = new List(); - // Search for Shader Forge data - float version; - string data = ExtractShaderForgeData( s, out version ); - if( string.IsNullOrEmpty( data ) ) { - editor.CreateOutputNode(); - return true; // Empty shader - } - string missingNode; - bool didLoadFlawlessly = LoadFromNodeData( data, version, out missingNode ); - - if( !didLoadFlawlessly ) { - EditorUtility.DisplayDialog( "Failed to load shader", "Failed to open shader due to missing the node [" + missingNode + "]", "Close" ); - editor.Close(); -// editor.Init(); - //editor.closeMe = true; - //editor.initialized = false; - //SF_Editor.instance = null; - //editor.Close(); - return false; - } - - return true; - - } - - - - - private static bool LoadFromNodeData( string data, float version, out string missingNode ) { - // First, split by rows (;) - missingNode = ""; - string[] rows = data.Split( ';' ); // TODO: Escape ; and | characters in user created comments! - - // TODO: Subshaders etc - SF_Parser.settingUp = true; - SF_Parser.quickLoad = true; - foreach( string row in rows ) { - if( row.StartsWith( "n:" ) ) { - //Debug.Log("Deserializing node:" + row); - SF_Node node = SF_Node.Deserialize( row.Substring( 2 ), ref links ); - if( node == null ) { - missingNode = row.Substring( 2 ).Split(',')[0].Split(':')[1]; - SF_Parser.settingUp = false; - SF_Parser.quickLoad = false; - return false; // Interrupt node loading, node wasn't found - } - continue; - } - if( row.StartsWith( "ps:" ) ) { - editor.ps.Deserialize( row.Substring( 3 ) ); - continue; - } - if( row.StartsWith( "proporder:" ) ) { - editor.nodeView.treeStatus.DeserializeProps( row.Substring(10) ); - continue; - } - } - - // Create all node links - for( int i = 0; i < links.Count; i++ ) { - links[i].Establish( editor ); - } - - - // If this was created in a version older than 0.37, reverse the node tree around its center point - if( version <= 0.36f){ - - Debug.Log("Reversing node tree due to shader being created before the reversal in 0.37"); - - // Average node position - float avgX = editor.nodes.Average(x => x.rect.center.x); - - // Reverse all nodes - foreach(SF_Node node in editor.nodes){ - Vector2 old = node.rect.center; - node.rect.center = new Vector2(2 * avgX - old.x, old.y); - } - - } - - - - //Debug.Log("All links established, hierarchally refreshing..."); - // Refresh hierarchally - - //Profiler.BeginSample ("MyPieceOfCode"); - - //editor.nodeView.HierarchalRefresh(); - - //Profiler.EndSample(); - - - //Debug.Log( "Reconnect pending..." ); - - editor.nodeView.ReconnectConnectedPending(); - SF_Parser.quickLoad = false; - - //Debug.Log( "Reconnect done, updating auto settings..." ); - - // Update auto settings based on everything connected - editor.ps.UpdateAutoSettings(); - - //Debug.Log( "Auto settings done, centering camera..." ); - - // Center camera - editor.nodeView.CenterCamera(); - SF_Parser.settingUp = false; - SF_Parser.quickLoad = false; - - - // Update preview images by refreshing all outermost nodes - editor.nodeView.HierarchalRefresh(); - - //Debug.Log( "Centered camera, recompiling shader..." ); - editor.mainNode.OnUpdateNode( NodeUpdateType.Hard, true ); - - return true; - } - - - - - - - public static string ExtractShaderForgeData( Shader s, out float version, bool setPath = true, bool findRenderers = true, bool findLOD = true) { - - string path = AssetDatabase.GetAssetPath( s ); - string[] shaderData = File.ReadAllLines( path ); - - string returnString = ""; - - version = 0f; - - if( shaderData.Length == 0 || shaderData == null ) { - //Debug.LogWarning( "Shader file empty" ); - return null; - } - - bool found_data = false; - bool found_renderers = !findRenderers; - bool found_path = !setPath; - bool found_LOD = !findLOD; - - - for( int i = 0; i < shaderData.Length; i++ ) { - if(shaderData[i].Contains("Shader created with Shader Forge")){ - string[] split = shaderData[i].Trim().Split(' '); - string verStr = split[split.Length-1]; - - if( verStr.StartsWith( "v" ) ) - verStr = verStr.Substring( 1 ); - - version = float.Parse(verStr); - } - if( shaderData[i].StartsWith( "/*SF_DATA;" ) ) { - returnString = shaderData[i].Substring( 10, shaderData[i].Length - 12 ); // Exclude comment markup - found_data = true; - } - if( setPath ) - if( shaderData[i].StartsWith( "Shader" ) ) { - editor.currentShaderPath = shaderData[i].Split( '\"' )[1]; - found_path = true; - } - if( findRenderers ) { - if( shaderData[i].TrimStart().StartsWith( "#pragma only_renderers" ) ) { - ParseRenderer( shaderData[i].Trim().Split( ' ' ), true); - found_renderers = true; - } else if( shaderData[i].TrimStart().StartsWith( "#pragma exclude_renderers" ) ) { - ParseRenderer( shaderData[i].Trim().Split( ' ' ), false ); - found_renderers = true; - } - } - if( findLOD ) { - if( shaderData[i].TrimStart().StartsWith( "LOD " ) ) { - editor.ps.catMeta.LOD = int.Parse(shaderData[i].Trim().Split( ' ' )[1]); - found_LOD = true; - } - } - - if( found_data && found_path && found_renderers && found_LOD ) - break; - } - - - - if( string.IsNullOrEmpty( returnString ) ) { - //Debug.LogWarning( "Shader did not contain node data" ); - } - - // TODO: check when it was last changed! - // This is where it should ask you if you want to overwrite the existing data, - // if it's older than x minutes - - return returnString; - } - - - public static bool ContainsShaderForgeData(Shader s){ - float version; - string sfData = SF_Parser.ExtractShaderForgeData( s, out version, false, false, false ); - return !string.IsNullOrEmpty( sfData ); - } - - public static void ParseRenderer( string[] arr, bool only ) { - for( int i = 0; i < editor.ps.catMeta.usedRenderers.Length; i++ ) { - editor.ps.catMeta.usedRenderers[i] = !only; // Enable or disable all - } - for( int i = 2; i < arr.Length; i++ ) { // i = 2 to ignore #pragma x_renderers - string rndr = arr[i]; - if( rndr == "flash" ) { - Debug.LogWarning( "Flash is no longer supported by Unity, and was removed from the shader" ); - continue; - } - if( rndr == "ps3" ) { - Debug.LogWarning( "PS3 is no longer supported by Unity since 5.5, and was removed from the shader" ); - continue; - } - if( rndr == "xbox360" ) { - Debug.LogWarning( "Xbox 360 is no longer supported by Unity since 5.5, and was removed from the shader" ); - continue; - } - if( rndr == "opengl" ) { - rndr = "glcore"; - } - int enm = (int)((RenderPlatform)Enum.Parse( typeof( RenderPlatform ), rndr )); - editor.ps.catMeta.usedRenderers[enm] = only; // Disable or enable one - } - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Parser.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Parser.cs.meta deleted file mode 100755 index 5c3d3717..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Parser.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 75956f9dcf7c14856949a94823268bb4 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PassSettings.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PassSettings.cs deleted file mode 100755 index 18d62789..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PassSettings.cs +++ /dev/null @@ -1,414 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; - -namespace ShaderForge { - - - [System.Serializable] - public class SF_PassSettings : ScriptableObject { - - // Mat ed - public SF_Editor editor; - public SF_FeatureChecker fChecker; - - - - - // SERIALIZATION OF VARS - public string Serialize() { - string s = "ps:"; - foreach(SFPS_Category cat in cats){ - s += cat.Serialize(); - } - return s.Substring(0,s.Length-1); - } - - - // TODO: Remove this, keep it in cats - private string Serialize( string key, string value, bool last = false ) { - return key + ":" + value + (last ? "" : ","); - } - - // DESERIALIZATION OF VARS - public void Deserialize(string s) { - string[] split = s.Split(','); - for( int i = 0; i < split.Length; i++ ) { - string[] keyval = split[i].Split(':'); - Deserialize( keyval[0], keyval[1] ); - } - } - - public void Deserialize( string key, string value ) { - foreach(SFPS_Category cat in cats){ - cat.Deserialize(key, value); - } - catBlending.UpdateAutoSort(); - } - - - - - - // END SERIALIZATION - - - // Node/auto vars - public string n_diffuse { - get { return mOut.diffuse.TryEvaluate(); } // Vector3 only - } - public string n_alpha { - get { return mOut.alpha.TryEvaluate(); } - } - public string n_alphaClip { - get { return mOut.alphaClip.TryEvaluate(); } - } - public string n_diffusePower { - get { return mOut.diffusePower.TryEvaluate(); } - } - public string n_gloss { - get { return mOut.gloss.TryEvaluate(); } - } - public string n_specular { - get { return mOut.specular.TryEvaluate(); } // Vector3 only - } - public string n_normals { - get { return mOut.normal.TryEvaluate(); } // Vector3 only - } - public string n_emissive { - get { return mOut.emissive.TryEvaluate(); } // Vector3 only - } - public string n_transmission { - get { return mOut.transmission.TryEvaluate(); } - } - public string n_lightWrap { - get { return mOut.lightWrap.TryEvaluate(); } - } - - public string n_ambientDiffuse { - get { return mOut.ambientDiffuse.TryEvaluate(); } - } - public string n_ambientSpecular { - get { return mOut.ambientSpecular.TryEvaluate(); } - } - public string n_diffuseOcclusion { - get { return mOut.diffuseOcclusion.TryEvaluate(); } - } - public string n_specularOcclusion { - get { return mOut.specularOcclusion.TryEvaluate(); } - } - public string n_customLighting { - get { return mOut.customLighting.TryEvaluate(); } - } - - public string n_outlineWidth { - get { return mOut.outlineWidth.TryEvaluate(); } - } - public string n_outlineColor { - get { return mOut.outlineColor.TryEvaluate(); } - } - public string n_distortion { - get { return mOut.refraction.TryEvaluate(); } - } - public string n_vertexOffset { - get { return mOut.vertexOffset.TryEvaluate(); } - } - public string n_displacement { - get { return mOut.displacement.TryEvaluate(); } - } - public string n_tessellation { - get { return mOut.tessellation.TryEvaluate(); } - } - public SFN_Final mOut { - get { return editor.mainNode; } - } - - - // GUI controls - //const int expIndent = 16; - - public List cats; - public SFPSC_Meta catMeta; - public SFPSC_Properties catProperties; - public SFPSC_Lighting catLighting; - public SFPSC_Geometry catGeometry; - public SFPSC_Blending catBlending; - public SFPSC_Experimental catExperimental; - public SFPSC_Console catConsole; - - // Add more here - - public int maxWidth; - - public SF_PassSettings() { - - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - public SF_PassSettings Initialize( SF_Editor materialEditor ) { - - this.editor = materialEditor; - fChecker = ScriptableObject.CreateInstance().Initialize(this, materialEditor); - - cats = new List(); - cats.Add( catMeta = NewCat ( "Shader Settings" )); - cats.Add( catProperties = NewCat ( "Properties" )); - cats.Add( catLighting = NewCat ( "Lighting" )); - cats.Add( catGeometry = NewCat ( "Geometry" )); - cats.Add( catBlending = NewCat ( "Blending" )); - cats.Add( catExperimental = NewCat ( "Experimental" )); - cats.Add( catConsole = NewCat ( "Console" )); - - return this; - } - - public T NewCat(string label) where T : SFPS_Category{ - return (T)ScriptableObject.CreateInstance().Initialize(this.editor, this, label); - } - - - Rect innerScrollRect = new Rect(0,0,0,0); - Vector2 scrollPos; - - float targetScrollWidth = 0f; - float currentScrollWidth = 0f; - - // Call this from the editor script - public bool guiChanged = false; - public int OnLocalGUI( int yOffset, int in_maxWidth ) { - - - if(Event.current.type == EventType.Repaint) - currentScrollWidth = Mathf.Lerp(currentScrollWidth, targetScrollWidth, 0.3f); - - this.maxWidth = in_maxWidth; - - Rect scrollRectPos = new Rect(0f,yOffset,in_maxWidth,Screen.height/EditorGUIUtility.pixelsPerPoint-yOffset-20); - bool useScrollbar = (innerScrollRect.height > scrollRectPos.height); - - targetScrollWidth = useScrollbar ? 15 : 0; - - int scrollBarWidth = (int)currentScrollWidth; - - - innerScrollRect.width = in_maxWidth-scrollBarWidth; - - guiChanged = false; - - int offset = 0; - - if(innerScrollRect.height < scrollRectPos.height) - innerScrollRect.height = scrollRectPos.height; - - this.maxWidth -= scrollBarWidth; - - int scrollPad = scrollBarWidth-15; - GUI.BeginGroup(scrollRectPos); - Rect scrollWrapper = scrollRectPos; - scrollWrapper.x = 0; - scrollWrapper.y = 0; // Since it's grouped - scrollPos = GUI.BeginScrollView(scrollWrapper.PadRight(scrollPad),scrollPos,innerScrollRect,false,true); - { - //offset = SettingsMeta( 0 ); - bool showErrors = editor.nodeView.treeStatus.Errors.Count > 0; - if( !showErrors ) - catConsole.expanded = false; - EditorGUI.BeginDisabledGroup( !showErrors ); - offset = catConsole.Draw( offset ); - offset = GUISeparator( offset ); // ---------------------------------------------- - EditorGUI.EndDisabledGroup(); - offset = catMeta.Draw( offset ); - offset = GUISeparator( offset ); // ---------------------------------------------- - offset = catProperties.Draw(offset); - offset = GUISeparator( offset ); // ---------------------------------------------- - offset = catLighting.Draw(offset); - offset = GUISeparator( offset ); // ---------------------------------------------- - offset = catGeometry.Draw( offset ); - offset = GUISeparator( offset ); // ---------------------------------------------- - offset = catBlending.Draw(offset); - offset = GUISeparator( offset ); // ---------------------------------------------- - offset = catExperimental.Draw(offset); - offset = GUISeparator( offset ); // ---------------------------------------------- - - } - GUI.EndScrollView(); - GUI.EndGroup(); - this.maxWidth += scrollBarWidth; - - - if( guiChanged ) { - editor.ps = this; - editor.OnShaderModified(NodeUpdateType.Hard); - } - - innerScrollRect.height = offset; - return offset; - - } - - - - private bool prevChangeState; - public void StartIgnoreChangeCheck() { - prevChangeState = EditorGUI.EndChangeCheck(); // Don't detect changes when toggling - } - - public void EndIgnoreChangeCheck() { - EditorGUI.BeginChangeCheck(); // Don't detect changes when toggling - if( prevChangeState ) { - GUI.changed = true; - } - } - - - - public void UpdateAutoSettings(){ - catBlending.UpdateAutoSettings(); - } - - - - public int GUISeparator(int yOffset) { - GUI.Box( new Rect(0,yOffset,maxWidth,1), "", EditorStyles.textField ); - return yOffset + 1; - } - - public bool IsOutlined(){ - return mOut.outlineWidth.IsConnectedEnabledAndAvailable(); - } - - public bool UseClipping() { - return mOut.alphaClip.IsConnectedEnabledAndAvailable(); - } - - public bool HasGloss(){ - return mOut.gloss.IsConnectedEnabledAndAvailable(); - } - - public bool HasNormalMap() { - return mOut.normal.IsConnectedEnabledAndAvailable(); - } - - public bool HasTangentSpaceNormalMap() { - return HasNormalMap() && catGeometry.normalSpace == SFPSC_Geometry.NormalSpace.Tangent; - } - public bool HasObjectSpaceNormalMap() { - return HasNormalMap() && catGeometry.normalSpace == SFPSC_Geometry.NormalSpace.Object; - } - public bool HasWorldSpaceNormalMap() { - return HasNormalMap() && catGeometry.normalSpace == SFPSC_Geometry.NormalSpace.World; - } - - public bool HasRefraction() { - return mOut.refraction.IsConnectedEnabledAndAvailable(); - } - - public bool HasTessellation() { - return mOut.tessellation.IsConnectedEnabledAndAvailable(); - } - public bool HasOutline() { - return mOut.outlineWidth.IsConnectedEnabledAndAvailable(); - } - - public bool HasDisplacement() { - return mOut.displacement.IsConnectedEnabledAndAvailable(); - } - - public bool HasEmissive() { - return mOut.emissive.IsConnectedEnabledAndAvailable(); - } - - public bool HasDiffuse(){ - return mOut.diffuse.IsConnectedEnabledAndAvailable(); - } - - public bool HasAlpha() { - return mOut.alpha.IsConnectedEnabledAndAvailable(); - } - - public bool HasAlphaClip() { - return mOut.alphaClip.IsConnectedEnabledAndAvailable(); - } - - public bool HasSpecular(){ - return mOut.specular.IsConnectedEnabledAndAvailable(); - } - - public bool HasDiffusePower(){ - return mOut.diffusePower.IsConnectedEnabledAndAvailable(); - } - - public bool HasAmbientDiffuse() { - return mOut.ambientDiffuse.IsConnectedEnabledAndAvailable(); - } - - public bool HasAmbientSpecular() { - return mOut.ambientSpecular.IsConnectedEnabledAndAvailable(); - } - - public bool HasAmbientOcclusionDiffuse() { - return mOut.diffuseOcclusion.IsConnectedEnabledAndAvailable(); - } - - public bool HasAmbientOcclusionSpecular() { - return mOut.specularOcclusion.IsConnectedEnabledAndAvailable(); - } - - public bool HasTransmission() { - return mOut.transmission.IsConnectedEnabledAndAvailable(); - } - - public bool HasAddedLight() { - return HasEmissive() || catLighting.HasSpecular(); - } - - public bool HasLightWrapping() { - return mOut.lightWrap.IsConnectedEnabledAndAvailable(); - } - } -} - -/* - public class SF_Serializeable{ - - public string key; - - public SF_Serializeable(){ - - } - - public virtual string Serialize(bool last = false){ - } - - public virtual void Deserialize(string key, string value){ - } - - protected string Serialize( string key, string value, bool last = false ) { - return key + ":" + value + (last ? "" : ","); - } - - } - - public class SFS_Int : SF_Serializeable{ - - int val; - - public SFS_Int(string key){ - this.key = key; - } - - public override string Serialize(bool last = false){ - return Serialize(key,val.ToString(),last); - } - - public override void Deserialize(string key, string value){ - if(key == this.key){ - val = int.Parse(value); - } - } - - }*/ \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PassSettings.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PassSettings.cs.meta deleted file mode 100755 index 929b76b9..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PassSettings.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: dc6ba9da0a5ba4b01a67cbac50456748 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewSettings.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewSettings.cs deleted file mode 100755 index d6d85bf6..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewSettings.cs +++ /dev/null @@ -1,22 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - [System.Serializable] - public class SF_PreviewSettings { - - //public SF_PreviewWindow preview; - - // TODO: Load/Save default settings - - public bool previewAutoRotate = true; - public Color colorBg = SF_GUI.ProSkin ? new Color( 0.2f, 0.2f, 0.2f, 1f ) : new Color( 0.6f, 0.6f, 0.6f, 1f ); - - - public SF_PreviewSettings( SF_PreviewWindow preview ) { - //this.preview = preview; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewSettings.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewSettings.cs.meta deleted file mode 100755 index dc54a197..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewSettings.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 893d44f1243e74fbca6139978a92f372 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewWindow.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewWindow.cs deleted file mode 100755 index 74ff2e0c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewWindow.cs +++ /dev/null @@ -1,506 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Reflection; -using System; - -namespace ShaderForge { - [Serializable] - public class SF_PreviewWindow { - - [SerializeField] - public SF_Editor editor; - [SerializeField] - public SF_PreviewSettings settings; - - // Preview assets - [SerializeField] - public Mesh mesh; - [SerializeField] - public Material internalMaterial; - public Material InternalMaterial { - get { - if(internalMaterial == null){ - internalMaterial = new Material(editor.currentShaderAsset); - } - return internalMaterial; - } - set { - internalMaterial = value; - } - } - - [SerializeField] - public RenderTexture render; // TODO: Why is this separated from the RT itself? - [SerializeField] - GUIStyle previewStyle; - [SerializeField] - public Texture2D backgroundTexture; - - bool previewIsSetUp = false; // Intentionally non-serialized - - - // Input/Rotation - [SerializeField] - public bool isDraggingLMB = false; - [SerializeField] - Vector2 dragStartPosLMB = Vector2.zero; - [SerializeField] - Vector2 rotMeshStart = new Vector2(-30f,0f); - [SerializeField] - Vector2 rotMesh = new Vector2(30f,0f); - [SerializeField] - Vector2 rotMeshSmooth = new Vector2(-30f,0f); - - // Light Input/Rotation - [SerializeField] - public bool isDraggingRMB = false; - - [SerializeField] - public Camera cam; - [SerializeField] - Transform camPivot; - [SerializeField] - Light[] lights; - - //public bool drawBgColor = true; - - Mesh _sphereMesh; - Mesh sphereMesh { - get { - if( _sphereMesh == null ) { - _sphereMesh = GetSFMesh( "sf_sphere" ); - } - return _sphereMesh; - } - } - - // Reflection to call Handles.SetCameraOnlyDrawMesh(this.m_Camera); - MethodInfo mSetCameraOnlyDrawMesh; - - public SF_PreviewWindow( SF_Editor editor ) { - settings = new SF_PreviewSettings( this ); - UpdatePreviewBackgroundColor(); - - this.editor = editor; - this.mesh = GetSFMesh( "sf_sphere" ); - SetupPreview(); - } - - [SerializeField] bool enabled = true; - public void OnEnable() { - enabled = true; - SetupPreview(); - } - public void OnDisable() { - enabled = false; - CleanupObjects(); - } - - public Mesh GetSFMesh(string find_name) { - UnityEngine.Object[] objs = SF_Resources.LoadAll( SF_Resources.pMeshes+"sf_meshes.fbx" ); - if( objs == null ) { - Debug.LogError( "sf_meshes.fbx missing" ); - return null; - } - if( objs.Length == 0 ) { - Debug.LogError( "sf_meshes.fbx missing sub assets" ); - return null; - } - foreach( UnityEngine.Object o in objs ) { - if( o.name == find_name && o.GetType() == typeof(Mesh)) { - return o as Mesh; - } - } - Debug.LogError("Mesh " + find_name + " could not be found in sf_meshes.fbx"); - return null; - } - - - public void SetupPreview() { - - previewIsSetUp = true; - - // Create preview camera - GameObject camObj = new GameObject("Shader Forge Camera"); - camObj.hideFlags = HideFlags.HideAndDontSave; - cam = camObj.AddComponent(); - cam.targetTexture = render; - cam.clearFlags = CameraClearFlags.SolidColor; - cam.renderingPath = RenderingPath.Forward; - cam.enabled = false; - cam.useOcclusionCulling = false; - cam.cameraType = CameraType.Preview; - cam.fieldOfView = targetFOV; - - // Make sure it only renders using DrawMesh, to make ignore the scene. This is a bit risky, due to using reflection :( - BindingFlags bfs = BindingFlags.Static | BindingFlags.NonPublic; - Type[] args = new Type[]{ typeof(Camera) }; - mSetCameraOnlyDrawMesh = typeof( Handles ).GetMethod( "SetCameraOnlyDrawMesh", bfs, null, args, null ); - mSetCameraOnlyDrawMesh.Invoke( null, new object[]{ cam } ); - - // Create pivot/transform to hold it - camPivot = new GameObject("Shader Forge Camera Pivot").transform; - camPivot.gameObject.hideFlags = HideFlags.HideAndDontSave; - cam.clearFlags = CameraClearFlags.Skybox; - cam.transform.parent = camPivot; - - // Create custom light sources - lights = new Light[] { - new GameObject("Light 0").AddComponent(), - new GameObject("Light 1").AddComponent() - }; - for( int i = 0; i < lights.Length; i++ ) { - lights[i].gameObject.hideFlags = HideFlags.HideAndDontSave; - lights[i].type = LightType.Directional; - lights[i].lightmapBakeType = LightmapBakeType.Realtime; - lights[i].enabled = false; - } - - lights[0].intensity = 1f; - lights[0].transform.rotation = Quaternion.Euler( 30f, 30f, 0f ); - lights[1].intensity = 0.75f; - lights[1].color = new Color( 1f, 0.5f, 0.25f ); - lights[1].transform.rotation = Quaternion.Euler( 340f, 218f, 177f ); - } - - void CleanupObjects() { - GameObject.DestroyImmediate( cam.gameObject ); - GameObject.DestroyImmediate( camPivot.gameObject ); - for( int i = 0; i < lights.Length; i++ ) { - GameObject.DestroyImmediate( lights[i].gameObject ); - } - } - - - public bool SkyboxOn{ - get{ - return cam.clearFlags == CameraClearFlags.Skybox; - } - set{ - if(SF_Debug.renderDataNodes) - cam.clearFlags = CameraClearFlags.Depth; - else - cam.clearFlags = value ? CameraClearFlags.Skybox : CameraClearFlags.SolidColor; - } - } - - static Vector2 rotMeshSphere = new Vector2( 22, -18 - 90 - 12 ); - const float fovSphere = 23.4f; - - public void PrepareForDataScreenshot(){ - - // Reset rotation - // Reset zoom - // Stop auto-rotate - - rotMesh.x = rotMeshSmooth.x = rotMeshSphere.x; - rotMesh.y = rotMeshSmooth.y = rotMeshSphere.y; - cam.fieldOfView = targetFOV = smoothFOV = fovSphere; - - } - - - public int OnGUI( int yOffset, int maxWidth ) { - - if( enabled == false ) - return yOffset; - - Rect topBar = new Rect( 0, yOffset, maxWidth, 18 ); - - - GUI.Box( topBar, "", EditorStyles.toolbar ); - - Rect r = new Rect( topBar ); - r.width = maxWidth / 3; - r.height = 16; - r.x += 10; - r.y += 1; - - //EditorGUILayout.BeginHorizontal(); - //{ - EditorGUI.BeginChangeCheck(); - mesh = (Mesh)EditorGUI.ObjectField(r, mesh, typeof( Mesh ), false ); - if( EditorGUI.EndChangeCheck() ) { - targetFOV = 35f; - //editor.Defocus(); // TODO: This is a bit hacky - } - - r.x += r.width + 10; - r.width *= 0.5f; - EditorGUI.BeginChangeCheck(); - GUI.enabled = cam.clearFlags != CameraClearFlags.Skybox; - //GUI.color = GUI.enabled ? Color.white : new Color(1f,1f,1f,0.5f); - settings.colorBg = EditorGUI.ColorField( r, "", settings.colorBg ); - cam.backgroundColor = settings.colorBg; - - GUI.enabled = true; - //GUI.color = Color.white; - if( EditorGUI.EndChangeCheck() ) - UpdatePreviewBackgroundColor(); - - - r.x += r.width + 10; - r.width += 10; - - - GUI.enabled = RenderSettings.skybox != null; - SkyboxOn = GUI.Toggle( r, SkyboxOn, "Skybox" ); - if(RenderSettings.skybox == null && SkyboxOn){ - SkyboxOn = false; - } - GUI.enabled = true; - - r.x += r.width + 10; - settings.previewAutoRotate = GUI.Toggle( r, settings.previewAutoRotate, "Rotate" ); - - - Rect previewRect = new Rect( topBar ); - previewRect.y += topBar.height; - previewRect.height = topBar.width; - - - UpdateCameraZoom(); - DrawMeshGUI( previewRect ); - if(SF_Debug.renderDataNodes) - GUI.Label(previewRect, "rotMesh.x = " + rotMesh.x + " rotMesh.y = " + rotMesh.y); - - return (int)previewRect.yMax; - } - - public void UpdateRenderPath(){ - SFPSC_Lighting.RenderPath rPath = editor.ps.catLighting.renderPath; - - if(rPath == SFPSC_Lighting.RenderPath.Forward){ - cam.renderingPath = RenderingPath.Forward; - } else if(rPath == SFPSC_Lighting.RenderPath.Deferred){ - cam.renderingPath = RenderingPath.DeferredLighting; - //pruCam.clearFlags == CameraClearFlags.Depth; - } - } - - public void UpdateRot(){ - if(settings.previewAutoRotate){ - rotMesh.y += (float)(editor.deltaTime * -22.5); - } - rotMeshSmooth = Vector2.Lerp(rotMeshSmooth,rotMesh,0.5f); - } - - public void StartDragLMB() { - isDraggingLMB = true; - if(settings.previewAutoRotate == true){ - settings.previewAutoRotate = false; - } - dragStartPosLMB = Event.current.mousePosition; - rotMeshStart = rotMesh; - } - - public void UpdateDragLMB() { - rotMesh.y = rotMeshStart.y + ( -(dragStartPosLMB.x - Event.current.mousePosition.x) ) * 0.4f; - rotMesh.x = Mathf.Clamp( rotMeshStart.x + ( -(dragStartPosLMB.y - Event.current.mousePosition.y) ) * 0.4f, -90f, 90f ); - } - - public void StopDragLMB() { - isDraggingLMB = false; - } - - - public void StartDragRMB() { - isDraggingRMB = true; - } - - public void UpdateDragRMB() { - - if( Event.current.isMouse && Event.current.type == EventType.mouseDrag ) { - float x = ( -( Event.current.delta.x ) ) * 0.4f; - float y = ( -( Event.current.delta.y ) ) * 0.4f; - for( int i = 0; i < lights.Length; i++ ) { - lights[i].transform.RotateAround( Vector3.zero, cam.transform.right, y ); - lights[i].transform.RotateAround( Vector3.zero, cam.transform.up, x ); - } - } - - - } - - public void StopDragRMB() { - isDraggingRMB = false; - } - - - public bool MouseOverPreview() { - return previewRect.Contains( Event.current.mousePosition ); - } - - [SerializeField] - Rect previewRect = new Rect(0f,0f,1f,1f); - public void DrawMeshGUI( Rect previewRect ) { - - if( previewRect == default( Rect ) ) { - previewRect = this.previewRect; - } - - if( previewRect.width > 1 ) - this.previewRect = previewRect; - - if( Event.current.rawType == EventType.mouseUp ) { - if( Event.current.button == 0 ) - StopDragLMB(); - else if( Event.current.button == 1 ) - StopDragRMB(); - } - - if( Event.current.type == EventType.mouseDown && MouseOverPreview() ) { - if( Event.current.button == 0 ) - StartDragLMB(); - else if( Event.current.button == 1 ) - StartDragRMB(); - } - - if( isDraggingLMB ) - UpdateDragLMB(); - if( isDraggingRMB ) - UpdateDragRMB(); - - - if( mesh == null || InternalMaterial == null || Event.current.type != EventType.repaint ) - return; - - - - if( previewStyle == null ) { - previewStyle = new GUIStyle( EditorStyles.textField ); - } - previewStyle.normal.background = backgroundTexture; - - - - bool makeNew = false; - if( render == null ) { - makeNew = true; - } else if( render.width != (int)previewRect.width || render.height != (int)previewRect.height ) { - RenderTexture.DestroyImmediate( render ); - makeNew = true; - } - - if( makeNew ) { - render = new RenderTexture( (int)previewRect.width, (int)previewRect.height, 24, RenderTextureFormat.ARGB32 ); - render.antiAliasing = 8; - } - - DrawMesh(); - GL.sRGBWrite = ( QualitySettings.activeColorSpace == ColorSpace.Linear ); - GUI.DrawTexture( previewRect, render, ScaleMode.StretchToFill, false ); - GL.sRGBWrite = false; - - } - - - - public void DrawMesh( RenderTexture overrideRT = null, Material overrideMaterial = null, bool sphere = false ) { - if( backgroundTexture == null ) - UpdatePreviewBackgroundColor(); - - // Make sure all objects are set up properly - if( previewIsSetUp == false ) { - SetupPreview(); - } - - - // TODO: Override RT is used for screenshots, probably - if( overrideRT != null ) - cam.targetTexture = overrideRT; - else if( cam.targetTexture == null ) - cam.targetTexture = render; - - UpdateRenderPath(); - - SetCustomLight(on:true); - - Mesh drawMesh = sphere ? sphereMesh : mesh; - - float A = sphere ? rotMeshSphere.y : rotMeshSmooth.y; - float B = sphere ? rotMeshSphere.x : rotMeshSmooth.x; - Quaternion rotA = Quaternion.Euler( 0f, A, 0f ); - Quaternion rotB = Quaternion.Euler( B, 0f, 0f ); - Quaternion finalRot = rotA * rotB; - camPivot.rotation = finalRot; - float meshExtents = drawMesh.bounds.extents.magnitude; - - - Vector3 pos = new Vector3( -drawMesh.bounds.center.x, -drawMesh.bounds.center.y, -drawMesh.bounds.center.z ); - cam.transform.localPosition = new Vector3( 0f, 0f, -3f * meshExtents ); - - int smCount = drawMesh.subMeshCount; - - Material mat = (overrideMaterial == null) ? InternalMaterial : overrideMaterial; - for( int i=0; i < smCount; i++ ) { - Graphics.DrawMesh( drawMesh, Quaternion.identity * pos, Quaternion.identity, mat, 31, cam, i ); - } - - cam.farClipPlane = 3f * meshExtents * 2f; - cam.nearClipPlane = 0.1f; - cam.fieldOfView = sphere ? fovSphere : smoothFOV; - cam.Render(); - - // Reset things - SetCustomLight( on: false ); - - if( overrideRT != null ) - cam.targetTexture = render; - - if( sphere ) // Reset if needed. // TODO: What? - cam.fieldOfView = smoothFOV; - } - - - - - [SerializeField] - const float minFOV = 1f; - [SerializeField] - float targetFOV = 30f; - [SerializeField] - float smoothFOV = 30f; - [SerializeField] - const float maxFOV = 60f; - - public void UpdateCameraZoom() { - - if( Event.current.type == EventType.scrollWheel && MouseOverPreview() ) { - if(Event.current.delta.y > 0f){ - targetFOV+=2f; - } else if( Event.current.delta.y < 0f ){ - targetFOV-=2f; - } - } - if( Event.current.type == EventType.repaint ) { - targetFOV = Mathf.Clamp( targetFOV, minFOV, maxFOV ); - smoothFOV = Mathf.Lerp( cam.fieldOfView, targetFOV, 0.5f ); - } - } - - - public void UpdatePreviewBackgroundColor() { - if( backgroundTexture == null ){ - backgroundTexture = new Texture2D( 1, 1, TextureFormat.ARGB32, false, QualitySettings.activeColorSpace == ColorSpace.Linear ); - backgroundTexture.hideFlags = HideFlags.HideAndDontSave; - } - Color c = settings.colorBg; - backgroundTexture.SetPixels( new Color[] { c } ); - backgroundTexture.Apply(); - } - - public void SetCustomLight(bool on) { - if( on ) { - UnityEditorInternal.InternalEditorUtility.SetCustomLighting( lights, RenderSettings.ambientLight ); - } else { - UnityEditorInternal.InternalEditorUtility.RemoveCustomLighting(); - } - } - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewWindow.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewWindow.cs.meta deleted file mode 100755 index 183dfa08..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_PreviewWindow.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 143d65d02bb214ab39919bad663ed37d -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_SelectionManager.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_SelectionManager.cs deleted file mode 100755 index 473f5a98..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_SelectionManager.cs +++ /dev/null @@ -1,412 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; - -namespace ShaderForge { - [System.Serializable] - public class SF_SelectionManager : ScriptableObject { - - [SerializeField] - SF_Editor editor; - [SerializeField] - List selection; - public List Selection { - get { - if( selection == null ) - selection = new List(); - return selection; - } - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - [SerializeField] - Rect selectionBox = new Rect(256,32,32,64); - - [SerializeField] - public bool boxSelecting = false; - - public void MoveSelection(Vector2 delta, SF_Node ignore) { - foreach(SF_Node n in Selection){ - if( n == ignore ) - continue; - //if(selection.Count > 1){ - //Debug.Log("Selection count = " + selection.Count + " thus nodes"); - Undo.RecordObject(n,"move nodes"); - //} - n.rect.x += delta.x; - n.rect.y += delta.y; - } - } - - - - public void DrawBoxSelection() { - if( boxSelecting ) { - Rect r = new Rect( selectionBox ); - SF_Tools.FlipNegative( ref r ); - GUI.Box( r, string.Empty, SF_Styles.SelectionStyle ); - //GUI.Label(r,selectionBox.ToString().Replace(' ','\n')); - } - } - - public void OnGUI() { - - /* - selectionBox.x = Event.current.mousePosition.x; - selectionBox.y = Event.current.mousePosition.y; - selectionBox.width = 128; - selectionBox.height = 128; - */ - - - if( SF_GUI.ReleasedRawLMB() && boxSelecting) { - ExecuteBoxSelect(); - } - - - if( SF_GUI.PressedLMB() && SF_GUI.HoldingBoxSelect() ) { - boxSelecting = true; - - if( !SF_GUI.MultiSelectModifierHeld() ) - DeselectAll(registerUndo:true); - - selectionBox.x = Event.current.mousePosition.x; - selectionBox.y = Event.current.mousePosition.y; - Event.current.Use(); - } - - - // Duplicate, copy, cut, paste - EventType et = Application.platform == RuntimePlatform.OSXEditor ? EventType.KeyDown : EventType.KeyUp; // TODO: Use KeyDown for Windows too - - - - if( SF_GUI.HoldingControl() && Event.current.type == et && !SF_Node.isEditingAnyNodeTextField ) { - - switch(Event.current.keyCode){ - case(KeyCode.D): - DuplicateSelection(); - break; - case(KeyCode.C): - CopySelection(); - break; - case(KeyCode.X): - CutSelection(); - break; - case(KeyCode.V): - PasteFromClipboard(); - break; - } - - } - - // Selection box - if( boxSelecting ) { - - selectionBox.width = Event.current.mousePosition.x - selectionBox.x; - selectionBox.height = Event.current.mousePosition.y - selectionBox.y; - - if(Event.current.isMouse) - Event.current.Use(); - } - - if( SF_GUI.PressedDelete() && !SF_Node.isEditingAnyNodeTextField ) { - DeleteSelected(); - Event.current.Use(); - } - } - - - - - public void ExecuteBoxSelect() { - boxSelecting = false; - foreach( SF_Node n in editor.nodes ) { - if( SF_Tools.Intersects( n.rect, selectionBox ) ){ - n.Select(registerUndo:true); - } - } - Event.current.Use(); - } - - - - public void DeleteSelected() { - - - if(Selection.Contains(editor.mainNode)){ - editor.mainNode.Deselect(registerUndo:false); // Deselect main node if you press delete - } - - int selCount = Selection.Count; - -// Debug.Log("Delete selected, count = " + selCount); - - if(selCount == 0) - return; - - string undoMsg = ""; - - if(selCount == 1) - undoMsg = "delete " + Selection[0].nodeName; - else - undoMsg = "delete " + selCount + " nodes"; - //Debug.Log("Selection delete initiated - " + undoMsg ); - - Undo.RecordObject(editor,undoMsg); - Undo.RecordObject(editor.nodeView.treeStatus, undoMsg); - - foreach(SF_Node node in editor.nodes){ - node.UndoRecord(undoMsg); - // Undo.RecordObject(node, undoMsg); - } - - Undo.RecordObject(this,undoMsg); - - - - // Undo recording is weird :( - - - - - - - for( int i = editor.nodes.Count - 1; i >= 0; i-- ) { - SF_Node n = editor.nodes[i]; - if( n.selected ) { - - if(n is SFN_Relay){ - SF_NodeConnector inCon = n["IN"]; - SF_NodeConnector outCon = n["OUT"]; - if(inCon.IsConnected() && outCon.IsConnected() ){ - // Relink all outputs to the incoming connectors - for (int ir = outCon.outputCons.Count - 1; ir >= 0; ir--) { - outCon.outputCons[ir].LinkTo(inCon.inputCon); - } - inCon.Disconnect(); - } - } - - foreach(SF_NodeConnector con in editor.nodes[i].connectors){ - if(con.conType == ConType.cOutput){ - con.Disconnect(); - } - } - if( editor.nodeView.treeStatus.propertyList.Contains( editor.nodes[i] ) ) - editor.nodeView.treeStatus.propertyList.Remove( editor.nodes[i] ); - editor.nodes[i].Deselect(registerUndo:false); - editor.nodes.RemoveAt(i); - - - //editor.nodes[i].Delete(registerUndo:false, undoMsg:undoMsg); - } - } - } - - - // Clipboard - public string[] CbNodes{ - get{ - string s = EditorPrefs.GetString("shaderforge_clipboard", ""); - return s.Split('\n'); - } - set{ - string s = ""; - for( int i=0;i 1) - undoMsg += "nodes"; - else - undoMsg += Selection[0].nodeName; - - RecordUndoNodeCreationAndSelectionStates(undoMsg); - - //Rect selBounds = GetSelectionBounds(); - Vector2 posOffset = new Vector2(64,64); - - InstantiateNodes(selectionSerialized, posOffset, undoMsg); - - } - - - void InstantiateNodes(string[] serializedNodes, Vector2 posOffset, string undoMsg){ - // Make sure it knows about the editor - SF_Parser.editor = editor; - - List newNodes = new List(); // List of all new nodes - List links = new List(); // Used for multi-clone - - int[] idOld = new int[serializedNodes.Length]; - int[] idNew = new int[serializedNodes.Length]; - - for(int i=0;i srzdSel = new List(); - - for(int i=0;i CloneNodeAndGetLinks(){ - List links = new List(); - - - - - return links; - } - - - public SF_SelectionManager Initialize( SF_Editor editor ) { - this.editor = editor; - return this; - } - - public void Add(SF_Node n) { - Selection.Add( n ); - } - - public void Remove( SF_Node n ) { - Selection.Remove( n ); - } - - public void DeselectAll(bool registerUndo, string undoMsg = null) { - editor.ResetRunningOutdatedTimer(); - foreach( SF_Node n in editor.nodes ) { - n.Deselect(registerUndo, undoMsg); - } - } - - - } -} - diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_SelectionManager.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_SelectionManager.cs.meta deleted file mode 100755 index f5092cdf..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_SelectionManager.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 43463d546def04200b133ba2feb5737d -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Settings.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Settings.cs deleted file mode 100755 index 75198613..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Settings.cs +++ /dev/null @@ -1,154 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; -using System; - - -namespace ShaderForge { - - public enum SF_Setting{ - CurveShape, // int Bezier/Linear/etc - AutoCompile, // bool True/False - HierarchalNodeMove, // bool True/False - RealTimeNodePreviews, // bool True/False - QuickPickScrollWheel, // bool True/False - ControlMode, // int Shader Forge / Unity / Unreal - ShowVariableSettings, // bool True/False - ShowNodeSidebar, // bool True/False - NodeRenderMode // int Mixed / MixedRealtime / Spheres / SpheresRealtime / ViewportRealtime - }; - - public enum ControlMode { ShaderForge, UnityMaya, Unreal }; - public enum NodeRenderMode { Mixed, Spheres, Viewport }; - - public class SF_Settings { - - public const string prefix = "shaderforge_"; - public const string suffixDefault = "_default"; - - public SF_Settings() { - - } - - public static void InitializeSettings() { - // Set up all defaults - SetDefaultBool( SF_Setting.HierarchalNodeMove, false ); - SetDefaultBool( SF_Setting.QuickPickScrollWheel, true ); - SetDefaultBool( SF_Setting.ShowVariableSettings, false ); - SetDefaultBool( SF_Setting.ShowNodeSidebar, true ); - SetDefaultBool( SF_Setting.RealTimeNodePreviews, true ); - SetDefaultInt( SF_Setting.NodeRenderMode, (int)NodeRenderMode.Mixed ); - } - - - // Cached, for speed - public static bool autoCompile; - public static bool hierarchalNodeMove; - public static bool quickPickScrollWheel; - public static bool showVariableSettings; - public static bool showNodeSidebar; - public static bool realtimeNodePreviews; - public static NodeRenderMode nodeRenderMode; - - // These two are called in OnEnable and OnDisable in SF_Editor - public static void LoadAllFromDisk() { - autoCompile = LoadBool( SF_Setting.AutoCompile ); - hierarchalNodeMove = LoadBool( SF_Setting.HierarchalNodeMove ); - quickPickScrollWheel = LoadBool( SF_Setting.QuickPickScrollWheel ); - showVariableSettings = LoadBool( SF_Setting.ShowVariableSettings ); - showNodeSidebar = LoadBool( SF_Setting.ShowNodeSidebar ); - realtimeNodePreviews = LoadBool( SF_Setting.RealTimeNodePreviews ); - nodeRenderMode = NodeRenderMode.Mixed; // nodeRenderMode = (NodeRenderMode)LoadInt( SF_Setting.NodeRenderMode ); - - } - public static void SaveAllToDisk() { - SaveBool( SF_Setting.AutoCompile, autoCompile ); - SaveBool( SF_Setting.HierarchalNodeMove, hierarchalNodeMove ); - SaveBool( SF_Setting.QuickPickScrollWheel, quickPickScrollWheel ); - SaveBool( SF_Setting.ShowVariableSettings, showVariableSettings ); - SaveBool( SF_Setting.ShowNodeSidebar, showNodeSidebar ); - SaveBool( SF_Setting.RealTimeNodePreviews, realtimeNodePreviews ); - SaveInt( SF_Setting.NodeRenderMode, (int)nodeRenderMode ); - } - - - - // -------------------------------------------------- - // Special functions - - public static bool RenderNodesInRealtime() { - return realtimeNodePreviews || nodeRenderMode == NodeRenderMode.Viewport; - } - - // -------------------------------------------------- - public static bool LoadBool( SF_Setting setting ) { - string key = KeyOf(setting); - return EditorPrefs.GetBool( key, EditorPrefs.GetBool( key + suffixDefault ) ); - } - public static string LoadString( SF_Setting setting ) { - string key = KeyOf(setting); - return EditorPrefs.GetString( key, EditorPrefs.GetString( key + suffixDefault ) ); - } - public static int LoadInt( SF_Setting setting ) { - string key = KeyOf(setting); - return EditorPrefs.GetInt( key, EditorPrefs.GetInt( key + suffixDefault) ); - } - public static float LoadFloat( SF_Setting setting ) { - string key = KeyOf(setting); - return EditorPrefs.GetFloat( key, EditorPrefs.GetFloat( key + suffixDefault) ); - } - // -------------------------------------------------- - private static string KeyOf( SF_Setting setting ){ - return prefix + setting.ToString(); - } - // -------------------------------------------------- - private static void SetDefaultBool( SF_Setting setting, bool value ){ - string key = KeyOf(setting); - EditorPrefs.SetBool(key + suffixDefault, value); - if(!EditorPrefs.HasKey(key)){ - SaveBool(setting, value); - } - } - private static void SetDefaultString(SF_Setting setting, string value){ - string key = KeyOf(setting); - EditorPrefs.SetString(key + suffixDefault, value); - if(!EditorPrefs.HasKey(key)){ - SaveString(setting, value); - } - } - private static void SetDefaultInt(SF_Setting setting, int value){ - string key = KeyOf(setting); - EditorPrefs.SetInt(key + suffixDefault, value); - if(!EditorPrefs.HasKey(key)){ - SaveInt(setting, value); - } - } - private static void SetDefaultFloat(SF_Setting setting, float value){ - string key = KeyOf(setting); - EditorPrefs.SetFloat(key + suffixDefault, value); - if(!EditorPrefs.HasKey(key)){ - SaveFloat(setting, value); - } - } - // -------------------------------------------------- - public static void SaveBool( SF_Setting setting, bool value ){ - string key = KeyOf(setting); - EditorPrefs.SetBool(key, value); - } - public static void SaveString(SF_Setting setting, string value){ - string key = KeyOf(setting); - EditorPrefs.SetString(key, value); - } - public static void SaveInt(SF_Setting setting, int value){ - string key = KeyOf(setting); - EditorPrefs.SetInt(key, value); - } - public static void SaveFloat(SF_Setting setting, float value){ - string key = KeyOf(setting); - EditorPrefs.SetFloat(key, value); - } - - } - -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Settings.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Settings.cs.meta deleted file mode 100755 index ef32682c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_Settings.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 94c65d8d5218043a49bf95b2ae42fc31 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_StatusBox.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_StatusBox.cs deleted file mode 100755 index b9949efc..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_StatusBox.cs +++ /dev/null @@ -1,328 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; - -namespace ShaderForge { - [System.Serializable] - public class SF_StatusBox { - - [SerializeField] - private SF_Editor editor; - [SerializeField] - SF_MinMax vCount = new SF_MinMax(); - [SerializeField] - SF_MinMax fCount = new SF_MinMax(); - [SerializeField] - SF_MinMax vtCount = new SF_MinMax(); - [SerializeField] - SF_MinMax ftCount = new SF_MinMax(); - [SerializeField] - public RenderPlatform platform; - - [SerializeField] - private GUIStyle labelStyle; - [SerializeField] - private GUIStyle labelStyleCentered; - [SerializeField] - private GUIStyle holderStyle; - [SerializeField] - private GUIStyle headerStyle; - - public SF_StatusBox() { - - - - } - - public void Initialize( SF_Editor editor) { - this.editor = editor; - labelStyle = new GUIStyle( EditorStyles.label ); - labelStyle.margin = new RectOffset( 0, 0, 0, 0 ); - labelStyle.padding = new RectOffset( 8, 0, 3, 1 ); - - labelStyleCentered = new GUIStyle( labelStyle ); - labelStyleCentered.alignment = TextAnchor.MiddleCenter; - - holderStyle = new GUIStyle(); - holderStyle.margin = new RectOffset( 0, 0, 0, 0 ); - holderStyle.padding = new RectOffset( 0, 0, 0, 0 ); - - - headerStyle = new GUIStyle( EditorStyles.toolbar ); - headerStyle.alignment = TextAnchor.MiddleLeft; - headerStyle.fontSize = 10; - //headerStyle.fontStyle = FontStyle.Bold; - } - - - public int OnGUI( int yOffset, int in_maxWidth ) { - - Rect r = new Rect( 0, yOffset, in_maxWidth, 18 ); - - //string tmp = "Instructions: "; - - //if( Compiled() ) { - headerStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black; - //} else { - //headerStyle.normal.textColor = new Color( 0f, 0f, 0f, 0.75f ); - //tmp = "(Shader not compiled yet)"; - //} - - GUI.Label( r, string.Empty, EditorStyles.toolbar ); // Toolbar - - Rect iRect = r; - - //Rect rTmp = iRect; - //rTmp = rTmp.MovedUp(); - - //GUI.Label(rTmp, "MIP USED; " + editor.nodeView.treeStatus.mipInputUsed); - - iRect.width = 64f; - - - GUI.color = new Color(1f,1f,1f,0.5f); - if( GUI.Button( iRect, "Select", EditorStyles.toolbarButton) ) { - Selection.activeObject = editor.currentShaderAsset; - EditorGUIUtility.PingObject(editor.currentShaderAsset); - } - GUI.color = Color.white; - - /* Instruction count disabled. - if(!editor.nodeView.treeStatus.CanDisplayInstructionCount){ - InstructionLabel( ref iRect, SF_Styles.IconWarningSmall, "Instruction count unavailable"); - } else { - - InstructionLabel( ref iRect, SF_GUI.Inst_vert, vCount.ToString() ); - InstructionLabel( ref iRect, SF_GUI.Inst_frag, fCount.ToString() ); - if( !vtCount.Empty() ) - InstructionLabel( ref iRect, SF_GUI.Inst_vert_tex, vtCount.ToString() ); - if( !ftCount.Empty() ) - InstructionLabel( ref iRect, SF_GUI.Inst_frag_tex, ftCount.ToString() ); - } - */ - - - - - - - - - - //if(Compiled()){ - Color c = GUI.color; - c.a = 0.5f; - GUI.color = c; - r.xMin += iRect.x; - r.xMax -= 4; - GUI.Label(r, SF_Tools.rendererLabels[(int)platform],SF_Styles.InstructionCountRenderer); - GUI.color = Color.white; - //} - - - - - - - GUI.color = Color.white; - - return (int)r.yMax; - } - - - public void InstructionLabel(ref Rect iRect, Texture2D icon, string label) { - - iRect.width = icon.width; - GUI.DrawTexture( iRect, icon ); - iRect.x += iRect.width; - iRect.width = SF_GUI.WidthOf( label, headerStyle )+2; - GUI.Label( iRect, label, headerStyle ); - iRect.x += iRect.width; - } - - - private bool Compiled() { - if( vCount.min == 0 ) - return false; - return true; - } - - //private enum LookingFor{ }; - - public void UpdateInstructionCount( Shader sh ) { - // Compiled shader string: - string[] css = ( new SerializedObject( sh ) ).FindProperty( "m_Script" ).stringValue.Split( '\n' ); - - Debug.Log( ( new SerializedObject( sh ) ).FindProperty( "m_Script" ).stringValue ); - Debug.Log(css.Length); - - if(css.Length < 2){ - return; - } - - ShaderProgram prog = ShaderProgram.Vert; - - - List passes = new List(); - SFIns_Pass cPass; // current pass - - for( int i = 0; i < css.Length; i++ ) { - if( css[i].Contains( "Pass {" ) ) { // Found a pass! - - bool ignoreMin = false; - i++; - - // Shadow passes - if( css[i].Contains( "Name \"ShadowCaster\"" ) || css[i].Contains( "Name \"ShadowCollector\"" ) || css[i].Contains( "Name \"ForwardAdd\"" ) ) - continue; - - if( (css[i].Contains("Name \"PrePassBase\"") || css[i].Contains("Name \"PrePassFinal\"") ) && editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Forward ) - continue; - - if( (css[i].Contains("Name \"ForwardBase\"") || css[i].Contains("Name \"ForwardAdd\"") ) && editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred ) - continue; - - - //ignoreMin = true; - - cPass = new SFIns_Pass(); - - for ( ; i < css.Length; i++ ) { - - if(css[i].StartsWith("// Vertex combos")){ - prog = ShaderProgram.Vert; - } else if(css[i].StartsWith("// Fragment combos")){ - prog = ShaderProgram.Frag; - } else { - continue; - } - - // Program found! - i++; // Next line... - // Scan following lines for shader platform data - for ( ; i < css.Length; i++ ) { - if(css[i].StartsWith( "//" )){ - cPass.Parse( prog, css[i], ignoreMin ); - } else { - // No more platform data - break; - } - } - // Leave this loop and start searching for the next pass if we just found the frag data - if( prog == ShaderProgram.Frag ) - break; - } - // Add the current pass to the list - passes.Add(cPass); - } - } - - - // All passes scanned! - // Show, some sort of instruction count - // Show sum of all passes min for now - vCount.Reset(); - fCount.Reset(); - vtCount.Reset(); - ftCount.Reset(); - - // Find which program to display instruction count for! - // if(mac) opengl - // if(win) d3d9 - // else gles - // else *any enabled* - - - - platform = GetPrimaryPlatform(); - int primPlat = (int)platform; - - - - // Debug.Log("Primary platform: " + (RenderPlatform)primPlat); - - - - foreach( SFIns_Pass p in passes ) { - vCount += p.plats[primPlat].vert; // Only d3d9 for now // TODO - fCount += p.plats[primPlat].frag; - vtCount += p.plats[primPlat].vTex; - ftCount += p.plats[primPlat].fTex; - } - - - //Debug.Log("vCount = " + vCount); - - - - - /* - int programID = 0; // 0 = vert | 1 = frag - for( int i = 0; i < css.Length; i++ ) { - if( css[i].Contains( "instructions" ) ) - continue; - if( css[i].Contains( "# " ) ) { - if( programID == 0 ) { - string[] split = css[i].Trim().Split( ' ' ); - vCount = int.Parse( split[1] ); // Vertex instructions TODO: Textures in vertex program - programID++; // Search for fragment - } else if( programID == 1 ) { - string[] split = css[i].Trim().Split( ' ' ); - fCount = int.Parse( split[1] ); // Fragment instructions - try { - tCount = int.Parse( split[3] ); // Textures - } catch { - - } - - } - } - } - */ - - - - - } - - - public RenderPlatform GetPrimaryPlatform() { - - // Let's check our build target! - BuildTarget active = EditorUserBuildSettings.activeBuildTarget; - - // Mobile platforms - // 9 = BuildTarget.iPhone // Unity 4.x - // 9 = BuildTarget.iOS // Unity 5.x - // 28 = BuildTarget.BB10 // Unity 4.x - // 28 = BuildTarget.BlackBerry // Unity 5.x - - bool mobile = ( active == BuildTarget.Android || (int)active == 9 || (int)active == 28 ); - if(mobile && editor.ps.catMeta.usedRenderers[(int)RenderPlatform.gles]) - return RenderPlatform.gles; - - // Standalone / Webplayer. In this case, it depends on what the user is using - // Pick the one that is currently running - if( Application.platform == RuntimePlatform.OSXEditor && editor.ps.catMeta.usedRenderers[(int)RenderPlatform.glcore] ) - return RenderPlatform.glcore; - if( Application.platform == RuntimePlatform.WindowsEditor && editor.ps.catMeta.usedRenderers[(int)RenderPlatform.d3d9] ) - return RenderPlatform.d3d9; - if( Application.platform == RuntimePlatform.WindowsEditor && editor.ps.catMeta.usedRenderers[(int)RenderPlatform.d3d11] ) - return RenderPlatform.d3d11; - - - Debug.LogWarning( "[SF] Unhandled platform settings. Make sure your build target (" + active + ") is sensible, and that you've got platforms enabled to compile for" ); - // You're using some weird setup, pick first active one - for(int i=0;i<12;i++){ - if(editor.ps.catMeta.usedRenderers[i]) - return (RenderPlatform)i; - } - - Debug.LogError("No renderers compilable, defaulting to d3d9"); - return RenderPlatform.d3d9; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_StatusBox.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/SF_StatusBox.cs.meta deleted file mode 100755 index 848efa0d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/SF_StatusBox.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bdeadd90c5eb14af9b16fdf9babcd447 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups.meta deleted file mode 100755 index 240e0c3b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: 69c81e70ae39d4265890a1da43af2896 -folderAsset: yes -DefaultImporter: - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Append.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Append.cs deleted file mode 100755 index 7eb5d3bf..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Append.cs +++ /dev/null @@ -1,213 +0,0 @@ -using UnityEngine; -using System.Collections; - - -namespace ShaderForge { - - // Used to detect types based on input - [System.Serializable] - public class SFNCG_Append : SF_NodeConnectionGroup { - - - - public SFNCG_Append Initialize( SF_NodeConnector output, params SF_NodeConnector[] inputs ) { - this.output = output; - this.inputs = inputs; - return this; - } - - - public int GetOutputComponentCount() { - - int cc = 0; - for( int i = 0; i < 4; i++ ) { - if(inputs[i].IsConnectedAndEnabled()) - cc += inputs[i].inputCon.GetCompCount(); - } - - if( cc == 0 ) - return 1; - else - return cc; - - } - - - public override void Refresh() { - - - // ALLOWED COMBOS - /* - * v1 v1 = v2 - * - * v1 v1 v1 = v3 - * v1 v2 = v3 - * - * v1 v1 v1 v1 = v4 - * v2 v1 v1 = v4 - * v2 v2 = v4 - * v1 v3 = v4 - */ - - // Are none of the inputs connected? In that case, it's all default - if( NoInputsConnected() ) - ResetValueTypes(); - - if( !inputs[0].node.InputsConnected() ) - return; - - - - int inCompSum = GetOutputComponentCount(); - - - - - if( inCompSum < 2 ) { - Debug.LogError( "Input sum is somehow " + inCompSum + " on " + inputs[0].node.nodeName ); - inputs[1].Disconnect(); // This should never happen - return; - } - - if( inCompSum > 4 ) { // TODO: Error message - Debug.LogWarning( "Connected too many components in Append node! Disconnecting all" ); - - for( int i = 0; i < 4; i++ ) { - if( inputs[i].IsConnectedAndEnabled() ) - Debug.LogWarning( "["+i+"]: " + inputs[i].inputCon.node.nodeName + " with " + inputs[i].inputCon.GetCompCount() + " components" ); - inputs[i].Disconnect(); - } - - return; - } - - - switch( inCompSum ) { - case 2: - output.valueType = ValueType.VTv2; - break; - case 3: - output.valueType = ValueType.VTv3; - break; - case 4: - output.valueType = ValueType.VTv4; - break; - } - - - - - - - /* - - - // If any input is non-pending, use that as base to assign the rest. - // Inputs: - ValueType baseInType = GetBaseInputType(); - ValueType genericInType = GetGenericInputType(); - AssignToEmptyInputs( genericInType ); - - // Output: - if( InputsMissing() ) { - if( baseInType == ValueType.VTv1 ) - output.valueType = ValueType.VTvPending; - else - output.valueType = baseInType; - } else { - output.valueType = GetDominantInputType(); - } - */ - } - - /* - - public ValueType GetGenericInputType() { - ValueType vt = GetBaseInputType(); - switch( vt ) { - case ValueType.VTv1: - return ValueType.VTvPending; - case ValueType.VTv2: - return ValueType.VTv1v2; - case ValueType.VTv3: - return ValueType.VTv1v3; - case ValueType.VTv4: - return ValueType.VTv1v4; - default: - Debug.LogError( "Invalid attempt to get generic input type from " + vt ); - return ValueType.VTvPending; - } - } - - public ValueType GetDominantInputType() { - ValueType dom = inputs[0].valueType; - for( int i = 1 ; i < inputs.Length ; i++ ) { - dom = GetDominantType( dom, inputs[i].valueType); - } - return dom; - } - - public ValueType GetDominantType(ValueType a, ValueType b) { - if( a == b ) - return a; - - if( a == ValueType.VTvPending ) - return b; - - if( b == ValueType.VTvPending ) - return a; - - if( a == ValueType.VTv1 ) { - if( IsVectorType( b ) ) - return b; - else - return a; - } - if( b == ValueType.VTv1 ) { - if( IsVectorType( a ) ) - return a; - else - return b; - } - - Debug.LogError( "You should not be able to get here! Dominant pending type returned" ); - return ValueType.VTvPending; - } - - - public ValueType GetBaseInputType() { - - ValueType retType = ValueType.VTvPending; - - foreach( SF_NodeConnection nc in inputs ) { - retType = GetDominantType( retType, nc.valueType ); - } - - if( retType == ValueType.VTvPending ) - Debug.LogError( "You should not be able to get here! Pending type returned" ); - return retType; - } - - public static bool CompatibleTypes( ValueType tInput, ValueType tOutput ) { - - // If they are the same type, they are of course compatible - if( tInput == tOutput ) - return true; - // If the input is a pending vector, any output vector is compatible - if( tInput == ValueType.VTvPending && IsVectorType( tOutput ) ) - return true; - // Check multi-type for v1/v2 - if( tInput == ValueType.VTv1v2 && ( tOutput == ValueType.VTv1 || tOutput == ValueType.VTv2 ) ) - return true; - // Check multi-type for v1/v3 - if( tInput == ValueType.VTv1v3 && ( tOutput == ValueType.VTv1 || tOutput == ValueType.VTv3 ) ) - return true; - // Check multi-type for v1/v4 - if( tInput == ValueType.VTv1v4 && ( tOutput == ValueType.VTv1 || tOutput == ValueType.VTv4 ) ) - return true; - // Didn't find any allowed link, return false - return false; - } - */ - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Append.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Append.cs.meta deleted file mode 100755 index c3319736..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Append.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 381cd199b81c0e343ad58f37ef1030e1 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Arithmetic.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Arithmetic.cs deleted file mode 100755 index 684627b7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Arithmetic.cs +++ /dev/null @@ -1,270 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - // Used to detect types based on input - [System.Serializable] - public class SFNCG_Arithmetic : SF_NodeConnectionGroup { - - - public bool lockedOutput = false; - - public SFNCG_Arithmetic() { - - } - - public SFNCG_Arithmetic Initialize( SF_NodeConnector output, params SF_NodeConnector[] inputs ) { - this.output = output; - this.inputs = inputs; - return this; - } - - public SFNCG_Arithmetic LockOutType() { - lockedOutput = true; - return this; - } - - - public override void Refresh() { - // Are none of the inputs connected? In that case, it's all default - if( NoInputsConnected() ) - ResetValueTypes(); - - // If any input is non-pending, use that as base to assign the rest. - // Inputs: - ValueType baseInType = GetBaseInputType(); - ValueType genericInType = GetGenericInputType(); - AssignToEmptyInputs( genericInType ); - - //Debug.Log("Refreshing connection group of " + output.node.nodeName ); - - // Output: - if( !lockedOutput ){ - if( RequiredInputsMissing() ) { - if( baseInType == ValueType.VTv1 ) - output.valueType = ValueType.VTvPending; - else - SetOutputValueType(baseInType); - } else { - ValueType vtDom = GetDominantInputType(); - SetOutputValueType(vtDom); - - UpdateTypecasts(); - } - } - } - - - public void SetOutputValueType(ValueType vt){ - - - //Debug.Log("Trying to set to " + vt); - - if(vt == ValueType.VTv1v2) - vt = ValueType.VTv2; - if(vt == ValueType.VTv1v3) - vt = ValueType.VTv3; - if(vt == ValueType.VTv1v4) - vt = ValueType.VTv4; - - - output.SetValueType(vt); - - int ccCalc; - if(SF_Tools.CompCountOf(vt, out ccCalc)){ - if(ccCalc != output.node.texture.CompCount){ - //Debug.Log("Trying to set to " + ccCalc + " from " + vt); - output.node.texture.CompCount = ccCalc; - } - } - - - //Debug.Log("Setting output type of " + output.node.nodeName + " to " + output.valueType); // THIS IS SET TO PENDING VOR VEC1 INPUTS - } - - - - - // This is only run if there are no inputs missing! - public void UpdateTypecasts(){ - ValueType domType = output.valueType; - - - - // Reset typecasts - foreach(SF_NodeConnector con in inputs) - con.typecastTarget = 0; - - if(domType == ValueType.VTv1 || domType == ValueType.VTv1v2 || domType == ValueType.VTv2) - return; // No typecasting - - int typeTarget = 0; - // If the dominant type is Vector3, cast all Vector2 to v3 - if(domType == ValueType.VTv1v3 || domType == ValueType.VTv3){ - typeTarget = 3; - } else if(domType == ValueType.VTv1v4 || domType == ValueType.VTv4){ - typeTarget = 4; - } else { - //Debug.LogError("Shouldn't be able to get here, invalid casting on "+base.output.node.GetType().ToString() + " domType = " + domType.ToString()); - } - - foreach(SF_NodeConnector con in inputs){ - - if(con.IsChild() && !con.IsConnected()) - continue; // This is fine, childs aren't required - - if(con.GetCompCount() == 2) - con.TypecastTo(typeTarget); - } - - } - - - public ValueType GetGenericInputType() { - ValueType vt = GetBaseInputType(); -// Debug.Log("Getting base input type on "+output.node.nodeName+" = " + vt); - switch( vt ) { - case ValueType.VTv1: - if(inputs.Length > 1) - return ValueType.VTvPending; // TODO: Really? - else - return ValueType.VTv1; // TODO: This feels weird - case ValueType.VTv2: - return ValueType.VTv1v2; - case ValueType.VTv3: - return ValueType.VTv1v3; - case ValueType.VTv4: - return ValueType.VTv1v4; - default: - //Debug.LogWarning( "Invalid attempt to get generic input type from " + vt ); - return ValueType.VTvPending; - } - } - - public virtual ValueType GetDominantInputType() { - - ValueType dom = inputs[0].valueType; - - - //ValueType dom = inputs[0].valueType; - //Debug.Log("Val 0 is " + inputs[0].valueType.ToString()); - //Debug.Log("Val 1 is " + inputs[1].valueType.ToString()); - - - for( int i = 1; i < inputs.Length; i++ ) { - dom = GetDominantType( dom, inputs[i].valueType ); - } - //Debug.Log("Found dominant type:" + dom.ToString()); - return dom; - } - - public ValueType GetDominantType( ValueType a, ValueType b ) { - - //if( SF_Debug.nodes) - // Debug.Log("DOM a:" + a.ToString() + " b:" + b.ToString()); - - if( a == b ) - return a; - - if( a == ValueType.VTvPending ) - return b; - - if( b == ValueType.VTvPending ) - return a; - - if( a == ValueType.VTv1 ) { - if( IsVectorType( b ) ) - return b; - else - return a; - } - if( b == ValueType.VTv1 ) { - if( IsVectorType( a ) ) - return a; - else - return b; - } - - if(a == ValueType.VTv2 || a == ValueType.VTv1v2) - return b; - if(b == ValueType.VTv2 || b == ValueType.VTv1v2) - return a; - - - if(a == ValueType.VTv3 && b == ValueType.VTv4) - return b; - if(b == ValueType.VTv3 && a == ValueType.VTv4) - return a; - - if(a == ValueType.VTv1v2 && b == ValueType.VTv2){ - return b; - } - if(b == ValueType.VTv1v2 && a == ValueType.VTv2){ - return a; - } - - if(a == ValueType.VTv1v3 && b == ValueType.VTv3){ - return b; - } - if(b == ValueType.VTv1v3 && a == ValueType.VTv3){ - return a; - } - - if(a == ValueType.VTv1v4 && b == ValueType.VTv4){ - return b; - } - if(b == ValueType.VTv1v4 && a == ValueType.VTv4){ - return a; - } - - - - - // Debug.LogWarning( "You should not be able to get here! Dominant pending type returned" ); - return ValueType.VTvPending; - } - - - public virtual ValueType GetBaseInputType() { - - ValueType retType = ValueType.VTvPending; - - foreach( SF_NodeConnector nc in inputs ) { - retType = GetDominantType( retType, nc.valueType ); - } - - //Debug.Log("Base input type is " + retType); - - //if( retType == ValueType.VTvPending ) - //Debug.LogWarning( "You should not be able to get here! Pending type returned" ); - return retType; - } - - public static bool CompatibleTypes( ValueType tInput, ValueType tOutput ) { - - // If they are the same type, they are of course compatible - if( tInput == tOutput ) - return true; - // If the input is a pending vector, any output vector is compatible - if( tInput == ValueType.VTvPending && IsVectorType( tOutput ) ) - return true; - // Check multi-type for v1/v2 - if( tInput == ValueType.VTv1v2 && ( tOutput == ValueType.VTv1 || tOutput == ValueType.VTv2 ) ) - return true; - // Check multi-type for v1/v3 - if( tInput == ValueType.VTv1v3 && ( tOutput == ValueType.VTv1 || tOutput == ValueType.VTv3 ) ) - return true; - // Check multi-type for v1/v4 - if( tInput == ValueType.VTv1v4 && ( tOutput == ValueType.VTv1 || tOutput == ValueType.VTv4 ) ) - return true; - // Matrices - if( tInput == ValueType.VTv4m4x4 && ( tOutput == ValueType.VTv4 || tOutput == ValueType.VTm4x4 ) ) - return true; - // Didn't find any allowed link, return false - return false; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Arithmetic.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Arithmetic.cs.meta deleted file mode 100755 index a1210a15..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_Arithmetic.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: af887491ef5675d4bac8f00faf209745 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_ChannelBlend.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_ChannelBlend.cs deleted file mode 100755 index 6b3590fd..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_ChannelBlend.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - // Used to detect types based on input - [System.Serializable] - public class SFNCG_ChannelBlend : SFNCG_Arithmetic { - - - public SFNCG_ChannelBlend() { - - } - - public new SFNCG_ChannelBlend Initialize( SF_NodeConnector output, params SF_NodeConnector[] inputs ) { - SF_NodeConnector[] inputsWithoutFirst = new SF_NodeConnector[inputs.Length-1]; - for(int i=1;i 4 ) { // TODO: Error message - Debug.LogWarning( "User connected vectors summing to " + inputs[0].node.nodeName ); - inputs[1].Disconnect(); - return; - } - - - switch( inCompSum ) { - case 2: - output.valueType = ValueType.VTv2; - break; - case 3: - output.valueType = ValueType.VTv3; - break; - case 4: - output.valueType = ValueType.VTv4; - break; - } - - - - - - - /* - - - // If any input is non-pending, use that as base to assign the rest. - // Inputs: - ValueType baseInType = GetBaseInputType(); - ValueType genericInType = GetGenericInputType(); - AssignToEmptyInputs( genericInType ); - - // Output: - if( InputsMissing() ) { - if( baseInType == ValueType.VTv1 ) - output.valueType = ValueType.VTvPending; - else - output.valueType = baseInType; - } else { - output.valueType = GetDominantInputType(); - } - */ - } - - /* - - public ValueType GetGenericInputType() { - ValueType vt = GetBaseInputType(); - switch( vt ) { - case ValueType.VTv1: - return ValueType.VTvPending; - case ValueType.VTv2: - return ValueType.VTv1v2; - case ValueType.VTv3: - return ValueType.VTv1v3; - case ValueType.VTv4: - return ValueType.VTv1v4; - default: - Debug.LogError( "Invalid attempt to get generic input type from " + vt ); - return ValueType.VTvPending; - } - } - - public ValueType GetDominantInputType() { - ValueType dom = inputs[0].valueType; - for( int i = 1 ; i < inputs.Length ; i++ ) { - dom = GetDominantType( dom, inputs[i].valueType); - } - return dom; - } - - public ValueType GetDominantType(ValueType a, ValueType b) { - if( a == b ) - return a; - - if( a == ValueType.VTvPending ) - return b; - - if( b == ValueType.VTvPending ) - return a; - - if( a == ValueType.VTv1 ) { - if( IsVectorType( b ) ) - return b; - else - return a; - } - if( b == ValueType.VTv1 ) { - if( IsVectorType( a ) ) - return a; - else - return b; - } - - Debug.LogError( "You should not be able to get here! Dominant pending type returned" ); - return ValueType.VTvPending; - } - - - public ValueType GetBaseInputType() { - - ValueType retType = ValueType.VTvPending; - - foreach( SF_NodeConnection nc in inputs ) { - retType = GetDominantType( retType, nc.valueType ); - } - - if( retType == ValueType.VTvPending ) - Debug.LogError( "You should not be able to get here! Pending type returned" ); - return retType; - } - - public static bool CompatibleTypes( ValueType tInput, ValueType tOutput ) { - - // If they are the same type, they are of course compatible - if( tInput == tOutput ) - return true; - // If the input is a pending vector, any output vector is compatible - if( tInput == ValueType.VTvPending && IsVectorType( tOutput ) ) - return true; - // Check multi-type for v1/v2 - if( tInput == ValueType.VTv1v2 && ( tOutput == ValueType.VTv1 || tOutput == ValueType.VTv2 ) ) - return true; - // Check multi-type for v1/v3 - if( tInput == ValueType.VTv1v3 && ( tOutput == ValueType.VTv1 || tOutput == ValueType.VTv3 ) ) - return true; - // Check multi-type for v1/v4 - if( tInput == ValueType.VTv1v4 && ( tOutput == ValueType.VTv1 || tOutput == ValueType.VTv4 ) ) - return true; - // Didn't find any allowed link, return false - return false; - } - */ - } - -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_ComponentMask.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_ComponentMask.cs.meta deleted file mode 100755 index a3d42950..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_ComponentMask.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f3ed7ab8c44ddc5429852ca5ffbb4850 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_MatrixMultiply.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_MatrixMultiply.cs deleted file mode 100644 index 8ee4e748..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_MatrixMultiply.cs +++ /dev/null @@ -1,90 +0,0 @@ -using UnityEngine; -using System.Collections; - - -namespace ShaderForge { - - // Used to detect types based on input - [System.Serializable] - public class SFNCG_MatrixMultiply : SF_NodeConnectionGroup { - - - - public SFNCG_MatrixMultiply Initialize( SF_NodeConnector output, params SF_NodeConnector[] inputs ) { - this.output = output; - this.inputs = inputs; - return this; - } - - public override void Refresh() { - - // ALLOWED COMBOS - /* - * m v = v - * v m = v - * m m = m - */ - - // Are none of the inputs connected? In that case, it's all default - if( NoInputsConnected() ) { - inputs[0].SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - inputs[1].SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - output.SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - } - - - //if( !inputs[0].node.InputsConnected() ) - // return; - - bool aCon = inputs[0].IsConnected(); - bool bCon = inputs[1].IsConnected(); - - bool oneConnected = aCon != bCon; - - - if(aCon && bCon){ - ValueType aType = inputs[0].inputCon.valueType; - ValueType bType = inputs[1].inputCon.valueType; - - if( aType == ValueType.VTv4 && bType == ValueType.VTm4x4 ){ - inputs[0].SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - inputs[1].SetValueTypeAndDefault( ValueType.VTm4x4 ); - output.SetValueTypeAndDefault( ValueType.VTv4 ); - } else if( aType == ValueType.VTm4x4 && bType == ValueType.VTv4 ){ - inputs[0].SetValueTypeAndDefault( ValueType.VTm4x4); - inputs[1].SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - output.SetValueTypeAndDefault( ValueType.VTv4 ); - } else if( aType == ValueType.VTm4x4 && bType == ValueType.VTm4x4 ){ - inputs[0].SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - inputs[1].SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - output.SetValueTypeAndDefault( ValueType.VTm4x4 ); - } else { - Debug.LogError( "Invalid input in Matrix multiply" ); - inputs[0].Disconnect(); - output.SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - } - } else if( oneConnected ) { - - SF_NodeConnector connected = aCon ? inputs[0] : inputs[1]; - SF_NodeConnector unconnected = aCon ? inputs[1] : inputs[0]; - - ValueType conType = connected.valueType; - - if(conType == ValueType.VTv4){ - unconnected.SetValueTypeAndDefault( ValueType.VTm4x4); - output.SetValueTypeAndDefault( ValueType.VTv4 ); - } else { - unconnected.SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - output.SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - } - } else { - inputs[0].SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - inputs[1].SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - output.SetValueTypeAndDefault( ValueType.VTv4m4x4 ); - } - - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_MatrixMultiply.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_MatrixMultiply.cs.meta deleted file mode 100644 index bf3037af..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SFNCG_MatrixMultiply.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b10258b471dba3e49b2c62e710a974f3 -timeCreated: 1436176254 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SF_NodeConnectionGroup.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SF_NodeConnectionGroup.cs deleted file mode 100755 index b1cf97fc..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SF_NodeConnectionGroup.cs +++ /dev/null @@ -1,83 +0,0 @@ -using UnityEngine; -using System.Collections; - - -namespace ShaderForge { - - // Used to detect types based on input - [System.Serializable] - public class SF_NodeConnectionGroup : ScriptableObject { - - - public SF_NodeConnector output; - public SF_NodeConnector[] inputs; - - - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - - public SF_NodeConnectionGroup() { - // Empty - } - - - /* - public void Initialize( SF_NodeConnection output, params SF_NodeConnection[] inputs ) { - this.output = output; - this.inputs = inputs; - }*/ - - - public virtual void Refresh() { - // Override - } - - public void AssignToEmptyInputs( ValueType vt ) { - //Debug.Log("AssignToEmptInputs: " + vt + " on output of " + output.node.nodeName); - foreach( SF_NodeConnector nc in inputs ) { - if( !nc.IsConnected() ) - nc.valueType = vt; - } - } - - public bool RequiredInputsMissing() { - foreach( SF_NodeConnector nc in inputs ) { - if( !nc.IsConnected() && nc.required ) - return true; - } - return false; - } - - public void ResetValueTypes() { - output.ResetValueType(); - foreach( SF_NodeConnector nc in inputs ) { - nc.ResetValueType(); - } - } - - public bool NoInputsConnected() { - foreach( SF_NodeConnector nc in inputs ) { - if( nc.IsConnected() ) - return false; - } - return true; - } - - public static bool IsVectorType( ValueType vTinput ) { - if( vTinput == ValueType.VTv1 ) - return true; - if( vTinput == ValueType.VTv2 ) - return true; - if( vTinput == ValueType.VTv3 ) - return true; - if( vTinput == ValueType.VTv4 ) - return true; - return false; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SF_NodeConnectionGroup.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SF_NodeConnectionGroup.cs.meta deleted file mode 100755 index e3adb3cf..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ConnectionGroups/SF_NodeConnectionGroup.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 29f1f79c469e47d4fbd337efdb4e4cb5 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Enums.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Enums.meta deleted file mode 100644 index 9e94440f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Enums.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: 549512c18f19b459fa330b7b13bc1f15 -folderAsset: yes -DefaultImporter: - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Enums/SF_VarTypeEnums.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Enums/SF_VarTypeEnums.cs deleted file mode 100644 index 03f99b37..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Enums/SF_VarTypeEnums.cs +++ /dev/null @@ -1,5 +0,0 @@ -using UnityEngine; -using System.Collections; - -public enum FloatPrecision{ Fixed, Half, Float }; -public enum CompCount{ c1, c2, c3, c4, c1x1, c2x2, c3x3, c4x4 }; \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Enums/SF_VarTypeEnums.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Enums/SF_VarTypeEnums.cs.meta deleted file mode 100644 index 3365c45d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Enums/SF_VarTypeEnums.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 83bc16350df4b47be937bd412bfe0a80 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator.meta deleted file mode 100755 index b8ece89a..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: 5f94f7f57d35346a79fe37c5394b46bf -folderAsset: yes -DefaultImporter: - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/Pass_FwdAdd.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/Pass_FwdAdd.cs deleted file mode 100755 index 555c872b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/Pass_FwdAdd.cs +++ /dev/null @@ -1,50 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge{ - public class Pass_FrwAdd : MonoBehaviour { - - public SF_Evaluator eval; - - - public Pass_FrwAdd( SF_Evaluator eval ) { - this.eval = eval; - } - - - public void ForwardAddPass() { - eval.ResetDefinedState(); - - - - } - - - - //////////////////////////////////////////////////////////// - - - public void StartPass() { - App( "Pass {" ); - eval.scope++; - } - - - - - - public void EndPass() { - eval.scope--; - App( "}" ); - } - - //////////////////////////////////////////////////////////// - - public void App( string s ) { - eval.App( s ); - } - - - } -} - diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/Pass_FwdAdd.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/Pass_FwdAdd.cs.meta deleted file mode 100755 index ac70217a..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/Pass_FwdAdd.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 22b57f25fa43b034dbe3965c4be91970 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs deleted file mode 100755 index 7448c77d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs +++ /dev/null @@ -1,3444 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; -using System; -using System.Reflection; -using System.IO; -using UnityEditor.VersionControl; -using System.Linq; - -namespace ShaderForge { - - - public enum PassType { - FwdBase, FwdAdd, ShadCast, - Outline, - Deferred, - Meta - }; - public enum ShaderProgram { Any, Vert, Frag, Tess }; - - [System.Serializable] - public class SF_Evaluator { - - public SF_Editor editor; - public List cNodes; - public List ghostNodes; - public int scope = 0; - public string shaderString = ""; - - public SF_PassSettings ps; - public SF_Dependencies dependencies; - public SF_ShaderProperty properties; - - public SFN_Final mOut; - - const bool DEBUG = true; - - - - - - public static PassType currentPass = PassType.FwdBase; - public static ShaderProgram currentProgram = ShaderProgram.Vert; - - public static bool inFrag { - get { - return SF_Evaluator.currentProgram == ShaderProgram.Frag; - } - } - public static bool inVert { - get { - return SF_Evaluator.currentProgram == ShaderProgram.Vert; - } - } - public static bool inTess { - get { - return SF_Evaluator.currentProgram == ShaderProgram.Tess; - } - } - - public static string WithProgramPrefix( string s ) { - if( SF_Evaluator.inFrag ) - return "i." + s; - if( SF_Evaluator.inVert ) - return "o." + s; - if( SF_Evaluator.inTess ) - return "v." + s; - Debug.Log( "Invalid program" ); - return null; - } - - - - // TODO: SHADER MODEL - public SF_Evaluator() { - - - } - - public SF_Evaluator( SF_Editor editor ) { - this.editor = editor; - this.ps = editor.ps; - } - - - public void PrepareEvaluation() { - ps.UpdateAutoSettings(); - - mOut = editor.mainNode; - } - - public void RemoveGhostNodes() { - if( ghostNodes == null ) - return; - - if( SF_Debug.ghostNodes ) - Debug.Log( "Removing ghost nodes. Count: " + ghostNodes.Count ); - for( int i = ghostNodes.Count - 1; i >= 0; i-- ) { - editor.nodes.Remove( ghostNodes[i] ); - ghostNodes[i].DeleteGhost(); - ghostNodes.Remove( ghostNodes[i] ); - } - //Debug.Log( "Done removing ghost nodes. Count: " + ghostNodes.Count ); - } - - bool LightmappedAndLit() { - return ps.catLighting.bakedLight && ( ps.HasSpecular() || ps.HasDiffuse() ) && ps.catLighting.lightMode != SFPSC_Lighting.LightMode.Unlit; - } - - bool IsReflectionProbed() { - return ( ps.HasSpecular() && ps.catLighting.lightMode != SFPSC_Lighting.LightMode.Unlit ) && ps.catLighting.reflectprobed && ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ); - } - - public void UpdateDependencies() { - - dependencies = new SF_Dependencies( editor.ps ); - - if( SF_Debug.evalFlow ) - Debug.Log( "UPDATING DEPENDENCIES: Pass = " + currentPass + " Prog = " + currentProgram ); - cNodes = editor.nodeView.treeStatus.GetListOfConnectedNodesWithGhosts( out ghostNodes, passDependent: true ); - if( SF_Debug.evalFlow ) - Debug.Log( "Found " + cNodes.Count + " nodes" ); - - - for( int i = 0; i < cNodes.Count; i++ ) { - cNodes[i].PrepareEvaluation(); - } - - if( currentPass == PassType.Meta ) { - dependencies.uv1 = true; - dependencies.uv2 = true; - } - - // Dependencies - if( ps.catLighting.IsLit() && !IsShadowOrOutlineOrMetaPass() && currentPass != PassType.Deferred ) { - dependencies.NeedLightColor(); - dependencies.NeedFragNormals(); - dependencies.NeedFragLightDir(); - - if( ( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.BlinnPhong || ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL ) && ps.mOut.specular.IsConnectedEnabledAndAvailableInThisPass( currentPass ) ) { - dependencies.NeedFragHalfDir(); - } - - if( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL && ps.mOut.diffuse.IsConnectedEnabledAndAvailableInThisPass(currentPass)){ - dependencies.NeedFragHalfDir(); - } - - - } - - if( editor.nodeView.treeStatus.viewDirectionInVertOffset ) { - dependencies.vert_viewDirection = true; - } - - if( currentPass == PassType.Deferred ) { - dependencies.NeedFragNormals(); - } - - if( IsReflectionProbed() && ps.HasSpecular() && ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ) ) { - dependencies.NeedFragViewReflection(); - dependencies.reflection_probes = true; - } - - if( ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ) && ( LightmappedAndLit() || IsReflectionProbed() || ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL ) ) { - dependencies.NeedFragViewReflection(); - } - - - if( LightmappedAndLit() && !IsShadowOrOutlineOrMetaPass() ) { - dependencies.vert_in_normals = true; - if( ps.catLighting.highQualityLightProbes ) - dependencies.NeedFragNormals(); - } - - if( ps.IsOutlined() && currentPass == PassType.Outline ) { - dependencies.vert_in_normals = true; - if( ps.catGeometry.outlineMode == SFPSC_Geometry.OutlineMode.VertexColors ) { - dependencies.vert_in_vertexColor = true; - } - } - - if( ps.catLighting.IsVertexLit() && ps.catLighting.IsLit() && !IsShadowOrOutlineOrMetaPass() ) { - if( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.BlinnPhong || ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL ) - dependencies.NeedVertHalfDir(); - dependencies.NeedVertLightDir(); - } - - - if( LightmappedAndLit() ) { - dependencies.NeedFragWorldPos(); - dependencies.NeedFragViewDirection(); - dependencies.uv1 = true; - dependencies.uv1_frag = true; - dependencies.uv2 = true; - dependencies.uv2_frag = true; - } - - - if( LightmappedAndLit() && !IsShadowOrOutlineOrMetaPass() ) { - dependencies.NeedFragTangentTransform(); // Directional LMs - dependencies.uv1 = true; // Lightmap UVs - } - - //if( ps.HasAnisotropicLight() && !IsShadowPass() ) { - // dependencies.NeedFragTangents(); - // dependencies.NeedFragBinormals(); - //} - - - - if( ps.catLighting.IsFragmentLit() && !IsShadowOrOutlineOrMetaPass() ) { - dependencies.vert_in_normals = true; - dependencies.vert_out_normals = true; - dependencies.vert_out_worldPos = true; - dependencies.frag_normalDirection = true; - if( ps.HasNormalMap() || ps.catLighting.HasSpecular() ) - dependencies.NeedFragViewDirection(); - } - - if( ps.HasTangentSpaceNormalMap() && !IsShadowOrOutlineOrMetaPass() ) { - dependencies.frag_normalDirection = true; - dependencies.NeedFragTangentTransform(); - } - - if( ps.HasObjectSpaceNormalMap() && !IsShadowOrOutlineOrMetaPass() ) { - dependencies.objectScaleReciprocal = true; - } - - if( ps.HasRefraction() && !IsShadowOrOutlineOrMetaPass() ) { - dependencies.NeedRefraction(); - } - - if( ps.HasTessellation() ) { - dependencies.NeedTessellation(); - } - - if( ps.HasDisplacement() ) { - dependencies.NeedDisplacement(); - } - - - if( ps.catBlending.dithering != Dithering.Off && editor.mainNode.alphaClip.IsConnectedEnabledAndAvailable() ) { - dependencies.NeedSceneUVs(); - } - - - - - - foreach( SF_Node n in cNodes ) { - - if( n is SFN_Time ) { - dependencies.time = true; - } - - if( n is SFN_SceneColor ) { - if( ( n as SFN_SceneColor ).AutoUV() ) - dependencies.NeedSceneUVs(); - dependencies.NeedGrabPass(); - } - - if( n is SFN_ObjectPosition ) { - if( currentProgram == ShaderProgram.Frag ) - dependencies.NeedFragObjPos(); - else - dependencies.NeedVertObjPos(); - } - - if( n is SFN_Fresnel ) { - dependencies.NeedFragViewDirection(); - if( !n.GetInputIsConnected( "NRM" ) ) // Normal. If it's not connected, make sure we have the dependency for normals - dependencies.NeedFragNormals(); - } - - if( n is SFN_FragmentPosition ) { - dependencies.NeedFragWorldPos(); - } - - if( n is SFN_SceneDepth ) { - dependencies.depthTexture = true; - if(n.GetInputIsConnected("UV") == false) - dependencies.NeedSceneUVs(); - } - - if( n is SFN_DepthBlend ) { - dependencies.NeedSceneDepth(); - dependencies.frag_pixelDepth = true; - } - - if( n is SFN_Depth ) { - // (mul( UNITY_MATRIX_V, float4((_WorldSpaceCameraPos.rgb-i.posWorld.rgb),0) ).b - _ProjectionParams.g) - dependencies.NeedFragPixelDepth(); - } - - if( n is SFN_ObjectScale ) { - if( ( n as SFN_ObjectScale ).reciprocal ) - dependencies.objectScaleReciprocal = true; - else - dependencies.objectScale = true; - } - - /* - if( n is SFN_Rotator ) { - if(!n.GetInputIsConnected("ANG")) - dependencies.time = true; - }*/ - - /* - if( n is SFN_Panner ) { - if( !n.GetInputIsConnected( "DIST" ) ) - dependencies.time = true; - } - */ - - if( n is SFN_ScreenPos ) { - dependencies.NeedSceneUVs(); - } - - if( n is SFN_Tex2d ) { - if( n.GetInputIsConnected( "MIP" ) ) { // MIP connection - //dependencies.ExcludeRenderPlatform( RenderPlatform.opengl ); // TODO: Find workaround! - dependencies.SetMinimumShaderTarget( 3 ); - } - } - - if( n is SFN_Cubemap ) { - if( n.GetInputIsConnected( "MIP" ) ) { // MIP connection - //dependencies.ExcludeRenderPlatform( RenderPlatform.opengl ); // TODO: Find workaround! - dependencies.SetMinimumShaderTarget( 3 ); - } - } - - /* - if( n is SFN_Tex2d ) { - if( !n.GetInputIsConnected( "UVIN" ) ) { // Unconnected UV input - dependencies.uv0 = true; - dependencies.uv0_frag = true; - } - }*/ - - if( n is SFN_VertexColor ) { - dependencies.NeedFragVertexColor(); // TODO: Check if it really needs to be frag - } - - if( n is SFN_DDX || n is SFN_DDY ) { - dependencies.pragmaGlsl = true; - } - - if( n is SFN_TexCoord ) { - SFN_TexCoord nTC = (SFN_TexCoord)n; - switch( nTC.currentUV ) { - case SFN_TexCoord.UV.uv0: - dependencies.uv0 = true; - dependencies.uv0_frag = true; - if( nTC.useAsFloat4 ) dependencies.uv0_float4 = true; - break; - case SFN_TexCoord.UV.uv1: - dependencies.uv1 = true; - dependencies.uv1_frag = true; - if( nTC.useAsFloat4 ) dependencies.uv1_float4 = true; - break; - case SFN_TexCoord.UV.uv2: - dependencies.uv2 = true; - dependencies.uv2_frag = true; - if( nTC.useAsFloat4 ) dependencies.uv2_float4 = true; - break; - case SFN_TexCoord.UV.uv3: - dependencies.uv3 = true; - dependencies.uv3_frag = true; - if( nTC.useAsFloat4 ) dependencies.uv3_float4 = true; - break; - } - } - if( n is SFN_Pi ) { - dependencies.const_pi = true; - } - if( n is SFN_Phi ) { - dependencies.const_phi = true; - } - if( n is SFN_E ) { - dependencies.const_e = true; - } - if( n is SFN_Root2 ) { - dependencies.const_root2 = true; - } - if( n is SFN_Tau ) { - dependencies.const_tau = true; - } - - if( n is SFN_HalfVector ) { - dependencies.NeedFragHalfDir(); - } - if( n is SFN_LightColor ) { - dependencies.NeedLightColor(); - } - - - if( n is SFN_Parallax ) { - dependencies.NeedFragViewDirection(); - dependencies.NeedFragTangentTransform(); - if( !( n as SFN_Parallax ).GetInputIsConnected( "UVIN" ) ) { - dependencies.uv0 = true; - } - } - - if( n is SFN_Cubemap ) { - if( !n.GetInputIsConnected( "DIR" ) ) { // DIR connection, if not connected, we need default reflection vector - dependencies.NeedFragViewReflection(); - } - } - - - - if( SF_Editor.NodeExistsAndIs( n, "SFN_SkyshopSpec" ) ) { - if( !n.GetInputIsConnected( "REFL" ) ) { // Reflection connection, if not connected, we need default reflection vector - dependencies.NeedFragViewReflection(); - } - } - - if( n is SFN_LightAttenuation ) { - dependencies.NeedFragAttenuation(); - } - - if( n is SFN_ViewReflectionVector ) { - dependencies.NeedFragViewReflection(); - } - - if( n is SFN_LightVector ) { - dependencies.NeedFragLightDir(); - } - - if( n is SFN_ViewVector ) { - dependencies.NeedFragViewDirection(); - } - - if( n is SFN_Tangent ) { - dependencies.NeedFragTangents(); - } - if( n is SFN_Bitangent ) { - dependencies.NeedFragBitangents(); - } - if( n is SFN_NormalVector ) { - dependencies.NeedFragNormals(); - } - - - - if( n is SFN_Transform ) { - if( ( n as SFN_Transform ).spaceSelFrom == SFN_Transform.Space.Tangent || ( n as SFN_Transform ).spaceSelTo == SFN_Transform.Space.Tangent ) { - dependencies.NeedFragTangentTransform(); - } - } - - if( n is SFN_FaceSign ) { - dependencies.frag_facing = true; - } - - if( ps.catGeometry.IsDoubleSided() ) { - dependencies.frag_facing = true; - } - - - // This has to be done afterwards - if( dependencies.frag_normalDirection && ps.catGeometry.IsDoubleSided() ) { - dependencies.NeedFragViewDirection(); - } - - - } - - //RemoveGhostNodes(); // TODO: Maybe not here? - - if( SF_Debug.evalFlow ) - Debug.Log( "DONE UPDATING DEPENDENCIES" ); - } - - - - - - void BeginShader() { - App( "Shader \"" + editor.currentShaderPath + "\" {" ); - scope++; - } - void BeginProperties() { - App( "Properties {" ); - scope++; - } - - void PropertiesShaderLab() { - - BeginProperties(); - - //Debug.Log("Printing properties, count = " + editor.nodeView.treeStatus.propertyList.Count); - - for( int i = 0; i < editor.nodeView.treeStatus.propertyList.Count; i++ ) { - if( editor.nodeView.treeStatus.propertyList[i] == null ) { - editor.nodeView.treeStatus.propertyList.RemoveAt( i ); - i = -1; // restart - } - if( editor.nodeView.treeStatus.propertyList[i].IsProperty() ) { - string line = editor.nodeView.treeStatus.propertyList[i].property.GetInitializationLine(); - App( line ); - } - } - - bool transparency = ps.mOut.alphaClip.IsConnectedEnabledAndAvailable() || ps.HasAlpha(); - - if( transparency ) - App( "[HideInInspector]_Cutoff (\"Alpha cutoff\", Range(0,1)) = 0.5" ); // Hack, but, required for transparency to play along with depth etc - - if( ps.catGeometry.showPixelSnap ) - App("[MaterialToggle] PixelSnap (\"Pixel snap\", Float) = 0"); - - if( ps.catBlending.allowStencilWriteThroughProperties ) { - App( "_Stencil (\"Stencil ID\", Float) = 0" ); - App( "_StencilReadMask (\"Stencil Read Mask\", Float) = 255" ); - App( "_StencilWriteMask (\"Stencil Write Mask\", Float) = 255" ); - App( "_StencilComp (\"Stencil Comparison\", Float) = 8" ); - App( "_StencilOp (\"Stencil Operation\", Float) = 0" ); - App( "_StencilOpFail (\"Stencil Fail Operation\", Float) = 0" ); - App( "_StencilOpZFail (\"Stencil Z-Fail Operation\", Float) = 0" ); - } - - - - End(); - - } - void PropertiesCG() { - for( int i = 0; i < cNodes.Count; i++ ) { - AppIfNonEmpty( cNodes[i].GetPrepareUniformsAndFunctions() ); - if( cNodes[i].IsProperty() ) { - string propName = cNodes[i].property.nameInternal; - if( !( ( IncludeLightingCginc() || IncludeUnity5BRDF() ) && propName == "_SpecColor" ) ) // SpecColor already defined in Lighting.cginc - App( cNodes[i].property.GetFilteredVariableLine() ); - } - } - } - void BeginSubShader() { - App( "SubShader {" ); - scope++; - } - void BeginTags() { - App( "Tags {" ); - scope++; - } - void BeginCG() { - App( "CGPROGRAM" ); - - if( dependencies.tessellation ) { - App( "#pragma hull hull" ); - App( "#pragma domain domain" ); - App( "#pragma vertex tessvert" ); - } else { - App( "#pragma vertex vert" ); - } - App( "#pragma fragment frag" ); - - - - switch( currentPass ) { - case PassType.FwdBase: - App( "#define UNITY_PASS_FORWARDBASE" ); - break; - case PassType.FwdAdd: - App( "#define UNITY_PASS_FORWARDADD" ); - break; - case PassType.Deferred: - App( "#define UNITY_PASS_DEFERRED" ); - break; - case PassType.ShadCast: - App( "#define UNITY_PASS_SHADOWCASTER" ); - break; - case PassType.Meta: - App( "#define UNITY_PASS_META 1" ); - break; - } - - - if( LightmappedAndLit() ) { - App( "#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )" ); - - } - - if(ps.catLighting.reflectprobed ){ - App ("#define _GLOSSYENV 1"); - } - - - if( ps.catGeometry.showPixelSnap ) - App( "#pragma multi_compile _ PIXELSNAP_ON" ); - - - App( "#include \"UnityCG.cginc\"" ); - - if( ShouldUseLightMacros() ) - App( "#include \"AutoLight.cginc\"" ); - if( IncludeLightingCginc() ) - App( "#include \"Lighting.cginc\"" ); - if( dependencies.tessellation ) - App( "#include \"Tessellation.cginc\"" ); - if( IncludeUnity5BRDF() ){ - App( "#include \"UnityPBSLighting.cginc\"" ); - App( "#include \"UnityStandardBRDF.cginc\"" ); - } - if( currentPass == PassType.Meta ) { - App("#include \"UnityMetaPass.cginc\""); - } - if( ps.catMeta.cgIncludes.Count > 0 ) { // Custom CG includes - for (int i = 0; i < ps.catMeta.cgIncludes.Count; i++){ - string incStr = ps.catMeta.cgIncludes[i]; - if( incStr == string.Empty ) - continue; - App( "#include \"" + incStr + ".cginc\"" ); - } - } - - if( currentPass == PassType.FwdBase ) { - App( "#pragma multi_compile_fwdbase" + ps.catBlending.GetShadowPragmaIfUsed() ); - } else if( currentPass == PassType.FwdAdd ) { - App( "#pragma multi_compile_fwdadd" + ps.catBlending.GetShadowPragmaIfUsed() ); - } else { - App( "#pragma fragmentoption ARB_precision_hint_fastest" ); - if(!ps.catExperimental.forceNoShadowPass) - App( "#pragma multi_compile_shadowcaster" ); - } - - if( currentPass == PassType.Deferred ) { - App( "#pragma multi_compile ___ UNITY_HDR_ON" ); - } - - if( LightmappedAndLit() ) { - App( "#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON" ); - App( "#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE" ); - App( "#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON" ); - } - - if( UseUnity5Fog() ) - App( "#pragma multi_compile_fog" ); - - - - - List groups = new List(); - foreach( SF_Node n in cNodes ) { - int group; - string[] mcPrags = n.TryGetMultiCompilePragmas( out group ); - if( !groups.Contains( group ) && mcPrags != null ) { - groups.Add( group ); - for( int i = 0; i < mcPrags.Length; i++ ) { - App( "#pragma multi_compile " + mcPrags[i] ); - } - } - // Old branching tests - //if(n.IsProperty() && n.property is SFP_Branch){ - // App(n.property.GetMulticompilePragma ()); - //} - } - - - - if( dependencies.DoesIncludePlatforms() ) - App( "#pragma only_renderers " + dependencies.GetIncludedPlatforms() ); - if( dependencies.IsTargetingAboveDefault() ) { - if( ps.catExperimental.force2point0 ) - App( "#pragma target 2.0" ); - else - App( "#pragma target " + dependencies.GetShaderTarget() ); - } - - } - void EndCG() { - App( "ENDCG" ); - } - - public bool IncludeUnity5BRDF() { - return LightmappedAndLit() || ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL || ps.catLighting.reflectprobed; - } - - bool UseUnity5Fog() { - return ps.catBlending.useFog; - } - - bool UseUnity5FogInThisPass() { - return ps.catBlending.useFog && ( currentPass == PassType.FwdAdd || currentPass == PassType.FwdBase || currentPass == PassType.Outline ); - } - - - - void AppTag( string k, string v ) { - App( "\"" + k + "\"=\"" + v + "\"" ); - } - - void PassTags() { - BeginTags(); - if( currentPass == PassType.FwdBase ) - AppTag( "LightMode", "ForwardBase" ); - else if( currentPass == PassType.FwdAdd ) - AppTag( "LightMode", "ForwardAdd" ); - else if( currentPass == PassType.ShadCast ) - AppTag( "LightMode", "ShadowCaster" ); - else if( currentPass == PassType.Deferred ) - AppTag( "LightMode", "Deferred" ); - else if( currentPass == PassType.Meta ) - AppTag( "LightMode", "Meta" ); - End(); - } - - - void SubShaderTags() { - - bool ip = ps.catBlending.ignoreProjector; - bool doesOffset = ps.catBlending.queuePreset != Queue.Geometry || ps.catBlending.queueOffset != 0; - bool hasRenderType = ps.catBlending.renderType != RenderType.None; - bool hasBatchConfig = ps.catMeta.batchingMode != SFPSC_Meta.BatchingMode.Enabled; - bool hasAtlasConfig = ps.catMeta.canUseSpriteAtlas; - bool hasPreviewType = ps.catMeta.previewType != SFPSC_Meta.Inspector3DPreviewType.Sphere; - - if( !ip && !doesOffset && !hasRenderType && !hasBatchConfig && !hasAtlasConfig && !hasPreviewType ) - return; // No tags! - - BeginTags(); - if( ip ) - AppTag( "IgnoreProjector", "True" ); - if( doesOffset ) { - string bse = ps.catBlending.queuePreset.ToString(); - string ofs = ""; - if( ps.catBlending.queueOffset != 0 ) - ofs = ps.catBlending.queueOffset > 0 ? ( "+" + ps.catBlending.queueOffset ) : ( ps.catBlending.queueOffset.ToString() ); - AppTag( "Queue", ( bse + ofs ).ToString() ); - } - if( hasRenderType ) - AppTag( "RenderType", ps.catBlending.renderType.ToString() ); - if( hasBatchConfig ) { - if(ps.catMeta.batchingMode == SFPSC_Meta.BatchingMode.Disabled) - AppTag( "DisableBatching", "True" ); - if(ps.catMeta.batchingMode == SFPSC_Meta.BatchingMode.DisableDuringLODFade) - AppTag( "DisableBatching", "LODFading" ); - } - if( hasAtlasConfig ) { - AppTag( "CanUseSpriteAtlas", "True" ); - } - if( hasPreviewType ) { - if( ps.catMeta.previewType == SFPSC_Meta.Inspector3DPreviewType.Plane) - AppTag( "PreviewType", "Plane" ); - if( ps.catMeta.previewType == SFPSC_Meta.Inspector3DPreviewType.Skybox ) - AppTag( "PreviewType", "Skybox" ); - } - - - - End(); - } - - void RenderSetup() { - - if( currentPass == PassType.FwdAdd ) - App( "Blend One One" ); - else if( currentPass == PassType.FwdBase && ps.catBlending.UseBlending() ) // Shadow passes and outlines use default blending - App( ps.catBlending.GetBlendString() ); - - if( currentPass == PassType.Meta ) { - App( "Cull Off" ); - } else if( currentPass == PassType.ShadCast ) { - App( "Offset 1, 1" ); - App( ps.catGeometry.GetCullString() ); - } else if( currentPass == PassType.Outline ) { - App( "Cull Front" ); - } else if( ps.catGeometry.UseCulling() ) - App( ps.catGeometry.GetCullString() ); - - if( ps.catBlending.UseDepthTest() && !IsShadowOrOutlineOrMetaPass() ) // Shadow passes and outlines use default - App( ps.catBlending.GetDepthTestString() ); - - if( !IsShadowOrOutlineOrMetaPass() ) { - App( ps.catBlending.GetZWriteString() ); - } - - if( ps.catBlending.colorMask != 15 ) { // 15 means RGBA, which is default - App("ColorMask " + ps.catBlending.colorMask.ToColorMaskString()); - } - - App( ps.catBlending.GetOffsetString() ); - - if(ps.catBlending.useStencilBuffer && currentPass == PassType.FwdBase){ - App("Stencil {"); - scope++; - App( ps.catBlending.GetStencilContent() ); - scope--; - App("}"); - } - - if( currentPass == PassType.FwdBase && ps.catBlending.alphaToCoverage ) { - App("AlphaToMask On"); - } - - - } - - void CGvars() { - - if( editor.mainNode.alphaClip.IsConnectedEnabledAndAvailable() ) { - if( ps.catBlending.dithering == Dithering.Dither2x2 ) { - App( "// Dithering function, to use with scene UVs (screen pixel coords)" ); - App( "// 2x2 Bayer matrix, based on https://en.wikipedia.org/wiki/Ordered_dithering" ); - App( "float BinaryDither2x2( float value, float2 sceneUVs ) {" ); - scope++; - App( "float2x2 mtx = float2x2(" ); - scope++; - App( "float2( 1, 3 )/5.0," ); - App( "float2( 4, 2 )/5.0" ); - scope--; - App( ");" ); - App( "float2 px = floor(_ScreenParams.xy * sceneUVs);" ); - App( "int xSmp = fmod(px.x,2);" ); - App( "int ySmp = fmod(px.y,2);" ); - App( "float2 xVec = 1-saturate(abs(float2(0,1) - xSmp));" ); - App( "float2 yVec = 1-saturate(abs(float2(0,1) - ySmp));" ); - App( "float2 pxMult = float2( dot(mtx[0],yVec), dot(mtx[1],yVec) );" ); - App( "return round(value + dot(pxMult, xVec));" ); - scope--; - App( "}" ); - } else if( ps.catBlending.dithering == Dithering.Dither3x3 ) { - App( "// Dithering function, to use with scene UVs (screen pixel coords)" ); - App( "// 3x3 Bayer matrix, based on https://en.wikipedia.org/wiki/Ordered_dithering" ); - App( "float BinaryDither3x3( float value, float2 sceneUVs ) {" ); - scope++; - App( "float3x3 mtx = float3x3(" ); - scope++; - App( "float3( 3, 7, 4 )/10.0," ); - App( "float3( 6, 1, 9 )/10.0," ); - App( "float3( 2, 8, 5 )/10.0" ); - scope--; - App( ");" ); - App( "float2 px = floor(_ScreenParams.xy * sceneUVs);" ); - App( "int xSmp = fmod(px.x,3);" ); - App( "int ySmp = fmod(px.y,3);" ); - App( "float3 xVec = 1-saturate(abs(float3(0,1,2) - xSmp));" ); - App( "float3 yVec = 1-saturate(abs(float3(0,1,2) - ySmp));" ); - App( "float3 pxMult = float3( dot(mtx[0],yVec), dot(mtx[1],yVec), dot(mtx[2],yVec) );" ); - App( "return round(value + dot(pxMult, xVec));" ); - scope--; - App( "}" ); - } else if( ps.catBlending.dithering == Dithering.Dither4x4 ) { - App( "// Dithering function, to use with scene UVs (screen pixel coords)" ); - App( "// 4x4 Bayer matrix, based on https://en.wikipedia.org/wiki/Ordered_dithering" ); - App( "float BinaryDither4x4( float value, float2 sceneUVs ) {" ); - scope++; - App( "float4x4 mtx = float4x4(" ); - scope++; - App( "float4( 1, 9, 3, 11 )/17.0," ); - App( "float4( 13, 5, 15, 7 )/17.0," ); - App( "float4( 4, 12, 2, 10 )/17.0," ); - App( "float4( 16, 8, 14, 6 )/17.0" ); - scope--; - App( ");" ); - App( "float2 px = floor(_ScreenParams.xy * sceneUVs);" ); - App( "int xSmp = fmod(px.x,4);" ); - App( "int ySmp = fmod(px.y,4);" ); - App( "float4 xVec = 1-saturate(abs(float4(0,1,2,3) - xSmp));" ); - App( "float4 yVec = 1-saturate(abs(float4(0,1,2,3) - ySmp));" ); - App( "float4 pxMult = float4( dot(mtx[0],yVec), dot(mtx[1],yVec), dot(mtx[2],yVec), dot(mtx[3],yVec) );" ); - App( "return round(value + dot(pxMult, xVec));" ); - scope--; - App( "}" ); - } - } - - - if( dependencies.lightColor && !IncludeLightingCginc() && !IncludeUnity5BRDF() ) // Lightmap and shadows include Lighting.cginc, which already has this. Don't include when making Unity 5 shaders - App( "uniform float4 _LightColor0;" ); - - - if( dependencies.grabPass ) { - App( "uniform sampler2D " + ps.catBlending.GetGrabTextureName() + ";" ); - } - - if( dependencies.depthTexture ) - App( "uniform sampler2D _CameraDepthTexture;" ); - - if( dependencies.fog_color ) { - App( "uniform float4 unity_FogColor;" ); - } - - - - PropertiesCG(); - - } - - void InitViewDirVert() { - if( dependencies.vert_viewDirection ) - App( "float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, v.vertex).xyz);" ); - } - void InitViewDirFrag() { - if( dependencies.frag_viewDirection ) - App( "float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);" ); - } - void InitTangentTransformFrag() { - if( ( dependencies.frag_tangentTransform && currentProgram == ShaderProgram.Frag ) || ( dependencies.vert_tangentTransform && currentProgram == ShaderProgram.Vert ) ) - App( "float3x3 tangentTransform = float3x3( " + WithProgramPrefix( "tangentDir" ) + ", " + WithProgramPrefix( "bitangentDir" ) + ", " + WithProgramPrefix( "normalDir" ) + ");" ); - } - - - - - string LightmapNormalDir() { - if( editor.mainNode.normal.IsConnectedAndEnabled() ) { - return "normalLocal"; - } - return "float3(0,0,1)"; - } - - void PrepareLightmapVars() { - if( !LightmapThisPass() ) - return; - - - // TODO U5 LMs - - - } - - void InitLightDir() { - - if( IsShadowPass() ) - return; - - if( ( currentProgram == ShaderProgram.Frag && !dependencies.frag_lightDirection ) || ( currentProgram == ShaderProgram.Vert && !dependencies.vert_lightDirection ) ) - return; - - if( currentPass == PassType.FwdBase ) { - - App( "float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);" ); - - return; - } - - // Point vs directional - App( "float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - " + WithProgramPrefix( "posWorld.xyz" ) + ",_WorldSpaceLightPos0.w));" ); - - } - - void InitLightColor(){ - App("float3 lightColor = _LightColor0.rgb;"); - } - - - void InitHalfVector() { - if( ( !dependencies.frag_halfDirection && currentProgram == ShaderProgram.Frag ) || ( !dependencies.vert_halfDirection && currentProgram == ShaderProgram.Vert ) ) - return; - App( "float3 halfDirection = normalize(viewDirection+lightDirection);" ); - } - - void InitAttenuation() { - - if( SF_Evaluator.inVert && ps.catLighting.IsVertexLit() && ShouldUseLightMacros() ) - App( "TRANSFER_VERTEX_TO_FRAGMENT(o)" ); - - string atten = "LIGHT_ATTENUATION(" + ( ( currentProgram == ShaderProgram.Frag ) ? "i" : "o" ) + ")"; - - string inner = ( ShouldUseLightMacros() ? atten : "1" ); - App( "float attenuation = " + inner + ";" ); - if( ps.catLighting.lightMode != SFPSC_Lighting.LightMode.Unlit ) - App( "float3 attenColor = attenuation * _LightColor0.xyz;" ); - } - - - string GetWithDiffPow( string s ) { - if( ps.HasDiffusePower() ) { - return "pow(" + s + ", " + ps.n_diffusePower + ")"; - } - return s; - } - - - - void CalcDiffuse() { - - //App( "float atten = 1.0;" ); - AppDebug( "Diffuse" ); - - - - //InitAttenuation(); - - - string lmbStr = ""; - - - - - - - - if( !InDeferredPass() ) { - bool definedNdotL = ps.HasSpecular(); - bool definedNdotLwrap = false; - - if( ps.HasTransmission() || ps.HasLightWrapping() ) { - - - - if( !InDeferredPass() ) { - if( !definedNdotL ) { - App( "float NdotL = dot( " + VarNormalDir() + ", lightDirection );" ); - definedNdotL = true; - } else { - App( "NdotL = dot( " + VarNormalDir() + ", lightDirection );" ); - } - definedNdotL = true; - } - - string fwdLight = "float3 forwardLight = "; // TODO - string backLight = "float3 backLight = "; // TODO - - - if( ps.HasLightWrapping() ) { - App( "float3 w = " + ps.n_lightWrap + "*0.5; // Light wrapping" ); - if( !definedNdotLwrap ) { - App( "float3 NdotLWrap = NdotL * ( 1.0 - w );" ); - definedNdotLwrap = true; - } - - App( fwdLight + GetWithDiffPow( "max(float3(0.0,0.0,0.0), NdotLWrap + w )" ) + ";" ); - if( ps.HasTransmission() ) { - App( backLight + GetWithDiffPow( "max(float3(0.0,0.0,0.0), -NdotLWrap + w )" ) + " * " + ps.n_transmission + ";" ); - } - - } else { - App( fwdLight + GetWithDiffPow( "max(0.0, NdotL )" ) + ";" ); - if( ps.HasTransmission() ) { - App( backLight + GetWithDiffPow( "max(0.0, -NdotL )" ) + " * " + ps.n_transmission + ";" ); - } - } - - lmbStr = "forwardLight"; - - if( ps.HasTransmission() ) { - lmbStr += "+backLight"; - lmbStr = "(" + lmbStr + ")"; - } - - }// else { - - - bool noSpec = !ps.HasSpecular(); - bool unity5pblDiffuse = ps.HasDiffuse() && ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL; - - bool needsToDefineNdotV = noSpec && unity5pblDiffuse; - - if( needsToDefineNdotV ) { - App( "float NdotV = max(0.0,dot( " + VarNormalDir() + ", viewDirection ));" ); - } - - - - if( !definedNdotL ) { - App( "float NdotL = max(0.0,dot( " + VarNormalDir() + ", lightDirection ));" ); - } else { - App( "NdotL = max(0.0,dot( " + VarNormalDir() + ", lightDirection ));" ); - } - - if( Unity5PBL() ) { - //if( ps.HasTransmission() || ps.HasLightWrapping() ) - //App( "NdotL = max(0.0,NdotL);" ); - App( "half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);" ); - if( ps.HasTransmission() || ps.HasLightWrapping() ) { - if( !definedNdotLwrap ) - App( "float3 NdotLWrap = max(0,NdotL);" ); - App( "float nlPow5 = Pow5(1-NdotLWrap);" ); - } else { - App( "float nlPow5 = Pow5(1-NdotL);" ); - } - App( "float nvPow5 = Pow5(1-NdotV);" ); - - - string pbrStr = "((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL)"; - - if( ps.HasTransmission() || ps.HasLightWrapping() ) { - lmbStr = "(" + lmbStr + " + " + pbrStr + ")"; - } else { - lmbStr = pbrStr; - } - - - } else if( !( ps.HasTransmission() || ps.HasLightWrapping() ) ) { - lmbStr = GetWithDiffPow( "max( 0.0, NdotL)" ); - } - - - - //} - - if( ps.catLighting.IsEnergyConserving() && !Unity5PBL() ) { - if( ps.HasLightWrapping() ) { - lmbStr += "*(0.5-max(w.r,max(w.g,w.b))*0.5)"; - } - } - - lmbStr = "float3 directDiffuse = " + lmbStr + " * attenColor"; - lmbStr += ";"; - App( lmbStr ); - } - - - - bool ambDiff = ps.mOut.ambientDiffuse.IsConnectedEnabledAndAvailableInThisPass( currentPass ); - bool shLight = DoPassSphericalHarmonics(); - bool diffAO = ps.mOut.diffuseOcclusion.IsConnectedEnabledAndAvailableInThisPass( currentPass ); - bool ambLight = ps.catLighting.useAmbient && ( currentPass == PassType.FwdBase ) && !LightmappedAndLit(); // Ambient is already in light probe data - - bool hasIndirectLight = ambDiff || shLight || ambLight; // TODO: Missing lightmaps - - - - - if( hasIndirectLight ) { - App( "float3 indirectDiffuse = float3(0,0,0);" ); - } - - - - - - - - - - // Direct light done, now let's do indirect light - - //if( !InDeferredPass() ) { - if( hasIndirectLight ) { - //App( " indirectDiffuse = float3(0,0,0);" ); - - if( ambLight ) - App( "indirectDiffuse += " + GetAmbientStr() + "; // Ambient Light" ); - if( ambDiff ) - App( "indirectDiffuse += " + ps.n_ambientDiffuse + "; // Diffuse Ambient Light" ); - - - if( LightmappedAndLit() ) { - - - App( "indirectDiffuse += gi.indirect.diffuse;" ); - - - } - - // Diffuse AO - if( diffAO ) { - App( "indirectDiffuse *= " + ps.n_diffuseOcclusion + "; // Diffuse AO" ); - } - - - } - //} - - - //if( LightmapThisPass() ) { - // scope--; - //App( "#endif" ); - // } - - // This has been defined before specular, in the case of PBL - if( !Unity5PBL() ) { - App( "float3 diffuseColor = " + ps.n_diffuse + ";" ); - } - - // To make diffuse/spec tradeoff better - if( DoPassDiffuse() && DoPassSpecular() ) { - if( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL ) { - if(ps.catLighting.specularMode != SFPSC_Lighting.SpecularMode.Metallic) // Metallic has already done this by now - App( "diffuseColor *= 1-specularMonochrome;" ); - } else if( ps.catLighting.energyConserving ) { - App( "diffuseColor *= 1-specularMonochrome;" ); - } - } - - if( !InDeferredPass() ) { - if( hasIndirectLight ) { - App( "float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;" ); - } else { - App( "float3 diffuse = directDiffuse * diffuseColor;" ); - } - - } - - //if( SF_Tools.UsingUnity5plus && ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL ) { - // App( "diffuse *= 0.75;" ); - //} - - - - - - } - - bool LightmapThisPass() { - return LightmappedAndLit() && ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ); - } - - void InitNormalDirVert() { - if( dependencies.vert_out_normals ) { - App( "o.normalDir = UnityObjectToWorldNormal(" + ps.catGeometry.GetNormalSign() + "v.normal);" ); - } - } - - void InitTangentDirVert() { - App( "o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );" ); - } - - void InitBitangentDirVert() { - App( "o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);" ); - } - - void InitObjectPos() { - if( dependencies.frag_objectPos || dependencies.vert_objectPos ) - App( "float4 objPos = mul ( unity_ObjectToWorld, float4(0,0,0,1) );" ); - } - void InitObjectScale() { - if( dependencies.objectScaleReciprocal || dependencies.objectScale ) - App( "float3 recipObjScale = float3( length(unity_WorldToObject[0].xyz), length(unity_WorldToObject[1].xyz), length(unity_WorldToObject[2].xyz) );" ); - if( dependencies.objectScale ) - App( "float3 objScale = 1.0/recipObjScale;" ); - } - - void InitNormalDirFrag() { - - if( ( !dependencies.frag_normalDirection && currentProgram == ShaderProgram.Frag ) ) - return; - - - - - //if(ps.normalQuality == SF_PassSettings.NormalQuality.Normalized){ - // App ("i.normalDir = normalize(i.normalDir);"); - //} - - - - if( currentPass == PassType.ShadCast || currentPass == PassType.Meta ) { - App( "float3 normalDirection = i.normalDir;" ); - } else { - if( ps.HasTangentSpaceNormalMap() ) { - App( "float3 normalLocal = " + ps.n_normals + ";" ); - App( "float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals" ); - } else if( ps.HasObjectSpaceNormalMap() ) { - App( "float3 normalLocal = " + ps.n_normals + ";" ); - App( "float3 normalDirection = mul( unity_WorldToObject, float4(normalLocal,0)) / recipObjScale;" ); - } else if( ps.HasWorldSpaceNormalMap() ) { - App( "float3 normalDirection = " + ps.n_normals + ";" ); - } else { - App( "float3 normalDirection = i.normalDir;" ); - } - } - - - - } - - - void CalcGloss() { - AppDebug( "Gloss" ); - if( ps.catLighting.glossRoughMode == SFPSC_Lighting.GlossRoughMode.Roughness ){ - App( "float gloss = 1.0 - " + ps.n_gloss + "; // Convert roughness to gloss" ); - if( Unity5PBL() ) - App( "float perceptualRoughness = " + ps.n_gloss + ";" ); - } else { - App( "float gloss = " + ps.n_gloss + ";" ); - if( Unity5PBL() ) - App( "float perceptualRoughness = 1.0 - " + ps.n_gloss + ";" ); - } - - if( Unity5PBL() ) { - if( ps.catLighting.geometricAntiAliasing ) { - App( "float3 spaaDx = ddx(i.normalDir);" ); - App( "float3 spaaDy = ddy(i.normalDir);" ); - App( "float geoRoughFactor = pow(saturate(max(dot(spaaDx,spaaDx),dot(spaaDy,spaaDy))),0.333);" ); - App( "perceptualRoughness = max(perceptualRoughness, geoRoughFactor);" ); - } - App( "float roughness = perceptualRoughness * perceptualRoughness;" ); - } - - if( !InDeferredPass() ) { - if( ps.catLighting.remapGlossExponentially ) { - App( "float specPow = exp2( gloss * 10.0 + 1.0 );" ); - } else { - App( "float specPow = gloss;" ); - } - } - - - - } - - bool DoAmbientSpecThisPass() { - return ( mOut.ambientSpecular.IsConnectedEnabledAndAvailable() && ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ) ); - } - - - void CalcSpecular() { - - - - AppDebug( "Specular" ); - - - - if( currentPass != PassType.Deferred ) { - App( "float NdotL = saturate(dot( " + VarNormalDir() + ", lightDirection ));" ); - } - - - //if(DoAmbientSpecThisPass() && ps.IsPBL()) - //App ("float NdotR = max(0, dot(viewReflectDirection, normalDirection));"); // WIP - - string directSpecular = "float3 directSpecular = "; - - string attColStr; - //if( ps.catLighting.maskedSpec && currentPass == PassType.FwdBase && ps.catLighting.lightMode != SFPSC_Lighting.LightMode.PBL ) { - // attColStr = "(floor(attenuation) * _LightColor0.xyz)"; - //} else { - attColStr = "attenColor"; - //} - - - - - - - - - /* - * float3 specular = pow(max(0.0,dot(halfDirection, normalDirection)),specPow) * specularColor; - #ifndef LIGHTMAP_OFF - #ifndef DIRLIGHTMAP_OFF - specular *= lightmap; - #else - specular *= floor(attenuation) * _LightColor0.xyz; - #endif - #else - specular = floor(attenuation) * _LightColor0.xyz; - #endif - * */ - - directSpecular += attColStr; /* * " + ps.n_specular;*/ // TODO: Doesn't this double the spec? Removed for now. Shouldn't evaluate spec twice when using PBL - - - - - //if( mOut.ambientSpecular.IsConnectedEnabledAndAvailable() && currentPass == PassType.FwdBase){ - // s += "(attenColor + " + ps.n_ambientSpecular + ")"; - //} else { - // s += "attenColor"; - //} - - - - bool occluded = ps.mOut.specularOcclusion.IsConnectedEnabledAndAvailableInThisPass( currentPass ) && !InDeferredPass(); - bool ambSpec = DoAmbientSpecThisPass(); - bool reflProbed = dependencies.reflection_probes; - bool hasIndirectSpecular = ambSpec || ( reflProbed && ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ) ); - string indirectSpecular = ""; - - if( hasIndirectSpecular ) { - - if( occluded ) { - App( "float3 specularAO = " + ps.n_specularOcclusion + ";" ); - } - - indirectSpecular = "float3 indirectSpecular = "; - - - - - - if( reflProbed ) { - indirectSpecular += "(gi.indirect.specular"; - } else { - indirectSpecular += "(0"; - } - - - if( ambSpec ) { - indirectSpecular += " + " + ps.n_ambientSpecular + ")"; - } else { - indirectSpecular += ")"; - } - - if( occluded ) { - indirectSpecular += " * specularAO"; - } - - - } - - - - - - - - - if( ps.catLighting.IsPBL() && !InDeferredPass() ) { - - App( "float LdotH = saturate(dot(lightDirection, halfDirection));" ); - - - - //s += "*NdotL"; // TODO: Really? Is this the cosine part? - - //if(DoAmbientSpecThisPass()) - //sAmb += " * NdotR"; - - } - - if( !InDeferredPass() && !Unity5PBL() ) { - if( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.Phong ) - directSpecular += " * pow(max(0,dot(reflect(-lightDirection, " + VarNormalDir() + "),viewDirection))"; - if( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.BlinnPhong ) { - directSpecular += " * pow(max(0,dot(halfDirection," + VarNormalDir() + "))"; - } - directSpecular += ",specPow)"; - } - - bool initialized_NdotV = false; - bool initialized_NdotH = false; - bool initialized_VdotH = false; - - - App( "float3 specularColor = " + ps.n_specular + ";" ); - if( Unity5PBL() ) { - App( "float specularMonochrome;" ); - App( "float3 diffuseColor = " + ps.n_diffuse + "; // Need this for specular when using metallic" ); - if( MetallicPBL() ) { - App( "diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );" ); - } else { - App( "diffuseColor = EnergyConservationBetweenDiffuseAndSpecular(diffuseColor, specularColor, specularMonochrome);" ); - } - App( "specularMonochrome = 1.0-specularMonochrome;" ); - } else if( ps.catLighting.energyConserving && DoPassDiffuse() && DoPassSpecular() ){ - App( "float specularMonochrome = max( max(specularColor.r, specularColor.g), specularColor.b);" ); - } - - - - - - - - string specularPBL = ""; - - // PBL SHADING, normalization term comes after this - if( ps.catLighting.IsPBL() && !InDeferredPass() ) { - - - - // FRESNEL TERM - //App( "float3 specularColor = " + ps.n_specular + ";" ); - - - - //specularPBL += "*NdotL"; - - - - // VISIBILITY TERM / GEOMETRIC TERM? - - if( !initialized_NdotV ) { - App( "float NdotV = abs(dot( " + VarNormalDir() + ", viewDirection ));" ); - initialized_NdotV = true; - } - - - if( !initialized_NdotH ) { - App( "float NdotH = saturate(dot( " + VarNormalDir() + ", halfDirection ));" ); - initialized_NdotH = true; - } - if( !initialized_VdotH ) { - App( "float VdotH = saturate(dot( viewDirection, halfDirection ));" ); - initialized_VdotH = true; - } - - App( "float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );" ); - - specularPBL += "*visTerm"; - - - - - - - } else { - //sAmb += " * specularColor"; - //directSpecular += " * specularColor"; - } - - - - if( ps.catLighting.IsEnergyConserving() && !InDeferredPass() ) { - // NORMALIZATION TERM - if( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.Phong ) { - App( "float normTerm = (specPow + 2.0 ) / (2.0 * Pi);" ); - directSpecular += "*normTerm"; - } else if( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.BlinnPhong || ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL ) { - if( Unity5PBL() ) { - - if( !initialized_NdotH ) { - App( "float NdotH = saturate(dot( " + VarNormalDir() + ", halfDirection ));" ); - initialized_NdotH = true; - } - - App( "float normTerm = GGXTerm(NdotH, roughness);" ); - specularPBL += "*normTerm"; - - } else { - App( "float normTerm = (specPow + 8.0 ) / (8.0 * Pi);" ); - directSpecular += "*normTerm"; - } - - } - - if( DoAmbientSpecThisPass() ) { - //sAmb += " * normTerm"; - } - - - - - } - - - - - - if( !InDeferredPass() ) { - if( Unity5PBL() ) { - - if( !initialized_NdotV ) { - App( "float NdotV = max(0.0,dot( " + VarNormalDir() + ", viewDirection ));" ); - initialized_NdotV = true; - } - - - - specularPBL = specularPBL.Substring( 1 ); // Remove first * symbol - specularPBL = "float specularPBL = (" + specularPBL + ") * UNITY_PI;"; - - App( specularPBL ); - - App( "#ifdef UNITY_COLORSPACE_GAMMA" ); - scope++; - App( "specularPBL = sqrt(max(1e-4h, specularPBL));" ); - scope--; - App( "#endif" ); - App( "specularPBL = max(0, specularPBL * NdotL);" ); - App( "#if defined(_SPECULARHIGHLIGHTS_OFF)" ); - scope++; - App( "specularPBL = 0.0;" ); - scope--; - App( "#endif" ); - - // Surface reduction - if( hasIndirectSpecular ) { - App( "half surfaceReduction;" ); - App( "#ifdef UNITY_COLORSPACE_GAMMA" ); - scope++; - App( "surfaceReduction = 1.0-0.28*roughness*perceptualRoughness;" ); - scope--; - App( "#else" ); - scope++; - App( "surfaceReduction = 1.0/(roughness*roughness + 1.0);" ); - scope--; - App( "#endif" ); - } - - - // Kill spec if color = 0 - App( "specularPBL *= any(specularColor) ? 1.0 : 0.0;" ); - - - directSpecular += "*specularPBL*FresnelTerm(specularColor, LdotH)"; - } else { - directSpecular += "*specularColor"; - } - - directSpecular += ";"; - - App( directSpecular ); - } else { - // If we're in deferred, we still need NdotV for lightmapping - if( !initialized_NdotV ) { - App( "float NdotV = max(0.0,dot( " + VarNormalDir() + ", viewDirection ));" ); - initialized_NdotV = true; - } - } - - - - - - string specular = ""; - - - if( hasIndirectSpecular ) { - - if( Unity5PBL() ) { - App( "half grazingTerm = saturate( gloss + specularMonochrome );" ); - } else { - indirectSpecular += "*specularColor"; - } - - App( indirectSpecular + ";" ); - - if( Unity5PBL() ) { - if( ps.HasSpecular() ) { - App( "indirectSpecular *= FresnelLerp (specularColor, grazingTerm, NdotV);" ); - if(!InDeferredPass()) - App( "indirectSpecular *= surfaceReduction;" ); - } else { - //App( "float3 indirectFresnelPBL = FresnelLerp (specularColor, grazingTerm, NdotV);" ); - } - } - if( !InDeferredPass() ) { - specular = "float3 specular = (directSpecular + indirectSpecular);"; - } - - } else if(!InDeferredPass()){ - specular = "float3 specular = directSpecular;"; - } - - if( !InDeferredPass() ) - App( specular ); // Specular - - - - - - - - - - - } - - // Spec & emissive - /* - void CalcAddedLight() { - - - // No added light unless we're using spec or emissive - if( !ps.HasSpecular() && !ps.HasEmissive() ) - return; - - AppDebug("CalcAddedLight()"); - - string s = ""; - //if( ps.HasSpecular() || ps.HasEmissive() && currentPass == PassType.FwdBase ) - - if( ps.HasSpecular() ) { - - CalcGloss(); - CalcSpecular(); - - if( ps.HasEmissive() && currentPass == PassType.FwdBase ) - s += " + " + ps.n_emissive; - - s += ";"; - - } else if( ps.HasEmissive() && currentPass == PassType.FwdBase ) { - s = "float3 addLight = "; - s += ps.n_emissive + ";"; - } - - App( s ); - } - */ - - - public bool MetallicPBL() { - return ps.catLighting.IsPBL() && ps.catLighting.specularMode == SFPSC_Lighting.SpecularMode.Metallic; - } - - bool Unity5PBL() { - return ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL; - } - - - void CalcEmissive() { - AppDebug( "Emissive" ); - App( "float3 emissive = " + ps.n_emissive + ";" ); - } - - bool DoPassDiffuse() { - return ps.HasDiffuse() && ( currentPass == PassType.FwdBase || currentPass == PassType.FwdAdd || currentPass == PassType.Deferred ); - } - bool DoPassEmissive() { // Emissive should always be in the base pass - return ps.HasEmissive() && ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ); - } - bool DoPassSpecular() { // Spec only in base and add passes - return ps.catLighting.HasSpecular() && ( currentPass == PassType.FwdBase || currentPass == PassType.FwdAdd || currentPass == PassType.Deferred ); - } - - - - void CalcFinalLight() { - //bool addedOnce = false; - string finalLightStr = "float3 lightFinal = "; - if( ps.catLighting.IsLit() ) { - finalLightStr += "diffuse"; - if( ps.catLighting.useAmbient && currentPass == PassType.FwdBase ) { - finalLightStr += " + UNITY_LIGHTMODEL_AMBIENT.xyz"; - } - } - - finalLightStr += ";"; - App( finalLightStr ); - - } - - - - - void AppFinalOutput( string color, string alpha ) { - - string rgbaValue; - if( ps.HasRefraction() && currentPass == PassType.FwdBase ) { - rgbaValue = "fixed4(lerp(sceneColor.rgb, " + color + "," + alpha + "),1)"; - } else { - rgbaValue = "fixed4(" + color + "," + alpha + ")"; - } - - if( UseUnity5FogInThisPass() ) { - App( "fixed4 finalRGBA = " + rgbaValue + ";" ); - if( ps.catBlending.fogOverrideColor ) { - App( "UNITY_APPLY_FOG_COLOR(i.fogCoord, finalRGBA, " + GetFogColorAsFixed3Value() + ");" ); - } else { - App( "UNITY_APPLY_FOG(i.fogCoord, finalRGBA);" ); - } - App( "return finalRGBA;" ); - } else { - App( "return " + rgbaValue + ";" ); - } - - } - - string GetFogColorAsFixed3Value() { - Color c = ps.catBlending.fogColor; - return "fixed4(" + c.r + "," + c.g + "," + c.b + "," + c.a + ")"; - } - - - string GetAmbientStr() { - string s; - if( InDeferredPass() ) - s = "unity_Ambient.rgb"; - else - s = "UNITY_LIGHTMODEL_AMBIENT.rgb"; - - - if( InDeferredPass() ) { - s += "*0.5"; // TODO: Maybe not? - } - - - - - - return s; - - } - - - bool DoPassSphericalHarmonics() { - return DoPassDiffuse() && LightmappedAndLit() && ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ); - } - - bool InDeferredPass() { - return currentPass == PassType.Deferred; - } - - - void Lighting() { - - if( IsShadowOrOutlineOrMetaPass() ) - return; - AppDebug( "Lighting" ); - - /* - if( ps.IsVertexLit() && SF_Evaluator.inFrag ) { - string finalLightStr = "float3 lightFinal = i.vtxLight"; - - if(DoPassDiffuse()) - finalLightStr += " * " + ps.n_diffuse; // TODO: Not ideal, affects both spec and diffuse - - finalLightStr += ";"; - App( finalLightStr ); // TODO: Emissive and other frag effects? TODO: Separate vtx spec and vtx diffuse - return; - } - */ - - bool attenBuiltin = ps.catLighting.IsLit() && ( ps.HasDiffuse() || ps.catLighting.HasSpecular() ) && currentPass != PassType.Deferred; - - if( attenBuiltin || ( dependencies.frag_attenuation && SF_Evaluator.inFrag ) ) - InitAttenuation(); - - if( !ps.catLighting.IsLit() && SF_Evaluator.inFrag ) { - - - string s = "float3 finalColor = "; - - - - //bool doAmbient = (currentPass == ShaderForge.PassType.FwdBase && ps.useAmbient); - bool doEmissive = DoPassEmissive(); - bool doCustomLight = mOut.customLighting.IsConnectedEnabledAndAvailable(); - - bool didAddLight = /*doAmbient || */doEmissive || doCustomLight; - - bool somethingAdded = false; - //if( doAmbient ){ - // s += somethingAdded ? " + ":""; - // s += GetAmbientStr(); - // somethingAdded = true; - //} - if( doEmissive ) { - CalcEmissive(); - s += somethingAdded ? " + " : ""; - s += "emissive"; - somethingAdded = true; - } - if( doCustomLight ) { - s += somethingAdded ? " + " : ""; - s += ps.n_customLighting; - somethingAdded = true; - } - - - - if( !didAddLight ) - s += "0"; // TODO: Don't do lighting at all if this is the case - - - s += ";"; - - App( s ); - - //if( ps.useAmbient && currentPass == PassType.FwdBase ) - // App( "float3 lightFinal = " + ps.n_emissive + "+UNITY_LIGHTMODEL_AMBIENT.xyz;"); // TODO; THIS IS SUPER WEIRD - //else - // App( "float3 lightFinal = " + ps.n_emissive + ";"); // Kinda weird, but emissive = light when unlit is on, so it's needed in additional passes too - return; - - } - - - - // Else if frag light... - - //InitLightDir(); - - //if(SF_Evaluator.inFrag) - - - if( DoPassDiffuse() || DoPassSpecular() ) { - if( ps.catLighting.IsEnergyConserving() ) { - App( "float Pi = 3.141592654;" ); - App( "float InvPi = 0.31830988618;" ); - } - } - - - bool unity5pblDiffusePlugged = ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL && ps.mOut.diffuse.IsConnectedEnabledAndAvailableInThisPass(currentPass); - - - if( DoPassSpecular() || unity5pblDiffusePlugged ) { // Specular - CalcGloss(); - } - - - CalcGIdata(); - - - - - if( DoPassSpecular() ) { // Specular - //if( !InDeferredPass() ) - //CalcGloss(); - CalcSpecular(); - //AppDebug("Spec done"); - } - - if( DoPassDiffuse() ) // Diffuse + texture (If not vertex lit) - CalcDiffuse(); - - if( DoPassEmissive() ) // Emissive - CalcEmissive(); - - /*if(!ps.IsLit() && ps.mOut.customLighting.IsConnectedEnabledAndAvailable() ){ - - App("float3 lightFinal = " + ps.n_customLighting ); - - }*/ - if( /*!ps.IsVertexLit() &&*/ currentProgram == ShaderProgram.Frag ) { - - AppDebug( "Final Color" ); - - /* - bool fresnelIndirectPBL = - Unity5PBL() && - ( ps.catLighting.reflectprobed || ps.HasAmbientSpecular() ) && - (currentPass == PassType.FwdBase || currentPass == PassType.PrePassFinal) - ;*/ - - - - if(!InDeferredPass()){ - - - string diffuse = ps.HasAlpha() && ps.catLighting.transparencyMode == SFPSC_Lighting.TransparencyMode.Reflective ? "diffuse * " + ps.n_alpha : "diffuse" ; - - string s = SumString( - new bool[] { DoPassDiffuse(), DoPassSpecular(), DoPassEmissive() }, - new string[] { diffuse, "specular", "emissive" }, - "0" - ); - - App( "float3 finalColor = " + s + ";" ); - } - - - } - - } - - - void CalcGIdata(){ - - - if( ( currentPass == PassType.FwdBase || currentPass == PassType.Deferred ) && ( ps.catLighting.lightMode == SFPSC_Lighting.LightMode.PBL || ps.catLighting.reflectprobed || LightmappedAndLit() ) ) { - - - AppDebug("GI Data"); - - - if( InDeferredPass() ) { - App( "UnityLight light; // Dummy light" ); - App( "light.color = 0;" ); - App( "light.dir = half3(0,1,0);" ); - App( "light.ndotl = max(0,dot(normalDirection,light.dir));" ); - } else { - App( "UnityLight light;" ); - App( "#ifdef LIGHTMAP_OFF" ); - scope++; - App( "light.color = lightColor;" ); - App( "light.dir = lightDirection;" ); - App( "light.ndotl = LambertTerm (normalDirection, light.dir);" ); - scope--; - App( "#else" ); - scope++; - App( "light.color = half3(0.f, 0.f, 0.f);" ); - App( "light.ndotl = 0.0f;" ); - App( "light.dir = half3(0.f, 0.f, 0.f);" ); - scope--; - App( "#endif" ); - } - - - - App("UnityGIInput d;"); - App("d.light = light;"); - App("d.worldPos = i.posWorld.xyz;"); - App("d.worldViewDir = viewDirection;"); - if( InDeferredPass() ) - App( "d.atten = 1;" ); - else - App("d.atten = attenuation;"); - - if( LightmappedAndLit() ) { - App( "#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)" ); - scope++; - App( "d.ambient = 0;" ); - App( "d.lightmapUV = i.ambientOrLightmapUV;" ); - scope--; - App( "#else" ); - scope++; - App( "d.ambient = i.ambientOrLightmapUV;" ); - scope--; - App( "#endif" ); - } - - - - - if(DoPassSpecular() && ps.catLighting.reflectprobed){ - App( "#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION" ); - scope++; - App("d.boxMin[0] = unity_SpecCube0_BoxMin;"); - App("d.boxMin[1] = unity_SpecCube1_BoxMin;"); - scope--; - App( "#endif" ); - - App( "#if UNITY_SPECCUBE_BOX_PROJECTION" ); - scope++; - App("d.boxMax[0] = unity_SpecCube0_BoxMax;"); - App("d.boxMax[1] = unity_SpecCube1_BoxMax;"); - App("d.probePosition[0] = unity_SpecCube0_ProbePosition;"); - App("d.probePosition[1] = unity_SpecCube1_ProbePosition;"); - scope--; - App( "#endif" ); - - App("d.probeHDR[0] = unity_SpecCube0_HDR;"); - App("d.probeHDR[1] = unity_SpecCube1_HDR;"); - - } - - - string glossStr = DoPassSpecular() ? "gloss" : "0"; - - App( "Unity_GlossyEnvironmentData ugls_en_data;" ); - App( "ugls_en_data.roughness = 1.0 - " + glossStr + ";" ); - App( "ugls_en_data.reflUVW = viewReflectDirection;" ); - - App( "UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );" ); - - - if( !InDeferredPass() ) { - App ("lightDirection = gi.light.dir;"); - App ("lightColor = gi.light.color;"); - } - - - } - - - - - - } - - - - - string SumString( bool[] bools, string[] strings, string defStr ) { - - int validCount = 0; - for( int i = 0; i < bools.Length; i++ ) { - if( bools[i] ) - validCount++; - } - - if( validCount == 0 ) - return defStr; - - string s = ""; - int added = 0; - for( int i = 0; i < strings.Length; i++ ) { - if( bools[i] ) { - s += strings[i]; - added++; - if( added < validCount ) - s += " + "; - } - } - return s; - } - - void InitReflectionDir() { - if( ( !dependencies.frag_viewReflection && currentProgram == ShaderProgram.Frag ) || ( !dependencies.vert_viewReflection && currentProgram == ShaderProgram.Vert ) ) - return; - App( "float3 viewReflectDirection = reflect( -" + VarViewDir() + ", " + VarNormalDir() + " );" ); - } - - void InitSceneColorAndDepth() { - - if( dependencies.frag_sceneDepth ) { - App( "float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);" ); - } - if( dependencies.frag_pixelDepth ) { - App( "float partZ = max(0,i.projPos.z - _ProjectionParams.g);" ); - } - - - if( dependencies.scene_uvs ) { - string sUv = "float2 sceneUVs = "; - - - if( ps.HasRefraction() ) { - sUv += "(i.projPos.xy / i.projPos.w) + " + ps.n_distortion + ";"; - } else { - sUv += "(i.projPos.xy / i.projPos.w);"; - } - - App( sUv ); - } - - - if( dependencies.grabPass ) { - - string s = "float4 sceneColor = "; - s += "tex2D(" + ps.catBlending.GetGrabTextureName() + ", sceneUVs);"; - App( s ); - } - - - - - - } - - - string VarNormalDir() { - if( currentProgram == ShaderProgram.Vert ) - return "o.normalDir"; - return "normalDirection"; - } - - string VarViewDir() { // TODO: Define view variable, dependency etc - if( currentProgram == ShaderProgram.Vert ) - return "normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz)"; - return "viewDirection"; - } - - - - - - - - public string GetUvCompCountString( int channel ) { - bool useFloat4 = false; - if( channel == 0 && dependencies.uv0_float4 ) { - useFloat4 = true; - } else if( channel == 1 && dependencies.uv1_float4 ) { - useFloat4 = true; - } else if( channel == 2 && dependencies.uv2_float4 ) { - useFloat4 = true; - } else if( channel == 3 && dependencies.uv3_float4 ) { - useFloat4 = true; - } - return useFloat4 ? "float4" : "float2"; - } - - - - - - - void VertexInputStruct() { - App( "struct VertexInput {" ); - scope++; - App( "float4 vertex : POSITION;" ); - CommonVertexData(); - scope--; - App( "};" ); - } - - void CommonVertexData() { - if( dependencies.vert_in_normals ) - App( "float3 normal : NORMAL;" ); - if( dependencies.vert_in_tangents ) - App( "float4 tangent : TANGENT;" ); - if( dependencies.uv0 ) - App( GetUvCompCountString( 0 ) + " texcoord0 : TEXCOORD0;" ); - if( dependencies.uv1 ) - App( GetUvCompCountString( 1 ) + " texcoord1 : TEXCOORD1;" ); - if( dependencies.uv2 ) - App( GetUvCompCountString( 2 ) + " texcoord2 : TEXCOORD2;" ); - if( dependencies.uv3 ) - App( GetUvCompCountString( 3 ) + " texcoord3 : TEXCOORD3;" ); - if( dependencies.vert_in_vertexColor ) - App( "float4 vertexColor : COLOR;" ); - } - - void TransferCommonData() { - App( "o.vertex = v.vertex;" ); - if( dependencies.vert_in_normals ) - App( "o.normal = v.normal;" ); - if( dependencies.vert_in_tangents ) - App( "o.tangent = v.tangent;" ); - if( inTess ) { - if( dependencies.uv0 ) - App( "o.texcoord0 = v.texcoord0;" ); - if( dependencies.uv1 ) - App( "o.texcoord1 = v.texcoord1;" ); - if( dependencies.uv2 ) - App( "o.texcoord2 = v.texcoord2;" ); - if( dependencies.uv3 ) - App( "o.texcoord3 = v.texcoord3;" ); - } else { - if( dependencies.uv0 ) - App( "o.uv0 = v.texcoord0;" ); - if( dependencies.uv1 ) - App( "o.uv1 = v.texcoord1;" ); - if( dependencies.uv2 ) - App( "o.uv2 = v.texcoord2;" ); - if( dependencies.uv3 ) - App( "o.uv3 = v.texcoord3;" ); - } - - if( dependencies.vert_in_vertexColor ) - App( "o.vertexColor = v.vertexColor;" ); - } - - - public string GetVertOutTexcoord( bool numberOnly = false ) { - if( numberOnly ) - return dependencies.GetVertOutTexcoord(); - return ( " : TEXCOORD" + dependencies.GetVertOutTexcoord() + ";" ); - } - - void VertexOutputStruct() { - App( "struct VertexOutput {" ); - scope++; - { - if( currentPass == PassType.ShadCast ) { - App( "V2F_SHADOW_CASTER;" ); - dependencies.IncrementTexCoord( 1 ); - } else { - App( "float4 pos : SV_POSITION;" ); // Already included in shadow passes - } - - if( ps.catLighting.IsVertexLit() ) - App( "float3 vtxLight : COLOR;" ); - //if( DoPassSphericalHarmonics() && !ps.highQualityLightProbes ) - // App ("float3 shLight" + GetVertOutTexcoord() ); - if( dependencies.uv0_frag ) - App( GetUvCompCountString( 0 ) + " uv0" + GetVertOutTexcoord() ); - if( dependencies.uv1_frag ) - App( GetUvCompCountString( 1 ) + " uv1" + GetVertOutTexcoord() ); - if( dependencies.uv2_frag ) - App( GetUvCompCountString( 2 ) + " uv2" + GetVertOutTexcoord() ); - if( dependencies.uv3_frag ) - App( GetUvCompCountString( 3 ) + " uv3" + GetVertOutTexcoord() ); - if( dependencies.vert_out_worldPos ) - App( "float4 posWorld" + GetVertOutTexcoord() ); - if( dependencies.vert_out_normals ) - App( "float3 normalDir" + GetVertOutTexcoord() ); - if( dependencies.vert_out_tangents ) - App( "float3 tangentDir" + GetVertOutTexcoord() ); - if( dependencies.vert_out_bitangents ) - App( "float3 bitangentDir" + GetVertOutTexcoord() ); - if( dependencies.vert_out_screenPos ) - App( "float4 screenPos" + GetVertOutTexcoord() ); - if( dependencies.vert_in_vertexColor ) - App( "float4 vertexColor : COLOR;" ); - if( dependencies.frag_projPos ) - App( "float4 projPos" + GetVertOutTexcoord() ); - if( ShouldUseLightMacros() ) - App( "LIGHTING_COORDS(" + GetVertOutTexcoord( true ) + "," + GetVertOutTexcoord( true ) + ")" ); - if( UseUnity5FogInThisPass() ) - App( "UNITY_FOG_COORDS(" + GetVertOutTexcoord( true ) + ")" ); // New in Unity 5 - - bool sh = DoPassSphericalHarmonics() && !ps.catLighting.highQualityLightProbes; - bool lm = LightmapThisPass(); - - - string shlmTexCoord = GetVertOutTexcoord(); - - - // Unity 5 LMs - if( sh || lm ) { - App( "#if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)" ); - scope++; - App( "float4 ambientOrLightmapUV" + shlmTexCoord ); - scope--; - App( "#endif" ); - } - - - - - - - - - - } - scope--; - App( "};" ); - } - - - - public bool ShouldUseLightMacros() { - return ( ( currentPass == PassType.FwdAdd || ( currentPass == PassType.FwdBase && !ps.catBlending.ignoreProjector ) ) && ( dependencies.UsesLightNodes() || ps.catLighting.IsLit() ) ); - } - - public bool IsShadowPass() { - return currentPass == PassType.ShadCast; - } - - public bool IsShadowOrOutlineOrMetaPass() { - return currentPass == PassType.Outline || currentPass == PassType.Meta || IsShadowPass(); - } - - public bool IncludeLightingCginc() { - return LightmappedAndLit() || IsShadowPass() || ( cNodes.Where( x => x is SFN_LightAttenuation ).Count() > 0 ); - } - - - void Vertex() { - currentProgram = ShaderProgram.Vert; - App( "VertexOutput vert (VertexInput v) {" ); - scope++; - App( "VertexOutput o = (VertexOutput)0;" ); - - - - if( dependencies.uv0_frag ) - App( "o.uv0 = v.texcoord0;" ); - if( dependencies.uv1_frag ) - App( "o.uv1 = v.texcoord1;" ); - if( dependencies.uv2_frag ) - App( "o.uv2 = v.texcoord2;" ); - if( dependencies.uv3_frag ) - App( "o.uv3 = v.texcoord3;" ); - if( dependencies.vert_out_vertexColor ) - App( "o.vertexColor = v.vertexColor;" ); - - - bool lm = LightmapThisPass(); - bool sh = DoPassSphericalHarmonics() && !ps.catLighting.highQualityLightProbes; - - if( lm ){ - App("#ifdef LIGHTMAP_ON"); - scope++; - App( "o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;" ); - App( "o.ambientOrLightmapUV.zw = 0;" ); - - scope--; - if(sh){ - App("#elif UNITY_SHOULD_SAMPLE_SH"); - scope++; - } else { - App("#endif"); - } - } - - if( sh ) { - - if( !lm ) { - App( "#if SHOULD_SAMPLE_SH" ); - scope++; - } - //App( "o.ambientOrLightmapUV.rgb = 0.01*ShadeSH9(float4(UnityObjectToWorldNormal(v.normal),1));" ); - //if( !lm ) { - scope--; - App( "#endif" ); - //} - - } - - if( lm ) { - App( "#ifdef DYNAMICLIGHTMAP_ON" ); - scope++; - App( "o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;" ); - scope--; - App("#endif"); - } - - - - - - - if( dependencies.vert_out_normals ) - InitNormalDirVert(); - if( dependencies.vert_out_tangents ) - InitTangentDirVert(); - if( dependencies.vert_out_bitangents ) - InitBitangentDirVert(); - - InitObjectPos(); - - if( editor.nodeView.treeStatus.viewDirectionInVertOffset ) { - InitViewDirVert(); - } - - InitObjectScale(); - - if( editor.mainNode.vertexOffset.IsConnectedAndEnabled() ) { - - if( ps.catGeometry.vertexOffsetMode == SFPSC_Geometry.VertexOffsetMode.Relative ) - App( "v.vertex.xyz += " + ps.n_vertexOffset + ";" ); - else - App( "v.vertex.xyz = " + ps.n_vertexOffset + ";" ); - } - - if( dependencies.vert_out_worldPos ) - App( "o.posWorld = mul(unity_ObjectToWorld, v.vertex);" ); - - - - - InitTangentTransformFrag(); - - if( !editor.nodeView.treeStatus.viewDirectionInVertOffset ) { - InitViewDirVert(); - } - - InitReflectionDir(); - if( dependencies.frag_lightDirection ) { - InitLightDir(); - } - if(dependencies.frag_lightColor) - InitLightColor(); - InitHalfVector(); - - string positioningPrefix; - if( ps.catExperimental.forceSkipModelProjection ){ - positioningPrefix = "mul(UNITY_MATRIX_VP, "; // Local space. Broken for shadows due to TRANSFER_SHADOW_CASTER assuming model projections - } else { - positioningPrefix = "UnityObjectToClipPos( "; // World space - } - - string positioningSuffix = " );"; - if( ps.catGeometry.vertexPositioning == SFPSC_Geometry.VertexPositioning.ClipSpace ) { - positioningPrefix = ""; - positioningSuffix = ";"; - } - if( ps.catGeometry.vertexPositioning == SFPSC_Geometry.VertexPositioning.Billboard ) { - - - App("float4x4 bbmv = UNITY_MATRIX_MV;"); - App( "bbmv._m00 = -1.0/length(unity_WorldToObject[0].xyz);" ); - App( "bbmv._m10 = 0.0f;" ); - App( "bbmv._m20 = 0.0f;" ); - App( "bbmv._m01 = 0.0f;" ); - App( "bbmv._m11 = -1.0/length(unity_WorldToObject[1].xyz);" ); - App( "bbmv._m21 = 0.0f;" ); - App( "bbmv._m02 = 0.0f;" ); - App( "bbmv._m12 = 0.0f;" ); - App( "bbmv._m22 = -1.0/length(unity_WorldToObject[2].xyz);" ); - - - positioningPrefix = "mul( UNITY_MATRIX_P, mul( bbmv, "; - positioningSuffix = " ));"; - } - - - if( currentPass == PassType.Outline ) { - string dir = ""; - if( ps.catGeometry.outlineMode == SFPSC_Geometry.OutlineMode.VertexNormals ) { - dir = "v.normal"; - } else if( ps.catGeometry.outlineMode == SFPSC_Geometry.OutlineMode.VertexColors ) { - dir = "v.vertexColor"; - } else if( ps.catGeometry.outlineMode == SFPSC_Geometry.OutlineMode.FromOrigin ) { - dir = "normalize(v.vertex)"; - } - App( "o.pos = "+ positioningPrefix +"float4(v.vertex.xyz + "+dir+"*" + ps.n_outlineWidth + ",1)" + positioningSuffix ); - - } else if(currentPass == PassType.Meta ){ - App( "o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );" ); - } else { - App( "o.pos = " + positioningPrefix + "v.vertex" + positioningSuffix ); - } - - if( ps.catGeometry.showPixelSnap ) { - App( "#ifdef PIXELSNAP_ON" ); - scope++; - App( "o.pos = UnityPixelSnap(o.pos);" ); - scope--; - App( "#endif" ); - } - - - // New in Unity 5 - if( UseUnity5FogInThisPass() ) { - App( "UNITY_TRANSFER_FOG(o,o.pos);" ); - } - - - if( dependencies.frag_projPos ) { - App( "o.projPos = ComputeScreenPos (o.pos);" ); - App( "COMPUTE_EYEDEPTH(o.projPos.z);" ); - } - - - if( dependencies.vert_out_screenPos ) { // TODO: Select screen pos accuracy etc - - if( ps.catGeometry.highQualityScreenCoords ) { - App( "o.screenPos = o.pos;" ); // Unpacked per-pixel - } else { - App( "o.screenPos = float4( o.pos.xy / o.pos.w, 0, 0 );" ); - App( "o.screenPos.y *= _ProjectionParams.x;" ); - } - } - - - - if( LightmapThisPass() ){ - - // TODO, I think - - } - - /* MOVE THIS: - App( "float4 unity_LightmapST;"); - App( "#ifdef DYNAMICLIGHTMAP_ON"); - scope++; - App( "float4 unity_DynamicLightmapST;"); - scope--; - App( "#endif"); -*/ - - - - - if( currentPass == PassType.ShadCast ) { - App( "TRANSFER_SHADOW_CASTER(o)" ); - } else { - if( ps.catLighting.IsVertexLit() ) - Lighting(); - else if( ShouldUseLightMacros() ) - App( "TRANSFER_VERTEX_TO_FRAGMENT(o)" ); - } - - App( "return o;" ); - - ResetDefinedState(); - End(); - } - - - void Fragment() { - currentProgram = ShaderProgram.Frag; - - if( currentPass == PassType.Meta ) { - string vface = ""; - if( dependencies.frag_facing ) { - vface = ", float facing : VFACE"; - } - App( "float4 frag(VertexOutput i" + vface + ") : SV_Target {" ); - } else if(currentPass == PassType.Deferred) { - App( "void frag(" ); - scope++; - App( "VertexOutput i," ); - App( "out half4 outDiffuse : SV_Target0," ); - App( "out half4 outSpecSmoothness : SV_Target1," ); - App( "out half4 outNormal : SV_Target2," ); - if( dependencies.frag_facing ) { - App( "out half4 outEmission : SV_Target3," ); - App( "float facing : VFACE )" ); - } else { - App( "out half4 outEmission : SV_Target3 )" ); - } - scope--; - App( "{" ); - } else { - string vface = ""; - if( dependencies.frag_facing ) { - vface = ", float facing : VFACE"; - } - App( "float4 frag(VertexOutput i" + vface + ") : COLOR {" ); - } - - scope++; - - if( dependencies.frag_facing ) { - App( "float isFrontFace = ( facing >= 0 ? 1 : 0 );" ); - App( "float faceSign = ( facing >= 0 ? 1 : -1 );" ); - } - - InitObjectPos(); - InitObjectScale(); - - if( ps.catGeometry.normalQuality == SFPSC_Geometry.NormalQuality.Normalized && dependencies.frag_normalDirection ) { - App( "i.normalDir = normalize(i.normalDir);" ); - if( dependencies.frag_facing ) { - App( "i.normalDir *= faceSign;" ); - } - } - - if( dependencies.vert_out_screenPos && ps.catGeometry.highQualityScreenCoords ) { - App( "i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );" ); - App( "i.screenPos.y *= _ProjectionParams.x;" ); - } - - InitTangentTransformFrag(); - InitViewDirFrag(); - InitNormalDirFrag(); - InitReflectionDir(); - - InitSceneColorAndDepth(); - - CheckClip(); - - PrepareLightmapVars(); - - - if( dependencies.frag_lightDirection ) - InitLightDir(); - if(dependencies.frag_lightColor) - InitLightColor(); - InitHalfVector(); - - - - - - Lighting(); // This is ignored in shadow passes - - - if( currentPass == PassType.Meta ) { - LightmapMetaPassFrag(); - } else if( currentPass == PassType.Deferred ) { - DeferredFragReturn(); - } else if( currentPass == PassType.ShadCast ) { - App( "SHADOW_CASTER_FRAGMENT(i)" ); - } else if( currentPass == PassType.Outline ) { - App( "return fixed4(" + ps.n_outlineColor + ",0);" ); - } else { - - //if(ps.mOut.diffuse.IsConnectedEnabledAndAvailable()){ - // AppFinalOutput("lightFinal + " + "diffuse", ps.n_alpha); // This is really weird, it should already be included in the light calcs. Do more research // TODO - //}else - if( currentPass == PassType.FwdAdd ) { - if(ps.catLighting.transparencyMode == SFPSC_Lighting.TransparencyMode.Fade) - AppFinalOutput( "finalColor * " + ps.n_alpha, "0" ); - else - AppFinalOutput( "finalColor", "0" ); - } else { - - if( ps.catBlending.alphaToCoverage && currentPass == PassType.FwdBase && ps.HasAlpha() == false && ps.HasAlphaClip() ) { - AppFinalOutput( "finalColor", "(" + ps.n_alphaClip + ") * 2.0 - 1.0" ); - } else { - AppFinalOutput( "finalColor", ps.n_alpha ); - } - } - - - } - - End(); - } - - void DeferredFragReturn() { - - - // DIFFUSE - if( ps.HasDiffuse() ) { - if( ps.mOut.diffuseOcclusion.IsConnectedEnabledAndAvailable() ) { - App( "outDiffuse = half4( diffuseColor, " + ps.n_diffuseOcclusion + " );" ); - } else { - App( "outDiffuse = half4( diffuseColor, 1 );" ); - } - } else { - App( "outDiffuse = half4( 0, 0, 0, 1 );" ); - } - - // SPEC & GLOSS - if( ps.HasSpecular() ) { - if( ps.HasGloss() ) { - App( "outSpecSmoothness = half4( specularColor, gloss );" ); - } else { - App( "outSpecSmoothness = half4( specularColor, 0.5 );" ); - } - } else { - App( "outSpecSmoothness = half4(0,0,0,0);" ); - } - - // NORMALS - App( "outNormal = half4( normalDirection * 0.5 + 0.5, 1 );" ); - - // EMISSION - if( ps.HasEmissive() ) { - App( "outEmission = half4( "+ps.n_emissive+", 1 );" ); - } else { - App( "outEmission = half4(0,0,0,1);" ); - } - - - bool specAmb = LightmappedAndLit() && ps.HasSpecular() || ps.mOut.ambientSpecular.IsConnectedEnabledAndAvailable(); - bool diffAmb = LightmappedAndLit() && ps.HasDiffuse() || ps.mOut.ambientDiffuse.IsConnectedEnabledAndAvailable(); - - if( specAmb ) { - if( ps.mOut.ambientSpecular.IsConnectedEnabledAndAvailable() ) { - App( "outEmission.rgb += indirectSpecular;" ); - } else { - App( "outEmission.rgb += indirectSpecular * "+ps.n_specularOcclusion+";" ); - } - } - if( diffAmb ) { - App( "outEmission.rgb += indirectDiffuse * diffuseColor;" ); // No need for diffuse AO, since that's covered already - } - - - App( "#ifndef UNITY_HDR_ON" ); - scope++; - App( "outEmission.rgb = exp2(-outEmission.rgb);" ); - scope--; - App( "#endif" ); - - - - } - - - - void LightmapMetaPassFrag() { - - - bool hasDiffuse = ps.mOut.diffuse.IsConnectedEnabledAndAvailable(); - bool hasSpec = ps.mOut.specular.IsConnectedEnabledAndAvailable(); - bool hasGloss = ps.mOut.gloss.IsConnectedEnabledAndAvailable(); - - - App( "UnityMetaInput o;" ); - App( "UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );" ); - App( "" ); - if( ps.mOut.emissive.IsConnectedEnabledAndAvailable() ) { - App( "o.Emission = " + ps.n_emissive + ";" ); - } else { - App( "o.Emission = 0;" ); - } - App( "" ); - - - if(hasDiffuse) - App( "float3 diffColor = " + ps.n_diffuse + ";" ); - else - App( "float3 diffColor = float3(0,0,0);" ); - - // Handle metallic properly - if( MetallicPBL() ) { - App( "float specularMonochrome;" ); - App( "float3 specColor;" ); - if( hasSpec ) - App( "diffColor = DiffuseAndSpecularFromMetallic( diffColor, " + ps.n_specular + ", specColor, specularMonochrome );" ); - else - App( "diffColor = DiffuseAndSpecularFromMetallic( diffColor, 0, specColor, specularMonochrome );" ); - } else { - if( hasSpec ) { - App( "float3 specColor = " + ps.n_specular + ";" ); - if( Unity5PBL() ) { - App( "float specularMonochrome = max(max(specColor.r, specColor.g),specColor.b);" ); - App( "diffColor *= (1.0-specularMonochrome);" ); - } - } - } - - if( hasGloss ) { - - if( hasSpec ) { - if( ps.catLighting.glossRoughMode == SFPSC_Lighting.GlossRoughMode.Roughness ) { - App( "float roughness = " + ps.n_gloss + ";" ); - } else { - App( "float roughness = 1.0 - " + ps.n_gloss + ";" ); - } - } - - if( hasSpec ) - App( "o.Albedo = diffColor + specColor * roughness * roughness * 0.5;" ); - else - App( "o.Albedo = diffColor;" ); - - } else { - if( hasSpec ) - App( "o.Albedo = diffColor + specColor * 0.125; // No gloss connected. Assume it's 0.5" ); - else - App( "o.Albedo = diffColor;" ); - } - - - - - App( "" ); - //App( "o.Albedo = float3(0,1,0);" ); // Debug - //App( "o.Emission = float3(0,1,0);"); - //App( "" ); - App( "return UnityMetaFragment( o );" ); - - } - - - string GetMaxUvCompCountString() { - return ( dependencies.uv0_float4 || dependencies.uv1_float4 || dependencies.uv2_float4 || dependencies.uv3_float4 ) ? "float4" : "float2"; - } - - - - void TessellationVertexStruct() { - App( "struct TessVertex {" ); - scope++; - App( "float4 vertex : INTERNALTESSPOS;" ); - CommonVertexData(); - scope--; - App( "};" ); - } - - void TessellationPatchConstant() { - App( "struct OutputPatchConstant {" ); - scope++; - App( "float edge[3] : SV_TessFactor;" ); - App( "float inside : SV_InsideTessFactor;" ); - App( "float3 vTangent[4] : TANGENT;" ); - App( GetMaxUvCompCountString() + " vUV[4] : TEXCOORD;" ); - App( "float3 vTanUCorner[4] : TANUCORNER;" ); - App( "float3 vTanVCorner[4] : TANVCORNER;" ); - App( "float4 vCWts : TANWEIGHTS;" ); - scope--; - App( "};" ); - } - - void TessellationVertexTransfer() { - App( "TessVertex tessvert (VertexInput v) {" ); - scope++; - App( "TessVertex o;" ); - TransferCommonData(); - App( "return o;" ); - scope--; - App( "}" ); - } - - void TessellationHullConstant() { - App( "OutputPatchConstant hullconst (InputPatch v) {" ); - scope++; - App( "OutputPatchConstant o = (OutputPatchConstant)0;" ); - App( "float4 ts = Tessellation( v[0], v[1], v[2] );" ); - App( "o.edge[0] = ts.x;" ); - App( "o.edge[1] = ts.y;" ); - App( "o.edge[2] = ts.z;" ); - App( "o.inside = ts.w;" ); - App( "return o;" ); - scope--; - App( "}" ); - } - - void TessellationHull() { - App( "[domain(\"tri\")]" ); - App( "[partitioning(\"fractional_odd\")]" ); - App( "[outputtopology(\"triangle_cw\")]" ); - App( "[patchconstantfunc(\"hullconst\")]" ); - App( "[outputcontrolpoints(3)]" ); - App( "TessVertex hull (InputPatch v, uint id : SV_OutputControlPointID) {" ); - scope++; - App( "return v[id];" ); - scope--; - App( "}" ); - } - - - void TessellationDomain() { - - App( "[domain(\"tri\")]" ); - App( "VertexOutput domain (OutputPatchConstant tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) {" ); - scope++; - App( "VertexInput v = (VertexInput)0;" ); - - TransferBarycentric( "vertex" ); - if( dependencies.vert_in_normals ) - TransferBarycentric( "normal" ); - if( dependencies.vert_in_tangents ) - TransferBarycentric( "tangent" ); - if( dependencies.uv0 ) - TransferBarycentric( "texcoord0" ); - if( dependencies.uv1 ) - TransferBarycentric( "texcoord1" ); - if( dependencies.vert_in_vertexColor ) - TransferBarycentric( "vertexColor" ); - if( dependencies.displacement ) - App( "displacement(v);" ); - App( "VertexOutput o = vert(v);" ); - App( "return o;" ); - scope--; - App( "}" ); - - } - - void TransferBarycentric( string s ) { - App( "v." + s + " = vi[0]." + s + "*bary.x + vi[1]." + s + "*bary.y + vi[2]." + s + "*bary.z;" ); - } - - - void FuncTessellation() { - - switch( ps.catGeometry.tessellationMode ) { - case SFPSC_Geometry.TessellationMode.Regular: - - App("float Tessellation(TessVertex v){");// First, we need a per-vertex evaluation of the tess factor - scope++; - App( "return " + ps.n_tessellation + ";"); - scope--; - App("}"); - - App( "float4 Tessellation(TessVertex v, TessVertex v1, TessVertex v2){" ); - scope++; - App( "float tv = Tessellation(v);" ); - App( "float tv1 = Tessellation(v1);" ); - App( "float tv2 = Tessellation(v2);" ); - App( "return float4( tv1+tv2, tv2+tv, tv+tv1, tv+tv1+tv2 ) / float4(2,2,2,3);" ); - scope--; - App( "}" ); - break; - - case SFPSC_Geometry.TessellationMode.EdgeLength: - App( "float4 Tessellation(TessVertex v, TessVertex v1, TessVertex v2){" ); - scope++; - App( "return UnityEdgeLengthBasedTess(v.vertex, v1.vertex, v2.vertex, " + ps.n_tessellation + ");" ); - scope--; - App( "}" ); - break; - } - - } - - void FuncDisplacement() { - if( !dependencies.displacement ) - return; - App( "void displacement (inout VertexInput v){" ); - scope++; - App( "v.vertex.xyz += " + ps.n_displacement + ";" ); - scope--; - App( "}" ); - } - - - - - - - void Tessellation() { - if( !dependencies.tessellation ) - return; - currentProgram = ShaderProgram.Tess; // Not really, but almost - - App( "#ifdef UNITY_CAN_COMPILE_TESSELLATION" ); - scope++; - //------------------------------------------------------------ - TessellationVertexStruct(); - TessellationPatchConstant(); - TessellationVertexTransfer(); - ResetDefinedState(); // A bit of a hack - FuncDisplacement(); - ResetDefinedState(); // A bit of a hack - FuncTessellation(); - TessellationHullConstant(); - TessellationHull(); - TessellationDomain(); - //------------------------------------------------------------ - scope--; - App( "#endif" ); - - ResetDefinedState(); - } - - - - - - - - - // Todo: threshold - void CheckClip() { - if( !ps.UseClipping() || currentPass == PassType.Meta ) - return; - if( ps.catBlending.dithering == Dithering.Off ) { - App( "clip(" + ps.n_alphaClip + " - 0.5);" ); - } else { - string ditherStr = SFPSC_Blending.strDithering[(int)ps.catBlending.dithering].ToString().Split( ' ' )[0]; - App( "clip( BinaryDither" + ditherStr + "(" + ps.n_alphaClip + " - 1.5, sceneUVs) );" ); - } - - } - - - - void Fallback() { - if( ps.catExperimental.forceNoFallback ) - return; - if( !string.IsNullOrEmpty( ps.catMeta.fallback ) ) - App( "FallBack \"" + ps.catMeta.fallback + "\"" ); - else - App( "FallBack \"Diffuse\"" ); // Needed for shadows! - } - - void WriteCustomEditor() { - App( "CustomEditor \"ShaderForgeMaterialInspector\"" ); - } - - - public void GrabPass() { - if( !dependencies.grabPass ) - return; - if(ps.catBlending.perObjectRefraction) - App( "GrabPass{ }" ); - else - App( "GrabPass{ \"" + ps.catBlending.GetGrabTextureName() + "\" }" ); - - } - - //////////////////////////////////////////////////////////////// DEFERRED - - void DeferredPass() { - currentPass = PassType.Deferred; - UpdateDependencies(); - ResetDefinedState(); - dependencies.ResetTexcoordNumbers(); - App( "Pass {" ); - scope++; - { - App( "Name \"DEFERRED\"" ); // TODO this name is a guess - PassTags(); - RenderSetup(); - BeginCG(); - { - CGvars(); - VertexInputStruct(); - VertexOutputStruct(); - Vertex(); - Tessellation(); - Fragment(); - } - EndCG(); - } - End(); - RemoveGhostNodes(); - } - - - //////////////////////////////////////////////////////////////// - - - - - void ForwardBasePass() { - currentPass = PassType.FwdBase; - UpdateDependencies(); - ResetDefinedState(); - dependencies.ResetTexcoordNumbers(); - App( "Pass {" ); - scope++; - { - App( "Name \"FORWARD\"" ); - PassTags(); - RenderSetup(); - BeginCG(); - { - CGvars(); - VertexInputStruct(); - VertexOutputStruct(); - Vertex(); - Tessellation(); - Fragment(); - } - EndCG(); - } - End(); - RemoveGhostNodes(); - } - - public void ForwardLightPass() { - - // TODO: FIX - // Only when real-time light things are connected. These are: - // Diffuse - // Specular - // Although could be any D: - - bool customLit = dependencies.UsesLightNodes(); - bool builtinLit = ps.catLighting.IsLit() && ( ps.HasDiffuse() || ps.catLighting.HasSpecular() ); - - bool needsLightPass = ( builtinLit || customLit ) && ps.catLighting.UseMultipleLights(); - - if( !needsLightPass ) - return; - - - - currentPass = PassType.FwdAdd; - UpdateDependencies(); - ResetDefinedState(); - dependencies.ResetTexcoordNumbers(); - App( "Pass {" ); - scope++; - { - App( "Name \"FORWARD_DELTA\"" ); - PassTags(); - RenderSetup(); - BeginCG(); - { - CGvars(); - VertexInputStruct(); - VertexOutputStruct(); - Vertex(); - Tessellation(); - Fragment(); - } - EndCG(); - } - End(); - RemoveGhostNodes(); - } - - - - // Only needed when using alpha clip and/or vertex offset (May be needed with Tessellation as well) - public void ShadowCasterPass() { - bool shouldUse = ps.UseClipping() || mOut.vertexOffset.IsConnectedAndEnabled() || mOut.displacement.IsConnectedAndEnabled() || ps.catGeometry.cullMode != SFPSC_Geometry.CullMode.BackfaceCulling; - if( !shouldUse || ps.catExperimental.forceNoShadowPass ) - return; - currentPass = PassType.ShadCast; - UpdateDependencies(); - ResetDefinedState(); - dependencies.ResetTexcoordNumbers(); - - App( "Pass {" ); - scope++; - { - App( "Name \"ShadowCaster\"" ); - PassTags(); - RenderSetup(); - BeginCG(); - { - CGvars(); - VertexInputStruct(); - VertexOutputStruct(); - Vertex(); - Tessellation(); - Fragment(); - } - EndCG(); - } - End(); - RemoveGhostNodes(); - } - - - public void OutlinePass() { - if( !mOut.outlineWidth.IsConnectedAndEnabled() ) - return; - currentPass = PassType.Outline; - UpdateDependencies(); - ResetDefinedState(); - dependencies.ResetTexcoordNumbers(); - App( "Pass {" ); - scope++; - { - App( "Name \"Outline\"" ); - PassTags(); - RenderSetup(); - BeginCG(); - { - CGvars(); - VertexInputStruct(); - VertexOutputStruct(); - Vertex(); - Tessellation(); - Fragment(); - } - EndCG(); - } - End(); - RemoveGhostNodes(); - } - - public void MetaPass() { - if( ps.catLighting.includeMetaPass == false ) - return; - if( !ps.catLighting.bakedLight || ( !mOut.diffuse.IsConnectedEnabledAndAvailable() && !mOut.emissive.IsConnectedAndEnabled() ) ) - return; - currentPass = PassType.Meta; - UpdateDependencies(); - ResetDefinedState(); - dependencies.ResetTexcoordNumbers(); - App( "Pass {" ); - scope++; - { - App( "Name \"Meta\"" ); - PassTags(); - RenderSetup(); - BeginCG(); - { - CGvars(); - VertexInputStruct(); - VertexOutputStruct(); - Vertex(); - Tessellation(); - Fragment(); - } - EndCG(); - } - End(); - RemoveGhostNodes(); - } - - - - - - public void ResetDefinedState() { - for( int i = 0; i < cNodes.Count; i++ ) { - cNodes[i].varDefined = false; - cNodes[i].varPreDefined = false; - } - } - - - - public void Evaluate() { - - if( SF_Debug.evalFlow ) - Debug.Log( "SHADER EVALUATING" ); - - editor.ps.fChecker.UpdateAvailability(); - if( !editor.nodeView.treeStatus.CheckCanCompile() ) { - return; - } - ps.UpdateAutoSettings(); - currentPass = PassType.FwdBase; - PrepareEvaluation(); - UpdateDependencies(); - shaderString = ""; - scope = 0; - - //EditorUtility.UnloadUnusedAssets(); - GC.Collect(); - - - BeginShader(); - { - PropertiesShaderLab(); - BeginSubShader(); - { - SubShaderTags(); - if( ps.catMeta.LOD > 0 ) - App( "LOD " + ps.catMeta.LOD ); - - GrabPass(); - OutlinePass(); - if( ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred ) { - DeferredPass(); - } - ForwardBasePass(); - ForwardLightPass(); - ShadowCasterPass(); - MetaPass(); - - } - End(); - Fallback(); - WriteCustomEditor(); - } - End(); - - SaveShaderAsset(); - ApplyPropertiesToMaterial(); - editor.ShaderOutdated = UpToDateState.UpToDate; - - } - - - //string GetEditorVersionOfShader() { - //return shaderString.Replace( "_Time", "_EditorTime" ); - // shaderString.Replace( "_SinTime", "_SinTimeEditor" ); - // shaderString.Replace( "_CosTime", "_CosTimeEditor" ); - // shaderString.Replace( "_SinTime", "_SinTimeEditor" ); - //return shaderString; - //} - - - - - public void SaveShaderAsset() { - - //Debug.Log("SaveShaderAsset()"); - string fileContent = editor.nodeView.GetNodeDataSerialized() + "\n\n" + shaderString; - - - // Version control unlocking - Asset shaderAsset = UnityEditor.VersionControl.Provider.GetAssetByPath( editor.GetShaderFilePath() ); - if( shaderAsset.locked || shaderAsset.readOnly ) { - UnityEditor.VersionControl.Provider.Lock( shaderAsset, false ); - UnityEditor.VersionControl.Provider.Checkout( shaderAsset, CheckoutMode.Both ); - } - - string path = editor.GetShaderFilePath(); - StreamWriter sw = new StreamWriter( path ); - sw.Write( fileContent ); - sw.Flush(); - sw.Close(); - - // Shader written, set default textures in import settings - List texNames = new List(); - List textures = new List(); - - // Collect all texture names and references - for( int i = 0; i < editor.nodes.Count; i++ ) { - if( editor.nodes[i] is SFN_Tex2d ) { - SFN_Tex2d t2d = editor.nodes[i] as SFN_Tex2d; - if( !t2d.TexAssetConnected() && t2d.textureAsset != null) { - texNames.Add( t2d.property.nameInternal ); - textures.Add( t2d.textureAsset ); - } - } else if( editor.nodes[i] is SFN_Tex2dAsset ) { - SFN_Tex2dAsset t2dAsset = editor.nodes[i] as SFN_Tex2dAsset; - if( t2dAsset.textureAsset != null ) { - texNames.Add( t2dAsset.property.nameInternal ); - textures.Add( t2dAsset.textureAsset ); - } - } - } - - // Apply default textures to the shader importer - ShaderImporter sImporter = ShaderImporter.GetAtPath( path ) as ShaderImporter; - sImporter.SetDefaultTextures( texNames.ToArray(), textures.ToArray() ); - - - try { - AssetDatabase.Refresh( ImportAssetOptions.DontDownloadFromCacheServer ); - } catch( Exception e ) { - e.ToString(); - } - - editor.OnShaderEvaluated(); - - } - - - - - - public void ApplyPropertiesToMaterial() { - for( int i = 0; i < cNodes.Count; i++ ) { - if( !cNodes[i].IsProperty() ) - continue; - ApplyProperty( cNodes[i] ); - } - } - - public void ApplyProperty( SF_Node node ) { - - if( !node.IsProperty() ) - return; - - Material m = SF_Editor.instance.preview.InternalMaterial; - switch( node.GetType().ToString() ) { - case ( "ShaderForge.SFN_Tex2d" ): - SFN_Tex2d texNode = (SFN_Tex2d)node; - m.SetTexture( texNode.property.GetVariable(), texNode.TextureAsset ); - break; - case ( "ShaderForge.SFN_Tex2dAsset" ): - SFN_Tex2dAsset texAssetNode = (SFN_Tex2dAsset)node; - m.SetTexture( texAssetNode.property.GetVariable(), texAssetNode.textureAsset ); - break; - case ( "ShaderForge.SFN_Cubemap" ): - SFN_Cubemap cubeNode = (SFN_Cubemap)node; - m.SetTexture( cubeNode.property.GetVariable(), cubeNode.cubemapAsset ); - break; - case ( "ShaderForge.SFN_Slider" ): - SFN_Slider sliderNode = (SFN_Slider)node; - m.SetFloat( sliderNode.property.GetVariable(), sliderNode.current ); - break; - case ( "ShaderForge.SFN_Color" ): - SFN_Color colorNode = (SFN_Color)node; - m.SetColor( colorNode.property.GetVariable(), colorNode.GetColor() ); - break; - case ( "ShaderForge.SFN_ValueProperty" ): - SFN_ValueProperty valueNode = (SFN_ValueProperty)node; - m.SetFloat( valueNode.property.GetVariable(), valueNode.texture.dataUniform[0] ); - break; - case ( "ShaderForge.SFN_ToggleProperty" ): - SFN_ToggleProperty toggleNode = (SFN_ToggleProperty)node; - m.SetFloat( toggleNode.property.GetVariable(), toggleNode.texture.dataUniform[0] ); - break; - case ( "ShaderForge.SFN_SwitchProperty" ): - SFN_SwitchProperty switchNode = (SFN_SwitchProperty)node; - m.SetFloat( switchNode.property.GetVariable(), switchNode.on ? 1f : 0f ); - break; - case ( "ShaderForge.SFN_Vector4Property" ): - SFN_Vector4Property vector4Node = (SFN_Vector4Property)node; - m.SetVector( vector4Node.property.GetVariable(), vector4Node.texture.dataUniform ); - break; - case ( "ShaderForge.SFN_StaticBranch" ): - SFN_StaticBranch sbNode = (SFN_StaticBranch)node; - - if( sbNode.on ) { - //Debug.Log("Enabling keyword"); - //m.EnableKeyword(sbNode.property.nameInternal); - } else { - //Debug.Log("Disabling keyword"); - //m.DisableKeyword(sbNode.property.nameInternal); - } - - break; - } - } - - - - - void End() { - scope--; - App( "}" ); - } - public void AppIfNonEmpty( string s ) { - if( !string.IsNullOrEmpty( s ) ) - App( s ); - } - public void AppFormat( string s, params object[] args ) { - App( string.Format( s, args ) ); - } - public void App( string s ) { - if( s.Contains( "\n" ) ) { - string[] split = s.Split( '\n' ); - for( int i = 0; i < split.Length; i++ ) { - App( split[i] ); - } - } else { - shaderString += GetScopeTabs() + s + "\n"; - } - } - public void AppDebug( string s ) { - //if(DEBUG) - - string scopeSlashes = GetScopeTabs().Replace( ' ', '/' ); - - if( scopeSlashes.Length < 2 ) - scopeSlashes = "//"; - - - shaderString += scopeSlashes.Substring( Mathf.Min( s.Length + 2, scopeSlashes.Length - 2 ) ) + " " + s + ":\n"; - } - string GetScopeTabs() { - string s = ""; - for( int i = 0; i < scope; i++ ) { - s += " "; - } - return s; - } - void NewLine() { - shaderString += "\n"; - } - - // shaderEvaluator.previewBackgroundColor - - - } -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs.meta deleted file mode 100755 index 0bf50688..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/SF_Evaluator.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8d4397298714b429da31207ae8e1b476 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/_NewSystem.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/_NewSystem.meta deleted file mode 100644 index ff3fdb17..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/_NewSystem.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: 2eb134ad201984c70b54a6af60bf785a -folderAsset: yes -DefaultImporter: - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/_NewSystem/DependencyTree.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/_NewSystem/DependencyTree.cs deleted file mode 100644 index 570eb04d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/_NewSystem/DependencyTree.cs +++ /dev/null @@ -1,102 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; -using System.Linq; - -namespace ShaderForge{ - - - public class DependencyTree where T : IDependable{ - - public List> tree; - - public DependencyTree(){ - tree = new List>(); - } - - - - public void Add(params IDependable[] deps){ - - } - - public void Add(IDependable dep){ - AddUnique(dep); - foreach(IDependable d in dep.Dependencies){ - AddUnique(d); - } - } - - private void AddUnique(IDependable dep){ - if(!tree.Contains(dep)){ - tree.Add(dep); - } - } - - /* - public void Add(T obj){ - tree.Add(obj); - } - - public void Add(List> objs){ - tree.AddRange(objs); - } - */ - public void Sort(){ - AssignDepthValues(); - SortByDepth(); - } - - private void MoveUpNode(IDependable dp, bool initial){ - if(!initial) - dp.Depth++; - foreach(IDependable d in dp.Dependencies){ - if(d.Depth <= dp.Depth){ - MoveUpNode(d, initial:false); - } - } - } - - private void AssignDepthValues(){ - ResetNodeDepths(); - foreach(IDependable dp in tree) - MoveUpNode(dp, initial:true); - } - - private void SortByDepth(){ - tree.OrderBy(o=>o.Depth).ToList(); - } - - private void ResetNodeDepths(){ - foreach(IDependable dp in tree) - dp.Depth = 0; - } - - - public List> GetDependenciesByGroup(out int maxWidth){ - List> groups = new List>(); - maxWidth = 0; - - int groupCount = tree.GroupBy(p => p.Depth).Select(g => g.First()).Count(); - - for(int i=0;i(T)x).Where(x=>x.Depth == i).ToList()); - maxWidth = Mathf.Max(maxWidth, groups[i].Count); - } - - return groups; - } - - - - - } - - - public interface IDependable{ - int Depth { get; set; } - List Dependencies { get; set;} - void AddDependency(T dp); - } - -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/_NewSystem/DependencyTree.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/_NewSystem/DependencyTree.cs.meta deleted file mode 100644 index 5db04ab8..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Evaluator/_NewSystem/DependencyTree.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 80f683523dd7f4167b990c2b34498ae8 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes.meta deleted file mode 100755 index e7c74516..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: 08f7249e4b23143d4983841458970d80 -folderAsset: yes -DefaultImporter: - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Abs.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Abs.cs deleted file mode 100755 index f5721864..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Abs.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Abs : SF_Node_Arithmetic { - - public SFN_Abs() { - } - - public override void Initialize() { - base.Initialize( "Abs" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "abs(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Abs( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Abs.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Abs.cs.meta deleted file mode 100755 index 6ec553bf..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Abs.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3980422c66600a74794dc56059bbec9c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Add.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Add.cs deleted file mode 100755 index 4d6d0e62..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Add.cs +++ /dev/null @@ -1,72 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Add : SF_Node_Arithmetic { - - public SFN_Add() { - - } - - public override void Initialize() { - base.Initialize( "Add" ); - //base.PrepareArithmetic(5); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.ModularInput; - UseLowerReadonlyValues( true ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"A","A",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","B",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"C","C",ConType.cInput,ValueType.VTvPending,false).SetRequired(false), - SF_NodeConnector.Create(this,"D","D",ConType.cInput,ValueType.VTvPending,false).SetRequired(false), - SF_NodeConnector.Create(this,"E","E",ConType.cInput,ValueType.VTvPending,false).SetRequired(false) - }; - - - SetExtensionConnectorChain("B", "C", "D", "E"); - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2], connectors[3], connectors[4], connectors[5] ); - - } - - public override void GetModularShaderFixes( out string prefix, out string infix, out string suffix ) { - prefix = ""; - infix = " + "; - suffix = ""; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - - string evalStr = ""; - - evalStr += GetConnectorByStringID( "A" ).TryEvaluate() + "+" + GetConnectorByStringID( "B" ).TryEvaluate(); - - ChainAppendIfConnected(ref evalStr, "+", "C", "D", "E"); - - return "(" + evalStr + ")"; - } - - - public override float EvalCPU( int c ) { - - float result = GetInputData( "A", c ) + GetInputData( "B", c ); - - if(GetInputIsConnected("C")){ - result += GetInputData( "C", c ); - } - if(GetInputIsConnected("D")){ - result += GetInputData( "D", c ); - } - if(GetInputIsConnected("E")){ - result += GetInputData( "E", c ); - } - - return result; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Add.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Add.cs.meta deleted file mode 100755 index d482a3e8..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Add.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: eee5e454a0aa7ce44b9ccc1adb7349d9 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_AmbientLight.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_AmbientLight.cs deleted file mode 100755 index 1c8f2f18..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_AmbientLight.cs +++ /dev/null @@ -1,63 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_AmbientLight : SF_Node { - - - public SFN_AmbientLight() { - - } - - public override void Initialize() { - base.Initialize( "Ambient Light" ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - base.texture.uniform = true; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this, "RGB", "RGB",ConType.cOutput,ValueType.VTv3,false).Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this, "R", "R",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R).WithColor(Color.red), - SF_NodeConnector.Create(this, "G", "G",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G).WithColor(Color.green), - SF_NodeConnector.Create(this, "B", "B",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B).WithColor(Color.blue), - SF_NodeConnector.Create(this, "A", "A",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.A) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public Color GetIconTint() { - Color c = texture.dataUniform; - c.a = 1.0f; - for( int i = 0; i < 3; i++ ) { - c[i] = 1f - Mathf.Pow( 1f - c[i], 2 ); - c[i] = Mathf.Lerp( 0.5f, 1f, c[i] ); - } - return c; - } - - public override void Update() { - if( ((Color)texture.dataUniform) != RenderSettings.ambientLight ) { - texture.dataUniform = RenderSettings.ambientLight; - texture.iconColor = GetIconTint(); - OnUpdateNode(NodeUpdateType.Soft, true); - } - - } - - public override void OnPreGetPreviewData() { - texture.dataUniform = RenderSettings.ambientLight; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "UNITY_LIGHTMODEL_AMBIENT"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_AmbientLight.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_AmbientLight.cs.meta deleted file mode 100755 index 372ab98c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_AmbientLight.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c293c5aea07b3ff40912d575d5ac542d -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Append.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Append.cs deleted file mode 100755 index a2b37b37..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Append.cs +++ /dev/null @@ -1,190 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Append : SF_Node { - - public override void Initialize() { - base.Initialize( "Append" ); - base.showColor = true; - UseLowerReadonlyValues( true ); - SFN_Append.channelColors[3] = SF_NodeConnector.colorEnabledDefault; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"A","",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"C","",ConType.cInput,ValueType.VTvPending,false).SetRequired(false), - SF_NodeConnector.Create(this,"D","",ConType.cInput,ValueType.VTvPending,false).SetRequired(false) - }; - - base.conGroup = ScriptableObject.CreateInstance(); - (base.conGroup as SFNCG_Append).Initialize( connectors[0], connectors[1], connectors[2], connectors[3], connectors[4] ); - - - SetExtensionConnectorChain( "B", "C", "D" ); - } - - public override int GetEvaluatedComponentCount() { - return ( (SFNCG_Append)conGroup ).GetOutputComponentCount(); - } - - public override bool IsUniformOutput() { - - bool a = GetInputIsConnected( "A" ); - bool b = GetInputIsConnected( "B" ); - bool c = GetInputIsConnected( "C" ); - bool d = GetInputIsConnected( "D" ); - - if( a && b && c && d ) - return ( GetInputData( "A" ).uniform && GetInputData( "B" ).uniform && GetInputData( "C" ).uniform && GetInputData( "D" ).uniform ); - else if( a && b && c ) - return ( GetInputData( "A" ).uniform && GetInputData( "B" ).uniform && GetInputData( "C" ).uniform); - - return ( GetInputData( "A" ).uniform && GetInputData( "B" ).uniform ); - } - - - // New system - public override void RefreshValue() { - UpdateInputLabels(); - RefreshValue( 1, 2 ); - } - - public override bool ExhaustedOptionalInputs() { - return GetEvaluatedComponentCount() >= 4; - } - - - - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string varName = "float"; - int compCount = GetEvaluatedComponentCount(); - if( compCount > 1 ) - varName += compCount; - - bool a = GetInputIsConnected( "A" ); - bool b = GetInputIsConnected( "B" ); - bool c = GetInputIsConnected( "C" ); - bool d = GetInputIsConnected( "D" ); - - string line = varName + "("; - - if( a && b && c && d ) - line += GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate() + "," + GetConnectorByStringID( "C" ).TryEvaluate() + "," + GetConnectorByStringID( "D" ).TryEvaluate(); - else if( a && b && c ) - line += GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate() + "," + GetConnectorByStringID( "C" ).TryEvaluate(); - else - line += GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate(); - - return line + ")"; - } - - public int GetAmountOfConnectedInputs() { - bool a = GetInputIsConnected( "A" ); - bool b = GetInputIsConnected( "B" ); - bool c = GetInputIsConnected( "C" ); - bool d = GetInputIsConnected( "D" ); - - if( a && b && c && d ) - return 4; - else if( a && b && c && !d ) - return 3; - else if( a && b && !c && !d ) - return 2; - else if( a && !b && !c && !d ) - return 1; - else if( !a && !b && !c && !d ) - return 0; - - return 0; - } - - public override float EvalCPU( int c ) { - - int conCount = GetAmountOfConnectedInputs(); - - int cSub = 0; - for( int i = 0; i < conCount; i++ ) { - int cc = connectors[i+1].GetCompCount(); - if(c < cc + cSub){ - return GetInputData( connectors[i+1].strID, c - cSub ); - } else { - cSub += cc; - continue; - } - } - return 0; - } - - - static Color[] channelColors = new Color[4] { Color.red, Color.green, Color.blue, Color.white }; - - public override void PrepareRendering( Material mat ) { - - Vector4[] masks = new Vector4[] { - Vector4.zero, - Vector4.zero, - Vector4.zero, - Vector4.zero - }; - Vector4 offsets = Vector4.zero; - int head = 0; - for( int i = 0; i < GetAmountOfConnectedInputs(); i++ ) { - SF_NodeConnector con = connectors[i + 1]; - if( GetInputIsConnected( con.strID ) ) { - int cc = con.GetCompCount(); - for( int j = head; j < cc + head; j++ ) { - masks[i][j] = 1f; - } - offsets[i] = head; - head += cc; - } - } - - //for( int i = 0; i < 4; i++ ) { - // Debug.Log("Masks: " + masks[i]); - //} - - mat.SetVector( "_A_mask", masks[0] ); - mat.SetVector( "_B_mask", masks[1] ); - mat.SetVector( "_C_mask", masks[2] ); - mat.SetVector( "_D_mask", masks[3] ); - mat.SetVector( "_offsets", offsets ); - - } - - public void UpdateInputLabels() { - - string rgba = "RGBA"; - - int conCount = 4; - int cSub = 0; - for( int i = 0; i < conCount; i++ ) { - SF_NodeConnector con = connectors[i + 1]; - if( GetInputIsConnected( con.strID ) ) { - - int cc = con.GetCompCount(); - con.label = rgba.Substring( cSub, cc ); - if( cc == 1 ) - con.color = channelColors[cSub]; - cSub += cc; - - } else { - con.label = ""; - con.color = SF_NodeConnector.colorEnabledDefault; - cSub++; - } - } - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Append.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Append.cs.meta deleted file mode 100755 index 14a1a0b2..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Append.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 162e89da5a50d9e4d8a4e894cbcdeb15 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcCos.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcCos.cs deleted file mode 100755 index c341e985..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcCos.cs +++ /dev/null @@ -1,30 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ArcCos : SF_Node_Arithmetic { - - public SFN_ArcCos() { - } - - public override void Initialize() { - base.Initialize( "ArcCos" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "acos(_in)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "acos(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Acos( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcCos.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcCos.cs.meta deleted file mode 100755 index c81a7618..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcCos.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1267f09847e198948b8685321890f373 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcSin.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcSin.cs deleted file mode 100755 index c48836d2..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcSin.cs +++ /dev/null @@ -1,30 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ArcSin : SF_Node_Arithmetic { - - public SFN_ArcSin() { - } - - public override void Initialize() { - base.Initialize( "ArcSin" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "asin(_in)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "asin(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Asin( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcSin.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcSin.cs.meta deleted file mode 100755 index 5c097895..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcSin.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 51a1743e634ae48499fec247d6ee111f -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan.cs deleted file mode 100755 index d8013314..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan.cs +++ /dev/null @@ -1,30 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ArcTan : SF_Node_Arithmetic { - - public SFN_ArcTan() { - } - - public override void Initialize() { - base.Initialize( "ArcTan" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "atan(_in)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "atan(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Atan( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan.cs.meta deleted file mode 100755 index f59d6992..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b0f13cb74c6cdd346ad7a92d8af2bda7 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan2.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan2.cs deleted file mode 100755 index 848a892c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan2.cs +++ /dev/null @@ -1,118 +0,0 @@ -using UnityEngine; -using UnityEditor; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ArcTan2 : SF_Node_Arithmetic { - - public enum ArcTan2Type { NegPiToPi, NegOneToOne, ZeroToOne, ZeroToOneWrapped }; - public static string[] atanTypeStr = new string[] { "-\u03C0 to \u03C0", "-1 to 1", "0 to 1", "0 to 1 Wrapped" }; - - public ArcTan2Type arcTanType = ArcTan2Type.NegPiToPi; - - public SFN_ArcTan2() { - } - - public override void Initialize() { - base.Initialize( "ArcTan2" ); - base.UseLowerPropertyBox( true, true ); - base.PrepareArithmetic(2); - base.shaderGenMode = ShaderGenerationMode.Modal; - connectors[1].label = "y"; - connectors[2].label = "x"; - } - - public override string[] GetModalModes() { - return new string[]{ - "NPTP", - "NOTO", - "ZTO", - "ZTOW" - }; - } - - public override string GetCurrentModalMode() { - switch( arcTanType ) { - case ArcTan2Type.NegOneToOne: - return "NOTO"; - case ArcTan2Type.ZeroToOne: - return "ZTO"; - case ArcTan2Type.ZeroToOneWrapped: - return "ZTOW"; - default: - return "NPTP"; - } - } - - public override string[] GetBlitOutputLines( string mode ) { - - - string s = "atan2(_a,_b)"; - - switch( mode ) { - case "NOTO": - s = "(" + s + "/3.14159265359)"; - break; - case "ZTO": - s = "(" + s + "/6.28318530718)+0.5"; - break; - case "ZTOW": - s = "(1-abs(" + s + ")/3.14159265359)"; - break; - } - return new string[] { s }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string aStr = GetConnectorByStringID( "A" ).TryEvaluate(); - string bStr = GetConnectorByStringID( "B" ).TryEvaluate(); - - - if( arcTanType == ArcTan2Type.NegOneToOne ) - return "(atan2(" + aStr + "," + bStr + ")/3.14159265359)"; - if( arcTanType == ArcTan2Type.ZeroToOne ) - return "((atan2(" + aStr + "," + bStr + ")/6.28318530718)+0.5)"; - if( arcTanType == ArcTan2Type.ZeroToOneWrapped ) - return "(1-abs(atan2(" + aStr + "," + bStr + ")/3.14159265359))"; - //if( arcTanType == ArcTan2Type.NegPiToPi ) - return "atan2(" + aStr + "," + bStr + ")"; - } - - public override float EvalCPU( int c ) { - - float a = GetInputData( "A", c ); - float b = GetInputData( "B", c ); - - if( arcTanType == ArcTan2Type.NegOneToOne ) - return Mathf.Atan2( a, b ) / Mathf.PI; - if( arcTanType == ArcTan2Type.ZeroToOne ) - return (Mathf.Atan2( a, b ) / (2*Mathf.PI)) + 0.5f; - if( arcTanType == ArcTan2Type.ZeroToOneWrapped ) - return 1f-(Mathf.Abs(Mathf.Atan2( a, b ) / Mathf.PI)); - //if( arcTanType == ArcTan2Type.NegPiToPi ) - return Mathf.Atan2( a, b ); - } - - public override void DrawLowerPropertyBox() { - EditorGUI.BeginChangeCheck(); - arcTanType = (ArcTan2Type)UndoableEnumPopupNamed( lowerRect, (int)arcTanType, atanTypeStr, "ArcTan2 type" ); - if( EditorGUI.EndChangeCheck() ) - OnUpdateNode(); - } - - public override string SerializeSpecialData() { - return "attp:" + (int)arcTanType; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "attp": - arcTanType = (ArcTan2Type)int.Parse( value ); - break; - } - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan2.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan2.cs.meta deleted file mode 100755 index 8f8c7199..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ArcTan2.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0792bd3dbd79d854f9d4c5ba334b03da -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Bitangent.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Bitangent.cs deleted file mode 100644 index b7abcebb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Bitangent.cs +++ /dev/null @@ -1,35 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Bitangent : SF_Node { - - - public SFN_Bitangent() { - - } - - public override void Initialize() { - base.Initialize( "Bitangent Dir.", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 3; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv3,false) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0f, 1f, 0f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return SF_Evaluator.WithProgramPrefix( "bitangentDir" ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Bitangent.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Bitangent.cs.meta deleted file mode 100644 index 157be31d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Bitangent.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 91678baf7d403d74b9e68a280151262e -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Blend.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Blend.cs deleted file mode 100644 index 06f210f8..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Blend.cs +++ /dev/null @@ -1,339 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge{ - public class SFN_Blend : SF_Node_Arithmetic { - - - public enum BlendMode { - Darken = 0, - Multiply = 1, - ColorBurn = 2, - LinearBurn = 3, - // DarkerColor = 4, - - Lighten = 5, - Screen = 6, - ColorDodge = 7, - LinearDodge = 8, - // LighterColor = 9, - - Overlay = 10, - // SoftLight = 11, - HardLight = 12, - VividLight = 13, - LinearLight = 14, - PinLight = 15, - HardMix = 16, - - Difference = 17, - Exclusion = 18, - Subtract = 19, - Divide = 20 - }; - - - const int maxEnum = 20; - static int[] skipEnum = new int[]{4,9,11}; - - public BlendMode currentBlendMode = BlendMode.Overlay; - public bool clamp = true; - - public SFN_Blend() { - - } - - public override void Initialize() { - base.Initialize( "Blend" ); - base.UseLowerPropertyBox( true, true ); - base.showColor = true; - base.texture.uniform = false; - base.texture.CompCount = 3; - base.node_height += 15; - base.shaderGenMode = ShaderGenerationMode.Modal; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"SRC","Src",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"DST","Dst",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2] ); - } - - public override bool IsUniformOutput() { - return false; - } - - - public void StepBlendMode(int inc, bool registerUndo){ - int nextBlendIndex = (int)currentBlendMode + inc; - - - - - restart: - foreach(int i in skipEnum){ - if(nextBlendIndex == i){ - nextBlendIndex += inc; - goto restart; // Watch out for raptors - } - } - - - if(nextBlendIndex == -1){ - BlendMode nextBlendMode = (BlendMode)maxEnum; - if(registerUndo){ - UndoRecord("switch blend mode to " + nextBlendMode.ToString()); - } - currentBlendMode = nextBlendMode; - return; - } else if(nextBlendIndex > maxEnum){ - BlendMode nextBlendMode = (BlendMode)0; - if(registerUndo){ - UndoRecord("switch blend mode to " + nextBlendMode.ToString()); - } - currentBlendMode = nextBlendMode; - return; - } - - if(registerUndo){ - UndoRecord("switch blend mode to " + (BlendMode)nextBlendIndex); - } - - currentBlendMode = (BlendMode)nextBlendIndex; - - } - - - - - - public override void RefreshValue() { - RefreshValue( 1, 2 ); - } - - public override void DrawLowerPropertyBox() { - GUI.color = Color.white; - EditorGUI.BeginChangeCheck(); - Rect r = lowerRect; - r.height = 17; - - currentBlendMode = (BlendMode)UndoableEnumPopup(r, currentBlendMode, "switch blend mode"); - - r = r.MovedDown(); - r.width -= r.height*2+8; - UndoableToggle(r,ref clamp, "Clamp", "blend node clamp", SF_Styles.ToggleDiscrete); - r.width = lowerRect.width; - r = r.MovedRight(); - r.width = r.height+4; - r = r.MovedLeft(2); - if(GUI.Button(r,"\u25B2")){ - StepBlendMode(-1, registerUndo:true); - } - r = r.MovedRight(); - if(GUI.Button(r, "\u25BC")){ - StepBlendMode(1, registerUndo:true); - } - - - if(EditorGUI.EndChangeCheck()) - OnUpdateNode(); - } - - public override string SerializeSpecialData() { - string s = ""; - s += "blmd:" + (int)currentBlendMode + ","; - s += "clmp:" + clamp.ToString(); - return s; - } - - - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "blmd": - currentBlendMode = (BlendMode)int.Parse( value ); - break; - case "clmp": - clamp = bool.Parse( value ); - break; - } - } - - - public override float EvalCPU( int c ) { - - float a = GetInputData( "SRC", c ); - float b = GetInputData( "DST", c ); - - float blended = Blend(a,b); - - if(clamp) - blended = Mathf.Clamp01(blended); - - - return blended; - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - // Update eval count here - - string a = GetConnectorByStringID( "SRC" ).TryEvaluate(); - string b = GetConnectorByStringID( "DST" ).TryEvaluate(); - - - - - string blend = Blend (a, b, currentBlendMode); - - if(clamp){ - return "saturate(" + blend + ")"; - } - - return blend; - } - - - public void UpdateUsageCount(){ - - SF_NodeConnector src = GetConnectorByStringID("SRC"); - SF_NodeConnector dst = GetConnectorByStringID("DST"); - - - - if(currentBlendMode == BlendMode.Overlay){ - src.usageCount = 2; - dst.usageCount = 3; - return; - } - - if(currentBlendMode == BlendMode.HardLight || - currentBlendMode == BlendMode.VividLight || - currentBlendMode == BlendMode.LinearLight || - currentBlendMode == BlendMode.PinLight){ - - src.usageCount = 3; - dst.usageCount = 2; - return; - } - - - - src.usageCount = 1; - dst.usageCount = 1; - - } - - - - public override string[] GetModalModes() { - return Enum.GetNames( typeof( BlendMode ) ); - } - - public override string GetCurrentModalMode() { - return currentBlendMode.ToString(); - } - - public override string[] GetBlitOutputLines( string mode ) { - string s = Blend( "_src", "_dst", (BlendMode)Enum.Parse( typeof( BlendMode ), mode ) ); - return new string[] { s }; - } - - - - // lerp( 2.0*a*b, 1.0-(1.0-2.0*(a-0.5))*(1.0-b), round(a) ) - - - public string Blend(string a, string b, BlendMode mode){ - switch( mode ) { - case BlendMode.Darken: - return "min(" + a + "," + b + ")"; - case BlendMode.Multiply: - return "("+a+"*"+b+")"; - case BlendMode.ColorBurn: - return "(1.0-((1.0-" + b + ")/" + a + "))"; - case BlendMode.LinearBurn: - return "(" + a + "+" + b + "-1.0)"; - case BlendMode.Lighten: - return "max(" + a + "," + b + ")"; - case BlendMode.Screen: - return "(1.0-(1.0-" + a + ")*(1.0-" + b + "))"; - case BlendMode.ColorDodge: - return "(" + b + "/(1.0-" + a + "))"; - case BlendMode.LinearDodge: - return "(" + a + "+" + b + ")"; - case BlendMode.Overlay: - return "( " + b + " > 0.5 ? (1.0-(1.0-2.0*(" + b + "-0.5))*(1.0-" + a + ")) : (2.0*" + b + "*" +a + ") )"; - case BlendMode.HardLight: - return "(" + a + " > 0.5 ? (1.0-(1.0-2.0*(" + a + "-0.5))*(1.0-" + b + ")) : (2.0*" + a + "*" + b + ")) "; - case BlendMode.VividLight: - return "( " + a + " > 0.5 ? (" + b + "/((1.0-" + a + ")*2.0)) : (1.0-(((1.0-" + b + ")*0.5)/" + a + ")))"; - case BlendMode.LinearLight: - return "( " + a + " > 0.5 ? (" + b + " + 2.0*" + a + " -1.0) : (" + b + " + 2.0*(" + a + "-0.5)))"; - case BlendMode.PinLight: - return "( " + a + " > 0.5 ? max(" + b + ",2.0*(" + a + "-0.5)) : min(" + b + ",2.0*" + a + ") )"; - case BlendMode.HardMix: - return "round( 0.5*(" + a + " + " + b + "))"; - case BlendMode.Difference: - return "abs(" + a + "-" + b + ")"; - case BlendMode.Exclusion: - return "(0.5 - 2.0*(" + a + "-0.5)*(" + b + "-0.5))"; - case BlendMode.Subtract: - return "(" + b + "-" + a + ")"; - case BlendMode.Divide: - return "(" + b + "/" + a + ")"; - } - return "0"; - } - - - public float Blend(float a, float b){ - switch(currentBlendMode){ - case BlendMode.Darken: - return Mathf.Min(a,b); - case BlendMode.Multiply: - return a*b; - case BlendMode.ColorBurn: - return 1f-((1f-b)/a); - case BlendMode.LinearBurn: - return a+b-1f; - case BlendMode.Lighten: - return Mathf.Max(a,b); - case BlendMode.Screen: - return 1f-(1f-a)*(1f-b); - case BlendMode.ColorDodge: - return b/(1f-a); - case BlendMode.LinearDodge: - return a+b; - case BlendMode.Overlay: - return b > 0.5f ? 1f-(1f-2f*(b-0.5f))*(1f-a) : 2f*a*b ; - case BlendMode.HardLight: - return a > 0.5f ? 1f-(1f-2f*(a-0.5f))*(1f-b) : 2f*a*b;; - case BlendMode.VividLight: - return a > 0.5f ? b/((1f-a)*2f) : 1f-(((1f-b)*0.5f)/a); - case BlendMode.LinearLight: - return a > 0.5f ? b + 2f*(a-0.5f) : b + 2f*a -1f; - case BlendMode.PinLight: - return a > 0.5f ? Mathf.Max(b,2f*(a-0.5f)) : Mathf.Min(b,2f*a); - case BlendMode.HardMix: - return Mathf.Round((a+b)*0.5f); - case BlendMode.Difference: - return Mathf.Abs(a-b); - case BlendMode.Exclusion: - return 0.5f - 2f*(a-0.5f)*(b-0.5f); - case BlendMode.Subtract: - return b-a; - case BlendMode.Divide: - return b/a; - } - return 0f; - } - - - } -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Blend.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Blend.cs.meta deleted file mode 100644 index 2867e546..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Blend.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: dc98abed3a52945188950124fb57da72 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Ceil.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Ceil.cs deleted file mode 100755 index 668520b7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Ceil.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Ceil : SF_Node_Arithmetic { - - public SFN_Ceil() { - } - - public override void Initialize() { - base.Initialize( "Ceil" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "ceil(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Ceil( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Ceil.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Ceil.cs.meta deleted file mode 100755 index 87aa1c9b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Ceil.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3f60d482333b50040ac5e3679061069c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ChannelBlend.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ChannelBlend.cs deleted file mode 100755 index 4327a63a..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ChannelBlend.cs +++ /dev/null @@ -1,194 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Linq; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ChannelBlend : SF_Node_Arithmetic { - - // SF_Node tNode; - public enum ChannelBlendType{ Summed, Layered }; - - public ChannelBlendType channelBlendType = ChannelBlendType.Summed; - - public SFN_ChannelBlend() { - - } - - - public override void Initialize() { - base.Initialize( "Channel Blend" ); - base.PrepareArithmetic(6); - base.extraWidthInput = 3; - base.UseLowerPropertyBox( true, true ); - base.shaderGenMode = ShaderGenerationMode.Manual; - - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create( this, "OUT", "", ConType.cOutput, ValueType.VTvPending, false ), - SF_NodeConnector.Create( this, "M", "Mask", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ).WithUseCount(4), - SF_NodeConnector.Create( this, "R", "Rcol", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "G", "Gcol", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "B", "Bcol", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "A", "Acol", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "BTM", "Btm", ConType.cInput, ValueType.VTvPending, false ).SetRequired( false ) - }; - this["BTM"].enableState = EnableState.Disabled; - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2], connectors[3], connectors[4], connectors[5], connectors[6] ); - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - if(this["M"].IsConnected()){ - UpdateMaskCompCountInputs(); - } - //base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - foreach(SF_NodeConnector con in connectors){ - if(con.conType == ConType.cOutput || !con.IsConnected()) - continue; - if(!con.inputCon.node.texture.uniform) - return false; - } - return true; - } - - public override int GetEvaluatedComponentCount() { - return this["R"].GetCompCount(); - } - - public override void PrepareRendering( Material mat ) { - mat.SetFloat( "_Type", channelBlendType == ChannelBlendType.Summed ? 0 : 1 ); - } - - - private void UpdateMaskCompCountInputs(){ - - int cc = this["M"].GetCompCount(); - base.texture.CompCount = cc; - - bool summed = channelBlendType == ChannelBlendType.Summed; - //int enableInputCount = summed ? 4 : 5; - - for(int i = 0;i<4;i++){ - - SF_NodeConnector con = connectors[i+2]; - - //if(con.IsConnected() && con.inputCon.GetCompCount() != cc) - // connectors[i+2].Disconnect(); - - bool use = i < cc; - - con.SetRequired( use ); - con.enableState = use ? EnableState.Enabled : EnableState.Disabled; - - // Disconnect if going hidden while connected, but not during load, as it might connect an unevaluated cc - //if(!SF_Parser.quickLoad && !SF_Parser.settingUp){ - if(con.IsConnected() && con.enableState == EnableState.Disabled){ - //connectors[i+2].Disconnect(); - //Debug.Log("Disconnecting thing due to things!"); - } - //} - - } - - this["BTM"].SetRequired(!summed); - this["BTM"].enableState = summed ? EnableState.Disabled : EnableState.Enabled; - } - - public override void DrawLowerPropertyBox() { - GUI.color = Color.white; - EditorGUI.BeginChangeCheck(); - channelBlendType = (ChannelBlendType)UndoableEnumPopup(lowerRect, channelBlendType, "switch channel blend type"); - //currentUV = (UV)EditorGUI.EnumPopup( lowerRect, currentUV ); - if(EditorGUI.EndChangeCheck()){ - UpdateMaskCompCountInputs(); - OnUpdateNode(NodeUpdateType.Hard); - } - } - - public override string SerializeSpecialData() { - return "chbt:" + (int)channelBlendType; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "chbt": - channelBlendType = (ChannelBlendType)int.Parse( value ); - break; - } - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - int cc = this["M"].GetCompCount(); - - string m = this["M"].TryEvaluate(); - - string[] chStr = new string[]{"r","g","b","a"}; - - - - - string str = "("; - - - if(channelBlendType == ChannelBlendType.Summed){ - for(int i=0;i().Initialize( connectors[0], connectors[1], connectors[2] ); - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - if( InputsConnected() ) - return ( GetInputData( "IN" ).uniform && GetInputData( "MIN" ).uniform && GetInputData( "MAX" ).uniform ); - return true; - } - - public override int GetEvaluatedComponentCount() { - return Mathf.Max( connectors[1].GetCompCount(), connectors[2].GetCompCount() ); - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "clamp(" + GetConnectorByStringID( "IN" ).TryEvaluate() + "," + GetInputCon( "MIN" ).Evaluate() + "," + GetInputCon( "MAX" ).Evaluate() + ")"; - } - - - public override float EvalCPU( int c ) { - //if( c + 1 > GetEvaluatedComponentCount() && GetEvaluatedComponentCount() > 1 ) // Why was this needed before? - // return 0f; - return Mathf.Clamp( GetInputData( "IN", c ), GetInputData( "MIN", c ), GetInputData( "MAX", c ) ); - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Clamp.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Clamp.cs.meta deleted file mode 100755 index 02c7e14e..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Clamp.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8f0e557ea28785e489136b0286b4a244 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Clamp01.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Clamp01.cs deleted file mode 100755 index 9deb90c7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Clamp01.cs +++ /dev/null @@ -1,30 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Clamp01 : SF_Node_Arithmetic { - - public SFN_Clamp01() { - } - - public override void Initialize() { - base.Initialize( "Clamp 0-1" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "saturate(_in)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "saturate(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Clamp01( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Clamp01.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Clamp01.cs.meta deleted file mode 100755 index d2e6395e..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Clamp01.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 24cede14d15605b4e804eccab2542450 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Code.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Code.cs deleted file mode 100755 index fd51d014..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Code.cs +++ /dev/null @@ -1,609 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -namespace ShaderForge { - - - public enum CustomValueType{ - Float, - Float2, - Float3, - Float4, - Half, - Half2, - Half3, - Half4, - Fixed, - Fixed2, - Fixed3, - Fixed4, - Sampler2D, - Matrix4x4 - /*, Texture*/ }; - - [System.Serializable] - public class SFN_Code : SF_Node_Resizeable { - - - public string code = ""; - public string functionName = "Function_node_"; - - private bool isEditing = false; - - public SFN_Code() { - } - - public override void Initialize() { - base.Initialize( "Code" ); - functionName = "Function_node_" + base.id; - base.minWidth = (int)(NODE_WIDTH * 2.5f); - base.minHeight = NODE_HEIGHT; - base.ClampSize(); - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","Out",ConType.cOutput,ValueType.VTvPending) - }; - controlName = base.id + "_codeArea"; - connectors[0].CustomValueType = CustomValueType.Float3; - //Debug.Log("Creating thing " + base.id); - } - - public string GetFunctionName(){ - return functionName; - //return "CustomCode_" + id; - } - - public override int GetEvaluatedComponentCount (){ - return SF_Tools.ComponentCountOf(connectors[0].CustomValueType); - } - - public override string GetPrepareUniformsAndFunctions(){ - return GetFunctionHeader() + "\n" + code + "\n}\n"; - } - - public string GetFunctionHeader(){ - string outputType = ToCodeType(connectors[0].CustomValueType); // Output type - string inputs = "("; - foreach(SF_NodeConnector con in connectors){ - if(con.conType == ConType.cOutput) - continue; - inputs += " " + ToCodeType(con.CustomValueType) + " " + con.label + " "; - - if(con != connectors[connectors.Length-1]) // Add comma if it's not the last one - inputs += ","; - } - inputs += "){"; - return outputType + " " + GetFunctionName() + inputs; - } - - private string ToCodeType(CustomValueType cvt){ - if(cvt == CustomValueType.Sampler2D) - return "sampler2D"; // Uppercase D - if( cvt == CustomValueType.Matrix4x4 ) - return "float4x4"; - return cvt.ToString().ToLower(); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string s = GetFunctionName(); - s += "("; - foreach(SF_NodeConnector con in connectors){ - if(con.conType == ConType.cOutput) - continue; - s += " " + con.TryEvaluate() + " "; - - if(con != connectors[connectors.Length-1]) // Add comma if it's not the last one - s += ","; - } - - s += ")"; - return s; - } - - public override float EvalCPU( int c ) { - return 1f; - } - - string controlName; - - - float targetSideButtonWidth; - float currentSideButtonWidth; - - //CustomValueType outType = CustomValueType.Float3; - - bool hoveringNode = false; - - int guiIncID = 0; - - bool justFocused = false; - int pressedTabLastFrameCounter = 0; - int pressedEditLastFrameCounter = 0; - int savedCaretPosition; - - TextEditor txtEditor; - - public override void DrawInner(Rect r){ - - - - //Debug.Log("GUI THREAD: " + Event.current.type + " - " + GUI.GetNameOfFocusedControl()); - - //if(Event.current.type == EventType.layout) - //return; - - if(Event.current.type == EventType.repaint) - guiIncID++; - - //if(Event.current.type == EventType.repaint) - //if(hoveringNode){ - //hoveringNode = r.Margin(128).Contains(Event.current.mousePosition); - //} else { - hoveringNode = r.Contains(Event.current.mousePosition); - //} - - - if(!isEditing) // Don't resize while editing - targetSideButtonWidth = (selected) ? 70f : 0f; - - - int sideButtonHeight = 16; - int buttonTextMargin = 4; - - int sideButtonWidth = Mathf.RoundToInt(currentSideButtonWidth); - if(Event.current.type == EventType.repaint){ - currentSideButtonWidth = Mathf.Lerp(currentSideButtonWidth, targetSideButtonWidth, 0.6f); - } - - Rect txtRect = r; - - - - txtRect = txtRect.PadRight(/*(int)sideButtonWidth +*/ buttonTextMargin); - txtRect = txtRect.PadLeft((int)sideButtonWidth*2 + buttonTextMargin); - txtRect = txtRect.PadBottom(buttonTextMargin); - - - // BUTTONS - if(sideButtonWidth > 12f){ - - Rect btnOutput = txtRect; - Rect btnInput = txtRect; - btnOutput.width = sideButtonWidth; - btnInput.width = sideButtonWidth*2; - btnOutput.height = btnInput.height = sideButtonHeight; - btnOutput.x += txtRect.width - sideButtonWidth; - btnInput.x += - buttonTextMargin / 2 - sideButtonWidth*2; - - DrawTypecastButtons( btnOutput, btnInput ); - - } - - - txtRect = txtRect.PadTop((int)(sideButtonWidth*0.32f)); - - - - if(isEditing && !justFocused && Event.current.type == EventType.repaint){ - //Debug.Log("GUI THREAD " + Event.current.type + " LOWER"); - if(GUI.GetNameOfFocusedControl() != controlName){ - //Debug.Log("DEFOCUS - " + Event.current.type + " fc: " + GUI.GetNameOfFocusedControl() ); - isEditing = false; - isEditingAnyNodeTextField = false; - } - } - - - - if(Event.current.type == EventType.repaint){ - justFocused = false; - } - - //Debug.Log("GUI THREAD B: " + Event.current.type + " - " + GUI.GetNameOfFocusedControl()); - - if(isEditing){ - - controlName = base.id + "_codeArea"; - - GUI.SetNextControlName(controlName); - - string codeBefore = code; - //code = GUI.TextArea(txtRect,code,SF_Styles.CodeTextArea); - code = UndoableTextArea(txtRect, code, "code", SF_Styles.CodeTextArea); - - SF_GUI.AssignCursor( txtRect , MouseCursor.Text ); - - //if(copied){ - // code = codeBefore; - // txtEditor.pos += copyLength-1; - //} - - - txtEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); - savedCaretPosition = txtEditor.cursorIndex; - //txtEditor.selectPos = 4; - - - - - //if(SF_GUI.HoldingControl() && Event.current.type == EventType.keyDown && Event.current.keyCode == KeyCode.C) - - - if(Event.current.keyCode == KeyCode.Tab && Event.current.type == EventType.keyDown){ - //Debug.Log("Tab"); - UndoRecord("insert tab in " + functionName + " code"); - code = code.Insert( txtEditor.cursorIndex, "\t" ); - //Debug.Log("Caret position = " + txtEditor.pos); - savedCaretPosition = txtEditor.cursorIndex; - pressedTabLastFrameCounter = 5; // Force it for five GUI frames - Event.current.Use(); - GUI.FocusControl(controlName); - } - - if(pressedTabLastFrameCounter > 0 /*&& GUI.GetNameOfFocusedControl() != controlName*/){ - GUI.FocusControl(controlName); - txtEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); - txtEditor.cursorIndex = savedCaretPosition + 1; - txtEditor.selectIndex = savedCaretPosition+1; - pressedTabLastFrameCounter--; - } - - /* - if(Event.current.keyCode == KeyCode.Tab && Event.current.type == EventType.keyUp){ - GUI.FocusControl(controlName); - Event.current.Use(); - GUI.FocusControl(controlName); - } - - if(Event.current.Equals( Event.KeyboardEvent("tab") )){ - GUI.FocusControl(controlName); - Event.current.Use(); - GUI.FocusControl(controlName); - }*/ - - - - if(code != codeBefore){ - OnUpdateNode(NodeUpdateType.Soft, false); - } - //if(focusBefore != string.Empty && GUI.GetNameOfFocusedControl() != focusBefore){ - // GUI.FocusControl(focusBefore); - //} - //Debug.Log("GUI THREAD B_A_1: " + Event.current.type + " - " + GUI.GetNameOfFocusedControl()); - - }else{ - //Debug.Log("GUI THREAD " + Event.current.type + " UPPER"); - //Debug.Log("GUI THREAD B_B_0: " + Event.current.type + " - " + GUI.GetNameOfFocusedControl()); - GUI.Box(txtRect.PadBottom(1),code,SF_Styles.CodeTextArea); - if(hoveringNode){ - - bool doubleClicked = Event.current.isMouse && Event.current.type == EventType.mouseDown && Event.current.clickCount == 2; - - Rect btnRect = new Rect(txtRect.xMax,txtRect.yMax,46,16).MovedUp().MovedLeft(); - btnRect.x -= 3; - btnRect.y -= 4; - - btnRect.xMin -= 3; - btnRect.yMin -= 4; - - // Workaround for a weird issue - //bool clickedBtn = btnRect.Contains(Event.current.mousePosition) && Event.current.type == EventType.mouseUp && Event.current.button == 0; - - //Debug.Log("GUI THREAD B_B_1: " + Event.current.type + " - " + GUI.GetNameOfFocusedControl()); - if(GUI.Button(btnRect,"Edit",EditorStyles.miniButton) || doubleClicked && Event.current.type == EventType.repaint){ - isEditing = true; - //Debug.Log("FOCUS - " + Event.current.type + " fc: " + GUI.GetNameOfFocusedControl() ); - pressedEditLastFrameCounter = 5; - isEditingAnyNodeTextField = true; - GUI.FocusControl(controlName); - // forceFocusCodeField = true; - Event.current.Use(); - justFocused = true; - } - //Debug.Log("GUI THREAD B_B_2: " + Event.current.type + " - " + GUI.GetNameOfFocusedControl()); - } - } - - if(pressedEditLastFrameCounter > 0){ - GUI.FocusControl(controlName); - //Debug.Log("REFOCUSING " + controlName + " fc: " + GUI.GetNameOfFocusedControl() ); - pressedEditLastFrameCounter--; - } - - //Debug.Log("GUI THREAD C: " + Event.current.type + " - " + GUI.GetNameOfFocusedControl()); - - - - /* - if (forceFocusCodeField) { - //GUI.SetNextControlName("focusChange"); - if (GUI.GetNameOfFocusedControl() != controlName) { - GUI.FocusControl(controlName); - } else { - forceFocusCodeField = false; - } - - }*/ - - - - - //Debug.Log("GUI THREAD END: " + Event.current.type + " - " + GUI.GetNameOfFocusedControl()); - } - - //bool forceFocusCodeField = false; - - public void DrawTypecastButtons(Rect btnL, Rect btnR){ - - - // OUTPUT - DrawTypecastButton(btnL, connectors[0]); - - - // INPUTS - foreach(SF_NodeConnector con in connectors){ - if(con.conType == ConType.cOutput) - continue; - DrawTypecastButton(btnR, con, isInput:true); - btnR.y += btnR.height+4; - } - - // ADD INPUT BUTTON - GUI.color = new Color(0.7f,1f,0.7f,1f); - if(GUI.Button(btnR,"Add input", EditorStyles.miniButton)){ - UndoRecord("add input to " + functionName); - AddInput(); - } - GUI.color = Color.white; - - - } - - - - - public void AddInput(){ - - - SF_NodeConnector[] savedCons = new SF_NodeConnector[connectors.Length+1]; - for(int i=0;i conList = new List(); - foreach(SF_NodeConnector c in connectors){ - if(c != con){ - conList.Add(c); - } - } - - if(undoRecord) - Undo.DestroyObjectImmediate(con); - else - DestroyImmediate(con); - connectors = conList.ToArray(); - - RefreshConnectorStringIDs(); - UpdateMinHeight(); - - OnUpdateNode(NodeUpdateType.Hard, false); - } - - public void RefreshConnectorStringIDs(){ - int nameIndex = 0; - foreach(SF_NodeConnector c in connectors){ - if(c.conType == ConType.cInput){ - c.strID = SF_Tools.alphabetUpper[nameIndex].ToString(); - nameIndex++; - } - } - } - - - string EncodeCode(){ - return SF_Tools.StringToBase64String( code ); - } - - string DecodeCode(string encoded){ - return SF_Tools.Base64StringToString( encoded ); - } - - public class SF_Serializer{ - - List keys; - List values; - - public SF_Serializer(){ - keys = new List(); - values = new List(); - } - - public SF_Serializer Add(string key, string value){ - keys.Add(key); - values.Add(value); - return this; - } - - public SF_Serializer Add(string key, int value){ - return Add(key, value.ToString()); - } - - public SF_Serializer Add(string key, float value){ - return Add(key, value.ToString()); - } - - public SF_Serializer Add(string key, bool value){ - return Add(key, value.ToString()); - } - - public override string ToString(){ - string s = ""; - for(int i=0;i 0) - s += ","; - s += keys[i] + ":" + values[i]; - } - return s; - } - - } - - - public override string SerializeSpecialData() { - /* - string s = ""; - s += "code:" + EncodeCode() + ","; - - s += "output:" + (int)connectors[0].CustomValueType + ","; - - s += "fnme:" + functionName + ","; - - for(int i=1;i 0){ - con.label = SF_ShaderProperty.FormatInternalName(con.label); - UpdateExtraInputWidth(); - OnUpdateNode(NodeUpdateType.Soft); - } - } else { - int cvtccBef = SF_Tools.ComponentCountOf(con.CustomValueType ); - //con.CustomValueType = (CustomValueType)EditorGUI.EnumPopup(r, con.CustomValueType); - con.CustomValueType = (CustomValueType)UndoableEnumPopup(r, con.CustomValueType, "set output value type"); - if(cvtccBef != SF_Tools.ComponentCountOf(con.CustomValueType)){ - con.Disconnect(); - } - } - - } - - public void UpdateExtraInputWidth(){ - - int widest = SF_NodeConnector.defaultConnectorWidth; - - foreach(SF_NodeConnector con in connectors){ - if(con.conType == ConType.cOutput) - continue; - - widest = Mathf.Max( SF_GUI.WidthOf(con.label, SF_Styles.MiniLabelOverflow)+2, widest); - } - - extraWidthInput = widest - SF_NodeConnector.defaultConnectorWidth; - - - - } - - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Code.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Code.cs.meta deleted file mode 100644 index a05224d1..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Code.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 98ffa0d6f7e664ac98d11cff5f2974ef -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Color.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Color.cs deleted file mode 100755 index e97e8727..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Color.cs +++ /dev/null @@ -1,123 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Color : SF_Node { - - - public SFN_Color() { - - } - - public override void Initialize() { - //node_height /= 2; - base.Initialize( "Color" ); - base.showColor = true; - base.UseLowerPropertyBox( true ); - base.property = ScriptableObject.CreateInstance().Initialize( this ); - base.texture.uniform = true; - base.neverDefineVariable = true; - base.texture.dataUniform = new Color( 0.5f, 0.5f, 0.5f, 1.0f ); - base.texture.CompCount = 4; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - lowerRect.width /= 4; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"RGB","RGB",ConType.cOutput,ValueType.VTv3) .Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"R","R",ConType.cOutput, ValueType.VTv1) .WithColor(Color.red) .Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"G","G",ConType.cOutput,ValueType.VTv1) .WithColor(Color.green) .Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"B","B",ConType.cOutput,ValueType.VTv1) .WithColor(Color.blue) .Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"A","A",ConType.cOutput,ValueType.VTv1) .Outputting(OutChannel.A) - }; - } - - public void OnUpdateValue() { - editor.shaderEvaluator.ApplyProperty( this ); - OnUpdateNode( NodeUpdateType.Soft ); - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return property.GetVariable(); - } - - public override void DrawLowerPropertyBox() { - - if(selected && !SF_GUI.MultiSelectModifierHeld() && !IsGlobalProperty()) - ColorPickerCorner( lowerRect ); - - Vector4 vecPrev = texture.dataUniform; - PrepareWindowColor(); - Rect tRect = lowerRect; - - if(IsGlobalProperty()){ - texture.dataUniform[0] = texture.dataUniform[1] = texture.dataUniform[2] = 0.5f; - texture.dataUniform[3] = 1f; - GUI.enabled = false; - } - - texture.dataUniform[0] = UndoableFloatField(tRect, texture.dataUniform[0], "R channel"); - tRect.x += tRect.width; - texture.dataUniform[1] = UndoableFloatField(tRect, texture.dataUniform[1], "G channel"); - tRect.x += tRect.width; - texture.dataUniform[2] = UndoableFloatField(tRect, texture.dataUniform[2], "B channel"); - tRect.x += tRect.width; - texture.dataUniform[3] = UndoableFloatField(tRect, texture.dataUniform[3], "A channel"); - ResetWindowColor(); - if( texture.dataUniform != vecPrev ) { - OnUpdateValue(); - OnUpdateNode(); - } - - if(IsGlobalProperty()){ - GUI.enabled = true; - } - - } - - public Color GetColor() { - return texture.dataUniform; - } - - public override string SerializeSpecialData() { - string s = property.Serialize() + ","; - s += "c1:" + texture.dataUniform[0] + ","; - s += "c2:" + texture.dataUniform[1] + ","; - s += "c3:" + texture.dataUniform[2] + ","; - s += "c4:" + texture.dataUniform[3]; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize(key,value); - switch( key ) { - case "c1": - float fVal1 = float.Parse( value ); - texture.dataUniform[0] = fVal1; - break; - case "c2": - float fVal2 = float.Parse( value ); - texture.dataUniform[1] = fVal2; - break; - case "c3": - float fVal3 = float.Parse( value ); - texture.dataUniform[2] = fVal3; - break; - case "c4": - float fVal4 = float.Parse( value ); - texture.dataUniform[3] = fVal4; - break; - } - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Color.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Color.cs.meta deleted file mode 100755 index 9c23e3c4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Color.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8bc17ab9cbfedf04dad0a0b49038cb4f -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_CommentBox.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_CommentBox.cs deleted file mode 100644 index 7dd06cdc..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_CommentBox.cs +++ /dev/null @@ -1,43 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -namespace ShaderForge { - - - [System.Serializable] - public class SFN_CommentBox : SF_Node_Resizeable { - - - public SFN_CommentBox() { - } - - public override void Initialize() { - base.Initialize( "Comment Box" ); - base.minWidth = (int)( NODE_WIDTH * 2.5f ); - base.minHeight = NODE_HEIGHT; - base.ClampSize(); - connectors = new SF_NodeConnector[]{ - //SF_NodeConnector.Create(this,"OUT","Out",ConType.cOutput,ValueType.VTvPending) - }; - } - - - public override void DrawInner( Rect r ) { - - // Things - UpdateMinHeight(); - - } - - - - - public void UpdateMinHeight() { - base.minHeight = Mathf.Max( NODE_HEIGHT, ( connectors.Length - 1 ) * 20 + 48 ); - base.ClampSize(); - } - - } - -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_CommentBox.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_CommentBox.cs.meta deleted file mode 100644 index 1db4ae24..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_CommentBox.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c0f7e2658ac66f644824764ce705d8c3 -timeCreated: 1426492859 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ComponentMask.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ComponentMask.cs deleted file mode 100755 index 41c444a2..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ComponentMask.cs +++ /dev/null @@ -1,387 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ComponentMask : SF_Node { - - public enum CompChannel {off = -1, r = 0, g = 1, b = 2, a = 3 }; - const string R = "R"; - const string G = "G"; - const string B = "B"; - const string A = "A"; - const string OFF = "-"; - public string[][] compLabels = new string[][]{ - new string[] { OFF, R }, - new string[] { OFF, R, G }, - new string[] { OFF, R, G, B }, - new string[] { OFF, R, G, B, A } - }; - public string[][] compLabelsFirst = new string[][]{ - new string[] { R }, - new string[] { R, G }, - new string[] { R, G, B }, - new string[] { R, G, B, A } - }; - - public const float colDesat = 0.6f; - - public static Color[] chanColors = new Color[]{ - Color.white, - new Color( 1f, colDesat, colDesat), - new Color( colDesat, 1f, colDesat), - new Color( colDesat*1.1f, colDesat*1.1f, 1f ), - Color.white - }; - - public static Color[] outputChanColors = new Color[]{ - Color.red, - Color.green, - Color.blue, - Color.white - }; - - - - public GUIStyle popupStyle; - - public CompChannel[] components = new CompChannel[] { - CompChannel.r, - CompChannel.off, - CompChannel.off, - CompChannel.off - }; - - public SFN_ComponentMask() { - /* - Initialize("Comp. Mask"); - base.showColor = true; - UseLowerReadonlyValues(true); - UseLowerPropertyBox( true, true ); - - popupStyle = new GUIStyle( EditorStyles.miniButton ); - popupStyle.alignment = TextAnchor.MiddleCenter; - popupStyle.fontSize = 12; - popupStyle.fontStyle = FontStyle.Bold; - - connectors = new SF_NodeConnection[]{ - new SF_NodeConnection(this,"-",ConType.cOutput,ValueType.VTvPending,false).Outputting(OutChannel.All), - new SF_NodeConnection(this,"In",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - */ - //base.conGroup = new SFNCG_Append( connectors[0], connectors[1], connectors[2] ); - } - - public override void Initialize() { - base.Initialize( "Comp. Mask" ); - base.SearchName = "ComponentMask"; - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.Modal; - UseLowerReadonlyValues( true ); - UseLowerPropertyBox( true, true ); - SFN_ComponentMask.outputChanColors[3] = SF_NodeConnector.colorEnabledDefault; - - - popupStyle = new GUIStyle( EditorStyles.miniButton ); - popupStyle.alignment = TextAnchor.MiddleCenter; - popupStyle.fontSize = 12; - popupStyle.fontStyle = FontStyle.Bold; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT", "-", ConType.cOutput, ValueType.VTvPending,false) .Outputting(OutChannel.All), - SF_NodeConnector.Create(this,"IN", "In", ConType.cInput, ValueType.VTvPending,false) .SetRequired(true), - SF_NodeConnector.Create(this,"R", "R", ConType.cOutput, ValueType.VTv1) .WithColor(Color.red) .Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"G", "G", ConType.cOutput, ValueType.VTv1) .WithColor(Color.green) .Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"B", "B", ConType.cOutput, ValueType.VTv1) .WithColor(Color.blue) .Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"A", "A", ConType.cOutput, ValueType.VTv1) .Outputting(OutChannel.A) - }; - outCompCount = 1; - UpdateOutput(); - } - - - public override int GetEvaluatedComponentCount() { - return outCompCount; - } - - public override bool IsUniformOutput() { - if( GetInputIsConnected("IN") && !GetInputData( "IN" ).uniform ) - return false; - return true; - } - - - // New system - public override void RefreshValue() { - RefreshValue( 1, 1 ); - } - - public override string[] ExtraPassedFloatProperties() { - return new string[]{ - "ChR", - "ChG", - "ChB", - "ChA" - }; - } - - public override string[] GetModalModes() { - return new string[]{ - "CC1", - "CC2", - "CC3", - "CC4" - }; - } - - public override void PrepareRendering( Material mat ) { - mat.SetFloat( "_chr", (int)components[0] ); - mat.SetFloat( "_chg", (int)components[1] ); - mat.SetFloat( "_chb", (int)components[2] ); - mat.SetFloat( "_cha", (int)components[3] ); - } - - public override string GetCurrentModalMode() { - if( components[1] == CompChannel.off ) - return "CC1"; - if( components[2] == CompChannel.off ) - return "CC2"; - if( components[3] == CompChannel.off ) - return "CC3"; - return "CC4"; - } - - public override string[] GetBlitOutputLines( string mode ) { - - string s = ""; - if( mode == "CC1" ) - s = "_in[_chr].xxxx"; - if( mode == "CC2" ) - s = "float4(_in[_chr],_in[_chg],0,0)"; - if( mode == "CC3" ) - s = "float4(_in[_chr],_in[_chg],_in[_chb],0)"; - if( mode == "CC4" ) - s = "float4(_in[_chr],_in[_chg],_in[_chb],_in[_cha])"; - - return new string[]{ s }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - //if( outCompCount == inCompCount ) - // return GetConnectorByStringID( "IN" ).TryEvaluate(); // Unchanged // No! - - - string componentString = "."; - - for( int i = 0; i < outCompCount; i++ ) { // Build component string - componentString += components[i].ToString(); - } - - return GetConnectorByStringID( "IN" ).TryEvaluate() + componentString; - } - - static string[] writtenNumber = new string[]{"first", "second", "third", "fourth"}; - - int outCompCount = 1; - int inCompCount = 4; - - public override void DrawLowerPropertyBox() { - - inCompCount = 4; - if( !connectors[1].IsConnected() ) { - GUI.enabled = false; - } else { - inCompCount = connectors[1].GetCompCount(); - if( inCompCount > 4 ) - inCompCount = 4; - } - - Rect r = lowerRect; - r.width /= 4; - - bool changed = false; - - EditorGUI.BeginChangeCheck(); - for( int i = 0; i < 4; i++ ) { - - - // Make sure they are valid - if((int)components[i] >= inCompCount){ - components[i] = (CompChannel)(inCompCount-1); - changed = true; - } - - - string[][] labels = (i == 0) ? compLabelsFirst : compLabels; - int labelOffset = (i == 0) ? 0 : -1; // When skipping OFF - - if(!GUI.enabled && i != 0) - components[i] = CompChannel.off; - - if(connectors[1].IsConnected()){ - - int curDisplayIndex = (int)components[i]-labelOffset; - string[] dispLabels = labels[inCompCount-1]; - GUI.color = chanColors[Mathf.Clamp((int)components[i]+1,0,4)]; - - components[i] = (CompChannel)(UndoablePopup( r, curDisplayIndex, dispLabels, "set "+writtenNumber[i]+" component mask channel", popupStyle )+labelOffset); - - //components[i] = (CompChannel)(EditorGUI.Popup( r, curDisplayIndex, dispLabels, popupStyle )+labelOffset); - } - - - if( components[i] == CompChannel.off ) - GUI.enabled = false; // Disable following buttons - - r.x += r.width; - } - - bool changedCompCount = UpdateOutCompCount(); - UpdateOutput(); - if( EditorGUI.EndChangeCheck() || changedCompCount || changed ) { - - OnUpdateNode(); - } - - - GUI.enabled = true; - - } - - bool UpdateOutCompCount() { // returns true if changed - int prev = outCompCount; - outCompCount = 0; - for( int i = 0; i < 4; i++ ) { - if( components[i] != CompChannel.off ) - outCompCount++; - } - if( outCompCount == 0 ) { - outCompCount = 1; - } - - if(outCompCount != prev) - return true; - return false; - - } - - void UpdateOutput() { - - // Set proper value types and component count - UpdateOutCompCount(); - texture.CompCount = outCompCount; - switch( outCompCount ) { - case 1: - connectors[0].valueType = ValueType.VTv1; - break; - case 2: - connectors[0].valueType = ValueType.VTv2; - break; - case 3: - connectors[0].valueType = ValueType.VTv3; - break; - case 4: - connectors[0].valueType = ValueType.VTv4; - break; - default: - connectors[0].valueType = ValueType.VTvPending; - texture.CompCount = 4; - break; - } - - - - // Rename the label - - string label = ""; - - if( connectors[0].valueType == ValueType.VTvPending ) { - label = "-"; - } else { - for( int i = 0; i < outCompCount; i++ ) { // Build component string - int id = (int)components[i]; - label += compLabels[3][id+1]; - } - } - connectors[0].label = label; - - connectors[0].color = outCompCount == 1 ? outputChanColors[Mathf.Clamp((int)components[0],0,3)] : SF_NodeConnector.colorEnabledDefault; - - - SF_NodeConnector inCon = GetConnectorByStringID( "IN" ); - if(inCon.IsConnected()){ - for(int i=0;i<4;i++){ - - if(i < outCompCount && outCompCount > 1){ - connectors[i+2].enableState = EnableState.Enabled; - } else { - connectors[i+2].enableState = EnableState.Hidden; - connectors[i+2].Disconnect(); - - } - - - int id = (int)components[i]; - connectors[i+2].label = compLabels[3][id+1]; - - connectors[i+2].color = outputChanColors[Mathf.Clamp(id,0,3)]; - } - - } - } - - - public override float EvalCPU( int c ) { - CompChannel channel = components[c]; // Get the channel the user selected for component i - if( channel == CompChannel.off ) { - if(outCompCount > 1) - return 0f; // Make remaining channels black if using more than one component - return GetInputData( "IN", (int)components[0] ); // Repeat same value when using one component - } - return GetInputData( "IN", (int)channel); - } - - public override string SerializeSpecialData() { - string s = ""; - s += "cc1:" + (int)components[0] + ","; - s += "cc2:" + (int)components[1] + ","; - s += "cc3:" + (int)components[2] + ","; - s += "cc4:" + (int)components[3]; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - - switch( key ) { - case ( "cc1" ): - if(value == "4") - value = "-1"; - components[0] = (CompChannel)int.Parse( value ); - break; - case ( "cc2" ): - if(value == "4") - value = "-1"; - components[1] = (CompChannel)int.Parse( value ); - break; - case ( "cc3" ): - if(value == "4") - value = "-1"; - components[2] = (CompChannel)int.Parse( value ); - break; - case ( "cc4" ): - if(value == "4") - value = "-1"; - components[3] = (CompChannel)int.Parse( value ); - break; - } - - UpdateOutput(); - OnUpdateNode(); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ComponentMask.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ComponentMask.cs.meta deleted file mode 100755 index 1b06d91f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ComponentMask.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c5cee9180050a794790a872678f78ed5 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantClamp.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantClamp.cs deleted file mode 100755 index 306a0c86..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantClamp.cs +++ /dev/null @@ -1,126 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ConstantClamp : SF_Node { - - // SF_Node tNode; - - public float min = 0f; - public float max = 1f; - - - public SFN_ConstantClamp() { - - } - - - public override void Initialize() { - base.Initialize( "Clamp (Simple)" ); - base.SearchName = "Clamp Simple"; - base.showColor = true; - UseLowerReadonlyValues( true ); - base.UseLowerPropertyBox( true, true ); - base.shaderGenMode = ShaderGenerationMode.ValuePassing; - - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"IN","",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1] ); - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 1 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - return GetInputData( "IN" ).uniform; - } - - public override int GetEvaluatedComponentCount() { - return Mathf.Max( this["IN"].GetCompCount() ); - } - - public override string[] ExtraPassedFloatProperties() { - return new string[]{ - "ClampMin", - "ClampMax" - }; - } - - public override void PrepareRendering( Material mat ) { - mat.SetFloat( "_clampmin", min ); - mat.SetFloat( "_clampmax", max ); - } - - public override string[] GetBlitOutputLines( ) { - return new string[] { "clamp( _in, _clampmin, _clampmax )" }; - } - - /* - public void UndoableEnterableFloatField(Rect r, ref float value, string undoMessage, GUIStyle style){ - SF_GUI.EnterableFloatField(this, r, ref value, null ); - } -*/ - - - - public override void DrawLowerPropertyBox() { - - EditorGUI.BeginChangeCheck(); - Rect r = lowerRect; - r.width /= 4; - GUI.Label( r, "Min", EditorStyles.miniLabel ); - r.x += r.width; - //SF_GUI.EnterableFloatField(this, r, ref min, null ); - UndoableEnterableFloatField(r, ref min, "min value", null); - r.x += r.width; - GUI.Label( r, "Max", EditorStyles.miniLabel ); - r.x += r.width; - //SF_GUI.EnterableFloatField( this, r, ref max, null ); - UndoableEnterableFloatField(r, ref max, "max value", null); - - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "clamp(" + GetConnectorByStringID( "IN" ).TryEvaluate() + "," + min + "," + max + ")"; - } - - // TODO Expose more out here! - public override float EvalCPU( int c ) { - if( GetEvaluatedComponentCount() != 1 ) - if( c + 1 > GetEvaluatedComponentCount() ) - return 0f; - return Mathf.Clamp( GetInputData( "IN", c ), min, max ); - } - - public override string SerializeSpecialData() { - string s = "min:" + min + ","; - s += "max:" + max; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "min": - min = float.Parse( value ); - break; - case "max": - max = float.Parse( value ); - break; - } - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantClamp.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantClamp.cs.meta deleted file mode 100755 index c1003961..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantClamp.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e17f3f3b88cf18843b95000bfd9c1bba -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantLerp.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantLerp.cs deleted file mode 100755 index ee86fbf9..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantLerp.cs +++ /dev/null @@ -1,125 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ConstantLerp : SF_Node { - - // SF_Node tNode; - - public float lerp_a = 0f; - public float lerp_b = 1f; - - - public SFN_ConstantLerp() { - - } - - - public override void Initialize() { - base.Initialize( "Lerp (Simple)" ); - base.SearchName = "Lerp Simple"; - base.showColor = true; - UseLowerReadonlyValues( true ); - base.UseLowerPropertyBox( true, true ); - base.shaderGenMode = ShaderGenerationMode.ValuePassing; - - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"IN","T",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1] ); - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 1 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - return GetInputData( "IN" ).uniform; - } - - public override int GetEvaluatedComponentCount() { - return Mathf.Max( this["IN"].GetCompCount() ); - } - - - - public override string[] ExtraPassedFloatProperties() { - return new string[]{ - "LerpA", - "LerpB" - }; - } - - public override void PrepareRendering( Material mat ) { - mat.SetFloat( "_lerpa", lerp_a ); - mat.SetFloat( "_lerpb", lerp_b ); - } - - public override string[] GetBlitOutputLines( ) { - return new string[] { "lerp(_lerpa, _lerpb, _in)" }; - } - - - - public override void DrawLowerPropertyBox() { - - //EditorGUI.BeginChangeCheck(); - Rect r = lowerRect; - r.width /= 8; - GUI.Label( r, "A" ); - r.x += r.width; - r.width *= 3; - //SF_GUI.EnterableFloatField(this, r, ref lerp_a, null ); - UndoableEnterableFloatField(r, ref lerp_a, "A value",null); - r.x += r.width; - r.width /= 3; - GUI.Label( r, "B" ); - r.x += r.width; - r.width *= 3; - //SF_GUI.EnterableFloatField( this, r, ref lerp_b, null ); - UndoableEnterableFloatField(r, ref lerp_b, "B value",null); - - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "lerp(" + lerp_a + "," + lerp_b + "," + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Lerp( lerp_a, lerp_b, GetInputData( "IN", c ) ); - } - - public float Lerp( float a, float b, float t ) { - return ( ( 1f - t ) * a + t * b ); - } - - public override string SerializeSpecialData() { - string s = "a:" + lerp_a + ","; - s += "b:" + lerp_b; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "a": - lerp_a = float.Parse( value ); - break; - case "b": - lerp_b = float.Parse( value ); - break; - } - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantLerp.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantLerp.cs.meta deleted file mode 100755 index d6332e5d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ConstantLerp.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 922be1943b72bf34ab001061c89b1aa8 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cos.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cos.cs deleted file mode 100755 index 048aa935..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cos.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Cos : SF_Node_Arithmetic { - - public SFN_Cos() { - } - - public override void Initialize() { - base.Initialize( "Cos" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "cos(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Cos( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cos.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cos.cs.meta deleted file mode 100755 index 9139ce4b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cos.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 980e537a5b3f41d43a7ed5b48d568bc4 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cross.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cross.cs deleted file mode 100755 index a92c095c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cross.cs +++ /dev/null @@ -1,36 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Cross : SF_Node_Arithmetic { - - public SFN_Cross() { - - } - - public override void Initialize() { - base.Initialize( "Cross" ); - base.PrepareArithmetic( 2, ValueType.VTv3, ValueType.VTv3 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - } - - public override int GetEvaluatedComponentCount() { - return 3; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "float4(cross(_a.xyz,_b.xyz),0);" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "cross(" + GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate() + ")"; - } - - public override Vector4 EvalCPU() { - return SF_Tools.Cross( GetInputData( "A" ).dataUniform, GetInputData( "B" ).dataUniform ); - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cross.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cross.cs.meta deleted file mode 100755 index 5f1377ab..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cross.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 859cb746c02cece4a83a6c8ac12751c8 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cubemap.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cubemap.cs deleted file mode 100755 index 0991951b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cubemap.cs +++ /dev/null @@ -1,203 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Reflection; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Cubemap : SF_Node { - - - public Cubemap cubemapAsset; - Texture2D textureAsset; - - - public CubemapFace previewFace; - - public SFN_Cubemap() { - - } - - - public override void Initialize() { - base.Initialize( "Cubemap" ); - base.UseLowerPropertyBox( true, true ); - base.texture.CompCount = 4; - property = ScriptableObject.CreateInstance().Initialize( this ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"DIR","DIR",ConType.cInput,ValueType.VTv3), - SF_NodeConnector.Create(this,"MIP","MIP",ConType.cInput,ValueType.VTv1), - SF_NodeConnector.Create(this,"RGB","RGB",ConType.cOutput,ValueType.VTv3) .Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"R","R",ConType.cOutput, ValueType.VTv1) .WithColor(Color.red) .Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"G","G",ConType.cOutput,ValueType.VTv1) .WithColor(Color.green) .Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"B","B",ConType.cOutput,ValueType.VTv1) .WithColor(Color.blue) .Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"A","A",ConType.cOutput,ValueType.VTv1) .Outputting(OutChannel.A) - }; - } - - - public override bool IsUniformOutput() { - return false; - } - - // TODO: MIP selection - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - - //float3 reflectDirection = reflect( -viewDirection, normalDirection ); - - string DIR = GetInputIsConnected( "DIR" ) ? GetConnectorByStringID( "DIR" ).TryEvaluate() : "viewReflectDirection"; - string func = GetInputIsConnected( "MIP" ) ? "texCUBElod" : "texCUBE"; - - if( GetInputIsConnected( "MIP" ) ) { - DIR = "float4(" + DIR + "," + GetConnectorByStringID( "MIP" ).TryEvaluate() + ")"; - } - - string s = func + "(" + property.GetVariable() + "," + DIR + ")"; - - return s; - } - - // TODO: EditorUtility.SetTemporarilyAllowIndieRenderTexture(true); - - - - - - public void RenderToTexture() { - - if( cubemapAsset == null ) { - Debug.Log( "Cubemap asset missing" ); - return; - } - - Texture2D tex = new Texture2D( cubemapAsset.width, cubemapAsset.height, TextureFormat.ARGB32, false ); - try{ - tex.SetPixels( cubemapAsset.GetPixels( previewFace ) ); - } catch( Exception e ) { - Debug.LogWarning("Cubemap texture preview failed: " + e.ToString()); - } - - tex.Apply(); - - - RenderTexture rt = new RenderTexture( cubemapAsset.width, cubemapAsset.height, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default ); - rt.Create(); - Graphics.Blit( tex/*cubemapAsset/*GetTextureFaceAsset(CubemapFace.PositiveZ)*/, rt ); - RenderTexture.active = rt; - // The data is now in the RT, in an arbitrary res - // TODO: Sample it with normalized coords down into a 128x128 - // Save it temporarily in a texture - Texture2D temp = new Texture2D( cubemapAsset.width, cubemapAsset.height, TextureFormat.ARGB32, false ); - temp.ReadPixels( new Rect( 0, 0, cubemapAsset.width, cubemapAsset.height ), 0, 0 ); - - RenderTexture.active = null; - rt.Release(); // Remove RT - texture.ReadData( temp ); // Read Data from temp texture - UnityEngine.Object.DestroyImmediate( temp ); // Destroy temp texture - - } - - - public Texture GetTextureFaceAsset( CubemapFace face ) { - if( cubemapAsset == null ) - return null; - - // Reflection of this: - // TextureUtil.GetSourceTexture(Cubemap cubemapRef, CubemapFace face); - Debug.Log( "GET FACE ASSET:" ); - Type textureUtil = Type.GetType( "UnityEditor.TextureUtil,UnityEditor" ); - Debug.Log( "textureUtil = " + textureUtil ); - BindingFlags bfs = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static; - MethodInfo getSourceTexture = textureUtil.GetMethod( "GetSourceTexture", bfs, null, new Type[] { typeof( Cubemap ), typeof( CubemapFace ) }, null ); - Debug.Log( "getSourceTexture = " + getSourceTexture ); - Texture2D tex = (Texture2D)getSourceTexture.Invoke( null, new object[] { cubemapAsset, face } ); - Debug.Log( "tex = " + tex ); - - return tex; - } - - public override void OnDelete() { - cubemapAsset = null; - } - - - public override bool Draw() { - ProcessInput(); - DrawHighlight(); - PrepareWindowColor(); - DrawWindow(); - ResetWindowColor(); - return true;//!CheckIfDeleted(); - } - - public override void NeatWindow( ) { - - GUI.skin.box.clipping = TextClipping.Overflow; - - GUI.BeginGroup( rect ); - - EditorGUI.BeginChangeCheck(); - DrawLowerPropertyBox(); - bool changedFace = EditorGUI.EndChangeCheck(); - - //GUI.DragWindow(); - - EditorGUI.BeginChangeCheck(); - - Cubemap newCubemap = (Cubemap)EditorGUI.ObjectField( rectInner, cubemapAsset, typeof( Cubemap ), false ); - if(newCubemap != cubemapAsset){ - if(newCubemap == null){ - UndoRecord("unassign cubemap from " + property.nameDisplay); - } else { - UndoRecord("switch cubemap to " + newCubemap.name + " in " + property.nameDisplay); - } - cubemapAsset = newCubemap; - } - - - - if( changedFace || EditorGUI.EndChangeCheck() ) { - RenderToTexture(); - OnUpdateNode(); - } - GUI.EndGroup(); - - } - - public override void DrawLowerPropertyBox() { - PrepareWindowColor(); - previewFace = (CubemapFace)UndoableEnumPopup(lowerRect, previewFace, "switch displayed cubemap face"); - //previewFace = (CubemapFace)EditorGUI.EnumPopup( lowerRect, previewFace ); - ResetWindowColor(); - } - - public override string SerializeSpecialData() { - string s = property.Serialize() + ","; - if( cubemapAsset != null ) - s += "cube:" + SF_Tools.AssetToGUID( cubemapAsset ) + ","; - s += "pvfc:" + (int)previewFace; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize( key, value ); - switch( key ) { - case "cube": - cubemapAsset = (Cubemap)SF_Tools.GUIDToAsset( value, typeof( Cubemap ) ); - break; - case "pvfc": - previewFace = (CubemapFace)int.Parse( value ); - break; - } - if( cubemapAsset != null ) - RenderToTexture(); - - } - - - } -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cubemap.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cubemap.cs.meta deleted file mode 100755 index 3674ea77..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Cubemap.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d192fbfcd1bab084691cf8513ba322fd -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDX.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDX.cs deleted file mode 100644 index 7357e40b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDX.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_DDX : SF_Node_Arithmetic { - - public SFN_DDX() { - } - - public override void Initialize() { - base.Initialize( "DDX" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "ddx(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return GetInputData( "IN", c ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDX.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDX.cs.meta deleted file mode 100644 index ad4aa268..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDX.cs.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 99860db2c026be84f80f5b2108261fff -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDXY.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDXY.cs deleted file mode 100644 index 99d29841..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDXY.cs +++ /dev/null @@ -1,30 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_DDXY : SF_Node_Arithmetic { - - public SFN_DDXY() { - } - - public override void Initialize() { - base.Initialize( "DDXY" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "fwidth(_in)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "fwidth(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return GetInputData( "IN", c ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDXY.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDXY.cs.meta deleted file mode 100644 index 87b2aece..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDXY.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0a3921307ddb3d544a630d3475e57bb3 -timeCreated: 1443603932 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDY.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDY.cs deleted file mode 100644 index 986fa974..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDY.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_DDY : SF_Node_Arithmetic { - - public SFN_DDY() { - } - - public override void Initialize() { - base.Initialize( "DDY" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "ddy(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return GetInputData( "IN", c ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDY.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDY.cs.meta deleted file mode 100644 index d59de2f4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DDY.cs.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 120c745ac37b86a42863ba7882f193eb -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Depth.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Depth.cs deleted file mode 100755 index d05ca2fe..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Depth.cs +++ /dev/null @@ -1,37 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Depth : SF_Node { - - - public SFN_Depth() { - - } - - public override void Initialize() { - base.Initialize( "Depth", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 1; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0.3f, 0.6f, 0.3f, 1f ); - } - - // (mul( UNITY_MATRIX_V, float4((_WorldSpaceCameraPos.rgb-i.posWorld.rgb),0) ).b - _ProjectionParams.g) - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "partZ"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Depth.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Depth.cs.meta deleted file mode 100644 index 3541f1f4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Depth.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 13975082ad41249e4a2ea11f1a3a309f -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DepthBlend.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DepthBlend.cs deleted file mode 100755 index 1edc1e2c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DepthBlend.cs +++ /dev/null @@ -1,43 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_DepthBlend : SF_Node { - - - public SFN_DepthBlend() { - - } - - public override void Initialize() { - base.Initialize( "Depth Blend" ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 1; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1), - SF_NodeConnector.Create(this,"DIST","Dist",ConType.cInput,ValueType.VTv1), - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0.3f, 0.6f, 0.3f, 1f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string dist = ""; - - if( GetConnectorByStringID("DIST").IsConnected()){ - dist = "/" + GetInputCon("DIST").TryEvaluate(); - } - - - return "saturate((sceneZ-partZ)" + dist + ")"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DepthBlend.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DepthBlend.cs.meta deleted file mode 100644 index 07dba0a3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_DepthBlend.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e6258458743164db7896c9d9beb16a00 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Desaturate.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Desaturate.cs deleted file mode 100755 index 1cabc8fe..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Desaturate.cs +++ /dev/null @@ -1,112 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Desaturate : SF_Node { - - // SF_Node tNode; - - public SFN_Desaturate() { - - } - - - public override void Initialize() { - base.Initialize( "Desaturate" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.Modal; - UseLowerReadonlyValues( true ); - - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"COL","Col",ConType.cInput,ValueType.VTvPending,false).SetRequired(true).TypecastTo(3), - SF_NodeConnector.Create(this,"DES","Des",ConType.cInput,ValueType.VTv1,false).SetRequired(false) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1] ); - (conGroup as SFNCG_Arithmetic).lockedOutput = true; - - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if(GetEvaluatedComponentCount() == 3){ - this["OUT"].valueType = ValueType.VTv3; - } else { - this["OUT"].valueType = ValueType.VTv1; - } - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - if(this["DES"].IsConnected()) - return ( GetInputData( "COL" ).uniform && GetInputData( "DES" ).uniform ); - return GetInputData( "COL" ).uniform; - } - - public override int GetEvaluatedComponentCount() { - return this["DES"].IsConnected() ? 3 : 1; - } - - public override string[] GetModalModes() { - return new string[]{ - "REQONLY", - "DES" - }; - } - - public override string GetCurrentModalMode() { - if( GetInputIsConnected( "DES" ) ) { - return "DES"; - } - return "REQONLY"; - } - - public override string[] GetBlitOutputLines( string mode ) { - - string dotStr = "dot(_col,float3(0.3,0.59,0.11))"; - - if( mode == "DES" ) { - dotStr = "lerp(_col, " + dotStr + ".xxxx, _des)"; - } - - return new string[]{ dotStr }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string col = GetInputCon( "COL" ).Evaluate(); - string lum = "float3(0.3,0.59,0.11)"; - string dot = "dot("+col+","+lum+")"; - - if( this["DES"].IsConnected() ) { - string desat = GetInputCon( "DES" ).Evaluate(); - return "lerp(" + col + "," + dot + "," + desat + ")"; - } else { - return dot; // Fully desaturated - } - } - - public override Vector4 EvalCPU() { - - Vector4 col = GetInputData( "COL" ).dataUniform; - Vector4 lum = new Color( 0.3f, 0.59f, 0.11f, 0f ); - Vector4 dot = Vector4.Dot( col, lum ) * Vector4.one; - - float desat = 1f; - if( this["DES"].IsConnected() ) { - desat = GetInputData( "DES" ).dataUniform[0]; - } - - return Vector4.Lerp( col, dot, desat ); - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Desaturate.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Desaturate.cs.meta deleted file mode 100755 index bdb4d917..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Desaturate.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9ebe66cf4036ce547a0fc395d515f199 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Distance.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Distance.cs deleted file mode 100755 index c96a2d28..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Distance.cs +++ /dev/null @@ -1,52 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Distance : SF_Node_Arithmetic { - - public SFN_Distance() { - - } - - public override void Initialize() { - base.Initialize( "Distance" ); - base.PrepareArithmetic( 2, ValueType.VTvPending, ValueType.VTv1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - ( base.conGroup as SFNCG_Arithmetic ).LockOutType(); - - } - - public override int GetEvaluatedComponentCount() { - return 1; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "distance(" + GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate() + ")"; - } - - public override Vector4 EvalCPU() { - - float dist = 0f; - switch( Mathf.Max( GetInputData( "A" ).CompCount, GetInputData( "B" ).CompCount ) ) { - case 1: - dist = Mathf.Abs( GetInputData( "A" ).dataUniform[0] - GetInputData( "B" ).dataUniform[0] ); - break; - case 2: - dist = ( ( (Vector2)GetInputData( "A" ).dataUniform ) - ( (Vector2)GetInputData( "B" ).dataUniform ) ).magnitude; - break; - case 3: - dist = ( ( (Vector3)GetInputData( "A" ).dataUniform ) - ( (Vector3)GetInputData( "B" ).dataUniform ) ).magnitude; - break; - default: - dist = ( GetInputData( "A" ).dataUniform - GetInputData( "B" ).dataUniform ).magnitude; - break; - } - - return dist * Vector4.one; - - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Distance.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Distance.cs.meta deleted file mode 100755 index eb1c1364..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Distance.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 43af2b1572b552e418281a533a9719eb -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Divide.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Divide.cs deleted file mode 100755 index 887fcfdb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Divide.cs +++ /dev/null @@ -1,43 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Divide : SF_Node_Arithmetic { - - public SFN_Divide() { - - } - - public override void Initialize() { - base.Initialize( "Divide" ); - base.PrepareArithmetic(); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "(" + GetConnectorByStringID( "A" ).TryEvaluate() + "/" + GetConnectorByStringID( "B" ).TryEvaluate() + ")"; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "_a/_b" }; - } - - public override float EvalCPU( int c ) { - float a = GetInputData( "A", c ); - float b = GetInputData( "B", c ); - - if( b == 0f ) { - if( a == 0f ) - return 1f; - return ( a > 0 ? float.MaxValue : float.MinValue ); - } - return a / b; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Divide.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Divide.cs.meta deleted file mode 100755 index 5a69ffea..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Divide.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b453280af8376424fa6c495f5b4d5ab1 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Dot.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Dot.cs deleted file mode 100755 index 084674e8..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Dot.cs +++ /dev/null @@ -1,137 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Dot : SF_Node_Arithmetic { - - - public enum DotType { Standard, Positive, Negative, Abs, Normalized }; - public DotType dotType = DotType.Standard; - - public SFN_Dot() { - - } - - public override void Initialize() { - base.Initialize( "Dot" ); - base.texture.CompCount = 1; - base.UseLowerPropertyBox( true, true ); - base.PrepareArithmetic(2, ValueType.VTvPending, ValueType.VTv1); - base.shaderGenMode = ShaderGenerationMode.Modal; - ( base.conGroup as SFNCG_Arithmetic ).LockOutType(); - } - - public override int GetEvaluatedComponentCount() { - return 1; - } - - public override string[] GetModalModes() { - return new string[]{ - "STD", - "POS", - "NEG", - "ABS", - "NRM" - }; - } - - public override string GetCurrentModalMode() { - if( dotType == DotType.Positive ) - return "POS"; - if( dotType == DotType.Negative ) - return "NEG"; - if( dotType == DotType.Abs ) - return "ABS"; - if( dotType == DotType.Normalized ) - return "NRM"; - //if( dotType == DotType.Standard ) - return "STD"; - } - - public override string[] GetBlitOutputLines( string mode ) { - string dotStr = "dot(_a, _b)"; - switch( mode ) { - case "POS": - dotStr = "max(0," + dotStr + ")"; - break; - case "NEG": - dotStr = "min(0," + dotStr + ")"; - break; - case "ABS": - dotStr = "abs(" + dotStr + ")"; - break; - case "NRM": - dotStr = "0.5*" + dotStr + "+0.5"; - break; - } - return new string[]{dotStr}; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string dotStr = "dot(" + GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate() + ")"; - switch( dotType ) { - case DotType.Positive: - return "max(0," + dotStr + ")"; - case DotType.Negative: - return "min(0," + dotStr + ")"; - case DotType.Abs: - return "abs(" + dotStr + ")"; - case DotType.Normalized: - return "0.5*" + dotStr + "+0.5"; - } - return dotStr; - } - - public override Vector4 EvalCPU() { - - - int cc = Mathf.Max(GetInputCon("A").GetCompCount(), GetInputCon("B").GetCompCount()); - - float dot = SF_Tools.Dot( GetInputData( "A" ).dataUniform, GetInputData( "B" ).dataUniform, cc ); - - switch( dotType ) { - case DotType.Positive: - dot = Mathf.Max(0f,dot); - break; - case DotType.Negative: - dot = Mathf.Min(0f,dot); - break; - case DotType.Abs: - dot = Mathf.Abs(dot); - break; - case DotType.Normalized: - dot = 0.5f*dot+0.5f; - break; - } - - return dot * Vector4.one; - } - - public override void DrawLowerPropertyBox() { - EditorGUI.BeginChangeCheck(); - dotType = (DotType)UndoableEnumPopup( lowerRect, dotType, "dot product type" ); - if( EditorGUI.EndChangeCheck() ) - OnUpdateNode(); - } - - public override string SerializeSpecialData() { - return "dt:" + (int)dotType; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "dt": - dotType = (DotType)int.Parse( value ); - break; - } - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Dot.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Dot.cs.meta deleted file mode 100755 index fc43bb34..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Dot.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3d9849bf37434cb4da9729daf6ad3333 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_E.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_E.cs deleted file mode 100755 index 3e29e910..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_E.cs +++ /dev/null @@ -1,20 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_E : SFN_Node_Constant { - - public SFN_E() { - } - - public override void Initialize() { - base.Initialize( "e" ); - base.SearchName = "EulersConstant"; - base.PrepareConstant( "const_e", "2.718281828459" ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_E.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_E.cs.meta deleted file mode 100755 index 04976c08..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_E.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5e6843ca855bad643a35c23873e0a2ab -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Exp.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Exp.cs deleted file mode 100755 index 0fb6f2f7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Exp.cs +++ /dev/null @@ -1,93 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Exp : SF_Node_Arithmetic { - - - public enum ExpType { Exp, Exp2 }; - public ExpType expType = ExpType.Exp; - - public SFN_Exp() { - - } - - public override void Initialize() { - base.Initialize( "Exp" ); - base.UseLowerPropertyBox( true, true ); - base.PrepareArithmetic( 1, ValueType.VTvPending, ValueType.VTvPending ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string inner = GetConnectorByStringID( "IN" ).TryEvaluate(); - switch( expType ) { - case ExpType.Exp: - return "exp(" + inner + ")"; - case ExpType.Exp2: - return "exp2(" + inner + ")"; - } - - return inner; - } - - public override string[] GetModalModes() { - return new string[]{ - "EXP", - "EXP2" - }; - } - - public override string GetCurrentModalMode() { - if( expType == ExpType.Exp2) - return "EXP2"; - return "EXP"; - } - - public override string[] GetBlitOutputLines( string mode ) { - return new string[]{ mode.ToLower() + "(_in)" }; - } - - public override float EvalCPU( int c ) { - - float inpDt = GetInputData( "IN", c ); - - switch( expType ) { - case ExpType.Exp: - inpDt = Mathf.Pow( 2.718281828459f, inpDt ); - break; - case ExpType.Exp2: - inpDt = Mathf.Pow( 2f, inpDt ); - break; - } - - return inpDt; - } - - public override void DrawLowerPropertyBox() { - EditorGUI.BeginChangeCheck(); - expType = (ExpType)EditorGUI.EnumPopup( lowerRect, expType ); - if( EditorGUI.EndChangeCheck() ) - OnUpdateNode(); - } - - public override string SerializeSpecialData() { - return "et:" + (int)expType; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "et": - expType = (ExpType)int.Parse( value ); - break; - } - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Exp.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Exp.cs.meta deleted file mode 100755 index 139a4f00..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Exp.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 41a3320367346d84b9d27af7538971a8 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FaceSign.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FaceSign.cs deleted file mode 100644 index 169e00c6..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FaceSign.cs +++ /dev/null @@ -1,93 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_FaceSign : SF_Node { - - - public enum FaceSignType { ZeroAndOne = 0, PlusMinusOne = 1 }; - public static string[] faceSignTypeStr = new string[] { "1 and 0", "1 and -1" }; - public FaceSignType currentType = FaceSignType.ZeroAndOne; - - public SFN_FaceSign() { - - } - - public override void Initialize() { - base.Initialize( "Face Sign", InitialPreviewRenderMode.BlitQuad ); - base.showColor = true; - base.UseLowerPropertyBox( true, true ); - UpdateIcon(); - base.texture.CompCount = 1; - base.neverDefineVariable = true; - base.shaderGenMode = ShaderGenerationMode.Manual; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"VFACE","",ConType.cOutput,ValueType.VTv1,false) - }; - texture.dataUniform = Color.white; - } - - public override bool IsUniformOutput() { - return true; - } - - public void UpdateIcon() { - base.texture.SetIconId( (int)currentType ); - } - - public override Vector4 EvalCPU() { - float v = 1; - return new Color( v, v, v ); - } - - public override float EvalCPU( int c ) { - return 1f; - } - - public override void DrawLowerPropertyBox() { - GUI.color = Color.white; - EditorGUI.BeginChangeCheck(); - //currentType = (ScreenPosType)EditorGUI.EnumPopup( lowerRect, currentType ); - currentType = (FaceSignType)UndoableEnumPopupNamed(lowerRect, (int)currentType, faceSignTypeStr, "switch face sign type"); - if( EditorGUI.EndChangeCheck() ) { - UpdateIcon(); - OnUpdateNode(); - } - - } - - public override void PrepareRendering( Material mat ) { - mat.SetFloat( "_BackfaceValue", currentType == FaceSignType.PlusMinusOne ? -1 : 0 ); - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - // NeedSceneUVs() - switch(currentType){ - case FaceSignType.ZeroAndOne: - return "isFrontFace"; - case FaceSignType.PlusMinusOne: - return "faceSign"; - } - Debug.LogError("Invalid face sign category"); - return ""; - } - - public override string SerializeSpecialData() { - return "fstp:" + (int)currentType; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "fstp": - currentType = (FaceSignType)int.Parse( value ); - UpdateIcon(); - break; - } - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FaceSign.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FaceSign.cs.meta deleted file mode 100644 index ef15a608..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FaceSign.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f7d4222ab5faa9d4d9fc3dde7dec26b3 -timeCreated: 1439889392 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Final.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Final.cs deleted file mode 100755 index 06f17db4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Final.cs +++ /dev/null @@ -1,100 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Final : SF_Node { - - - - - public SF_NodeConnector - diffuse - , specular - , gloss - , normal - , emissive - , alpha - , alphaClip - , diffusePower - , refraction - , transmission - , lightWrap - , ambientDiffuse - , ambientSpecular - , diffuseOcclusion - , specularOcclusion - , customLighting - , outlineWidth - , outlineColor - //, anisotropicDirection - , vertexOffset - , displacement - , tessellation - ; - - public SFN_Final() { - - } - - public SFN_Final Initialize( SF_Editor editor ) { - base.Initialize( "Main" ); - this.editor = editor; - base.showColor = true; - AssignID(); - base.nodeName = "Main"; - Vector2 pos = new Vector2( 32768, 32768 ); - base.rect = new Rect( pos.x - NODE_WIDTH / 2, pos.y - NODE_HEIGHT / 2, NODE_WIDTH * 1.7f, 400 + 20f * 2 ); - - this.connectors = new SF_NodeConnector[]{ - - // SURFACE - diffuse = SF_NodeConnector.Create(this,"diff", "Diffuse", ConType.cInput, ValueType.VTvPending ,true,"float3(0,0,0)" ).Skip(PassType.ShadCast, PassType.Outline).TypecastTo(3), - diffusePower = SF_NodeConnector.Create(this,"diffpow", "Diffuse Power", ConType.cInput, ValueType.VTvPending ,true,"1" ).Skip(PassType.Meta, PassType.ShadCast, PassType.Outline).DisplayLockIfDeferredPrePassIsOn(), - specular = SF_NodeConnector.Create(this,"spec", "Specular", ConType.cInput, ValueType.VTvPending ,true ).Skip(PassType.ShadCast, PassType.Outline).TypecastTo(3), - gloss = SF_NodeConnector.Create(this,"gloss", "Gloss", ConType.cInput, ValueType.VTv1 ,true,"0.5" ).Skip(PassType.ShadCast, PassType.Outline), - normal = SF_NodeConnector.Create(this,"normal", "Normal", ConType.cInput, ValueType.VTv3 ,true ).Skip(PassType.Meta, PassType.ShadCast, PassType.Outline), - emissive = SF_NodeConnector.Create(this,"emission", "Emission", ConType.cInput, ValueType.VTvPending ,true,"float3(0,0,0)" ).Skip(PassType.ShadCast, PassType.Outline).TypecastTo(3), - transmission = SF_NodeConnector.Create(this,"transm", "Transmission", ConType.cInput, ValueType.VTvPending ,true ).Skip(PassType.Meta, PassType.ShadCast, PassType.Outline).TypecastTo(3).DisplayLockIfDeferredPrePassIsOn(), - lightWrap = SF_NodeConnector.Create(this,"lwrap", "Light Wrapping", ConType.cInput, ValueType.VTvPending ,true ).Skip(PassType.Meta, PassType.ShadCast, PassType.Outline).TypecastTo(3).DisplayLockIfDeferredPrePassIsOn(), - - // LIGHTING - ambientDiffuse = SF_NodeConnector.Create(this,"amdfl", "Diffuse Ambient Light", ConType.cInput, ValueType.VTvPending ,true,"float3(0,0,0)" ).Skip(PassType.Meta, PassType.ShadCast, PassType.FwdAdd, PassType.Outline).TypecastTo(3), - ambientSpecular = SF_NodeConnector.Create(this,"amspl", "Specular Ambient Light", ConType.cInput, ValueType.VTvPending ,true,"float3(0,0,0)" ).Skip(PassType.Meta, PassType.ShadCast, PassType.FwdAdd, PassType.Outline).TypecastTo(3), - diffuseOcclusion = SF_NodeConnector.Create(this,"difocc", "Diffuse Ambient Occlusion", ConType.cInput, ValueType.VTv1 ,true,"1" ).Skip(PassType.Meta, PassType.ShadCast, PassType.FwdAdd, PassType.Outline).TypecastTo(1), - specularOcclusion = SF_NodeConnector.Create(this,"spcocc", "Specular Ambient Occlusion", ConType.cInput, ValueType.VTv1 ,true,"1" ).Skip(PassType.Meta, PassType.ShadCast, PassType.FwdAdd, PassType.Outline).TypecastTo(1), - customLighting = SF_NodeConnector.Create(this,"custl", "Custom Lighting", ConType.cInput, ValueType.VTvPending ,true ).Skip(PassType.Meta, PassType.ShadCast, PassType.Outline).TypecastTo(3).DisplayLockIfDeferredPrePassIsOn(), - - // TRANSPARENCY - alpha = SF_NodeConnector.Create(this,"alpha", "Opacity", ConType.cInput, ValueType.VTv1 ,true,"1" ).Skip(PassType.Meta, PassType.ShadCast, PassType.Outline).DisplayLockIfDeferredPrePassIsOn(), - alphaClip = SF_NodeConnector.Create(this,"clip", "Opacity Clip", ConType.cInput, ValueType.VTv1 ,true ).Skip(PassType.Meta), - refraction = SF_NodeConnector.Create(this,"refract", "Refraction", ConType.cInput, ValueType.VTv2 ,true ).Skip(PassType.Meta, PassType.ShadCast, PassType.Outline).TypecastTo(2).DisplayLockIfDeferredPrePassIsOn(), - - // DEFORMERS - outlineWidth = SF_NodeConnector.Create(this,"olwid", "Outline Width", ConType.cInput, ValueType.VTv1 ,true ).Skip(PassType.Meta, PassType.ShadCast, PassType.FwdAdd, PassType.FwdBase).DisplayLockIfDeferredPrePassIsOn(), - outlineColor = SF_NodeConnector.Create(this,"olcol", "Outline Color", ConType.cInput, ValueType.VTvPending ,true,"float3(0,0,0)" ).Skip(PassType.Meta, PassType.ShadCast, PassType.FwdAdd, PassType.FwdBase).TypecastTo(3).DisplayLockIfDeferredPrePassIsOn(), - vertexOffset = SF_NodeConnector.Create(this,"voffset", "Vertex Offset", ConType.cInput, ValueType.VTvPending ,true ).ForceBlock(ShaderProgram.Vert).TypecastTo(3), - displacement = SF_NodeConnector.Create(this,"disp", "Displacement", ConType.cInput, ValueType.VTv3 ,true ).ForceBlock(ShaderProgram.Vert).TypecastTo(3), - tessellation = SF_NodeConnector.Create(this,"tess", "Tessellation", ConType.cInput, ValueType.VTv1 ,true ).ForceBlock(ShaderProgram.Vert) - }; - - //distortion.enableState = EnableState.Disabled; - //customLighting.enableState = EnableState.Disabled; - //cusomLightingDiffuse.enableState = EnableState.Disabled; - //anisotropicDirection.enableState = EnableState.Disabled; - - - return this; - - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( cascade ) - editor.OnShaderModified( updType ); - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Final.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Final.cs.meta deleted file mode 100755 index bcc973cc..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Final.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7082105362975344ca2b9df696cebfc0 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Floor.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Floor.cs deleted file mode 100755 index c177e4fa..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Floor.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Floor : SF_Node_Arithmetic { - - public SFN_Floor() { - } - - public override void Initialize() { - base.Initialize( "Floor" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "floor(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Floor( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Floor.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Floor.cs.meta deleted file mode 100755 index d8f77b58..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Floor.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 865a1444020b4c04dbe91ab9abe7d68d -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fmod.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fmod.cs deleted file mode 100755 index 17813c56..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fmod.cs +++ /dev/null @@ -1,29 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Fmod : SF_Node_Arithmetic { - - public SFN_Fmod() { - } - - public override void Initialize() { - base.Initialize( "Fmod" ); - base.PrepareArithmetic( 2 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "fmod(" + GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - float a = GetInputData( "A", c ); - float b = GetInputData( "B", c ); - float r = SF_Tools.Frac(Mathf.Abs(a/b))*Mathf.Abs(b); - return ( a < 0 ) ? -r : r; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fmod.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fmod.cs.meta deleted file mode 100755 index 58d537c9..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fmod.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a31abae5d5101c843bb077f6bc0d59b4 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FogColor.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FogColor.cs deleted file mode 100644 index a3703c80..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FogColor.cs +++ /dev/null @@ -1,52 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_FogColor : SF_Node { - - - public SFN_FogColor() { - - } - - public override void Initialize() { - base.Initialize( "Fog Color" ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - base.texture.uniform = true; - base.texture.coloredAlphaOverlay = true; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this, "RGB", "RGB",ConType.cOutput,ValueType.VTv3,false).Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this, "R", "R",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R).WithColor(Color.red), - SF_NodeConnector.Create(this, "G", "G",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G).WithColor(Color.green), - SF_NodeConnector.Create(this, "B", "B",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B).WithColor(Color.blue), - SF_NodeConnector.Create(this, "A", "A",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.A) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override void Update() { - if( texture.dataUniformColor != RenderSettings.fogColor ) { - texture.dataUniform = RenderSettings.fogColor; - OnUpdateNode(NodeUpdateType.Soft, true); - } - } - - public override void OnPreGetPreviewData() { - texture.dataUniform = RenderSettings.fogColor; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "unity_FogColor"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FogColor.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FogColor.cs.meta deleted file mode 100644 index d425bd88..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FogColor.cs.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 7500dcc568419264598b312dc040d374 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Frac.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Frac.cs deleted file mode 100755 index 6e9f2bdb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Frac.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Frac : SF_Node_Arithmetic { - - public SFN_Frac() { - } - - public override void Initialize() { - base.Initialize( "Frac" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "frac(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return SF_Tools.Frac( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Frac.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Frac.cs.meta deleted file mode 100755 index 67af7217..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Frac.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a625d40360731bd4fb8f5a2d020d3d11 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FragmentPosition.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FragmentPosition.cs deleted file mode 100755 index 4ee7aa5e..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FragmentPosition.cs +++ /dev/null @@ -1,49 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_FragmentPosition : SF_Node { - - - public SFN_FragmentPosition() { - - } - - public override void Initialize() { - base.Initialize( "World Pos.", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"XYZ","XYZ",ConType.cOutput,ValueType.VTv3,false).Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"X","X",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R).WithColor(Color.red), - SF_NodeConnector.Create(this,"Y","Y",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G).WithColor(Color.green), - SF_NodeConnector.Create(this,"Z","Z",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B).WithColor(Color.blue), - SF_NodeConnector.Create(this,"W","W",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.A) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0f, 0.7071068f, 0.7071068f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - if( SF_Evaluator.inFrag ) - return "i.posWorld"; - else if( SF_Evaluator.inVert ) - return "mul(_Object2World, v.vertex)"; - else if( SF_Evaluator.inTess ) - return "mul(_Object2World, v.vertex)"; - else{ - Debug.Log( "Evaluated into unknown shader program" ); - return null; - } - - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FragmentPosition.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FragmentPosition.cs.meta deleted file mode 100755 index 1471e8f5..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_FragmentPosition.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9b70f54e080f02746a1e069a06a69481 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fresnel.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fresnel.cs deleted file mode 100755 index 1cef8f5a..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fresnel.cs +++ /dev/null @@ -1,100 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Fresnel : SF_Node { - - - public SFN_Fresnel() { - - } - - public override void Initialize() { - - base.shaderGenMode = ShaderGenerationMode.ManualModal; - base.Initialize( "Fresnel", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 1; - base.vectorDataNode = true; - - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1,false), - SF_NodeConnector.Create(this,"NRM","Nrm",ConType.cInput,ValueType.VTv3,false), - SF_NodeConnector.Create(this,"EXP","Exp",ConType.cInput,ValueType.VTv1,false) - }; - - this["NRM"].unconnectedEvaluationValue = "normalDirection"; - - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue(0,0); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - return false; - } - - public override int GetEvaluatedComponentCount() { - return 1; - } - - public override string[] GetModalModes() { - return new string[]{ - "REQONLY", - "NRM", - "EXP", - "NRM_EXP" - }; - } - - public override string GetCurrentModalMode() { - if( connectors == null ) - return "REQONLY"; - - bool expCon = GetInputIsConnected( "EXP" ); - bool nrmCon = GetInputIsConnected( "NRM" ); - - if( !expCon && !nrmCon ) - return "REQONLY"; - if( !expCon && nrmCon ) - return "NRM"; - if( expCon && !nrmCon ) - return "EXP"; - // if( expCon && nrmCon ) - return "NRM_EXP"; - } - - public override string[] GetBlitOutputLines( string mode ) { - - string nrmStr = mode.Contains( "NRM" ) ? "_nrm.xyz" : "normalDirection"; - - string s = string.Format( "1.0-max(0,dot({0}, viewDirection))", nrmStr ); - - if( mode.Contains( "EXP" ) ) { - s = string.Format( "pow( {0}, {1} )", s, "_exp.x" ); - } - - return new string[]{ s }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string dot = "1.0-max(0,dot(" + this["NRM"].TryEvaluate() + ", viewDirection))"; - - if( GetInputIsConnected( "EXP" ) ) { - return "pow(" + dot + "," + this["EXP"].TryEvaluate() + ")"; - } - return "("+dot+")"; - - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fresnel.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fresnel.cs.meta deleted file mode 100755 index eaa19ce0..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Fresnel.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 805e259b709717a45aa900113bca53c1 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Get.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Get.cs deleted file mode 100644 index 352639e2..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Get.cs +++ /dev/null @@ -1,98 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Linq; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Get : SF_Node_Arithmetic { - - public SFN_Get() { - - } - - public SF_NodeConnector[] FindInConnectors() { - return SF_Editor.instance.nodes.Where( x => x is SFN_Set ).Select( x => x.connectors[0] ).ToArray(); - } - - public string[] GetInConnectorNames( SF_NodeConnector[] connectors ) { - return connectors.Select( x => x.node.variableName ).ToArray(); - } - - public override void Initialize() { - node_height = 20; - node_width = 120; - base.Initialize( "Get" ); - lowerRect.y -= 8; - lowerRect.height = 28; - base.showColor = false; - base.discreteTitle = true; - base.UseLowerPropertyBox( true, true ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - base.lockedVariableName = false; - extraWidthInput = -9; - extraWidthOutput = -9; - //base.texture.uniform = true; - //base.texture.CompCount = 1; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"IN","",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - }; - - connectors[1].enableState = EnableState.Hidden; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1]); - - editor.nodeView.RefreshRelaySources(); - - } - - public override string[] GetBlitOutputLines() { - return new string[] { "_in" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return GetConnectorByStringID( "IN" ).TryEvaluate(); - } - - public override float EvalCPU( int c ) { - return GetInputData( "IN", c ); - } - - - public override void DrawLowerPropertyBox() { - Rect r = new Rect( lowerRect ); - r.yMin += 4; - r.yMax -= 2; - r.xMin += 2; - Rect[] splitRects = r.SplitHorizontal( 0.25f, 2 ); - - int selectedID = -1; - if( connectors[1].inputCon != null){ - selectedID = editor.nodeView.NodeIdToRelayId( connectors[1].inputCon.node.id ); - } - - EditorGUI.BeginChangeCheck(); - int newID = UndoableEnumPopupNamed( splitRects[1], selectedID, editor.nodeView.relayInNames, "select Get option" ); - if( EditorGUI.EndChangeCheck() ) { - // Changed input, let's hook it up! - SF_NodeConnector con = editor.nodeView.relayInSources[newID].con; - connectors[1].LinkTo( con ); - } - - - Rect texCoords = new Rect( splitRects[0] ); - texCoords.width /= 7; - texCoords.height /= 3; - texCoords.x = texCoords.y = 0; - GUI.DrawTextureWithTexCoords( splitRects[0], SF_GUI.Handle_drag, texCoords, alphaBlend:true ); - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Get.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Get.cs.meta deleted file mode 100644 index 01c2c2cd..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Get.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b4b577d8837417743a49f63715fda21c -timeCreated: 1447437104 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HalfVector.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HalfVector.cs deleted file mode 100755 index 4e424328..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HalfVector.cs +++ /dev/null @@ -1,36 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_HalfVector : SF_Node { - - - public SFN_HalfVector() { - - } - - public override void Initialize() { - base.Initialize( "Half Dir.", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.availableInDeferredPrePass = false; - base.texture.CompCount = 3; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv3,false) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0.7071068f, 0f, 0.7071068f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "halfDirection"; // normalize(_WorldSpaceLightPos0.xyz); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HalfVector.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HalfVector.cs.meta deleted file mode 100755 index 3ac8e54b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HalfVector.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d27e30128b1a90946a33e1f6e18b2d27 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HsvToRgb.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HsvToRgb.cs deleted file mode 100644 index fb5c5a85..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HsvToRgb.cs +++ /dev/null @@ -1,71 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_HsvToRgb : SF_Node { - - public SFN_HsvToRgb() { - } - - public override void Initialize() { - base.Initialize( "HSV to RGB" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - UseLowerReadonlyValues( true ); - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create( this, "OUT", "", ConType.cOutput, ValueType.VTv3, false ), - SF_NodeConnector.Create( this, "H", "Hue", ConType.cInput, ValueType.VTv1, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "S", "Sat", ConType.cInput, ValueType.VTv1, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "V", "Val", ConType.cInput, ValueType.VTv1, false ).SetRequired( true )}; - } - - public override int GetEvaluatedComponentCount() { - return 3; - } - - public override bool IsUniformOutput() { - if( InputsConnected() ) { - return GetInputData( "H" ).uniform && GetInputData( "S" ).uniform && GetInputData( "V" ).uniform; - } - return true; - } - - public override string[] GetBlitOutputLines() { - return new string[] { - "float4((lerp(float3(1,1,1),saturate(3.0*abs(1.0-2.0*frac(_h.x+float3(0.0,-1.0/3.0,1.0/3.0)))-1),_s.x)*_v.x),0)" - }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string h = GetConnectorByStringID( "H" ).TryEvaluate(); - string s = GetConnectorByStringID( "S" ).TryEvaluate(); - string v = GetConnectorByStringID( "V" ).TryEvaluate(); - return "(lerp(float3(1,1,1),saturate(3.0*abs(1.0-2.0*frac("+h+"+float3(0.0,-1.0/3.0,1.0/3.0)))-1),"+s+")*" + v + ")"; - } - - static Vector3 offsets = new Vector3(0f,-1f/3f, 1f/3f); - - public override float EvalCPU( int c ) { - if(c == 3) - return 1f; - float h = GetInputData( "H", c ); - float s = GetInputData( "S", c ); - float v = GetInputData( "V", c ); - float o = offsets[c]; - return Mathf.Lerp(1,Mathf.Clamp01(3 * Mathf.Abs(1-2*Frac(h+o)) - 1),s)*v; - } - - float Frac( float x ) { - return x - Mathf.Floor( x ); - - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HsvToRgb.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HsvToRgb.cs.meta deleted file mode 100644 index 46bb4a9f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_HsvToRgb.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 68a644a284b0e1845858bdca07ef2ed7 -timeCreated: 1436519980 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Hue.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Hue.cs deleted file mode 100644 index c7987ec1..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Hue.cs +++ /dev/null @@ -1,64 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Hue : SF_Node { - - public SFN_Hue() { - } - - public override void Initialize() { - base.Initialize( "Hue" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - UseLowerReadonlyValues( true ); - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create( this, "OUT", "", ConType.cOutput, ValueType.VTv3, false ), - SF_NodeConnector.Create( this, "IN", "", ConType.cInput, ValueType.VTv1, false ).SetRequired( true )}; - } - - public override int GetEvaluatedComponentCount() { - return 3; - } - - public override bool IsUniformOutput() { - - if(GetInputIsConnected("IN")){ - return GetInputData( "IN" ).uniform; - } - return true; - } - - public override string[] GetBlitOutputLines() { - return new string[]{ "float4(saturate(3.0*abs(1.0-2.0*frac(_in.x+float3(0.0,-1.0/3.0,1.0/3.0)))-1),0)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string v = GetConnectorByStringID( "IN" ).TryEvaluate(); - return "saturate(3.0*abs(1.0-2.0*frac("+v+"+float3(0.0,-1.0/3.0,1.0/3.0)))-1)"; - } - - static Vector3 offsets = new Vector3(0f,-1f/3f, 1f/3f); - - public override float EvalCPU( int c ) { - if(c == 3) - return 1f; - float v = GetInputData( "IN", c ); - float o = offsets[c]; - return Mathf.Clamp01(3 * Mathf.Abs(1-2*Frac(v+o)) - 1); - } - - float Frac( float x ) { - return x - Mathf.Floor( x ); - - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 1 ); - base.OnUpdateNode( updType ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Hue.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Hue.cs.meta deleted file mode 100644 index ee8349cd..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Hue.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e81546dbfab1e6c489c92093e9600cf7 -timeCreated: 1436200734 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_If.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_If.cs deleted file mode 100755 index 10973699..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_If.cs +++ /dev/null @@ -1,95 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_If : SF_Node_Arithmetic { - - public SFN_If() { - } - - public override void Initialize() { - base.Initialize( "If" ); - base.PrepareArithmetic(0); - base.showLowerReadonlyValues = false; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create( this,"OUT", "", ConType.cOutput, ValueType.VTvPending, false ), - SF_NodeConnector.Create( this,"A", "A", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this,"B", "B", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this,"GT", "A>B", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this,"EQ", "A=B", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this,"LT", "A().Initialize( connectors[0], connectors[1], connectors[2], connectors[3], connectors[4], connectors[5] ); - } - - - public string StA() { - return GetVariableName() + "_if_leA"; - } - public string StB() { - return GetVariableName() + "_if_leB"; - } - - - public override string[] GetPreDefineRows() { - return new string[] { - "float " + StA() + " = step(" + this["A"].TryEvaluate() + "," + this["B"].TryEvaluate() + ");", - "float " + StB() + " = step(" + this["B"].TryEvaluate() + "," + this["A"].TryEvaluate() + ");" - }; - } - - public override string[] GetBlitOutputLines() { - - string less = "(sta*_lt)"; - string larger = "(stb*_gt)"; - string lela = less + "+" + larger; - - return new string[]{ - "float sta = step(_a,_b);", - "float stb = step(_b,_a);", - "lerp(" + lela + ",_eq,sta*stb)" - }; - } - - public override bool IsUniformOutput() { - foreach(SF_NodeConnector con in connectors){ - if(con.conType == ConType.cOutput) - continue; - if(con.IsConnectedAndEnabled()) - if(!con.inputCon.node.IsUniformOutput()) - return false; - } - return true; - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - if(!ShouldDefineVariable()) // TODO: Isn't this already handled on the node level? - this.PreDefine(); - - string less = "(" + StA() + "*" + GetInputCon( "LT" ).Evaluate() + ")"; - string larger = "(" + StB() + "*" + GetInputCon( "GT" ).Evaluate() + ")"; - string lela = less + "+" + larger; - - return "lerp(" + lela + "," + GetInputCon( "EQ" ).Evaluate() + "," + StA() + "*" + StB() + ")"; - } - - public override float EvalCPU( int c ) { - float a = GetInputData( "A", c ); - float b = GetInputData( "B", c ); - - float sta = ( ( a <= b ) ? 1.0f : 0.0f ); - float stb = ( ( b <= a ) ? 1.0f : 0.0f ); - - float less = sta * GetInputData( "LT", c ); - float larger = stb * GetInputData( "GT", c ); - float lela = ( less + larger ); - - return Mathf.Lerp( lela, GetInputData( "EQ", c ), sta * stb ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_If.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_If.cs.meta deleted file mode 100755 index a9cbc818..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_If.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 08bd8679c2a595b4ebd6d65a4a96817e -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_InverseLerp.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_InverseLerp.cs deleted file mode 100644 index 89e6b3cb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_InverseLerp.cs +++ /dev/null @@ -1,75 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_InverseLerp : SF_Node { - - public SFN_InverseLerp() { - - } - - public override void Initialize() { - base.Initialize( "Inverse Lerp" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - UseLowerReadonlyValues( true ); - - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","T",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"A","A",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","B",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"V","Val",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2], connectors[3] ); - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override string[] GetBlitOutputLines() { - return new string[] { "((_v-_a)/(_b-_a))" }; - } - - public override bool IsUniformOutput() { - return ( GetInputData( "A" ).uniform && GetInputData( "B" ).uniform && GetInputData( "V" ).uniform ); - } - - public override int GetEvaluatedComponentCount() { - return Mathf.Max( this["A"].GetCompCount(), this["B"].GetCompCount(), this["V"].GetCompCount() ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string a = GetConnectorByStringID( "A" ).TryEvaluateAs( GetEvaluatedComponentCount() ); - string b = GetConnectorByStringID( "B" ).TryEvaluateAs( GetEvaluatedComponentCount() ); - string v = GetConnectorByStringID( "V" ).TryEvaluateAs( GetEvaluatedComponentCount() ); - - return "((" + v + "-" + a + ")/(" + b + "-" + a + "))"; - } - - public override float EvalCPU( int c ) { - - float a = GetInputData( "A", c ); - float b = GetInputData( "B", c ); - float v = GetInputData( "V", c ); - - if( (b - a) == 0f ) - return 0; - return ( v - a ) / ( b - a ); - } - - public float Lerp( float a, float b, float t ) { - return ( ( 1f - t ) * a + t * b ); - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_InverseLerp.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_InverseLerp.cs.meta deleted file mode 100644 index de877657..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_InverseLerp.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 16d3bfd026312984b9f3db11f2c6762a -timeCreated: 1439743244 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Length.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Length.cs deleted file mode 100755 index 66f193c4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Length.cs +++ /dev/null @@ -1,42 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Length : SF_Node_Arithmetic { - - public SFN_Length() { - } - - public override void Initialize() { - base.Initialize( "Length" ); - base.PrepareArithmetic( 1, ValueType.VTvPending, ValueType.VTv1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - ( base.conGroup as SFNCG_Arithmetic ).LockOutType(); - } - - public override int GetEvaluatedComponentCount() { - return 1; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "length(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override Vector4 EvalCPU() { - - switch( GetInputData( "IN" ).CompCount ) { - case 1: - return Vector4.one * Mathf.Abs( GetInputData( "IN" ).dataUniform[0] ); - case 2: - return Vector4.one * ( (Vector2)GetInputData( "IN" ).dataUniform ).magnitude; - case 3: - return Vector4.one * ( (Vector3)GetInputData( "IN" ).dataUniform ).magnitude; - default: - return Vector4.one * GetInputData( "IN" ).dataUniform.magnitude; - } - - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Length.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Length.cs.meta deleted file mode 100755 index f274b079..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Length.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9dffa999f0a9a014692a70f8050a87f4 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Lerp.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Lerp.cs deleted file mode 100755 index b55cf9b3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Lerp.cs +++ /dev/null @@ -1,58 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Lerp : SF_Node { - - public SFN_Lerp() { - - } - - public override void Initialize() { - base.Initialize( "Lerp" ); - base.showColor = true; - UseLowerReadonlyValues( true ); - - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"A","A",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","B",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"T","T",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2], connectors[3] ); - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - return ( GetInputData( "A" ).uniform && GetInputData( "B" ).uniform && GetInputData( "T" ).uniform ); - } - - public override int GetEvaluatedComponentCount() { - return Mathf.Max( this["A"].GetCompCount(), this["B"].GetCompCount(), this["T"].GetCompCount() ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "lerp(" + GetConnectorByStringID( "A" ).TryEvaluateAs(GetEvaluatedComponentCount()) + "," + GetConnectorByStringID( "B" ).TryEvaluateAs(GetEvaluatedComponentCount()) + "," + GetInputCon( "T" ).Evaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Lerp( GetInputData( "B", c ), GetInputData( "B", c ), GetInputData( "T", c ) ); - } - - public float Lerp( float a, float b, float t ) { - return ( ( 1f - t ) * a + t * b ); - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Lerp.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Lerp.cs.meta deleted file mode 100755 index 00994367..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Lerp.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f4503b6214f161b4a95dfd184348546f -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightAttenuation.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightAttenuation.cs deleted file mode 100755 index d6326d7b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightAttenuation.cs +++ /dev/null @@ -1,36 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_LightAttenuation : SF_Node { - - - public SFN_LightAttenuation() { - - } - - public override void Initialize() { - base.Initialize( "Light Atten.", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 1; - base.neverDefineVariable = true; - base.availableInDeferredPrePass = false; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1,false) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 1f, 1f, 1f, 1f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "attenuation"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightAttenuation.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightAttenuation.cs.meta deleted file mode 100755 index 9b609234..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightAttenuation.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 686b4d39e6a081d4ab3974d70ea038ea -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightColor.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightColor.cs deleted file mode 100755 index 98a9f5ca..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightColor.cs +++ /dev/null @@ -1,40 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_LightColor : SF_Node { - - - public SFN_LightColor() { - - } - - public override void Initialize() { - base.Initialize( "Light Color", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - base.neverDefineVariable = true; - base.availableInDeferredPrePass = false; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"RGB","RGB",ConType.cOutput,ValueType.VTv3,false).Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"R","R",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R).WithColor(Color.red), - SF_NodeConnector.Create(this,"G","G",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G).WithColor(Color.green), - SF_NodeConnector.Create(this,"B","B",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B).WithColor(Color.blue), - SF_NodeConnector.Create(this,"A","A",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.A) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0.5f, 0, 0, 0 ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "_LightColor0"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightColor.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightColor.cs.meta deleted file mode 100755 index e6600c28..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightColor.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7f012e392e4a89a4791a4856f4f56b4c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightPosition.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightPosition.cs deleted file mode 100755 index 4a9044e1..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightPosition.cs +++ /dev/null @@ -1,40 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_LightPosition : SF_Node { - - - public SFN_LightPosition() { - - } - - public override void Initialize() { - base.Initialize( "Light Pos.", InitialPreviewRenderMode.BlitQuad ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - base.neverDefineVariable = true; - base.availableInDeferredPrePass = false; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"XYZ","XYZ",ConType.cOutput,ValueType.VTv3,false).Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"X","X",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R).WithColor(Color.red), - SF_NodeConnector.Create(this,"Y","Y",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G).WithColor(Color.green), - SF_NodeConnector.Create(this,"Z","Z",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B).WithColor(Color.blue), - SF_NodeConnector.Create(this,"PNT","Pnt",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.A) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0f, 0.7071068f, 0.7071068f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "_WorldSpaceLightPos0"; // normalize(_WorldSpaceLightPos0.xyz); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightPosition.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightPosition.cs.meta deleted file mode 100755 index 14671d07..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightPosition.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0b9d9898dea86c748886d87751eb5e9b -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightVector.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightVector.cs deleted file mode 100755 index 7e231bad..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightVector.cs +++ /dev/null @@ -1,36 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_LightVector : SF_Node { - - - public SFN_LightVector() { - - } - - public override void Initialize() { - base.Initialize( "Light Dir.", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 3; - base.neverDefineVariable = true; - base.availableInDeferredPrePass = false; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv3,false) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0f, 0.7071068f, 0.7071068f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "lightDirection"; // normalize(_WorldSpaceLightPos0.xyz); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightVector.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightVector.cs.meta deleted file mode 100755 index df3db58a..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_LightVector.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 66c49f9dbeaeb414a8aaff0d8c27d00d -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Log.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Log.cs deleted file mode 100755 index 15d3af5a..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Log.cs +++ /dev/null @@ -1,111 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Log : SF_Node_Arithmetic { - - - public enum LogType { Natural, Base2, Base10 }; - public LogType logType = LogType.Natural; - - public SFN_Log() { - - } - - public override void Initialize() { - base.Initialize( "Log" ); - base.UseLowerPropertyBox( true, true ); - base.PrepareArithmetic( 1, ValueType.VTvPending, ValueType.VTvPending ); - base.shaderGenMode = ShaderGenerationMode.Modal; - } - - - public override string[] GetModalModes() { - return new string[] { - "LOG", - "LOG2", - "LOG10" - }; - } - - public override string GetCurrentModalMode() { - switch( logType ) { - case LogType.Base10: - return "LOG10"; - case LogType.Base2: - return "LOG2"; - default: - return "LOG"; - } - } - - public override string[] GetBlitOutputLines( string mode ) { - if( mode == "LOG2" ) - return new string[] { "log(_in);" }; - if( mode == "LOG10" ) - return new string[] { "log10(_in);" }; - return new string[] { "log(_in)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string inner = GetConnectorByStringID( "IN" ).TryEvaluate(); - switch( logType ) { - case LogType.Natural: - return "log(" + inner + ")"; - case LogType.Base2: - return "log2(" + inner + ")"; - case LogType.Base10: - return "log10(" + inner + ")"; - } - - return inner; - } - - public override float EvalCPU( int c ) { - - float inpDt = GetInputData( "IN", c ); - - switch( logType ) { - case LogType.Natural: - inpDt = Mathf.Log( inpDt ); - break; - case LogType.Base2: - inpDt = Mathf.Log( inpDt ) / Mathf.Log( 2f ); - break; - case LogType.Base10: - inpDt = Mathf.Log10( inpDt ); - break; - } - - return inpDt; - } - - public override void DrawLowerPropertyBox() { - EditorGUI.BeginChangeCheck(); - logType = (LogType)UndoableEnumPopup( lowerRect, logType, "switch log type"); - //logType = (LogType)EditorGUI.EnumPopup( lowerRect, logType ); - if( EditorGUI.EndChangeCheck() ) - OnUpdateNode(); - } - - public override string SerializeSpecialData() { - return "lt:" + (int)logType; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "lt": - logType = (LogType)int.Parse( value ); - break; - } - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Log.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Log.cs.meta deleted file mode 100755 index bb9bc278..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Log.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 61c69de42939c63429fcb6359f2b7953 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4.cs deleted file mode 100644 index 2e3fa623..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4.cs +++ /dev/null @@ -1,93 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - public class SFN_Matrix4x4 : SF_Node { - - - public SFN_Matrix4x4() { - - } - - public Matrix4x4 mtx = Matrix4x4.identity; - - public override void Initialize() { - node_height = NODE_HEIGHT; - base.Initialize( "Matrix 4x4" ); - base.showColor = false; - base.UseLowerPropertyBox( false ); - base.texture.uniform = true; - base.texture.CompCount = 4; - base.canAlwaysSetPrecision = true; - base.alwaysDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTm4x4,false) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return mtx.ToCgMatrix(); - } - - public override void NeatWindow() { - PrepareWindowColor(); - GUI.BeginGroup( rect ); - Rect r = new Rect( rectInner ); - r = r.Pad( 4 ); - r.height = 20; - - DrawGrabHandle( r ); - - - Rect tRect = rectInner.Pad( 2 ); - tRect.yMin += 28; - - tRect.width /= 4; - tRect.height /= 4; - tRect.height = Mathf.FloorToInt( tRect.height ); - - for( int i=0; i < 4; i++ ) { - UndoableEnterableFloatFieldMtx( tRect, i, 0); - tRect.x += tRect.width; - UndoableEnterableFloatFieldMtx( tRect, i, 1 ); - tRect.x += tRect.width; - UndoableEnterableFloatFieldMtx( tRect, i, 2 ); - tRect.x += tRect.width; - UndoableEnterableFloatFieldMtx( tRect, i, 3 ); - tRect.x -= tRect.width*3; - tRect.y += tRect.height; - } - - - GUI.EndGroup(); - ResetWindowColor(); - - } - - - public void UndoableEnterableFloatFieldMtx(Rect r, int row, int column ) { - float val = mtx[row,column]; - UndoableEnterableFloatField( r, ref val, "matrix [" + row + "," + column + "]", null ); - mtx[row, column] = val; - } - - public override string SerializeSpecialData() { - return mtx.SerializeToCSV(); - } - - public override void DeserializeSpecialData( string key, string value ) { - mtx = mtx.DeserializeKeyValue( key, value ); - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4.cs.meta deleted file mode 100644 index 0d05a31f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e3bfdd39d540f4846810495c5c353993 -timeCreated: 1436168471 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4Property.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4Property.cs deleted file mode 100644 index f9b17465..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4Property.cs +++ /dev/null @@ -1,98 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - public class SFN_Matrix4x4Property : SF_Node { - - - public SFN_Matrix4x4Property() { - - } - - public Matrix4x4 mtx = Matrix4x4.identity; - - public override void Initialize() { - node_height = NODE_HEIGHT; - base.Initialize( "Matrix 4x4" ); - base.showColor = false; - base.UseLowerPropertyBox( false ); - base.texture.uniform = true; - base.texture.CompCount = 4; - base.canAlwaysSetPrecision = true; - base.alwaysDefineVariable = false; - - property = ScriptableObject.CreateInstance().Initialize( this ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTm4x4,false) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return property.GetVariable(); - } - - public override void NeatWindow() { - PrepareWindowColor(); - GUI.BeginGroup( rect ); - Rect r = new Rect( rectInner ); - r = r.Pad( 4 ); - r.height = 20; - - DrawGrabHandle( r ); - - - Rect tRect = rectInner.Pad( 2 ); - tRect.yMin += 28; - - tRect.width /= 4; - tRect.height /= 4; - tRect.height = Mathf.FloorToInt( tRect.height ); - - EditorGUI.BeginDisabledGroup(true); - for( int i=0; i < 4; i++ ) { - UndoableEnterableFloatFieldMtx( tRect, i, 0); - tRect.x += tRect.width; - UndoableEnterableFloatFieldMtx( tRect, i, 1 ); - tRect.x += tRect.width; - UndoableEnterableFloatFieldMtx( tRect, i, 2 ); - tRect.x += tRect.width; - UndoableEnterableFloatFieldMtx( tRect, i, 3 ); - tRect.x -= tRect.width*3; - tRect.y += tRect.height; - } - EditorGUI.EndDisabledGroup(); - - GUI.EndGroup(); - ResetWindowColor(); - - } - - - public void UndoableEnterableFloatFieldMtx(Rect r, int row, int column ) { - float val = mtx[row,column]; - UndoableEnterableFloatField( r, ref val, "matrix [" + row + "," + column + "]", null ); - mtx[row, column] = val; - } - - public override string SerializeSpecialData() { - return property.Serialize() + "," + mtx.SerializeToCSV(); - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize( key, value ); - mtx = mtx.DeserializeKeyValue( key, value ); - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4Property.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4Property.cs.meta deleted file mode 100644 index 0001a42b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Matrix4x4Property.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 638c5b214d6a1b14ea3a6ef2a69d0b89 -timeCreated: 1436192974 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Max.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Max.cs deleted file mode 100755 index ecbb2749..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Max.cs +++ /dev/null @@ -1,76 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Max : SF_Node_Arithmetic { - - public SFN_Max() { - - } - - public override void Initialize() { - base.Initialize( "Max" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.ModularInput; - UseLowerReadonlyValues( true ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"A","A",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","B",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"C","C",ConType.cInput,ValueType.VTvPending,false).SetRequired(false), - SF_NodeConnector.Create(this,"D","D",ConType.cInput,ValueType.VTvPending,false).SetRequired(false), - SF_NodeConnector.Create(this,"E","E",ConType.cInput,ValueType.VTvPending,false).SetRequired(false) - }; - - - SetExtensionConnectorChain("B", "C", "D", "E"); - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2], connectors[3], connectors[4], connectors[5] ); - - } - - public override void GetModularShaderFixes( out string prefix, out string infix, out string suffix ) { - prefix = "max("; - infix = ", "; - suffix = ")"; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string retStr = "max(" + TryEvalInput("A") + "," + TryEvalInput("B") + ")"; - - // Loop through all chain childs - foreach(SF_NodeConnector con in connectors){ - if(con.IsConnected() && con.IsChild()){ - retStr = "max(" + retStr + "," + con.TryEvaluate() + ")"; - } - } - - return retStr; - } - - string TryEvalInput(string s){ - return GetConnectorByStringID(s).TryEvaluate(); - } - - public override float EvalCPU( int c ) { - - float maximum = Mathf.Max( GetInputData( "A", c ), GetInputData( "B", c ) ); - - // Loop through all chain childs - foreach(SF_NodeConnector con in connectors){ - if(con.IsConnected() && con.IsChild()){ - maximum = Mathf.Max(maximum, GetInputData( con.strID, c ) ); - } - } - - - return maximum; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Max.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Max.cs.meta deleted file mode 100755 index f8f9bad5..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Max.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a4a4eeb60c3655748ab34f85aaa9eca6 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Min.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Min.cs deleted file mode 100755 index f01df021..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Min.cs +++ /dev/null @@ -1,78 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Min : SF_Node_Arithmetic { - - public SFN_Min() { - - } - - public override void Initialize() { - base.Initialize( "Min" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.ModularInput; - UseLowerReadonlyValues( true ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"A","A",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","B",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"C","C",ConType.cInput,ValueType.VTvPending,false).SetRequired(false), - SF_NodeConnector.Create(this,"D","D",ConType.cInput,ValueType.VTvPending,false).SetRequired(false), - SF_NodeConnector.Create(this,"E","E",ConType.cInput,ValueType.VTvPending,false).SetRequired(false) - }; - - - SetExtensionConnectorChain("B", "C", "D", "E"); - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2], connectors[3], connectors[4], connectors[5] ); - - } - - public override void GetModularShaderFixes( out string prefix, out string infix, out string suffix ) { - prefix = "min("; - infix = ", "; - suffix = ")"; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string retStr = "min(" + TryEvalInput("A") + "," + TryEvalInput("B") + ")"; - - // Loop through all chain childs - foreach(SF_NodeConnector con in connectors){ - if(con.IsConnected() && con.IsChild()){ - retStr = "min(" + retStr + "," + con.TryEvaluate() + ")"; - } - } - - return retStr; - } - - string TryEvalInput(string s){ - return GetConnectorByStringID(s).TryEvaluate(); - } - - - public override float EvalCPU( int c ) { - - float minimum = Mathf.Min( GetInputData( "A", c ), GetInputData( "B", c ) ); - - // Loop through all chain childs - foreach(SF_NodeConnector con in connectors){ - if(con.IsConnected() && con.IsChild()){ - minimum = Mathf.Min(minimum, GetInputData( con.strID, c ) ); - } - } - - - return minimum; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Min.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Min.cs.meta deleted file mode 100755 index 2b12f397..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Min.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 24a991d2351190f4f88d3c06eabafb58 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Multiply.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Multiply.cs deleted file mode 100755 index aaa9c373..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Multiply.cs +++ /dev/null @@ -1,72 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Multiply : SF_Node_Arithmetic { - - public SFN_Multiply() { - - } - - public override void Initialize() { - base.Initialize( "Multiply" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.ModularInput; - UseLowerReadonlyValues( true ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"A","A",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","B",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"C","C",ConType.cInput,ValueType.VTvPending,false).SetRequired(false), - SF_NodeConnector.Create(this,"D","D",ConType.cInput,ValueType.VTvPending,false).SetRequired(false), - SF_NodeConnector.Create(this,"E","E",ConType.cInput,ValueType.VTvPending,false).SetRequired(false) - }; - - - SetExtensionConnectorChain("B", "C", "D", "E"); - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2], connectors[3], connectors[4], connectors[5] ); - - } - - public override void GetModularShaderFixes( out string prefix, out string infix, out string suffix ) { - prefix = ""; - infix = " * "; - suffix = ""; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - - string evalStr = ""; - - evalStr += GetConnectorByStringID( "A" ).TryEvaluate() + "*" + GetConnectorByStringID( "B" ).TryEvaluate(); - - ChainAppendIfConnected(ref evalStr, "*", "C", "D", "E"); - - return "(" + evalStr + ")"; - } - - public override float EvalCPU( int c ) { - - float result = GetInputData( "A", c ) * GetInputData( "B", c ); - - if(GetInputIsConnected("C")){ - result *= GetInputData( "C", c ); - } - if(GetInputIsConnected("D")){ - result *= GetInputData( "D", c ); - } - if(GetInputIsConnected("E")){ - result *= GetInputData( "E", c ); - } - - return result; - } - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Multiply.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Multiply.cs.meta deleted file mode 100755 index 68e66520..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Multiply.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e4fb4b834fbc00e4bac700df8f98ea7c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_MultiplyMatrix.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_MultiplyMatrix.cs deleted file mode 100644 index 1774a633..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_MultiplyMatrix.cs +++ /dev/null @@ -1,91 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_MultiplyMatrix : SF_Node_Arithmetic { - - public Matrix4x4 mtx; - - public SFN_MultiplyMatrix() { - - } - - public override void Initialize() { - node_height = 58; - base.Initialize( "Multiply Matrix" ); - base.showColor = false; - base.UseLowerPropertyBox( false, true ); - //UseLowerReadonlyValues( true ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv4m4x4,false), - SF_NodeConnector.Create(this,"A","A",ConType.cInput,ValueType.VTv4m4x4,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","B",ConType.cInput,ValueType.VTv4m4x4,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2] ); - - } - - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string evalStr = ""; - evalStr += "mul(" + GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate() + ")"; - return evalStr; - } - - public override Vector4 EvalCPU() { - - return Color.black; - /* - SF_NodeConnector a = ConnectedInputs[0]; - SF_NodeConnector b = ConnectedInputs[1]; - - if( !a.IsConnected() || !b.IsConnected() ) { - return Color.black; - } - - - bool am = a.inputCon.valueType == ValueType.VTm4x4; - bool bm = b.inputCon.valueType == ValueType.VTm4x4; - - Matrix4x4 mtx; - if( am && bm ) { - return Color.black; - } else if(am){ - mtx = ( a.inputCon.node as SFN_Matrix4x4 ).mtx; - return mtx * GetInputData( "B" )[x,y]; - } else if( bm ) { - mtx = ( b.inputCon.node as SFN_Matrix4x4 ).mtx; - return mtx.transpose * GetInputData( "A" )[x, y]; - } - return Color.black;*/ - } - - - - public override void NeatWindow() { - PrepareWindowColor(); - GUI.BeginGroup( rect ); - Rect r = new Rect( rectInner ); - r = r.Pad( 4 ); - - Rect texCoords = new Rect( r ); - texCoords.width /= 7; - texCoords.height /= 3; - texCoords.x = texCoords.y = 0; - GUI.DrawTextureWithTexCoords( r, SF_GUI.Handle_drag, texCoords, alphaBlend: true ); - - GUI.EndGroup(); - ResetWindowColor(); - - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_MultiplyMatrix.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_MultiplyMatrix.cs.meta deleted file mode 100644 index 91806432..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_MultiplyMatrix.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: adea9494f4e8c5a4a9e044ebb72374ee -timeCreated: 1436175018 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Negate.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Negate.cs deleted file mode 100755 index 8bd3ee74..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Negate.cs +++ /dev/null @@ -1,30 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Negate : SF_Node_Arithmetic { - - public SFN_Negate() { - } - - public override void Initialize() { - base.Initialize( "Negate" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "(-1*_in)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "(-1*" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return -GetInputData( "IN", c ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Negate.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Negate.cs.meta deleted file mode 100755 index bf594a50..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Negate.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e3df968e03820c742ab7e8c36642dca2 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Node_Constant.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Node_Constant.cs deleted file mode 100755 index 07957c14..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Node_Constant.cs +++ /dev/null @@ -1,57 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Node_Constant : SF_Node { - - - public float constFloat; - public string constStr; - - - - public SFN_Node_Constant() { - } - - public void PrepareConstant(string icon, string constant){ - base.showColor = true; - base.UseLowerPropertyBox( true, true ); - base.showLowerReadonlyValues = true; - base.texture.uniform = true; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - constStr = constant; - constFloat = float.Parse( constant ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1,false) - }; - base.texture.CompCount = 1; - base.texture.dataUniform[0] = constFloat; - node_height = Mathf.RoundToInt( node_height * 0.6666666666f ); - node_width = Mathf.RoundToInt( node_width * 0.6666666666f ); - InitializeDefaultRect( rect.center ); - - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return constStr; - } - - public override float EvalCPU( int c ) { - return constFloat; - } - - public override int GetEvaluatedComponentCount() { - return 1; - } - - /* - public override void DrawLowerPropertyBox() { - GUI.Label( lowerRect, texture.dataUniform[0].ToString(), EditorStyles.textField ); - }*/ - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Node_Constant.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Node_Constant.cs.meta deleted file mode 100755 index a3ef7002..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Node_Constant.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7c4dd42ed9362ff43a8f530348653ef1 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Noise.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Noise.cs deleted file mode 100755 index 13694ec5..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Noise.cs +++ /dev/null @@ -1,87 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Noise : SF_Node { - - public SFN_Noise() { - - } - - public override void Initialize() { - base.Initialize( "Noise" ); - base.UseLowerPropertyBox(false); - base.showColor = true; - base.alwaysDefineVariable = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","Rnd",ConType.cOutput,ValueType.VTv1,false), - SF_NodeConnector.Create(this,"XY","XY",ConType.cInput,ValueType.VTv2,false).SetRequired(false).TypecastTo(2).WithUseCount(3).SetGhostNodeLink(typeof(SFN_TexCoord),"UVOUT") - }; - } - - public override int GetEvaluatedComponentCount (){ - return 1; - } - - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 1 ); - base.OnUpdateNode( updType ); - } - - - - public string Skew() { - return GetVariableName() + "_skew"; - } - - public string Rnd() { - return GetVariableName() + "_rnd"; - } - - public override string[] GetBlitOutputLines() { - return new string[] { - "float2 s = _xy + 0.2127+_xy.x*0.3713*_xy.y;", - "float2 r = 4.789*sin(489.123*s);", - "frac(r.x*r.y*(1+s.x))" - }; - } - - public override string[] GetPreDefineRows (){ - - string p = this["XY"].TryEvaluate(); - string r = Rnd(); - string s = Skew(); - - return new string[]{ - "float2 "+s+" = "+p+" + 0.2127+"+p+".x*0.3713*"+p+".y;", - "float2 "+r+" = 4.789*sin(489.123*("+s+"));" - }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string r = Rnd(); - string s = Skew(); - return "frac("+r+".x*"+r+".y*(1+"+s+".x))"; - } - - public override Vector4 EvalCPU() { - - Vector2 p = GetInputIsConnected( "XY" ) ? GetInputData( "XY" ).dataUniform : Vector4.one; - - float tmp = 0.2127f+p.x*0.3713f*p.y; - Vector2 s = p + new Vector2(tmp,tmp); - - Vector2 r = Vector2.Scale (new Vector2(4.789f,4.789f), new Vector2(Mathf.Sin(489.123f*s.x),Mathf.Sin(489.123f*s.y))); - - return SF_Tools.Frac(r.x*r.y*(1f+s.x)) * Vector4.one; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Noise.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Noise.cs.meta deleted file mode 100644 index 17817a63..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Noise.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e1b0f1ce950794145888c8e0552a1bb0 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalBlend.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalBlend.cs deleted file mode 100755 index e3dd37c2..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalBlend.cs +++ /dev/null @@ -1,101 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_NormalBlend : SF_Node { - - // SF_Node tNode; - - public SFN_NormalBlend() { - - } - - - public override void Initialize() { - base.Initialize( "Normal Blend" ); - base.showColor = true; - UseLowerReadonlyValues( false ); - base.alwaysDefineVariable = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - texture.CompCount = 3; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv3,false), - SF_NodeConnector.Create(this,"BSE","Base",ConType.cInput,ValueType.VTv3,false).SetRequired(true), - SF_NodeConnector.Create(this,"DTL","Det.",ConType.cInput,ValueType.VTv3,false).SetRequired(true) - }; - - //extraWidthInput = 5; - - } - - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - return ( GetInputData( "BSE" ).uniform && GetInputData( "DTL" ).uniform ); - } - - public override int GetEvaluatedComponentCount() { - return 3; - } - - public string BaseNrm() { - return GetVariableName() + "_nrm_base"; - } - public string DetailNrm() { - return GetVariableName() + "_nrm_detail"; - } - public string CombinedNrm() { - return GetVariableName() + "_nrm_combined"; - } - - /* - float3 t = nrmBase + float3(0, 0, 1); - float3 u = nrmDetail * float3(-1, -1, 1); - float3 rnm = t*dot(t, u)/t.z - u; - */ - - public override string[] GetBlitOutputLines() { - return new string[] { - "float3 bse = _bse.xyz + float3(0,0,1);", - "float3 dtl = _dtl.xyz * float3(-1,-1,1);", - "float4(bse*dot(bse, dtl)/bse.z - dtl,0)" - }; - } - - public override string[] GetPreDefineRows() { - return new string[] { - "float3 " + BaseNrm() + " = " + this["BSE"].TryEvaluate() + " + float3(0,0,1);", - "float3 " + DetailNrm() + " = " + this["DTL"].TryEvaluate() + " * float3(-1,-1,1);", - "float3 " + CombinedNrm() + " = " + BaseNrm() + "*dot(" + BaseNrm() + ", " + DetailNrm() + ")/" + BaseNrm() + ".z - " + DetailNrm() + ";" - }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return CombinedNrm(); - } - - public override Vector4 EvalCPU() { - - Vector3 bse = (Vector3)GetInputData( "BSE" ).dataUniform + new Vector3(0,0,1); - Vector3 dtl = Vector3.Scale( (Vector3)GetInputData( "DTL" ).dataUniform, new Vector3(-1,-1,1)); - - Vector3 cmb = bse*Vector3.Dot(bse, dtl)/bse.z - dtl; - - return cmb; - } - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalBlend.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalBlend.cs.meta deleted file mode 100644 index 152c2591..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalBlend.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ed09b5422155445199a1bb8aa27d9d78 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalVector.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalVector.cs deleted file mode 100755 index 2219ea75..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalVector.cs +++ /dev/null @@ -1,78 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_NormalVector : SF_Node { - - - public bool perturbed; - - public SFN_NormalVector() { - - } - - public override void Initialize() { - perturbed = false; - base.Initialize( "Normal Dir.", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( true, true ); - //UpdateIcon(); - base.texture.CompCount = 3; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv3,false) - }; - base.lockedVariableName = true; - } - - public override Vector4 EvalCPU() { - return new Color( 0, 0, 1, 0 ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - if( SF_Evaluator.inVert || SF_Evaluator.inTess ) - return "v.normal"; - return perturbed ? "normalDirection" : "i.normalDir"; - } - /* - public void UpdateIcon() { - if(perturbed){ - texture.LoadDataTexture(this.GetType(), "2"); - } else { - texture.LoadDataTexture(this.GetType()); - } - base.texture.SetIconId( perturbed ? 1 : 0 ); - }*/ - - public override void DrawLowerPropertyBox() { - EditorGUI.BeginChangeCheck(); - Rect r = lowerRect; - r.xMin += 3; - perturbed = EditorGUI.Toggle( r, perturbed ); - r.xMin += 17; - GUI.Label(r,"Perturbed"); - if( EditorGUI.EndChangeCheck() ) { - //UpdateIcon(); - OnUpdateNode(); - } - - } - - public override string SerializeSpecialData() { - return "pt:" + perturbed; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "pt": - perturbed = bool.Parse( value ); - //UpdateIcon(); - break; - } - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalVector.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalVector.cs.meta deleted file mode 100755 index cf258db3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_NormalVector.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 60dad608f3107a142b0f959e8671cf81 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Normalize.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Normalize.cs deleted file mode 100755 index 90a67b0d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Normalize.cs +++ /dev/null @@ -1,44 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Normalize : SF_Node_Arithmetic { - - public SFN_Normalize() { - } - - public override void Initialize() { - base.Initialize( "Normalize" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "normalize(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - /* - public override float NodeOperator( int c ) { - return Mathf.Abs( GetInputData( 1, x, y, c ) ); - }*/ - - public override Vector4 EvalCPU() { - - Vector4 v = GetInputData( "IN" ).dataUniform; - - switch( GetInputData( "IN" ).CompCount ) { - case 1: - float val = Mathf.Sign( v.x ); - return new Vector4( val, val, val, val ); - case 2: - return (Vector4)((Vector2)v).normalized; - case 3: - return (Vector4)( (Vector3)v ).normalized; - default: - return v.normalized; - } - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Normalize.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Normalize.cs.meta deleted file mode 100755 index 5b6d78c9..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Normalize.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: eaaa4d2409678fa4aa98dd05538841e7 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectPosition.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectPosition.cs deleted file mode 100755 index d33922bc..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectPosition.cs +++ /dev/null @@ -1,39 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ObjectPosition : SF_Node { - - - public SFN_ObjectPosition() { - - } - - public override void Initialize() { - base.Initialize( "Object Pos." ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"XYZ","XYZ",ConType.cOutput,ValueType.VTv3,false).Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"X","X",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R).WithColor(Color.red), - SF_NodeConnector.Create(this,"Y","Y",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G).WithColor(Color.green), - SF_NodeConnector.Create(this,"Z","Z",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B).WithColor(Color.blue), - SF_NodeConnector.Create(this,"W","W",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.A) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0f, 0.7071068f, 0.7071068f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "objPos"; // normalize(_WorldSpaceLightPos0.xyz); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectPosition.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectPosition.cs.meta deleted file mode 100755 index f87fead4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectPosition.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 258f9aa8e54fb9646858e46b7fd133dd -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectScale.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectScale.cs deleted file mode 100644 index 172e1255..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectScale.cs +++ /dev/null @@ -1,70 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ObjectScale : SF_Node { - - - public bool reciprocal; - - public SFN_ObjectScale() { - - } - - public override void Initialize() { - base.Initialize( "Object Scale", InitialPreviewRenderMode.BlitQuad ); - base.showColor = true; - base.UseLowerPropertyBox( true, true ); - base.texture.CompCount = 3; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"XYZ","XYZ",ConType.cOutput,ValueType.VTv3,false), - SF_NodeConnector.Create(this,"X","X",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R).WithColor(Color.red), - SF_NodeConnector.Create(this,"Y","Y",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G).WithColor(Color.green), - SF_NodeConnector.Create(this,"Z","Z",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B).WithColor(Color.blue) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 1f, 1f, 1f, 1f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return reciprocal ? "recipObjScale" : "objScale"; - } - - public override string GetBlitShaderSuffix() { - if( reciprocal ) - return "Reciprocal"; - return "Default"; - } - - public override void DrawLowerPropertyBox() { - EditorGUI.BeginChangeCheck(); - Rect r = lowerRect; - r.xMin += 3; - reciprocal = EditorGUI.Toggle( r, reciprocal ); - r.xMin += 17; - GUI.Label( r, "Reciprocal" ); - if( EditorGUI.EndChangeCheck() ) { - OnUpdateNode(); - } - } - - public override string SerializeSpecialData() { - return "rcp:" + reciprocal; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "rcp": - reciprocal = bool.Parse( value ); - break; - } - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectScale.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectScale.cs.meta deleted file mode 100644 index 3d278bf7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ObjectScale.cs.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: cdfee0322d93a3349a5b3cb98e76c9ca -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_OneMinus.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_OneMinus.cs deleted file mode 100755 index e1a3e0de..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_OneMinus.cs +++ /dev/null @@ -1,57 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_OneMinus : SF_Node { - - public SFN_OneMinus() { - - } - - public override void Initialize() { - base.Initialize( "One Minus" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - UseLowerReadonlyValues( true ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"IN","",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1] ); - } - - public override int GetEvaluatedComponentCount() { - return this["IN"].GetCompCount(); - } - - public override bool IsUniformOutput() { - return GetInputData( "IN" ).uniform; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "1.0 - _in" }; - } - - - // New system - public override void RefreshValue() { - RefreshValue( 1, 1 ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "(1.0 - " + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return 1f - GetInputData( "IN", c ); - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_OneMinus.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_OneMinus.cs.meta deleted file mode 100755 index 5e3ca60d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_OneMinus.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 553497763edc19b4a854a3f6c55a2782 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Panner.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Panner.cs deleted file mode 100755 index e65d66bf..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Panner.cs +++ /dev/null @@ -1,161 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Panner : SF_Node { - - // SF_Node tNode; - - - public Vector2 speed = new Vector2(1,1); - - public SFN_Panner() { - - } - - - public override void Initialize() { - base.Initialize( "Panner" ); - base.showColor = true; - base.UseLowerPropertyBox( true, true ); - base.shaderGenMode = ShaderGenerationMode.Modal; - texture.CompCount = 2; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"UVOUT","UV",ConType.cOutput,ValueType.VTv2,false), - SF_NodeConnector.Create(this,"UVIN","UV",ConType.cInput,ValueType.VTv2,false).SetRequired(true)/*.SetGhostNodeLink(typeof(SFN_TexCoord),"UVOUT")*/, - SF_NodeConnector.Create(this,"DIST","Dist",ConType.cInput,ValueType.VTv1,false).SetRequired(false).SetGhostNodeLink(typeof(SFN_Time),"T") - }; - - } - - - public override void DrawLowerPropertyBox() { - //EditorGUI.BeginChangeCheck(); - Rect r = lowerRect; - r.width /= 8; - GUI.Label(r,"U"); - r.x += r.width; - r.width *= 3; - //SF_GUI.EnterableFloatField( this, r, ref speed.x, EditorStyles.textField ); - UndoableEnterableFloatField( r, ref speed.x, "U speed", EditorStyles.textField ); - //speed.x = EditorGUI.FloatField( r, speed.x ); - r.x += r.width; - r.width /= 3; - GUI.Label( r, "V" ); - r.x += r.width; - r.width *= 3; - //SF_GUI.EnterableFloatField( this, r, ref speed.y, EditorStyles.textField ); - UndoableEnterableFloatField( r, ref speed.y, "V speed", EditorStyles.textField ); - //speed.y = EditorGUI.FloatField( r, speed.y ); - - //if( EditorGUI.EndChangeCheck() ) { - // OnUpdateNode(); - //} - - } - - public override string[] ExtraPassedFloatProperties() { - return new string[]{ - "Uspeed", - "Vspeed" - }; - } - - public override string[] GetModalModes() { - return new string[]{ - "REQONLY", - "DIST" - }; - } - - public override string GetCurrentModalMode() { - if( this["DIST"].IsConnectedAndEnabled() ) - return "DIST"; - return "REQONLY"; - } - - public override void PrepareRendering( Material mat ) { - mat.SetFloat( "_uspeed", speed.x ); - mat.SetFloat( "_vspeed", speed.y ); - } - - public override string[] GetBlitOutputLines( string mode ) { - string distStr = mode == "DIST" ? "_dist.x" : "0"; - return new string[]{ - "float4((_uvin.xy+" + distStr + "*float2(_uspeed,_vspeed)),0,0)" - }; - } - - public override void OnUpdateNode( NodeUpdateType updType = NodeUpdateType.Hard, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - if(this["UVIN"].IsConnectedAndEnabled() && this["DIST"].IsConnectedAndEnabled()){ - return ( GetInputData( "UVIN" ).uniform && GetInputData( "DIST" ).uniform ); - } - return false; - } - - public override int GetEvaluatedComponentCount() { - return 2; - } - - public override bool UpdatesOverTime() { - return true; //GetInputIsConnected( "DIST" ); - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string distEval = this["DIST"].TryEvaluate(); - return "(" + GetInputCon( "UVIN" ).Evaluate() + "+" + distEval + "*float2(" + speed.x + "," + speed.y + "))"; - } - - // TODO Expose more out here! - public override Vector4 EvalCPU() { - - Vector2 inputVec = Vector2.one; - - if(GetInputIsConnected("UVIN")){ - inputVec = new Vector2( GetInputData( "UVIN", 0 ), GetInputData( "UVIN", 1 ) ); - } else { - //inputVec = new Vector2( x/((float)SF_Node.NODE_SIZE), y/SF_NodeData.RESf ); // TODO: should use ghost nodes... - } - - - float distance = GetInputIsConnected( "DIST" ) ? GetInputData( "DIST", 0 ) : 0f; - return (Vector4)( inputVec + speed * distance ); - } - - - public override string SerializeSpecialData() { - string s = "spu:" + speed.x + ","; - s += "spv:" + speed.y; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "spu": - float fVal1 = float.Parse( value ); - speed.x = fVal1; - break; - case "spv": - float fVal2 = float.Parse( value ); - speed.y = fVal2; - break; - } - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Panner.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Panner.cs.meta deleted file mode 100755 index 068e4e17..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Panner.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 42c03a582f7865e4ab828b6649d825a8 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Parallax.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Parallax.cs deleted file mode 100755 index 4b49e76d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Parallax.cs +++ /dev/null @@ -1,142 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Parallax : SF_Node { - - // SF_Node tNode; - - public SFN_Parallax() { - - } - - - public override void Initialize() { - base.Initialize( "Parallax" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.ManualModal; - UseLowerReadonlyValues( false ); - texture.CompCount = 2; - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"UVOUT","UV",ConType.cOutput,ValueType.VTv2,false).Outputting(OutChannel.RG), - SF_NodeConnector.Create(this,"UVIN","UV",ConType.cInput,ValueType.VTv2,false).SetGhostNodeLink(typeof(SFN_TexCoord),"UVOUT"), - SF_NodeConnector.Create(this,"HEI","Hei",ConType.cInput,ValueType.VTv1,false).SetRequired(true), - SF_NodeConnector.Create(this,"DEP","Dep",ConType.cInput,ValueType.VTv1,false), - SF_NodeConnector.Create(this,"REF","Ref",ConType.cInput,ValueType.VTv1,false) - }; - - //base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2] ); - } - - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - - public override bool IsUniformOutput() { - return false; - } - - public override int GetEvaluatedComponentCount() { - return 2; - } - - public override string GetCurrentModalMode() { - - - bool uvCon = GetInputIsConnected( "UVIN" ); - bool refCon = GetInputIsConnected( "REF" ); - bool depCon = GetInputIsConnected( "DEP" ); - - if( !uvCon && !refCon && !depCon ) { - return "REQONLY"; - } - - if( uvCon && !refCon && !depCon ) { - return "UV"; - } - - string s = ""; - if( refCon && depCon ) { - s = "DEP_REF"; - } else { - if( refCon ) - s = "REF"; - else - s = "DEP"; - } - - - if( GetInputIsConnected( "UVIN" ) ) { - s = "UV_" + s; - } - - return s; - - } - - public override string[] GetModalModes() { - return new string[] { - "REQONLY", - "DEP", - "REF", - "DEP_REF", - "UV", - "UV_DEP", - "UV_REF", - "UV_DEP_REF", - }; - } - - public override string[] GetBlitOutputLines( string mode ) { - - string uvStr = mode.Contains( "UV" ) ? "_uv.xy" : "i.uv0.xy"; - string depStr = mode.Contains( "DEP" ) ? "_dep.x" : "0.05"; - string refStr = mode.Contains( "REF" ) ? "_ref.x" : "0.5"; - string vDir = "mul(tangentTransform, viewDirection).xy"; - - string line = string.Format( "({0}*({1} - {2})*{3} + {4})", depStr, "_hei", refStr, vDir, uvStr ); - return new string[] { line }; - - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string uv = GetInputIsConnected( "UVIN" ) ? GetInputCon( "UVIN" ).Evaluate() : "i.uv0.xy"; - string hei = GetInputCon( "HEI" ).Evaluate(); - string dep = GetInputIsConnected( "DEP" ) ? GetInputCon( "DEP" ).Evaluate() : "0.05"; - string href = GetInputIsConnected( "REF" ) ? GetInputCon( "REF" ).Evaluate() : "0.5"; - string vDir = "mul(tangentTransform, viewDirection).xy"; - - return "(" + dep + "*(" + hei + " - " + href + ")*" + vDir + " + " + uv + ")"; - } - - // TODO Expose more out here! - public override float EvalCPU( int c ) { - - //return 1f; - - - if( GetInputIsConnected( "UVIN" ) && GetInputIsConnected( "HEI" ) ) { // UV and height connected ? - float hei = GetInputData( "HEI", c ); - float dep = GetInputIsConnected( "DEP" ) ? GetInputData( "DEP", c ) : 0.05f; - float href = GetInputIsConnected( "REF" ) ? GetInputData( "REF", c ) : 0.5f; - return GetInputData( "UVIN", c ) - ( dep * ( hei - href ) ); - } - else - return 0; - //return Lerp( GetInputData( 1, x, y, c ), GetInputData( 2, x, y, c ), GetInputData( 3, x, y, c ) ); - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Parallax.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Parallax.cs.meta deleted file mode 100755 index 72f3a9a4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Parallax.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 45449b9f1a89a1f419300f90e557f9b6 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Phi.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Phi.cs deleted file mode 100755 index b3d72ce5..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Phi.cs +++ /dev/null @@ -1,19 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Phi : SFN_Node_Constant { - - public SFN_Phi() { - } - - public override void Initialize() { - base.Initialize( "Phi" ); - base.PrepareConstant( "const_phi", "1.61803398875" ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Phi.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Phi.cs.meta deleted file mode 100755 index ce3b1229..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Phi.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d74bd6a57e872b440a8754bf05a4e9cc -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Pi.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Pi.cs deleted file mode 100755 index 62b2c7d9..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Pi.cs +++ /dev/null @@ -1,19 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Pi : SFN_Node_Constant { - - public SFN_Pi() { - } - - public override void Initialize() { - base.Initialize( "Pi" ); - base.PrepareConstant( "const_pi", "3.141592654" ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Pi.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Pi.cs.meta deleted file mode 100755 index ed1f98fa..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Pi.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f2b0c407da0b7b8439fdd2e019fed284 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_PixelSize.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_PixelSize.cs deleted file mode 100644 index bb37d554..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_PixelSize.cs +++ /dev/null @@ -1,38 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_PixelSize : SF_Node { - - - public SFN_PixelSize() { - - } - - public override void Initialize() { - base.Initialize( "Pixel Size" ); - base.SearchName = "Pixel Size"; - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 2; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"PXWH","XY",ConType.cOutput,ValueType.VTv2,false).Outputting(OutChannel.RG), - SF_NodeConnector.Create(this,"PXW","X",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R).WithColor(Color.red), - SF_NodeConnector.Create(this,"PXH","Y",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G).WithColor(Color.green) - }; - //base.extraWidthOutput = 12; - } - - public override Vector4 EvalCPU() { - return new Color( 1f/1920f, 1f/1080f, 0f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "float2( _ScreenParams.z-1, _ScreenParams.w-1 )"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_PixelSize.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_PixelSize.cs.meta deleted file mode 100644 index 354ab356..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_PixelSize.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a2079e0d7a4d6dc4daf9b1214f41b8fb -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Posterize.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Posterize.cs deleted file mode 100755 index 6ab846b8..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Posterize.cs +++ /dev/null @@ -1,48 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Posterize : SF_Node_Arithmetic { - - public SFN_Posterize() { - } - - public override void Initialize() { - base.Initialize( "Posterize" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - UseLowerReadonlyValues( true ); - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create( this, "OUT", "", ConType.cOutput, ValueType.VTvPending, false ), - SF_NodeConnector.Create( this, "IN", "", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "STPS", "Steps", ConType.cInput, ValueType.VTv1, false ).SetRequired( true ).WithUseCount(2) - }; - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1]); - base.extraWidthInput = 6; - } - - public override bool IsUniformOutput() { - return ( GetInputData( "IN" ).uniform && GetInputData( "STPS" ).uniform ); - } - - public override string[] GetBlitOutputLines() { - return new string[] { "floor(_in * _stps) / (_stps - 1)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string mainInput = GetConnectorByStringID( "IN" ).TryEvaluate(); - string steps = GetConnectorByStringID( "STPS" ).TryEvaluate(); - - - return "floor(" + mainInput + " * " + steps + ") / (" + steps + " - 1)"; - } - - public override float EvalCPU( int c ) { - float steps = GetInputData( "STPS", c ); - return Mathf.Floor( GetInputData( "IN", c ) * steps ) / (steps - 1); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Posterize.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Posterize.cs.meta deleted file mode 100644 index f244fa48..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Posterize.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ce4916dc08f684bff93ce9a9f0c72f79 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Power.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Power.cs deleted file mode 100755 index 3bd594eb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Power.cs +++ /dev/null @@ -1,56 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Power : SF_Node { - - public SFN_Power() { - - } - - public override void Initialize() { - base.Initialize( "Power" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - UseLowerReadonlyValues( true ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"VAL","Val",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"EXP","Exp",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2] ); - } - - - public override int GetEvaluatedComponentCount() { - return Mathf.Max( this["VAL"].GetCompCount(), this["EXP"].GetCompCount() ); - } - - public override bool IsUniformOutput() { - return ( GetInputData( "VAL" ).uniform && GetInputData( "EXP" ).uniform ); - } - - public override string[] GetBlitOutputLines() { - return new string[] { "pow(_val,_exp)" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "pow(" + GetInputCon( "VAL" ).Evaluate() + "," + GetInputCon( "EXP" ).Evaluate() + ")"; - } - - // New system - public override void RefreshValue() { - RefreshValue( 1, 2 ); - } - - public override float EvalCPU( int c ) { - return Mathf.Pow( GetInputData( "VAL", c ), GetInputData( "EXP", c ) ); - } - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Power.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Power.cs.meta deleted file mode 100755 index c34b5696..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Power.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 186b007e983e194498489dc426592f34 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ProjectionParameters.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ProjectionParameters.cs deleted file mode 100755 index a7e23e59..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ProjectionParameters.cs +++ /dev/null @@ -1,40 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ProjectionParameters : SF_Node { - - - public SFN_ProjectionParameters() { - - } - - public override void Initialize() { - base.Initialize( "Proj. Params" ); - base.SearchName = "Projection Parameters"; - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"SGN","Sign",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"NEAR","Near",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"FAR","Far",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"RFAR","1/Far",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.A) - }; - base.extraWidthOutput = 7; - } - - public override Vector4 EvalCPU() { - return new Color( 0f, 0.7071068f, 0.7071068f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "_ProjectionParams"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ProjectionParameters.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ProjectionParameters.cs.meta deleted file mode 100755 index bd5cac20..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ProjectionParameters.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6725d93fa4d8e5a4eadd259e63cf8914 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reciprocal.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reciprocal.cs deleted file mode 100644 index 92da5d87..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reciprocal.cs +++ /dev/null @@ -1,59 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Reciprocal : SF_Node { - - public SFN_Reciprocal() { - - } - - public override void Initialize() { - base.Initialize( "Reciprocal" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - UseLowerReadonlyValues( true ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"IN","",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1] ); - } - - public override int GetEvaluatedComponentCount() { - return this["IN"].GetCompCount(); - } - - public override bool IsUniformOutput() { - return GetInputData( "IN" ).uniform; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "(1.0 / _in)" }; - } - - // New system - public override void RefreshValue() { - RefreshValue( 1, 1 ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "(1.0 / " + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - float val = GetInputData( "IN", c ); - if(val == 0) - val = float.MaxValue; - return 1f / val; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reciprocal.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reciprocal.cs.meta deleted file mode 100644 index 1e1e4260..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reciprocal.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9f87f5b738b04eb4d8d512131e680f39 -timeCreated: 1436199973 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reflect.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reflect.cs deleted file mode 100755 index 4970a115..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reflect.cs +++ /dev/null @@ -1,34 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Reflect : SF_Node_Arithmetic { - - public SFN_Reflect() { - - } - - public override void Initialize() { - base.Initialize( "Reflect" ); - base.PrepareArithmetic( 2 ); - connectors[1].label = "I"; - connectors[2].label = "N"; - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "reflect(" + GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate() + ")"; - } - - public override Vector4 EvalCPU() { - Color i = GetInputData( "A" ).dataUniform; - Color n = GetInputData( "B" ).dataUniform; - int cc = Mathf.Max(GetInputCon( "A" ).GetCompCount(), GetInputCon( "B" ).GetCompCount()); - float dot = SF_Tools.Dot(i, n, cc); - return i - 2 * n * dot; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reflect.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reflect.cs.meta deleted file mode 100755 index 1f1f2eef..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Reflect.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 133722a37716917478fcc26301e64759 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Relay.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Relay.cs deleted file mode 100755 index 179373ad..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Relay.cs +++ /dev/null @@ -1,69 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Relay : SF_Node_Arithmetic { - - - public SFN_Relay() { - - } - - public override void Initialize() { - node_height = 24; - node_width = 40; - base.Initialize( "Relay" ); - lowerRect.y -= 8; - lowerRect.height = 28; - base.showColor = false; - base.discreteTitle = true; - base.UseLowerPropertyBox( true, true ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - extraWidthInput = -9; - extraWidthOutput = -9; - //base.texture.uniform = true; - //base.texture.CompCount = 1; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"IN","",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1]); - - } - - public override string[] GetBlitOutputLines() { - return new string[] { "_in" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return GetConnectorByStringID( "IN" ).TryEvaluate(); - } - - public override float EvalCPU( int c ) { - return GetInputData( "IN", c ); - } - - - public override void DrawLowerPropertyBox() { - Rect r = new Rect( lowerRect ); - r.yMin += 4; - r.yMax -= 2; - r.xMin += 2; - Rect texCoords = new Rect( r ); - texCoords.width /= 7; - texCoords.height /= 3; - texCoords.x = texCoords.y = 0; - GUI.DrawTextureWithTexCoords( r, SF_GUI.Handle_drag, texCoords, alphaBlend:true ); - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Relay.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Relay.cs.meta deleted file mode 100644 index ca9d5abb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Relay.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7fb81051589734669a06831b008982b6 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRange.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRange.cs deleted file mode 100755 index 818cb0e4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRange.cs +++ /dev/null @@ -1,151 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_RemapRange : SF_Node_Arithmetic { - - // SF_Node tNode; - - [SerializeField] - Vector2 from = new Vector2(0,1); - [SerializeField] - Vector2 to = new Vector2(-1,1); - [SerializeField] - float multiplier = 2f; - float offset = -1f; - - - public SFN_RemapRange() { - - } - - - public override void Initialize() { - base.Initialize( "Remap (Simple)" ); - base.SearchName = "Remap Simple"; - base.showColor = true; - base.UseLowerPropertyBox( true, true ); - base.PrepareArithmetic(1); - base.node_height += 15; - base.shaderGenMode = ShaderGenerationMode.ValuePassing; - UpdateMultOffset(); - - } - - - // n-p*m = x - - public override string[] ExtraPassedFloatProperties() { - return new string[]{ - "Multiplier", - "Offset" - }; - } - - public override void PrepareRendering( Material mat ) { - UpdateMultOffset(); - mat.SetFloat( "_multiplier", multiplier ); - mat.SetFloat( "_offset", offset ); - } - - public override string[] GetBlitOutputLines() { - return new string[]{ - "_in*_multiplier+_offset" - }; - } - - - public override void DrawLowerPropertyBox() { - //EditorGUI.BeginChangeCheck(); - Rect r = lowerRect; - r.height = 15; - r.y += 2; - r.width /= 3; - - Vector2 befFrom = from; - Vector2 befTo = to; - DrawRemapLine(ref r, "From", ref from); - DrawRemapLine(ref r, "To", ref to); - - if( (from != befFrom) || (to != befTo) ){ - UpdateMultOffset(); - } - - - } - - // x = n/p - - public void UpdateMultOffset(){ - float oldRange = from.y - from.x; - float newRange = to.y - to.x; - multiplier = newRange/oldRange; // Might need to warn on division by zero - offset = to.x - from.x * multiplier; - } - - public void DrawRemapLine(ref Rect r, string label, ref Vector2 target){ - GUI.Label(r.PadRight(4),label,SF_Styles.MiniLabelRight); - r = r.MovedRight(); - //SF_GUI.EnterableFloatField( this, r, ref target.x, EditorStyles.textField ); - UndoableEnterableFloatField(r, ref target.x, "lower '" + label.ToLower() + "' value", EditorStyles.textField); - r = r.MovedRight(); - //SF_GUI.EnterableFloatField( this, r, ref target.y, EditorStyles.textField ); - UndoableEnterableFloatField(r, ref target.y, "upper '" + label.ToLower() + "' value", EditorStyles.textField); - r = r.MovedDown().MovedLeft(2); - } - - - public override void OnUpdateNode( NodeUpdateType updType = NodeUpdateType.Hard, bool cascade = true ) { - UpdateMultOffset(); - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string inVal = GetInputCon( "IN" ).Evaluate(); - return "(" + inVal + "*" + multiplier.ToString( "0.0###########" ) + "+" + offset.ToString( "0.0###########" ) + ")"; - } - - // TODO Expose more out here! - public override float EvalCPU( int c ) { - return GetInputData( "IN", c ) * multiplier + offset; - } - - - public override string SerializeSpecialData() { - string s = ""; - s += "frmn:" + from.x + ","; - s += "frmx:" + from.y + ","; - s += "tomn:" + to.x + ","; - s += "tomx:" + to.y; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "frmn": - from.x = float.Parse( value ); - break; - case "frmx": - from.y = float.Parse( value ); - break; - case "tomn": - to.x = float.Parse( value ); - break; - case "tomx": - to.y = float.Parse( value ); - break; - } - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRange.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRange.cs.meta deleted file mode 100644 index f15e85d4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRange.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4dd68e3505e874a599219c31449c75c7 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRangeAdvanced.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRangeAdvanced.cs deleted file mode 100755 index 4731e17f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRangeAdvanced.cs +++ /dev/null @@ -1,94 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_RemapRangeAdvanced : SF_Node_Arithmetic { - - - public SFN_RemapRangeAdvanced() { - - } - - - public override void Initialize() { - base.Initialize( "Remap" ); - base.SearchName = "Remap"; - base.PrepareArithmetic( 5 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - - - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create( this, "OUT", "", ConType.cOutput, ValueType.VTvPending, false ), - SF_NodeConnector.Create( this, "IN", "Val", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "IMIN", "iMin", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "IMAX", "iMax", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "OMIN", "oMin", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "OMAX", "oMax", ConType.cInput, ValueType.VTvPending, false ).SetRequired( true )}; - base.conGroup = ScriptableObject.CreateInstance().Initialize(connectors[0], connectors[1], connectors[2], connectors[3], connectors[4], connectors[5] ); - base.extraWidthInput = 6; - GetConnectorByStringID("IMIN").usageCount = 2; - GetConnectorByStringID("OMIN").usageCount = 2; - - } - - - public override bool IsUniformOutput() { - - if(InputsConnected()){ - return ( GetInputData( "IN" ).uniform && GetInputData( "IMIN" ).uniform && GetInputData( "IMAX" ).uniform && GetInputData( "OMIN" ).uniform && GetInputData( "OMAX" ).uniform ); - } - return true; - - - } - - - - - public override void OnUpdateNode( NodeUpdateType updType = NodeUpdateType.Hard, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - - public override string[] GetBlitOutputLines() { - return new string[] { - "(_omin + ( (_in - _imin) * (_omax - _omin) ) / (_imax - _imin))" - }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string val = GetInputCon( "IN" ).Evaluate(); - string iMin = GetInputCon( "IMIN" ).Evaluate(); - string iMax = GetInputCon( "IMAX" ).Evaluate(); - string oMin = GetInputCon( "OMIN" ).Evaluate(); - string oMax = GetInputCon( "OMAX" ).Evaluate(); - - return "(" + oMin + " + ( (" + val + " - " + iMin + ") * (" + oMax + " - " + oMin + ") ) / (" + iMax + " - " + iMin + "))"; - } - - // TODO Expose more out here! - public override float EvalCPU( int c ) { - float val = GetInputData( "IN", c ); - float iMin = GetInputData( "IMIN", c ); - float iMax = GetInputData( "IMAX", c ); - float oMin = GetInputData( "OMIN", c ); - float oMax = GetInputData( "OMAX", c ); - - return oMin + ( (val - iMin) * (oMax - oMin) ) / (iMax - iMin); - } - - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRangeAdvanced.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRangeAdvanced.cs.meta deleted file mode 100644 index 431d0dc6..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RemapRangeAdvanced.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5a2bcf3599de6412c9ed20eac230ef44 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RgbToHsv.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RgbToHsv.cs deleted file mode 100644 index 2d504028..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RgbToHsv.cs +++ /dev/null @@ -1,130 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_RgbToHsv : SF_Node { - - public SFN_RgbToHsv() { - - } - - public override void Initialize() { - base.Initialize( "RGB to HSV" ); - base.UseLowerPropertyBox(false); - base.showColor = true; - base.alwaysDefineVariable = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"HOUT","Hue",ConType.cOutput,ValueType.VTv1,false), - SF_NodeConnector.Create(this,"SOUT","Sat",ConType.cOutput,ValueType.VTv1,false), - SF_NodeConnector.Create(this,"VOUT","Val",ConType.cOutput,ValueType.VTv1,false), - SF_NodeConnector.Create(this,"IN","",ConType.cInput,ValueType.VTv3,false).SetRequired(true).TypecastTo(3).WithUseCount(3) - }; - - connectors[0].outputChannel = OutChannel.R; - connectors[1].outputChannel = OutChannel.G; - connectors[2].outputChannel = OutChannel.B; - } - - public override int GetEvaluatedComponentCount (){ - return 3; - } - - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 1 ); - base.OnUpdateNode( updType ); - } - - - - public string K() { - return GetVariableName() + "_k"; - } - public string P() { - return GetVariableName() + "_p"; - } - public string Q() { - return GetVariableName() + "_q"; - } - public string D() { - return GetVariableName() + "_d"; - } - public string E() { - return GetVariableName() + "_e"; - } - - - public override string[] GetBlitOutputLines() { - return new string[]{ - "float4 k = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);", - "float4 p = lerp(float4(_in.zy, k.wz), float4(_in.yz, k.xy), step(_in.z, _in.y));", - "float4 q = lerp(float4(p.xyw, _in.x), float4(_in.x, p.yzx), step(p.x, _in.x));", - "float d = q.x - min(q.w, q.y);", - "float e = 1.0e-10;", - "float4(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x, 0);" - }; - } - - - public override string[] GetPreDefineRows (){ - - string c = this["IN"].TryEvaluateAs(4); - string k = K(); - string p = P(); - string q = Q(); - string d = D(); - string e = E(); - - return new string[]{ - "float4 "+k+" = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);", - "float4 "+p+" = lerp(float4("+c+".zy, "+k+".wz), float4("+c+".yz, "+k+".xy), step("+c+".z, "+c+".y));", - "float4 "+q+" = lerp(float4("+p+".xyw, "+c+".x), float4("+c+".x, "+p+".yzx), step("+p+".x, "+c+".x));", - "float "+d+" = "+q+".x - min("+q+".w, "+q+".y);", - "float "+e+" = 1.0e-10;", - }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string q = Q(); - string d = D(); - string e = E(); - return "float3(abs(" + q + ".z + (" + q + ".w - " + q + ".y) / (6.0 * " + d + " + " + e + ")), " + d + " / (" + q + ".x + " + e + "), " + q + ".x);"; - } - - public override Vector4 EvalCPU() { - - if( !GetInputIsConnected( "IN" ) ) - return Color.black; - - - Vector4 c = GetInputData( "IN" ).dataUniform; - Vector4 k = new Vector4( 0, -1f/3f, 2f/3f, -1f ); - Vector4 p = Vector4.Lerp( new Vector4( c.z, c.y, k.w, k.z ), new Vector4( c.y, c.z, k.x, k.y ), Step( c.z, c.y )); - Vector4 q = Vector4.Lerp( new Vector4( p.x, p.y, p.w, c.x ), new Vector4( c.x, p.y, p.z, p.x ), Step( p.x, c.x ) ); - float d = q.x - Mathf.Min(q.w, q.y); - float e = Mathf.Epsilon; - - Vector3 rgb = new Vector3(); - - rgb.x = Mathf.Abs(q.z + (q.w - q.y) / (6f * d + e)); - rgb.y = d / ( q.x + e ); - rgb.z = q.x; - - - return SF_Tools.VectorToColor( rgb ); - } - - public float Step( float a, float b ) { - if( a <= b ) - return 1f; - return 0f; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RgbToHsv.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RgbToHsv.cs.meta deleted file mode 100644 index 0466de18..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_RgbToHsv.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2ba73c676a37ca34da27f7f9c13ae5ed -timeCreated: 1436522064 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Root2.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Root2.cs deleted file mode 100755 index c1d84735..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Root2.cs +++ /dev/null @@ -1,19 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Root2 : SFN_Node_Constant { - - public SFN_Root2() { - } - - public override void Initialize() { - base.Initialize( "Root 2" ); - base.PrepareConstant( "const_root2", "1.41421356237309504" ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Root2.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Root2.cs.meta deleted file mode 100755 index a35bde6a..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Root2.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 478e80eb771ee3e4d8ee8a4fa1bfa141 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Rotator.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Rotator.cs deleted file mode 100755 index d23368bb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Rotator.cs +++ /dev/null @@ -1,179 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Rotator : SF_Node { - - // SF_Node tNode; - - public SFN_Rotator() { - - } - - - public override void Initialize() { - base.Initialize( "Rotator" ); - base.showColor = true; - UseLowerReadonlyValues( false ); - base.alwaysDefineVariable = true; - base.shaderGenMode = ShaderGenerationMode.ManualModal; - texture.CompCount = 2; - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"UVOUT","UV",ConType.cOutput,ValueType.VTv2,false), - SF_NodeConnector.Create(this,"UVIN","UV",ConType.cInput,ValueType.VTv2,false).SetRequired(true), - SF_NodeConnector.Create(this,"PIV","Piv",ConType.cInput,ValueType.VTv2,false,"float2(0.5,0.5)").SetRequired(false), - SF_NodeConnector.Create(this,"ANG","Ang",ConType.cInput,ValueType.VTv1,false).SetRequired(false).SetGhostNodeLink(typeof(SFN_Time),"T"), - SF_NodeConnector.Create(this,"SPD","Spd",ConType.cInput,ValueType.VTv1,false,"1.0").SetRequired(false), - }; - - //base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2] ); - } - - - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - return false; - } - - public override int GetEvaluatedComponentCount() { - return 2; - } - - public string Sin() { - return GetVariableName() + "_sin"; - } - public string Cos() { - return GetVariableName() + "_cos"; - } - public string Spd() { - return GetVariableName() + "_spd"; - } - public string Ang() { - return GetVariableName() + "_ang"; - } - public string Piv() { - return GetVariableName() + "_piv"; - } - public string RotMatrix() { - return "float2x2( " + Cos() + ", -" + Sin() + ", " + Sin() + ", " + Cos() + ")"; - } - - - public override string[] GetModalModes() { - return new string[]{ - "REQONLY", - "PIV", - "SPD", - "ANG", - "PIV_SPD", - "PIV_ANG", - "SPD_ANG", - "PIV_SPD_ANG" - }; - } - - public override string[] GetBlitOutputLines( string mode ) { - - - string pivStr = mode.Contains( "PIV" ) ? "_piv.xy" : "float2(0.5,0.5)"; - string spdStr = mode.Contains( "SPD" ) ? "_spd.x" : "1.0"; - string angStr = mode.Contains( "ANG" ) ? "_ang.x" : "_Time"; - - return new string[] { - "float ang = "+angStr+";", - "float spd = " + spdStr + ";", - "float cosVal = cos("+ spdStr + "*ang);", - "float sinVal = sin("+ spdStr + "*ang);", - "float2 piv = " + pivStr + ";", - "float4((mul(_uvin.xy-piv,float2x2( cosVal, -sinVal, sinVal, cosVal))+piv),0,0)" - }; - } - - public override string GetCurrentModalMode() { - List all = new List(); - if( GetInputIsConnected( "PIV" ) ) - all.Add("PIV"); - if( GetInputIsConnected( "SPD" ) ) - all.Add( "SPD" ); - if( GetInputIsConnected( "ANG" ) ) - all.Add( "ANG" ); - - if( all.Count == 0 ) { - return "REQONLY"; - } - - return string.Join( "_", all.ToArray() ); - } - - - public override string[] GetPreDefineRows() { - return new string[] { - "float " + Ang() + " = " + this["ANG"].TryEvaluate() + ";", - "float " + Spd() + " = " + this["SPD"].TryEvaluate() + ";", - "float " + Cos() + " = cos("+ Spd() + "*" + Ang() + ");", - "float " + Sin() + " = sin("+ Spd() + "*" + Ang() + ");", - "float2 " + Piv() + " = " + this["PIV"].TryEvaluate() + ";" - }; - } - - public override bool UpdatesOverTime() { - return true; //GetInputIsConnected( "ANG" ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "(mul(" + GetInputCon( "UVIN" ).Evaluate() + "-" + Piv() + "," + RotMatrix() + ")+" + Piv() + ")"; - } - - // TODO Expose more out here! - public override Vector4 EvalCPU() { - - //return GetInputData( 1 )[x, y]; - - float angle = connectors[3].IsConnected() ? GetInputData( "ANG", 0 ) : Mathf.PI / 8f; - Vector2 pivot = connectors[2].IsConnected() ? new Vector2( GetInputData( "PIV", 0 ), GetInputData( "PIV", 1 ) ) : new Vector2( 0.5f, 0.5f ); - Vector2 vec = Vector2.one; - - if(GetInputIsConnected("UVIN")){ - vec = new Vector2( GetInputData( "UVIN", 0 ), GetInputData( "UVIN", 1 ) ); - } else { - //vec = new Vector2( x/SF_NodeData.RESf, y/SF_NodeData.RESf ); // TODO: should use ghost nodes... - } - vec -= pivot; - - - float cos = Mathf.Cos( angle ); - float sin = Mathf.Sin( angle ); - - Vector4 mtx = new Vector4( - cos, -sin, - sin, cos - ); - - - Vector2 retVec = new Vector2( - mtx.x * vec.x + mtx.y * vec.y, - mtx.z * vec.x + mtx.w * vec.y - ); - - retVec += pivot; - - return new Color( retVec.x, retVec.y, 0f, 0f );//Lerp( GetInputData( 1, x, y, c ), GetInputData( 2, x, y, c ), GetInputData( 3, x, y, c ) ); - } - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Rotator.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Rotator.cs.meta deleted file mode 100755 index 32546de8..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Rotator.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b18d65c11cc5afe449017a80a6ea966e -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Round.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Round.cs deleted file mode 100755 index ec39a767..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Round.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Round : SF_Node_Arithmetic { - - public SFN_Round() { - } - - public override void Initialize() { - base.Initialize( "Round" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "round(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Round( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Round.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Round.cs.meta deleted file mode 100755 index afebb05b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Round.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5965b04db15c4d243b3a4d5ea44c2e4c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneColor.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneColor.cs deleted file mode 100755 index 0b6ad777..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneColor.cs +++ /dev/null @@ -1,51 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_SceneColor : SF_Node { - - - public SFN_SceneColor() { - - } - - public override void Initialize() { - base.Initialize( "Scene Color" ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"UVIN","UV",ConType.cInput,ValueType.VTv2), - SF_NodeConnector.Create(this,"RGB","RGB",ConType.cOutput,ValueType.VTv3) .Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"R","R",ConType.cOutput, ValueType.VTv1) .WithColor(Color.red) .Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"G","G",ConType.cOutput,ValueType.VTv1) .WithColor(Color.green) .Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"B","B",ConType.cOutput,ValueType.VTv1) .WithColor(Color.blue) .Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"A","A",ConType.cOutput,ValueType.VTv1) .Outputting(OutChannel.A) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0.3f, 0.6f, 0.3f, 1f ); - } - - public bool AutoUV(){ - return !GetInputIsConnected( "UVIN" ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string UV = ""; - - if(AutoUV()){ - return "sceneColor"; - } else { - UV = GetInputCon( "UVIN" ).Evaluate(); - return "tex2D( "+editor.ps.catBlending.GetGrabTextureName()+", " + UV + ")"; - } - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneColor.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneColor.cs.meta deleted file mode 100755 index 090a6b35..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneColor.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d6a693eff9dba4958966e3afe0905bbb -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneDepth.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneDepth.cs deleted file mode 100755 index 1d2815f2..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneDepth.cs +++ /dev/null @@ -1,40 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_SceneDepth : SF_Node { - - - public SFN_SceneDepth() { - - } - - public override void Initialize() { - base.Initialize( "Scene Depth" ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 1; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1), - SF_NodeConnector.Create(this,"UV","UV",ConType.cInput,ValueType.VTv2) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0.3f, 0.6f, 0.3f, 1f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - string infix = ""; - if( GetConnectorByStringID( "UV" ).IsConnectedAndEnabled() ) - infix = GetConnectorByStringID( "UV" ).TryEvaluate(); - else - infix = "sceneUVs"; - return "max(0, LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, " + infix + ")) - _ProjectionParams.g)"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneDepth.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneDepth.cs.meta deleted file mode 100644 index 7df9f496..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SceneDepth.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 48380218bb14f4f9fbc3764914c2ffb1 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenParameters.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenParameters.cs deleted file mode 100755 index 9be57a9c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenParameters.cs +++ /dev/null @@ -1,40 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ScreenParameters : SF_Node { - - - public SFN_ScreenParameters() { - - } - - public override void Initialize() { - base.Initialize( "Scrn. Params" ); - base.SearchName = "Screen Parameters"; - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"PXW","pxW",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"PXH","pxH",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"RCW","1+1/W",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"RCH","1+1/H",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.A) - }; - base.extraWidthOutput = 12; - } - - public override Vector4 EvalCPU() { - return new Color( 0f, 0.7071068f, 0.7071068f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "_ScreenParams"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenParameters.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenParameters.cs.meta deleted file mode 100755 index bfd5c66d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenParameters.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8ffce1d1cbd31b6438a435cfbc89f838 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenPos.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenPos.cs deleted file mode 100755 index 9b645c92..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenPos.cs +++ /dev/null @@ -1,83 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ScreenPos : SF_Node { - - - public enum ScreenPosType { Normalized = 0, Tiled = 1, SceneUVs = 2 }; - public ScreenPosType currentType = ScreenPosType.Normalized; - - public SFN_ScreenPos() { - - } - - public override void Initialize() { - base.Initialize( "Screen Pos.", InitialPreviewRenderMode.BlitQuad ); - base.showColor = true; - base.UseLowerPropertyBox( true, true ); - UpdateIcon(); - base.texture.CompCount = 2; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"UVOUT","UV",ConType.cOutput,ValueType.VTv2,false).Outputting(OutChannel.RG), - SF_NodeConnector.Create(this,"U","U",ConType.cOutput,ValueType.VTv1).WithColor(Color.red).Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"V","V",ConType.cOutput,ValueType.VTv1).WithColor(Color.green).Outputting(OutChannel.G) - }; - } - - public void UpdateIcon() { - base.texture.SetIconId( (int)currentType ); - } - - /* - public override Vector4 NodeOperator() { - return new Color( Screen.width - base.rect.x + x * 0.66666f, Screen.height - base.rect.y + y * 0.66666f, 0, 0 ); - } - */ - - public override void DrawLowerPropertyBox() { - GUI.color = Color.white; - EditorGUI.BeginChangeCheck(); - //currentType = (ScreenPosType)EditorGUI.EnumPopup( lowerRect, currentType ); - currentType = (ScreenPosType)UndoableEnumPopup(lowerRect, currentType, "switch screen position type"); - if( EditorGUI.EndChangeCheck() ) { - UpdateIcon(); - OnUpdateNode(); - } - - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - // NeedSceneUVs() - switch(currentType){ - case ScreenPosType.Normalized: - return "(sceneUVs * 2 - 1)"; - case ScreenPosType.Tiled: - return "float2((sceneUVs.x * 2 - 1)*(_ScreenParams.r/_ScreenParams.g), sceneUVs.y * 2 - 1)"; - case ScreenPosType.SceneUVs: - return "sceneUVs"; - } - Debug.LogError("Invalid screen position category"); - return ""; - } - - public override string SerializeSpecialData() { - return "sctp:" + (int)currentType; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "sctp": - currentType = (ScreenPosType)int.Parse( value ); - UpdateIcon(); - break; - } - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenPos.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenPos.cs.meta deleted file mode 100755 index 12a5db77..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ScreenPos.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6c8f79b55a93b5645bea8d939b688ef1 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Set.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Set.cs deleted file mode 100644 index 77f35004..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Set.cs +++ /dev/null @@ -1,83 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Set : SF_Node_Arithmetic { - - public SFN_Set() { - - } - - public override void Initialize() { - node_height = 20; - node_width = 120; - base.Initialize( "Set" ); - lowerRect.y -= 8; - lowerRect.height = 28; - base.showColor = false; - base.discreteTitle = true; - base.alwaysDefineVariable = true; - base.UseLowerPropertyBox( true, true ); - base.lockedVariableName = false; // In order for it to serialize - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - extraWidthInput = -9; - extraWidthOutput = -9; - //base.texture.uniform = true; - //base.texture.CompCount = 1; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"IN","",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - }; - - connectors[0].enableState = EnableState.Hidden; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1]); - - editor.nodeView.RefreshRelaySources(); - } - - public override bool CanCustomizeVariable() { - return false; // Never allow using the dropdown varname editor - } - - public override string[] GetBlitOutputLines() { - return new string[] { "_in" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return GetConnectorByStringID( "IN" ).TryEvaluate(); - } - - public override float EvalCPU( int c ) { - return GetInputData( "IN", c ); - } - - - public override void DrawLowerPropertyBox() { - Rect r = new Rect( lowerRect ); - r.yMin += 4; - r.yMax -= 2; - r.xMin += 2; - Rect[] splitRects = r.SplitHorizontal( 0.75f, 2 ); - EditorGUI.BeginChangeCheck(); - variableName = UndoableTextField( splitRects[0], variableName, "Set variable name", null ); - if( EditorGUI.EndChangeCheck() ) { - editor.nodeView.RefreshRelaySources(); - } - Rect texCoords = new Rect( splitRects[1] ); - texCoords.width /= 7; - texCoords.height /= 3; - texCoords.x = texCoords.y = 0; - GUI.DrawTextureWithTexCoords( splitRects[1], SF_GUI.Handle_drag, texCoords, alphaBlend: true ); - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Set.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Set.cs.meta deleted file mode 100644 index 42d72ead..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Set.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 962662ba043415346a05959ced04f0f4 -timeCreated: 1447436935 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sign.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sign.cs deleted file mode 100755 index 196c0293..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sign.cs +++ /dev/null @@ -1,29 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Sign : SF_Node_Arithmetic { - - public SFN_Sign() { - } - - public override void Initialize() { - base.Initialize( "Sign" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "sign(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - float v = GetInputData( "IN", c ); - if( v == 0 ) - return 0f; - return v > 0f ? 1f : -1f; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sign.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sign.cs.meta deleted file mode 100755 index f10e81cf..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sign.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 23a3e4987bfdf3944b39de15059fd63e -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sin.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sin.cs deleted file mode 100755 index 713b40c3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sin.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Sin : SF_Node_Arithmetic { - - public SFN_Sin() { - } - - public override void Initialize() { - base.Initialize( "Sin" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "sin(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Sin( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sin.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sin.cs.meta deleted file mode 100755 index 02e6793c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sin.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7fafe81ac61f44348b70f30fd8959cab -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Slider.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Slider.cs deleted file mode 100755 index 3fc64f4c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Slider.cs +++ /dev/null @@ -1,170 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Slider : SF_Node { - - - public float min = 0.0f; - public float max = 1.0f; - public float current = 0.0f; - - GUIStyle centerFloatField; - //GUIStyle centerFloatFieldDark; - - public SFN_Slider() { - - } - - public override void Initialize() { - node_width = 256; - node_height = 58; - base.Initialize( "Slider" ); - base.showColor = false; - base.neverDefineVariable = true; - base.UseLowerPropertyBox( false ); - base.texture.uniform = true; - base.texture.CompCount = 1; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - property = ScriptableObject.CreateInstance().Initialize( this ); - - centerFloatField = new GUIStyle( EditorStyles.numberField ); - centerFloatField.alignment = TextAnchor.MiddleCenter; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1,false) - }; - } - - /*public override bool IsUniformOutput() { - return true; - }*/ - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return property.GetVariable(); - } - - public override float EvalCPU( int c ) { - return current; - } - - public override bool IsUniformOutput() { - return true; - } - - - public override void NeatWindow( ) { - PrepareWindowColor(); - int labelWidth = 28; - int sliderWidth = (int)( rectInner.width - 4 * labelWidth ); - GUI.BeginGroup( rect ); - Rect r = new Rect( rectInner ); - r.height = 16; - // r.width = labelWidth*3; - // Upper: - //float normSlider = Mathf.InverseLerp( min, max, current ); - //r.x = normSlider * sliderWidth + 0.5f * labelWidth; - - bool inverse = min > max; - - float prevValue = current; - - Rect valRect = r; - //float t = (current/max); - valRect.xMin += 80;//+134*t; - valRect.xMax -= 80;//+134*(1-t); - if(inverse){ - current = Mathf.Clamp( EditorGUI.FloatField( valRect, current, centerFloatField ), max, min ); - } else { - current = Mathf.Clamp( EditorGUI.FloatField( valRect, current, centerFloatField ), min, max ); - } - - // Lower: - r.y += r.height + 4; - r.x = rectInner.x; - r.width = labelWidth; - - GUI.Label( r, "Min" ); - r.x += r.width; - //min = EditorGUI.FloatField( r, min, centerFloatField ); - min = UndoableFloatField(r, min, "slider min value", centerFloatField); - r.x += r.width; - r.width = sliderWidth; - float beforeSlider = current; - - string sliderName = "slider" + this.id; - GUI.SetNextControlName( sliderName ); - //current = GUI.HorizontalSlider( r, current, min, max ); - - Rect sliderRect = r; - - sliderRect.xMax -= 8; - sliderRect.xMin += 8; - - if(inverse){ - current = (min+max) - UndoableHorizontalSlider(sliderRect, (min+max) - current, max, min, "value" ); - } else { - current = UndoableHorizontalSlider(sliderRect, current, min, max, "value" ); - } - - - if( beforeSlider != current ) - GUI.FocusControl( sliderName ); - r.x += r.width; - r.width = labelWidth; - //max = EditorGUI.FloatField( r, max, centerFloatField ); - max = UndoableFloatField(r, max, "slider max value", centerFloatField); - r.x += r.width; - GUI.Label( r, "Max" ); - - // sliderRect.x += labelWidth; - // sliderRect.width -= labelWidth * 2; - - if( prevValue != current ){ - OnValueChanged(); - } - GUI.EndGroup(); - ResetWindowColor(); - //GUI.DragWindow(); - } - - // TODO: Refresh node thumbs - public void OnValueChanged() { - texture.dataUniform = current * Vector4.one; - editor.shaderEvaluator.ApplyProperty( this ); - OnUpdateNode( NodeUpdateType.Soft ); - } - - - public override string SerializeSpecialData() { - string s = property.Serialize() + ","; - s += "min:" + min + ","; - s += "cur:" + current + ","; - s += "max:" + max; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize( key, value ); - switch( key ) { - case "min": - min = float.Parse( value ); - break; - case "cur": - current = float.Parse( value ); - OnValueChanged(); - break; - case "max": - max = float.Parse( value ); - break; - } - } - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Slider.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Slider.cs.meta deleted file mode 100755 index c17303fb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Slider.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9987079b02539a14288441b9a1078362 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Smoothstep.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Smoothstep.cs deleted file mode 100644 index becac226..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Smoothstep.cs +++ /dev/null @@ -1,64 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Smoothstep : SF_Node_Arithmetic { - - public SFN_Smoothstep() { - } - - public override void Initialize() { - base.Initialize( "Smoothstep" ); - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - UseLowerReadonlyValues( true ); - - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","T",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"A","Min",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","Max",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"V","Val",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2], connectors[3] ); - } - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - return ( GetInputData( "A" ).uniform && GetInputData( "B" ).uniform && GetInputData( "V" ).uniform ); - } - - public override int GetEvaluatedComponentCount() { - return Mathf.Max( this["A"].GetCompCount(), this["B"].GetCompCount(), this["V"].GetCompCount() ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string a = GetConnectorByStringID( "A" ).TryEvaluateAs( GetEvaluatedComponentCount() ); - string b = GetConnectorByStringID( "B" ).TryEvaluateAs( GetEvaluatedComponentCount() ); - string v = GetConnectorByStringID( "V" ).TryEvaluateAs( GetEvaluatedComponentCount() ); - - return string.Format( "smoothstep( {0}, {1}, {2} )", a, b, v ); - } - - public override float EvalCPU( int c ) { - - float a = GetInputData( "A", c ); - float b = GetInputData( "B", c ); - float v = GetInputData( "V", c ); - - if( ( b - a ) == 0f ) - return 0; - float t = Mathf.Clamp01(( v - a ) / ( b - a )); - return t * t * ( 3.0f - ( 2.0f * t ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Smoothstep.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Smoothstep.cs.meta deleted file mode 100644 index 90b4730c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Smoothstep.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 289a8fc8292655944a478a667b333850 -timeCreated: 1443603669 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sqrt.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sqrt.cs deleted file mode 100755 index 501aeaab..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sqrt.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Sqrt : SF_Node_Arithmetic { - - public SFN_Sqrt() { - } - - public override void Initialize() { - base.Initialize( "Sqrt" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "sqrt(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Sqrt( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sqrt.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sqrt.cs.meta deleted file mode 100755 index a1e1f626..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Sqrt.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c77bd2f2aab8059488ee83b49ccad0ca -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_StaticBranch.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_StaticBranch.cs deleted file mode 100755 index 688d14e1..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_StaticBranch.cs +++ /dev/null @@ -1,80 +0,0 @@ -using UnityEngine; -using UnityEditor; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_StaticBranch : SF_Node_Arithmetic { - - public bool on = false; - - public SFN_StaticBranch() { - } - - public override void Initialize() { - base.Initialize( "Static Branch" ); - base.PrepareArithmetic(2); - base.showLowerReadonlyValues = false; - base.alwaysDefineVariable = true; - base.onlyPreDefine = true; - base.showLowerPropertyBox = true; - base.showLowerPropertyBoxAlways = true; - base.property = ScriptableObject.CreateInstance().Initialize( this ); - } - - - public override void DrawLowerPropertyBox() { - EditorGUI.BeginChangeCheck(); - Rect r = lowerRect; - r.xMin += 3; - on = EditorGUI.Toggle( r, on ); - r.xMin += 17; - GUI.Label(r,"On"); - if( EditorGUI.EndChangeCheck() ) { - OnUpdateNode(); - editor.shaderEvaluator.ApplyProperty( this ); - } - - } - - public override string[] GetPreDefineRows() { - string indent = " "; - string[] rows = new string[]{ - "#ifdef STATIC_BRANCH", - indent+"float" + GetEvaluatedComponentCount() + " " + GetVariableName() + " = " + this["B"].TryEvaluate() + ";", - "#else", - indent+"float" + GetEvaluatedComponentCount() + " " + GetVariableName() + " = " + this["A"].TryEvaluate() + ";", - "#endif" - }; - varDefined = true; // Hack - return rows; - - } - - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - if(!ShouldDefineVariable()) // TODO: Isn't this already handled on the node level? - this.PreDefine(); - - return GetVariableName(); - } - - public override float EvalCPU( int c ) { - return on ? GetInputData( "B", c ) : GetInputData( "B", c ); - } - - public override string SerializeSpecialData() { - return "on:" + on; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "on": - on = bool.Parse( value ); - editor.shaderEvaluator.ApplyProperty( this ); - break; - } - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_StaticBranch.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_StaticBranch.cs.meta deleted file mode 100644 index 133134d4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_StaticBranch.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7139eb5003a7146d1a075fa9811fc5c0 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Step.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Step.cs deleted file mode 100755 index 9a8f8797..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Step.cs +++ /dev/null @@ -1,31 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Step : SF_Node_Arithmetic { - - public SFN_Step() { - } - - public override void Initialize() { - base.Initialize( "Step (A <= B)" ); - base.SearchName = "Step"; - base.PrepareArithmetic(2); - base.showLowerReadonlyValues = false; - base.connectors[0].label = "<="; - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "step(" + GetConnectorByStringID( "A" ).TryEvaluate() + "," + GetConnectorByStringID( "B" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - float a = GetInputData( "B", c ); - float b = GetInputData( "B", c ); - return ((a <= b) ? 1.0f : 0.0f); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Step.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Step.cs.meta deleted file mode 100755 index 4f7e7d51..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Step.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 040227aa4fb888540b24aabbda43bf84 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Subtract.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Subtract.cs deleted file mode 100755 index 3d782807..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Subtract.cs +++ /dev/null @@ -1,31 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Subtract : SF_Node_Arithmetic { - - public SFN_Subtract() { - - } - - public override void Initialize() { - base.Initialize( "Subtract" ); - base.PrepareArithmetic(); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - } - - public override string[] GetBlitOutputLines() { - return new string[] { "_a - _b" }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "(" + GetConnectorByStringID( "A" ).TryEvaluate() + "-" + GetConnectorByStringID( "B" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return GetInputData( "A", c ) - GetInputData( "B", c ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Subtract.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Subtract.cs.meta deleted file mode 100755 index 1a777d66..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Subtract.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f800be44f0a6bcb4db234f16ffbb3c4c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SwitchProperty.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SwitchProperty.cs deleted file mode 100755 index 3623a7eb..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SwitchProperty.cs +++ /dev/null @@ -1,161 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_SwitchProperty : SF_Node_Arithmetic { - - public SFN_SwitchProperty() { - - } - - [SerializeField] - public bool on = false; - - public override void Initialize() { - - base.Initialize( "Switch" ); - base.node_height -= 20; - //base.lowerRect.height += 4; - base.showColor = true; - base.shaderGenMode = ShaderGenerationMode.ValuePassing; - - base.UseLowerPropertyBox( true, true ); - - - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTvPending,false), - SF_NodeConnector.Create(this,"A","Off",ConType.cInput,ValueType.VTvPending,false).SetRequired(true), - SF_NodeConnector.Create(this,"B","On",ConType.cInput,ValueType.VTvPending,false).SetRequired(true) - }; - - property = ScriptableObject.CreateInstance().Initialize( this ); - - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2]); - - } - - float smoothConnectorHeight = 23; - float targetConnectorHeight = 23; - Color conLineBg = Color.black; - Color conLineFg = Color.white; - // Color conLineBgTrns = new Color(0f,0f,0f,0.3f); - // Color conLineFgTrns = new Color(1f,1f,1f,0.3f); - - public override string[] ExtraPassedFloatProperties(){ - return new string[] { "On" }; - } - - public override void PrepareRendering( Material mat ) { - mat.SetFloat( "_on", on ? 1.0f : 0.0f ); - } - - public override string[] GetBlitOutputLines() { - return new string[] { "lerp(_a,_b,_on)" }; - } - - - public override void DrawLowerPropertyBox() { - EditorGUI.BeginChangeCheck(); - Rect r = lowerRect; - r.height = 24; - r.width = 26; - r.y -= 26; - - if(Event.current.type == EventType.repaint){ - smoothConnectorHeight = Mathf.Lerp(smoothConnectorHeight, targetConnectorHeight, 0.6f); - } - - r = r.PadTop(1).PadBottom(1).PadLeft(2); - - r.width = r.height + 2; - //r.xMin += 3; - - //Handles.BeginGUI(rect); - - bool hovering = rect.Contains(Event.current.mousePosition + rect.TopLeft()); - - - - if(hovering){ - targetConnectorHeight = on ? 43 : 23; - Vector2 p0 = new Vector2(rect.width,23); - Vector2 p1 = new Vector2(0, smoothConnectorHeight); - GUILines.QuickBezier( p0, p1, conLineBg, 12, 5 ); - GUILines.QuickBezier( p0, p1, conLineFg, 12, 3 ); - GUILines.QuickBezier( p0, p1, conLineFg, 12, 3 ); - bool prevVal = on; - GUI.color = new Color(SF_Node.colorExposed.r,SF_Node.colorExposed.g,SF_Node.colorExposed.b,GUI.color.a); - bool newVal = GUI.Button(r,string.Empty) ? !prevVal : prevVal; - - if(newVal){ - Rect chkRect = r; - chkRect.width = SF_GUI.Toggle_check_icon.width; - chkRect.height = SF_GUI.Toggle_check_icon.height; - chkRect.x += (r.width-chkRect.width)*0.5f; - chkRect.y += 2; - GUI.DrawTexture(chkRect,SF_GUI.Toggle_check_icon); - } - - GUI.color = Color.white; - - if(prevVal != newVal){ - string dir = on ? "on" : "off"; - UndoRecord("switch " + dir + " " + property.nameDisplay); - on = newVal; - OnUpdateNode(NodeUpdateType.Soft, true); - editor.shaderEvaluator.ApplyProperty( this ); - } - } - - - //GUILines.DrawMultiBezierConnection(editor,,GetEvaluatedComponentCount(),Color.white); - - //Handles.DrawLine(new Vector3(0,0),new Vector3(32,32)); - // - //Handles.EndGUI(); - - - - - - //GUI.enabled = true; - - - - - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "lerp( " + GetConnectorByStringID( "A" ).TryEvaluate() + ", " + GetConnectorByStringID( "B" ).TryEvaluate() + ", "+ property.GetVariable() + " )"; - } - - public override float EvalCPU( int c ) { - if(on){ - return GetInputData("B", c); - } else { - return GetInputData("A", c); - } - } - - - public override string SerializeSpecialData() { - string s = property.Serialize() + ","; - s += "on:" + on; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize( key, value ); - switch( key ) { - case "on": - on = bool.Parse( value ); - break; - } - } - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SwitchProperty.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SwitchProperty.cs.meta deleted file mode 100644 index cbcde250..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_SwitchProperty.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2975b0d64d9d5418bb473f40734754c9 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tan.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tan.cs deleted file mode 100755 index 65695d80..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tan.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Tan : SF_Node_Arithmetic { - - public SFN_Tan() { - } - - public override void Initialize() { - base.Initialize( "Tan" ); - base.PrepareArithmetic( 1 ); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "tan(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - return Mathf.Tan( GetInputData( "IN", c ) ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tan.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tan.cs.meta deleted file mode 100755 index aa772307..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tan.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 194e3cc730febb44196573c2fd1a4ff8 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tangent.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tangent.cs deleted file mode 100755 index 0694adf2..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tangent.cs +++ /dev/null @@ -1,35 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Tangent : SF_Node { - - - public SFN_Tangent() { - - } - - public override void Initialize() { - base.Initialize( "Tangent Dir.", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 3; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv3,false) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 1f, 0f, 0f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return SF_Evaluator.WithProgramPrefix("tangentDir"); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tangent.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tangent.cs.meta deleted file mode 100755 index a3772158..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tangent.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 139600edd90131c43842df0965b82082 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tau.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tau.cs deleted file mode 100755 index 19742d72..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tau.cs +++ /dev/null @@ -1,19 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Tau : SFN_Node_Constant { - - public SFN_Tau() { - } - - public override void Initialize() { - base.Initialize( "Tau"); - base.PrepareConstant( "const_tau", "6.28318530718" ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tau.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tau.cs.meta deleted file mode 100755 index 30c4d425..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tau.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 62750aaecd1cee044b767f00ed0605bf -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2d.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2d.cs deleted file mode 100755 index 68b4bd08..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2d.cs +++ /dev/null @@ -1,488 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - - - - -namespace ShaderForge { - - - public enum NoTexValue{White, Gray, Black, Bump}; - - [System.Serializable] - public class SFN_Tex2d : SF_Node { - - - public Texture textureAsset; - - public Texture TextureAsset { - get { - if(TexAssetConnected()){ - textureAsset = null; - return ( GetInputCon( "TEX" ).node as SFN_Tex2dAsset ).textureAsset; - } - return textureAsset; - } - set { - textureAsset = value; - } - } - - //public bool unpackNormal = false; - public NoTexValue noTexValue = NoTexValue.White; - public bool markedAsNormalMap = false; - - public SF_ShaderProperty shelvedProperty; - - - public SFN_Tex2d() { - - } - - public override void Initialize() { - base.Initialize( "Texture 2D" ); - //node_height = (int)(rect.height - 6f); // Odd, but alright... - base.UseLowerPropertyBox( true, true ); - - - property = ScriptableObject.CreateInstance().Initialize( this ); - - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"UVIN","UV",ConType.cInput,ValueType.VTv2).SetGhostNodeLink(typeof(SFN_TexCoord),"UVOUT"), - SF_NodeConnector.Create(this,"MIP","MIP",ConType.cInput,ValueType.VTv1), - SF_NodeConnector.Create(this,"TEX","Tex",ConType.cInput,ValueType.TexAsset).WithColor(SF_Node.colorExposed), - SF_NodeConnector.Create(this,"RGB","RGB",ConType.cOutput,ValueType.VTv3) .Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"R","R",ConType.cOutput, ValueType.VTv1) .WithColor(Color.red) .Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"G","G",ConType.cOutput,ValueType.VTv1) .WithColor(Color.green) .Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"B","B",ConType.cOutput,ValueType.VTv1) .WithColor(Color.blue) .Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"A","A",ConType.cOutput,ValueType.VTv1) .Outputting(OutChannel.A) - }; - base.alwaysDefineVariable = true; - base.neverDefineVariable = false; - base.texture.CompCount = 4; - connectors[0].usageCount = 2; // To define a variable of UVs to use with TRANSFORM_TEX - - } - - public override bool IsUniformOutput() { - return false; - } - - public bool IsNormalMap() { - - /* - if( textureAsset != null ) { - string path = AssetDatabase.GetAssetPath( textureAsset ); - if( string.IsNullOrEmpty( path ) ) - return false; - else - return ( (TextureImporter)UnityEditor.AssetImporter.GetAtPath( path ) ).normalmap; - } - - - if( property == null ) { - if( GetInputIsConnected( "TEX" ) ) - return ( GetInputCon( "TEX" ).node as SFN_Tex2d ).IsNormalMap(); - } else { - return ( property as SFP_Tex2d ).isBumpmap; - }*/ - // TODO: Is this right?¨ - - if(TexAssetConnected()) - return ( GetInputCon( "TEX" ).node as SFN_Tex2dAsset ).IsNormalMap(); - return markedAsNormalMap; - } - - - public bool TexAssetConnected(){ - if( property == null ) - if( GetInputIsConnected( "TEX" ) ) - return true; - return false; - } - - - public override string GetBlitShaderSuffix() { - - bool uv = GetInputIsConnected( "UVIN" ); - bool mip = GetInputIsConnected( "MIP" ); - - if( uv && mip ) { - return "UV_MIP"; - } else if( mip ) { - return "MIP"; - } else if( uv ){ - return "UV"; - } else { - return "NoInputs"; - } - - } - - public override void PrepareRendering( Material mat ) { - if( textureAsset != null ) { - mat.mainTexture = textureAsset; - mat.SetFloat( "_IsNormal", IsNormalMap() ? 1 : 0 ); - } - } - - - - public override void DrawLowerPropertyBox() { - GUI.color = Color.white; - EditorGUI.BeginChangeCheck(); - Rect tmp = lowerRect; - tmp.height = 16f; - noTexValue = (NoTexValue)UndoableLabeledEnumPopup(tmp, "Default", noTexValue, "swith default color of " + property.nameDisplay ); - tmp.y += tmp.height; - bool preMarked = markedAsNormalMap; - - - UndoableToggle(tmp, ref markedAsNormalMap, "Normal map", "normal map decode of " + property.nameDisplay, null); - //markedAsNormalMap = GUI.Toggle(tmp, markedAsNormalMap, "Normal map" ); - - if(EditorGUI.EndChangeCheck()){ - if(markedAsNormalMap && !preMarked) - noTexValue = NoTexValue.Bump; - UpdateCompCount(); - UpdateNormalMapAlphaState(); - OnUpdateNode(); - } - } - - public void UpdateNormalMapAlphaState(){ - if(markedAsNormalMap){ - GetConnectorByStringID("A").Disconnect(); - GetConnectorByStringID("A").enableState = EnableState.Hidden; - } else { - GetConnectorByStringID("A").enableState = EnableState.Enabled; // No alpha channel when unpacking normals - } - } - - public override int GetEvaluatedComponentCount() { - if( IsNormalMap() ) - return 3; - return 4; - } - - public bool HasAlpha() { - if( TextureAsset == null ) return false; - string path = AssetDatabase.GetAssetPath( TextureAsset ); - if( string.IsNullOrEmpty( path ) ) return false; - return ( (TextureImporter)UnityEditor.AssetImporter.GetAtPath( path ) ).DoesSourceTextureHaveAlpha(); - } - - private void UpdateCompCount(){ - texture.CompCount = IsNormalMap() ? 3 : 4; // TODO: This doesn't work when opening shaders. Why? - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - - UpdateCompCount(); - - if( varDefined ) - return GetVariableName(); - - - bool useLOD = GetInputIsConnected( "MIP" ) || ( SF_Evaluator.inVert || SF_Evaluator.inTess ); - string uvStr = GetInputIsConnected( "UVIN" ) ? GetInputCon( "UVIN" ).Evaluate() : SF_Evaluator.WithProgramPrefix( SF_Evaluator.inFrag ? "uv0" : "texcoord0" ); - string func = useLOD ? "tex2Dlod" : "tex2D"; - string mip = GetInputIsConnected( "MIP" ) ? GetInputCon( "MIP" ).Evaluate() : "0"; - - string variableName = this["TEX"].IsConnected() ? GetInputCon( "TEX" ).node.property.GetVariable() : property.GetVariable(); - - bool useTilingLocally = IsProperty() && !property.tagNoScaleOffset; - bool useTilingByAsset = this["TEX"].IsConnected() && !this["TEX"].inputCon.node.property.tagNoScaleOffset; - if( useTilingLocally || useTilingByAsset ) - uvStr = "TRANSFORM_TEX(" + uvStr + ", " + variableName + ")"; - - if( useLOD ) { - uvStr = "float4(" + uvStr + ",0.0," + mip + ")"; - } - - - string s = func + "(" + variableName + "," + uvStr + ")"; - if( IsNormalMap() ) { - s = "UnpackNormal(" + s + ")"; - } - - return s; - } - - public void UnpackNormals( ref Texture2D t ) { - Color[] colors = t.GetPixels(); - for( int i = 0; i < colors.Length; i++ ) { - colors[i] = UnpackNormal( colors[i] ); - } - t.SetPixels( colors ); - t.Apply(); - } - - public Color UnpackNormal( Color c ) { - Vector3 normal = Vector3.zero; - - normal = new Vector2( c.a, c.g ) * 2f - Vector2.one; - normal.z = Mathf.Sqrt( 1f - normal.x * normal.x - normal.y * normal.y ); - - // TODO: Check color clamp method! - return SF_Tools.VectorToColor( normal ); - } - - - - public override bool Draw() { - - CheckPropertyInput(); - - // If Tex is plugged in, make sure this uses the same asset and all - if( property == null ) { - - SFN_Tex2dAsset inTex = ( GetInputCon( "TEX" ).node as SFN_Tex2dAsset ); - - bool refresh = false; - if( this.TextureAsset == null ) - refresh = true; - if(!refresh) - if( inTex.textureAsset != this.TextureAsset ) - refresh = true; - - if( refresh ) { - this.TextureAsset = inTex.textureAsset; - //RenderToTexture(); - } - } - - - ProcessInput(); - DrawHighlight(); - PrepareWindowColor(); - - DrawWindow(); - ResetWindowColor(); - return true;//!CheckIfDeleted(); - } - - - public void CheckPropertyInput() { - if( property != null && connectors[2].IsConnected() ) { - shelvedProperty = property; - property = null; - if( editor.nodeView.treeStatus.propertyList.Contains( this ) ) - editor.nodeView.treeStatus.propertyList.Remove( this ); - } else if( property == null && !connectors[2].IsConnected() ) { - property = shelvedProperty; - shelvedProperty = null; - if( !editor.nodeView.treeStatus.propertyList.Contains( this ) ) - editor.nodeView.treeStatus.propertyList.Add( this ); - } - } - - - public override void OnDelete() { - TextureAsset = null; - } - - public override void NeatWindow( ) { - - rect.height = TexAssetConnected() ? NODE_HEIGHT : NODE_HEIGHT + 34; - - GUI.skin.box.clipping = TextClipping.Overflow; - GUI.BeginGroup( rect ); - - if( IsProperty() && Event.current.type == EventType.DragPerform && rectInner.Contains(Event.current.mousePosition) ) { - Object droppedObj = DragAndDrop.objectReferences[0]; - if( droppedObj is Texture2D || droppedObj is ProceduralTexture || droppedObj is RenderTexture) { - Event.current.Use(); - TextureAsset = droppedObj as Texture; - OnAssignedTexture(); - } - } - - if( IsProperty() && Event.current.type == EventType.dragUpdated ) { - if(DragAndDrop.objectReferences.Length > 0){ - Object dragObj = DragAndDrop.objectReferences[0]; - if( dragObj is Texture2D || dragObj is ProceduralTexture || dragObj is RenderTexture) { - DragAndDrop.visualMode = DragAndDropVisualMode.Link; - editor.nodeBrowser.CancelDrag(); - Event.current.Use(); - } else { - DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; - } - } else { - DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; - } - } - - - - Color prev = GUI.color; - if( TextureAsset ) { - GUI.color = Color.white; - GUI.DrawTexture( rectInner, texture.texture, ScaleMode.StretchToFill, false ); // TODO: Doesn't seem to work - if(displayVectorDataMask){ - GUI.DrawTexture( rectInner, SF_GUI.VectorIconOverlay, ScaleMode.ScaleAndCrop, true); - } - } - - if( showLowerPropertyBox && !TexAssetConnected()) { - GUI.color = Color.white; - DrawLowerPropertyBox(); - } - - //else { - //GUI.color = new Color( GUI.color.r, GUI.color.g, GUI.color.b,0.5f); - //GUI.Label( rectInner, "Empty"); - //} - GUI.color = prev; - - - - if( IsProperty()){ - - bool draw = rectInner.Contains( Event.current.mousePosition ) && !SF_NodeConnector.IsConnecting(); - - Rect selectRect = new Rect( rectInner ); - selectRect.yMin += 80; - selectRect.xMin += 40; - Color c = GUI.color; - GUI.color = new Color( 1, 1, 1, draw ? 1 : 0 ); - if(GUI.Button( selectRect, "Select", EditorStyles.miniButton )){ - EditorGUIUtility.ShowObjectPicker( TextureAsset, false, "", this.id ); - Event.current.Use(); - } - GUI.color = c; - - } - - - if( IsProperty() && Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == this.id ) { - Event.current.Use(); - Texture newTextureAsset = EditorGUIUtility.GetObjectPickerObject() as Texture; - if(newTextureAsset != TextureAsset){ - if(newTextureAsset == null){ - UndoRecord("unassign texture of " + property.nameDisplay); - } else { - UndoRecord("switch texture to " + newTextureAsset.name + " in " + property.nameDisplay); - } - TextureAsset = newTextureAsset; - OnAssignedTexture(); - } - } - - GUI.EndGroup(); - - - - // GUI.DragWindow(); - - - - - /* - EditorGUI.BeginChangeCheck(); - textureAsset = (Texture)EditorGUI.ObjectField( rectInner, textureAsset, typeof( Texture ), false ); - if( EditorGUI.EndChangeCheck() ) { - OnAssignedTexture(); - } - * */ - - } - - public override void RefreshValue() { - CheckPropertyInput(); - base.RefreshValue(0,0); - //RenderToTexture(); - } - - public void OnAssignedTexture() { - - /* - if( HasAlpha() ) { - connectors[6].enableState = EnableState.Enabled; - base.texture.CompCount = 4; - } else { - connectors[6].Disconnect(); - connectors[6].enableState = EnableState.Hidden; - base.texture.CompCount = 3; - }*/ - - - - RefreshNoTexValueAndNormalUnpack(); - - - UpdateNormalMapAlphaState(); - //RenderToTexture(); - editor.shaderEvaluator.ApplyProperty( this ); - OnUpdateNode(NodeUpdateType.Soft); - } - - public void RefreshNoTexValueAndNormalUnpack(){ - bool newAssetIsNormalMap = false; - - string path = AssetDatabase.GetAssetPath( TextureAsset ); - if( string.IsNullOrEmpty( path ) ) - newAssetIsNormalMap = false; - else{ - AssetImporter importer = UnityEditor.AssetImporter.GetAtPath( path ); - if(importer is TextureImporter) - newAssetIsNormalMap = ((TextureImporter)importer ).textureType == TextureImporterType.NormalMap; - else if(TextureAsset is ProceduralTexture && TextureAsset.name.EndsWith("_Normal")) - newAssetIsNormalMap = true; // When it's a ProceduralTexture having _Normal as a suffix - else - newAssetIsNormalMap = false; // When it's a RenderTexture or ProceduralTexture - } - - if(newAssetIsNormalMap){ - noTexValue = NoTexValue.Bump; - markedAsNormalMap = true; - UpdateNormalMapAlphaState(); - } else if( noTexValue == NoTexValue.Bump){ - noTexValue = NoTexValue.Black; - markedAsNormalMap = false; - UpdateNormalMapAlphaState(); - } - - UpdateCompCount(); - - } - - - public override string SerializeSpecialData() { - string s = ""; - if( property != null ) - s += property.Serialize() + ","; - - if( TextureAsset != null ) - s += "tex:" + SF_Tools.AssetToGUID( TextureAsset ) + ","; - s += "ntxv:" + ((int)noTexValue).ToString() + ","; - s += "isnm:" + markedAsNormalMap.ToString(); - - return s; - - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize( key, value ); - switch( key ) { - case "tex": - TextureAsset = (Texture)SF_Tools.GUIDToAsset( value, typeof( Texture ) ); - OnAssignedTexture(); - break; - case "ntxv": - noTexValue = (NoTexValue)int.Parse(value); - break; - case "isnm": - markedAsNormalMap = bool.Parse(value); - UpdateNormalMapAlphaState(); - UpdateCompCount(); - break; - } - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2d.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2d.cs.meta deleted file mode 100755 index f227c246..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2d.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: cb7203f0faaf7274fa89fa02822dd483 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2dAsset.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2dAsset.cs deleted file mode 100755 index 33f7cc00..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2dAsset.cs +++ /dev/null @@ -1,366 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - - -namespace ShaderForge { - [System.Serializable] - public class SFN_Tex2dAsset : SF_Node { - - - public Texture textureAsset; // TODO: Use a parent class, this looks ridiculous - public NoTexValue noTexValue = NoTexValue.White;// TODO: Use a parent class, this looks ridiculous - public bool markedAsNormalMap = false; // TODO: Use a parent class, this looks ridiculous - - public SFN_Tex2dAsset() { - - } - - public override void Initialize() { - base.Initialize( "Texture Asset", InitialPreviewRenderMode.BlitQuad ); - node_height = (int)(rect.height - 6f); // Odd, but alright... - base.UseLowerPropertyBox( true, true ); - base.texture.CompCount = 4; - base.showColor = true; - neverDefineVariable = true; - isFloatPrecisionBasedVariable = false; - base.shaderGenMode = ShaderGenerationMode.Manual; - //alwaysDefineVariable = true; - property = ScriptableObject.CreateInstance().Initialize( this ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"TEX","Tex",ConType.cOutput,ValueType.TexAsset).WithColor(SF_Node.colorExposed) - }; - } - - public override bool IsUniformOutput() { - return false; - } - - - - public bool IsNormalMap() { - return markedAsNormalMap; - } - - - public bool IsAssetNormalMap() { - - string path = AssetDatabase.GetAssetPath( textureAsset ); - if( string.IsNullOrEmpty( path ) ) - return false; - else{ - AssetImporter importer = UnityEditor.AssetImporter.GetAtPath( path ); - if(importer is TextureImporter) - return ((TextureImporter)importer).textureType == TextureImporterType.NormalMap; - else if(textureAsset is ProceduralTexture && textureAsset.name.EndsWith("_Normal")) - return true; // When it's a ProceduralTexture having _Normal as a suffix - else - return false; // When it's a RenderTexture or ProceduralTexture - } - - } - - public bool HasAlpha() { - if( textureAsset == null ) return false; - string path = AssetDatabase.GetAssetPath( textureAsset ); - if( string.IsNullOrEmpty( path ) ) return false; - return ( (TextureImporter)UnityEditor.AssetImporter.GetAtPath( path ) ).DoesSourceTextureHaveAlpha(); - } - - // TODO: MIP selection - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - //if( varDefined ) - return GetVariableName(); - //else - //DefineVariable(); // This lags for some reason - - /* - bool useLOD = GetInputIsConnected( 1 ) || (SF_Evaluator.inVert || SF_Evaluator.inTess); - string uvStr = GetInputIsConnected( 0 ) ? GetInputCon( 0 ).Evaluate() : SF_Evaluator.WithProgramPrefix( "uv0.xy" ); - string func = useLOD ? "tex2Dlod" : "tex2D"; - string mip = GetInputIsConnected( 1 ) ? GetInputCon( 1 ).Evaluate() : "0"; - - if( useLOD ) { - uvStr = "float4(" + uvStr + ",0.0," + mip + ")"; - } - - - string s = func + "(" + property.GetVariable() + "," + uvStr + ")"; - if( IsNormalMap() ) { - s = "UnpackNormal(" + s + ")"; - } - */ - //Debug.LogError( "Invalid evaluation of " + property.name ); -// return ""; - } - - - public void UnpackNormals( ref Texture2D t ) { - Color[] colors = t.GetPixels(); - for( int i = 0; i < colors.Length; i++ ) { - colors[i] = UnpackNormal( colors[i] ); - } - t.SetPixels( colors ); - t.Apply(); - } - - public Color UnpackNormal( Color c ) { - Vector3 normal = Vector3.zero; - - normal = new Vector2( c.a, c.g ) * 2f - Vector2.one; - normal.z = Mathf.Sqrt( 1f - normal.x * normal.x - normal.y * normal.y ); - - // TODO: Check color clamp method! - return SF_Tools.VectorToColor( normal ); - } - - - - public override bool Draw() { - if( IsGlobalProperty()){ - rect.height = (int)(NODE_HEIGHT + 16f + 2); - } else { - rect.height = (int)(NODE_HEIGHT + 32f + 2); - } - - ProcessInput(); - DrawHighlight(); - PrepareWindowColor(); - DrawWindow(); - ResetWindowColor(); - return true;//!CheckIfDeleted(); - } - - public override void OnDelete() { - textureAsset = null; - } - - public override void NeatWindow( ) { - - GUI.skin.box.clipping = TextClipping.Overflow; - GUI.BeginGroup( rect ); - - if(IsGlobalProperty()){ - GUI.enabled = false; - } - - if( IsProperty() && Event.current.type == EventType.DragPerform && rectInner.Contains(Event.current.mousePosition) ) { - Object droppedObj = DragAndDrop.objectReferences[0]; - if( droppedObj is Texture2D || droppedObj is ProceduralTexture || droppedObj is RenderTexture) { - Event.current.Use(); - textureAsset = droppedObj as Texture; - OnAssignedTexture(); - } - } - - if( IsProperty() && Event.current.type == EventType.dragUpdated ) { - if(DragAndDrop.objectReferences.Length > 0){ - Object dragObj = DragAndDrop.objectReferences[0]; - if( dragObj is Texture2D || dragObj is ProceduralTexture || dragObj is RenderTexture) { - DragAndDrop.visualMode = DragAndDropVisualMode.Link; - editor.nodeBrowser.CancelDrag(); - Event.current.Use(); - } else { - DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; - } - } else { - DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; - } - } - - if(IsGlobalProperty()){ - GUI.enabled = true; - } - - - - Color prev = GUI.color; - if( textureAsset ) { - GUI.color = Color.white; - GUI.DrawTexture( rectInner, texture.texture, ScaleMode.StretchToFill, false ); - } //else { - //GUI.color = new Color( GUI.color.r, GUI.color.g, GUI.color.b,0.5f); - //GUI.Label( rectInner, "Empty"); - //} - - if( showLowerPropertyBox ) { - GUI.color = Color.white; - DrawLowerPropertyBox(); - } - - GUI.color = prev; - - - - if( rectInner.Contains( Event.current.mousePosition ) && !SF_NodeConnector.IsConnecting() && !IsGlobalProperty() ) { - Rect selectRect = new Rect( rectInner ); - selectRect.yMin += 80; - selectRect.xMin += 40; - - if(GUI.Button( selectRect, "Select", EditorStyles.miniButton )){ - EditorGUIUtility.ShowObjectPicker( textureAsset, false, "", this.id ); - Event.current.Use(); - } - - } - - - if( !IsGlobalProperty() && Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == this.id ) { - Event.current.Use(); - Texture newTextureAsset = EditorGUIUtility.GetObjectPickerObject() as Texture; - if(newTextureAsset != textureAsset){ - if(newTextureAsset == null){ - UndoRecord("unassign texture of " + property.nameDisplay); - } else { - UndoRecord("switch texture to " + newTextureAsset.name + " in " + property.nameDisplay); - } - textureAsset = newTextureAsset; - OnAssignedTexture(); - } - - } - - GUI.EndGroup(); - - - - // GUI.DragWindow(); - - - - - /* - EditorGUI.BeginChangeCheck(); - textureAsset = (Texture)EditorGUI.ObjectField( rectInner, textureAsset, typeof( Texture ), false ); - if( EditorGUI.EndChangeCheck() ) { - OnAssignedTexture(); - } - * */ - - } - - public override void RefreshValue() { - base.RefreshValue( 0, 0 ); - //RenderToTexture(); - } - - public override int GetEvaluatedComponentCount() { - if( IsNormalMap() ) - return 3; - return 4; - } - - public override void PrepareRendering( Material mat ) { - if( textureAsset != null ) { - mat.mainTexture = textureAsset; - mat.SetFloat( "_IsNormal", IsNormalMap() ? 1 : 0 ); - } - } - - - public void OnAssignedTexture() { - - /* - if( HasAlpha() ) { - connectors[6].enableState = EnableState.Enabled; - base.texture.CompCount = 4; - } else { - connectors[6].Disconnect(); - connectors[6].enableState = EnableState.Hidden; - base.texture.CompCount = 3; - }*/ - RefreshNoTexValueAndNormalUnpack(); - editor.shaderEvaluator.ApplyProperty( this ); - OnUpdateNode(); - } - - - - // TODO: Use a parent class, this looks ridiculous - // TODO: Use a parent class, this looks ridiculous - // TODO: Use a parent class, this looks ridiculous - public void RefreshNoTexValueAndNormalUnpack(){ - bool newAssetIsNormalMap = false; - - string path = AssetDatabase.GetAssetPath( textureAsset ); - if( string.IsNullOrEmpty( path ) ) - newAssetIsNormalMap = false; - else{ - AssetImporter importer = UnityEditor.AssetImporter.GetAtPath( path ); - if(importer is TextureImporter) - newAssetIsNormalMap = ((TextureImporter)importer ).textureType == TextureImporterType.NormalMap; - else if(textureAsset is ProceduralTexture && textureAsset.name.EndsWith("_Normal")) - newAssetIsNormalMap = true; // When it's a ProceduralTexture having _Normal as a suffix - else - newAssetIsNormalMap = false; // When it's a RenderTexture or ProceduralTexture - } - - if(newAssetIsNormalMap){ - noTexValue = NoTexValue.Bump; - markedAsNormalMap = true; - } else if( noTexValue == NoTexValue.Bump){ - noTexValue = NoTexValue.Black; - markedAsNormalMap = false; - } - - } - - - public override void DrawLowerPropertyBox() { - GUI.color = Color.white; - EditorGUI.BeginChangeCheck(); - Rect tmp = lowerRect; - tmp.height = 16f; - if(!IsGlobalProperty()){ - noTexValue = (NoTexValue)UndoableLabeledEnumPopup(tmp, "Default", noTexValue, "swith default color of " + property.nameDisplay ); - //noTexValue = (NoTexValue)SF_GUI.LabeledEnumField( tmp, "Default", noTexValue, EditorStyles.miniLabel ); - tmp.y += tmp.height; - } - bool preMarked = markedAsNormalMap; - UndoableToggle(tmp, ref markedAsNormalMap, "Normal map", "normal map decode of " + property.nameDisplay, null); - //markedAsNormalMap = GUI.Toggle(tmp, markedAsNormalMap, "Normal map" ); - if(EditorGUI.EndChangeCheck()){ - - if(markedAsNormalMap && !preMarked) - noTexValue = NoTexValue.Bump; - OnUpdateNode(); - - } - - } - - - public override string SerializeSpecialData() { - - string s = property.Serialize() + ","; - - if( textureAsset != null ) - s += "tex:" + SF_Tools.AssetToGUID( textureAsset ) + ","; - s += "ntxv:" + ( (int)noTexValue ).ToString() + ","; - s += "isnm:" + markedAsNormalMap.ToString(); - - return s; - - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize( key, value ); - switch( key ) { - case "tex": - textureAsset = (Texture)SF_Tools.GUIDToAsset( value, typeof( Texture ) ); - OnAssignedTexture(); - break; - case "ntxv": - noTexValue = (NoTexValue)int.Parse( value ); - break; - case "isnm": - markedAsNormalMap = bool.Parse( value ); - break; - } - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2dAsset.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2dAsset.cs.meta deleted file mode 100755 index 139eb125..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Tex2dAsset.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9869459e0257d034e93856da292f741e -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_TexCoord.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_TexCoord.cs deleted file mode 100755 index 3c9b29d0..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_TexCoord.cs +++ /dev/null @@ -1,122 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_TexCoord : SF_Node { - - - - public enum UV { uv0 = 0, uv1 = 1, uv2 = 2, uv3 = 3 }; - public UV currentUV = UV.uv0; - public bool useAsFloat4 = false; - - public SFN_TexCoord() { - - } - - public override void Initialize() { - base.Initialize( "UV Coord.", InitialPreviewRenderMode.BlitQuad ); - base.UseLowerPropertyBox( true, true ); - base.showColor = true; - base.texture.uniform = false; - base.texture.CompCount = 4; - base.neverDefineVariable = true; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"UVOUT","UV",ConType.cOutput,ValueType.VTv2), - SF_NodeConnector.Create(this,"U","U",ConType.cOutput,ValueType.VTv1).WithColor(Color.red).Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"V","V",ConType.cOutput,ValueType.VTv1).WithColor(Color.green).Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"Z","Z",ConType.cOutput,ValueType.VTv1).WithColor(Color.blue).Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"W","W",ConType.cOutput,ValueType.VTv1).Outputting(OutChannel.A) - }; - - UpdateConnectorVisibility(); - - - } - - public override int GetEvaluatedComponentCount() { - return useAsFloat4 ? 4 : 2; - } - - public override bool IsUniformOutput() { - return false; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string s = SF_Evaluator.inTess ? "texcoord" + (int)currentUV : currentUV.ToString(); - - return SF_Evaluator.WithProgramPrefix( s ); - } - - static string[] float4Names = new string[] { "uv", "uvzw" }; - const string undoCompCountSwitch = "uv component count"; - const string undoSwitchUvChannel = "switch UV channel"; - - public override void DrawLowerPropertyBox() { - GUI.color = Color.white; - EditorGUI.BeginChangeCheck(); - - Rect[] rects = lowerRect.SplitHorizontal( 0.5f ); - - currentUV = (UV)UndoableEnumPopup( rects[0], currentUV, undoSwitchUvChannel ); - int curVal = useAsFloat4 ? 1 : 0; - int newVal = UndoableEnumPopupNamed( rects[1], curVal, float4Names, undoCompCountSwitch ); - useAsFloat4 = newVal == 1; - - if( EditorGUI.EndChangeCheck() ) { - UpdateConnectorVisibility(); - OnUpdateNode(); - } - } - - void UpdateConnectorVisibility() { - SF_NodeConnector z = GetConnectorByID( "Z" ); - SF_NodeConnector w = GetConnectorByID( "W" ); - if( !useAsFloat4 ) { - if(z.IsConnected()){ - for( int i = 0; i < z.outputCons.Count; i++ ) { - Undo.RecordObject( z.outputCons[i], "disconnect" ); - } - Undo.RecordObject( z, "disconnect" ); - z.Disconnect(); - } - if( w.IsConnected() ) { - for( int i = 0; i < w.outputCons.Count; i++ ) { - Undo.RecordObject( w.outputCons[i], "disconnect" ); - } - Undo.RecordObject( w, "disconnect" ); - w.Disconnect(); - } - } - EnableState enableState = useAsFloat4 ? EnableState.Enabled : EnableState.Disabled; - z.enableState = enableState; - w.enableState = enableState; - } - - public override string SerializeSpecialData() { - string s = ""; - s += "uv:" + (int)currentUV + ","; - s += "uaff:" + useAsFloat4.ToString(); - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "uv": - currentUV = (UV)int.Parse( value ); - break; - case "uaff": - useAsFloat4 = (bool)bool.Parse( value ); - UpdateConnectorVisibility(); - break; - } - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_TexCoord.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_TexCoord.cs.meta deleted file mode 100755 index 8386db58..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_TexCoord.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 848317c8e7955f44da670e263a6c0603 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Time.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Time.cs deleted file mode 100755 index 79b5239f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Time.cs +++ /dev/null @@ -1,53 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Time : SF_Node { - - - public SFN_Time() { - - } - - public override void Initialize() { - base.Initialize( "Time", InitialPreviewRenderMode.BlitQuad ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.uniform = false; - base.texture.CompCount = 4; - - base.alwaysDefineVariable = true; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"TSL","t/20",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"T","t",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"TDB","t*2",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"TTR","t*3",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.A) - }; - - } - - public override bool UpdatesOverTime() { - return true; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "_Time"; - } - - public override float EvalCPU( int c ) { - return 1f; - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Time.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Time.cs.meta deleted file mode 100755 index 3d85654e..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Time.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 28440b6a8c7a9fa4c9d4d8f5dfa12015 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ToggleProperty.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ToggleProperty.cs deleted file mode 100755 index 2bacdddd..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ToggleProperty.cs +++ /dev/null @@ -1,146 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ToggleProperty : SF_Node { - - - public SFN_ToggleProperty() { - - } - - [SerializeField] - public bool on = false; - - public override void Initialize() { - node_height = 24; - //node_width = (int)(NODE_WIDTH*1.25f); - base.Initialize( "Toggle" ); - lowerRect.y -= 8; - lowerRect.height = 28; - base.showColor = false; - base.neverDefineVariable = true; - base.UseLowerPropertyBox( true ); - base.texture.uniform = true; - base.texture.CompCount = 1; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - - property = ScriptableObject.CreateInstance().Initialize( this ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1,false) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return property.GetVariable(); - } - - - public override void DrawLowerPropertyBox() { - PrepareWindowColor(); - float vecPrev = texture.dataUniform[0]; - //int strWidth = (int)SF_Styles.GetLargeTextField().CalcSize( new GUIContent( texture.dataUniform[0].ToString() ) ).x; - //lowerRect.width = Mathf.Max( 32, strWidth ); - Rect r = new Rect( lowerRect ); - r.width -= 75; - r.width *= 2; - r.yMin += 4; - r.yMax -= 2; - r.xMin += 2; - float fVal = texture.dataUniform[0];; - - //GUI.enabled = false; - //fVal = EditorGUI.FloatField(r, texture.dataUniform[0], SF_Styles.LargeTextField); - //GUI.enabled = true; - - //r.x += r.width + 6; - - - - bool prevVal = on; - - GUI.enabled = false; - r = r.PadTop(2); - GUI.Label(r,prevVal ? "1": "0", SF_Styles.LargeTextFieldNoFrame); - r = r.PadTop(-2); - GUI.enabled = true; - - r.x += 18; - - r.width = r.height + 2; - bool newVal = GUI.Button(r,string.Empty) ? !prevVal : prevVal; - - if(newVal){ - Rect chkRect = r; - chkRect.width = SF_GUI.Toggle_check_icon.width; - chkRect.height = SF_GUI.Toggle_check_icon.height; - chkRect.x += (r.width-chkRect.width)*0.5f; - chkRect.y += 2; - GUI.DrawTexture(chkRect,SF_GUI.Toggle_check_icon); - } - - - - if(prevVal != newVal){ - UndoRecord("set toggle of " + property.nameDisplay + " to " + newVal.ToString()); - fVal = newVal ? 1f : 0f; - connectors[0].label = ""; - //Debug.Log("Setting it to " + newVal.ToString()); - } - - r.x += r.width + 6; - r.width = r.height + 18; - Rect texCoords = new Rect( r ); - texCoords.width /= 7; - texCoords.height /= 3; - texCoords.x = texCoords.y = 0; - GUI.DrawTextureWithTexCoords( r, SF_GUI.Handle_drag, texCoords, alphaBlend:true ); - on = newVal; - texture.dataUniform = new Color( fVal, fVal, fVal, fVal ); - if( texture.dataUniform[0] != vecPrev ) { - OnUpdateNode( NodeUpdateType.Soft ); - editor.shaderEvaluator.ApplyProperty( this ); - } - - ResetWindowColor(); - - } - - public override float EvalCPU( int c ) { - if(on){ - return 1f; - } else { - return 0f; - } - } - - - public override string SerializeSpecialData() { - string s = property.Serialize() + ","; - s += "on:" + on; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize( key, value ); - switch( key ) { - case "on": - on = bool.Parse( value ); - float fVal = on ? 1f : 0f; - texture.dataUniform = new Color( fVal, fVal, fVal, fVal ); - break; - } - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ToggleProperty.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ToggleProperty.cs.meta deleted file mode 100644 index 8a300c35..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ToggleProperty.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 103e84f5af0dd42d492e08d62f85e2c2 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transform.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transform.cs deleted file mode 100755 index 96c3ea7c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transform.cs +++ /dev/null @@ -1,248 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Transform : SF_Node { - - - /* - public string[] matrixVars = new string[]{ - "UNITY_MATRIX_MVP", - "UNITY_MATRIX_MV", - "UNITY_MATRIX_V", - "UNITY_MATRIX_P", - "UNITY_MATRIX_VP", - "UNITY_MATRIX_T_MV", - "UNITY_MATRIX_IT_MV", - "unity_Object2World", - "unity_WorldToObject", - "tangentTransform" - }; - - public string[] matrixLabels = new string[]{ - "Model*View*Projection", - "Model*View", - "View", - "Projection", - "View*Projection", - "Transpose Model*View", - "Inverse transpose Model*View", - "Model to World", - "World to Model", - "Tangent" - }; - */ - - - public string[] spaceLabels = new string[]{ - "World", - "Local", - "Tangent", - "View" - }; - - public enum Space{World, Local, Tangent, View}; - - public Space spaceSelFrom = Space.World; - public Space spaceSelTo = Space.Local; - - - //public const int tangentID = 9; - //public int selection = 0; - - public SFN_Transform() { - - } - - public override void Initialize() { - base.Initialize( "Transform" ); - base.showColor = true; - base.vectorDataNode = true; // This should really be renamed to "Always draw as 3D" - UseLowerPropertyBox( true, true ); - base.shaderGenMode = ShaderGenerationMode.Manual; - //UseLowerReadonlyValues(true,true); - - - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"XYZ","XYZ",ConType.cOutput,ValueType.VTv3,false).Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"IN","In",ConType.cInput,ValueType.VTv3,false).SetRequired(true) - }; - base.node_height += 14; - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1] ); - } - - public override int GetEvaluatedComponentCount() { - return this["IN"].GetCompCount(); - } - - public override bool IsUniformOutput() { - return GetInputData( "IN" ).uniform; - } - - public override void PrepareRendering( Material mat ) { - mat.SetFloat( "_FromSpace", (int)spaceSelFrom ); - mat.SetFloat( "_ToSpace", (int)spaceSelTo ); - } - - - // New system - public override void RefreshValue() { - RefreshValue( 1, 1 ); - } - - public string GetInVector(bool tangent = false){ - if(tangent) - return GetConnectorByStringID( "IN" ).TryEvaluate(); - else - return "float4("+GetConnectorByStringID( "IN" ).TryEvaluate()+",0)"; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - if(spaceSelFrom == spaceSelTo){ // TODO: Add warning about tunneling variable - return GetConnectorByStringID( "IN" ).TryEvaluate(); - } - - - // From world space - if( FromTo( Space.World, Space.Local) ){ - return "mul( unity_WorldToObject, " + GetInVector() + " ).xyz"; - } - if( FromTo( Space.World, Space.Tangent) ){ - return "mul( tangentTransform, "+ GetInVector(tangent:true)+" ).xyz"; - } - if( FromTo(Space.World, Space.View)){ - return "mul( UNITY_MATRIX_V, " + GetInVector() + " ).xyz"; - } - - - // From local space - if( FromTo( Space.Local, Space.World) ){ - return "mul( unity_ObjectToWorld, " + GetInVector() + " ).xyz"; - } - if(FromTo(Space.Local, Space.Tangent)){ - return "mul( tangentTransform, " + "mul( unity_ObjectToWorld, " + GetInVector() + " ).xyz" + " ).xyz"; - } - if( FromTo(Space.Local, Space.View)){ - return "UnityObjectToViewPos( " + GetInVector() + " ).xyz"; - } - - - - - // From tangent space - if( FromTo( Space.Tangent, Space.World) ){ - return "mul( "+ GetInVector(tangent:true)+", tangentTransform ).xyz"; - } - if( FromTo( Space.Tangent, Space.Local) ){ - return "mul( unity_WorldToObject, " + "float4(mul( "+ GetInVector(tangent:true)+", tangentTransform ),0)" + " ).xyz"; - } - if( FromTo( Space.Tangent, Space.View) ){ - return "mul( UNITY_MATRIX_V, " + "float4(mul( "+ GetInVector(tangent:true)+", tangentTransform ),0)" + " ).xyz"; - } - - - // From view space - if( FromTo(Space.View, Space.World)){ - return "mul( " + GetInVector() + ", UNITY_MATRIX_V ).xyz"; - } - if( FromTo(Space.View, Space.Local)){ - return "mul( " + GetInVector() + ", UNITY_MATRIX_MV ).xyz"; - } - if( FromTo(Space.View, Space.Tangent)){ - return "mul( tangentTransform, "+ "mul( " + GetInVector() + ", UNITY_MATRIX_V ).xyz"+" ).xyz"; - } - - - - // TODO TODO TODO: - return GetConnectorByStringID( "IN" ).TryEvaluate(); - - - - /* - if( selection != tangentID ) - return "mul( " + matrixVars[selection] + ", float4( " + GetConnectorByStringID( "IN" ).TryEvaluate() + ", 0 )).xyz"; - else - return "mul( " + matrixVars[selection] + ", " + GetConnectorByStringID( "IN" ).TryEvaluate() + " )"; - */ - } - - public bool FromTo(Space from, Space to){ - return (spaceSelFrom == from && spaceSelTo == to); - } - - // Pass through - public override Vector4 EvalCPU() { - return GetInputData( "IN" ).node.EvalCPU(); - } - - const float dirLabelWidth = 28; - public override void DrawLowerPropertyBox() { - EditorGUI.BeginChangeCheck(); - - Rect r = new Rect(lowerRect); - r.width = dirLabelWidth; - r.height = 18; - //r.height /= 2; - GUI.Label(r,"From",SF_Styles.MiniLabelOverflow); - r.x += r.width; - r.width = (lowerRect.width-dirLabelWidth); - - spaceSelFrom = (Space)UndoablePopup(r, (int)spaceSelFrom, spaceLabels, "switch transform 'from' setting"); - r.y += r.height; - spaceSelTo = (Space)UndoablePopup(r, (int)spaceSelTo, spaceLabels, "switch transform 'to' setting"); - r.x = 0; - r.width = dirLabelWidth; - GUI.Label(r,"To",SF_Styles.MiniLabelOverflow); - - /* - r.width -= toLabelWidth; - float popupWidth = (r.width /= 2); - spaceSelFrom = EditorGUI.Popup(r, spaceSelFrom, spaceLabels); - r.x += r.width; - r.width = toLabelWidth; - GUI.Label(r,"to",SF_Styles.MiniLabelOverflow); - r.x += r.width; - r.width = popupWidth; - spaceSelTo = EditorGUI.Popup(r, spaceSelTo, spaceLabels); - */ - - //selection = EditorGUI.Popup( lowerRect, selection, matrixLabels ); - if( EditorGUI.EndChangeCheck() ) { - OnUpdateNode(); - } - } - - - public override string SerializeSpecialData() { - string s = "tffrom:" + (int)spaceSelFrom + ","; - s += "tfto:" + (int)spaceSelTo; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "tffrom": - spaceSelFrom = (Space)int.Parse( value ); - break; - case "tfto": - spaceSelTo = (Space)int.Parse( value ); - break; - } - } - - - /* - public override Vector4 NodeOperator( int x, int y ) { - return base.NodeOperator( x, y ); - } - */ - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transform.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transform.cs.meta deleted file mode 100755 index 6650d470..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transform.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 124d80ea9a58a4246b0a4a6cccdaac62 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transpose.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transpose.cs deleted file mode 100644 index 77998e92..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transpose.cs +++ /dev/null @@ -1,53 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Transpose : SF_Node { - - public SFN_Transpose() { - } - - public override void Initialize() { - node_height = 58; - base.Initialize( "Transpose" ); - base.showColor = false; - base.UseLowerPropertyBox( false, true ); - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTm4x4,false), - SF_NodeConnector.Create(this,"IN","",ConType.cInput,ValueType.VTm4x4,false).SetRequired(true) - }; - } - - public override void NeatWindow() { - PrepareWindowColor(); - GUI.BeginGroup( rect ); - Rect r = new Rect( rectInner ); - r = r.Pad( 4 ); - - Rect texCoords = new Rect( r ); - texCoords.width /= 7; - texCoords.height /= 3; - texCoords.x = texCoords.y = 0; - GUI.DrawTextureWithTexCoords( r, SF_GUI.Handle_drag, texCoords, alphaBlend: true ); - - GUI.EndGroup(); - ResetWindowColor(); - - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "transpose(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override Vector4 EvalCPU() { - return Color.black; - } - - public override void RefreshValue() { - RefreshValue( 1, 1 ); - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transpose.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transpose.cs.meta deleted file mode 100644 index b6416903..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Transpose.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 443238bf8445e494fb3ddbb7a7e3651e -timeCreated: 1436201790 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Trunc.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Trunc.cs deleted file mode 100755 index 1eb7526f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Trunc.cs +++ /dev/null @@ -1,27 +0,0 @@ -using UnityEngine; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Trunc : SF_Node_Arithmetic { - - public SFN_Trunc() { - } - - public override void Initialize() { - base.Initialize( "Trunc" ); - base.PrepareArithmetic(1); - base.shaderGenMode = ShaderGenerationMode.SimpleFunction; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "trunc(" + GetConnectorByStringID( "IN" ).TryEvaluate() + ")"; - } - - public override float EvalCPU( int c ) { - float val = GetInputData( "IN", c ); - return val < 0 ? -Mathf.Floor( -val ) : Mathf.Floor( val ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Trunc.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Trunc.cs.meta deleted file mode 100755 index a361cfa0..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Trunc.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1d73655491ef04b4ea839fe65ab4831a -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_UVTile.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_UVTile.cs deleted file mode 100644 index 5cd6f5dc..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_UVTile.cs +++ /dev/null @@ -1,128 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -//using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_UVTile : SF_Node { - - - public SFN_UVTile() { - - } - - - public override void Initialize() { - base.Initialize( "UV Tile" ); - base.showColor = true; - UseLowerReadonlyValues( false ); - base.alwaysDefineVariable = true; - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - texture.CompCount = 2; - //SF_NodeConnection lerpCon; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"UVOUT","UV",ConType.cOutput,ValueType.VTv2,false), - SF_NodeConnector.Create(this,"UVIN","UV",ConType.cInput,ValueType.VTv2,false).SetRequired(false).SetGhostNodeLink(typeof(SFN_TexCoord),"UVOUT"), - SF_NodeConnector.Create(this,"WDT","Wid",ConType.cInput,ValueType.VTv1,false).SetRequired(true).WithUseCount(2), - SF_NodeConnector.Create(this,"HGT","Hei",ConType.cInput,ValueType.VTv1,false).SetRequired(true).SetGhostNodeLink(typeof(SFN_Time),"T"), - SF_NodeConnector.Create(this,"TILE","Tile",ConType.cInput,ValueType.VTv1,false).SetRequired(true).WithUseCount(2), - }; - - //base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2] ); - } - - - - - public override void OnUpdateNode( NodeUpdateType updType, bool cascade = true ) { - if( InputsConnected() ) - RefreshValue( 1, 2 ); - base.OnUpdateNode( updType ); - } - - public override bool IsUniformOutput() { - if( GetInputIsConnected( "UVIN" ) && !GetInputData( "UVIN" ).uniform ) - return false; - if( GetInputIsConnected( "WDT" ) && !GetInputData( "WDT" ).uniform ) - return false; - if( GetInputIsConnected( "HGT" ) && !GetInputData( "HGT" ).uniform ) - return false; - if( GetInputIsConnected( "TILE" ) && !GetInputData( "TILE" ).uniform ) - return false; - return false; - } - - public override int GetEvaluatedComponentCount() { - return 2; - } - - public string TileCountRecip() { - return GetVariableName() + "_tc_rcp"; - } - - public string TileX() { - return GetVariableName() + "_tx"; - } - - public string TileY() { - return GetVariableName() + "_ty"; - } - - public override string[] GetBlitOutputLines() { - return new string[] { - "float2 tcrcp = float2(1.0,1.0)/float2( _wdt.x, _hgt.x );", - "float ty = floor(_tile.x * tcrcp.x);", - "float tx = _tile.x - _wdt.x * ty;", - "float4((_uvin.xy + float2(tx, ty)) * tcrcp,0,0)" - }; - } - - public override string[] GetPreDefineRows() { - return new string[] { - "float2 " + TileCountRecip() + " = float2(1.0,1.0)/float2( " + this["WDT"].TryEvaluate() + ", " + this["HGT"].TryEvaluate() + " );", - "float " + TileY() + " = floor(" + this["TILE"].TryEvaluate() + " * " + TileCountRecip() + ".x);", - "float " + TileX() + " = " + this["TILE"].TryEvaluate() + " - " + this["WDT"].TryEvaluate() + " * " + TileY() + ";", - }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "(" + this["UVIN"].TryEvaluate() + " + float2(" + TileX() + ", " + TileY() + ")) * " + TileCountRecip(); - } - - // TODO Expose more out here! - public override Vector4 EvalCPU() { - - // GetInputData( "ANG", x, y, 0 ) - - Vector2 uv = Vector2.one; - if( GetInputIsConnected( "UVIN" ) ) { - uv = new Vector2( GetInputData( "UVIN", 0 ), GetInputData( "UVIN", 1 ) ); - } else { - //uv = new Vector2( x / SF_NodeData.RESf, y / SF_NodeData.RESf ); // TODO: should use ghost nodes... - } - float tile = GetInputData( "TILE", 0 ); - float w = GetInputData( "WDT", 0 ); - float h = GetInputData( "HGT", 0 ); - - float ty = Mathf.Floor( tile / w ); - float tx = tile - w * ty; - - uv.x += tx; - uv.y += ty; - - uv.x /= w; - uv.y /= h; - - - return new Color( uv.x, uv.y, 0f, 0f ); - } - - float Frac( float x ) { - return x - Mathf.Floor( x ); - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_UVTile.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_UVTile.cs.meta deleted file mode 100644 index 8694c0ad..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_UVTile.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b76724c3c29f6ba49b2898ad57abf498 -timeCreated: 1439735875 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ValueProperty.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ValueProperty.cs deleted file mode 100755 index d9d365ed..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ValueProperty.cs +++ /dev/null @@ -1,102 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ValueProperty : SF_Node { - - - public SFN_ValueProperty() { - - } - - public override void Initialize() { - node_height = 24; - //node_width = (int)(NODE_WIDTH*1.25f); - base.Initialize( "Value" ); - lowerRect.y -= 8; - lowerRect.height = 28; - base.showColor = false; - base.neverDefineVariable = true; - base.UseLowerPropertyBox( true ); - base.texture.uniform = true; - base.texture.CompCount = 1; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - - property = ScriptableObject.CreateInstance().Initialize( this ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1,false) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return property.GetVariable(); - } - - - public override void DrawLowerPropertyBox() { - PrepareWindowColor(); - float vecPrev = texture.dataUniform[0]; - //int strWidth = (int)SF_Styles.GetLargeTextField().CalcSize( new GUIContent( texture.dataUniform[0].ToString() ) ).x; - //lowerRect.width = Mathf.Max( 32, strWidth ); - Rect r = new Rect( lowerRect ); - r.width -= 32; - r.yMin += 4; - r.yMax -= 2; - r.xMin += 2; - float fVal; - if(IsGlobalProperty()){ - fVal = 1f; - GUI.enabled = false; - EditorGUI.FloatField( r, 1, SF_Styles.LargeTextField ); - GUI.enabled = true; - - } else { - fVal = UndoableFloatField(r, texture.dataUniform[0], "value" , SF_Styles.LargeTextField); - //fVal = EditorGUI.FloatField( r, texture.dataUniform[0], SF_Styles.LargeTextField ); - } - r.x += r.width + 6; - r.width = r.height; - Rect texCoords = new Rect( r ); - texCoords.width /= 7; - texCoords.height /= 3; - texCoords.x = texCoords.y = 0; - GUI.DrawTextureWithTexCoords( r, SF_GUI.Handle_drag, texCoords, alphaBlend:true ); - - texture.dataUniform = new Vector4( fVal, fVal, fVal, fVal ); - if( texture.dataUniform[0] != vecPrev ) { - OnUpdateNode( NodeUpdateType.Soft ); - editor.shaderEvaluator.ApplyProperty( this ); - } - - ResetWindowColor(); - - } - - public override string SerializeSpecialData() { - string s = property.Serialize() + ","; - s += "v1:" + texture.dataUniform[0]; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize(key,value); - switch( key ) { - case "v1": - float fVal = float.Parse( value ); - texture.dataUniform = new Color( fVal, fVal, fVal, fVal ); - break; - } - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ValueProperty.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ValueProperty.cs.meta deleted file mode 100755 index 7a655236..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ValueProperty.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ad7dec924ed5ebe4f80cca8439af7294 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector1.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector1.cs deleted file mode 100755 index fa45022d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector1.cs +++ /dev/null @@ -1,91 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Vector1 : SF_Node { - - - public SFN_Vector1() { - - } - - public override void Initialize() { - node_height = 24; - //node_width = (int)(NODE_WIDTH*1.25f); - base.Initialize( "Value" ); - lowerRect.y -= 8; - lowerRect.height = 28; - base.showColor = false; - base.UseLowerPropertyBox( true ); - base.texture.uniform = true; - base.texture.CompCount = 1; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv1,false) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string str = texture.dataUniform[0].ToString( "0.0###########" ); // At least one decimal - - if( texture.dataUniform[0] < 0f) - return "("+str+")"; - return str; - - } - - public override int GetEvaluatedComponentCount(){ - return 1; - } - - - public override void DrawLowerPropertyBox() { - float vecPrev = texture.dataUniform[0]; - //int strWidth = (int)SF_Styles.GetLargeTextField().CalcSize( new GUIContent( texture.dataUniform[0].ToString() ) ).x; - //lowerRect.width = Mathf.Max( 32, strWidth ); - Rect r = new Rect( lowerRect ); - r.width -= 32; - r.yMin += 4; - r.yMax -= 2; - r.xMin += 2; - //SF_GUI.EnterableFloatField( this, r, ref texture.dataUniform.r, SF_Styles.LargeTextField ); - UndoableEnterableFloatField(r, ref texture.dataUniform.x, "value", SF_Styles.LargeTextField); - r.x += r.width + 6; - r.width = r.height; - Rect texCoords = new Rect( r ); - texCoords.width /= 7; - texCoords.height /= 3; - texCoords.x = texCoords.y = 0; - GUI.DrawTextureWithTexCoords( r, SF_GUI.Handle_drag, texCoords, alphaBlend:true ); - - texture.dataUniform = new Vector4( texture.dataUniform.x, texture.dataUniform.x, texture.dataUniform.x, texture.dataUniform.x ); - if( texture.dataUniform[0] != vecPrev ) - OnUpdateNode(); - } - - public override string SerializeSpecialData() { - return "v1:" + texture.dataUniform[0]; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "v1": - float fVal = float.Parse( value ); - texture.dataUniform = new Color( fVal, fVal, fVal, fVal ); - break; - } - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector1.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector1.cs.meta deleted file mode 100755 index 265a331a..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector1.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c5a90f9239f419d4f99c9b73ae51f110 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector2.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector2.cs deleted file mode 100755 index b4fe3c80..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector2.cs +++ /dev/null @@ -1,79 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Vector2 : SF_Node { - - - public SFN_Vector2() { - - } - - public override void Initialize() { - node_height /= 2; - base.Initialize( "Vector 2" ); - base.showColor = true; - base.UseLowerPropertyBox( true ); - base.texture.uniform = true; - base.canAlwaysSetPrecision = true; - base.texture.CompCount = 2; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - lowerRect.width /= 2; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv2,false) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return precision.ToCode() + "2(" + texture.dataUniform[0] + "," + texture.dataUniform[1] + ")"; - } - - public override void DrawLowerPropertyBox() { - - if( selected && !SF_GUI.MultiSelectModifierHeld() ) - ColorPickerCorner(lowerRect); - - Vector4 cPrev = texture.dataUniform; - Rect tRect = lowerRect; - //SF_GUI.EnterableFloatField( this, tRect, ref texture.dataUniform.r, null ); - UndoableEnterableFloatField(tRect,ref texture.dataUniform.x, "R channel", null); - tRect.x += tRect.width; - //SF_GUI.EnterableFloatField( this, tRect, ref texture.dataUniform.g, null ); - UndoableEnterableFloatField(tRect,ref texture.dataUniform.y, "G channel", null); - if( texture.dataUniform != cPrev ) - OnUpdateNode(); - - } - - - public override string SerializeSpecialData() { - string s = "v1:" + texture.dataUniform[0] + ","; - s += "v2:" + texture.dataUniform[1]; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "v1": - float fVal1 = float.Parse( value ); - texture.dataUniform[0] = fVal1; - break; - case "v2": - float fVal2 = float.Parse( value ); - texture.dataUniform[1] = fVal2; - break; - } - } - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector2.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector2.cs.meta deleted file mode 100755 index 9b05d822..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector2.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a4a9e941838527c4ab45dac110a4c10c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector3.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector3.cs deleted file mode 100755 index d5e5bb56..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector3.cs +++ /dev/null @@ -1,89 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_Vector3 : SF_Node { - - - public SFN_Vector3() { - - } - - public override void Initialize() { - node_height /= 2; - base.Initialize( "Vector 3" ); - base.showColor = true; - base.UseLowerPropertyBox( true ); - base.texture.uniform = true; - base.canAlwaysSetPrecision = true; - base.texture.CompCount = 3; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - lowerRect.width /= 3; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv3,false) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return precision.ToCode() + "3(" + texture.dataUniform[0] + "," + texture.dataUniform[1] + "," + texture.dataUniform[2] + ")"; - } - - public override void DrawLowerPropertyBox() { - - if( selected && !SF_GUI.MultiSelectModifierHeld() ) - ColorPickerCorner( lowerRect ); - - //Color vecPrev = texture.dataUniform; - Rect tRect = lowerRect; - UndoableEnterableFloatField( tRect, ref texture.dataUniform.x, "R channel", null); - tRect.x += tRect.width; - UndoableEnterableFloatField( tRect, ref texture.dataUniform.y, "G channel", null); - tRect.x += tRect.width; - UndoableEnterableFloatField( tRect, ref texture.dataUniform.z, "B channel", null); - } - - public override string SerializeSpecialData() { - string s = "v1:" + texture.dataUniform[0] + ","; - s += "v2:" + texture.dataUniform[1] + ","; - s += "v3:" + texture.dataUniform[2]; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "v1": - float fVal1 = float.Parse( value ); - texture.dataUniform[0] = fVal1; - break; - case "v2": - float fVal2 = float.Parse( value ); - texture.dataUniform[1] = fVal2; - break; - case "v3": - float fVal3 = float.Parse( value ); - texture.dataUniform[2] = fVal3; - break; - } - } - - - // public override float[] GetVectorWithCompCount(int cCount){ - // if(cCount == 3) - // return vec; - // else - // Debug.LogWarning("Vector3 not convertible to vector" + cCount); // Vector3 is not convertible to any other - // } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector3.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector3.cs.meta deleted file mode 100755 index df78be29..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector3.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9641f0761fe611c47bbca6329cbedc20 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4.cs deleted file mode 100755 index ae76d8fe..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4.cs +++ /dev/null @@ -1,89 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - public class SFN_Vector4 : SF_Node { - - - public SFN_Vector4() { - - } - - public override void Initialize() { - node_height /= 2; - base.Initialize( "Vector 4" ); - base.showColor = true; - base.UseLowerPropertyBox( true ); - base.texture.uniform = true; - base.texture.CompCount = 4; - base.canAlwaysSetPrecision = true; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - lowerRect.width /= 4; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv4,false) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return precision.ToCode() + "4(" + texture.dataUniform[0] + "," + texture.dataUniform[1] + "," + texture.dataUniform[2] + "," + texture.dataUniform[3] + ")"; - } - - - public override void DrawLowerPropertyBox() { - - if( selected && !SF_GUI.MultiSelectModifierHeld() ) - ColorPickerCorner( lowerRect ); - - //Color vecPrev = texture.dataUniform; - Rect tRect = lowerRect; - UndoableEnterableFloatField( tRect, ref texture.dataUniform.x, "R channel", null); - tRect.x += tRect.width; - UndoableEnterableFloatField( tRect, ref texture.dataUniform.y, "G channel", null); - tRect.x += tRect.width; - UndoableEnterableFloatField( tRect, ref texture.dataUniform.z, "B channel", null); - tRect.x += tRect.width; - UndoableEnterableFloatField( tRect, ref texture.dataUniform.w, "A channel", null); - - } - - public override string SerializeSpecialData() { - string s = "v1:" + texture.dataUniform[0] + ","; - s += "v2:" + texture.dataUniform[1] + ","; - s += "v3:" + texture.dataUniform[2] + ","; - s += "v4:" + texture.dataUniform[3]; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - switch( key ) { - case "v1": - float fVal1 = float.Parse( value ); - texture.dataUniform[0] = fVal1; - break; - case "v2": - float fVal2 = float.Parse( value ); - texture.dataUniform[1] = fVal2; - break; - case "v3": - float fVal3 = float.Parse( value ); - texture.dataUniform[2] = fVal3; - break; - case "v4": - float fVal4 = float.Parse( value ); - texture.dataUniform[3] = fVal4; - break; - } - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4.cs.meta deleted file mode 100755 index a6483068..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6cd58b55cabc56347876d1fad012dbb4 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4Property.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4Property.cs deleted file mode 100755 index 92da37b3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4Property.cs +++ /dev/null @@ -1,112 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - public class SFN_Vector4Property : SF_Node { - - - public SFN_Vector4Property() { - - } - - public override void Initialize() { - base.Initialize( "Vector 4" ); - base.showColor = true; - base.UseLowerPropertyBox( true ); - base.neverDefineVariable = true; - base.texture.uniform = true; - base.texture.CompCount = 4; - base.shaderGenMode = ShaderGenerationMode.OffUniform; - lowerRect.width /= 4; - - property = ScriptableObject.CreateInstance().Initialize( this ); - - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"XYZ","XYZ",ConType.cOutput,ValueType.VTv3) .Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"X","X",ConType.cOutput,ValueType.VTv1) .WithColor(Color.red) .Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"Y","Y",ConType.cOutput,ValueType.VTv1) .WithColor(Color.green) .Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"Z","Z",ConType.cOutput,ValueType.VTv1) .WithColor(Color.blue) .Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"W","W",ConType.cOutput,ValueType.VTv1) .Outputting(OutChannel.A) - }; - } - - public override bool IsUniformOutput() { - return true; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return property.GetVariable(); - } - - - public override void DrawLowerPropertyBox() { - - Vector4 vecPrev = texture.dataUniform; - - if( !IsGlobalProperty() && selected && !SF_GUI.MultiSelectModifierHeld() ) - ColorPickerCorner( lowerRect ); - - PrepareWindowColor(); - if(IsGlobalProperty()){ - texture.dataUniform[0] = texture.dataUniform[1] = texture.dataUniform[2] = 0.5f; - texture.dataUniform[3] = 1f; - GUI.enabled = false; - } - Rect tRect = lowerRect; - texture.dataUniform[0] = UndoableFloatField(tRect, texture.dataUniform[0], "R channel"); - tRect.x += tRect.width; - texture.dataUniform[1] = UndoableFloatField(tRect, texture.dataUniform[1], "G channel"); - tRect.x += tRect.width; - texture.dataUniform[2] = UndoableFloatField(tRect, texture.dataUniform[2], "B channel"); - tRect.x += tRect.width; - texture.dataUniform[3] = UndoableFloatField(tRect, texture.dataUniform[3], "A channel"); - if(IsGlobalProperty()){ - GUI.enabled = true; - } - ResetWindowColor(); - if( texture.dataUniform != vecPrev ) { - OnUpdateNode( NodeUpdateType.Soft ); - editor.shaderEvaluator.ApplyProperty( this ); - } - - } - - public override string SerializeSpecialData() { - string s = property.Serialize() + ","; - s += "v1:" + texture.dataUniform[0] + ","; - s += "v2:" + texture.dataUniform[1] + ","; - s += "v3:" + texture.dataUniform[2] + ","; - s += "v4:" + texture.dataUniform[3]; - return s; - } - - public override void DeserializeSpecialData( string key, string value ) { - property.Deserialize(key,value); - switch( key ) { - case "v1": - float fVal1 = float.Parse( value ); - texture.dataUniform[0] = fVal1; - break; - case "v2": - float fVal2 = float.Parse( value ); - texture.dataUniform[1] = fVal2; - break; - case "v3": - float fVal3 = float.Parse( value ); - texture.dataUniform[2] = fVal3; - break; - case "v4": - float fVal4 = float.Parse( value ); - texture.dataUniform[3] = fVal4; - break; - } - } - - - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4Property.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4Property.cs.meta deleted file mode 100755 index 4f04747b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_Vector4Property.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 23b7c804c8bc56748a714271c303569f -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorProjection.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorProjection.cs deleted file mode 100755 index f7028ae2..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorProjection.cs +++ /dev/null @@ -1,59 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_VectorProjection : SF_Node_Arithmetic { - - public SFN_VectorProjection() { - - } - - public override void Initialize() { - base.Initialize( "Vector Project." ); - base.PrepareArithmetic( 2 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - GetConnectorByStringID("A").usageCount = 1; - GetConnectorByStringID("B").usageCount = 4; - } - - public override string[] GetBlitOutputLines() { - string dotLeft = "_b * dot(_a,_b)"; - string dotRight = "dot(_b,_b)"; - string retStr = "(" + dotLeft + "/" + dotRight + ")"; - return new string[] { retStr }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string a = GetConnectorByStringID( "A" ).TryEvaluate(); - string b = GetConnectorByStringID( "B" ).TryEvaluate(); - - string dotLeft = b + " * dot(" + a + "," + b + ")"; - string dotRight = "dot(" + b + "," + b + ")"; - - string retStr = "(" + dotLeft + "/" + dotRight + ")"; - - return retStr; - } - - public override Vector4 EvalCPU() { - - Vector4 a = GetInputData( "A" ).dataUniform; - Vector4 b = GetInputData( "B" ).dataUniform; - - int cc = Mathf.Max(GetInputCon( "A" ).GetCompCount(), GetInputCon( "B" ).GetCompCount()); - - float dotLeft = SF_Tools.Dot( a, b, cc ); - float dotRight = SF_Tools.Dot( b, b, cc ); - - Vector4 retVec = (dotLeft/dotRight) * b; - - return retVec; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorProjection.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorProjection.cs.meta deleted file mode 100644 index 63c93aff..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorProjection.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 50e107124a8704b46bc0d1757615d87f -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorRejection.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorRejection.cs deleted file mode 100755 index 95eb7e1d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorRejection.cs +++ /dev/null @@ -1,59 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_VectorRejection : SF_Node_Arithmetic { - - public SFN_VectorRejection() { - - } - - public override void Initialize() { - base.Initialize( "Vector Reject." ); - base.PrepareArithmetic( 2 ); - base.shaderGenMode = ShaderGenerationMode.CustomFunction; - GetConnectorByStringID("A").usageCount = 2; - GetConnectorByStringID("B").usageCount = 4; - } - - public override string[] GetBlitOutputLines() { - string dotLeft = "_b * dot(_a,_b)"; - string dotRight = "dot(_b,_b)"; - string retStr = "(_a - (" + dotLeft + "/" + dotRight + "))"; - return new string[] { retStr }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - - string a = GetConnectorByStringID( "A" ).TryEvaluate(); - string b = GetConnectorByStringID( "B" ).TryEvaluate(); - - string dotLeft = b + " * dot(" + a + "," + b + ")"; - string dotRight = "dot(" + b + "," + b + ")"; - - string retStr = "(" + a + " - (" + dotLeft + "/" + dotRight + "))"; - - return retStr; - } - - public override Vector4 EvalCPU() { - - Vector4 a = GetInputData( "A" ).dataUniform; - Vector4 b = GetInputData( "B" ).dataUniform; - - int cc = Mathf.Max(GetInputCon( "A" ).GetCompCount(), GetInputCon( "B" ).GetCompCount()); - - float dotLeft = SF_Tools.Dot( a, b, cc ); - float dotRight = SF_Tools.Dot( b, b, cc ); - - Vector4 retVec = a - (dotLeft/dotRight) * b; - - return retVec; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorRejection.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorRejection.cs.meta deleted file mode 100644 index 3c81869c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VectorRejection.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5e6f56ecc8b1f4edfbfa9eae75988a2b -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VertexColor.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VertexColor.cs deleted file mode 100755 index c05b0a49..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VertexColor.cs +++ /dev/null @@ -1,35 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_VertexColor : SF_Node { - - - public SFN_VertexColor() { - - } - - public override void Initialize() { - base.Initialize( "Vertex Color", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 4; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"RGB","RGB",ConType.cOutput,ValueType.VTv3,false).Outputting(OutChannel.RGB), - SF_NodeConnector.Create(this,"R","R",ConType.cOutput, ValueType.VTv1) .WithColor(Color.red) .Outputting(OutChannel.R), - SF_NodeConnector.Create(this,"G","G",ConType.cOutput,ValueType.VTv1) .WithColor(Color.green) .Outputting(OutChannel.G), - SF_NodeConnector.Create(this,"B","B",ConType.cOutput,ValueType.VTv1) .WithColor(Color.blue) .Outputting(OutChannel.B), - SF_NodeConnector.Create(this,"A","A",ConType.cOutput,ValueType.VTv1) .Outputting(OutChannel.A) - }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return SF_Evaluator.WithProgramPrefix( "vertexColor" ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VertexColor.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VertexColor.cs.meta deleted file mode 100755 index 88c5b423..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_VertexColor.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8e5d87afa7814f644a9e0493dd32ca91 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewPosition.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewPosition.cs deleted file mode 100755 index 8ce23357..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewPosition.cs +++ /dev/null @@ -1,38 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ViewPosition : SF_Node { - - - public SFN_ViewPosition() { - - } - - public override void Initialize() { - base.Initialize( "View Pos.", InitialPreviewRenderMode.BlitQuad ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 3; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"XYZ","XYZ",ConType.cOutput,ValueType.VTv3,false), - SF_NodeConnector.Create(this,"X","X",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.R).WithColor(Color.red), - SF_NodeConnector.Create(this,"Y","Y",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.G).WithColor(Color.green), - SF_NodeConnector.Create(this,"Z","Z",ConType.cOutput,ValueType.VTv1,false).Outputting(OutChannel.B).WithColor(Color.blue) - }; - } - - public override Vector4 EvalCPU() { - return new Color( 0f, 0.7071068f, 0.7071068f, 0f ); - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "_WorldSpaceCameraPos"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewPosition.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewPosition.cs.meta deleted file mode 100755 index e068de70..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewPosition.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2aeeefb42d9a9784dabd94b3d82c05bc -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewReflectionVector.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewReflectionVector.cs deleted file mode 100755 index 71455e59..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewReflectionVector.cs +++ /dev/null @@ -1,31 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ViewReflectionVector : SF_Node { - - - public SFN_ViewReflectionVector() { - - } - - public override void Initialize() { - base.Initialize( "View Refl.", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 3; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv3,false) - }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "viewReflectDirection"; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewReflectionVector.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewReflectionVector.cs.meta deleted file mode 100755 index d87b761d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewReflectionVector.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2f7ebdd9ba1b27c4e8f26cc468d8d810 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewVector.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewVector.cs deleted file mode 100755 index 7c3d6378..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewVector.cs +++ /dev/null @@ -1,32 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFN_ViewVector : SF_Node { - - - public SFN_ViewVector() { - - } - - public override void Initialize() { - base.Initialize( "View Dir.", InitialPreviewRenderMode.BlitSphere ); - base.showColor = true; - base.UseLowerPropertyBox( false ); - base.texture.CompCount = 3; - base.neverDefineVariable = true; - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create(this,"OUT","",ConType.cOutput,ValueType.VTv3,false) - }; - } - - public override string Evaluate( OutChannel channel = OutChannel.All ) { - return "viewDirection"; - } - - } - -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewVector.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewVector.cs.meta deleted file mode 100755 index f9bcc76f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SFN_ViewVector.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e6425e0019e46fd429bb6fb731bfb0be -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node.cs deleted file mode 100755 index acded025..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node.cs +++ /dev/null @@ -1,2661 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Xml; -using System; - - -namespace ShaderForge { - - public enum NodeUpdateType { Soft, Hard }; - public enum ShaderGenerationMode { - OffUniform, // No shader written - Modal, // Requires modes or C# intervention, Array of suffixes & Array of custom outputs - Manual, // Fully manually written - ManualModal, // Manually written, with modes - ValuePassing, // Floats are sent from the node to the material before render - SimpleFunction, // Generates a name(inputs) - CustomFunction, // Generates a custom output line - ModularInput // Generates 5 shaders for different input counts - }; - - public enum InitialPreviewRenderMode { Off, BlitQuad, BlitSphere }; - - - [System.Serializable] - public class SF_Node : ScriptableObject, IDependable { - - public const int NODE_SIZE = 96; - public const int NODE_WIDTH = NODE_SIZE + 3; // This fits a NODE_SIZE texture inside - public const int NODE_HEIGHT = NODE_SIZE + 16; // This fits a NODE_SIZE texture inside - - public int node_width = NODE_WIDTH; - public int node_height = NODE_HEIGHT; - - public ShaderGenerationMode shaderGenMode = ShaderGenerationMode.Manual; - - public int depth = 0; // Used when deserializing and updating - - public string _variableName; - public string variableName{ - get{ - if(string.IsNullOrEmpty(_variableName) && GUI.GetNameOfFocusedControl() != VarNameControl() ){ - ResetVariableName(); - } - return _variableName; - } - set{ - _variableName = value; - if(IsProperty() && property.overrideInternalName){ - property.UpdateInternalName(); - } - SF_Tools.FormatSerializableVarName(ref _variableName); - } - } - - public bool canAlwaysSetPrecision = false; - public bool isFloatPrecisionBasedVariable = true; - public bool lockedVariableName = false; - public FloatPrecision precision = FloatPrecision.Float; - - string[] _precisionLabels; - public string[] precisionLabels{ - get{ - if(_precisionLabels == null || _precisionLabels.Length == 0){ - _precisionLabels = FloatPrecision.Float.DisplayStrings(); - } - return _precisionLabels; - } - } - -// string[] _precisionLabelsSimple; -// public string[] precisionLabelsSimple{ -// get{ -// if(_precisionLabelsSimple == null){ -// _precisionLabelsSimple = new string[3]; -// for(int i=0;i<3;i++){ -// _precisionLabelsSimple[i] = ((FloatPrecision)i).ToString().ToLower(); -// } -// } -// return _precisionLabelsSimple; -// } -// } - - public bool isGhost = false; - - public bool selected = false; - - public bool discreteTitle = false; - - public bool varDefined = false; // Whether or not this node has had its variable defined already. - public bool varPreDefined = false; // Whether or not this variable has done its predefs - public bool alwaysDefineVariable = false; - public bool neverDefineVariable = false; - public bool onlyPreDefine = false; // If it should only do the pre-define, and skip the regular variable or not (Used in branching) - public bool availableInDeferredPrePass = true; - - public static Color colorExposed = new Color( 0.8f, 1f, 0.9f ); - public static Color colorExposedDim = new Color( 0.8f, 1f, 0.9f )*0.8f; - public static Color colorExposedDark = new Color( 0.24f, 0.32f, 0.30f ) * 1.25f; - public static Color colorExposedDarker = new Color( 0.24f, 0.32f, 0.30f ) * 0.75f; - - public static Color colorGlobal = new Color( 1f, 0.8f, 0.7f); // ( 1f, 0.9f, 0.8f); - - public void UndoRecord(string undoMsg, UpToDateState tempOutdatedState = UpToDateState.OutdatedHard){ - SetDirty(tempOutdatedState); // This will only be in the restored undo state - Undo.RecordObject(this,undoMsg); - if(texture != null) - Undo.RecordObject(texture, undoMsg); - if(property != null) - Undo.RecordObject(property, undoMsg); - if(status != null) - Undo.RecordObject(status, undoMsg); - foreach(SF_NodeConnector con in connectors){ - Undo.RecordObject(con, undoMsg); - } - SetDirty(UpToDateState.UpToDate); // Might need to comment this for Redo to work, it seems - } - - public void ResetVariableName() { - _variableName = "node_" + id; - } - - - public Color colorDefault{ - get{ - if(SF_GUI.ProSkin) - return new Color( 0.8f, 0.8f, 0.8f); - else - return new Color( 1f, 1f, 1f ); - } - } - - public bool showColor; - public Color displayColor = Color.black; - - public SF_ShaderProperty property = null; - - public SF_NodeStatus status; - - public SF_Editor editor; - - public ShaderProgram program = ShaderProgram.Any; - - // User typed comment - public string comment = ""; - //public bool hasComment; - - public bool showLowerPropertyBox; - public bool showLowerPropertyBoxAlways; - public bool showLowerReadonlyValues; - public bool initialized = false; - - - //public int depth = 0; // Used to sort variable initialization - - // public static bool DEBUG = false; - - - public SF_NodePreview texture; - // public float[] vector; - - - - public int id; - - public string nodeName; - private string nodeNameSearch; - public string SearchName{ - get{ - if(string.IsNullOrEmpty(nodeNameSearch)){ - return nodeName; - } else { - return nodeNameSearch; - } - } - set{ - nodeNameSearch = value; - } - } - - public Rect rect; - public Rect rectInner; - public Rect lowerRect; - - [SerializeField] - public SF_NodeConnector[] connectors; - - public SF_NodeConnectionGroup conGroup; - - public float extraWidthOutput = 0f; - public float extraWidthInput = 0f; - - public SF_Node() { - //Debug.Log("NODE " + GetType()); - } - - // Quick retrieval of connectors - public SF_NodeConnector this[string s] { - get { - return GetConnectorByStringID(s); - } - } - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - #region IDependable implementation - - private List dependencies; - public int iDepth = 0; - void IDependable.AddDependency (SF_Node dp){ - (this as IDependable).Dependencies.Add(dp); - } - - int IDependable.Depth { - get { - return iDepth; - } - set { - iDepth = value; - } - } - - List IDependable.Dependencies { - get { - if(dependencies == null){ - dependencies = new List(); - } - return dependencies; - } - set { - dependencies = value; - } - } - - - public void ReadDependencies(){ - (this as IDependable).Dependencies.Clear(); - foreach(SF_NodeConnector c in connectors){ - if(c.conType == ConType.cOutput) - continue; - if(!c.IsConnectedAndEnabled()) - continue; - if(c.inputCon == null) - continue; - (this as IDependable).AddDependency(c.inputCon.node); - } - } - - - #endregion - - public bool IsProperty() { - if( property == null ) - return false; - if( string.IsNullOrEmpty( property.nameType ) ) { - property = null; - return false; - } - return true; - } - - public bool IsGlobalProperty(){ - return IsProperty() ? property.global : false; - } - - public virtual bool UpdatesOverTime() { - return false; // Override on nodes like Time, Panner and Rotator - } - - - // TODO: Matrices & Samplers? - public string GetVariableType() { - - - // HACK - if( this is SFN_Transpose ) { - return precision.ToCode() + "4x4"; - } - - if( this is SFN_Matrix4x4 ) { - return precision.ToCode() + "4x4"; - } - - if( this is SFN_Matrix4x4Property ) { - return precision.ToCode() + "4x4"; - } - - if( this is SFN_MultiplyMatrix ) { - if( GetConnectorByStringID( "OUT" ).IsConnected() ) { - if( GetConnectorByStringID( "OUT" ).valueType == ValueType.VTm4x4) - return precision.ToCode() + "4x4"; - else - return precision.ToCode() + "4"; - } - } - - if( this is SFN_Code ) { - if( GetConnectorByStringID( "OUT" ).IsConnected() ) { - if( GetConnectorByStringID( "OUT" ).valueType == ValueType.VTm4x4) - return precision.ToCode() + "4x4"; - } - } - - - int cc = GetEvaluatedComponentCount(); - if( cc == 0 ) - cc = texture.CompCount; - - string precisionStr = precision.ToCode(); - - - if(cc == 1) - return precisionStr; - return precisionStr + cc; - - //if( texture.CompCount == 1 ) - // return "float"; - //return "float" + texture.CompCount; - } - - public string GetVariableName(bool createIfNull = true) { - if(IsProperty()){ - if(ShouldDefineVariable() && !neverDefineVariable) - return property.nameInternal + "_var"; - else if( neverDefineVariable) - return property.nameInternal; - } - if( createIfNull && string.IsNullOrEmpty( variableName ) ) - ResetVariableName(); - return variableName; - } - - public virtual void Initialize() { - // Override - } - - - public SF_NodeConnector[] ConnectedInputs{ - get{ - return connectors.Where(con=>con.IsConnectedAndEnabled() && con.conType == ConType.cInput).Select(con=>con).ToArray(); - } - } - - - // Used for 3D data like normal/view vector, etc. - public bool vectorDataNode = false; - public bool displayVectorDataMask = false; - - public void UpdateDisplayVectorDataMask(){ - displayVectorDataMask = CheckIfShouldDisplayVectorDataMask(); - } - - public bool CheckIfShouldDisplayVectorDataMask(){ - if(vectorDataNode){ - return true; - } else { - bool disp = false; - foreach(SF_NodeConnector con in ConnectedInputs){ - if(con.inputCon.node.displayVectorDataMask){ - disp = true; - break; - } - } - return disp; - } - } - - public InitialPreviewRenderMode initialPreviewMode; - - public void Initialize( string name, InitialPreviewRenderMode initialPreviewMode = InitialPreviewRenderMode.Off ) { - this.initialPreviewMode = initialPreviewMode; - editor = SF_Editor.instance; // TODO, pass in a better way - status = ScriptableObject.CreateInstance().Initialize(this); - Vector2 pos = editor.mousePosition; // TODO: check where to spawn first - AssignID(); - this.nodeName = name; - if( SF_Debug.nodes ) - this.nodeName = ( "[" + id + "] " + this.nodeName ); - texture = ScriptableObject.CreateInstance().Initialize( this ); - texture.Fill( Color.black ); - - - - - GenerateBaseData(); - - - texture.LoadAndInitializeIcons(this.GetType()); - - - - /* - // Try to find icon - if(vectorDataTexture){ - vectorDataNode = true; - displayVectorDataMask = true; - texture.LoadDataTexture(this.GetType()); - }*/ - - - pos = editor.nodeView.ScreenSpaceToZoomSpace( pos ); - InitializeDefaultRect( pos ); - } - - public void GenerateBaseData() { - if( initialPreviewMode != InitialPreviewRenderMode.Off ) { - bool preferQuad = initialPreviewMode == InitialPreviewRenderMode.BlitQuad; - bool sphereWhen3D = SF_Settings.nodeRenderMode != NodeRenderMode.Viewport; - bool canRenderQuads = SF_Settings.nodeRenderMode == NodeRenderMode.Mixed; - - if( preferQuad && canRenderQuads ) { - vectorDataNode = false; // ? - displayVectorDataMask = false; - texture.GenerateBaseData( render3D: false ); - } else { - vectorDataNode = sphereWhen3D; - displayVectorDataMask = sphereWhen3D; - texture.GenerateBaseData( render3D: true ); - } - - } else if( texture.uniform && IsUniformOutput() ) { - texture.GenerateBaseData( false ); - } - } - - public void AssignID() { - this.id = editor.GetUniqueNodeID(); - } - - public virtual void OnPreGetPreviewData() { - // Override - } - - public virtual string GetPrepareUniformsAndFunctions(){ - return string.Empty; // Override - } - - - public virtual void Update() { - - // TODO: REALTIME - // - if( SF_Settings.RenderNodesInRealtime() ) { - if( UpdatesOverTime() || initialPreviewMode != InitialPreviewRenderMode.Off ) { - SetDirty( UpToDateState.OutdatedSoft ); - GenerateBaseData(); - } - } - // Override - } - - public void InitializeDefaultRect( Vector2 pos ) { - - - this.rect = new Rect( - pos.x - node_width / 2, - pos.y - node_height / 2, - node_width, - ( showLowerPropertyBox ? ( node_height ) : ( node_height + 20 ) ) ); // TODO: This seems a bit reversed... - rectInner = rect; - rectInner.x = 1; - rectInner.y = 15; - rectInner.width = node_width - 3; - rectInner.height = node_height - 16; - - lowerRect = rectInner; - lowerRect.y += rectInner.height; - lowerRect.height = 20; - - - } - - - public bool IsDescendantOf( SF_Node other ) { - foreach( SF_NodeConnector con in other.connectors ) { - if( con.conType != ConType.cOutput ) - continue; - if( !con.IsConnectedAndEnabled() ) - continue; - foreach( SF_NodeConnector oCon in con.outputCons ) { - if( oCon.node == this ) { - return true; - } else if( this.IsDescendantOf( oCon.node ) ) { - return true; - } - } - } - return false; - } - - - public bool IsChildOf( SF_Node other ) { - foreach( SF_NodeConnector con in other.connectors ) { - if( con.conType != ConType.cOutput ) - continue; - if( !con.IsConnectedAndEnabled() ) - continue; - foreach( SF_NodeConnector oCon in con.outputCons ) { - if( oCon.node == this ) - return true; - } - } - return false; - } - - - - - - - - - public void UndoableToggle(Rect r, ref bool boolVar, string label, string undoActionName, GUIStyle style){ - if(style == null) - style = EditorStyles.toggle; - bool newValue = GUI.Toggle(r,boolVar,label, style); - if(newValue != boolVar){ - UndoRecord((newValue ? "enable" : "disable") + " " + undoActionName); - boolVar = newValue; - } - } - - public Enum UndoableEnumPopup( Rect r, Enum enumValue, string undoPrefix ) { - Enum nextEnum = EditorGUI.EnumPopup( r, enumValue ); - if( nextEnum.ToString() != enumValue.ToString() ) { - string undoName = undoPrefix + " to " + nextEnum; - UndoRecord( undoName ); - enumValue = nextEnum; - } - return enumValue; - } - - public int UndoableEnumPopupNamed(Rect r, int enumValue, string[] names, string undoPrefix){ - int nextEnum = EditorGUI.Popup( r, enumValue, names ); - if(nextEnum != enumValue){ - string undoName = undoPrefix + " to " + nextEnum; - UndoRecord(undoName); - return nextEnum; - } - return enumValue; - } - - public Enum UndoableLabeledEnumPopup(Rect r, string label, Enum enumValue, string undoPrefix){ - Enum nextEnum = SF_GUI.LabeledEnumField( r, label, enumValue, EditorStyles.miniLabel ); - if(nextEnum.ToString() != enumValue.ToString()){ - UndoRecord(undoPrefix + " to " + nextEnum); - Undo.IncrementCurrentGroup(); - enumValue = nextEnum; - } - return enumValue; - } - - - public int UndoablePopup(Rect r, int selected, string[] displayedOptions, string undoPrefix, GUIStyle style = null){ - if(style == null) - style = EditorStyles.popup; - int pickedID = EditorGUI.Popup( r, selected, displayedOptions,style); - if(pickedID != selected){ - UndoRecord(undoPrefix + " to " + displayedOptions[pickedID]); - selected = pickedID; - } - return selected; - } - - //EditorGUI.FloatField( r, texture.dataUniform[0], SF_Styles.LargeTextField ); - - public float UndoableFloatField(Rect r, float value, string undoInfix, GUIStyle style = null){ - if(style == null) - style = EditorStyles.textField; - float newValue = EditorGUI.FloatField( r, value, style ); - if(newValue != value){ - if(IsProperty() || IsGlobalProperty()){ - UndoRecord("set " + undoInfix + " of " + (IsGlobalProperty() ? property.nameInternal : property.nameDisplay)); - } else { - UndoRecord("set " + undoInfix + " of " + nodeName + " node"); - } - return newValue; - } - return value; - } - - // (r, ref texture.dataUniform.r, "value", SF_Styles.LargeTextField); - - public void UndoableEnterableFloatField(Rect r, ref float value, string undoInfix, GUIStyle style){ - if(style == null) - style = EditorStyles.textField; - float previousValue = value; - SF_GUI.EnterableFloatField(this, r, ref value, style ); - float newValue = value; - if(previousValue != value){ - value = previousValue; - - UndoRecord("set " + undoInfix + " of " + nodeName + " node"); - value = newValue; - } - } - - public float UndoableHorizontalSlider(Rect r, float value, float min, float max, string undoInfix){ - float newValue = GUI.HorizontalSlider( r, value, min, max ); - if(newValue != value){ - if(IsProperty() || IsGlobalProperty()){ - UndoRecord("set " + undoInfix + " of " + (IsGlobalProperty() ? property.nameInternal : property.nameDisplay)); - } else { - UndoRecord("set " + undoInfix + " of " + nodeName + " node"); - } - return newValue; - } - return value; - } - - // code = GUI.TextArea(txtRect,code,SF_Styles.CodeTextArea); - public string UndoableTextArea(Rect r, string value, string undoInfix, GUIStyle style){ - string newValue = EditorGUI.TextArea( r, value, style ); - if(newValue != value){ - if(this is SFN_Code){ - UndoRecord("edit " + undoInfix + " of " + (this as SFN_Code).functionName); - } else if(IsProperty() || IsGlobalProperty()){ - UndoRecord("edit " + undoInfix + " of " + (IsGlobalProperty() ? property.nameInternal : property.nameDisplay)); - } else { - UndoRecord("edit " + undoInfix + " of " + nodeName + " node"); - } - - return newValue; - } - return value; - } - - public string UndoableTextField(Rect r, string value, string undoInfix, GUIStyle style, bool readPropertyName = true){ - if(style == null) - style = EditorStyles.textField; - string newValue = EditorGUI.TextField( r, value, style ); - if(newValue != value){ - if(this is SFN_Code && readPropertyName){ - UndoRecord("edit " + undoInfix + " of " + (this as SFN_Code).functionName); - } else if( ( IsProperty() || IsGlobalProperty() ) && readPropertyName){ - UndoRecord("edit " + undoInfix + " of " + (IsGlobalProperty() ? property.nameInternal : property.nameDisplay)); - } else { - UndoRecord("edit " + undoInfix + " of " + nodeName + " node"); - } - - return newValue; - } - return value; - } - - public Color UndoableColorField(Rect r, Color color, string undoMsg){ - Color newColor = EditorGUI.ColorField( r, color ); - if(newColor != color){ - UndoRecord(undoMsg); - return newColor; - } - return color; - } - - - - // UndoableTextField - - - - /* - public int UndoableEnterableTextField(Rect r, ref string str, ){ - - SF_GUI.EnterableTextField(this, r, - - }*/ - - - - - - - - - - - - - - - - // public virtual void OnConnectedNode(){ - // Debug.Log("OnConnectedNode " + name); - // } - - public void MakeChildrenOutdated( UpToDateState state ) { - foreach( SF_NodeConnector mCon in connectors ) { - if( mCon == null ) - continue; - if( mCon.conType == ConType.cOutput ) { - for( int i = 0; i < mCon.outputCons.Count; i++ ) { - SF_NodeConnector mConOut = mCon.outputCons[i]; - mConOut.node.dirtyState = state; - //mConOut.node.MakeChildrenOutdated( state ); // Recursive is super expensive - } - } - } - } - - public virtual void OnUpdateNode( NodeUpdateType updType = NodeUpdateType.Hard, bool cascade = true ) { - - //Debug.Log("Updating " + nodeName); - - - - if( conGroup != null ) - conGroup.Refresh(); - - if( !InputsConnected() ) { - //Debug.Log("Detected missing input on obj " + name); - texture.OnLostConnection(); - } - - // Update texture if it's uniform for things like Color/Value etc. - if( texture.uniform ) { - //Debug.Log("Blitting uniform " + texture.dataUniform); - PrepareRendering( SF_Blit.mat ); - texture.GenerateBaseData(); - } - - RefreshValue(); // Refresh this value - - if( IsProperty() ) - editor.shaderEvaluator.ApplyProperty(this); - - if( cascade ) - if( connectors != null && connectors.Length > 0 ) - foreach( SF_NodeConnector mCon in connectors ) { - if( mCon == null ) - continue; - if( mCon.conType == ConType.cOutput ) { - for (int i = 0; i < mCon.outputCons.Count; i++) { - SF_NodeConnector mConOut = mCon.outputCons [i]; - UpToDateState state = (updType == NodeUpdateType.Soft) ? UpToDateState.OutdatedSoft : UpToDateState.OutdatedHard; - mConOut.node.dirtyState = state; - mConOut.node.MakeChildrenOutdated( state ); - //mConOut.node.OnUpdateNode (updType); - // TODO Null ref - } - } - } - - UpdateDisplayVectorDataMask(); - - editor.OnShaderModified( NodeUpdateType.Soft ); - //if(!SF_Parser.quickLoad && !isGhost) - //Repaint(); - - } - - public void ChainAppendIfConnected(ref string evalStr, string op, params string[] cons ){ - foreach(string con in cons){ - if(GetInputIsConnected(con)){ - evalStr += op + GetConnectorByStringID(con).TryEvaluate(); - } - } - } - - - public void SetExtensionConnectorChain(params string[] cNames){ - - SF_NodeConnector con = GetConnectorByStringID(cNames[0]); - for(int i=1;i 1){ - if(c > cc-1){ - return 0f; - } - } - } - - - - //return GetInputData( id, x, y, c ); - return GetInputData( id ).dataUniform[c]; - } - - /* - public SF_NodePreview GetInputData( int id ) { - - if( connectors[id].inputCon == null ) { - Debug.LogWarning( "Attempt to find input node of connector " + id + " of " + this.nodeName ); - } - - return connectors[id].inputCon.node.texture; - }*/ - - public SF_NodePreview GetInputData( string id ) { - - SF_NodeConnector con = GetConnectorByStringID(id); - //SF_Node n; // TODO: What was this? Quite recent too. Define and undefine ghosts? - - if( con.inputCon == null ) { - - List tmpGhosts = new List(); - con.DefineGhostIfNeeded(ref tmpGhosts); - //n = tmpGhosts[0]; - tmpGhosts = null; - - Debug.LogWarning( "Attempt to find input node of connector " + id + " of " + this.nodeName ); - } - - //SF_NodePreview ret = con.inputCon.node.texture; - - - - - return con.inputCon.node.texture; - } - - /* - public SF_NodeConnection GetInputCon( int id ) { - if( connectors[id] == null ) { - Debug.LogError("Failed attempt to find connector [" + id + "] in " + this.nodeName); - return null; - } - if( connectors[id].inputCon == null ) { - Debug.LogError( "Failed attempt to find node of connector [" + id + "] on " + this.nodeName ); - return null; - } - return connectors[id].inputCon; - }*/ - - public int ReadComponentCountFromFirstOutput() { - if( connectors == null ) - return 4; - for( int i = 0; i < connectors.Length; i++ ) { - if( connectors[i].conType == ConType.cOutput ) { - return connectors[i].GetCompCount(); - } - } - Debug.LogWarning("No component count could be read from " + nodeName + " (" + variableName + ")"); - return 0; - } - - public SF_NodeConnector GetInputCon( string id ) { - SF_NodeConnector con = GetConnectorByStringID( id ); - - if( con == null ) { - Debug.LogError( "Failed attempt to find connector [" + id + "] in " + this.nodeName ); - return null; - } - if(con.inputCon == null) { - Debug.LogError( "Failed attempt to find input connector of [" + id + "] in " + this.nodeName ); - return null; - } - return con.inputCon; - } - - - public float BoundsTop(){ - - float top = rect.yMin; - - if(this.IsProperty()) - top -= 20; - if(HasComment()) - top -= 20; - - return top; - } - - public float BoundsBottom(){ - return rect.yMax; - } - - - public virtual int GetEvaluatedComponentCount() { - // Override - return 0; - } - - public bool CanEvaluate() { - //Debug.Log("Checking if can evaluate " + nodeName); - for( int i = 0; i < connectors.Length; i++ ) { - if( connectors[i].required ) - if( !connectors[i].IsConnected() ) - return false; - } - return true; - } - - - public void CheckForBrokenConnections() { - foreach( SF_NodeConnector con in connectors ) { - if( con.IsConnected() && con.conType == ConType.cInput ) { - if( con.inputCon.IsDeleted() ) - con.inputCon = null; - } - - } - } - - // public MaterialNode MakeDotProductNode(){ - // connectors = new MaterialNodeConnector[3]{ - // new MaterialNodeConnector(this,"A",ConType.cInput), - // new MaterialNodeConnector(this,"B",ConType.cInput), - // new MaterialNodeConnector(this,"Out",ConType.cOutput) - // }; - // return this; - // } - - - public void DrawConnections() { - foreach( SF_NodeConnector con in connectors ) - con.CheckConnection( editor ); - } - - public void Repaint() { - //SF_Editor.instance.Repaint(); - } - - public bool IsFocused() { - return rect.Contains( Event.current.mousePosition ); - } - - /* - public bool CheckIfDeleted() { - - if( Event.current.keyCode == KeyCode.Delete && Event.current.type == EventType.keyDown && selected ) { - Delete(true,"delete " + nodeName); - return true; - } - return false; - - }*/ - - public void PrepareWindowColor() { - - if(IsProperty()){ - if(property.global){ - GUI.color = colorGlobal; - } else { - GUI.color = colorExposed; // colorExposed - } - } else { - GUI.color = colorDefault; - } - } - - public void ResetWindowColor() { - GUI.color = colorDefault; - } - - - public void OnPress(){ - if( MouseOverNode( world: true ) && Event.current.isMouse ) { - editor.ResetRunningOutdatedTimer(); - if( !selected && !SF_GUI.MultiSelectModifierHeld() ) - editor.nodeView.selection.DeselectAll(registerUndo:true); - - StartDragging(); - - //if(!selected) - Event.current.Use(); - //Select(); - } - - } - - public void OnRelease() { - - - if(isDragging){ - isDragging = false; - Vector2 tmp = new Vector2(rect.x, rect.y); - rect.x = dragStart.x; - rect.y = dragStart.y; - UndoRecord("move " + nodeName + " node"); - rect.x = tmp.x; - rect.y = tmp.y; - - } - //isDragging = false; - - if( SF_NodeConnector.pendingConnectionSource != null ) - return; - - bool hover = MouseOverNode( world: true ); - bool stationary = dragDelta.sqrMagnitude < SF_Tools.stationaryCursorRadius; - bool placingNew = editor.nodeBrowser.IsPlacing(); - - if( hover && stationary && !placingNew ) { // If you released on the node without dragging - if( SF_GUI.MultiSelectModifierHeld() ) { - if( selected ) - Deselect(registerUndo:true); - else - Select(registerUndo:true); - Event.current.Use(); - } else if(!selected) { - editor.nodeView.selection.DeselectAll(registerUndo:true); - Select(registerUndo:true); - Event.current.Use(); - } - } - - } - - - public bool isDragging = false; - bool isEditingNodeTextField = false; - public static bool isEditingAnyNodeTextField = false; - - public void ContextClick( object o ) { - string picked = o as string; - switch(picked){ - case "prop_global_toggle": - property.ToggleGlobal(); - editor.ShaderOutdated = UpToDateState.OutdatedHard; - break; - case "doc_open": - SF_Web.OpenDocumentationForNode(this); - break; - case "cmt_edit": - editor.Defocus(deselectNodes:true); - GUI.FocusControl("node_comment_" + id); - isEditingNodeTextField = true; - SF_Node.isEditingAnyNodeTextField = true; - editor.ShaderOutdated = UpToDateState.OutdatedSoft; - break; - case "taghide": - property.tagHideInInspector = !property.tagHideInInspector; - editor.ShaderOutdated = UpToDateState.OutdatedHard; - break; - case "tagnsco": - property.tagNoScaleOffset = !property.tagNoScaleOffset; - editor.ShaderOutdated = UpToDateState.OutdatedHard; - break; - case "tagnrm": - property.tagNormal = !property.tagNormal; - editor.ShaderOutdated = UpToDateState.OutdatedHard; - break; - case "taghdr": - property.tagHDR = !property.tagHDR; - editor.ShaderOutdated = UpToDateState.OutdatedHard; - break; - case "tagprd": - property.tagPerRendererData = !property.tagPerRendererData; - editor.ShaderOutdated = UpToDateState.OutdatedHard; - break; - } - - } - - - public bool HasComment(){ - return !string.IsNullOrEmpty(comment); - } - - public bool UnavailableInThisRenderPath(){ - return editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred && !availableInDeferredPrePass; - } - - float commentYposTarget; - float commentYposCurrent; - - - public void DrawWindow() { - - - - - - - //Vector2 prev = new Vector2( rect.x, rect.y ); - //int prevCont = GUIUtility.hotControl; - - if(Event.current.type == EventType.repaint){ - commentYposCurrent = Mathf.Lerp(commentYposCurrent, commentYposTarget, 0.4f); - } - - - if(UnavailableInThisRenderPath()) - GUI.color = new Color(1f,1f,1f,0.5f); - GUI.Box( rect, nodeName, discreteTitle ? SF_Styles.NodeStyleDiscrete : SF_Styles.NodeStyle ); - - - // Draw lock - if(UnavailableInThisRenderPath()){ - SF_GUI.DrawLock(rect.PadTop(3), "This node is only available in forward rendering"); - } - - - if(!UnavailableInThisRenderPath()) - GUI.color = Color.white; - - - - - ResetWindowColor(); - //rect = GUI.Window( id, rect, NeatWindow, nodeName ); - NeatWindow(); - - // If you didn't interact with anything inside... - if( SF_GUI.PressedLMB() ) { - OnPress(); - } else if( SF_GUI.ReleasedRawLMB() ) { - OnRelease(); - } else if( Event.current.type == EventType.ContextClick ) { - //Vector2 mousePos = Event.current.mousePosition; - if( MouseOverNode( world: true ) ) { - // Now create the menu, add items and show it - GenericMenu menu = new GenericMenu(); - editor.ResetRunningOutdatedTimer(); - if(IsProperty() && property.CanToggleGlobal()){ - if(property.global){ - menu.AddItem( new GUIContent("Make local"), false, ContextClick, "prop_global_toggle" ); - } else { - menu.AddItem( new GUIContent("Make global"), false, ContextClick, "prop_global_toggle" ); - } - } - menu.AddItem( new GUIContent("Edit Comment"), false, ContextClick, "cmt_edit" ); - menu.AddItem( new GUIContent("What does " + nodeName + " do?"), false, ContextClick, "doc_open" ); - if( IsProperty() && property.global == false ) { - menu.AddSeparator( "" ); - menu.AddItem( new GUIContent( "[Hide in inspector]" ), property.tagHideInInspector, ContextClick, "taghide" ); - if( property is SFP_Tex2d ) { - menu.AddItem( new GUIContent( "[No scale and offset]" ), property.tagNoScaleOffset, ContextClick, "tagnsco" ); - menu.AddItem( new GUIContent( "[Accept normals only]" ), property.tagNormal, ContextClick, "tagnrm" ); - menu.AddItem( new GUIContent( "[Accept HDR only]" ), property.tagHDR, ContextClick, "taghdr" ); - menu.AddItem( new GUIContent( "[Per-renderer data]" ), property.tagPerRendererData, ContextClick, "tagprd" ); - } else if( property is SFP_Color ) { - menu.AddItem( new GUIContent( "[HDR color picker]" ), property.tagHDR, ContextClick, "taghdr" ); - } - // taghide tagnsco tagnrm taghdr tagprd - } - - - Matrix4x4 prevMatrix = GUI.matrix; - GUI.matrix = Matrix4x4.identity; // Odd hack, but, works - menu.ShowAsContext(); - GUI.matrix = prevMatrix; - Event.current.Use(); - } - } - - - - - if( isDragging && Event.current.isMouse) - OnDraggedWindow( Event.current.delta ); - - - - string focusName = "namelabel" + this.id; - if( Event.current.type == EventType.keyDown && ( Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter ) && GUI.GetNameOfFocusedControl() == focusName ) { - editor.Defocus(); - } - - bool codeNode = this is SFN_Code; - - bool mouseOver = rect.Contains( Event.current.mousePosition ); - - if( IsProperty() || codeNode ) { - PrepareWindowColor(); - Rect nameRect = new Rect( rect ); - nameRect.height = 20; - nameRect.y -= nameRect.height; - nameRect.xMax -= 1; // Due to reasons - //GUI.color = SF_Styles.nodeNameLabelBackgroundColor; - GUI.Box( nameRect, "", EditorStyles.textField ); - GUI.color = EditorGUIUtility.isProSkin ? Color.white : Color.black; - string oldName = codeNode ? (this as SFN_Code).functionName : IsGlobalProperty() ? property.nameInternal : property.nameDisplay; - - GUI.SetNextControlName(focusName); - //Debug.Log(); - - string newName; - //if(codeNode) - // newName = UndoableTextField( nameRect, oldName, SF_Styles.GetNodeNameLabelText() ); // newName = GUI.TextField( nameRect, oldName, SF_Styles.GetNodeNameLabelText() ); - //else if(IsGlobalProperty()) - // newName = GUI.TextField( nameRect, oldName, SF_Styles.GetNodeNameLabelText() ); - //else - - - string labelType = codeNode ? "function name" : !IsGlobalProperty() ? "property name" : "internal name"; - newName = UndoableTextField( nameRect, oldName, labelType, SF_Styles.GetNodeNameLabelText(), readPropertyName:false ); - - if(codeNode) - newName = SF_ShaderProperty.FormatInternalName(newName); - else - SF_Tools.FormatSerializable( ref newName ); - - - - - if( oldName != newName ){ - if(codeNode) - (this as SFN_Code).functionName = newName.Replace(" ",string.Empty); - else if(IsGlobalProperty()) - property.SetBothNameAndInternal( newName ); - else - property.SetName( newName ); - } - - bool focusedField = GUI.GetNameOfFocusedControl() == focusName; - - mouseOver = nameRect.Contains( Event.current.mousePosition ) || rect.Contains( Event.current.mousePosition ); - - if( focusedField ) - editor.nodeView.selection.DeselectAll(registerUndo:true); - - if( selected || focusedField || mouseOver && !editor.screenshotInProgress ) { - GUI.color = new Color(1f,1f,1f,0.6f); - nameRect.x += nameRect.width; - if(!IsGlobalProperty() && !codeNode){ - GUI.Label( nameRect, property.nameInternal, EditorStyles.boldLabel ); - } - nameRect.y -= 12; - - // Right: - if(!IsGlobalProperty() && !codeNode){ // Global ones *only* have internal names, display as main instead - GUI.color = new Color( 1f, 1f, 1f, 0.3f ); - GUI.Label( nameRect, "Internal name:", EditorStyles.miniLabel); - } - - - // Upper: - nameRect = new Rect( rect ); - nameRect.height = 20; - nameRect.y -= 33; - GUI.color = new Color( 1f, 1f, 1f, 0.6f ); - GUI.Label( nameRect, codeNode ? "Function name:" : !IsGlobalProperty() ? "Property label:" : "Internal name:", EditorStyles.miniLabel ); - - - GUI.color = Color.white; - } - ResetWindowColor(); - - } - - - Rect cr = rect; - if(HasComment() || isEditingNodeTextField){ - GUI.color = Color.white; - - cr.height = SF_Styles.GetNodeCommentLabelTextField().fontSize + 4; - cr.width = 2048; - cr.y -= cr.height + 2; - - - commentYposTarget = cr.y; - - //commentYposCurrent = - - if( IsProperty() || this is SFN_Code ){ - commentYposTarget -= 19; - if( mouseOver || selected ){ - commentYposTarget -= 8; - } - } - - cr.y = Mathf.Round(commentYposCurrent); - - if(isEditingNodeTextField){ - - - bool clicked = Event.current.rawType == EventType.mouseDown && Event.current.button == 0; - bool clickedOutside = clicked && !cr.Contains(Event.current.mousePosition); - bool pressedReturn = Event.current.rawType == EventType.KeyDown && Event.current.keyCode == KeyCode.Return; - - bool defocus = pressedReturn || clickedOutside; - - if( defocus ){ - isEditingNodeTextField = false; - SF_Node.isEditingAnyNodeTextField = false; - editor.Defocus(); - } - string fieldStr = "node_comment_" + id; - GUI.SetNextControlName(fieldStr); - Rect tmp = cr; - tmp.width = 256; - //comment = GUI.TextField(tmp, comment, SF_Styles.GetNodeCommentLabelTextField()); - comment = UndoableTextField(tmp, comment, "comment", SF_Styles.GetNodeCommentLabelTextField()); - - SF_Tools.FormatSerializableComment(ref comment); - - - if(!defocus){ - GUI.FocusControl(fieldStr); - } - - } else { - GUI.Label(cr, "// " + comment, SF_Styles.GetNodeCommentLabelText()); - } - - - - } - - - // Tags - if(IsProperty() && !property.global){ - - - cr.y = BoundsTop() - 18; - if( mouseOver || selected ) { - cr.y -= 8; - } - cr.height = 15; - Color c = colorExposed; - c.a = 0.6f; - GUI.color = c; - - - TagLabel( ref cr, "Hidden", property.tagHideInInspector ); - TagLabel( ref cr, "No scale/offset", property.tagNoScaleOffset ); - TagLabel( ref cr, "Normal", property.tagNormal ); - TagLabel( ref cr, "HDR", property.tagHDR ); - TagLabel( ref cr, "Per-renderer", property.tagPerRendererData ); - - GUI.color = Color.white; - - } - - - - - - - - - Rect ur = rect; - - ur = ur.MovedDown(); - - - // See how tall/which ones we should use on this node - bool showPrecision = ((ShouldDefineVariable() || IsProperty()) && isFloatPrecisionBasedVariable) || canAlwaysSetPrecision; - bool showVarname = !IsGlobalProperty() && (ShouldDefineVariable() || IsProperty()) && !lockedVariableName ; - bool optionalVarname = IsProperty(); - bool showPanel = SF_Settings.showVariableSettings && (showPrecision || showVarname); - - - - - ur.height = (showPrecision && showVarname) ? 46 : 26; - ur.y += 1; - if(ur.width != NODE_WIDTH){ - ur.x += (rect.width - NODE_WIDTH)/2f; - ur.width = NODE_WIDTH; - } - - - - - // #precision #variablename - - if( showPanel ){ - - // Background - PrepareWindowColor(); - GUI.Label(ur, string.Empty, SF_Styles.NodeStyle); - GUI.color = Color.white; - - - Rect varNameRect = ur.Pad(4); - Rect precisionRect = ur.Pad(4); - - if(showPrecision){ - - if(showVarname){ - Rect[] split = ur.SplitVertical(0.5f, padding:4); - precisionRect = split[0]; - varNameRect = split[1]; - } - - precision = (FloatPrecision)UndoablePopup(precisionRect,(int)precision,precisionLabels,"variable precision",SF_Styles.BoldEnumField); - - //GUI.SetNextControlName(VarPrecisionControl()); - //string[] labels = split[0].Contains(Event.current.mousePosition) ? precisionLabels : precisionLabelsSimple; - - } - - - - - if( showVarname ){ - - if( optionalVarname ){ - Rect[] split = varNameRect.SplitFromLeft((int)varNameRect.height); - varNameRect = split[1]; - UndoableToggle(split[0],ref property.overrideInternalName,string.Empty,"override internal name", EditorStyles.toggle); - GUI.enabled = property.overrideInternalName; - } - - GUI.SetNextControlName(VarNameControl()); - variableName = UndoableTextField(varNameRect, (IsProperty() && !property.overrideInternalName) ? property.nameInternal : variableName, (IsProperty() ? "variable" : "internal") + " name", EditorStyles.textField, false); - GUI.enabled = true; - - } - - - - - } - - - //GUI.Label( nameRect, "Test", EditorStyles.toolbarTextField ); - - } - - - void TagLabel( ref Rect r, string tag, bool tagOn ) { - if( tagOn ) { - GUI.Label( r, "[" + tag + "]", EditorStyles.miniLabel ); - r = r.MovedUp(); - } - } - - -// public bool ShowPrecisionEditField(){ -// -// } -// -// public bool ShowVarnameEditField(){ -// -// } -// -// -// public int GetHeightOfLowerPanel(){ -// -// } - - - public virtual bool CanCustomizeVariable(){ - return ( ShouldDefineVariable() || IsProperty() ) && !lockedVariableName; - } - - public string VarNameControl(){ - return "ctrl_" + id + "_varname"; - } - public string VarPrecisionControl(){ - return "ctrl_" + id + "_precision"; - } - - - public void UpdateNeighboringConnectorLines(){ - foreach(SF_NodeConnector con in connectors){ - if(!con.IsConnected()) - continue; - if(con.conType == ConType.cOutput){ - foreach(SF_NodeConnector conOut in con.outputCons){ - conOut.conLine.ReconstructShapes(); - } - } else if(con.conType == ConType.cInput){ - con.conLine.ReconstructShapes(); - } - } - } - - - public void StartDragging() { - isDragging = true; - dragStart = new Vector2( rect.x, rect.y ); - dragDelta = Vector2.zero; - } - - - public static int snapThreshold = 10; - public static int snapDistance = 256; - public static Color snapColor = new Color(1f,1f,1f,0.5f); - public Vector2 dragStart; - public Vector2 dragDelta; - - public void OnDraggedWindow( Vector2 delta ) { - - - - editor.ResetRunningOutdatedTimer(); - - //UndoRecord("move " + nodeName + " node"); - - dragDelta += delta; - Vector2 finalDelta = new Vector2( rect.x, rect.y ); - rect.x = dragStart.x + dragDelta.x; - rect.y = dragStart.y + dragDelta.y; - Event.current.Use(); - - - UpdateNeighboringConnectorLines(); - - - - if(!SF_Settings.hierarchalNodeMove) // TODO: Snap toggle + make it work properly with hierarchal on - foreach(SF_Node n in editor.nodes){ - if( n == this ) - continue; - if( SF_Tools.DistChebyshev( rect.center, n.rect.center ) > snapDistance ) - continue; - if( n.selected ) // Don't snap to selected nodes - continue; - if( Mathf.Abs( n.rect.xMax - rect.xMax ) < snapThreshold ) { // RIGHT SIDE SNAP - delta.x -= rect.xMax - n.rect.xMax; - rect.x = n.rect.xMax - rect.width; - } else if( Mathf.Abs( n.rect.x - rect.x ) < snapThreshold ) { // LEFT SIDE SNAP - delta.x -= rect.x - n.rect.x; - rect.x = n.rect.x; - } else if( Mathf.Abs( n.rect.y - rect.y ) < snapThreshold ) { // TOP SIDE SNAP - delta.y -= rect.y - n.rect.y; - rect.y = n.rect.y; - } else if( Mathf.Abs( n.rect.center.x - rect.center.x ) < snapThreshold ) { // CENTER HORIZONTAL SNAP - delta.x -= rect.center.x - n.rect.center.x; - Vector2 tmp = rect.center; - tmp.x = n.rect.center.x; - rect.center = tmp; - - //GUILines.DrawLine( rect.center, n.rect.center, snapColor, snapThreshold * 2, true ); - - } else if( Mathf.Abs( n.rect.center.y - rect.center.y ) < snapThreshold ) { // CENTER VERTICAL SNAP - delta.y -= rect.center.y - n.rect.center.y; - Vector2 tmp = rect.center; - tmp.y = n.rect.center.y; - rect.center = tmp; - - //GUILines.DrawLine( editor.nodeView.AddNodeWindowOffset( rect.center ), editor.nodeView.AddNodeWindowOffset( n.rect.center ), Color.white, snapThreshold * 2, true ); - - } - } - - finalDelta = new Vector2( rect.x, rect.y ) - finalDelta; - - editor.nodeView.selection.MoveSelection(finalDelta, ignore:this); - - bool moveAsHierarchy = SF_GUI.HoldingControl() ^ SF_Settings.hierarchalNodeMove; - if( delta != Vector2.zero && moveAsHierarchy && ( GetType() != typeof( SFN_Final ) ) ) { - MoveUnselectedChildren( delta ); - } - - } - - public void MoveUnselectedChildren( Vector2 delta ) { - // Find all child nodes - // TODO: On click or on connect, not every frame - List children = new List(); - children.AddRange( editor.nodeView.selection.Selection ); - children.Add( this ); - AppendUnselectedChildren( children ); - foreach( SF_Node n in editor.nodeView.selection.Selection ) { - n.AppendUnselectedChildren( children ); - } - foreach(SF_Node n in editor.nodeView.selection.Selection){ - children.Remove( n ); - } - children.Remove( this ); - - for( int i = 0; i < children.Count; i++ ) { - children[i].rect.x += delta.x; - children[i].rect.y += delta.y; - } - } - - public void AppendUnselectedChildren( List list ) { - - // Search all connected - for( int i = 0; i < connectors.Length; i++ ) { - if( connectors[i].conType == ConType.cOutput ) - continue; - if( connectors[i].IsConnected() && !list.Contains( connectors[i].inputCon.node ) ) { - //if( connectors[i].inputCon.node.ConnectedOutputCount() > 1 ) - // continue; // Only unique children - //if( OutputsToAnyOutside( list ) ) - // continue; // Only unique children - if( !connectors[i].inputCon.node.selected ) - list.Add( connectors[i].inputCon.node ); - connectors[i].inputCon.node.AppendUnselectedChildren( list ); - } - } - } - - - /* - public bool OutputsToAnyOutside( List list ) { - foreach( SF_NodeConnection nc in connectors ) { - if( nc.conType == ConType.cInput ) - continue; - foreach(SF_NodeConnection con in nc.outputCons){ - if( !list.Contains( con.inputCon.node ) ) - return true; - } - } - return false; - }*/ - - public int ConnectedOutputCount() { - int count = 0; - foreach( SF_NodeConnector nc in connectors ) { - if(nc.conType == ConType.cInput) - continue; - count += nc.outputCons.Count; - } - return count; - } - - public void UndoRecordSelectionState(string undoMsg){ - UndoRecord(undoMsg, UpToDateState.OutdatedSoft); - Undo.RecordObject(editor.nodeView.selection, undoMsg); - } - - public void Select(bool registerUndo) { - if( !editor.nodeView.selection.Selection.Contains( this ) ) { - if(registerUndo) - UndoRecordSelectionState("select"); - editor.nodeView.selection.Add( this ); - selected = true; - } - } - - public void Deselect(bool registerUndo, string undoMsg = null) { - if(!selected) - return; - if(undoMsg == null) - undoMsg = "deselect"; - if(registerUndo) - UndoRecordSelectionState(undoMsg); - editor.nodeView.selection.Remove( this ); - selected = false; - } - - public void DrawHighlight() { - - //if( Event.current.type == EventType.repaint ) - if( selected ) { - - Rect r = new Rect( rect ); - r.xMax -= 1; - if( IsProperty() ) - r.yMin -= 20; - GUILines.Highlight( r, offset: 1, strength: 2 ); - } - } - - /* - public void OnSelectedWindow() { - Debug.Log("Beep!"); - }*/ - - - public void ProcessInput() { - /* - if( IsFocused() ) - Debug.Log( "Mouse over " + nodeName + " rawType = " + Event.current.rawType ); - if( Event.current.rawType == EventType.mouseDown && Event.current.button == 0 ) { - if( !selected ) { - Debug.Log("SELECTED"); - Debug.Log("Rect: " + rect + " mPos: " + Event.current.mousePosition); - editor.nodeView.selection.DeselectAll(); - Select(); - } - - }*/ - } - - - public virtual bool Draw() { - - - ProcessInput(); - - - DrawHighlight(); - - //if(status != null) - - if( SF_Debug.nodePreviews ) { - Rect tmp = rect; - tmp.y -= 20; - tmp.height = 20; - GUI.Label( tmp, "State: " + dirtyState ); - } - - - - PrepareWindowColor(); - - if( showLowerPropertyBox ) - if( showLowerPropertyBoxAlways || ( showLowerPropertyBox && CanEvaluate() && IsUniformOutput() ) ) { - rect.height = ( node_height + 20 ); - } else { - rect.height = node_height; - } - - - DrawWindow(); - - ResetWindowColor(); - - return true; - } - - - - public void DrawGrabHandle(Rect r) { - Rect texCoords = new Rect( r ); - texCoords.width /= 7; - texCoords.height /= 3; - texCoords.x = texCoords.y = 0; - GUI.DrawTextureWithTexCoords( r, SF_GUI.Handle_drag, texCoords, alphaBlend: true ); - } - - - - public virtual void NeatWindow( ) { - GUI.BeginGroup( rect ); - - if(UnavailableInThisRenderPath()) - GUI.color = new Color(1f,1f,1f,0.5f); - else - GUI.color = Color.white; - GUI.skin.box.clipping = TextClipping.Overflow; - - - if( showColor ) { - texture.Draw( rectInner, UnavailableInThisRenderPath() ); - GUI.color = Color.white; - - /* - if( SF_Debug.nodes ) { - Rect r = new Rect( 0, 16, 96, 20 ); - GUI.color = Color.white; - GUI.skin.box.normal.textColor = Color.white; - GUI.Box( r, "ID: " + id ); - r.y += r.height; - //GUI.Box( r, "Cmps: " + texture.CompCount ); - //r.y += r.height; - //GUI.Box( r, "Unif: " + texture.dataUniform ); - - }*/ - - - } - - if( showLowerPropertyBox ) { - GUI.color = Color.white; - DrawLowerPropertyBox(); - } - - //GUI.DragWindow(); - - - GUI.EndGroup( ); - - - //if(rect.center.x) - } - - - public Rect LocalRect() { - Rect r = new Rect( rect ); - r.x = 0; - r.y = 0; - return r; - } - - public bool MouseOverNode(bool world = false) { - - if(!editor.nodeView.MouseInsideNodeView(offset:true)) - return false; - - if( world ) { - return rect.Contains( Event.current.mousePosition ); - } - else - return LocalRect().Contains( Event.current.mousePosition ); - } - - public void ColorPickerCorner( Rect r ) { - //bool prevEnabledState = GUI.enabled; - //GUI.enabled = MouseOverNode(false); - - //try { - Rect pickRect = new Rect( r ); - pickRect.height = 15; - pickRect.width = 45; - pickRect.y -= pickRect.height + 1; - pickRect.x += 1; - Rect pickBorder = new Rect( pickRect ); - pickBorder.xMax -= 18; - //pickBorder.xMin -= 1; - //pickBorder.yMax += 1; - //pickBorder.yMin -= 1; - - float grayscale = ((Color)texture.dataUniform).grayscale; - Color borderColor = Color.white - new Color( grayscale, grayscale, grayscale ); - borderColor.a = GUI.enabled ? 1f : 0.25f; - GUI.color = borderColor; - GUI.DrawTexture( pickBorder, EditorGUIUtility.whiteTexture ); - GUI.color = Color.white; - - - - Color pickedColor = EditorGUI.ColorField( pickRect, texture.ConvertToDisplayColor( texture.dataUniform ) ); - SetColor( pickedColor, true ); - - } - - public void SetColor(Color c, bool registerUndo = false) { - if( (Vector4)c != texture.dataUniform ) { - Color newColor = texture.ConvertToDisplayColor( c ); - if(registerUndo){ - if(IsProperty()){ - UndoRecord("set color of " + property.nameDisplay); - } else { - UndoRecord("set color of " + nodeName); - } - - } - - texture.dataUniform = newColor; - if( IsProperty() ) { - if( property is SFP_Color ) { - ( this as SFN_Color ).OnUpdateValue(); - } - } - } - } - - - public string FloatArrToString( float[] arr ) { - string s = ""; - for( int i = 0; i < arr.Length; i++ ) - s += arr[i] + " "; - return s; - } - - public void UseLowerReadonlyValues( bool use ) { - UseLowerPropertyBox( use ); - showLowerReadonlyValues = use; - } - - public void UseLowerPropertyBox( bool use, bool always = false ) { - rect.height = ( use ? ( node_height + 20 ) : ( node_height ) ); - showLowerPropertyBox = use; - if( always ) - showLowerPropertyBoxAlways = use; - } - - public virtual void DrawLowerPropertyBox() { - if( showLowerReadonlyValues ) - DrawLowerReadonlyValues(); - } - - public void DrawLowerReadonlyValues() { - - if( !texture.uniform ) - return; - - if( !InputsConnected() || !texture.uniform ) { - GUI.enabled = false; - GUI.skin.label.alignment = TextAnchor.MiddleCenter; - GUI.Label( lowerRect, "" ); - GUI.skin.label.alignment = TextAnchor.MiddleLeft; - GUI.enabled = true; - return; - } - - Rect tmp = lowerRect; - tmp.width /= texture.CompCount; - GUI.enabled = false; - for( int i = 0; i < texture.CompCount; i++ ) { - GUI.Box( tmp, "" ); - EditorGUI.SelectableLabel( tmp, texture.dataUniform[i].ToString() ); - tmp.x += tmp.width; - } - GUI.enabled = true; - } - - public virtual void OnDelete() { - // Override - } - - [SerializeField] - public UpToDateState dirtyState = UpToDateState.UpToDate; - - public bool CheckIfDirty(){ - - if( dirtyState == UpToDateState.UpToDate ) - return false; - - - - foreach( SF_NodeConnector con in ConnectedInputs ) { - if( con.inputCon.node.dirtyState != UpToDateState.UpToDate ) { - return false; - } - } - - NodeUpdateType updType = NodeUpdateType.Hard; - if( dirtyState == UpToDateState.OutdatedHard ) - updType = NodeUpdateType.Hard; - if( dirtyState == UpToDateState.OutdatedSoft ) - updType = NodeUpdateType.Soft; - - OnUpdateNode(updType, true); - dirtyState = UpToDateState.UpToDate; - return true; - } - - public void SetDirty(UpToDateState dirtyState){ - this.dirtyState = dirtyState; - } - - - // CURRENTLY ONLY USED BY GHOST NODES - public void DeleteGhost(bool registerUndo = false, string undoMsg = "") { - - if( this is SFN_Final ) - return; - - //bool leadsToFinal = status.leadsToFinal; - - - if(SF_Debug.nodeActions) - Debug.Log("Deleting node " + nodeName); - - - - OnDelete(); - - - Deselect(registerUndo:false); - editor.nodes.Remove( this ); - if( editor.nodeView.treeStatus.propertyList.Contains( this ) ) - editor.nodeView.treeStatus.propertyList.Remove( this ); - - for( int i = 0; i < connectors.Length; i++ ) { - connectors[i].Disconnect(true, false); - //connectors[i] = null; // TODO - } - //connectors = null; // TODO - - - //SF_Editor.instance.CheckForBrokenConnections(); - //SF_Editor.instance.Repaint(); - - texture.DestroyTexture(); - - - - - DestroyImmediate( texture ); - ScriptableObject.DestroyImmediate( status ); - - ScriptableObject.DestroyImmediate(this); - - - - - editor.OnShaderModified(NodeUpdateType.Soft); - - //if(leadsToFinal){ - // editor.ShaderOutdated = UpToDateState.OutdatedHard; // TODO: Only if connected - //} - } - - - - // TODO: Channels etc - // Override if this node has unconnected, required inputs - public virtual string Evaluate( OutChannel channel = OutChannel.All ) { - return GetVariableName(); - } - - - // Used to see if it's an already defined variable or not - public string PreEvaluate() { - - if(varDefined) - return GetVariableName(); - - // If it shouldn't be defined, get raw value - if( !ShouldDefineVariable() ) { - return Evaluate(); - } else if( !varDefined && !neverDefineVariable ) { // If it's not defined yet, define it! Append a new row - DefineVariable(); - } - - return GetVariableName(); - - } - - public void DefineVariable() { - - //if(this is SFN_If) - //Debug.Log("Defining variable"); - - if( varDefined || neverDefineVariable ) { - //Debug.Log( "Already defined!" ); - return; - } - PreDefine(); - - if(onlyPreDefine){ - varDefined = true; - return; - } - - string s = GetVariableType() + " " + GetVariableName() + " = " + Evaluate() + ";"; - - if(HasComment()){ - s += " // " + comment; - } - - SF_Editor.instance.shaderEvaluator.App( s ); - varDefined = true; - } - - public virtual string[] TryGetMultiCompilePragmas( out int group ){ - group = 0; - return null; // Override - } - - - public void DefineGhostsIfNeeded(ref List ghosts) { - - //Debug.Log("Checking if ghosts should be defined on " + nodeName + "..."); - - - // Super duper ultra weird and shouldn't be here. Find real issue later // TODO - if(this == null) - return; - - // TODO: This will prevent multi-ghosting - /* - if( editor.shaderEvaluator.ghostNodes.Contains(this) ){ - if(SF_Debug.The(DebugType.GhostNodes)) - Debug.Log("Skipping ghost define for " + nodeName); - return; - } - - if(Connectors == null){ - Debug.Log("CHK. GHOST: [" + nodeName + "] Connector count = NULL"); - Debug.Log("WHAT? this = " + this); - if(this == null) - return; - } else - Debug.Log("CHK. GHOST: [" + nodeName + "] Connector count = " + Connectors.Length); - */ - - foreach(SF_NodeConnector con in connectors){ - if( con.conType == ConType.cOutput) { - //Debug.LogError("Ghost node defined on an output: "+nodeName+"[" + con.label + "]"); - continue; - } - con.DefineGhostIfNeeded( ref ghosts ); - } - } - - - public void PreDefine() { - if( varDefined || varPreDefined ) - return; - - string[] preDefs = GetPreDefineRows(); - if( preDefs != null ) { - foreach( string row in preDefs ) { - SF_Editor.instance.shaderEvaluator.App( row ); - } - } - varPreDefined = true; - } - - public virtual string[] GetPreDefineRows() { - return null; // Override this - } - - - - public bool ShouldDefineVariable() { - if(neverDefineVariable) - return false; - return ((UsedMultipleTimes() || alwaysDefineVariable) /*&& !varDefined*/); - } - - - public bool UsedMultipleTimes() { - return ( GetOutputCount() > 1 ); - } - - public int GetOutputCount() { - int n = 0; - foreach( SF_NodeConnector con in connectors ) { - if( con.conType == ConType.cInput ) - continue; - if( con.IsConnected() ) { - foreach(SF_NodeConnector inCon in con.outputCons){ - n += inCon.usageCount; // Make sure it counts some as multiple uses - } - } - } - return n; - } - - - public virtual string SerializeSpecialData() { - return null; // Override! - } - - public virtual void DeserializeSpecialData( string key, string value ) { - return; // Override! - } - - - // n:type:SFN_Multiply,id:8,x:33794,y:32535|1-9-0,2-7-0; - // Deserialize is in SF_Parser - public string Serialize(bool skipExternalLinks = false, bool useSuffixPrefix = false) { - - string s = ""; - if(useSuffixPrefix) - s = "n:"; - - - s += "type:" + this.GetType().ToString() + ","; - s += "id:" + this.id + ","; - s += "x:" + (int)rect.x + ","; - s += "y:" + (int)rect.y; - if(IsProperty()){ - s += ",ptovrint:" + property.overrideInternalName; - s += ",ptlb:" + property.nameDisplay; - s += ",ptin:" + property.nameInternal; - } - if(HasComment()) - s += ",cmnt:" + comment; - if(!string.IsNullOrEmpty(variableName) && !lockedVariableName){ - s += ",varname:" + variableName; - } - if(isFloatPrecisionBasedVariable) - s += ",prsc:" + (int)precision; - - - // - string specialData = SerializeSpecialData(); // <-- This is the unique data for each node - if( !string.IsNullOrEmpty( specialData ) ) { - s += "," + specialData; - } - // - - if( HasAnyInputConnected(skipExternalLinks) ) { - s += "|"; - int linkCount = 0; - int i = 0; - foreach( SF_NodeConnector con in connectors ) { // List connections, connected inputs only - if( con.conType == ConType.cOutput ) { i++; continue; } - if( !con.IsConnected() ) { i++; continue; } - - if(skipExternalLinks) - if(!con.inputCon.node.selected){ i++; continue; } - - - string link = con.GetIndex() + "-" + connectors[i].inputCon.node.id + "-" + connectors[i].inputCon.GetIndex(); - - if( linkCount > 0 ) - s += ","; - s += link; - - linkCount++; - i++; - } - } - - if(useSuffixPrefix) - s += ";"; - - return s; - } - - // This is the data per-node - // n:type:SFN_Final,id:6,x:33383,y:32591|0-8-0; - public static SF_Node Deserialize( string row, ref List linkList) { - - - bool isLinked = row.Contains( "|" ); - - string linkData = ""; - - // Grab connections, if any, and remove them from the main row - if( isLinked ) { - string[] split = row.Split( '|' ); - row = split[0]; - linkData = split[1]; - } - - - string[] nData = row.Split( ',' ); // Split the node data - SF_Node node = null; - - // This is the data in a single node, without link information - // type:SFN_Final,id:6,x:33383,y:32591 - foreach( string s in nData ) { - if(SF_Debug.deserialization) - Debug.Log("Deserializing node: " + s); - string[] split = s.Split( ':' ); - string dKey = split[0]; - string dValue = split[1]; - - switch( dKey ) { - case "type": - //Debug.Log( "Deserializing " + dValue ); - node = TryCreateNodeOfType( dValue ); - if( node == null ) { - if(SF_Debug.dynamicNodeLoad) - Debug.LogError( "Node not found, returning..." ); - return null; - } - break; - case "id": - node.id = int.Parse( dValue ); - break; - case "x": - node.rect.x = int.Parse( dValue ); - break; - case "y": - node.rect.y = int.Parse( dValue ); - break; - case "ptovrint": - node.property.overrideInternalName = bool.Parse(dValue); - break; - case "ptlb": - node.property.SetName( dValue ); - break; - case "ptin": - node.property.nameInternal = dValue; - break; - case "cmnt": - node.comment = dValue; - break; - case "varname": - node.variableName = dValue; - break; - case "prsc": - node.precision = (FloatPrecision)int.Parse(dValue); - break; - default: - //Debug.Log("Deserializing KeyValue: " +dKey + " v: " + dValue); - node.DeserializeSpecialData( dKey, dValue ); - break; - } - } - - // Add links to link data, if it's connected - if( isLinked ) { - string[] parsedLinks = linkData.Split( ',' ); - foreach( string s in parsedLinks ) - linkList.Add( new SF_Link( node.id, s ) ); - } - - // Update image if needed - node.GenerateBaseData(); - - - return node; - - } - - - private static SF_Node TryCreateNodeOfType( string nodeType ) { - SF_Node node = null; - - // Renamed nodes - if(nodeType == "ShaderForge.SFN_Binormal") - nodeType = "ShaderForge.SFN_Bitangent"; - - - if( nodeType == "ShaderForge.SFN_Final" ) { - node = SF_Editor.instance.CreateOutputNode(); - } else { - foreach( SF_EditorNodeData tmp in SF_Editor.instance.nodeTemplates ) { - if( tmp.type == nodeType ) { // 1 is the type - node = SF_Editor.instance.AddNode( tmp ); // Create the node - break; - } - } - } - if( node == null && SF_Debug.dynamicNodeLoad ) { - Debug.LogError( "Type [" + nodeType + "] not found!" ); - } - return node; - } - - - public void TrySerialize( XmlWriter xml, string key, object val ) { - if( val == null ) - return; - string str = val.ToString(); - if( string.IsNullOrEmpty( str ) ) - return; - xml.WriteElementString( key, str ); - } - - /* - public virtual string SerializeCustomData() { - return ""; // Override - }*/ - - public void DrawConnectors() { - - - - int yOut = 0; - int yIn = 0; - - int spacing = 20; - - if( connectors != null ) { - for( int i = 0; i < connectors.Length; i++ ) { - Vector2 pos = new Vector2( rect.width + rect.x, 16 + rect.y ); - - - if( connectors[i].conType == ConType.cInput ) { - pos.y += yIn * spacing; - yIn++; - } else { - pos.y += yOut * spacing; - yOut++; - } - - connectors[i].Draw( pos ); - - - } - } - - - - /*if( DEBUG ) { - Rect tmp = new Rect( rect ); - tmp.height = 20; - tmp.width = 250; - tmp.y -= tmp.height; - GUI.Box( tmp, depth.ToString(), EditorStyles.largeLabel ); - tmp.y -= tmp.height; - GUI.Box( tmp, "cCons: " + CalcConnectionCount().ToString(), EditorStyles.largeLabel ); - tmp.y -= tmp.height; - GUI.Box( tmp, "Conctrs: " + connectors.Length, EditorStyles.largeLabel ); - tmp.y -= tmp.height; - GUI.Box( tmp, "Editor: " + ( editor != null ), EditorStyles.largeLabel ); - tmp.y -= tmp.height; - GUI.Box( tmp, "Property: " + IsProperty(), EditorStyles.miniLabel ); - tmp.y -= tmp.height; - if( conGroup != null ) { - GUI.Box( tmp, "C Group out: " + conGroup.output, EditorStyles.miniLabel ); - tmp.y -= tmp.height; - GUI.Box( tmp, "C Group ins: " + conGroup.inputs.Length, EditorStyles.miniLabel ); - tmp.y -= tmp.height; - GUI.Box( tmp, "C Group hash: " + conGroup.GetHashCode(), EditorStyles.miniLabel ); - tmp.y -= tmp.height; - } else { - GUI.Box( tmp, "C Group is NULL", EditorStyles.miniLabel ); - tmp.y -= tmp.height; - } - GUI.Box( tmp, "Type: " + GetType().ToString(), EditorStyles.miniLabel ); - tmp.y -= tmp.height; - GUI.Box( tmp, "Hash: " + GetHashCode(), EditorStyles.miniLabel ); - tmp.y -= tmp.height; - if(texture != null) - GUI.Box( tmp, "Unif: " + texture.uniform ); - tmp.y -= tmp.height; - }*/ - - } - - public SF_NodeConnector GetConnectorByID(string s) { - int number; - if( int.TryParse( s, out number ) ) { - return connectors[number]; - } else { - return GetConnectorByStringID(s); - } - } - - public SF_NodeConnector GetConnectorByStringID(string s) { - foreach( SF_NodeConnector con in connectors ) { - if( !con.HasID() ) - continue; - if( s == con.strID ) - return con; - } - - Debug.LogError("Unsuccessfully tried to find connector by string ID [" + s + "] in node " + nodeName); - return null; - } - - public bool HasAnyInputConnected(bool skipExternalLinks = false) { - foreach( SF_NodeConnector con in connectors ) - if( con.IsConnected() && con.conType == ConType.cInput ){ - if(skipExternalLinks){ - if(con.inputCon.node.selected) - return true; - } else { - return true; - } - } - - return false; - } - - public int CalcConnectionCount() { - int i = 0; - foreach( SF_NodeConnector con in connectors ) { - if( con.IsConnected() ) - i++; - } - return i; - } - } - -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node.cs.meta deleted file mode 100755 index 4948a6c3..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5aedfe1c90dc2284b8220346c3a38f39 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Arithmetic.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Arithmetic.cs deleted file mode 100755 index 48e6faf1..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Arithmetic.cs +++ /dev/null @@ -1,60 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; - -namespace ShaderForge { - [System.Serializable] - public class SF_Node_Arithmetic : SF_Node { - - public void PrepareArithmetic(int inputCount = 2, ValueType inputType = ValueType.VTvPending, ValueType outputType = ValueType.VTvPending) { - base.showColor = true; - UseLowerReadonlyValues( true ); - - - if( inputCount == 2 ) { - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create( this, "OUT", "", ConType.cOutput, outputType, false ), - SF_NodeConnector.Create( this, "A", "A", ConType.cInput, inputType, false ).SetRequired( true ), - SF_NodeConnector.Create( this, "B", "B", ConType.cInput, inputType, false ).SetRequired( true )}; - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1], connectors[2] ); - } else if( inputCount == 1 ){ - connectors = new SF_NodeConnector[]{ - SF_NodeConnector.Create( this, "OUT", "", ConType.cOutput, outputType, false ), - SF_NodeConnector.Create( this, "IN", "", ConType.cInput, inputType, false ).SetRequired( true )}; - base.conGroup = ScriptableObject.CreateInstance().Initialize( connectors[0], connectors[1]); - } - - } - - public override int GetEvaluatedComponentCount() { - int max = 0; - foreach(SF_NodeConnector con in connectors){ - if( con.conType == ConType.cOutput || !con.IsConnected()) // Only connected ones, for now - continue; - //Debug.Log("GetEvaluatedComponentCount from node " + nodeName + " [" + con.label + "] cc = " + con.GetCompCount()); - max = Mathf.Max( max, con.GetCompCount() ); - } - return max; - } - - public override bool IsUniformOutput() { - - if(InputsConnected()){ - if( connectors.Length > 2) - return ( GetInputData( "A" ).uniform && GetInputData( "B" ).uniform ); - return ( GetInputData( "IN" ).uniform ); - } - return true; - } - - // New system - public override void RefreshValue() { - if( connectors.Length == 3 ) - RefreshValue( 1, 2 ); - else - RefreshValue( 1, 1 ); - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Arithmetic.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Arithmetic.cs.meta deleted file mode 100755 index 032d8046..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Arithmetic.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7ff67b8320fb71341a7e68fac5f5560c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Resizeable.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Resizeable.cs deleted file mode 100755 index 9f977907..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Resizeable.cs +++ /dev/null @@ -1,263 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; -using System.Xml; - - -namespace ShaderForge { - - [System.Serializable] - public class SF_Node_Resizeable : SF_Node { - - - public int minWidth = NODE_WIDTH; - public int minHeight = NODE_HEIGHT; - - /* - public void Deselect() { - editor.nodeView.selection.Remove( this ); - selected = false; - } - - public void DrawHighlight() { - - //if( Event.current.type == EventType.repaint ) - if( selected ) { - - Rect r = new Rect( rect ); - r.xMax -= 1; - if( IsProperty() ) - r.yMin -= 20; - GUILines.Highlight( r, offset: 1, strength: 2 ); - } - }*/ - - - - public override bool Draw() { - - - ProcessInput(); - - - DrawHighlight(); - - - - - PrepareWindowColor(); - - if( showLowerPropertyBox ) - if( showLowerPropertyBoxAlways || ( showLowerPropertyBox && CanEvaluate() && IsUniformOutput() ) ) { - rect.height = ( node_height + 20 ); - } else { - rect.height = node_height; - } - - - DrawWindow(); - - ResetWindowColor(); - - return true; - } - - - bool resizing = false; - int xDrag = 0; - int yDrag = 0; - - public override void NeatWindow( ) { - GUI.BeginGroup( rect ); - GUI.color = Color.white; - GUI.skin.box.clipping = TextClipping.Overflow; - - - - - - // Resize handle - int size = 10; - - - - - Rect topLeft = LocalRect().GetBorder(RectBorder.TopLeft,size); - //Rect lowerRight = LocalRect().GetBorder(RectBorder.BottomRight,size); - Rect topRight = LocalRect().GetBorder(RectBorder.TopRight,size); - - Rect left = LocalRect().GetBorder(RectBorder.Left,size); - //Rect lowerRight = LocalRect().GetBorder(RectBorder.Center,size); - Rect right = LocalRect().GetBorder(RectBorder.Right,size); - - - Rect lowerLeft = LocalRect().GetBorder(RectBorder.BottomLeft,size); //new Rect(rect.width - size, rect.height-size,size,size); - Rect lower = LocalRect().GetBorder(RectBorder.Bottom,size); - Rect lowerRight = LocalRect().GetBorder(RectBorder.BottomRight,size); - - - /* - if(!resizing) - SF_GUI.AssignCursor(lowerRight,MouseCursor.ResizeUpLeft); - else - SF_GUI.AssignCursor(new Rect(0,0,Screen.width,Screen.height),MouseCursor.ResizeUpLeft);*/ - - - - SF_GUI.DrawTextureTiled(LocalRect().GetBorder(RectBorder.TopLeft ,size, showResizeCursor:true), SF_GUI.Handle_drag, local:true ); - //SF_GUI.DrawTextureTiled(LocalRect().GetBorder(RectBorder.Top ,size, showResizeCursor:true), SF_GUI.Handle_drag, local:true ); - SF_GUI.DrawTextureTiled(LocalRect().GetBorder(RectBorder.TopRight ,size, showResizeCursor:true), SF_GUI.Handle_drag, local:true ); - SF_GUI.DrawTextureTiled(LocalRect().GetBorder(RectBorder.Left ,size, showResizeCursor:true), SF_GUI.Handle_drag, local:true ); - SF_GUI.DrawTextureTiled(LocalRect().GetBorder(RectBorder.Right ,size, showResizeCursor:true), SF_GUI.Handle_drag, local:true ); - SF_GUI.DrawTextureTiled(LocalRect().GetBorder(RectBorder.BottomLeft ,size, showResizeCursor:true), SF_GUI.Handle_drag, local:true ); - SF_GUI.DrawTextureTiled(LocalRect().GetBorder(RectBorder.Bottom ,size, showResizeCursor:true), SF_GUI.Handle_drag, local:true ); - SF_GUI.DrawTextureTiled(LocalRect().GetBorder(RectBorder.BottomRight ,size, showResizeCursor:true), SF_GUI.Handle_drag, local:true ); - - - // -1 = left / top - // 0 = static - // 1 = right / bottom - - - - bool clicked = Event.current.type == EventType.mouseDown && Event.current.button == 0; - - - - - if(clicked){ - - xDrag = 0; - yDrag = 0; - Vector3 mPos = Event.current.mousePosition; - /* - bool[,] dragGrid = new bool[3,3]{ - {topLeft.Contains(mPos), false, topRight.Contains(mPos)}, - {left.Contains(mPos), false, right.Contains(mPos)}, - {lowerLeft.Contains(mPos), lower.Contains(mPos), lowerRight.Contains(mPos)} - };*/ - - bool[,] dragGrid = new bool[3,3]{ - {topLeft.Contains(mPos),left.Contains(mPos),lowerLeft.Contains(mPos)}, - {false,false,lower.Contains(mPos)}, - {topRight.Contains(mPos),right.Contains(mPos),lowerRight.Contains(mPos)} - }; - - - - bool leftSide = dragGrid[0,0] || dragGrid[0,1] || dragGrid[0,2]; - bool rightSide = dragGrid[2,0] || dragGrid[2,1] || dragGrid[2,2]; - bool topSide = dragGrid[0,0] || dragGrid[1,0] || dragGrid[2,0]; - bool bottomSide = dragGrid[0,2] || dragGrid[1,2] || dragGrid[2,2]; - - - if(leftSide) - xDrag = -1; - else if(rightSide) - xDrag = 1; - - if(topSide) - yDrag = -1; - else if(bottomSide) - yDrag = 1; - - - bool contained = xDrag != 0 || yDrag != 0; - - - if( contained ){ - resizing = true; - Event.current.Use(); - } - - } - - - - - if(resizing && Event.current.type == EventType.mouseDrag){ - - if(Event.current.delta.sqrMagnitude > 0){ - UndoRecord("resize node"); - } - - if(xDrag == 1) - rect.width += Event.current.delta.x; - else if(xDrag == -1) - rect.xMin += Event.current.delta.x; - - if(yDrag == 1) - rect.height += Event.current.delta.y; - if(yDrag == -1) - rect.yMin += Event.current.delta.y; - - //Debug.Log("RESIZING X " + xDrag + " Y " + yDrag); - - ClampSize(); - - Event.current.Use(); - } - - if(resizing && SF_GUI.ReleasedRawLMB()){ - resizing = false; - xDrag = 0; - yDrag = 0; - if(base.isDragging) - base.OnRelease(); - Event.current.Use(); - } - - Rect insideHandleRect = LocalRect().PadLeft(size).PadRight(size).PadBottom(size).PadTop(Mathf.Max(15,size)); - DrawInner(insideHandleRect); - - /* - if( showColor ) { - - texture.Draw( rectInner ); - - if( SF_Debug.nodes ) { - Rect r = new Rect( 0, 16, 96, 20 ); - GUI.color = Color.white; - GUI.skin.box.normal.textColor = Color.white; - GUI.Box( r, "ID: " + id ); - r.y += r.height; - //GUI.Box( r, "Cmps: " + texture.CompCount ); - //r.y += r.height; - //GUI.Box( r, "Unif: " + texture.dataUniform ); - - } - - - }*/ - - if( showLowerPropertyBox ) { - GUI.color = Color.white; - DrawLowerPropertyBox(); - } - - //GUI.DragWindow(); - - - GUI.EndGroup( ); - - - //if(rect.center.x) - } - - - public void ClampSize(){ - rect = rect.ClampMinSize(minWidth, minHeight); - } - - - public virtual void DrawInner(Rect r){ - // Override - } - - - - - } - -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Resizeable.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Resizeable.cs.meta deleted file mode 100644 index 7b800443..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Nodes/SF_Node_Resizeable.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9a79950ae6ecc41439f30ac282389f9f -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties.meta deleted file mode 100755 index 27b2f3f8..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: a539d47bbd8db459ca996ac18a58303b -folderAsset: yes -DefaultImporter: - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Branch.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Branch.cs deleted file mode 100755 index 94ff502d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Branch.cs +++ /dev/null @@ -1,39 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Text.RegularExpressions; - - -namespace ShaderForge { - - [System.Serializable] - public class SFP_Branch : SF_ShaderProperty { - - public new SFP_Branch Initialize( SF_Node node ) { - base.nameType = "Static Branch"; - base.Initialize( node ); - return this; - } - - public override void UpdateInternalName() { - - string s = nameDisplay; - - s = s.Replace(" ","_"); - - Regex rgx = new Regex( "[^a-zA-Z0-9_]" ); - s = rgx.Replace( s, "" ); - - s = s.ToUpper(); - - - // TODO: Make sure it's valid and unique - - nameInternal = s; - } - - public override string GetMulticompilePragma (){ - return "#pragma multi_compile " + nameInternal; - } - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Branch.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Branch.cs.meta deleted file mode 100644 index f0b8b8fd..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Branch.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: caf1e1fe0d9a241339086202fccb2133 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Color.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Color.cs deleted file mode 100755 index 23a76e5c..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Color.cs +++ /dev/null @@ -1,37 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFP_Color : SF_ShaderProperty { - - - public bool isBumpmap = false; - - public new SFP_Color Initialize( SF_Node node ) { - base.nameType = "Color"; - base.Initialize( node ); - return this; - } - - public override string GetInitializationLine() { - return GetTagString() + GetVariable() + " (\"" + nameDisplay + "\", Color) = (" + GetValue().r + "," + GetValue().g + "," + GetValue().b + "," + GetValue().a + ")"; - } - - Color GetValue() { - return ( node as SFN_Color ).texture.dataUniform; - } - - public override string GetVariableLine() { - return "uniform " + node.precision.ToCode() + "4 " + GetVariable() + ";"; - } - - // TODO: Unity UV offsets - public override string GetFragmentPrepare() { - return node.precision.ToCode() + "4 " + GetVariable() + " = " + node.Evaluate() + ";"; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Color.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Color.cs.meta deleted file mode 100755 index 4e551377..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Color.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7e0f81cb63fbd57449cda3f78bbf4407 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Cubemap.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Cubemap.cs deleted file mode 100755 index b107197b..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Cubemap.cs +++ /dev/null @@ -1,32 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFP_Cubemap : SF_ShaderProperty { - - - public new SFP_Cubemap Initialize( SF_Node node ) { - base.nameType = "Cubemap"; - base.Initialize( node ); - return this; - } - - public override string GetInitializationLine() { - string defaultValue = "\"_Skybox\""; - return GetTagString() + GetVariable() + " (\"" + nameDisplay + "\", Cube) = " + defaultValue + " {}"; - } - - public override string GetVariableLine() { - return "uniform samplerCUBE " + GetVariable() + ";"; - } - - // TODO: UVs - public override string GetFragmentPrepare() { - return "fixed4 " + GetVariable() + " = " + node.Evaluate() + ";"; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Cubemap.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Cubemap.cs.meta deleted file mode 100755 index a6cbd8e5..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Cubemap.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 89bae648dacc8ce46bd4441582e727a3 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Matrix4x4Property.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Matrix4x4Property.cs deleted file mode 100644 index 01a9df50..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Matrix4x4Property.cs +++ /dev/null @@ -1,35 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFP_Matrix4x4Property : SF_ShaderProperty { - - public new SFP_Matrix4x4Property Initialize( SF_Node node ) { - base.nameType = "Matrix 4x4"; - base.Initialize( node ); - global = true; - return this; - } - - public override string GetInitializationLine() { - return "";// GetTagString() + GetVariable() + " (\"" + nameDisplay + "\", Vector) = (" + GetValue().r + "," + GetValue().g + "," + GetValue().b + "," + GetValue().a + ")"; - } - - Color GetValue() { - return Color.black; - } - - public override string GetVariableLine() { - return "uniform " + node.precision.ToCode() + "4x4 " + GetVariable() + ";"; - } - - // TODO: Unity UV offsets - public override string GetFragmentPrepare() { - return node.precision.ToCode() + "4x4 " + GetVariable() + " = " + node.Evaluate() + ";"; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Matrix4x4Property.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Matrix4x4Property.cs.meta deleted file mode 100644 index 5139912f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Matrix4x4Property.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 053697bbbcf06d047bee1332920a9ab4 -timeCreated: 1436193035 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Slider.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Slider.cs deleted file mode 100755 index 63a6bf54..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Slider.cs +++ /dev/null @@ -1,49 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFP_Slider : SF_ShaderProperty { - - - public bool isBumpmap = false; - - public new SFP_Slider Initialize( SF_Node node ) { - base.nameType = "Slider"; - base.Initialize( node ); - return this; - } - - - - public override string GetInitializationLine() { - string defaultValue = GetCurrent().ToString(); - // name ("display name", Range (min, max)) = number - return GetTagString() + GetVariable() + " (\"" + nameDisplay + "\", Range(" + GetMin() + ", " + GetMax() + ")) = " + defaultValue; - } - - float GetMin() { - return ( node as SFN_Slider ).min; - } - - float GetMax() { - return ( node as SFN_Slider ).max; - } - - float GetCurrent() { - return ( node as SFN_Slider ).current; - } - - public override string GetVariableLine() { - return "uniform " + node.precision.ToCode() + " " + GetVariable() + ";"; - } - - // TODO: Unity UV offsets - public override string GetFragmentPrepare() { - return node.precision.ToCode()+" " + GetVariable() + " = " + node.Evaluate() + ";"; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Slider.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Slider.cs.meta deleted file mode 100755 index 850fd5dc..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Slider.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d8fff7db79c3ac549a795dc95865193a -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_SwitchProperty.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_SwitchProperty.cs deleted file mode 100755 index 1f6c5d58..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_SwitchProperty.cs +++ /dev/null @@ -1,31 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFP_SwitchProperty : SF_ShaderProperty { - - public new SFP_SwitchProperty Initialize( SF_Node node ) { - base.nameType = "Toggle"; - base.Initialize( node ); - return this; - } - - public override string GetInitializationLine() { - string defaultValue = base.node.texture.dataUniform.x.ToString(); - return GetTagString() + "[MaterialToggle] " + GetVariable() + " (\"" + nameDisplay + "\", Float ) = " + defaultValue; - } - - public override string GetVariableLine() { - return "uniform fixed " + GetVariable() + ";"; - } - - // TODO: Unity UV offsets - //public override string GetFragmentPrepare() { - // return "fixed4 " + GetVariable() + " = " + node.Evaluate() + ";"; - //} - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_SwitchProperty.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_SwitchProperty.cs.meta deleted file mode 100644 index 7569fc45..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_SwitchProperty.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 310feff246d89480987042663b16e1e1 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Tex2d.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Tex2d.cs deleted file mode 100755 index 0d1e5bd7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Tex2d.cs +++ /dev/null @@ -1,50 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFP_Tex2d : SF_ShaderProperty { - - - //public bool isBumpmap = false; // TODO: Is this even used? - - public new SFP_Tex2d Initialize( SF_Node node ) { - base.nameType = "Texture (2D)"; - base.Initialize( node ); - return this; - } - - - public override string GetInitializationLine() { - //string defaultValue = isBumpmap ? "\"bump\"" : "\"white\""; - - NoTexValue noTexValue = NoTexValue.Black; - - if(base.node is SFN_Tex2d) - noTexValue = (base.node as SFN_Tex2d).noTexValue; - else if(base.node is SFN_Tex2dAsset) - noTexValue = (base.node as SFN_Tex2dAsset).noTexValue; - - return GetTagString() + GetVariable() + " (\"" + nameDisplay + "\", 2D) = \"" + noTexValue.ToString().ToLower() + "\" {}"; - } - - public override string GetVariableLine() { - string varName = GetVariable(); - - string s = "uniform sampler2D " + varName + ";"; - if( !tagNoScaleOffset ) { - s += " uniform float4 " + varName + "_ST;"; - } - - return s; - } - - - public override string GetFragmentPrepare() { - return "fixed4 " + GetVariable() + " = " + node.Evaluate() + ";"; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Tex2d.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Tex2d.cs.meta deleted file mode 100755 index 174c1a30..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Tex2d.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 30072d9ca7304e4419000143e2124c81 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ToggleProperty.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ToggleProperty.cs deleted file mode 100755 index f56da373..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ToggleProperty.cs +++ /dev/null @@ -1,31 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFP_ToggleProperty : SF_ShaderProperty { - - public new SFP_ToggleProperty Initialize( SF_Node node ) { - base.nameType = "Toggle"; - base.Initialize( node ); - return this; - } - - public override string GetInitializationLine() { - string defaultValue = base.node.texture.dataUniform.x.ToString(); - return GetTagString() + "[MaterialToggle] " + GetVariable() + " (\"" + nameDisplay + "\", Float ) = " + defaultValue; - } - - public override string GetVariableLine() { - return "uniform fixed " + GetVariable() + ";"; - } - - // TODO: Unity UV offsets - //public override string GetFragmentPrepare() { - // return "fixed4 " + GetVariable() + " = " + node.Evaluate() + ";"; - //} - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ToggleProperty.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ToggleProperty.cs.meta deleted file mode 100644 index b92f23a4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ToggleProperty.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 576fd6450a0cb4342ac9df49954d9802 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ValueProperty.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ValueProperty.cs deleted file mode 100755 index 3078b183..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ValueProperty.cs +++ /dev/null @@ -1,31 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFP_ValueProperty : SF_ShaderProperty { - - public new SFP_ValueProperty Initialize( SF_Node node ) { - base.nameType = "Value"; - base.Initialize( node ); - return this; - } - - public override string GetInitializationLine() { - string defaultValue = base.node.texture.dataUniform.x.ToString(); - return GetTagString() + GetVariable() + " (\"" + nameDisplay + "\", Float ) = " + defaultValue; - } - - public override string GetVariableLine() { - return "uniform "+node.precision.ToCode()+" " + GetVariable() + ";"; - } - - // TODO: Unity UV offsets - public override string GetFragmentPrepare() { - return node.precision.ToCode() + "4 " + GetVariable() + " = " + node.Evaluate() + ";"; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ValueProperty.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ValueProperty.cs.meta deleted file mode 100755 index 989d5319..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_ValueProperty.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 43479457355519949a7175ee9526d96e -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Vector4Property.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Vector4Property.cs deleted file mode 100755 index daf2475f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Vector4Property.cs +++ /dev/null @@ -1,38 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace ShaderForge { - - [System.Serializable] - public class SFP_Vector4Property : SF_ShaderProperty { - - - public bool isBumpmap = false; - - public new SFP_Vector4Property Initialize( SF_Node node ) { - base.nameType = "Vector 4"; - base.Initialize( node ); - return this; - } - - - public override string GetInitializationLine() { - return GetTagString() + GetVariable() + " (\"" + nameDisplay + "\", Vector) = (" + GetValue().r + "," + GetValue().g + "," + GetValue().b + "," + GetValue().a + ")"; - } - - Color GetValue() { - return ( node as SFN_Vector4Property ).texture.dataUniform; - } - - public override string GetVariableLine() { - return "uniform " + node.precision.ToCode() + "4 " + GetVariable() + ";"; - } - - // TODO: Unity UV offsets - public override string GetFragmentPrepare() { - return node.precision.ToCode() + "4 " + GetVariable() + " = " + node.Evaluate() + ";"; - } - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Vector4Property.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Vector4Property.cs.meta deleted file mode 100755 index 273d75f2..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SFP_Vector4Property.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8d2eadd39bae92549a09c1cb3349c112 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SF_ShaderProperty.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SF_ShaderProperty.cs deleted file mode 100755 index 35df622e..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SF_ShaderProperty.cs +++ /dev/null @@ -1,297 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; - - -namespace ShaderForge { - [System.Serializable] - public class SF_ShaderProperty : ScriptableObject { - - public bool tagHideInInspector = false; - public bool tagHDR = false; - public bool tagPerRendererData = false; - public bool tagNoScaleOffset = false; - public bool tagNormal = false; - - public string nameDisplay = ""; // The displayed name in the material inspector - public string nameType; // Used for labeling in the editor - public string nameInternal = "_"; // The internal shader code name - public SF_Node node; - - public bool global = false; - public bool overrideInternalName = false; - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - public string GetTagString() { - string s = ""; - if( tagHideInInspector ) - s += "[HideInInspector]"; - if( tagNoScaleOffset ) - s += "[NoScaleOffset]"; - if( tagNormal ) - s += "[Normal]"; - if( tagHDR ) - s += "[HDR]"; - if( tagPerRendererData ) - s += "[PerRendererData]"; - return s; - } - - public void Initialize(SF_Node node){ - this.node = node; - SetName( node.GetVariableName() ); - } - - public static string FormatInternalName(string s){ - Regex rgx = new Regex( "[^a-zA-Z0-9_]" ); - s = rgx.Replace( s, "" ); - return s; - } - - public virtual void UpdateInternalName() { - - if(overrideInternalName){ - nameInternal = node.variableName; - return; - } - - string s = nameDisplay; - - - s = FormatInternalName(s); - - s = "_" + s; - - - // TODO: Make sure it's valid and unique - - nameInternal = s; - } - - public void SetName( string s) { - nameDisplay = s; - if( !overrideInternalName ) - UpdateInternalName(); - } - - public void SetBothNameAndInternal(string s){ - s = FormatInternalName(s); - nameDisplay = s; - nameInternal = s; - } - - public void ToggleGlobal(){ - - - - string undoMsg = global ? "make " + nameDisplay + " local" : "make " + nameDisplay + " global"; - Undo.RecordObject(this,undoMsg); - Undo.RecordObject(node.editor.nodeView.treeStatus,undoMsg); - - List propList = node.editor.nodeView.treeStatus.propertyList; - - global = !global; - - - if(global){ - - if(propList.Contains(node)){ - propList.Remove(node); - } - - } else { - - if(!propList.Contains(node)){ - propList.Add(node); - } - - } - } - - - - - string[] replacements = new string[]{ - "_r","_g", - "_R","_G", - "_g","_b", - "_G","_B", - "_b","_a", - "_B","_A", - "_x","_y", - "_X","_Y", - "_y","_z", - "_Y","_Z", - "_z","_w", - "_Z","_W", - "(R)","(G)", - "(G)","(B)", - "(B)","(A)", - "(r)","(g)", - "(g)","(b)", - "(b)","(a)", - "(X)","(Y)", - "(Y)","(Z)", - "(Z)","(W)", - "(x)","(y)", - "(y)","(z)", - "(z)","(w)" - - }; - - public string GetClonedName(){ - - string oldName = nameDisplay; - string newName = nameDisplay; - bool done = false; - - for(int i=0;i< replacements.Length;i+=2){ - if(oldName.EndsWith(replacements[i])){ - newName = oldName.Substring(0,oldName.Length - replacements[i].Length) + replacements[i+1]; - done = true; - } - } - - // Numerical increments - if(!nameDisplay.StartsWith("node_")) - if(!done){ - if( TryGetNextNumericalName(ref newName) ){ - done = true; - } - } - - // Fallback - if(!done){ - newName = oldName + "_copy"; - done = true; - } - - - return newName; - - } - - public bool TryGetNextNumericalName(ref string sOut){ - - int digits = 0; - for(int i = nameDisplay.Length-1; i>=0; i-- ){ - if(char.IsNumber(nameDisplay[i])) - digits++; - else - break; - } - - if(digits == 0) - return false; - - - string strWoNum = nameDisplay.Substring(0,nameDisplay.Length-digits); - string strNum = nameDisplay.Substring(nameDisplay.Length-digits); - - int number = int.Parse(strNum); - - number++; - - sOut = strWoNum + number.ToString("D"+digits); // Makes sure it's 01 02 etc - return true; - } - - - public bool CanToggleGlobal(){ - if(this is SFP_ValueProperty) - return true; - if(this is SFP_Color) - return true; - if(this is SFP_Tex2d && node is SFN_Tex2dAsset) - return true; - if(this is SFP_Vector4Property) - return true; - //if( this is SFP_Matrix4x4Property ) - // return true; - return false; - } - - - public SF_ShaderProperty() { - // Empty - } - - - public virtual string GetVariable() { - return nameInternal; - //return "_" + node.GetVariableName(); - } - - //public virtual string GetVariable() { - // return nameInternal; // Override for textures - //} - - public string GetFilteredVariableLine() { - //if( this.nameInternal == "_SpecColor" ) { // TODO: Why? - // return null; - //} - - return GetVariableLine(); - - } - - public string Serialize(){ - string s = ""; - s += "glob:" + global.ToString(); - s += ",taghide:" + tagHideInInspector.ToString(); - s += ",taghdr:" + tagHDR.ToString(); - s += ",tagprd:" + tagPerRendererData.ToString(); - s += ",tagnsco:" + tagNoScaleOffset.ToString(); - s += ",tagnrm:" + tagNormal.ToString(); - return s; - } - - public void Deserialize( string key, string value ){ - switch( key ) { - case "glob": - global = bool.Parse( value ); - break; - case "taghide": - tagHideInInspector = bool.Parse( value ); - break; - case "taghdr": - tagHDR = bool.Parse( value ); - break; - case "tagprd": - tagPerRendererData = bool.Parse( value ); - break; - case "tagnsco": - tagNoScaleOffset = bool.Parse( value ); - break; - case "tagnrm": - tagNormal = bool.Parse( value ); - break; - } - } - - - public virtual string GetMulticompilePragma(){ - return ""; // Override for branching - } - - public virtual string GetInitializationLine() { - return ""; // Override, textures need to unpack before usage in the frag shader - } - - public virtual string GetVariableLine() { - return ""; // Override - } - - public virtual string GetFragmentPrepare() { - return ""; // Override - } - - - - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SF_ShaderProperty.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SF_ShaderProperty.cs.meta deleted file mode 100755 index 886f1502..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_ShaderProperties/SF_ShaderProperty.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d8c935ac774257c49ad63340aa7af37a -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility.meta deleted file mode 100755 index 4550660e..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: 8159890c121914a839942f4820d9ce63 -folderAsset: yes -DefaultImporter: - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/GUILines.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/GUILines.cs deleted file mode 100755 index 462cfd41..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/GUILines.cs +++ /dev/null @@ -1,478 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; -using System.Reflection; - -namespace ShaderForge { - - public class GUILines { - - public static Color connectionColor = new Color( 1f, 1f, 1f, 0.3f ); - - public static void Initialize() { - - } - - - - - - public static void DrawLine( Vector2 pointA, Vector2 pointB, Color color, float width, bool antiAlias ) { - Handles.BeginGUI(); - Handles.color = color; - if( antiAlias ) - Handles.DrawAAPolyLine( width, new Vector3[] { pointA, pointB } ); - else - Handles.DrawPolyLine( new Vector3[] { pointA, pointB } ); - Handles.EndGUI(); - } - - public static void DrawDisc( Vector2 center, float radius, Color color) { - Handles.BeginGUI(); - Handles.color = color; - Handles.DrawWireDisc(center,Vector3.forward,radius); - Handles.EndGUI(); - } - - - - - - public static void DrawLines( SF_Editor editor, Vector2[] points, Color color, float width, bool antiAlias, bool railway = false ) { - Handles.BeginGUI(); - Handles.color = color; - - - Vector3[] v3Pts = new Vector3[points.Length]; - for (int i = 0; i < points.Length; i++) { - points[i] = editor.nodeView.ZoomSpaceToScreenSpace( points[i] ); - v3Pts[i] = new Vector3(points[i].x, points[i].y); - } - - if( antiAlias ){ - if( railway ) { - DrawPolyLineWithRail( width, v3Pts ); - } else { - Handles.DrawAAPolyLine( width, v3Pts ); - } - } else { - Handles.DrawPolyLine( v3Pts ); - } - Handles.EndGUI(); - } - - - static void DrawPolyLineWithRail( float width, Vector3[] v3pts ) { - - Vector3[] pair = new Vector3[] { Vector3.zero, Vector3.zero }; - for( int i = 0; i < v3pts.Length - 1; i++ ) { - - Vector3 dir = (v3pts[i] - v3pts[i+1] ).normalized; - dir = new Vector3(-dir.y, dir.x); - Vector3 center = (v3pts[i] + v3pts[i+1] )*0.5f; - pair[0] = center + dir * 3; - pair[1] = center - dir * 3; - Handles.DrawAAPolyLine( pair ); - } - - Handles.DrawAAPolyLine( width, v3pts ); - } - - - - public static void Highlight( Rect r, float offset, int strength = 1 ) { - - //float width = 4; - //offset = 3; - //Color color = Color.yellow; - r.xMax += 1; - r = SF_Tools.GetExpanded( r, offset ); - - /* - Vector2 tl = new Vector2( r.x, r.y); - Vector2 tr = new Vector2( r.xMax, r.y ); - Vector2 bl = new Vector2( r.x, r.yMax ); - Vector2 br = new Vector2( r.xMax, r.yMax ); - Vector2 dn = new Vector2( 0f, width * 3 ); - Vector2 rg = new Vector2( width * 3, 0f ); - */ - - //Color prevCol = GUI.color; - //GUI.color = color; - - for( int i = 0; i < strength; i++ ) { - GUI.Box( r, string.Empty, SF_Styles.HighlightStyle ); - } - //GUI.color = prevCol; - - /* - for( int i = 0; i < strength; i++ ) { - GUI.Box( r, string.Empty, SF_Styles.HighlightStyle ); - }*/ - - - //GUI.Box( r, string.Empty, (GUIStyle)"flow node 0 on" ); - /* - for( int i = 0; i < strength; i++ ) { - DrawLine( tl, tr, color, width, true ); - DrawLine( tr, br, color, width, true ); - DrawLine( br, bl, color, width, true ); - DrawLine( bl, tl, color, width, true ); - - - DrawLine( tl + rg, tl + dn, color, width, true ); - DrawLine( tr - rg, tr + dn, color, width, true ); - DrawLine( bl + rg, bl - dn, color, width, true ); - DrawLine( br - rg, br - dn, color, width, true ); - - }*/ - - } - - - - - public static void DrawCubicBezier( Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, Color color, float width, bool antiAlias, int segments, bool railway = false ) { - Initialize(); - Vector2 lastV = CubicBezier( p0, p1, p2, p3, 0 ); - for( int i = 1; i <= segments; i++ ) { - Vector2 v = CubicBezier( p0, p1, p2, p3, i / (float)segments ); - - if( railway ) { - Vector2 dir = ( lastV - v ).normalized; - dir = new Vector2(-dir.y, dir.x)*2; - Vector2 center = ( v + lastV ) * 0.5f; - DrawLine( center + dir, center - dir, color, width, antiAlias ); - } else { - DrawLine( lastV, v, color, width, antiAlias ); - } - - lastV = v; - } - } - - public static void DrawCubicBezierOffset( float offset, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, Color color, float width, bool antiAlias, int segments ) { - Initialize(); - Vector2 lastV = CubicBezierOffset( offset, p0, p1, p2, p3, 0 ); - for( int i = 1; i <= segments; i++ ) { - Vector2 v = CubicBezierOffset( offset, p0, p1, p2, p3, i / (float)segments ); - DrawLine( lastV, v, color, width, antiAlias ); - lastV = v; - } - } - - - - - public static Vector2[] ConnectionBezierOffsetArray(float offset, SF_NodeConnector startCon, SF_NodeConnector endCon, int segments){ - - - Vector2 start = startCon.GetConnectionPoint(); - Vector2 end = endCon.GetConnectionPoint(); - - bool reversed = (start.x < end.x); - - Vector2[] points; - - int pCount = (segments+1); // Point count per bezier - - if(reversed) - points = new Vector2[pCount*2]; // Two curves - else - points = new Vector2[pCount]; - - - - if(reversed){ - - // Calculate new start/end positions! - // We want an S shape, which essentially is two curves with a connected center - // Let's define the new points! - - - float midVert; - - if(startCon.node.rect.center.y > endCon.node.rect.center.y) - midVert = (startCon.node.BoundsTop() + endCon.node.BoundsBottom())/2; - else - midVert = (startCon.node.BoundsBottom() + endCon.node.BoundsTop())/2; - - - - float deltaX = Mathf.Abs(start.x-end.x); - float mul = Mathf.InverseLerp(0f,100f,deltaX); - mul = SF_Tools.Smoother(mul) * 0.70710678118f; - - - Vector2 bAp0 = start; // Start Point - Vector2 bAp3 = new Vector2(start.x, midVert); // End Point - - - - float tangentMag = Mathf.Abs(bAp0.y-bAp3.y)*mul; // TODO: Scale based on length if smaller than something - Vector2 tangentVec = new Vector2(tangentMag, 0f); - - - Vector2 bAp1 = bAp0 - tangentVec; // Start Tangent - Vector2 bAp2 = bAp3 - tangentVec; // End Tangent - - - for(int i=0;i end.x) ? 1f : 4f; - - float xHalfway = Mathf.Abs(end.x-start.x)*0.5f * mult; - - Vector2 p1 = new Vector2(start.x-xHalfway, start.y); - Vector2 p2 = new Vector2(end.x+xHalfway, end.y); - return CubicBezierOffset(offset, start, p1, p2, end, t); - } - - public static Vector2 CubicBezierOffset( float offset, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t ) { - Vector2 a = QuadBezier( p0, p1, p2, t ); - Vector2 b = QuadBezier( p1, p2, p3, t ); - Vector2 origin = Lerp( a, b, t ); - Vector2 tangent = ( b - a ).normalized; - Vector2 normal = new Vector2( -tangent.y, tangent.x ); - return origin + normal * offset; - } - - public static Vector2 CubicBezier( Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t ) { - float omt = 1f - t; - float omt2 = omt * omt; - float t2 = t * t; - return p0 * ( omt2 * omt ) + - p1 * ( 3f * omt2 * t ) + - p2 * ( 3f * omt * t2 ) + - p3 * ( t2 * t ); - } - - public static Vector2 QuadBezier( Vector2 p0, Vector2 p1, Vector2 p2, float t ) { - float tsq = t * t; - float t2 = t * 2; - return p0 * ( tsq - t2 + 1 ) + p1 * ( t2 - 2 * tsq ) + p2 * tsq; - - } - - public static Vector2 Lerp( Vector2 v0, Vector2 v1, float t ) { - return ( v0 * ( 1f - t ) + t * v1 ); - } - - - - - public static void QuickBezier(Vector2 p0, Vector2 p1, Color color, int detail = 12, int width = 2){ - - Vector2 prevPoint = p0; - for(float i=1;i(); - _blitCamera.enabled = false; - _blitCamera.clearFlags = CameraClearFlags.Nothing; - _blitCamera.orthographic = true; - _blitCamera.orthographicSize = 1f; - _blitCamera.nearClipPlane = 3.5f; - _blitCamera.farClipPlane = 4.5f; - _blitCamera.enabled = false; - _blitCamera.cullingMask = ( 1 << 7 ); - } - return _blitCamera; - } - } - - - - - - - static string[] defaultInputNames = new string[] { - "_A", - "_B", - "_C", - "_D", - "_E", - "_F", - "_G", - "_H", - "_I", - "_J", - "_K", - "_L" - }; - - public static SF_Node currentNode; - static Material _mat; - public static Material mat { - get { - if( _mat == null ) - _mat = new Material( Shader.Find( "Hidden/Shader Forge/FillColor" ) ); - return _mat; - } - } - - static Material _matColor; - public static Material matColor { - get { - if( _matColor == null ) - _matColor = new Material( Shader.Find( "Hidden/Shader Forge/FillColor" ) ); - return _matColor; - } - } - - static Material _matExtractChannel; - public static Material matExtractChannel { - get { - if( _matExtractChannel == null ) - _matExtractChannel = new Material( Shader.Find( "Hidden/Shader Forge/ExtractChannel" ) ); - return _matExtractChannel; - } - } - - public static void RenderUsingViewport( RenderTexture target, string shader ) { - LoadShaderForMaterial( shader ); - RenderUsingViewport( target, mat ); - } - - static void LoadShaderForMaterial( string shader ) { - Shader s = Shader.Find( "Hidden/Shader Forge/" + shader ); - if(s == null) - Debug.LogError("Shader not found: " + shader ); - mat.shader = s; - } - - public static void Render( RenderTexture target, string shader, string[] inputNames, Texture[] inputTextures ) { - - LoadShaderForMaterial( shader ); - - for( int i = 0; i < inputTextures.Length; i++ ) { - mat.SetTexture( "_" + inputNames[i], inputTextures[i] ); - } - - Render( target, mat ); - } - - public static void RenderUsingViewport( RenderTexture target, string shader, string[] inputNames, Texture[] inputTextures ) { - LoadShaderForMaterial( shader ); - for( int i = 0; i < inputTextures.Length; i++ ) { - mat.SetTexture( "_" + inputNames[i], inputTextures[i] ); - } - RenderUsingViewport( target, mat ); - } - - public static void Render( RenderTexture target, string shader, params Texture[] inputTextures ) { - Render( target, shader, defaultInputNames, inputTextures ); - } - - public static void Render( RenderTexture target, Material material ) { - ApplyComponentCountMask( material ); - - blitCamera.targetTexture = target; - Graphics.DrawMesh( blitQuad, Vector3.zero, Quaternion.identity, material, 7, blitCamera ); - blitCamera.Render(); - blitCamera.targetTexture = null; - - //Graphics.SetRenderTarget( target ); - //Graphics.DrawMesh( blitQuad, Matrix4x4.identity, material, -1, null ); - //Graphics.DrawMeshNow( blitQuad, -Vector3.forward * 0.5f, Quaternion.identity ); - - //Graphics.Blit( null, target, material ); - } - - static void ApplyComponentCountMask(Material material) { - int cc = GetComponentCountAndPrepare(material); - Vector4 mask = CompCountToMask( cc ); - material.SetVector( "_OutputMask", mask ); - } - - static int GetComponentCountAndPrepare(Material material) { - if( currentNode != null ) { - currentNode.PrepareRendering( material ); - return currentNode.ReadComponentCountFromFirstOutput(); - } - return 4; - } - - public static void RenderUsingViewport( RenderTexture target, Material material ) { - ApplyComponentCountMask( material ); - bool sphere = SF_Settings.nodeRenderMode == NodeRenderMode.Spheres || SF_Settings.nodeRenderMode == NodeRenderMode.Mixed; - SF_Editor.instance.preview.DrawMesh( target, material, sphere ); - } - - public static Vector4 CompCountToMask(int cc) { - if( cc == 2 ) - return new Vector4( 1, 1, 0, 0 ); - if( cc == 3 ) - return new Vector4( 1, 1, 1, 0 ); - return Vector4.one; - } - - public static void Render( RenderTexture target, Color color ) { - matColor.color = color; - Render( target, matColor ); - } - - - - - } - -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Blit.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Blit.cs.meta deleted file mode 100644 index 841e3dd0..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Blit.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 03fa839fa4cf8e146aef035b18b2fe8c -timeCreated: 1444468702 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ColorPicker.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ColorPicker.cs deleted file mode 100755 index 4d275798..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ColorPicker.cs +++ /dev/null @@ -1,863 +0,0 @@ -/* -using System; -using UnityEngine; -using UnityEngineInternal; -using UnityEditor; -using UnityEditorInternal; - -namespace ShaderForge { - public class SF_ColorPicker : EditorWindow { - private enum ColorBoxMode { - SV_H, - HV_S, - HS_V, - BG_R, - BR_G, - RG_B, - EyeDropper - } - private enum SliderMode { - RGB, - HSV - } - private class Styles { - public GUIStyle pickerBox = "ColorPickerBox"; - public GUIStyle thumb2D = "ColorPicker2DThumb"; - public GUIStyle thumbHoriz = "ColorPickerHorizThumb"; - public GUIStyle thumbVert = "ColorPickerVertThumb"; - public GUIStyle headerLine = "IN Title"; - public GUIStyle colorPickerBox = "ColorPickerBox"; - public GUIStyle background = "ColorPickerBackground"; - public GUIContent eyeDropper = EditorGUIUtility.IconContent( "EyeDropper.Large" ); - public GUIContent colorCycle = EditorGUIUtility.IconContent( "ColorPicker.CycleColor" ); - public GUIContent colorToggle = EditorGUIUtility.TextContent( "ColorPicker.ColorFoldout" ); - public GUIContent sliderToggle = EditorGUIUtility.TextContent( "ColorPicker.SliderFoldout" ); - public GUIContent presetsToggle = new GUIContent( "Presets" ); - public GUIContent sliderCycle = EditorGUIUtility.IconContent( "ColorPicker.CycleSlider" ); - } - private const int kHueRes = 64; - private const int kColorBoxSize = 8; - private const int kEyeDropperHeight = 95; - private const int kSlidersHeight = 82; - private const int kColorBoxHeight = 162; - private const int kPresetsHeight = 300; - private static SF_ColorPicker s_SharedColorPicker; - [SerializeField] - private Color m_Color = Color.black; - [SerializeField] - private Color m_OriginalColor; - [SerializeField] - private float m_R; - [SerializeField] - private float m_G; - [SerializeField] - private float m_B; - [SerializeField] - private float m_H; - [SerializeField] - private float m_S; - [SerializeField] - private float m_V; - [SerializeField] - private float m_A = 1f; - [SerializeField] - private float m_ColorSliderSize = 4f; - [SerializeField] - private Texture2D m_ColorSlider; - [SerializeField] - private float m_SliderValue; - [SerializeField] - private Color[] m_Colors; - [SerializeField] - private Texture2D m_ColorBox; - private static int s_Slider2Dhash = "Slider2D".GetHashCode(); - [SerializeField] - private bool m_ShowColors = true; - [SerializeField] - private bool m_ShowSliders = true; - [SerializeField] - private bool m_ShowPresets = true; - [SerializeField] - private bool m_IsOSColorPicker; - [SerializeField] - private bool m_resetKeyboardControl; - [SerializeField] - private bool m_ShowAlpha = true; - private Texture2D m_RTexture; - private float m_RTextureG = -1f; - private float m_RTextureB = -1f; - private Texture2D m_GTexture; - private float m_GTextureR = -1f; - private float m_GTextureB = -1f; - private Texture2D m_BTexture; - private float m_BTextureR = -1f; - private float m_BTextureG = -1f; - [SerializeField] - private Texture2D m_HueTexture; - private float m_HueTextureS = -1f; - private float m_HueTextureV = -1f; - [SerializeField] - private Texture2D m_SatTexture; - private float m_SatTextureH = -1f; - private float m_SatTextureV = -1f; - [SerializeField] - private Texture2D m_ValTexture; - private float m_ValTextureH = -1f; - private float m_ValTextureS = -1f; - [SerializeField] - private int m_TextureColorSliderMode = -1; - [SerializeField] - private Vector2 m_LastConstantValues = new Vector2( -1f, -1f ); - [NonSerialized] - private int m_TextureColorBoxMode = -1; - [SerializeField] - private float m_LastConstant = -1f; - [SerializeField] - private ContainerWindow m_TrackingWindow; - [SerializeField] - private SF_ColorPicker.ColorBoxMode m_ColorBoxMode = SF_ColorPicker.ColorBoxMode.BG_R; - [SerializeField] - private SF_ColorPicker.ColorBoxMode m_OldColorBoxMode; - [SerializeField] - private SF_ColorPicker.SliderMode m_SliderMode = SF_ColorPicker.SliderMode.HSV; - [SerializeField] - private Texture2D m_AlphaTexture; - private float m_OldAlpha = -1f; - [SerializeField] - private GUIView m_DelegateView; - private PresetLibraryEditor m_ColorLibraryEditor; - private PresetLibraryEditorState m_ColorLibraryEditorState; - private static SF_ColorPicker.Styles styles; - public static string presetsEditorPrefID { - get { - return "Color"; - } - } - private bool colorChanged { - get; - set; - } - public static bool visible { - get { - return SF_ColorPicker.s_SharedColorPicker != null; - } - } - public static Color color { - get { - return SF_ColorPicker.get.m_Color; - } - set { - SF_ColorPicker.get.SetColor( value ); - } - } - public static SF_ColorPicker get { - get { - if( !SF_ColorPicker.s_SharedColorPicker ) { - UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll( typeof( SF_ColorPicker ) ); - if( array != null && array.Length > 0 ) { - SF_ColorPicker.s_SharedColorPicker = (SF_ColorPicker)array[0]; - } - if( !SF_ColorPicker.s_SharedColorPicker ) { - SF_ColorPicker.s_SharedColorPicker = ScriptableObject.CreateInstance(); - SF_ColorPicker.s_SharedColorPicker.wantsMouseMove = true; - } - } - return SF_ColorPicker.s_SharedColorPicker; - } - } - public string currentPresetLibrary { - get { - this.InitIfNeeded(); - return this.m_ColorLibraryEditor.currentLibraryWithoutExtension; - } - set { - this.InitIfNeeded(); - this.m_ColorLibraryEditor.currentLibraryWithoutExtension = value; - } - } - public SF_ColorPicker() { - base.hideFlags = HideFlags.DontSave; - this.m_ShowSliders = ( EditorPrefs.GetInt( "CPSliderShow", 1 ) != 0 ); - this.m_SliderMode = (SF_ColorPicker.SliderMode)EditorPrefs.GetInt( "CPSliderMode", 0 ); - this.m_ShowColors = ( EditorPrefs.GetInt( "CPColorShow", 1 ) != 0 ); - this.m_ColorBoxMode = (SF_ColorPicker.ColorBoxMode)EditorPrefs.GetInt( "CPColorMode", 0 ); - this.m_IsOSColorPicker = EditorPrefs.GetBool( "UseOSColorPicker" ); - this.m_ShowPresets = ( EditorPrefs.GetInt( "CPPresetsShow", 1 ) != 0 ); - EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine( EditorApplication.update, new EditorApplication.CallbackFunction( this.PollOSColorPicker ) ); - } - private void OnSelectionChange() { - this.m_resetKeyboardControl = true; - base.Repaint(); - } - private void RGBToHSV() { - EditorGUIUtility.RGBToHSV( new Color( this.m_R, this.m_G, this.m_B, 1f ), out this.m_H, out this.m_S, out this.m_V ); - } - private void HSVToRGB() { - Color color = EditorGUIUtility.HSVToRGB( this.m_H, this.m_S, this.m_V ); - this.m_R = color.r; - this.m_G = color.g; - this.m_B = color.b; - } - private static void swap( ref float f1, ref float f2 ) { - float num = f1; - f1 = f2; - f2 = num; - } - private Vector2 Slider2D( Rect rect, Vector2 value, Vector2 maxvalue, Vector2 minvalue, GUIStyle backStyle, GUIStyle thumbStyle ) { - if( backStyle == null ) { - return value; - } - if( thumbStyle == null ) { - return value; - } - int controlID = GUIUtility.GetControlID( SF_ColorPicker.s_Slider2Dhash, FocusType.Native ); - if( maxvalue.x < minvalue.x ) { - SF_ColorPicker.swap( ref maxvalue.x, ref minvalue.x ); - } - if( maxvalue.y < minvalue.y ) { - SF_ColorPicker.swap( ref maxvalue.y, ref minvalue.y ); - } - float num = ( thumbStyle.fixedHeight != 0f ) ? thumbStyle.fixedHeight : ( (float)thumbStyle.padding.vertical ); - float num2 = ( thumbStyle.fixedWidth != 0f ) ? thumbStyle.fixedWidth : ( (float)thumbStyle.padding.horizontal ); - Vector2 vector = new Vector2( ( rect.width - (float)( backStyle.padding.right + backStyle.padding.left ) - num2 * 2f ) / ( maxvalue.x - minvalue.x ), ( rect.height - (float)( backStyle.padding.top + backStyle.padding.bottom ) - num * 2f ) / ( maxvalue.y - minvalue.y ) ); - Rect position = new Rect( rect.x + value.x * vector.x + num2 / 2f + (float)backStyle.padding.left - minvalue.x * vector.x, rect.y + value.y * vector.y + num / 2f + (float)backStyle.padding.top - minvalue.y * vector.y, num2, num ); - Event current = Event.current; - switch( current.GetTypeForControl( controlID ) ) { - case EventType.MouseDown: - if( rect.Contains( current.mousePosition ) ) { - GUIUtility.hotControl = controlID; - value.x = ( current.mousePosition.x - rect.x - num2 - (float)backStyle.padding.left ) / vector.x + minvalue.x; - value.y = ( current.mousePosition.y - rect.y - num - (float)backStyle.padding.top ) / vector.y + minvalue.y; - GUI.changed = true; - Event.current.Use(); - } - break; - case EventType.MouseUp: - if( GUIUtility.hotControl == controlID ) { - GUIUtility.hotControl = 0; - current.Use(); - } - break; - case EventType.MouseDrag: - if( GUIUtility.hotControl == controlID ) { - value.x = ( current.mousePosition.x - rect.x - num2 - (float)backStyle.padding.left ) / vector.x + minvalue.x; - value.y = ( current.mousePosition.y - rect.y - num - (float)backStyle.padding.top ) / vector.y + minvalue.y; - value.x = Mathf.Clamp( value.x, minvalue.x, maxvalue.x ); - value.y = Mathf.Clamp( value.y, minvalue.y, maxvalue.y ); - GUI.changed = true; - Event.current.Use(); - } - break; - case EventType.Repaint: - backStyle.Draw( rect, GUIContent.none, controlID ); - thumbStyle.Draw( position, GUIContent.none, controlID ); - break; - } - return value; - } - private void RGBSliders() { - bool changed = GUI.changed; - GUI.changed = false; - this.m_RTexture = SF_ColorPicker.Update1DSlider( this.m_RTexture, 8, this.m_G, this.m_B, ref this.m_RTextureG, ref this.m_RTextureB, 0, false ); - this.m_GTexture = SF_ColorPicker.Update1DSlider( this.m_GTexture, 8, this.m_R, this.m_B, ref this.m_GTextureR, ref this.m_GTextureB, 1, false ); - this.m_BTexture = SF_ColorPicker.Update1DSlider( this.m_BTexture, 8, this.m_R, this.m_G, ref this.m_BTextureR, ref this.m_BTextureG, 2, false ); - float num = (float)( (int)Mathf.Round( this.m_R * 255f ) ); - float num2 = (float)( (int)Mathf.Round( this.m_G * 255f ) ); - float num3 = (float)( (int)Mathf.Round( this.m_B * 255f ) ); - num = this.TexturedSlider( this.m_RTexture, "R", num, 0f, 255f ); - num2 = this.TexturedSlider( this.m_GTexture, "G", num2, 0f, 255f ); - num3 = this.TexturedSlider( this.m_BTexture, "B", num3, 0f, 255f ); - if( GUI.changed ) { - this.m_R = num / 255f; - this.m_G = num2 / 255f; - this.m_B = num3 / 255f; - this.RGBToHSV(); - } - GUI.changed |= changed; - } - private static Texture2D Update1DSlider( Texture2D tex, int xSize, float const1, float const2, ref float oldConst1, ref float oldConst2, int idx, bool hsvSpace ) { - if( !tex || const1 != oldConst1 || const2 != oldConst2 ) { - if( !tex ) { - tex = SF_ColorPicker.MakeTexture( xSize, 2 ); - } - Color[] array = new Color[xSize * 2]; - Color black = Color.black; - Color black2 = Color.black; - switch( idx ) { - case 0: - black = new Color( 0f, const1, const2, 1f ); - black2 = new Color( 1f, 0f, 0f, 0f ); - break; - case 1: - black = new Color( const1, 0f, const2, 1f ); - black2 = new Color( 0f, 1f, 0f, 0f ); - break; - case 2: - black = new Color( const1, const2, 0f, 1f ); - black2 = new Color( 0f, 0f, 1f, 0f ); - break; - case 3: - black = new Color( 0f, 0f, 0f, 1f ); - black2 = new Color( 1f, 1f, 1f, 0f ); - break; - } - SF_ColorPicker.FillArea( xSize, 2, array, black, black2, new Color( 0f, 0f, 0f, 0f ) ); - if( hsvSpace ) { - SF_ColorPicker.HSVToRGBArray( array ); - } - oldConst1 = const1; - oldConst2 = const2; - tex.SetPixels( array ); - tex.Apply(); - } - return tex; - } - private float TexturedSlider( Texture2D background, string text, float val, float min, float max ) { - Rect rect = GUILayoutUtility.GetRect( 16f, 16f, GUI.skin.label ); - GUI.Label( new Rect( rect.x, rect.y - 1f, 20f, 16f ), text ); - rect.x += 14f; - rect.width -= 50f; - if( Event.current.type == EventType.Repaint ) { - Rect screenRect = new Rect( rect.x + 1f, rect.y + 2f, rect.width - 2f, rect.height - 4f ); - Graphics.DrawTexture( screenRect, background, new Rect( 0.5f / (float)background.width, 0.5f / (float)background.height, 1f - 1f / (float)background.width, 1f - 1f / (float)background.height ), 0, 0, 0, 0, Color.grey ); - } - int controlID = EditorGUI.GetControlID( 869045, EditorGUIUtility.native, base.position ); - bool changed = GUI.changed; - GUI.changed = false; - val = GUI.HorizontalSlider( new Rect( rect.x, rect.y + 1f, rect.width, rect.height - 2f ), val, min, max, SF_ColorPicker.styles.pickerBox, SF_ColorPicker.styles.thumbHoriz ); - if( GUI.changed && EditorGUI.s_RecycledEditor.IsEditingControl( controlID ) ) { - EditorGUI.s_RecycledEditor.EndEditing(); - } - Rect position = new Rect( rect.xMax + 6f, rect.y, 30f, 16f ); - val = (float)( (int)EditorGUI.DoFloatField( EditorGUI.s_RecycledEditor, position, new Rect( 0f, 0f, 0f, 0f ), controlID, val, EditorGUI.kIntFieldFormatString, EditorStyles.numberField, false ) ); - val = Mathf.Clamp( val, min, max ); - GUI.changed |= changed; - return val; - } - private void HSVSliders() { - bool changed = GUI.changed; - GUI.changed = false; - this.m_HueTexture = SF_ColorPicker.Update1DSlider( this.m_HueTexture, 64, 1f, 1f, ref this.m_HueTextureS, ref this.m_HueTextureV, 0, true ); - this.m_SatTexture = SF_ColorPicker.Update1DSlider( this.m_SatTexture, 8, this.m_H, Mathf.Max( this.m_V, 0.2f ), ref this.m_SatTextureH, ref this.m_SatTextureV, 1, true ); - this.m_ValTexture = SF_ColorPicker.Update1DSlider( this.m_ValTexture, 8, this.m_H, this.m_S, ref this.m_ValTextureH, ref this.m_ValTextureS, 2, true ); - float num = (float)( (int)Mathf.Round( this.m_H * 359f ) ); - float num2 = (float)( (int)Mathf.Round( this.m_S * 255f ) ); - float num3 = (float)( (int)Mathf.Round( this.m_V * 255f ) ); - num = this.TexturedSlider( this.m_HueTexture, "H", num, 0f, 359f ); - num2 = this.TexturedSlider( this.m_SatTexture, "S", num2, 0f, 255f ); - num3 = this.TexturedSlider( this.m_ValTexture, "V", num3, 0f, 255f ); - if( GUI.changed ) { - this.m_H = num / 359f; - this.m_S = num2 / 255f; - this.m_V = num3 / 255f; - this.HSVToRGB(); - } - GUI.changed |= changed; - } - private static void FillArea( int xSize, int ySize, Color[] retval, Color topLeftColor, Color rightGradient, Color downGradient ) { - Color b = new Color( 0f, 0f, 0f, 0f ); - Color b2 = new Color( 0f, 0f, 0f, 0f ); - if( xSize > 1 ) { - b = rightGradient / (float)( xSize - 1 ); - } - if( ySize > 1 ) { - b2 = downGradient / (float)( ySize - 1 ); - } - Color color = topLeftColor; - int num = 0; - for( int i = 0; i < ySize; i++ ) { - Color color2 = color; - for( int j = 0; j < xSize; j++ ) { - retval[num++] = color2; - color2 += b; - } - color += b2; - } - } - private static void HSVToRGBArray( Color[] colors ) { - int num = colors.Length; - for( int i = 0; i < num; i++ ) { - Color color = colors[i]; - Color color2 = EditorGUIUtility.HSVToRGB( color.r, color.g, color.b ); - color2.a = color.a; - colors[i] = color2; - } - } - private void DrawColorSlider( Rect colorSliderRect, Vector2 constantValues ) { - if( Event.current.type != EventType.Repaint ) { - return; - } - if( this.m_ColorBoxMode != (SF_ColorPicker.ColorBoxMode)this.m_TextureColorSliderMode ) { - int num = (int)this.m_ColorSliderSize; - int num2; - if( this.m_ColorBoxMode == SF_ColorPicker.ColorBoxMode.SV_H ) { - num2 = 64; - } else { - num2 = (int)this.m_ColorSliderSize; - } - if( this.m_ColorSlider == null ) { - this.m_ColorSlider = SF_ColorPicker.MakeTexture( num, num2 ); - } - if( this.m_ColorSlider.width != num || this.m_ColorSlider.height != num2 ) { - this.m_ColorSlider.Resize( num, num2 ); - } - } - if( this.m_ColorBoxMode != (SF_ColorPicker.ColorBoxMode)this.m_TextureColorSliderMode || constantValues != this.m_LastConstantValues ) { - Color[] pixels = this.m_ColorSlider.GetPixels( 0 ); - int width = this.m_ColorSlider.width; - int height = this.m_ColorSlider.height; - switch( this.m_ColorBoxMode ) { - case SF_ColorPicker.ColorBoxMode.SV_H: - SF_ColorPicker.FillArea( width, height, pixels, new Color( 0f, 1f, 1f, 1f ), new Color( 0f, 0f, 0f, 0f ), new Color( 1f, 0f, 0f, 0f ) ); - SF_ColorPicker.HSVToRGBArray( pixels ); - break; - case SF_ColorPicker.ColorBoxMode.HV_S: - SF_ColorPicker.FillArea( width, height, pixels, new Color( this.m_H, 0f, Mathf.Max( this.m_V, 0.3f ), 1f ), new Color( 0f, 0f, 0f, 0f ), new Color( 0f, 1f, 0f, 0f ) ); - SF_ColorPicker.HSVToRGBArray( pixels ); - break; - case SF_ColorPicker.ColorBoxMode.HS_V: - SF_ColorPicker.FillArea( width, height, pixels, new Color( this.m_H, this.m_S, 0f, 1f ), new Color( 0f, 0f, 0f, 0f ), new Color( 0f, 0f, 1f, 0f ) ); - SF_ColorPicker.HSVToRGBArray( pixels ); - break; - case SF_ColorPicker.ColorBoxMode.BG_R: - SF_ColorPicker.FillArea( width, height, pixels, new Color( 0f, this.m_G, this.m_B, 1f ), new Color( 0f, 0f, 0f, 0f ), new Color( 1f, 0f, 0f, 0f ) ); - break; - case SF_ColorPicker.ColorBoxMode.BR_G: - SF_ColorPicker.FillArea( width, height, pixels, new Color( this.m_R, 0f, this.m_B, 1f ), new Color( 0f, 0f, 0f, 0f ), new Color( 0f, 1f, 0f, 0f ) ); - break; - case SF_ColorPicker.ColorBoxMode.RG_B: - SF_ColorPicker.FillArea( width, height, pixels, new Color( this.m_R, this.m_G, 0f, 1f ), new Color( 0f, 0f, 0f, 0f ), new Color( 0f, 0f, 1f, 0f ) ); - break; - } - this.m_ColorSlider.SetPixels( pixels, 0 ); - this.m_ColorSlider.Apply( true ); - } - Graphics.DrawTexture( colorSliderRect, this.m_ColorSlider, new Rect( 0.5f / (float)this.m_ColorSlider.width, 0.5f / (float)this.m_ColorSlider.height, 1f - 1f / (float)this.m_ColorSlider.width, 1f - 1f / (float)this.m_ColorSlider.height ), 0, 0, 0, 0, Color.grey ); - } - public static Texture2D MakeTexture( int width, int height ) { - return new Texture2D( width, height, TextureFormat.ARGB32, false ) { - hideFlags = HideFlags.HideAndDontSave, - wrapMode = TextureWrapMode.Clamp - //hideFlags = HideFlags.DontSave - }; - } - private void DrawColorSpaceBox( Rect colorBoxRect, float constantValue ) { - if( Event.current.type != EventType.Repaint ) { - return; - } - if( this.m_ColorBoxMode != (SF_ColorPicker.ColorBoxMode)this.m_TextureColorBoxMode ) { - int num = 8; - int num2; - if( this.m_ColorBoxMode == SF_ColorPicker.ColorBoxMode.HV_S || this.m_ColorBoxMode == SF_ColorPicker.ColorBoxMode.HS_V ) { - num2 = 64; - } else { - num2 = 8; - } - if( this.m_ColorBox == null ) { - this.m_ColorBox = SF_ColorPicker.MakeTexture( num2, num ); - } - if( this.m_ColorBox.width != num2 || this.m_ColorBox.height != num ) { - this.m_ColorBox.Resize( num2, num ); - } - } - if( this.m_ColorBoxMode != (SF_ColorPicker.ColorBoxMode)this.m_TextureColorBoxMode || this.m_LastConstant != constantValue ) { - this.m_Colors = this.m_ColorBox.GetPixels( 0 ); - int width = this.m_ColorBox.width; - int height = this.m_ColorBox.height; - switch( this.m_ColorBoxMode ) { - case SF_ColorPicker.ColorBoxMode.SV_H: - SF_ColorPicker.FillArea( width, height, this.m_Colors, new Color( this.m_H, 0f, 0f, 1f ), new Color( 0f, 1f, 0f, 0f ), new Color( 0f, 0f, 1f, 0f ) ); - SF_ColorPicker.HSVToRGBArray( this.m_Colors ); - break; - case SF_ColorPicker.ColorBoxMode.HV_S: - SF_ColorPicker.FillArea( width, height, this.m_Colors, new Color( 0f, this.m_S, 0f, 1f ), new Color( 1f, 0f, 0f, 0f ), new Color( 0f, 0f, 1f, 0f ) ); - SF_ColorPicker.HSVToRGBArray( this.m_Colors ); - break; - case SF_ColorPicker.ColorBoxMode.HS_V: - SF_ColorPicker.FillArea( width, height, this.m_Colors, new Color( 0f, 0f, this.m_V, 1f ), new Color( 1f, 0f, 0f, 0f ), new Color( 0f, 1f, 0f, 0f ) ); - SF_ColorPicker.HSVToRGBArray( this.m_Colors ); - break; - case SF_ColorPicker.ColorBoxMode.BG_R: - SF_ColorPicker.FillArea( width, height, this.m_Colors, new Color( this.m_R, 0f, 0f, 1f ), new Color( 0f, 0f, 1f, 0f ), new Color( 0f, 1f, 0f, 0f ) ); - break; - case SF_ColorPicker.ColorBoxMode.BR_G: - SF_ColorPicker.FillArea( width, height, this.m_Colors, new Color( 0f, this.m_G, 0f, 1f ), new Color( 0f, 0f, 1f, 0f ), new Color( 1f, 0f, 0f, 0f ) ); - break; - case SF_ColorPicker.ColorBoxMode.RG_B: - SF_ColorPicker.FillArea( width, height, this.m_Colors, new Color( 0f, 0f, this.m_B, 1f ), new Color( 1f, 0f, 0f, 0f ), new Color( 0f, 1f, 0f, 0f ) ); - break; - } - this.m_ColorBox.SetPixels( this.m_Colors, 0 ); - this.m_ColorBox.Apply( true ); - this.m_LastConstant = constantValue; - this.m_TextureColorBoxMode = (int)this.m_ColorBoxMode; - } - Graphics.DrawTexture( colorBoxRect, this.m_ColorBox, new Rect( 0.5f / (float)this.m_ColorBox.width, 0.5f / (float)this.m_ColorBox.height, 1f - 1f / (float)this.m_ColorBox.width, 1f - 1f / (float)this.m_ColorBox.height ), 0, 0, 0, 0, Color.grey ); - } - private void InitIfNeeded() { - if( SF_ColorPicker.styles == null ) { - SF_ColorPicker.styles = new SF_ColorPicker.Styles(); - } - if( this.m_ColorLibraryEditorState == null ) { - this.m_ColorLibraryEditorState = new PresetLibraryEditorState( SF_ColorPicker.presetsEditorPrefID ); - this.m_ColorLibraryEditorState.TransferEditorPrefsState( true ); - } - if( this.m_ColorLibraryEditor == null ) { - ScriptableObjectSaveLoadHelper helper = new ScriptableObjectSaveLoadHelper( "colors", SaveType.Text ); - this.m_ColorLibraryEditor = new PresetLibraryEditor( helper, this.m_ColorLibraryEditorState, new Action( this.PresetClickedCallback ) ); - this.m_ColorLibraryEditor.previewAspect = 1f; - this.m_ColorLibraryEditor.minMaxPreviewHeight = new Vector2( 14f, 14f ); - this.m_ColorLibraryEditor.settingsMenuRightMargin = 2f; - this.m_ColorLibraryEditor.useOnePixelOverlappedGrid = true; - this.m_ColorLibraryEditor.alwaysShowScrollAreaHorizontalLines = false; - this.m_ColorLibraryEditor.marginsForGrid = new RectOffset( 0, 0, 0, 0 ); - this.m_ColorLibraryEditor.marginsForList = new RectOffset( 0, 5, 2, 2 ); - } - } - private void PresetClickedCallback( int clickCount, object presetObject ) { - Color color = (Color)presetObject; - this.SetColor( color ); - this.colorChanged = true; - } - private void DoColorSwatchAndEyedropper() { - GUILayout.BeginHorizontal( new GUILayoutOption[0] ); - if( GUILayout.Button( SF_ColorPicker.styles.eyeDropper, GUIStyle.none, new GUILayoutOption[] - { - GUILayout.Width(40f), - GUILayout.ExpandWidth(false) - } ) ) { - EyeDropper.Start( this.m_Parent ); - this.m_ColorBoxMode = SF_ColorPicker.ColorBoxMode.EyeDropper; - GUIUtility.ExitGUI(); - } - Color color = new Color( this.m_R, this.m_G, this.m_B, this.m_A ); - Rect rect = GUILayoutUtility.GetRect( 20f, 20f, 20f, 20f, SF_ColorPicker.styles.SF_ColorPickerBox, new GUILayoutOption[] - { - GUILayout.ExpandWidth(true) - } ); - EditorGUIUtility.DrawColorSwatch( rect, color, this.m_ShowAlpha ); - if( Event.current.type == EventType.Repaint ) { - SF_ColorPicker.styles.pickerBox.Draw( rect, GUIContent.none, false, false, false, false ); - } - GUILayout.EndHorizontal(); - } - private void DoColorSpaceGUI() { - GUILayout.BeginHorizontal( new GUILayoutOption[0] ); - this.m_ShowColors = GUILayout.Toggle( this.m_ShowColors, SF_ColorPicker.styles.colorToggle, EditorStyles.foldout, new GUILayoutOption[0] ); - GUI.enabled = this.m_ShowColors; - if( GUILayout.Button( SF_ColorPicker.styles.colorCycle, GUIStyle.none, new GUILayoutOption[] - { - GUILayout.ExpandWidth(false) - } ) ) { - this.m_OldColorBoxMode = ( this.m_ColorBoxMode = ( this.m_ColorBoxMode + 1 ) % SF_ColorPicker.ColorBoxMode.EyeDropper ); - } - GUI.enabled = true; - GUILayout.EndHorizontal(); - if( this.m_ShowColors ) { - bool changed = GUI.changed; - GUILayout.BeginHorizontal( new GUILayoutOption[] - { - GUILayout.ExpandHeight(false) - } ); - Rect aspectRect = GUILayoutUtility.GetAspectRect( 1f, SF_ColorPicker.styles.pickerBox, new GUILayoutOption[] - { - GUILayout.MinWidth(64f), - GUILayout.MinHeight(64f), - GUILayout.MaxWidth(256f), - GUILayout.MaxHeight(256f) - } ); - EditorGUILayout.Space(); - Rect rect = GUILayoutUtility.GetRect( 8f, 32f, 64f, 128f, SF_ColorPicker.styles.pickerBox ); - rect.height = aspectRect.height; - GUILayout.EndHorizontal(); - GUI.changed = false; - switch( this.m_ColorBoxMode ) { - case SF_ColorPicker.ColorBoxMode.SV_H: - this.Slider3D( aspectRect, rect, ref this.m_S, ref this.m_V, ref this.m_H, SF_ColorPicker.styles.pickerBox, SF_ColorPicker.styles.thumb2D, SF_ColorPicker.styles.thumbVert ); - if( GUI.changed ) { - this.HSVToRGB(); - } - break; - case SF_ColorPicker.ColorBoxMode.HV_S: - this.Slider3D( aspectRect, rect, ref this.m_H, ref this.m_V, ref this.m_S, SF_ColorPicker.styles.pickerBox, SF_ColorPicker.styles.thumb2D, SF_ColorPicker.styles.thumbVert ); - if( GUI.changed ) { - this.HSVToRGB(); - } - break; - case SF_ColorPicker.ColorBoxMode.HS_V: - this.Slider3D( aspectRect, rect, ref this.m_H, ref this.m_S, ref this.m_V, SF_ColorPicker.styles.pickerBox, SF_ColorPicker.styles.thumb2D, SF_ColorPicker.styles.thumbVert ); - if( GUI.changed ) { - this.HSVToRGB(); - } - break; - case SF_ColorPicker.ColorBoxMode.BG_R: - this.Slider3D( aspectRect, rect, ref this.m_B, ref this.m_G, ref this.m_R, SF_ColorPicker.styles.pickerBox, SF_ColorPicker.styles.thumb2D, SF_ColorPicker.styles.thumbVert ); - if( GUI.changed ) { - this.RGBToHSV(); - } - break; - case SF_ColorPicker.ColorBoxMode.BR_G: - this.Slider3D( aspectRect, rect, ref this.m_B, ref this.m_R, ref this.m_G, SF_ColorPicker.styles.pickerBox, SF_ColorPicker.styles.thumb2D, SF_ColorPicker.styles.thumbVert ); - if( GUI.changed ) { - this.RGBToHSV(); - } - break; - case SF_ColorPicker.ColorBoxMode.RG_B: - this.Slider3D( aspectRect, rect, ref this.m_R, ref this.m_G, ref this.m_B, SF_ColorPicker.styles.pickerBox, SF_ColorPicker.styles.thumb2D, SF_ColorPicker.styles.thumbVert ); - if( GUI.changed ) { - this.RGBToHSV(); - } - break; - case SF_ColorPicker.ColorBoxMode.EyeDropper: - EyeDropper.DrawPreview( Rect.MinMaxRect( aspectRect.x, aspectRect.y, rect.xMax, aspectRect.yMax ) ); - break; - } - GUI.changed |= changed; - } - } - private void DoColorSliders() { - GUILayout.BeginHorizontal( new GUILayoutOption[0] ); - this.m_ShowSliders = GUILayout.Toggle( this.m_ShowSliders, SF_ColorPicker.styles.sliderToggle, EditorStyles.foldout, new GUILayoutOption[0] ); - GUI.enabled = this.m_ShowSliders; - if( GUILayout.Button( SF_ColorPicker.styles.sliderCycle, GUIStyle.none, new GUILayoutOption[] - { - GUILayout.ExpandWidth(false) - } ) ) { - this.m_SliderMode = ( this.m_SliderMode + 1 ) % (SF_ColorPicker.SliderMode)2; - GUI.changed = true; - } - GUI.enabled = true; - GUILayout.EndHorizontal(); - if( this.m_ShowSliders ) { - SF_ColorPicker.SliderMode sliderMode = this.m_SliderMode; - if( sliderMode != SF_ColorPicker.SliderMode.RGB ) { - if( sliderMode == SF_ColorPicker.SliderMode.HSV ) { - this.HSVSliders(); - } - } else { - this.RGBSliders(); - } - if( this.m_ShowAlpha ) { - this.m_AlphaTexture = SF_ColorPicker.Update1DSlider( this.m_AlphaTexture, 8, 0f, 0f, ref this.m_OldAlpha, ref this.m_OldAlpha, 3, false ); - this.m_A = this.TexturedSlider( this.m_AlphaTexture, "A", Mathf.Round( this.m_A * 255f ), 0f, 255f ) / 255f; - } - } - } - private void DoPresetsGUI() { - GUILayout.BeginHorizontal( new GUILayoutOption[0] ); - EditorGUI.BeginChangeCheck(); - this.m_ShowPresets = GUILayout.Toggle( this.m_ShowPresets, SF_ColorPicker.styles.presetsToggle, EditorStyles.foldout, new GUILayoutOption[0] ); - if( EditorGUI.EndChangeCheck() ) { - EditorPrefs.SetInt( "CPPresetsShow", ( !this.m_ShowPresets ) ? 0 : 1 ); - } - GUILayout.Space( 17f ); - GUILayout.EndHorizontal(); - if( this.m_ShowPresets ) { - GUILayout.Space( -18f ); - Rect rect = GUILayoutUtility.GetRect( 0f, Mathf.Clamp( this.m_ColorLibraryEditor.contentHeight, 40f, 250f ) ); - this.m_ColorLibraryEditor.OnGUI( rect, this.m_Color ); - } - } - private void OnGUI() { - this.InitIfNeeded(); - if( this.m_resetKeyboardControl ) { - GUIUtility.keyboardControl = 0; - this.m_resetKeyboardControl = false; - } - EventType type = Event.current.type; - if( type == EventType.ExecuteCommand ) { - string commandName = Event.current.commandName; - switch( commandName ) { - case "EyeDropperUpdate": - base.Repaint(); - break; - case "EyeDropperClicked": { - Color lastPickedColor = EyeDropper.GetLastPickedColor(); - this.m_R = lastPickedColor.r; - this.m_G = lastPickedColor.g; - this.m_B = lastPickedColor.b; - this.RGBToHSV(); - this.m_ColorBoxMode = this.m_OldColorBoxMode; - this.m_Color = new Color( this.m_R, this.m_G, this.m_B, this.m_A ); - this.SendEvent( true ); - break; - } - case "EyeDropperCancelled": - base.Repaint(); - this.m_ColorBoxMode = this.m_OldColorBoxMode; - break; - } - } - EditorGUIUtility.LookLikeControls( 15f, 30f ); - Rect rect = EditorGUILayout.BeginVertical( SF_ColorPicker.styles.background, new GUILayoutOption[0] ); - EditorGUI.BeginChangeCheck(); - this.DoColorSwatchAndEyedropper(); - GUILayout.Space( 10f ); - this.DoColorSpaceGUI(); - GUILayout.Space( 10f ); - this.DoColorSliders(); - GUILayout.Space( 10f ); - if( EditorGUI.EndChangeCheck() ) { - this.colorChanged = true; - } - this.DoPresetsGUI(); - GUILayout.Space( 10f ); - if( this.colorChanged ) { - EditorPrefs.SetInt( "CPSliderShow", ( !this.m_ShowSliders ) ? 0 : 1 ); - EditorPrefs.SetInt( "CPSliderMode", (int)this.m_SliderMode ); - EditorPrefs.SetInt( "CPColorShow", ( !this.m_ShowColors ) ? 0 : 1 ); - EditorPrefs.SetInt( "CPColorMode", (int)this.m_ColorBoxMode ); - } - if( this.colorChanged ) { - this.colorChanged = false; - this.m_Color = new Color( this.m_R, this.m_G, this.m_B, this.m_A ); - this.SendEvent( true ); - } - EditorGUILayout.EndVertical(); - if( rect.height > 0f ) { - this.SetHeight( rect.height ); - } - if( Event.current.type == EventType.KeyDown ) { - KeyCode keyCode = Event.current.keyCode; - if( keyCode != KeyCode.Return ) { - if( keyCode == KeyCode.Escape ) { - this.m_Color = this.m_OriginalColor; - this.SendEvent( false ); - base.Close(); - GUIUtility.ExitGUI(); - return; - } - if( keyCode != KeyCode.KeypadEnter ) { - return; - } - } - base.Close(); - } - } - private void SetHeight( float newHeight ) { - if( newHeight == base.position.height ) { - return; - } - base.minSize = new Vector2( 193f, newHeight ); - base.maxSize = new Vector2( 193f, newHeight ); - } - private void Slider3D( Rect boxPos, Rect sliderPos, ref float x, ref float y, ref float z, GUIStyle box, GUIStyle thumb2D, GUIStyle thumbHoriz ) { - Rect colorBoxRect = boxPos; - colorBoxRect.x += 1f; - colorBoxRect.y += 1f; - colorBoxRect.width -= 2f; - colorBoxRect.height -= 2f; - this.DrawColorSpaceBox( colorBoxRect, z ); - Vector2 value = new Vector2( x, 1f - y ); - value = this.Slider2D( boxPos, value, new Vector2( 0f, 0f ), new Vector2( 1f, 1f ), box, thumb2D ); - x = value.x; - y = 1f - value.y; - Rect colorSliderRect = new Rect( sliderPos.x + 1f, sliderPos.y + 1f, sliderPos.width - 2f, sliderPos.height - 2f ); - this.DrawColorSlider( colorSliderRect, new Vector2( x, y ) ); - z = GUI.VerticalSlider( sliderPos, z, 1f, 0f, box, thumbHoriz ); - } - private void SendEvent( bool exitGUI ) { - if( this.m_DelegateView ) { - Event e = EditorGUIUtility.CommandEvent( "ColorPickerChanged" ); - if( !this.m_IsOSColorPicker ) { - base.Repaint(); - } - this.m_DelegateView.SendEvent( e ); - if( !this.m_IsOSColorPicker && exitGUI ) { - GUIUtility.ExitGUI(); - } - } - } - public void SetColor( Color c ) { - if( this.m_IsOSColorPicker ) { - OSColorPicker.color = c; - } else { - if( this.m_Color.r == c.r && this.m_Color.g == c.g && this.m_Color.b == c.b && this.m_Color.a == c.a ) { - return; - } - this.m_resetKeyboardControl = true; - this.m_Color = c; - this.m_R = c.r; - this.m_G = c.g; - this.m_B = c.b; - this.RGBToHSV(); - this.m_A = c.a; - base.Repaint(); - } - } - public static void Show( GUIView viewToUpdate, Color col ) { - SF_ColorPicker.Show( viewToUpdate, col, true ); - } - public static void Show( GUIView viewToUpdate, Color col, bool showAlpha ) { - SF_ColorPicker.get.m_DelegateView = viewToUpdate; - SF_ColorPicker.color = col; - SF_ColorPicker.get.m_OriginalColor = col; - SF_ColorPicker.get.m_ShowAlpha = showAlpha; - if( SF_ColorPicker.get.m_IsOSColorPicker ) { - OSColorPicker.Show( showAlpha ); - } else { - SF_ColorPicker get = SF_ColorPicker.get; - get.title = "Color"; - float x = (float)EditorPrefs.GetInt( "CPickerWidth", (int)get.position.width ); - float y = (float)EditorPrefs.GetInt( "CPickerHeight", (int)get.position.height ); - get.minSize = new Vector2( x, y ); - get.maxSize = new Vector2( x, y ); - get.ShowAuxWindow(); - } - } - private void PollOSColorPicker() { - if( this.m_IsOSColorPicker ) { - if( !OSColorPicker.visible || Application.platform != RuntimePlatform.OSXEditor ) { - UnityEngine.Object.DestroyImmediate( this ); - } else { - Color color = OSColorPicker.color; - if( this.m_Color != color ) { - this.m_Color = color; - this.SendEvent( true ); - } - } - } - } - public void OnDestroy() { - if( this.m_ColorSlider ) { - UnityEngine.Object.DestroyImmediate( this.m_ColorSlider ); - } - if( this.m_ColorBox ) { - UnityEngine.Object.DestroyImmediate( this.m_ColorBox ); - } - if( this.m_RTexture ) { - UnityEngine.Object.DestroyImmediate( this.m_RTexture ); - } - if( this.m_GTexture ) { - UnityEngine.Object.DestroyImmediate( this.m_GTexture ); - } - if( this.m_BTexture ) { - UnityEngine.Object.DestroyImmediate( this.m_BTexture ); - } - if( this.m_HueTexture ) { - UnityEngine.Object.DestroyImmediate( this.m_HueTexture ); - } - if( this.m_SatTexture ) { - UnityEngine.Object.DestroyImmediate( this.m_SatTexture ); - } - if( this.m_ValTexture ) { - UnityEngine.Object.DestroyImmediate( this.m_ValTexture ); - } - if( this.m_AlphaTexture ) { - UnityEngine.Object.DestroyImmediate( this.m_AlphaTexture ); - } - ColorPicker.s_SharedColorPicker = null; - if( this.m_IsOSColorPicker ) { - OSColorPicker.Close(); - } - EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove( EditorApplication.update, new EditorApplication.CallbackFunction( this.PollOSColorPicker ) ); - if( this.m_ColorLibraryEditorState != null ) { - this.m_ColorLibraryEditorState.TransferEditorPrefsState( false ); - } - this.m_ColorLibraryEditor.UnloadUsedLibraries(); - EditorPrefs.SetInt( "CPickerWidth", (int)base.position.width ); - EditorPrefs.SetInt( "CPickerHeight", (int)base.position.height ); - } - } -} -*/ \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ColorPicker.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ColorPicker.cs.meta deleted file mode 100755 index 19902f24..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ColorPicker.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 58e7b6eb98a25e6459f959ec5d0ed3bd -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Debug.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Debug.cs deleted file mode 100755 index 7d841bed..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Debug.cs +++ /dev/null @@ -1,23 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; - -namespace ShaderForge{ - - public static class SF_Debug { - - public static bool nodes = false; - public static bool window = false; - public static bool evalFlow = false; - public static bool screenshot = false; - public static bool ghostNodes = false; - public static bool nodeActions = false; - public static bool performance = false; - public static bool nodePreviews = false; - public static bool dynamicNodeLoad = false; - public static bool deserialization = false; - public static bool renderDataNodes = false; - - } - -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Debug.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Debug.cs.meta deleted file mode 100755 index 2e6b5468..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Debug.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 193f27cce31804ce9bc01ff6947651da -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_DraggableSeparator.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_DraggableSeparator.cs deleted file mode 100755 index 12147039..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_DraggableSeparator.cs +++ /dev/null @@ -1,102 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; - -namespace ShaderForge { - [System.Serializable] - public class SF_DraggableSeparator : ScriptableObject { - - - [SerializeField] - public bool dragging = false; - - [SerializeField] - public Rect rect; - - [SerializeField] - public bool initialized = false; - - public void OnEnable() { - base.hideFlags = HideFlags.HideAndDontSave; - } - - [SerializeField] - int minX; - public int MinX { - get { - return minX; - } - set { - minX = value; - ClampX(); - } - } - - [SerializeField] - int maxX; - public int MaxX { - get { - return maxX; - } - set { - maxX = value; - ClampX(); - } - } - - public void Draw( int yPos, int height ) { - - rect.y = yPos; - rect.height = height; - rect.width = 7; - - GUI.Box( rect, "", EditorStyles.textField ); - Rect rHandle = new Rect( rect ); - rHandle.xMin += 0; - rHandle.xMax -= 0; - Rect uv = new Rect( rect ); - uv.x = 0; - uv.y = 0; - uv.width = 1; - uv.height /= SF_GUI.Handle_drag.height; - GUI.DrawTextureWithTexCoords( rHandle, SF_GUI.Handle_drag, uv ); - - if( rect.Contains( Event.current.mousePosition ) || dragging ) { - SF_GUI.AssignCursor( rect, MouseCursor.ResizeHorizontal ); - } - - if(Event.current.isMouse){ - - if( SF_GUI.ReleasedRawLMB() ) { - StopDrag(); - } - if( dragging ) { - UpdateDrag(); - } - if( SF_GUI.PressedLMB( rect ) ) { - StartDrag(); - } - } - } - - - void ClampX(){ - rect.x = Mathf.Clamp( rect.x, minX, maxX ); - } - int startDragOffset = 0; - void StartDrag() { - dragging = true; - startDragOffset = (int)(Event.current.mousePosition.x - rect.x); - } - void UpdateDrag() { - rect.x = Event.current.mousePosition.x - startDragOffset; - ClampX(); - } - void StopDrag() { - dragging = false; - } - - - } -} - diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_DraggableSeparator.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_DraggableSeparator.cs.meta deleted file mode 100755 index c0eefbb1..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_DraggableSeparator.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: dd68a761edae39b44918ba61f5f84440 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Extensions.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Extensions.cs deleted file mode 100644 index a31592e8..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Extensions.cs +++ /dev/null @@ -1,531 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; - -namespace ShaderForge{ - - public enum RectBorder{ - TopLeft, Top, TopRight, - Left, Center, Right, - BottomLeft, Bottom, BottomRight - } - - public static class SF_Extensions { - - - public static bool GetBit( this int value, int bit ){ - return ( ( 1 << bit ) & value ) == ( 1 << bit ); - } - - public static int SetBit( this int value, int bit, bool bitValue ) { - if(bitValue) - return value | ( 1 << bit ); - else - return value & ~( 1 << bit ); - } - - public static string ToColorMaskString( this int value ) { - // Indexed in reverse order - // A = 0, B = 1, G = 2, R = 3 - string s = ""; - if( value.GetBit( 0 ) ) - s = "A"; - if( value.GetBit( 1 ) ) - s = "B" + s; - if( value.GetBit( 2 ) ) - s = "G" + s; - if( value.GetBit( 3 ) ) - s = "R" + s; - if( s == "" ) - s = "0"; - return s; - } - - - public static float Average(this float[] floats){ - - if(floats == null) - return 0f; - if(floats.Length == 0) - return 0f; - if(floats.Length == 1) - return floats[0]; - - float avg = 0f; - for(int i=0;i(this List list, T obj){ - if(!list.Contains(obj)){ - list.Add(obj); - return true; - } - return false; - } - - - - // RECT CLASS - //----------- - - public static Rect MovedDown(this Rect r, int count = 1){ - for (int i = 0; i < count; i++) { - r.y += r.height; - } - return r; - } - public static Rect MovedUp(this Rect r, int count = 1){ - for (int i = 0; i < count; i++) { - r.y -= r.height; - } - return r; - } - public static Rect MovedRight(this Rect r, int count = 1){ - for (int i = 0; i < count; i++) { - r.x += r.width; - } - return r; - } - public static Rect MovedLeft(this Rect r, int count = 1){ - for (int i = 0; i < count; i++) { - r.x -= r.width; - } - return r; - } - - - public static Rect PadBottom(this Rect r, int pixels ){ - r.yMax -= pixels; - return r; - } - - public static Rect PadTop(this Rect r, int pixels ){ - r.yMin += pixels; - return r; - } - - public static Rect PadRight(this Rect r, int pixels ){ - r.xMax -= pixels; - return r; - } - - public static Rect PadLeft(this Rect r, int pixels ){ - r.xMin += pixels; - return r; - } - - public static Rect PadHorizontal(this Rect r, int pixels ){ - return r.PadLeft(pixels).PadRight(pixels); - } - - public static Rect PadVertical(this Rect r, int pixels ){ - return r.PadTop(pixels).PadBottom(pixels); - } - - public static Rect[] SplitHorizontal(this Rect r, float t, int padding = 0){ - return new Rect[2]{ - r.PadRight(Mathf.RoundToInt(r.width*(1f-t))).Pad(padding).PadRight(-Mathf.CeilToInt(padding/2f)), - r.PadLeft(Mathf.RoundToInt(r.width*t)).Pad(padding).PadLeft(-Mathf.FloorToInt(padding/2f)) - }; - } - public static Rect[] SplitVertical(this Rect r, float t, int padding = 0){ - return new Rect[2]{ - r.PadBottom(Mathf.RoundToInt(r.height*(1f-t))).Pad(padding).PadBottom(-Mathf.CeilToInt(padding/2f)), - r.PadTop(Mathf.RoundToInt(r.height*t)).Pad(padding).PadTop(-Mathf.FloorToInt(padding/2f)) - }; - } - public static Rect[] SplitFromLeft(this Rect r, int width, int padding = 0){ - return new Rect[2]{ - r.PadRight((int)(r.width-width)).Pad(padding).PadRight(-Mathf.CeilToInt(padding/2f)), - r.PadLeft(width).Pad(padding).PadLeft(-Mathf.FloorToInt(padding/2f)) - }; - } - - - public static Rect ClampWidth(this Rect r, int min, int max){ - r.width = Mathf.Clamp(r.width, min, max); - return r; - } - public static Rect ClampHeight(this Rect r, int min, int max){ - r.height = Mathf.Clamp(r.height, min, max); - return r; - } - public static Rect ClampSize(this Rect r, int min, int max){ - return r.ClampWidth(min,max).ClampHeight(min,max); - } - public static Rect ClampMinSize(this Rect r, int width, int height){ - if(r.width < width) - r.width = width; - if(r.height < height) - r.height = height; - return r; - } - public static Rect ClampMaxSize(this Rect r, int width, int height){ - if(r.width > width) - r.width = width; - if(r.height > height) - r.height = height; - return r; - } - public static Rect ClampMinSize(this Rect r, int size){ - if(r.width < size) - r.width = size; - if(r.height < size) - r.height = size; - return r; - } - public static Rect ClampMaxSize(this Rect r, int size){ - if(r.width > size) - r.width = size; - if(r.height > size) - r.height = size; - return r; - } - - public static Vector2 TopLeft(this Rect r){ - return new Vector2(r.x, r.y); - } - - public static Vector2 TopRight(this Rect r){ - return new Vector2(r.xMax, r.y); - } - - public static Vector2 BottomRight(this Rect r){ - return new Vector2(r.xMax, r.yMax); - } - - public static Vector2 BottomLeft(this Rect r){ - return new Vector2(r.x, r.yMax); - } - - - public static Rect Margin(this Rect r, int pixels){ - r.xMax += pixels; - r.xMin -= pixels; - r.yMax += pixels; - r.yMin -= pixels; - return r; - } - - public static Rect Pad(this Rect r, int pixels){ - return r.Margin(-pixels); - } - - public static Rect Lerp(this Rect r, Rect a, Rect b, float t ){ - r.x = Mathf.Lerp(a.x,b.x,t); - r.y = Mathf.Lerp(a.y,b.y,t); - r.width = Mathf.Lerp(a.width,b.width,t); - r.height = Mathf.Lerp(a.height,b.height,t); - return r; - } - - - - public static Rect ScaleSizeBy(this Rect rect, float scale){ - return rect.ScaleSizeBy(scale, rect.center); - } - public static Rect ScaleSizeBy(this Rect rect, float scale, Vector2 pivotPoint){ - Rect result = rect; - result.x -= pivotPoint.x; - result.y -= pivotPoint.y; - result.xMin *= scale; - result.xMax *= scale; - result.yMin *= scale; - result.yMax *= scale; - result.x += pivotPoint.x; - result.y += pivotPoint.y; - - return result; - } - - - public static Rect GetBorder(this Rect r, RectBorder border, int size, bool showResizeCursor = false){ - Rect retRect = r; - - // Dimensions - if(border == RectBorder.Left || border == RectBorder.Right) - retRect.height = r.height-size*2; - else - retRect.height = size; - - if(border == RectBorder.Top || border == RectBorder.Bottom) - retRect.width = r.width-size*2; - else - retRect.width = size; - - // Position - if(border == RectBorder.Left || border == RectBorder.Center || border == RectBorder.Right) - retRect.y += size; - if(border == RectBorder.BottomLeft || border == RectBorder.Bottom || border == RectBorder.BottomRight) - retRect.y += r.height-size; - - if(border == RectBorder.Top || border == RectBorder.Center || border == RectBorder.Bottom) - retRect.x += size; - if(border == RectBorder.TopRight || border == RectBorder.Right || border == RectBorder.BottomRight) - retRect.x += r.width-size; - - - if(showResizeCursor){ - - MouseCursor cursor; - - if(border == RectBorder.Top || border == RectBorder.Bottom) - cursor = MouseCursor.ResizeVertical; - else if(border == RectBorder.Left || border == RectBorder.Right) - cursor = MouseCursor.ResizeHorizontal; - else if(border == RectBorder.TopLeft || border == RectBorder.BottomRight) - cursor = MouseCursor.ResizeUpLeft; - else if(border == RectBorder.BottomLeft || border == RectBorder.TopRight) - cursor = MouseCursor.ResizeUpRight; - else - cursor = MouseCursor.MoveArrow; - - SF_GUI.AssignCursor(retRect,cursor); - - - } - - return retRect; - - } - - - - - - public static float ManhattanDistanceToPoint(this Rect r, Vector2 point){ - - if(r.Contains(point)){ - return 0f; - } - - Vector2 clampedPoint = new Vector2( - Mathf.Clamp(point.x, r.xMin, r.xMax), - Mathf.Clamp(point.y, r.yMin, r.yMax) - ); - - return ChebyshevDistance(clampedPoint, point); - - - } - - public static float ChebyshevDistance(Vector2 a, Vector2 b){ - return Mathf.Max(Mathf.Abs(a.x-b.x),Mathf.Abs(a.y-b.y)); - } - - public static float ManhattanDistance(Vector2 a, Vector2 b){ - return Mathf.Abs(a.x-b.x)+Mathf.Abs(a.y-b.y); - } - - - public static float ShortestManhattanDistanceToRects(this Vector2 point, Rect[] rects){ - - float shortest = float.MaxValue; - - for (int i = 0; i < rects.Length; i++) { - shortest = Mathf.Min (shortest, rects[i].ManhattanDistanceToPoint(point)); - } - - return shortest; - - } - - - public static float ShortestChebyshevDistanceToPoints(this Vector2 point, Vector2[] points){ - - float shortest = float.MaxValue; - - for (int i = 0; i < points.Length; i++) { - shortest = Mathf.Min (shortest, ManhattanDistance(point, points[i]) ); - } - - return shortest; - - - } - - - - - public static string ToCgMatrix( this Matrix4x4 mtx ) { - string s = "{\n"; - s += " {" + mtx[0, 0] + "," + mtx[0, 1] + "," + mtx[0, 2] + "," + mtx[0, 3] + "},\n"; - s += " {" + mtx[1, 0] + "," + mtx[1, 1] + "," + mtx[1, 2] + "," + mtx[1, 3] + "},\n"; - s += " {" + mtx[2, 0] + "," + mtx[2, 1] + "," + mtx[2, 2] + "," + mtx[2, 3] + "},\n"; - s += " {" + mtx[3, 0] + "," + mtx[3, 1] + "," + mtx[3, 2] + "," + mtx[3, 3] + "}\n}"; - return s; - } - - public static string SerializeToCSV( this Matrix4x4 mtx ) { - string s = ""; - s += "m00:" + mtx[0, 0] + ","; - s += "m01:" + mtx[0, 1] + ","; - s += "m02:" + mtx[0, 2] + ","; - s += "m03:" + mtx[0, 3] + ","; - s += "m10:" + mtx[1, 0] + ","; - s += "m11:" + mtx[1, 1] + ","; - s += "m12:" + mtx[1, 2] + ","; - s += "m13:" + mtx[1, 3] + ","; - s += "m20:" + mtx[2, 0] + ","; - s += "m21:" + mtx[2, 1] + ","; - s += "m22:" + mtx[2, 2] + ","; - s += "m23:" + mtx[2, 3] + ","; - s += "m30:" + mtx[3, 0] + ","; - s += "m31:" + mtx[3, 1] + ","; - s += "m32:" + mtx[3, 2] + ","; - s += "m33:" + mtx[3, 3]; - return s; - } - - public static Matrix4x4 DeserializeKeyValue( this Matrix4x4 mtx, string key, string value ) { - switch( key ) { - case "m00": - mtx[0, 0] = float.Parse( value ); - break; - case "m01": - mtx[0, 1] = float.Parse( value ); - break; - case "m02": - mtx[0, 2] = float.Parse( value ); - break; - case "m03": - mtx[0, 3] = float.Parse( value ); - break; - - case "m10": - mtx[1, 0] = float.Parse( value ); - break; - case "m11": - mtx[1, 1] = float.Parse( value ); - break; - case "m12": - mtx[1, 2] = float.Parse( value ); - break; - case "m13": - mtx[1, 3] = float.Parse( value ); - break; - - case "m20": - mtx[2, 0] = float.Parse( value ); - break; - case "m21": - mtx[2, 1] = float.Parse( value ); - break; - case "m22": - mtx[2, 2] = float.Parse( value ); - break; - case "m23": - mtx[2, 3] = float.Parse( value ); - break; - - case "m30": - mtx[3, 0] = float.Parse( value ); - break; - case "m31": - mtx[3, 1] = float.Parse( value ); - break; - case "m32": - mtx[3, 2] = float.Parse( value ); - break; - case "m33": - mtx[3, 3] = float.Parse( value ); - break; - } - return mtx; - } - - - - - - public static Vector2 xx( this Vector4 v ) { - return new Vector2( v.x, v.x ); - } - public static Vector2 xy( this Vector4 v ) { - return new Vector2( v.x, v.y ); - } - public static Vector2 xz( this Vector4 v ) { - return new Vector2( v.x, v.z ); - } - public static Vector2 xw( this Vector4 v ) { - return new Vector2( v.x, v.w ); - } - public static Vector2 yx( this Vector4 v ) { - return new Vector2( v.y, v.x ); - } - public static Vector2 yy( this Vector4 v ) { - return new Vector2( v.y, v.y ); - } - public static Vector2 yz( this Vector4 v ) { - return new Vector2( v.y, v.z ); - } - public static Vector2 yw( this Vector4 v ) { - return new Vector2( v.y, v.w ); - } - public static Vector2 zx( this Vector4 v ) { - return new Vector2( v.z, v.x ); - } - public static Vector2 zy( this Vector4 v ) { - return new Vector2( v.z, v.y ); - } - public static Vector2 zz( this Vector4 v ) { - return new Vector2( v.z, v.z ); - } - public static Vector2 zw( this Vector4 v ) { - return new Vector2( v.z, v.w ); - } - public static Vector2 wx( this Vector4 v ) { - return new Vector2( v.w, v.x ); - } - public static Vector2 wy( this Vector4 v ) { - return new Vector2( v.w, v.y ); - } - public static Vector2 wz( this Vector4 v ) { - return new Vector2( v.w, v.z ); - } - public static Vector2 ww( this Vector4 v ) { - return new Vector2( v.w, v.w ); - } - - // Do the rest as needed - public static Vector3 xyw( this Vector4 v ) { - return new Vector3( v.x, v.y, v.w ); - } - public static Vector3 yzx( this Vector4 v ) { - return new Vector3( v.y, v.z, v.x ); - } - - - - - - - - } - -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Extensions.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Extensions.cs.meta deleted file mode 100644 index 505a53f7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Extensions.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a985ed724d90c4d4dab68acab8a7817d -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_GUI.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_GUI.cs deleted file mode 100755 index 093c2f7f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_GUI.cs +++ /dev/null @@ -1,718 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Reflection; -using System; -using System.Linq; - -namespace ShaderForge { - - public static class SF_GUI { - - - - - - static Matrix4x4 prevMatrix; - - public static Color[] outdatedStateColors = new Color[]{ - new Color(0.7f, 1f, 0.7f), - new Color(1f, 1f, 0.7f), - new Color(1f,0.7f,0.7f) - }; - - - public static void DrawLock(Rect r, string tooltip = null, TextAlignment align = TextAlignment.Right){ - if(Event.current.type != EventType.repaint) - return; - - Color pCol = GUI.color; - GUI.color = Color.white; - SF_Styles.IconLock.Draw(r, false, true, true, false); - - if(tooltip != null && r.Contains(Event.current.mousePosition) ){ - - GUIStyle style = EditorStyles.miniButton; - - r.width = style.CalcSize(new GUIContent(tooltip)).x + 8; - r.height = style.CalcSize(new GUIContent(tooltip)).y + 4; - - r = r.MovedUp(); - - if(align == TextAlignment.Left){ - r.x = (r.MovedLeft().x + r.x)/2f; - } - - - GUI.color = new Color(1f,1f,1f,0.8f); - GUI.Box(r, tooltip, style); - - } - - GUI.color = pCol; - - - } - - private static Texture2D LoadTexture(string path, string name){ - - //AssetDatabase.LoadAssetAtPath( - - return SF_Resources.Load(path+name); - - //return (Texture2D)Resources.Load(path + name, typeof(Texture2D) ); // TODO: This has to change into something that's not using resources - } - - - private static Texture2D vectorIconOverlay; - public static Texture2D VectorIconOverlay{ - get{ - if( vectorIconOverlay == null ) - vectorIconOverlay = SF_Resources.LoadNodeIcon("Data/node_3d_data_mask"); - return vectorIconOverlay; - } - } - - - private static Texture2D handle_drag; - public static Texture2D Handle_drag { - get { - if( handle_drag == null ) - handle_drag = SF_Resources.LoadInterfaceIcon("handle_drag"); - return handle_drag; - } - } - - - - private static Texture2D logo; - public static Texture2D Logo { - get { - if( logo == null ) - logo = SF_Resources.LoadInterfaceIcon( SkinSuffix("logo") ); - return logo; - } - } - - private static Texture2D icon; - public static Texture2D Icon { - get { - if( icon == null ) - icon = SF_Resources.LoadInterfaceIcon( SkinSuffix( "icon" ) ); - return icon; - } - } - - private static Texture2D toggle_check_icon; - public static Texture2D Toggle_check_icon { - get { - if( toggle_check_icon == null ) - toggle_check_icon = SF_Resources.LoadInterfaceIcon( SkinSuffix( "chk" ) ); - return toggle_check_icon; - } - } - - private static Texture2D screenshot_icon; - public static Texture2D Screenshot_icon { - get { - if( screenshot_icon == null ) - screenshot_icon = SF_Resources.LoadInterfaceIcon( SkinSuffix( "screenshot_icon" ) ); - return screenshot_icon; - } - } - - - - - - - private static Texture2D shader_preset_icon_custom; - public static Texture2D Shader_preset_icon_custom { - get { - if( shader_preset_icon_custom == null ) - shader_preset_icon_custom = SF_Resources.LoadInterfaceIcon( "preset_custom" ); - return shader_preset_icon_custom; - } - } - - private static Texture2D shader_preset_icon_litbasic; - public static Texture2D Shader_preset_icon_litbasic { - get { - if( shader_preset_icon_litbasic == null ) - shader_preset_icon_litbasic = SF_Resources.LoadInterfaceIcon( "preset_litbasic" ); - return shader_preset_icon_litbasic; - } - } - - private static Texture2D shader_preset_icon_litpbr; - public static Texture2D Shader_preset_icon_litpbr { - get { - if( shader_preset_icon_litpbr == null ) - shader_preset_icon_litpbr = SF_Resources.LoadInterfaceIcon( "preset_litpbr" ); - return shader_preset_icon_litpbr; - } - } - - private static Texture2D shader_preset_icon_particleadditive; - public static Texture2D Shader_preset_icon_particleadditive { - get { - if( shader_preset_icon_particleadditive == null ) - shader_preset_icon_particleadditive = SF_Resources.LoadInterfaceIcon( SkinSuffix("preset_particleadditive") ); - return shader_preset_icon_particleadditive; - } - } - - private static Texture2D shader_preset_icon_particlealphablended; - public static Texture2D Shader_preset_icon_particlealphablended { - get { - if( shader_preset_icon_particlealphablended == null ) - shader_preset_icon_particlealphablended = SF_Resources.LoadInterfaceIcon( SkinSuffix("preset_particlealphablended") ); - return shader_preset_icon_particlealphablended; - } - } - - private static Texture2D shader_preset_icon_particlemultiplicative; - public static Texture2D Shader_preset_icon_particlemultiplicative { - get { - if( shader_preset_icon_particlemultiplicative == null ) - shader_preset_icon_particlemultiplicative = SF_Resources.LoadInterfaceIcon( SkinSuffix("preset_particlemultiplicative") ); - return shader_preset_icon_particlemultiplicative; - } - } - - private static Texture2D shader_preset_icon_sky; - public static Texture2D Shader_preset_icon_sky { - get { - if( shader_preset_icon_sky == null ) - shader_preset_icon_sky = SF_Resources.LoadInterfaceIcon( "preset_sky" ); - return shader_preset_icon_sky; - } - } - - private static Texture2D shader_preset_icon_sprite; - public static Texture2D Shader_preset_icon_sprite { - get { - if( shader_preset_icon_sprite == null ) - shader_preset_icon_sprite = SF_Resources.LoadInterfaceIcon( "preset_sprite" ); - return shader_preset_icon_sprite; - } - } - - private static Texture2D shader_preset_icon_unlit; - public static Texture2D Shader_preset_icon_unlit { - get { - if( shader_preset_icon_unlit == null ) - shader_preset_icon_unlit = SF_Resources.LoadInterfaceIcon( "preset_unlit" ); - return shader_preset_icon_unlit; - } - } - - private static Texture2D shader_preset_icon_highlight; - public static Texture2D Shader_preset_icon_highlight { - get { - if( shader_preset_icon_highlight == null ) - shader_preset_icon_highlight = SF_Resources.LoadInterfaceIcon( "preset_highlight" ); - return shader_preset_icon_highlight; - } - } - - private static Texture2D shader_preset_icon_posteffect; - public static Texture2D Shader_preset_icon_posteffect { - get { - if( shader_preset_icon_posteffect == null ) - shader_preset_icon_posteffect = SF_Resources.LoadInterfaceIcon( "preset_posteffect" ); - return shader_preset_icon_posteffect; - } - } - - - - - - - private static Texture2D inst_vert; - public static Texture2D Inst_vert { - get { - if( inst_vert == null ) - inst_vert = SF_Resources.LoadInterfaceIcon( SkinSuffix( "inst_vert" ) ); - return inst_vert; - } - } - - private static Texture2D inst_vert_tex; - public static Texture2D Inst_vert_tex { - get { - if( inst_vert_tex == null ) - inst_vert_tex = SF_Resources.LoadInterfaceIcon( SkinSuffix( "inst_vert_tex" ) ); - return inst_vert_tex; - } - } - - private static Texture2D inst_frag; - public static Texture2D Inst_frag { - get { - if( inst_frag == null ) - inst_frag = SF_Resources.LoadInterfaceIcon( SkinSuffix("inst_frag" ) ); - return inst_frag; - } - } - - private static Texture2D inst_frag_tex; - public static Texture2D Inst_frag_tex { - get { - if( inst_frag_tex == null ) - inst_frag_tex = SF_Resources.LoadInterfaceIcon( SkinSuffix( "inst_frag_tex" ) ); - return inst_frag_tex; - } - } - - public static void DrawTextureTiled(Rect r, Texture2D tex, bool local = true){ - Rect tCoords = new Rect( - local ? 0 : (float)r.x/(float)tex.width, - local ? 0 : (float)r.y/(float)tex.height, - (float)r.width/(float)tex.width, - (float)r.height/(float)tex.height - ); - GUI.DrawTextureWithTexCoords(r,tex,tCoords); - } - - - public static string SkinSuffix(string s) { - return s + ( SF_GUI.ProSkin ? "" : "_light" ); - } - - - /* - public static void StartZoomPanel( float zoom, Rect rect ) { - float zoomInv = 1f / zoom; - - GUI.EndGroup(); // Leave parent group to avoid clipping issues - Rect clippedArea = rect.ScaleSizeBy( zoomInv, rect.TopLeft() ); - - //clippedArea.x -= clippedArea.width * zoomInv * 0.25f; - //clippedArea.y -= clippedArea.height * zoomInv * 0.25f; - clippedArea.width *= zoom; - clippedArea.height *= zoom; - clippedArea.y += GetEditorTabHeight(); - GUI.BeginGroup( clippedArea, EditorStyles.numberField ); - - prevMatrix = GUI.matrix; - Matrix4x4 Translation = Matrix4x4.TRS( new Vector3( clippedArea.x, clippedArea.y, 0 ), Quaternion.identity, Vector3.one ); - Matrix4x4 Scale = Matrix4x4.Scale( new Vector3( zoom, zoom, zoom ) ); - GUI.matrix = Translation * Scale * Translation.inverse * GUI.matrix; - } - - public static void EndZoomPanel() { - GUI.matrix = prevMatrix; - GUI.EndGroup(); - GUI.BeginGroup( new Rect( 0.0f, GetEditorTabHeight(), Screen.width, Screen.height ) ); // Remake parent - } - * */ - - - public static bool AcceptedNewShaderReplaceDialog() { - return EditorUtility.DisplayDialog( "Delete existing shader?", "This shader was not created in Shader Forge. Are you sure you want to remove all existing shader data and open it in Shader Forge?", "Yes", "Cancel" ); - } - - - - public static int GetEditorTabHeight() { - return 21; // TODO: This is correct when docked, not floating - } - - public static void AssignCursorForPreviousRect( MouseCursor cursor ) { - EditorGUIUtility.AddCursorRect( GUILayoutUtility.GetLastRect(), cursor ); - } - - public static void AssignCursor( Rect r, MouseCursor cursor ) { - EditorGUIUtility.AddCursorRect( r, cursor ); - } - - public static bool PressedLMB( Rect r ) { - return ( PressedLMB() && r.Contains(Event.current.mousePosition)); - } - - public static bool PressedLMB() { - return ( Event.current.type == EventType.mouseDown ) && ( Event.current.button == 0 ); - } - - public static bool ReleasedLMB() { - return ( Event.current.type == EventType.mouseUp ) && ( Event.current.button == 0 ); - } - - public static bool PressedMMB() { - return ( Event.current.type == EventType.mouseDown ) && ( Event.current.button == 2 ); - } - - public static bool ReleasedRawMMB() { - return ( Event.current.rawType == EventType.mouseUp ) && ( Event.current.button == 2 ); - } - - public static bool ReleasedRawLMB() { - return ( Event.current.rawType == EventType.mouseUp ) && ( Event.current.button == 0 ); - } - - public static bool ReleasedRawRMB() { - return ( Event.current.rawType == EventType.mouseUp ) && ( Event.current.button == 1 ); - } - - public static bool PressedRMB() { - return ( Event.current.type == EventType.mouseDown ) && ( Event.current.button == 1 ); - } - - public static bool ReleasedRMB() { - return ( Event.current.type == EventType.mouseUp ) && ( Event.current.button == 1 ); - } - - public static bool HoldingAlt() { - return (Event.current.modifiers & EventModifiers.Alt) != 0; // Alt is held - } - - public static bool HoldingBoxSelect() { - return HoldingAlt(); // Alt is held. TODO: Make a toggle for (Alt cam) vs (Alt select) - } - - public static bool HoldingShift() { - return ( Event.current.modifiers & EventModifiers.Shift ) != 0; // Shift is held - } - - public static bool HoldingControl() { - if( Application.platform == RuntimePlatform.OSXEditor ) - return ( Event.current.modifiers & EventModifiers.Command ) != 0; // Command is held - else { - return ( Event.current.control ); // Control is held - } - - } - - public static bool PressedDelete(){ - if(Event.current.type != EventType.keyDown) - return false; - - if(Event.current.keyCode == KeyCode.Delete) // Windows / Mac extended keyboard delete - return true; - - bool holdingCommand = HoldingControl(); - bool pressedBackspace = (Event.current.keyCode == KeyCode.Backspace); - - if(holdingCommand && pressedBackspace) // Mac laptop style delete - return true; - - return false; - - } - - public static bool PressedCameraMove(){ - return ( PressedLMB() || PressedMMB() ); - } - - public static bool ReleasedCameraMove(){ - return ( ReleasedRawLMB() || ReleasedRawMMB() ); - } - - public static bool MultiSelectModifierHeld(){ - return ( HoldingShift() || HoldingControl() ); - } - - public const byte ColBgPro = (byte)56; - public const byte ColBgFree = (byte)194; - public static void UseBackgroundColor() { - byte v = EditorGUIUtility.isProSkin ? ColBgPro : ColBgFree; - GUI.color = new Color32( v, v, v, (byte)255 ); - } - - public static Color selectionColor = new Color32( (byte)41, (byte)123, (byte)194, (byte)255 ); - public static Color selectionColorBright = new Color32( (byte)54, (byte)162, (byte)255, (byte)255 ); - public static Color selectionColorBrighter = new Color32( (byte)175, (byte)218, (byte)255, (byte)255 ); - /* public static Color SelectionColor { - get { - if( selectionColor == null ) - selectionColor - return selectionColor; - } - }*/ - - public static int WidthOf(GUIContent s, GUIStyle style){ - return (int)style.CalcSize( s ).x; - } - - public static int WidthOf( string s, GUIStyle style ) { - return (int)style.CalcSize( new GUIContent(s) ).x; - } - - public static System.Enum LabeledEnumField( Rect r, string label, System.Enum enumVal, GUIStyle style, bool zoomCompensate = false ) { - return LabeledEnumField( r, new GUIContent(label), enumVal, style, zoomCompensate); - } - - public static void MoveRight( ref Rect r, int newWidth ) { - r.x += r.width; - r.width = newWidth; - } - - public static int LabeledEnumFieldNamed( Rect r, string[] names, GUIContent label, int enumVal, GUIStyle style ) { - Rect leftRect = new Rect( r ); - Rect rightRect = new Rect( r ); - int width = WidthOf( label, style ) + 4; - leftRect.width = width; - rightRect.xMin += width; - GUI.Label( leftRect, label, style ); - return EditorGUI.Popup( rightRect, (int)enumVal, names ); - } - - public static System.Enum LabeledEnumField(Rect r, GUIContent label, System.Enum enumVal, GUIStyle style, bool zoomCompensate = false) { - Rect leftRect = new Rect( r ); - Rect rightRect = new Rect( r ); - int width = WidthOf( label, style) + 4; - leftRect.width = width; - rightRect.xMin += width; - GUI.Label( leftRect, label, style ); - - return SF_GUI.EnumPopup( rightRect, GUIContent.none, enumVal, EditorStyles.popup, zoomCompensate); - //return EditorGUI.EnumPopup( rightRect, GUIContent.none, enumVal, EditorStyles.popup ); - //return EnumPopupZoomCompensated( rightRect, enumVal ); - - } - - - - - // UnityEditor.EditorGUI - - public static Enum EnumPopup(Rect position, GUIContent label, Enum selected, GUIStyle style, bool zoomCompensate = false) - { - - - Type type = selected.GetType(); - if (!type.IsEnum) - { - throw new Exception("parameter _enum must be of type System.Enum"); - } - string[] names = Enum.GetNames(type); - int num = Array.IndexOf(names, Enum.GetName(type, selected)); - Matrix4x4 prevMatrix = Matrix4x4.identity; - if(zoomCompensate){ - prevMatrix = GUI.matrix; - GUI.matrix = Matrix4x4.identity; - } - num = EditorGUI.Popup(position, label, num, TempContent(( - from x in names - select ObjectNames.NicifyVariableName(x)).ToArray()), style); - if (num < 0 || num >= names.Length) - { - if(zoomCompensate) - GUI.matrix = prevMatrix; - return selected; - } - if(zoomCompensate) - GUI.matrix = prevMatrix; - return (Enum)Enum.Parse(type, names[num]); - } - - /* - public static int Popup(Rect position, GUIContent label, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style) - { - int controlID = GUIUtility.GetControlID(EditorGUI.s_PopupHash, EditorGUIUtility.native, position); - return EditorGUI.DoPopup(EditorGUI.PrefixLabel(position, controlID, label), controlID, selectedIndex, displayedOptions, style); - }*/ - - - // UnityEditor.EditorGUIUtility - private static GUIContent[] TempContent(string[] texts) - { - GUIContent[] array = new GUIContent[texts.Length]; - for (int i = 0; i < texts.Length; i++) - { - array[i] = new GUIContent(texts[i]); - } - return array; - } - - - - /* - public static Enum EnumPopupZoomCompensated(Rect r, Enum selected ){ - - // TODO: Custom enum popup proper zoom positioning - - if(GUI.Button(r,selected.ToString(),EditorStyles.popup)){ - - GenericMenu gm = new GenericMenu(); - //gm.AddItem(selected); - - Array enumList = Enum.GetValues(selected.GetType()); - - for(int i=0;i < enumList.Length;i++){ - - gm.AddItem( new GUIContent(enumList.GetValue(i).ToString()), i == Convert.ToInt32(selected), (object o)=>{Debug.Log(o.ToString());},"Test " + i); - - - } - - gm.ShowAsContext(); - - - - } - - - - return selected; - - } -*/ - - public static void FillBackground( Rect r ) { - Color pCol = GUI.color; - SF_GUI.UseBackgroundColor(); - GUI.DrawTexture( r, EditorGUIUtility.whiteTexture ); - GUI.color = pCol; - } - - - public static void EnterableFloatField( SF_Node n, Rect r, ref float val, GUIStyle style ) { - if( style == null ) - style = EditorStyles.textField; - string field_name = n.GetType().ToString() + "_" + n.id; - - - GUI.SetNextControlName( field_name ); - EditorGUI.BeginChangeCheck(); - val = EditorGUI.FloatField( r, val, style ); - - - bool pressedEnter = Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyDown; - - if( pressedEnter ) { - EditorGUI.EndChangeCheck(); - //Debug.Log("Pressed enter with focus on " + GUI.GetNameOfFocusedControl() + ", should have been " + field_name); - if(GUI.GetNameOfFocusedControl() == field_name){ - //Debug.Log("Pressed enter!"); - n.OnUpdateNode( NodeUpdateType.Hard ); - } - } else if( EditorGUI.EndChangeCheck() ) { - n.OnUpdateNode( NodeUpdateType.Soft ); - } - } - - - - - - - - public static void EnterableTextField( SF_Node n, Rect r, ref string str, GUIStyle style, bool update = true ) { - if( style == null ) - style = EditorStyles.textField; - string field_name = n.GetType().ToString() + "_txt_" + n.id; - - - GUI.SetNextControlName( field_name ); - EditorGUI.BeginChangeCheck(); - str = EditorGUI.TextField( r, str, style ); - - bool pressedEnter = Event.current.keyCode == KeyCode.Return; - - if(update){ - if( pressedEnter ) { - if( GUI.GetNameOfFocusedControl() == field_name ) - n.OnUpdateNode( NodeUpdateType.Hard ); - EditorGUI.EndChangeCheck(); - } else if( EditorGUI.EndChangeCheck() ) { - n.OnUpdateNode( NodeUpdateType.Soft ); - } - } else if(EditorGUI.EndChangeCheck()){ - n.editor.ShaderOutdated = UpToDateState.OutdatedSoft; - } - - } - - - - - - public static void ConditionalToggle(Rect r, ref bool value, bool usableIf, bool disabledDisplayValue, string label){ - if(usableIf){ - value = GUI.Toggle(r, value, label); - } else { - GUI.enabled = false; - GUI.Toggle(r, disabledDisplayValue, label); - GUI.enabled = true; - } - } - - - - - - - - public static int ContentScaledToolbar(Rect r, string label, int selected, string[] labels ) { - - r.height = 15; - - Rect rLeft = new Rect( r ); - Rect rRight = new Rect( r ); - - rLeft.width = SF_GUI.WidthOf( label, EditorStyles.miniLabel )+4; - rRight.width = r.width - rLeft.width; - rRight.x += rLeft.width; - - GUI.Label( rLeft, label, EditorStyles.miniLabel); - - - // Full pixel width of strings: - float[] lblPxWidth = new float[labels.Length]; - float pxWidthTotal = 0; - for( int i = 0; i < labels.Length; i++ ) { - lblPxWidth[i] = SF_GUI.WidthOf( labels[i], EditorStyles.miniButtonMid ); - pxWidthTotal += lblPxWidth[i]; - } - - // Scale all buttons to fit the rect - float scale = rRight.width / pxWidthTotal; - for( int i = 0; i < labels.Length; i++ ) { - lblPxWidth[i] *= scale; - } - - - - - GUIStyle style = EditorStyles.miniButtonLeft; - int retval = selected; - - Rect rTemp = new Rect(rRight); - - for( int i = 0; i < labels.Length; i++ ) { - - rTemp.width = lblPxWidth[i]; - - if( i == labels.Length - 1 ) { - style = EditorStyles.miniButtonRight; - } else if( i > 0 ) { - style = EditorStyles.miniButtonMid; - } - - bool prev = selected == i; - bool newVal = GUI.Toggle( rTemp, prev, labels[i], style ); - if( newVal != prev ) { - retval = i; - } - - rTemp.x += rTemp.width; - } - GUI.color = Color.white; - return retval; - - } - - - - public static bool ProSkin { - get{ - return EditorGUIUtility.isProSkin; - } - } - - } -} - diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_GUI.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_GUI.cs.meta deleted file mode 100755 index 608f5409..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_GUI.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 729a144b29ff13241b778e1946cde443 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Link.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Link.cs deleted file mode 100644 index 14910d30..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Link.cs +++ /dev/null @@ -1,55 +0,0 @@ - -using UnityEngine; - -// OLD: [Source][Con] <---- [Con][Target] -// NEW: [Target][Con] ----> [Con][Source] - -namespace ShaderForge{ - public struct SF_Link { - public int sNode; // Source - string sCon; - public int tNode; // Target - string tCon; - - public SF_Link( int sNode, string linkData ) { - this.sNode = sNode; - string[] split = linkData.Split( '-' ); - if(split.Length != 3){ - Debug.Log("Invalid link on node " + sNode + ". Expected 3 entries, found " + split.Length + ". Link Data = [" + linkData + "]"); - } - sCon = split[0]; - tNode = int.Parse( split[1] ); - tCon = split[2]; - } - - public void Establish( SF_Editor editor, LinkingMethod linkMethod = LinkingMethod.NoUpdate ) { - SF_Node source = editor.GetNodeByID( sNode ); - SF_Node target = editor.GetNodeByID( tNode ); - // Debug.Log( "Linking " + target.nodeName + " <- " + source.nodeName ); - - target.GetConnectorByID(tCon).LinkTo( source.GetConnectorByID(sCon), linkMethod ); - } - - - - public void Remap(int[] oldIDs, int[] newIDs){ - // Source id switching - for(int i=0; i(string name) where T : UnityEngine.Object { - return (T)AssetDatabase.LoadAssetAtPath(InternalResourcesPath + name, typeof(T) ); - } - - public static UnityEngine.Object[] LoadAll(string name) { - return AssetDatabase.LoadAllAssetsAtPath(InternalResourcesPath + name ); - } - - public static Texture2D LoadInterfaceIcon(string name){ - string path = InternalResourcesPath + "Interface/" + name; - Texture2D retTex = (Texture2D)AssetDatabase.LoadAssetAtPath(path + ".png", typeof(Texture2D) ); - if(retTex == null){ - retTex = (Texture2D)AssetDatabase.LoadAssetAtPath(path + ".tga", typeof(Texture2D) ); - } - return retTex; - } - - public static Texture2D LoadNodeIcon(string name){ - return (Texture2D)AssetDatabase.LoadAssetAtPath(InternalResourcesPath + "Interface/Nodes/" + name + ".png", typeof(Texture2D) ); - } - - - private static string internalResourcesPath = ""; - public static string InternalResourcesPath{ - get{ - if(string.IsNullOrEmpty(internalResourcesPath)){ - string path; - if(SearchForInternalResourcesPath(out path)){ - internalResourcesPath = path; - } else { - Debug.LogError("Unable to locate the internal resources folder. Make sure your Shader Forge installation is intact"); - SF_Editor.instance.Close(); - } - } - return internalResourcesPath; - } - } - - - - private static bool SearchForInternalResourcesPath( out string path ){ - path = ""; - string partialPath = "/ShaderForge/Editor/InternalResources/"; - string foundPath = null; - foreach(string s in AssetDatabase.GetAllAssetPaths()){ - if(s.Contains(partialPath)){ - foundPath = s; - break; - } - } - if(foundPath == null){ - return false; - } - string[] split = foundPath.Replace(partialPath,"#").Split('#'); - path = split[0] + partialPath; - return true; - } - - - - - } -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Resources.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Resources.cs.meta deleted file mode 100644 index 2a7a25bd..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Resources.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 93a8198ea76894b6c89ca317cc15acb9 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Styles.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Styles.cs deleted file mode 100755 index 4d478994..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Styles.cs +++ /dev/null @@ -1,337 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Reflection; -using System; - -namespace ShaderForge { - public static class SF_Styles { - - private static Texture2D _iconErrorSmall; - public static Texture2D IconErrorSmall { - get { - return ( _iconErrorSmall = _iconErrorSmall ?? EditorGUIUtility.FindTexture( "console.erroricon.sml" ) ); - } - } - private static Texture2D _iconWarningSmall; - public static Texture2D IconWarningSmall { - get { - return ( _iconWarningSmall = _iconWarningSmall ?? EditorGUIUtility.FindTexture( "console.warnicon.sml" ) ); - } - } - private static GUIStyle _iconLock; - public static GUIStyle IconLock{ - get{ - return ( _iconLock = _iconLock ?? new GUIStyle("IN LockButton") ); - } - } - - private static GUIStyle miniLabelRight; - public static GUIStyle MiniLabelRight { - get { - if( miniLabelRight == null ) { - miniLabelRight = new GUIStyle( EditorStyles.miniLabel ); - miniLabelRight.alignment = TextAnchor.MiddleRight; - } - return miniLabelRight; - } - } - - - - private static GUIStyle largeTextField; - public static GUIStyle LargeTextField { - get { - if( largeTextField == null ) { - largeTextField = new GUIStyle( EditorStyles.textField ); - largeTextField.fontSize = 20; - largeTextField.alignment = TextAnchor.MiddleLeft; - } - return largeTextField; - } - } - - private static GUIStyle smallTextArea; - public static GUIStyle SmallTextArea { - get { - if( smallTextArea == null ) { - smallTextArea = new GUIStyle( EditorStyles.miniLabel ); - smallTextArea.wordWrap = true; - smallTextArea.padding = new RectOffset( 5, 5, 3, 3 ); - smallTextArea.fontSize = EditorStyles.miniLabel.fontSize; - } - return smallTextArea; - } - } - - - private static GUIStyle largeTextFieldNoFrame; - public static GUIStyle LargeTextFieldNoFrame { - get { - if( largeTextFieldNoFrame == null ) { - largeTextFieldNoFrame = new GUIStyle( EditorStyles.label ); - largeTextFieldNoFrame.fontSize = LargeTextField.fontSize; - largeTextFieldNoFrame.alignment = LargeTextField.alignment; - - } - return largeTextFieldNoFrame; - } - } - - private static GUIStyle richTextField; - public static GUIStyle RichTextField { - get { - if( richTextField == null ) { - richTextField = new GUIStyle( EditorStyles.textField ); - richTextField.richText = true; - } - return richTextField; - } - } - - private static GUIStyle richLabel; - public static GUIStyle RichLabel { - get { - if( richLabel == null ) { - richLabel = new GUIStyle( EditorStyles.label ); - richLabel.richText = true; - } - return richLabel; - } - } - - - private static GUIStyle instructionCountRenderer; - public static GUIStyle InstructionCountRenderer { - get { - if( instructionCountRenderer == null ) { - instructionCountRenderer = new GUIStyle( EditorStyles.miniLabel ); - InstructionCountRenderer.alignment = TextAnchor.MiddleRight; - } - return instructionCountRenderer; - } - } - - - private static GUIStyle codeTextArea; - public static GUIStyle CodeTextArea { - get { - if( codeTextArea == null ) { - codeTextArea = new GUIStyle( GUI.skin.textArea ); - codeTextArea.font = SF_Resources.Load( SF_Resources.pFonts + "VeraMono.ttf" ); - codeTextArea.padding = new RectOffset(3,3,3,0); - codeTextArea.wordWrap = false; - } - return codeTextArea; - } - } - - // Bitstream Vera Sans Mono - - - private static GUIStyle miniLabelOverflow; - public static GUIStyle MiniLabelOverflow { - get { - if( miniLabelOverflow == null ) { - miniLabelOverflow = new GUIStyle( EditorStyles.miniLabel ); - miniLabelOverflow.clipping = TextClipping.Overflow; - } - return miniLabelOverflow; - } - } - - private static GUIStyle creditsLabelText; - public static GUIStyle CreditsLabelText { - get { - if( creditsLabelText == null ) { - creditsLabelText = new GUIStyle( EditorStyles.label ); - creditsLabelText.alignment = TextAnchor.MiddleLeft; - creditsLabelText.fixedHeight = 16; - creditsLabelText.padding = new RectOffset(0,0,6,0); - creditsLabelText.clipping = TextClipping.Overflow; - } - return creditsLabelText; - } - } - - private static GUIStyle boldEnumField; - public static GUIStyle BoldEnumField{ - get{ - if(boldEnumField == null){ - boldEnumField = new GUIStyle((GUIStyle)"MiniPopup"); - boldEnumField.fontStyle = FontStyle.Bold; - Color c = SF_GUI.ProSkin ? (Color)new Color32( 161, 225, 87, 255 ) : ((Color)new Color32( 161, 225, 87, 255 ))*0.5f; // Used for variable precision - c.a = 1; - boldEnumField.normal.textColor = c; - boldEnumField.active.textColor = c; - boldEnumField.focused.textColor = c; - - } - return boldEnumField; - } - } - - - private static GUIStyle nodeNameLabelText; - public static GUIStyle GetNodeNameLabelText() { - if( nodeNameLabelText == null ) { - nodeNameLabelText = new GUIStyle( EditorStyles.largeLabel ); - nodeNameLabelText.fontStyle = FontStyle.Bold; - nodeNameLabelText.fontSize = 11; - nodeNameLabelText.alignment = TextAnchor.MiddleCenter; - nodeNameLabelText.normal.textColor = new Color( 0.8f, 0.8f, 0.8f, 1f ); - } - return nodeNameLabelText; - } - - - private static GUIStyle nodeCommentLabelText; - public static GUIStyle GetNodeCommentLabelText() { - if( nodeCommentLabelText == null ) { - nodeCommentLabelText = new GUIStyle( EditorStyles.largeLabel ); - nodeCommentLabelText.fontStyle = FontStyle.Italic; - nodeCommentLabelText.fontSize = 16; - nodeCommentLabelText.alignment = TextAnchor.LowerLeft; - float col = SF_GUI.ProSkin ? 1f : 0f; - nodeCommentLabelText.normal.textColor = new Color( col, col, col, 0.3f ); - } - return nodeCommentLabelText; - } - - private static GUIStyle nodeScreenshotTitleText; - public static GUIStyle GetNodeScreenshotTitleText() { - if( nodeScreenshotTitleText == null ) { - //nodeScreenshotTitleText = new GUIStyle( NodeStyle ); - nodeScreenshotTitleText = new GUIStyle(EditorStyles.boldLabel); - nodeScreenshotTitleText.fontSize = 14; - nodeScreenshotTitleText.alignment = TextAnchor.LowerCenter; - nodeScreenshotTitleText.clipping = TextClipping.Overflow; - float col = SF_GUI.ProSkin ? 1f : 0f; - nodeScreenshotTitleText.normal.textColor = new Color( col, col, col, 0.5f ); - } - return nodeScreenshotTitleText; - } - - - - private static GUIStyle nodeCommentLabelTextField; - public static GUIStyle GetNodeCommentLabelTextField() { - if( nodeCommentLabelTextField == null ) { - nodeCommentLabelTextField = new GUIStyle( EditorStyles.textField ); - nodeCommentLabelTextField.fontStyle = FontStyle.Italic; - nodeCommentLabelTextField.fontSize = 16; - nodeCommentLabelTextField.alignment = TextAnchor.LowerLeft; - nodeCommentLabelTextField.normal.textColor = new Color( 1f, 1f, 1f, 0.3f ); - } - return nodeCommentLabelTextField; - } - - - private static GUIStyle nodeNameLabelBackground; - public static Color nodeNameLabelBackgroundColor = new Color( 0.7f, 0.7f, 0.7f ); - public static GUIStyle GetNodeNameLabelBackground() { - if( nodeNameLabelBackground == null ) { - nodeNameLabelBackground = new GUIStyle( EditorStyles.textField ); - } - return nodeNameLabelBackground; - } - - private static GUIStyle highlightStyle; - public static GUIStyle HighlightStyle { - get { - if( highlightStyle == null ) { - //if( Application.unityVersion.StartsWith("4") ) - highlightStyle = new GUIStyle( (GUIStyle)"flow node 0 on" ); - } - return highlightStyle; - } - } - - - private static GUIStyle selectionStyle; - public static GUIStyle SelectionStyle { - get { - if( selectionStyle == null ) { - //if( Application.unityVersion.StartsWith("4") ) - selectionStyle = new GUIStyle( (GUIStyle)"SelectionRect" ); - } - return selectionStyle; - } - } - - private static GUIStyle nodeStyle; - public static GUIStyle NodeStyle { - get { - if( nodeStyle == null ) { - //if( Application.unityVersion.StartsWith( "4" ) ) - nodeStyle = new GUIStyle( (GUIStyle)"flow node 0" ); - nodeStyle.alignment = TextAnchor.UpperCenter; - if(Application.platform == RuntimePlatform.WindowsEditor) - nodeStyle.fontSize = 9; - else - nodeStyle.fontSize = 11; - nodeStyle.font = EditorStyles.standardFont; - nodeStyle.fontStyle = FontStyle.Bold; - nodeStyle.padding.top = 23; - nodeStyle.padding.left = 1; - //nodeStyle.margin.right = 8; - //nodeStyle.border.right = 25; - nodeStyle.border.left = 25; - if(SF_GUI.ProSkin) - nodeStyle.normal.textColor = new Color( 1f, 1f, 1f, 0.75f ); - else - nodeStyle.normal.textColor = new Color( 0f, 0f, 0f, 0.7f ); - - } - - return nodeStyle; - } - } - - - private static GUIStyle nodeStyleDiscrete; - public static GUIStyle NodeStyleDiscrete{ - get { - if( nodeStyleDiscrete == null ) { - nodeStyleDiscrete = new GUIStyle(NodeStyle); - nodeStyleDiscrete.normal.textColor = SF_GUI.ProSkin ? new Color( 1f, 1f, 1f, 0.75f/5f ) : new Color( 0f, 0f, 0f, 0.7f/5f ); - } - return nodeStyleDiscrete; - } - } - //NodeStyleDiscrete - - - private static GUIStyle toggleDiscrete; - public static GUIStyle ToggleDiscrete { - get { - if( toggleDiscrete == null ) { - toggleDiscrete = new GUIStyle( GUI.skin.toggle ); - toggleDiscrete.fontSize = 10; - } - - return toggleDiscrete; - } - } - - - - // Thanks to Tenebrous! - public static void ListStyles() { - foreach( GUIStyle ss in GUI.skin.customStyles ) { - GUILayout.Label( ss.name ); - EditorGUILayout.LabelField( ss.name, ss ); - } - - FieldInfo f = typeof( EditorGUIUtility ).GetField( "s_IconGUIContents", BindingFlags.NonPublic | BindingFlags.Static ); - Hashtable ff = (Hashtable)f.GetValue( null ); - foreach( DictionaryEntry fff in ff ) { - GUILayout.Label( fff.Key.ToString() ); - GUILayout.Label( (GUIContent)fff.Value ); - } - } - - - - } -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Styles.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Styles.cs.meta deleted file mode 100755 index 35b377c7..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Styles.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: efe449f52e390bf4f846e213fd973d30 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Tools.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Tools.cs deleted file mode 100755 index dbf37e21..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Tools.cs +++ /dev/null @@ -1,486 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; -using System.Reflection; -using System.Text.RegularExpressions; - -namespace ShaderForge { - - [System.Serializable] - public enum RenderPlatform { - d3d9 = 0, // - Direct3D 9 - d3d11 = 1, // - Direct3D 11 / 12 - glcore = 2, // - OpenGL Core - gles = 3, // - OpenGL ES 2.0 - gles3 = 4, // - OpenGL ES 3.0 - metal = 5, // - iOS Metal - d3d11_9x = 6, // - Direct3D 11 windows RT - xboxone = 7, // - Xbox One - ps4 = 8, // - PlayStation 4 - psp2 = 9, // - PlayStation Vita - n3ds = 10, // - Nintendo 3DS - wiiu = 11 // - Nintendo Wii U - }; - - - - public static class SF_Tools { - - // Versioning - public static int versionNumPrimary = 1; - public static int versionNumSecondary = 38; - public static string versionStage = ""; - public static string version = versionNumPrimary + "." + versionNumSecondary.ToString( "D2" ); - public static string versionString = "Shader Forge v" + version; - - // Misc strings - public const string bugReportLabel = "Post bugs & ideas"; - public const string bugReportURL = "https://shaderforge.userecho.com/"; - public const string documentationLabel = "Node Documentation"; - public const string documentationURL = "http://www.acegikmo.com/shaderforge/nodes/"; - public static string[] rendererLabels = new string[]{ - "Direct3D 9", - "Direct3D 11 & 12", - "OpenGL Core", - "OpenGL ES 2.0", - "OpenGL ES 3.0", - "iOS Metal", - "Direct3D 11 for Windows RT/Phone", - "Xbox One", - "PlayStation 4", - "PlayStation Vita", - "Nintendo 3DS", - "Nintendo Wii U" - }; - - public const string alphabetLower = "abcdefghijklmnopqrstuvwxyz"; - public const string alphabetUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - - // Constants - public const int connectorMargin = 4; - - // User prefs - public static bool absColor = false; - public static bool advancedInspector = true; - public static int stationaryCursorRadius = 7; - - - public const float minimumUnityVersion = 5.3f; - - private static float currentUnityVersion = 0f; - public static float CurrentUnityVersion{ - get{ - if(currentUnityVersion == 0f){ - currentUnityVersion = float.Parse(Application.unityVersion.Substring(0,3)); - } - return currentUnityVersion; - } - } - - public static bool CanRunShaderForge(){ - return (CurrentUnityVersion >= minimumUnityVersion); - } - - - public static bool HasUnityPro(){ - return UnityEditorInternal.InternalEditorUtility.HasPro(); - } - - - - - public static void UnityOutOfDateGUI(){ - GUIStyle st = new GUIStyle(EditorStyles.boldLabel); - - st.alignment = TextAnchor.MiddleCenter; - - GUILayout.Label(string.Empty); - GUILayout.Label("You need to install Unity " + SF_Tools.minimumUnityVersion + " or later in order to use Shader Forge", st); - GUILayout.Label("You are currently running Unity version " + Application.unityVersion, st); - if(GUILayout.Button("Update Unity")){ - Application.OpenURL("http://unity3d.com/unity/download"); - } - GUILayout.Label(string.Empty); - } - - public static int ComponentCountOf(CustomValueType cvt){ - - switch(cvt){ - case CustomValueType.Float: - return 1; - case CustomValueType.Half: - return 1; - case CustomValueType.Fixed: - return 1; - case CustomValueType.Float2: - return 2; - case CustomValueType.Half2: - return 2; - case CustomValueType.Fixed2: - return 2; - case CustomValueType.Float3: - return 3; - case CustomValueType.Half3: - return 3; - case CustomValueType.Fixed3: - return 3; - case CustomValueType.Float4: - return 4; - case CustomValueType.Half4: - return 4; - case CustomValueType.Fixed4: - return 4; - case CustomValueType.Sampler2D: - return 4; - default: - // Debug.Log("Invalid component count check of custom value type: " + cvt); - return 16; - } - - - } - - - public static Color VectorToColor( float v ) { - if( absColor ) - v = Mathf.Abs(v); - return new Color( v,v,v ); - } - - public static Color VectorToColor( Vector2 v ) { - if( absColor ) - return new Color( Mathf.Clamp01( Mathf.Abs( v.x ) ), Mathf.Clamp01( Mathf.Abs( v.y ) ), 0f ); - else - return new Color( Mathf.Clamp01( v.x ), Mathf.Clamp01( v.y ), 0f ); - } - - public static Color VectorToColor( Vector3 v ) { - if( absColor ) - return new Color( Mathf.Clamp01( Mathf.Abs( v.x ) ), Mathf.Clamp01( Mathf.Abs( v.y ) ), Mathf.Clamp01( Mathf.Abs( v.z ) ) ); - else - return new Color( Mathf.Clamp01( v.x ), Mathf.Clamp01( v.y ), Mathf.Clamp01( v.z ) ); - } - - public static string AssetToGUID( UnityEngine.Object asset ) { - return AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( asset ) ); - } - - public static UnityEngine.Object GUIDToAsset( string GUID, Type type ) { - return AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath( GUID ), type ); - } - - public static float Smooth( float x ) { - return x * x * ( 3f - 2f * x ); - } - - public static float Smoother( float x ) { - return x * x * x * ( x * ( x * 6f - 15f ) + 10f ); - } - - - - public static string PathFromAbsoluteToProject(string s){ - return s.Substring(Application.dataPath.Length-6); - } - - public static void LinkButton(Rect r, string label, string URL, GUIStyle style){ - if( GUI.Button( r, label, style ) ) - Application.OpenURL(URL); - } - - - public static void AssignShaderToMaterialAsset( ref Material m, Shader s ) { - m.shader = s; - } - - public static float[] VectorToArray(Vector4 vec) { - return new float[4] { vec.x, vec.y, vec.z, vec.w }; - } - - public static float[] VectorToArray( float vec ) { - return new float[4] { vec, vec, vec, vec }; - } - - public static Vector3 ToVector3(Color c) { - return new Vector3( c.r, c.g, c.b ); - } - - public static Color ToColor( Vector3 vec ) { - return new Color( vec.x, vec.y, vec.z); - } - - public static float DistChebyshev(Vector2 a, Vector2 b) { - return Mathf.Max( Mathf.Abs(a.x - b.x), Mathf.Abs(a.y - b.y) ); - } - - - private static MethodInfo _doColorPickerMethod; - private static MethodInfo DoColorPickerMethod { - get{ - if(_doColorPickerMethod == null){ - Type t = Type.GetType( "UnityEditor.EditorGUI,UnityEditor" ); - Debug.Log("Type = " + t); - BindingFlags bfs = BindingFlags.Static | BindingFlags.NonPublic; - _doColorPickerMethod = t.GetMethod( "DoColorField", bfs, null, new Type[] { typeof( Rect ), typeof( int ), typeof( Color ), typeof( bool ), typeof( bool ) }, null ); - } - return _doColorPickerMethod; - } - } - - - // private static Color DoColorField(Rect position, int id, Color value, bool showEyedropper, bool showAlpha) - public static Color DoColorPicker( Rect position, Color color, bool showEyedropper, bool showAlpha ) { - //int id = GUIUtility.GetControlID(); - //return (Color)DoColorPickerMethod.Invoke( null, new object[] { position, id, color, showEyedropper, showAlpha } ); - return Color.red; - } - - public static Color FloatToColor( float f ) { - return new Color( f, f, f, f ); - } - - public static float Distance( Color a, Color b, int cc ) { - Color v = a - b; - return Mathf.Sqrt( Dot( v, v, cc ) ); - } - - public static float Dot(Color a, Color b, int compCount) { - - float retVal = 0f; - - for(int i=0;i s.xMax ) - s.xMax = i.xMax; - if( i.xMin < s.xMin ) - s.xMin = i.xMin; - if( i.yMax > s.yMax ) - s.yMax = i.yMax; - if( i.yMin < s.yMin ) - s.yMin = i.yMin; - return s; - } - - - public static void FormatShaderPath(ref string s){ - Regex rgx = new Regex( "[^a-zA-Z0-9/s -_]" ); // Only allow Alphanumeric, forward slash, space, dash and underscore - s = rgx.Replace( s, "" ); - } - - public static void FormatAlphanumeric( ref string s ) { - Regex rgx = new Regex( "[^a-zA-Z0-9-_]" ); // Only allow Alphanumeric, forward slash, space, dash and underscore - s = rgx.Replace( s, "" ); - } - - public static void FormatSerializableComment(ref string s){ - Regex rgx = new Regex( "[^\\w\\s_\\?\\.-]" ); // Only allow Alphanumeric, dot, dash, underscore and questionmark - s = rgx.Replace( s, "" ); - } - - public static void FormatSerializable( ref string s ) { - s = s.Replace( ":", "" ) - .Replace( ";", "" ) - .Replace( ",", "" ) - .Replace( "/*", "" ) - .Replace( "*/", "" ) - .Replace("\"", ""); - } - - public static void FormatSerializableVarName( ref string s ){ - FormatShaderPath(ref s); - - s = s.Replace(" ", string.Empty); - - if(s.Length > 0){ - - int tmp; - while(s.Length > 0 && int.TryParse(s[0].ToString(), out tmp)){ - s = s.Substring(1, s.Length-1); // Remove first character if first is a parsable integer - } - -// if(s.Length == 1){ -// s = s.ToLower(); // Lowercase the one character -// } else { -// char first = s[0]; // Lowercase the first character -// string rest = s.Substring( -// } - } - - } - - - public static Rect GetExpanded( Rect r, float px ) { - r.y -= px; - r.x -= px; - r.width += 2 * px; - r.height += 2 * px; - return r; - } - - - public static bool Intersects( Rect a, Rect b ) { - FlipNegative( ref a ); - FlipNegative( ref b ); - bool c1 = a.xMin < b.xMax; - bool c2 = a.xMax > b.xMin; - bool c3 = a.yMin < b.yMax; - bool c4 = a.yMax > b.yMin; - return c1 && c2 && c3 && c4; - } - - public static void FlipNegative(ref Rect r) { - if( r.width < 0 ) - r.x -= ( r.width *= -1 ); - if( r.height < 0 ) - r.y -= ( r.height *= -1 ); - } - - - public static float DistanceToLines(Vector2 point, Vector2[] line){ - float shortest = float.MaxValue; - - for (int i = 0; i < line.Length-1; i++) { - shortest = Mathf.Min(shortest, DistanceToLine(line[i], line[i+1], point)); - } - - return shortest; - - } - - public static float DistanceToLine(Vector2 a, Vector2 b, Vector2 point){ - // Return minimum distance between line segment vw and point p - float l2 = Vector2.SqrMagnitude(a - b); // i.e. |w-v|^2 - avoid a sqrt - if (l2 == 0.0) - return Vector2.Distance(point, a); // v == w case - // Consider the line extending the segment, parameterized as v + t (w - v). - // We find projection of point p onto the line. - // It falls where t = [(p-v) . (w-v)] / |w-v|^2 - float t = Vector2.Dot(point - a, b - a) / l2; - if (t < 0.0) - return Vector2.Distance(point, a); // Beyond the 'v' end of the segment - else if (t > 1.0) - return Vector2.Distance(point, b); // Beyond the 'w' end of the segment - Vector2 projection = a + t * (b - a); // Projection falls on the segment - return Vector2.Distance(point, projection); - } - - - - public static bool LineIntersection(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, out Vector2 intersection){ - - intersection = Vector2.zero; - - Vector2 s1, s2; - s1.x = p1.x - p0.x; - s1.y = p1.y - p0.y; - s2.x = p3.x - p2.x; - s2.y = p3.y - p2.y; - - float s, t, d; - d = -s2.x * s1.y + s1.x * s2.y; - - if(d == 0){ - return false; // Parallel lines, no intersection - } - - Vector2 pDiff = p0 - p2; - s = (-s1.y * pDiff.x + s1.x * pDiff.y) / d; - t = ( s2.x * pDiff.y - s2.y * pDiff.x) / d; - - if (s >= 0 && s <= 1 && t >= 0 && t <= 1) - { - intersection = p0 + (t * s1); - return true; // Intersection! - } - - return false; // No intersection - } - - - - // Returns the first intersection it can find - public static bool LineIntersection(Vector2 p0, Vector2 p1, Vector2[] points, out Vector2 intersection){ - intersection = Vector2.zero; - for(int i=0;i 0; - - } - - - public static string StringToBase64String(string str) { - return System.Convert.ToBase64String( GetBytes( str ) ); - } - - public static string Base64StringToString( string encoded ) { - return GetString( System.Convert.FromBase64String( encoded ) ); - } - - static byte[] GetBytes( string str ) { - byte[] bytes = new byte[str.Length * sizeof( char )]; - System.Buffer.BlockCopy( str.ToCharArray(), 0, bytes, 0, bytes.Length ); - return bytes; - } - - static string GetString( byte[] bytes ) { - char[] chars = new char[bytes.Length / sizeof( char )]; - System.Buffer.BlockCopy( bytes, 0, chars, 0, bytes.Length ); - return new string( chars ); - } - - - } -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Tools.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Tools.cs.meta deleted file mode 100755 index beee6963..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Tools.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 57c34190e3ef7294a906d4f71d8764ac -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Web.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Web.cs deleted file mode 100755 index 9da797d4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Web.cs +++ /dev/null @@ -1,32 +0,0 @@ -using UnityEngine; -using System.Collections; - -// Web data and access with Shader Forge -// Used for documentation, and perhaps later for update checking as well - -namespace ShaderForge{ - public static class SF_Web { - - - const string urlRoot = "http://acegikmo.com/shaderforge/"; // ?search=add"; - const string urlNodes = urlRoot + "nodes/"; - - - public static void OpenDocumentationForNode(SF_Node node){ - OpenDocumentationForString(node.SearchName); - } - public static void OpenDocumentationForNode(SF_EditorNodeData nodeData){ - OpenDocumentationForString(nodeData.SearchName); - } - - static void OpenDocumentationForString(string s){ - Application.OpenURL( urlNodes + "?search=" + StripExtraChars(s) ); - } - - - static string StripExtraChars(string s){ - return s.Replace(" ","").Replace(".",""); - } - - } -} diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Web.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Web.cs.meta deleted file mode 100755 index a46be09d..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_Web.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 149fd1a15c5e14ecab3711504e2fad2b -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ZoomArea.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ZoomArea.cs deleted file mode 100644 index c8687ed5..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ZoomArea.cs +++ /dev/null @@ -1,43 +0,0 @@ -using UnityEngine; - -namespace ShaderForge{ - public class SF_ZoomArea{ - private static float kEditorWindowTabHeight = 22.0f; - private static Matrix4x4 prevGuiMatrix; - - public static Rect Begin(float zoomScale, Rect screenCoordsArea, Vector2 cameraPos){ - GUI.EndGroup(); - kEditorWindowTabHeight = screenCoordsArea.y; - Rect clippedArea = screenCoordsArea.ScaleSizeBy(1.0f / zoomScale, screenCoordsArea.TopLeft()); - GUI.BeginGroup(clippedArea); - //if(zoomScale != 1f){ - //clippedArea.y += kEditorWindowTabHeight; - prevGuiMatrix = GUI.matrix; - Matrix4x4 translation = Matrix4x4.TRS(clippedArea.TopLeft(), Quaternion.identity, Vector3.one); - Matrix4x4 scale = Matrix4x4.Scale(new Vector3(zoomScale, zoomScale, 1.0f)); - GUI.matrix = translation * scale * translation.inverse * GUI.matrix; - //} else{ - // GUI.matrix = Matrix4x4.identity; - // prevGuiMatrix - //} - Rect offsetRect = screenCoordsArea; - offsetRect.x -= cameraPos.x; - offsetRect.y -= cameraPos.y; - offsetRect.width = int.MaxValue/2; - offsetRect.height = int.MaxValue/2; - GUI.BeginGroup(offsetRect); - - return clippedArea; - } - - public static void End(float zoomScale){ - GUI.EndGroup(); - //if(zoomScale != 1f) - GUI.matrix = prevGuiMatrix; - //else - // GUI.matrix = Matrix4x4.identity; - GUI.EndGroup(); - GUI.BeginGroup(new Rect(0.0f, kEditorWindowTabHeight, Screen.width, Screen.height)); - } - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ZoomArea.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ZoomArea.cs.meta deleted file mode 100644 index 0dcf3af4..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SF_ZoomArea.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2de28fcf3e7de48dd97865761bfa9eb2 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SerializableDictionary.cs b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SerializableDictionary.cs deleted file mode 100755 index 068ad2aa..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SerializableDictionary.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml.Serialization; - -namespace ShaderForge { - [XmlRoot( "dictionary" )] - public class SerializableDictionary : Dictionary, IXmlSerializable { - #region IXmlSerializable Members - public System.Xml.Schema.XmlSchema GetSchema() { - return null; - } - - public void ReadXml( System.Xml.XmlReader reader ) { - XmlSerializer keySerializer = new XmlSerializer( typeof( TKey ) ); - XmlSerializer valueSerializer = new XmlSerializer( typeof( TValue ) ); - - bool wasEmpty = reader.IsEmptyElement; - reader.Read(); - - if( wasEmpty ) - return; - - while( reader.NodeType != System.Xml.XmlNodeType.EndElement ) { - reader.ReadStartElement( "item" ); - - reader.ReadStartElement( "key" ); - TKey key = (TKey)keySerializer.Deserialize( reader ); - reader.ReadEndElement(); - - reader.ReadStartElement( "value" ); - TValue value = (TValue)valueSerializer.Deserialize( reader ); - reader.ReadEndElement(); - - this.Add( key, value ); - - reader.ReadEndElement(); - reader.MoveToContent(); - } - reader.ReadEndElement(); - } - - public void WriteXml( System.Xml.XmlWriter writer ) { - XmlSerializer keySerializer = new XmlSerializer( typeof( TKey ) ); - XmlSerializer valueSerializer = new XmlSerializer( typeof( TValue ) ); - - foreach( TKey key in this.Keys ) { - writer.WriteStartElement( "item" ); - - writer.WriteStartElement( "key" ); - keySerializer.Serialize( writer, key ); - writer.WriteEndElement(); - - writer.WriteStartElement( "value" ); - TValue value = this[key]; - valueSerializer.Serialize( writer, value ); - writer.WriteEndElement(); - - writer.WriteEndElement(); - } - } - #endregion - } -} \ No newline at end of file diff --git a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SerializableDictionary.cs.meta b/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SerializableDictionary.cs.meta deleted file mode 100755 index d4a5bc6f..00000000 --- a/Shader Forge/Assets/ShaderForge/Editor/Code/_Utility/SerializableDictionary.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7a1a116097ee8bf4f89ff5b55aced743 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Shader Forge/Assets/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeInspector.cs b/Shader Forge/Assets/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeInspector.cs index d49f27ae..682d3cf8 100644 --- a/Shader Forge/Assets/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeInspector.cs +++ b/Shader Forge/Assets/ShaderForge/Editor/InternalResources/Inspectors/ShaderForgeInspector.cs @@ -168,7 +168,7 @@ public override void OnInspectorGUI() { if( hasShaderForgeData ) { if( GUILayout.Button( "Open in Shader Forge" ) ) { - if(Event.current.rawType != EventType.mouseDown) + if(Event.current.rawType != EventType.MouseDown) SF_Editor.Init( shader ); } } else { diff --git a/Shader Forge/Assets/ShaderForge/Editor/ShaderForge.dll b/Shader Forge/Assets/ShaderForge/Editor/ShaderForge.dll new file mode 100644 index 00000000..fad8c09c Binary files /dev/null and b/Shader Forge/Assets/ShaderForge/Editor/ShaderForge.dll differ diff --git a/Shader Forge/Assets/ShaderForge/Editor/ShaderForge.dll.meta b/Shader Forge/Assets/ShaderForge/Editor/ShaderForge.dll.meta new file mode 100644 index 00000000..6fb4050b --- /dev/null +++ b/Shader Forge/Assets/ShaderForge/Editor/ShaderForge.dll.meta @@ -0,0 +1,34 @@ +fileFormatVersion: 2 +guid: 08443a5b77d963441a8fd8ae06b00101 +timeCreated: 1503340689 +licenseType: Store +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/CustomLighting.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/CustomLighting.shader index 5d79f548..b45aaa3f 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/CustomLighting.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/CustomLighting.shader @@ -106,7 +106,7 @@ Shader "Shader Forge/Examples/Custom Lighting" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(i.uv0, _Diffuse)); float3 finalColor = (attenuation*_LightColor0.rgb*((_Diffuse_var.rgb*_Color.rgb*floor(max(0,dot(lightDirection,normalDirection)) * _Bands) / (_Bands - 1))+UNITY_LIGHTMODEL_AMBIENT.rgb+floor(pow(max(0,dot(normalDirection,halfDirection)),exp2(((_Gloss*10.0)+1.0))) * _Bands) / (_Bands - 1))); return fixed4(finalColor,1); @@ -174,7 +174,7 @@ Shader "Shader Forge/Examples/Custom Lighting" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(i.uv0, _Diffuse)); float3 finalColor = (attenuation*_LightColor0.rgb*((_Diffuse_var.rgb*_Color.rgb*floor(max(0,dot(lightDirection,normalDirection)) * _Bands) / (_Bands - 1))+UNITY_LIGHTMODEL_AMBIENT.rgb+floor(pow(max(0,dot(normalDirection,halfDirection)),exp2(((_Gloss*10.0)+1.0))) * _Bands) / (_Bands - 1))); return fixed4(finalColor * 1,0); diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/CustomLighting.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/CustomLighting.shader.meta index afc26cc7..0609b53f 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/CustomLighting.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/CustomLighting.shader.meta @@ -1,11 +1,11 @@ fileFormatVersion: 2 guid: e570c2adf90d6a24b8634788025bb2bb -timeCreated: 1503327501 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: - _Diffuse: {fileID: 2800000, guid: 8993b617f08498f43adcbd90697f1c5d, type: 3} - _Normals: {fileID: 2800000, guid: c6dfb00dbee6bc044a8a3bb22e56e064, type: 3} + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/LightWrapping.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/LightWrapping.shader index 2aa87c34..7f37e513 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/LightWrapping.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/LightWrapping.shader @@ -1,7 +1,7 @@ // Shader created with Shader Forge v1.38 // Shader Forge (c) Freya Holmer - http://www.acegikmo.com/shaderforge/ // Note: Manually altering this data may prevent you from opening it in Shader Forge -/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:3,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:False,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:0,x:33560,y:32563,varname:node_0,prsc:2|diff-270-RGB,spec-1906-OUT,gloss-8495-OUT,lwrap-272-RGB;n:type:ShaderForge.SFN_Color,id:270,x:33250,y:32393,ptovrint:False,ptlb:Diffuse,ptin:_Diffuse,varname:_Diffuse,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0.9117647,c2:0.8760425,c3:0.8179066,c4:1;n:type:ShaderForge.SFN_Color,id:272,x:33250,y:32735,ptovrint:False,ptlb:Light Wrapping,ptin:_LightWrapping,varname:_LightWrapping,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0.9058824,c2:0.4941176,c3:0.4901961,c4:1;n:type:ShaderForge.SFN_Vector1,id:1906,x:33250,y:32541,varname:node_1906,prsc:2,v1:0;n:type:ShaderForge.SFN_Slider,id:8495,x:33093,y:32628,ptovrint:False,ptlb:Gloss,ptin:_Gloss,varname:node_8495,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;proporder:272-270-8495;pass:END;sub:END;*/ +/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:3,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:False,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:0,x:33560,y:32563,varname:node_0,prsc:2|diff-270-RGB,spec-1906-OUT,gloss-8495-OUT,lwrap-272-RGB;n:type:ShaderForge.SFN_Color,id:270,x:33250,y:32393,ptovrint:False,ptlb:Diffuse,ptin:_Diffuse,varname:_Diffuse,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0.9117647,c2:0.8760425,c3:0.8179066,c4:1;n:type:ShaderForge.SFN_Color,id:272,x:33250,y:32735,ptovrint:False,ptlb:Light Wrapping,ptin:_LightWrapping,varname:_LightWrapping,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0.9058824,c2:0.4941176,c3:0.4901961,c4:1;n:type:ShaderForge.SFN_Vector1,id:1906,x:33250,y:32541,varname:node_1906,prsc:2,v1:0;n:type:ShaderForge.SFN_Slider,id:8495,x:33093,y:32628,ptovrint:False,ptlb:Gloss,ptin:_Gloss,varname:_Gloss,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;proporder:272-270-8495;pass:END;sub:END;*/ Shader "Shader Forge/Examples/LightWrapping" { Properties { @@ -23,7 +23,6 @@ Shader "Shader Forge/Examples/LightWrapping" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDBASE #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #define _GLOSSYENV 1 #include "UnityCG.cginc" @@ -91,7 +90,7 @@ Shader "Shader Forge/Examples/LightWrapping" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; float Pi = 3.141592654; float InvPi = 0.31830988618; @@ -204,7 +203,6 @@ Shader "Shader Forge/Examples/LightWrapping" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDADD #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #define _GLOSSYENV 1 #include "UnityCG.cginc" @@ -260,7 +258,7 @@ Shader "Shader Forge/Examples/LightWrapping" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; float Pi = 3.141592654; float InvPi = 0.31830988618; @@ -320,7 +318,6 @@ Shader "Shader Forge/Examples/LightWrapping" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_META 1 #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #define _GLOSSYENV 1 #include "UnityCG.cginc" diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/LightWrapping.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/LightWrapping.shader.meta index 3b2e7edf..7f704f51 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/LightWrapping.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/LightWrapping.shader.meta @@ -1,9 +1,9 @@ fileFormatVersion: 2 guid: 12dc48c8a56df784b93db42c5d582f3e -timeCreated: 1503327504 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: [] + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Parallax.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Parallax.shader index 10de31ab..8196b843 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Parallax.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Parallax.shader @@ -23,7 +23,6 @@ Shader "Shader Forge/Examples/Parallax" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDBASE #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #define _GLOSSYENV 1 #include "UnityCG.cginc" @@ -100,7 +99,7 @@ Shader "Shader Forge/Examples/Parallax" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; float Pi = 3.141592654; float InvPi = 0.31830988618; @@ -212,7 +211,6 @@ Shader "Shader Forge/Examples/Parallax" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDADD #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #define _GLOSSYENV 1 #include "UnityCG.cginc" @@ -278,7 +276,7 @@ Shader "Shader Forge/Examples/Parallax" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; float Pi = 3.141592654; float InvPi = 0.31830988618; @@ -337,7 +335,6 @@ Shader "Shader Forge/Examples/Parallax" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_META 1 #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #define _GLOSSYENV 1 #include "UnityCG.cginc" diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Parallax.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Parallax.shader.meta index 4b22187d..59fee484 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Parallax.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Parallax.shader.meta @@ -1,11 +1,11 @@ fileFormatVersion: 2 guid: 848a7fd7a01ca494bbaad23b3f926b42 -timeCreated: 1503327507 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: - _Normal: {fileID: 2800000, guid: cf20bfced7e912046a9ce991a4d775ec, type: 3} - _AORGBHeightA: {fileID: 2800000, guid: 5fb7986dd6d0a8e4093ba82369dd6a4d, type: 3} + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/PixelRotator.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/PixelRotator.shader index acd388a8..a34c8d30 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/PixelRotator.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/PixelRotator.shader @@ -58,7 +58,7 @@ Shader "Shader Forge/Examples/Pixel Rotator" { float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz); float3 lightColor = _LightColor0.rgb; ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; /////// Diffuse: float NdotL = max(0.0,dot( normalDirection, lightDirection )); @@ -79,8 +79,8 @@ Shader "Shader Forge/Examples/Pixel Rotator" { float2 node_741_skew = node_744 + 0.2127+node_744.x*0.3713*node_744.y; float2 node_741_rnd = 4.789*sin(489.123*(node_741_skew)); float node_741 = frac(node_741_rnd.x*node_741_rnd.y*(1+node_741_skew.x)); - float4 node_1817 = _Time; - float node_563_ang = node_1817.g; + float4 node_6513 = _Time; + float node_563_ang = node_6513.g; float node_563_spd = 1.0; float node_563_cos = cos(node_563_spd*node_563_ang); float node_563_sin = sin(node_563_spd*node_563_ang); @@ -146,7 +146,7 @@ Shader "Shader Forge/Examples/Pixel Rotator" { float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w)); float3 lightColor = _LightColor0.rgb; ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; /////// Diffuse: float NdotL = max(0.0,dot( normalDirection, lightDirection )); @@ -165,8 +165,8 @@ Shader "Shader Forge/Examples/Pixel Rotator" { float2 node_741_skew = node_744 + 0.2127+node_744.x*0.3713*node_744.y; float2 node_741_rnd = 4.789*sin(489.123*(node_741_skew)); float node_741 = frac(node_741_rnd.x*node_741_rnd.y*(1+node_741_skew.x)); - float4 node_1127 = _Time; - float node_563_ang = node_1127.g; + float4 node_9092 = _Time; + float node_563_ang = node_9092.g; float node_563_spd = 1.0; float node_563_cos = cos(node_563_spd*node_563_ang); float node_563_sin = sin(node_563_spd*node_563_ang); diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/PixelRotator.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/PixelRotator.shader.meta index 5a747784..5c7b8ef3 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/PixelRotator.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/PixelRotator.shader.meta @@ -1,9 +1,9 @@ fileFormatVersion: 2 guid: 3c2ff98dd53924d0b85358d999cf6890 -timeCreated: 1503327511 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: [] + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Refraction.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Refraction.shader index 6a765d74..c575bf2b 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Refraction.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Refraction.shader @@ -85,7 +85,7 @@ Shader "Shader Forge/Examples/Refraction" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; float Pi = 3.141592654; float InvPi = 0.31830988618; @@ -251,7 +251,7 @@ Shader "Shader Forge/Examples/Refraction" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; float Pi = 3.141592654; float InvPi = 0.31830988618; diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Refraction.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Refraction.shader.meta index f3f1efe9..3907daad 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Refraction.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Refraction.shader.meta @@ -1,10 +1,10 @@ fileFormatVersion: 2 guid: 6562ed1722964fc4fa4eba1d756e19b7 -timeCreated: 1502814920 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: - _Refraction: {fileID: 2800000, guid: bbab0a6f7bae9cf42bf057d8ee2755f6, type: 3} + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/TessellationDisplacement.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/TessellationDisplacement.shader index 1cc8f63b..5719a2a5 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/TessellationDisplacement.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/TessellationDisplacement.shader @@ -1,7 +1,7 @@ // Shader created with Shader Forge v1.38 // Shader Forge (c) Freya Holmer - http://www.acegikmo.com/shaderforge/ // Note: Manually altering this data may prevent you from opening it in Shader Forge -/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:1,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:1,x:34362,y:32994,varname:node_1,prsc:2|diff-162-OUT,spec-165-OUT,gloss-66-OUT,normal-160-OUT,lwrap-237-OUT,disp-13-OUT,tess-8-OUT;n:type:ShaderForge.SFN_Tex2d,id:3,x:33597,y:33194,ptovrint:False,ptlb:Normals,ptin:_Normals,varname:_Normals,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:cf20bfced7e912046a9ce991a4d775ec,ntxv:3,isnm:True|UVIN-6-OUT;n:type:ShaderForge.SFN_Tex2d,id:4,x:32986,y:33006,varname:node_798,prsc:2,tex:5fb7986dd6d0a8e4093ba82369dd6a4d,ntxv:0,isnm:False|UVIN-6-OUT,TEX-254-TEX;n:type:ShaderForge.SFN_TexCoord,id:5,x:32078,y:33020,varname:node_5,prsc:2,uv:0,uaff:False;n:type:ShaderForge.SFN_Multiply,id:6,x:32307,y:33100,varname:node_6,prsc:2|A-5-UVOUT,B-7-OUT;n:type:ShaderForge.SFN_Vector1,id:7,x:32078,y:33232,varname:node_7,prsc:2,v1:2;n:type:ShaderForge.SFN_Vector1,id:8,x:34051,y:33620,varname:node_8,prsc:2,v1:3;n:type:ShaderForge.SFN_Tex2d,id:12,x:32759,y:33284,varname:node_803,prsc:2,tex:5fb7986dd6d0a8e4093ba82369dd6a4d,ntxv:0,isnm:False|UVIN-6-OUT,MIP-15-OUT,TEX-254-TEX;n:type:ShaderForge.SFN_Multiply,id:13,x:34051,y:33418,varname:node_13,prsc:2|A-14-OUT,B-17-OUT;n:type:ShaderForge.SFN_NormalVector,id:14,x:33824,y:33442,prsc:2,pt:False;n:type:ShaderForge.SFN_Vector1,id:15,x:32532,y:33364,varname:node_15,prsc:2,v1:1;n:type:ShaderForge.SFN_Slider,id:16,x:33213,y:33639,ptovrint:False,ptlb:Depth,ptin:_Depth,varname:_Depth,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.25,max:0.25;n:type:ShaderForge.SFN_Multiply,id:17,x:33824,y:33620,varname:node_17,prsc:2|A-23-OUT,B-26-OUT;n:type:ShaderForge.SFN_OneMinus,id:23,x:33597,y:33379,varname:node_23,prsc:2|IN-153-OUT;n:type:ShaderForge.SFN_Multiply,id:26,x:33597,y:33537,varname:node_26,prsc:2|A-27-OUT,B-16-OUT;n:type:ShaderForge.SFN_Vector1,id:27,x:33370,y:33478,varname:node_27,prsc:2,v1:-1;n:type:ShaderForge.SFN_Vector1,id:66,x:34051,y:32948,varname:node_66,prsc:2,v1:10;n:type:ShaderForge.SFN_Tex2d,id:152,x:32759,y:33099,ptovrint:False,ptlb:Displacement (R),ptin:_DisplacementR,varname:_DisplacementR,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:28c7aad1372ff114b90d330f8a2dd938,ntxv:0,isnm:False|UVIN-161-UVOUT,MIP-15-OUT;n:type:ShaderForge.SFN_Max,id:153,x:33370,y:33276,varname:node_153,prsc:2|A-152-R,B-12-A;n:type:ShaderForge.SFN_Subtract,id:154,x:32986,y:33174,varname:node_154,prsc:2|A-12-A,B-152-R;n:type:ShaderForge.SFN_Clamp01,id:156,x:33370,y:33108,varname:node_156,prsc:2|IN-154-OUT;n:type:ShaderForge.SFN_Lerp,id:157,x:33824,y:32948,varname:node_157,prsc:2|A-159-OUT,B-3-RGB,T-156-OUT;n:type:ShaderForge.SFN_Vector3,id:159,x:33597,y:33061,varname:node_159,prsc:2,v1:0,v2:0,v3:1;n:type:ShaderForge.SFN_Normalize,id:160,x:34051,y:33082,varname:node_160,prsc:2|IN-157-OUT;n:type:ShaderForge.SFN_Panner,id:161,x:32532,y:32984,varname:node_161,prsc:2,spu:0.4,spv:0|UVIN-6-OUT;n:type:ShaderForge.SFN_Lerp,id:162,x:33597,y:32875,varname:node_162,prsc:2|A-163-OUT,B-170-OUT,T-156-OUT;n:type:ShaderForge.SFN_Vector3,id:163,x:33370,y:32790,varname:node_163,prsc:2,v1:0.4117647,v2:0.3826572,v3:0.3602941;n:type:ShaderForge.SFN_Multiply,id:165,x:34051,y:32746,varname:node_165,prsc:2|A-156-OUT,B-172-OUT;n:type:ShaderForge.SFN_Multiply,id:170,x:33370,y:32940,varname:node_170,prsc:2|A-3497-RGB,B-4-RGB;n:type:ShaderForge.SFN_ComponentMask,id:172,x:33824,y:32770,varname:node_172,prsc:2,cc1:0,cc2:-1,cc3:-1,cc4:-1|IN-162-OUT;n:type:ShaderForge.SFN_OneMinus,id:174,x:33824,y:33284,varname:node_174,prsc:2|IN-156-OUT;n:type:ShaderForge.SFN_Multiply,id:237,x:34051,y:33250,varname:node_237,prsc:2|A-238-OUT,B-174-OUT;n:type:ShaderForge.SFN_Vector1,id:238,x:33824,y:33150,varname:node_238,prsc:2,v1:0.5;n:type:ShaderForge.SFN_Tex2dAsset,id:254,x:32532,y:33145,ptovrint:False,ptlb:AO (RGB) Height (A),ptin:_AORGBHeightA,varname:_AORGBHeightA,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:5fb7986dd6d0a8e4093ba82369dd6a4d,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:3497,x:32986,y:32833,ptovrint:False,ptlb:Diffuse,ptin:_Diffuse,varname:node_3497,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:b66bceaf0cc0ace4e9bdc92f14bba709,ntxv:0,isnm:False;proporder:3-254-152-16-3497;pass:END;sub:END;*/ +/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:1,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:1,x:34362,y:32994,varname:node_1,prsc:2|diff-162-OUT,spec-165-OUT,gloss-66-OUT,normal-160-OUT,lwrap-237-OUT,disp-13-OUT,tess-8-OUT;n:type:ShaderForge.SFN_Tex2d,id:3,x:33597,y:33194,ptovrint:False,ptlb:Normals,ptin:_Normals,varname:_Normals,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:cf20bfced7e912046a9ce991a4d775ec,ntxv:3,isnm:True|UVIN-6-OUT;n:type:ShaderForge.SFN_Tex2d,id:4,x:32986,y:33006,varname:node_798,prsc:2,tex:5fb7986dd6d0a8e4093ba82369dd6a4d,ntxv:0,isnm:False|UVIN-6-OUT,TEX-254-TEX;n:type:ShaderForge.SFN_TexCoord,id:5,x:32078,y:33020,varname:node_5,prsc:2,uv:0,uaff:False;n:type:ShaderForge.SFN_Multiply,id:6,x:32307,y:33100,varname:node_6,prsc:2|A-5-UVOUT,B-7-OUT;n:type:ShaderForge.SFN_Vector1,id:7,x:32078,y:33232,varname:node_7,prsc:2,v1:2;n:type:ShaderForge.SFN_Vector1,id:8,x:34051,y:33620,varname:node_8,prsc:2,v1:3;n:type:ShaderForge.SFN_Tex2d,id:12,x:32759,y:33284,varname:node_803,prsc:2,tex:5fb7986dd6d0a8e4093ba82369dd6a4d,ntxv:0,isnm:False|UVIN-6-OUT,MIP-15-OUT,TEX-254-TEX;n:type:ShaderForge.SFN_Multiply,id:13,x:34051,y:33418,varname:node_13,prsc:2|A-14-OUT,B-17-OUT;n:type:ShaderForge.SFN_NormalVector,id:14,x:33824,y:33442,prsc:2,pt:False;n:type:ShaderForge.SFN_Vector1,id:15,x:32532,y:33364,varname:node_15,prsc:2,v1:1;n:type:ShaderForge.SFN_Slider,id:16,x:33213,y:33639,ptovrint:False,ptlb:Depth,ptin:_Depth,varname:_Depth,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.25,max:0.25;n:type:ShaderForge.SFN_Multiply,id:17,x:33824,y:33620,varname:node_17,prsc:2|A-23-OUT,B-26-OUT;n:type:ShaderForge.SFN_OneMinus,id:23,x:33597,y:33379,varname:node_23,prsc:2|IN-153-OUT;n:type:ShaderForge.SFN_Multiply,id:26,x:33597,y:33537,varname:node_26,prsc:2|A-27-OUT,B-16-OUT;n:type:ShaderForge.SFN_Vector1,id:27,x:33370,y:33478,varname:node_27,prsc:2,v1:-1;n:type:ShaderForge.SFN_Vector1,id:66,x:34051,y:32948,varname:node_66,prsc:2,v1:10;n:type:ShaderForge.SFN_Tex2d,id:152,x:32759,y:33099,ptovrint:False,ptlb:Displacement (R),ptin:_DisplacementR,varname:_DisplacementR,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:28c7aad1372ff114b90d330f8a2dd938,ntxv:0,isnm:False|UVIN-161-UVOUT,MIP-15-OUT;n:type:ShaderForge.SFN_Max,id:153,x:33370,y:33276,varname:node_153,prsc:2|A-152-R,B-12-A;n:type:ShaderForge.SFN_Subtract,id:154,x:32986,y:33174,varname:node_154,prsc:2|A-12-A,B-152-R;n:type:ShaderForge.SFN_Clamp01,id:156,x:33370,y:33108,varname:node_156,prsc:2|IN-154-OUT;n:type:ShaderForge.SFN_Lerp,id:157,x:33824,y:32948,varname:node_157,prsc:2|A-159-OUT,B-3-RGB,T-156-OUT;n:type:ShaderForge.SFN_Vector3,id:159,x:33597,y:33061,varname:node_159,prsc:2,v1:0,v2:0,v3:1;n:type:ShaderForge.SFN_Normalize,id:160,x:34051,y:33082,varname:node_160,prsc:2|IN-157-OUT;n:type:ShaderForge.SFN_Panner,id:161,x:32532,y:32984,varname:node_161,prsc:2,spu:0.4,spv:0|UVIN-6-OUT;n:type:ShaderForge.SFN_Lerp,id:162,x:33597,y:32875,varname:node_162,prsc:2|A-163-OUT,B-170-OUT,T-156-OUT;n:type:ShaderForge.SFN_Vector3,id:163,x:33370,y:32790,varname:node_163,prsc:2,v1:0.4117647,v2:0.3826572,v3:0.3602941;n:type:ShaderForge.SFN_Multiply,id:165,x:34051,y:32746,varname:node_165,prsc:2|A-156-OUT,B-172-OUT;n:type:ShaderForge.SFN_Multiply,id:170,x:33370,y:32940,varname:node_170,prsc:2|A-3497-RGB,B-4-RGB;n:type:ShaderForge.SFN_ComponentMask,id:172,x:33824,y:32770,varname:node_172,prsc:2,cc1:0,cc2:-1,cc3:-1,cc4:-1|IN-162-OUT;n:type:ShaderForge.SFN_OneMinus,id:174,x:33824,y:33284,varname:node_174,prsc:2|IN-156-OUT;n:type:ShaderForge.SFN_Multiply,id:237,x:34051,y:33250,varname:node_237,prsc:2|A-238-OUT,B-174-OUT;n:type:ShaderForge.SFN_Vector1,id:238,x:33824,y:33150,varname:node_238,prsc:2,v1:0.5;n:type:ShaderForge.SFN_Tex2dAsset,id:254,x:32532,y:33145,ptovrint:False,ptlb:AO (RGB) Height (A),ptin:_AORGBHeightA,varname:_AORGBHeightA,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:5fb7986dd6d0a8e4093ba82369dd6a4d,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:3497,x:32986,y:32833,ptovrint:False,ptlb:Diffuse,ptin:_Diffuse,varname:_Diffuse,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:b66bceaf0cc0ace4e9bdc92f14bba709,ntxv:0,isnm:False;proporder:3-254-152-16-3497;pass:END;sub:END;*/ Shader "Shader Forge/Examples/TessellationDisplacement" { Properties { @@ -123,9 +123,9 @@ Shader "Shader Forge/Examples/TessellationDisplacement" { return o; } void displacement (inout VertexInput v){ - float4 node_21 = _Time; + float4 node_7816 = _Time; float2 node_6 = (v.texcoord0*2.0); - float2 node_161 = (node_6+node_21.g*float2(0.4,0)); + float2 node_161 = (node_6+node_7816.g*float2(0.4,0)); float node_15 = 1.0; float4 _DisplacementR_var = tex2Dlod(_DisplacementR,float4(TRANSFORM_TEX(node_161, _DisplacementR),0.0,node_15)); float4 node_803 = tex2Dlod(_AORGBHeightA,float4(TRANSFORM_TEX(node_6, _AORGBHeightA),0.0,node_15)); @@ -178,8 +178,8 @@ Shader "Shader Forge/Examples/TessellationDisplacement" { float3 _Normals_var = UnpackNormal(tex2D(_Normals,TRANSFORM_TEX(node_6, _Normals))); float node_15 = 1.0; float4 node_803 = tex2Dlod(_AORGBHeightA,float4(TRANSFORM_TEX(node_6, _AORGBHeightA),0.0,node_15)); - float4 node_21 = _Time; - float2 node_161 = (node_6+node_21.g*float2(0.4,0)); + float4 node_7816 = _Time; + float2 node_161 = (node_6+node_7816.g*float2(0.4,0)); float4 _DisplacementR_var = tex2Dlod(_DisplacementR,float4(TRANSFORM_TEX(node_161, _DisplacementR),0.0,node_15)); float node_156 = saturate((node_803.a-_DisplacementR_var.r)); float3 normalLocal = normalize(lerp(float3(0,0,1),_Normals_var.rgb,node_156)); @@ -189,7 +189,7 @@ Shader "Shader Forge/Examples/TessellationDisplacement" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; ///////// Gloss: float gloss = 10.0; @@ -362,9 +362,9 @@ Shader "Shader Forge/Examples/TessellationDisplacement" { return o; } void displacement (inout VertexInput v){ - float4 node_2942 = _Time; + float4 node_5581 = _Time; float2 node_6 = (v.texcoord0*2.0); - float2 node_161 = (node_6+node_2942.g*float2(0.4,0)); + float2 node_161 = (node_6+node_5581.g*float2(0.4,0)); float node_15 = 1.0; float4 _DisplacementR_var = tex2Dlod(_DisplacementR,float4(TRANSFORM_TEX(node_161, _DisplacementR),0.0,node_15)); float4 node_803 = tex2Dlod(_AORGBHeightA,float4(TRANSFORM_TEX(node_6, _AORGBHeightA),0.0,node_15)); @@ -417,8 +417,8 @@ Shader "Shader Forge/Examples/TessellationDisplacement" { float3 _Normals_var = UnpackNormal(tex2D(_Normals,TRANSFORM_TEX(node_6, _Normals))); float node_15 = 1.0; float4 node_803 = tex2Dlod(_AORGBHeightA,float4(TRANSFORM_TEX(node_6, _AORGBHeightA),0.0,node_15)); - float4 node_2942 = _Time; - float2 node_161 = (node_6+node_2942.g*float2(0.4,0)); + float4 node_5581 = _Time; + float2 node_161 = (node_6+node_5581.g*float2(0.4,0)); float4 _DisplacementR_var = tex2Dlod(_DisplacementR,float4(TRANSFORM_TEX(node_161, _DisplacementR),0.0,node_15)); float node_156 = saturate((node_803.a-_DisplacementR_var.r)); float3 normalLocal = normalize(lerp(float3(0,0,1),_Normals_var.rgb,node_156)); @@ -427,7 +427,7 @@ Shader "Shader Forge/Examples/TessellationDisplacement" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; ///////// Gloss: float gloss = 10.0; @@ -547,9 +547,9 @@ Shader "Shader Forge/Examples/TessellationDisplacement" { return o; } void displacement (inout VertexInput v){ - float4 node_7647 = _Time; + float4 node_266 = _Time; float2 node_6 = (v.texcoord0*2.0); - float2 node_161 = (node_6+node_7647.g*float2(0.4,0)); + float2 node_161 = (node_6+node_266.g*float2(0.4,0)); float node_15 = 1.0; float4 _DisplacementR_var = tex2Dlod(_DisplacementR,float4(TRANSFORM_TEX(node_161, _DisplacementR),0.0,node_15)); float4 node_803 = tex2Dlod(_AORGBHeightA,float4(TRANSFORM_TEX(node_6, _AORGBHeightA),0.0,node_15)); @@ -690,9 +690,9 @@ Shader "Shader Forge/Examples/TessellationDisplacement" { return o; } void displacement (inout VertexInput v){ - float4 node_5250 = _Time; + float4 node_5112 = _Time; float2 node_6 = (v.texcoord0*2.0); - float2 node_161 = (node_6+node_5250.g*float2(0.4,0)); + float2 node_161 = (node_6+node_5112.g*float2(0.4,0)); float node_15 = 1.0; float4 _DisplacementR_var = tex2Dlod(_DisplacementR,float4(TRANSFORM_TEX(node_161, _DisplacementR),0.0,node_15)); float4 node_803 = tex2Dlod(_AORGBHeightA,float4(TRANSFORM_TEX(node_6, _AORGBHeightA),0.0,node_15)); @@ -751,8 +751,8 @@ Shader "Shader Forge/Examples/TessellationDisplacement" { float4 node_798 = tex2D(_AORGBHeightA,TRANSFORM_TEX(node_6, _AORGBHeightA)); float node_15 = 1.0; float4 node_803 = tex2Dlod(_AORGBHeightA,float4(TRANSFORM_TEX(node_6, _AORGBHeightA),0.0,node_15)); - float4 node_5250 = _Time; - float2 node_161 = (node_6+node_5250.g*float2(0.4,0)); + float4 node_5112 = _Time; + float2 node_161 = (node_6+node_5112.g*float2(0.4,0)); float4 _DisplacementR_var = tex2Dlod(_DisplacementR,float4(TRANSFORM_TEX(node_161, _DisplacementR),0.0,node_15)); float node_156 = saturate((node_803.a-_DisplacementR_var.r)); float3 node_162 = lerp(float3(0.4117647,0.3826572,0.3602941),(_Diffuse_var.rgb*node_798.rgb),node_156); diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/TessellationDisplacement.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/TessellationDisplacement.shader.meta index 1f37dba9..fc12fb54 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/TessellationDisplacement.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/TessellationDisplacement.shader.meta @@ -1,13 +1,13 @@ fileFormatVersion: 2 guid: 5e81283b11113de4295d1943aec0a765 -timeCreated: 1503327524 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: - _Normals: {fileID: 2800000, guid: cf20bfced7e912046a9ce991a4d775ec, type: 3} - _DisplacementR: {fileID: 2800000, guid: 28c7aad1372ff114b90d330f8a2dd938, type: 3} - _AORGBHeightA: {fileID: 2800000, guid: 5fb7986dd6d0a8e4093ba82369dd6a4d, type: 3} - _Diffuse: {fileID: 2800000, guid: b66bceaf0cc0ace4e9bdc92f14bba709, type: 3} + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Tiles.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Tiles.shader index 331776e7..8895fb73 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Tiles.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Tiles.shader @@ -1,7 +1,7 @@ // Shader created with Shader Forge v1.38 // Shader Forge (c) Freya Holmer - http://www.acegikmo.com/shaderforge/ // Note: Manually altering this data may prevent you from opening it in Shader Forge -/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:3,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:0,x:33638,y:32808,varname:node_0,prsc:2|diff-138-RGB,spec-145-OUT,gloss-144-OUT;n:type:ShaderForge.SFN_Tex2d,id:138,x:33259,y:32700,ptovrint:False,ptlb:Base Color,ptin:_BaseColor,varname:_Diffuse,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:b66bceaf0cc0ace4e9bdc92f14bba709,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Slider,id:144,x:33102,y:32979,ptovrint:False,ptlb:Gloss,ptin:_Gloss,varname:_Gloss,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.5,max:1;n:type:ShaderForge.SFN_Slider,id:145,x:33102,y:32879,ptovrint:False,ptlb:Metallic,ptin:_Metallic,varname:_Specular,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;proporder:138-145-144;pass:END;sub:END;*/ +/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:3,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:0,x:33638,y:32808,varname:node_0,prsc:2|diff-138-RGB,spec-145-OUT,gloss-144-OUT;n:type:ShaderForge.SFN_Tex2d,id:138,x:33259,y:32700,ptovrint:False,ptlb:Base Color,ptin:_BaseColor,varname:_BaseColor,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:b66bceaf0cc0ace4e9bdc92f14bba709,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Slider,id:144,x:33102,y:32979,ptovrint:False,ptlb:Gloss,ptin:_Gloss,varname:_Gloss,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.5,max:1;n:type:ShaderForge.SFN_Slider,id:145,x:33102,y:32879,ptovrint:False,ptlb:Metallic,ptin:_Metallic,varname:_Metallic,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;proporder:138-145-144;pass:END;sub:END;*/ Shader "Shader Forge/Examples/Tiles" { Properties { @@ -23,7 +23,6 @@ Shader "Shader Forge/Examples/Tiles" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDBASE #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #define _GLOSSYENV 1 #include "UnityCG.cginc" @@ -97,7 +96,7 @@ Shader "Shader Forge/Examples/Tiles" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; float Pi = 3.141592654; float InvPi = 0.31830988618; @@ -209,7 +208,6 @@ Shader "Shader Forge/Examples/Tiles" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDADD #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #define _GLOSSYENV 1 #include "UnityCG.cginc" @@ -271,7 +269,7 @@ Shader "Shader Forge/Examples/Tiles" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; float Pi = 3.141592654; float InvPi = 0.31830988618; @@ -330,7 +328,6 @@ Shader "Shader Forge/Examples/Tiles" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_META 1 #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #define _GLOSSYENV 1 #include "UnityCG.cginc" diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Tiles.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Tiles.shader.meta index 0cfc4dca..7de6f97e 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Tiles.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Tiles.shader.meta @@ -1,10 +1,10 @@ fileFormatVersion: 2 guid: 05eb3a2c382b4154cb71394a349d0909 -timeCreated: 1503327527 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: - _BaseColor: {fileID: 2800000, guid: b66bceaf0cc0ace4e9bdc92f14bba709, type: 3} + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Vegetation.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Vegetation.shader index 0cbfab75..38937c99 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Vegetation.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Vegetation.shader @@ -26,7 +26,6 @@ Shader "Shader Forge/Examples/Animated Vegetation" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDBASE #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "AutoLight.cginc" @@ -110,7 +109,7 @@ Shader "Shader Forge/Examples/Animated Vegetation" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; ///////// Gloss: float gloss = 0.4; @@ -182,7 +181,6 @@ Shader "Shader Forge/Examples/Animated Vegetation" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDADD #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "AutoLight.cginc" @@ -254,7 +252,7 @@ Shader "Shader Forge/Examples/Animated Vegetation" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; ///////// Gloss: float gloss = 0.4; @@ -295,7 +293,6 @@ Shader "Shader Forge/Examples/Animated Vegetation" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_SHADOWCASTER #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "Lighting.cginc" @@ -364,7 +361,6 @@ Shader "Shader Forge/Examples/Animated Vegetation" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_META 1 #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "Lighting.cginc" diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Vegetation.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Vegetation.shader.meta index 655f7968..2b099fb4 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Vegetation.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/Vegetation.shader.meta @@ -1,11 +1,11 @@ fileFormatVersion: 2 guid: e17d9c256530145c39caf8efc8c94a16 -timeCreated: 1503327530 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: - _Diffuse: {fileID: 2800000, guid: 66321cc856b03e245ac41ed8a53e0ecc, type: 3} - _Normal: {fileID: 2800000, guid: cb6c5165ed180c543be39ed70e72abc8, type: 3} + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexAnimation.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexAnimation.shader index 8779b653..f0fc2708 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexAnimation.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexAnimation.shader @@ -26,7 +26,6 @@ Shader "Shader Forge/Examples/Vertex Animation" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDBASE #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "AutoLight.cginc" @@ -85,8 +84,8 @@ Shader "Shader Forge/Examples/Vertex Animation" { o.normalDir = UnityObjectToWorldNormal(v.normal); o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz ); o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); - float4 node_3210 = _Time; - float node_133 = pow((abs((frac((o.uv0+node_3210.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient + float4 node_7291 = _Time; + float node_133 = pow((abs((frac((o.uv0+node_7291.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient float node_1924 = node_133; v.vertex.xyz += (node_1924*_BulgeScale*v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); @@ -101,8 +100,8 @@ Shader "Shader Forge/Examples/Vertex Animation" { float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir); float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); float3 _Normals_var = UnpackNormal(tex2D(_Normals,TRANSFORM_TEX(i.uv0, _Normals))); - float4 node_3210 = _Time; - float node_133 = pow((abs((frac((i.uv0+node_3210.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient + float4 node_7291 = _Time; + float node_133 = pow((abs((frac((i.uv0+node_7291.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient float3 normalLocal = normalize(lerp(_Normals_var.rgb,float3(0,0,1),node_133)); float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals float3 viewReflectDirection = reflect( -viewDirection, normalDirection ); @@ -110,7 +109,7 @@ Shader "Shader Forge/Examples/Vertex Animation" { float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; ///////// Gloss: float gloss = 0.5; @@ -185,7 +184,6 @@ Shader "Shader Forge/Examples/Vertex Animation" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDADD #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "AutoLight.cginc" @@ -233,8 +231,8 @@ Shader "Shader Forge/Examples/Vertex Animation" { o.normalDir = UnityObjectToWorldNormal(v.normal); o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz ); o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); - float4 node_982 = _Time; - float node_133 = pow((abs((frac((o.uv0+node_982.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient + float4 node_3933 = _Time; + float node_133 = pow((abs((frac((o.uv0+node_3933.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient float node_1924 = node_133; v.vertex.xyz += (node_1924*_BulgeScale*v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); @@ -249,15 +247,15 @@ Shader "Shader Forge/Examples/Vertex Animation" { float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir); float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); float3 _Normals_var = UnpackNormal(tex2D(_Normals,TRANSFORM_TEX(i.uv0, _Normals))); - float4 node_982 = _Time; - float node_133 = pow((abs((frac((i.uv0+node_982.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient + float4 node_3933 = _Time; + float node_133 = pow((abs((frac((i.uv0+node_3933.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient float3 normalLocal = normalize(lerp(_Normals_var.rgb,float3(0,0,1),node_133)); float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w)); float3 lightColor = _LightColor0.rgb; float3 halfDirection = normalize(viewDirection+lightDirection); ////// Lighting: - float attenuation = LIGHT_ATTENUATION(i); + UNITY_LIGHT_ATTENUATION(attenuation,i, i.posWorld.xyz); float3 attenColor = attenuation * _LightColor0.xyz; ///////// Gloss: float gloss = 0.5; @@ -299,7 +297,6 @@ Shader "Shader Forge/Examples/Vertex Animation" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_SHADOWCASTER #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "Lighting.cginc" @@ -336,8 +333,8 @@ Shader "Shader Forge/Examples/Vertex Animation" { o.uv1 = v.texcoord1; o.uv2 = v.texcoord2; o.normalDir = UnityObjectToWorldNormal(v.normal); - float4 node_8271 = _Time; - float node_133 = pow((abs((frac((o.uv0+node_8271.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient + float4 node_2313 = _Time; + float node_133 = pow((abs((frac((o.uv0+node_2313.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient float node_1924 = node_133; v.vertex.xyz += (node_1924*_BulgeScale*v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); @@ -363,7 +360,6 @@ Shader "Shader Forge/Examples/Vertex Animation" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_META 1 #define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) ) #include "UnityCG.cginc" #include "Lighting.cginc" @@ -404,8 +400,8 @@ Shader "Shader Forge/Examples/Vertex Animation" { o.uv1 = v.texcoord1; o.uv2 = v.texcoord2; o.normalDir = UnityObjectToWorldNormal(v.normal); - float4 node_6924 = _Time; - float node_133 = pow((abs((frac((o.uv0+node_6924.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient + float4 node_6916 = _Time; + float node_133 = pow((abs((frac((o.uv0+node_6916.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient float node_1924 = node_133; v.vertex.xyz += (node_1924*_BulgeScale*v.normal); o.posWorld = mul(unity_ObjectToWorld, v.vertex); @@ -419,8 +415,8 @@ Shader "Shader Forge/Examples/Vertex Animation" { UnityMetaInput o; UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o ); - float4 node_6924 = _Time; - float node_133 = pow((abs((frac((i.uv0+node_6924.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient + float4 node_6916 = _Time; + float node_133 = pow((abs((frac((i.uv0+node_6916.g*float2(0.25,0)).r)-0.5))*2.0),_BulgeShape); // Panning gradient float node_1924 = node_133; o.Emission = (_GlowColor.rgb*_GlowIntensity*node_1924); diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexAnimation.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexAnimation.shader.meta index 086ec59e..7b1e8a12 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexAnimation.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexAnimation.shader.meta @@ -1,11 +1,11 @@ fileFormatVersion: 2 guid: 6dedef75fd0484cdf8557f522ceaa8bf -timeCreated: 1503327533 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: - _Diffuse: {fileID: 2800000, guid: b66bceaf0cc0ace4e9bdc92f14bba709, type: 3} - _Normals: {fileID: 2800000, guid: bbab0a6f7bae9cf42bf057d8ee2755f6, type: 3} + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexColorRounding.shader b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexColorRounding.shader index 9e1394ee..830c1a0a 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexColorRounding.shader +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexColorRounding.shader @@ -21,7 +21,6 @@ Shader "Shader Forge/Examples/Vertex Color Rounding" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_FORWARDBASE #include "UnityCG.cginc" #pragma multi_compile_fwdbase_fullshadows #pragma only_renderers d3d9 d3d11 glcore gles gles3 metal d3d11_9x xboxone ps4 psp2 n3ds wiiu @@ -61,7 +60,6 @@ Shader "Shader Forge/Examples/Vertex Color Rounding" { CGPROGRAM #pragma vertex vert #pragma fragment frag - #define UNITY_PASS_META 1 #include "UnityCG.cginc" #include "UnityMetaPass.cginc" #pragma fragmentoption ARB_precision_hint_fastest diff --git a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexColorRounding.shader.meta b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexColorRounding.shader.meta index 8ad756b6..72ea7569 100644 --- a/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexColorRounding.shader.meta +++ b/Shader Forge/Assets/ShaderForge/Example Assets/Shaders/VertexColorRounding.shader.meta @@ -1,9 +1,9 @@ fileFormatVersion: 2 guid: 49227bca0885f49f9898c7a9ba353bc1 -timeCreated: 1503327570 -licenseType: Pro ShaderImporter: + externalObjects: {} defaultTextures: [] + nonModifiableTextures: [] userData: assetBundleName: assetBundleVariant: diff --git a/Shader Forge/Packages/manifest.json b/Shader Forge/Packages/manifest.json new file mode 100644 index 00000000..526aca60 --- /dev/null +++ b/Shader Forge/Packages/manifest.json @@ -0,0 +1,4 @@ +{ + "dependencies": { + } +} diff --git a/Shader Forge/ProjectSettings/PresetManager.asset b/Shader Forge/ProjectSettings/PresetManager.asset new file mode 100644 index 00000000..636a595b --- /dev/null +++ b/Shader Forge/ProjectSettings/PresetManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1386491679 &1 +PresetManager: + m_ObjectHideFlags: 0 + m_DefaultList: [] diff --git a/Shader Forge/ProjectSettings/ProjectVersion.txt b/Shader Forge/ProjectSettings/ProjectVersion.txt index ca09a3da..22977b32 100644 --- a/Shader Forge/ProjectSettings/ProjectVersion.txt +++ b/Shader Forge/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 5.6.0f3 +m_EditorVersion: 2018.1.0f2