{
  "Name": "BlendImagesMultiply",
  "_id": "466a8528-9871-4cdf-b635-db6bbcf6b725",
  "Namespace": "lib.image.adjust",
  "Description": "",
  "Inputs": [
    {
      "Name": "Code",
      "MetaInstanceID": "34aadb03-69e0-4246-b671-8f2841a6b7d7",
      "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",
          "    a= clamp(a,0,1);\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": "06681534-fb08-4da8-937b-096a783da201",
      "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": "e8321acc-fcab-4d06-8dbd-90d5b32a092e",
      "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": "06518ee9-aebb-4580-b4c2-77056c5f13b2",
      "MetaID": "9848060d-fd84-45b0-b658-d0d531c61dab"
    }
  ],
  "OperatorParts": [
    {
      "MetaInstanceID": "48294f59-e8bb-4da2-a392-262f8fb314b5",
      "MetaID": "65057efe-1c9b-436b-816b-427eaa2c40a3",
      "Name": "BlendImagesMultiplyFunc",
      "Version": "cf320726-55e5-4a87-8ed0-823212db0900",
      "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.ID65057efe_1c9b_436b_816b_427eaa2c40a3",
        "{",
        "    public class Class_BlendImagesMultiply : 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; if (Image1 == null) return;",
        "                var Image2 = inputs[(int)InputId.Image2].Eval(context).Image; if (Image2 == null) return;",
        "                //<<< __params",
        "",
        "                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",
        "",
        "                Render(context);",
        "",
        "                //>>> _cleanup",
        "                }",
        "                //<<< _cleanup",
        "            });",
        "        }",
        "",
        "    }",
        "}",
        "",
        ""
      ],
      "AdditionalAssemblies": []
    }
  ],
  "Operators": [],
  "Connections": [
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "48294f59-e8bb-4da2-a392-262f8fb314b5",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "06518ee9-aebb-4580-b4c2-77056c5f13b2"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "34aadb03-69e0-4246-b671-8f2841a6b7d7",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "48294f59-e8bb-4da2-a392-262f8fb314b5"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "06681534-fb08-4da8-937b-096a783da201",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "48294f59-e8bb-4da2-a392-262f8fb314b5"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "e8321acc-fcab-4d06-8dbd-90d5b32a092e",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "48294f59-e8bb-4da2-a392-262f8fb314b5"
    }
  ]
}