{
  "Name": "BlendImagesAdd",
  "_id": "65ef8dd3-1075-4e0e-b83f-8e083e027099",
  "Namespace": "lib.image.adjust",
  "Description": "",
  "Inputs": [
    {
      "Name": "Code",
      "MetaInstanceID": "35d31711-3711-4174-9fee-20cdfadb1276",
      "DefaultValue": {
        "Type": "Text",
        "Value": [
          "//>>> _common parameters\r",
          "float4x4 objectToWorldMatrix;",
          "float4x4 worldToCameraMatrix;",
          "float4x4 projMatrix;",
          "Texture2D txDiffuse;",
          "float2 RenderTargetSize;",
          "//<<< _common parameters\r",
          "\r",
          "//>>> _parameters\r",
          "Texture2D Image1;",
          "Texture2D Image2;",
          "//<<< _parameters\r",
          "float4x4 ViewToWorld;\r",
          " \r",
          "//>>> setup\r",
          "SamplerState samNearest\r",
          "{\r",
          "    Filter = MIN_MAG_MIP_POINT;\r",
          "    AddressU = Clamp;\r",
          "    AddressV = Clamp;\r",
          "};\r",
          "//<<< setup\r",
          "\r",
          "//>>> declarations\r",
          "struct VS_IN\r",
          "{\r",
          "    float4 pos : POSITION;\r",
          "    float2 texCoord : TEXCOORD;\r",
          "};\r",
          "\r",
          "struct PS_IN\r",
          "{\r",
          "    float4 pos : SV_POSITION;\r",
          "    float2 texCoord: TEXCOORD0;\t    \r",
          "    float3 worldTViewPos: TEXCOORD1;\r",
          "    float3 worldTViewDir: TEXCOORD2;\r",
          "};\r",
          "//<<< declarations\r",
          "\r",
          "//>>> _GS\r",
          "",
          "//<<< _GS\r",
          "\r",
          "//>>> _VS \r",
          "PS_IN VS( VS_IN input )",
          "{",
          "    PS_IN output = (PS_IN)0;",
          "",
          "    output.pos = mul(input.pos, worldToCameraMatrix);",
          "    output.pos = mul(output.pos, projMatrix);",
          "    output.texCoord = input.texCoord;",
          "",
          "    return output;",
          "}",
          "//<<< _VS\r",
          "\r",
          "//>>> PS\r",
          "float4 PS( PS_IN input ) : SV_Target\r",
          "{\r",
          "    float4 t0=Image1.Sample(samNearest, input.texCoord); \r",
          "    float4 t1=Image2.Sample(samNearest, input.texCoord);    \r",
          "\r",
          "    float a = t0.a + t1.a - t0.a * t1.a;\r",
          "    float3 rgb=  t0.rgb + t1.a * t1.rgb;   \r",
          "    return float4(rgb,1);\r",
          "    //return col1+col2;\r",
          "    \r",
          "}\r",
          "//<<< PS\r",
          "\r",
          "//>>> _technique\r",
          "technique10 Render",
          "{",
          "    pass P0",
          "    {",
          "        SetGeometryShader( 0 );",
          "        SetVertexShader( CompileShader( vs_4_0, VS() ) );",
          "        SetPixelShader( CompileShader( ps_4_0, PS() ) );",
          "    }",
          "}",
          "//<<< _technique\r",
          ""
        ]
      },
      "MetaID": "c522a66e-3260-4692-b3e3-79fd0361fa3d",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "-100000",
      "Max": "100000",
      "Scale": "0.1",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "Image1",
      "MetaInstanceID": "155e09d4-8fa1-4ea7-b7b6-dd3810328f4c",
      "DefaultValue": {
        "Type": "Image",
        "Value": "Framefield.Core.Image"
      },
      "MetaID": "9848060d-fd84-45b0-b658-d0d531c61dab",
      "IsMultiInput": "False",
      "Relevance": "Required",
      "Description": "",
      "Min": "-100000",
      "Max": "100000",
      "Scale": "0.1",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "Image2",
      "MetaInstanceID": "3b4927be-6a67-4872-aeb7-b1dee2136f29",
      "DefaultValue": {
        "Type": "Image",
        "Value": "Framefield.Core.Image"
      },
      "MetaID": "9848060d-fd84-45b0-b658-d0d531c61dab",
      "IsMultiInput": "False",
      "Relevance": "Required",
      "Description": "",
      "Min": "-100000",
      "Max": "100000",
      "Scale": "0.1",
      "ScaleType": "Linear",
      "EnumValues": []
    }
  ],
  "Outputs": [
    {
      "Name": "Image",
      "MetaInstanceID": "93b119c0-4467-428d-91be-32ebdeed0a07",
      "MetaID": "9848060d-fd84-45b0-b658-d0d531c61dab"
    }
  ],
  "OperatorParts": [
    {
      "MetaInstanceID": "2d9b7f7f-0512-42c7-bc22-bf4d96bf17db",
      "MetaID": "90b83442-e7fd-4eeb-9275-be80a1b7f421",
      "Name": "BlendImagesAddFunc",
      "Version": "33559b5d-41b6-45eb-b9a4-63685dce8912",
      "Type": "Float",
      "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.ID90b83442_e7fd_4eeb_9275_be80a1b7f421",
        "{",
        "    public class Class_BlendImagesAdd : FXImageFunction",
        "    {",
        "        //>>> _inputids",
        "        private enum InputId",
        "        {",
        "            Code = 0,",
        "            Image1 = 1,",
        "            Image2 = 2",
        "        }",
        "        //<<< _inputids",
        "",
        "        public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx)",
        "        {",
        "            return PrepareAndEvalOnChange(context, () =>",
        "            {",
        "                //>>> __params",
        "                var Code = inputs[(int)InputId.Code].Eval(context).Text;",
        "                var Image1 = inputs[(int)InputId.Image1].Eval(context).Image; ",
        "                var Image2 = inputs[(int)InputId.Image2].Eval(context).Image; ",
        "                //<<< __params",
        "                ",
        "                if (Image1 == null || Image2 == null) {",
        "                    return;",
        "                }",
        "",
        "                ClearRenderTarget(context, new SharpDX.Color4(0, 0, 0, 0));",
        "",
        "                //>>> _setup",
        "                using (var Image1View = new ShaderResourceView(context.D3DDevice, Image1))",
        "                using (var Image2View = new ShaderResourceView(context.D3DDevice, Image2))",
        "                {",
        "                    _effect.GetVariableByName(\"RenderTargetSize\").AsVector().Set(new Vector2(_usedViewport.Width, _usedViewport.Height));",
        "                    _effect.GetVariableByName(\"Image1\").AsShaderResource().SetResource(Image1View);",
        "                    _effect.GetVariableByName(\"Image2\").AsShaderResource().SetResource(Image2View);",
        "                //<<< _setup",
        "",
        "                var prevBlendState = context.BlendState;",
        "                context.BlendState = OperatorPartContext.DefaultRenderer.DisabledBlendState;",
        "                Render(context);",
        "                context.BlendState = prevBlendState;",
        "",
        "                //>>> _cleanup",
        "                }",
        "                //<<< _cleanup",
        "            });",
        "        }",
        "",
        "    }",
        "}",
        "",
        ""
      ],
      "AdditionalAssemblies": []
    }
  ],
  "Operators": [],
  "Connections": [
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "2d9b7f7f-0512-42c7-bc22-bf4d96bf17db",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "93b119c0-4467-428d-91be-32ebdeed0a07"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "35d31711-3711-4174-9fee-20cdfadb1276",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "2d9b7f7f-0512-42c7-bc22-bf4d96bf17db"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "155e09d4-8fa1-4ea7-b7b6-dd3810328f4c",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "2d9b7f7f-0512-42c7-bc22-bf4d96bf17db"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "3b4927be-6a67-4872-aeb7-b1dee2136f29",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "2d9b7f7f-0512-42c7-bc22-bf4d96bf17db"
    }
  ]
}