{
  "Name": "Resize",
  "_id": "cac42a38-0356-4917-aac2-d0c328904ad5",
  "Namespace": "lib.image.adjust",
  "Description": "Renders the input into a texture with the given size.",
  "Inputs": [
    {
      "Name": "Code",
      "MetaInstanceID": "5b8f828d-44aa-4491-a041-1ca1e557016f",
      "DefaultValue": {
        "Type": "Text",
        "Value": [
          "//>>> _common parameters\r",
          "float4x4 objectToWorldMatrix;",
          "float4x4 worldToCameraMatrix;",
          "float4x4 projMatrix;",
          "Texture2D txDiffuse;",
          "float2 RenderTargetSize;",
          "//<<< _common parameters\r",
          "\r",
          "//>>> _parameters\r",
          "Texture2D Image;",
          "float2 Size;",
          "//<<< _parameters\r",
          " \r",
          "//>>> _setup\r",
          "SamplerState samLinear",
          "{",
          "    Filter = MIN_MAG_MIP_LINEAR;",
          "    AddressU = Clamp;",
          "    AddressV = Clamp;",
          "};",
          "//<<< _setup\r",
          "\r",
          "//>>> _declarations\r",
          "struct VS_IN",
          "{",
          "    float4 pos : POSITION;",
          "    float2 texCoord : TEXCOORD;",
          "};",
          "",
          "struct PS_IN",
          "{",
          "    float4 pos : SV_POSITION;",
          "    float2 texCoord: TEXCOORD0;",
          "};",
          "//<<< _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",
          "    return Image.Sample(samLinear, input.texCoord);\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": "Image",
      "MetaInstanceID": "6f31653d-5066-4b97-81e2-6f7010a69ebc",
      "DefaultValue": {
        "Type": "Image",
        "Value": "Framefield.Core.Image"
      },
      "MetaID": "9848060d-fd84-45b0-b658-d0d531c61dab",
      "IsMultiInput": "False",
      "Relevance": "Required",
      "Description": "",
      "Min": "-100000",
      "Max": "100000",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "Size.X",
      "MetaInstanceID": "09b4ff2b-7297-4e0d-9be6-55b4ed9c8e88",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "10000",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "Size.Y",
      "MetaInstanceID": "08b3b348-ce14-4e3d-bd91-6529ca6d1af2",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "10000",
      "Scale": "1",
      "ScaleType": "Linear",
      "EnumValues": []
    }
  ],
  "Outputs": [
    {
      "Name": "Image",
      "MetaInstanceID": "b9c6b769-1226-48e9-891e-9532acd4fb76",
      "MetaID": "9848060d-fd84-45b0-b658-d0d531c61dab"
    }
  ],
  "OperatorParts": [
    {
      "MetaInstanceID": "7fd93b8b-5215-4290-ae1f-8784ecf74fe9",
      "MetaID": "7bfdcda2-71b4-4d98-a970-9feb9f11925c",
      "Name": "ResizeFunc",
      "Version": "a0c1ff07-07d1-475f-98d5-f916113b756e",
      "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.ID7bfdcda2_71b4_4d98_a970_9feb9f11925c",
        "{",
        "    public class Class_Resize : FXImageFunction",
        "    {",
        "        //>>> _inputids",
        "        private enum InputId",
        "        {",
        "            Code = 0,",
        "            Image = 1,",
        "            SizeX = 2,",
        "            SizeY = 3",
        "        }",
        "        //<<< _inputids",
        "",
        "        public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx)",
        "        {",
        "            //>>> _params",
        "            var Code = inputs[(int)InputId.Code].Eval(context).Text;",
        "            var Image = inputs[(int)InputId.Image].Eval(context).Image; // Needs to be checked for null!",
        "            var SizeX = inputs[(int)InputId.SizeX].Eval(context).Value;",
        "            var SizeY = inputs[(int)InputId.SizeY].Eval(context).Value;",
        "            var Size = new Vector2(SizeX, SizeY);",
        "            //<<< _params",
        "",
        "            using (new PropertyStasher<OperatorPartContext>(context, \"Viewport\")) ",
        "            {",
        "                context.Viewport = new ViewportF(0, 0, SizeX, SizeY);",
        "    ",
        "                return PrepareAndEvalOnChange(context, () =>",
        "                {",
        "                    ClearRenderTarget(context, new Color4(0, 0, 0, 0));",
        "    ",
        "                    //>>> _setup",
        "                    using (var ImageView = new ShaderResourceView(context.D3DDevice, Image))",
        "                    {",
        "                        _effect.GetVariableByName(\"RenderTargetSize\").AsVector().Set(new Vector2(_usedViewport.Width, _usedViewport.Height));",
        "                        _effect.GetVariableByName(\"Image\").AsShaderResource().SetResource(ImageView);",
        "                        _effect.GetVariableByName(\"Size\").AsVector().Set(new Vector2(SizeX, SizeY));",
        "                        //<<< _setup",
        "    ",
        "                        Render(context);",
        "",
        "                    //>>> _cleanup",
        "                    }",
        "                    //<<< _cleanup",
        "                });",
        "            }",
        "        }",
        "    }",
        "}",
        "",
        ""
      ],
      "AdditionalAssemblies": []
    }
  ],
  "Operators": [],
  "Connections": [
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "7fd93b8b-5215-4290-ae1f-8784ecf74fe9",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "b9c6b769-1226-48e9-891e-9532acd4fb76"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "5b8f828d-44aa-4491-a041-1ca1e557016f",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "7fd93b8b-5215-4290-ae1f-8784ecf74fe9"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "6f31653d-5066-4b97-81e2-6f7010a69ebc",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "7fd93b8b-5215-4290-ae1f-8784ecf74fe9"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "09b4ff2b-7297-4e0d-9be6-55b4ed9c8e88",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "7fd93b8b-5215-4290-ae1f-8784ecf74fe9"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "08b3b348-ce14-4e3d-bd91-6529ca6d1af2",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "7fd93b8b-5215-4290-ae1f-8784ecf74fe9"
    }
  ]
}