Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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
        }
Ejemplo n.º 3
0
        public void RefractionBlock(ref Rect r)
        {
            perObjectRefraction = UndoableToggle(r, perObjectRefraction, "每个对象的折射/场景颜色 (耗费性能)", "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, "纹理名称/组");
            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();
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
		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 );
		}
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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 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'));
     }
 }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        public override string SerializeSpecialData()
        {
            string s = property.Serialize() + ",";

            if (cubemapAsset != null)
            {
                s += "cube:" + SF_Tools.AssetToGUID(cubemapAsset) + ",";
            }
            s += "pvfc:" + (int)previewFace;
            return(s);
        }
 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();
 }
Ejemplo n.º 14
0
		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;

		}
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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 );
             *
             * }*/
        }
Ejemplo n.º 17
0
        void DeserializeCgIncludes(string serialized)
        {
            string decoded = SF_Tools.Base64StringToString(serialized);

            cgIncludes = new List <string>(decoded.Split(splitChars));

            // Remove empty entries
            for (int i = cgIncludes.Count - 1; i >= 0; i--)
            {
                if (cgIncludes[i] == string.Empty)
                {
                    cgIncludes.RemoveAt(i);
                }
            }
        }
Ejemplo n.º 18
0
		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;
			}
		}
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        public static void QuickBezier(Vector2 p0, Vector2 p1, Color color, int detail = 12, int width = 2)
        {
            Vector2 prevPoint = p0;

            for (float i = 1; i < detail - 1; i++)
            {
                float t = i / (detail - 2);

                Vector2 nextPoint = new Vector2(
                    Mathf.Lerp(p0.x, p1.x, t),
                    Mathf.Lerp(p0.y, p1.y, SF_Tools.Smooth(t))
                    );

                DrawLine(prevPoint, nextPoint, color, width, true);

                prevPoint = nextPoint;
            }
        }
Ejemplo n.º 21
0
        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();
            }
        }
Ejemplo n.º 22
0
        public void DrawTypecastButton(Rect r, SF_NodeConnector con, bool isInput = false)
        {
            Rect closeRect = r.ClampWidth(0, (int)r.height);

            if (isInput)
            {
                GUI.color = new Color(1f, 0.7f, 0.7f, 1f);
                if (GUI.Button(closeRect, "-"))
                {
                    RemoveConnector(con, undoRecord: true);
                    return;
                }
                GUI.color = Color.white;
                r.xMin   += closeRect.width;
                Rect dropdownRect = r;
                dropdownRect.xMax -= 50;
                r.xMin            += dropdownRect.width;
                int cvtccBef = SF_Tools.ComponentCountOf(con.CustomValueType);
                //con.CustomValueType = (CustomValueType)EditorGUI.EnumPopup(dropdownRect, con.CustomValueType);
                con.CustomValueType = (CustomValueType)UndoableEnumPopup(dropdownRect, con.CustomValueType, "set input " + con.label + " value type");
                if (cvtccBef != SF_Tools.ComponentCountOf(con.CustomValueType))
                {
                    con.Disconnect();
                }
                string before = con.label;
                con.label = EditorGUI.TextField(r, con.label);
                if (con.label != before && con.label.Length > 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();
                }
            }
        }
        private Rect GetSelectionBounds()
        {
            Rect nullRect = new Rect(0, 0, 0, 0);
            Rect r        = nullRect;

            for (int i = 0; i < selection.Count; i++)
            {
                if (selection[i] is SFN_Final)
                {
                    continue;
                }
                if (r == nullRect)
                {
                    r = new Rect(selection[i].rect);
                }
                else
                {
                    r = SF_Tools.Encapsulate(r, selection[i].rect);
                }
            }

            return(r);
        }
Ejemplo n.º 24
0
        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));
        }
Ejemplo n.º 25
0
 public override int GetEvaluatedComponentCount()
 {
     return(SF_Tools.ComponentCountOf(connectors[0].CustomValueType));
 }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
 string EncodeCode()
 {
     return(SF_Tools.StringToBase64String(code));
 }
Ejemplo n.º 28
0
 string DecodeCode(string encoded)
 {
     return(SF_Tools.Base64StringToString(encoded));
 }
Ejemplo n.º 29
0
        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 < pCount; i++)
                {
                    float t = (float)i / (float)segments;
                    points[i] = CubicBezierOffset(offset, bAp0, bAp1, bAp2, bAp3, t);
                }

                // Second line! Let's go

                Vector2 bBp0 = new Vector2(end.x, midVert);                // Start Point
                Vector2 bBp3 = end;                                        // End Point

                tangentMag = Mathf.Abs(bBp0.y - bBp3.y) * mul;             // TODO: Scale based on length if smaler than something
                tangentVec = new Vector2(tangentMag, 0f);

                Vector2 bBp1 = bBp0 + tangentVec;                                       // Start Tangent
                Vector2 bBp2 = bBp3 + tangentVec;                                       // End Tangent

                for (int i = 0; i < pCount; i++)
                {
                    float t = (float)i / (float)segments;
                    points[i + pCount] = CubicBezierOffset(offset, bBp0, bBp1, bBp2, bBp3, t);
                }
            }
            else
            {
                for (int i = 0; i < pCount; i++)
                {
                    float t = (float)i / (float)segments;
                    points[i] = ConnectionBezierOffset(offset, start, end, t);
                }
            }



            return(points);
        }
Ejemplo n.º 30
0
        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;

            EditorGUI.LabelField(r, "Custom Tag", EditorStyles.miniLabel);
            r.xMin   += 80;
            r.height  = 17;
            r.xMax   -= 3;
            customTag = UndoableTextField(r, customTag, "CustomTag", null);
            r.xMin   -= 80;
            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, "<color=#00000000>" + cgIncludes[i] + "</color>.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 < usedRenderers.Length; i++)
            {
                bool isDX11orGlCore = (i == (int)RenderPlatform.d3d11) || i == (int)RenderPlatform.glcore;

                r.width = 20;

                bool prevEnable = GUI.enabled;
                //bool displayBool = usedRenderers[i];

                bool shouldDisable = !isDX11orGlCore && onlyDX11GlCore;

                if (shouldDisable)
                {
                    GUI.enabled = false;
                    EditorGUI.Toggle(r, false);
                }
                else
                {
                    usedRenderers[i] = UndoableToggle(r, usedRenderers[i], SF_Tools.rendererLabels[i] + " renderer");
                    //usedRenderers[i] = EditorGUI.Toggle( r, usedRenderers[i] );
                }


                r.width = pWidth;
                r.xMin += 20;
                EditorGUI.LabelField(r, SF_Tools.rendererLabels[i], EditorStyles.miniLabel);

                if (shouldDisable)
                {
                    GUI.enabled = prevEnable;
                }

                r.xMin -= 20;
                r.y    += r.height + 1;
            }

            r.y += prevYpos;

            return((int)r.yMax);
        }