{
  "Name": "BlendState",
  "_id": "37779055-d9d9-479f-9e81-51fd35ad0a40",
  "Namespace": "lib.3d.material",
  "Description": "Sets a new blend state.",
  "Inputs": [
    {
      "Name": "SceneInput",
      "MetaInstanceID": "2a146001-0a5e-4636-8c74-4fc9151da7a9",
      "DefaultValue": {
        "Type": "Scene",
        "Value": "Framefield.Core.Scene"
      },
      "MetaID": "79122951-7bc4-4c68-b085-866eab828248",
      "IsMultiInput": "False",
      "Relevance": "Required",
      "Description": "",
      "Min": "-100000",
      "Max": "100000",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "BlendEnabled",
      "MetaInstanceID": "2a94a9ca-b8b0-4c11-8073-d2999c925ec2",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": [
        {
          "Name": "Off",
          "Value": "0"
        },
        {
          "Name": "On",
          "Value": "1"
        }
      ]
    },
    {
      "Name": "SrcBlend",
      "MetaInstanceID": "5c972ca3-966e-4a7c-96ae-55e936d8ce84",
      "DefaultValue": {
        "Type": "Float",
        "Value": "5"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "1",
      "Max": "19",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": [
        {
          "Name": "Zero",
          "Value": "1"
        },
        {
          "Name": "One",
          "Value": "2"
        },
        {
          "Name": "Src Color",
          "Value": "3"
        },
        {
          "Name": "Inv Src Color",
          "Value": "4"
        },
        {
          "Name": "Src Alpha",
          "Value": "5"
        },
        {
          "Name": "Inv Src Alpha",
          "Value": "6"
        },
        {
          "Name": "Dest Alpha",
          "Value": "7"
        },
        {
          "Name": "Inv Dest Alpha",
          "Value": "8"
        },
        {
          "Name": "Dest Color",
          "Value": "9"
        },
        {
          "Name": "Inv Dest Color",
          "Value": "10"
        },
        {
          "Name": "Src Alpha Sat",
          "Value": "11"
        },
        {
          "Name": "Blend Factor",
          "Value": "14"
        },
        {
          "Name": "Inv Blend Factor",
          "Value": "15"
        },
        {
          "Name": "Src1 Color",
          "Value": "16"
        },
        {
          "Name": "Inv Src1 Color",
          "Value": "17"
        },
        {
          "Name": "Src1 Alpha",
          "Value": "18"
        },
        {
          "Name": "Inv Src1 Alpha",
          "Value": "19"
        }
      ]
    },
    {
      "Name": "DestBlend",
      "MetaInstanceID": "0cbf38c6-d0c2-4c23-a8c3-1aa3a0376da8",
      "DefaultValue": {
        "Type": "Float",
        "Value": "6"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "1",
      "Max": "19",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": [
        {
          "Name": "Zero",
          "Value": "1"
        },
        {
          "Name": "One",
          "Value": "2"
        },
        {
          "Name": "Src Color",
          "Value": "3"
        },
        {
          "Name": "Inv Src Color",
          "Value": "4"
        },
        {
          "Name": "Src Alpha",
          "Value": "5"
        },
        {
          "Name": "Inv Src Alpha",
          "Value": "6"
        },
        {
          "Name": "Dest Alpha",
          "Value": "7"
        },
        {
          "Name": "Inv Dest Alpha",
          "Value": "8"
        },
        {
          "Name": "Dest Color",
          "Value": "9"
        },
        {
          "Name": "Inv Dest Color",
          "Value": "10"
        },
        {
          "Name": "Src Alpha Sat",
          "Value": "11"
        },
        {
          "Name": "Blend Factor",
          "Value": "14"
        },
        {
          "Name": "Inv Blend Factor",
          "Value": "15"
        },
        {
          "Name": "Src1 Color",
          "Value": "16"
        },
        {
          "Name": "Inv Src1 Color",
          "Value": "17"
        },
        {
          "Name": "Src1 Alpha",
          "Value": "18"
        },
        {
          "Name": "Inv Src1 Alpha",
          "Value": "19"
        }
      ]
    },
    {
      "Name": "BlendOp",
      "MetaInstanceID": "8a55b94d-cb79-457f-bf22-e6b3870abefa",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "1",
      "Max": "5",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": [
        {
          "Name": "Add",
          "Value": "1"
        },
        {
          "Name": "Subtract",
          "Value": "2"
        },
        {
          "Name": "Rev Subtract",
          "Value": "3"
        },
        {
          "Name": "Min",
          "Value": "4"
        },
        {
          "Name": "Max",
          "Value": "5"
        }
      ]
    },
    {
      "Name": "SrcBlendAlpha",
      "MetaInstanceID": "f86e07d8-8788-4576-99c0-be46c1340b05",
      "DefaultValue": {
        "Type": "Float",
        "Value": "5"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "1",
      "Max": "19",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": [
        {
          "Name": "Zero",
          "Value": "1"
        },
        {
          "Name": "One",
          "Value": "2"
        },
        {
          "Name": "Src Alpha",
          "Value": "5"
        },
        {
          "Name": "Inv Src Alpha",
          "Value": "6"
        },
        {
          "Name": "Dest Alpha",
          "Value": "7"
        },
        {
          "Name": "Inv Dest Alpha",
          "Value": "8"
        },
        {
          "Name": "Src Alpha Sat",
          "Value": "11"
        },
        {
          "Name": "Blend Factor",
          "Value": "14"
        },
        {
          "Name": "Inv Blend Factor",
          "Value": "15"
        },
        {
          "Name": "Src1 Alpha",
          "Value": "18"
        },
        {
          "Name": "Inv Src1 Alpha",
          "Value": "19"
        }
      ]
    },
    {
      "Name": "DestBlendAlpha",
      "MetaInstanceID": "b4c35183-d299-4009-808e-36c739acb5bb",
      "DefaultValue": {
        "Type": "Float",
        "Value": "7"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "1",
      "Max": "19",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": [
        {
          "Name": "Zero",
          "Value": "1"
        },
        {
          "Name": "One",
          "Value": "2"
        },
        {
          "Name": "Src Alpha",
          "Value": "5"
        },
        {
          "Name": "Inv Src Alpha",
          "Value": "6"
        },
        {
          "Name": "Dest Alpha",
          "Value": "7"
        },
        {
          "Name": "Inv Dest Alpha",
          "Value": "8"
        },
        {
          "Name": "Src Alpha Sat",
          "Value": "11"
        },
        {
          "Name": "Blend Factor",
          "Value": "14"
        },
        {
          "Name": "Inv Blend Factor",
          "Value": "15"
        },
        {
          "Name": "Src1 Alpha",
          "Value": "18"
        },
        {
          "Name": "Inv Src1 Alpha",
          "Value": "19"
        }
      ]
    },
    {
      "Name": "BlendOpAlpha",
      "MetaInstanceID": "d3a4486c-6af7-449e-b449-ac88b3cf6a7e",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "1",
      "Max": "5",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": [
        {
          "Name": "Add",
          "Value": "1"
        },
        {
          "Name": "Subtract",
          "Value": "2"
        },
        {
          "Name": "Rev Subtract",
          "Value": "3"
        },
        {
          "Name": "Min",
          "Value": "4"
        },
        {
          "Name": "Max",
          "Value": "5"
        }
      ]
    },
    {
      "Name": "RenderTargetWriteMask",
      "MetaInstanceID": "fb38d0b7-896f-4a94-a1d4-a48ec24c2c99",
      "DefaultValue": {
        "Type": "Float",
        "Value": "15"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "255",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "AlphaToCoverageEnable",
      "MetaInstanceID": "17dbcc19-40a2-4fb1-b25e-37959e1a9dd0",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": [
        {
          "Name": "Off",
          "Value": "0"
        },
        {
          "Name": "On",
          "Value": "1"
        }
      ]
    },
    {
      "Name": "BlendFactor.R",
      "MetaInstanceID": "7174c72f-23d3-4db3-92b8-0e637acba4a1",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "BlendFactor.G",
      "MetaInstanceID": "6239b46b-a748-426a-b2d6-81b513f49276",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "BlendFactor.B",
      "MetaInstanceID": "64c5f629-ca0d-4d80-92d8-e13a0964dd37",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "BlendFactor.A",
      "MetaInstanceID": "1c88fb44-b494-4da8-a710-f1681efcd46b",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    }
  ],
  "Outputs": [
    {
      "Name": "SceneTransformOut",
      "MetaInstanceID": "d4968c82-e03a-4801-b991-c78fbc84a091",
      "MetaID": "79122951-7bc4-4c68-b085-866eab828248"
    }
  ],
  "OperatorParts": [
    {
      "MetaInstanceID": "3e9a8b32-730f-4c5e-9707-27eb1551f732",
      "MetaID": "727de282-bae4-4a11-a180-bf3dcac63d15",
      "Name": "BlendStateFunc",
      "Version": "38ff47b4-499f-416a-8fc7-c4dc23279f84",
      "Type": "Scene",
      "IsMultiInput": "True",
      "Script": [
        "//>>> _using",
        "using System;",
        "using System.Collections.Generic;",
        "using System.Linq;",
        "using System.Text;",
        "using SharpDX;",
        "using SharpDX.Direct3D11;",
        "using SharpDX.Windows;",
        "//<<< _using",
        "",
        "",
        "namespace Framefield.Core.ID727de282_bae4_4a11_a180_bf3dcac63d15",
        "{",
        "    public class Class_BlendState : OperatorPart.Function",
        "    {",
        "        //>>> _inputids",
        "        private enum InputId",
        "        {",
        "            SceneInput = 0,",
        "            BlendEnabled = 1,",
        "            SrcBlend = 2,",
        "            DestBlend = 3,",
        "            BlendOp = 4,",
        "            SrcBlendAlpha = 5,",
        "            DestBlendAlpha = 6,",
        "            BlendOpAlpha = 7,",
        "            RenderTargetWriteMask = 8,",
        "            AlphaToCoverageEnable = 9,",
        "            BlendFactorR = 10,",
        "            BlendFactorG = 11,",
        "            BlendFactorB = 12,",
        "            BlendFactorA = 13",
        "        }",
        "        //<<< _inputids",
        "",
        "        public override void Dispose()",
        "        {",
        "            Utilities.DisposeObj(ref _blendState);",
        "            base.Dispose();",
        "        }",
        "",
        "        public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx)",
        "        {",
        "            //>>> _params",
        "            var SceneInput = inputs[(int)InputId.SceneInput];",
        "            var BlendEnabled = (int) inputs[(int)InputId.BlendEnabled].Eval(context).Value;",
        "            var SrcBlend = (int) inputs[(int)InputId.SrcBlend].Eval(context).Value;",
        "            var DestBlend = (int) inputs[(int)InputId.DestBlend].Eval(context).Value;",
        "            var BlendOp = (int) inputs[(int)InputId.BlendOp].Eval(context).Value;",
        "            var SrcBlendAlpha = (int) inputs[(int)InputId.SrcBlendAlpha].Eval(context).Value;",
        "            var DestBlendAlpha = (int) inputs[(int)InputId.DestBlendAlpha].Eval(context).Value;",
        "            var BlendOpAlpha = (int) inputs[(int)InputId.BlendOpAlpha].Eval(context).Value;",
        "            var RenderTargetWriteMask = inputs[(int)InputId.RenderTargetWriteMask].Eval(context).Value;",
        "            var AlphaToCoverageEnable = (int) inputs[(int)InputId.AlphaToCoverageEnable].Eval(context).Value;",
        "            var BlendFactorR = inputs[(int)InputId.BlendFactorR].Eval(context).Value;",
        "            var BlendFactorG = inputs[(int)InputId.BlendFactorG].Eval(context).Value;",
        "            var BlendFactorB = inputs[(int)InputId.BlendFactorB].Eval(context).Value;",
        "            var BlendFactorA = inputs[(int)InputId.BlendFactorA].Eval(context).Value;",
        "            var BlendFactor = new Color4(BlendFactorR, BlendFactorG, BlendFactorB, BlendFactorA);",
        "            //<<< _params",
        "",
        "            if (Changed)",
        "            {",
        "                var blendDescription = new BlendStateDescription();",
        "",
        "                blendDescription.RenderTarget[0].IsBlendEnabled = BlendEnabled > 0.5f ? true : false;",
        "                blendDescription.RenderTarget[0].SourceBlend = (BlendOption)SrcBlend;",
        "                blendDescription.RenderTarget[0].DestinationBlend = (BlendOption)DestBlend;",
        "                blendDescription.RenderTarget[0].BlendOperation = (BlendOperation)BlendOp;",
        "                blendDescription.RenderTarget[0].SourceAlphaBlend = (BlendOption)SrcBlendAlpha;",
        "                blendDescription.RenderTarget[0].DestinationAlphaBlend = (BlendOption)DestBlendAlpha;",
        "                blendDescription.RenderTarget[0].AlphaBlendOperation = (BlendOperation)BlendOpAlpha;",
        "                blendDescription.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;",
        "                //blendDescription.IsAlphaToCoverageEnabled = AlphaToCoverageEnable > 0.5f ? true : false;",
        "",
        "                Utilities.DisposeObj(ref _blendState);",
        "                _blendState = new BlendState(context.D3DDevice, blendDescription);",
        "                _blendFactor = BlendFactor;",
        "                Changed = false;",
        "            }",
        "",
        "            var prevBlendState = context.BlendState;",
        "            var prevBlendFactor = context.BlendFactor;",
        "            context.BlendState = _blendState;",
        "            context.BlendFactor = _blendFactor;",
        "",
        "            SceneInput.Eval(context);",
        "",
        "            context.BlendState = prevBlendState;",
        "            context.BlendFactor = prevBlendFactor;",
        "",
        "            return context;",
        "        }",
        "",
        "        private BlendState _blendState;",
        "        private Color4 _blendFactor;",
        "    }",
        "}",
        ""
      ],
      "AdditionalAssemblies": []
    }
  ],
  "Operators": [],
  "Connections": [
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "2a146001-0a5e-4636-8c74-4fc9151da7a9",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "2a94a9ca-b8b0-4c11-8073-d2999c925ec2",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "5c972ca3-966e-4a7c-96ae-55e936d8ce84",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "0cbf38c6-d0c2-4c23-a8c3-1aa3a0376da8",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "8a55b94d-cb79-457f-bf22-e6b3870abefa",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "f86e07d8-8788-4576-99c0-be46c1340b05",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "b4c35183-d299-4009-808e-36c739acb5bb",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "d3a4486c-6af7-449e-b449-ac88b3cf6a7e",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "fb38d0b7-896f-4a94-a1d4-a48ec24c2c99",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "17dbcc19-40a2-4fb1-b25e-37959e1a9dd0",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "7174c72f-23d3-4db3-92b8-0e637acba4a1",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "6239b46b-a748-426a-b2d6-81b513f49276",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "64c5f629-ca0d-4d80-92d8-e13a0964dd37",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "1c88fb44-b494-4da8-a710-f1681efcd46b",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "3e9a8b32-730f-4c5e-9707-27eb1551f732",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "d4968c82-e03a-4801-b991-c78fbc84a091"
    }
  ]
}