{
  "Name": "RGBANoise",
  "_id": "3b4733a5-c5a3-4f11-9543-3907437f2ae1",
  "Namespace": "lib.image.generate",
  "Description": "Returns an image buffer with noise. Use [SetResolution] above to adjust the default size of the current render-target.",
  "Inputs": [
    {
      "Name": "Code",
      "MetaInstanceID": "cf8f90e2-0f2e-4a99-b4be-37153fd76471",
      "DefaultValue": {
        "Type": "Text",
        "Value": [
          "//>>> _common parameters\r",
          "float4x4 objectToWorldMatrix;",
          "float4x4 worldToCameraMatrix;",
          "float4x4 projMatrix;",
          "Texture2D txDiffuse;",
          "float2 RenderTargetSize;",
          "//<<< _common parameters\r",
          "\r",
          "//>>> _parameters\r",
          "float4 MinColor;",
          "float4 MaxColor;",
          "float Seed;",
          "float Saturation;",
          "//<<< _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",
          "\r",
          "// Calculate noise between 0 .. 1\r",
          "float noise( float x) \r",
          "{   \r",
          "    x = fmod(x,1234);\r",
          "    int n = (int)x + (int)Seed*137;\r",
          "       \r",
          "    n = (n << 13) ^ n;    \r",
          "    return abs(1.0f - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0f);\r",
          "}\r",
          "\r",
          "float4 PS(PS_IN input) : SV_Target\r",
          "{\r",
          "    float aspectRatio = RenderTargetSize.x/RenderTargetSize.y;\r",
          "    float cr= noise( fmod(input.pos.x * 10.0012 *( fmod(Seed,1.63)+101),1234) * (input.pos.y +  (Seed+0.23)));\r",
          "    float cg= noise( fmod(input.pos.x * 14.0012 *( fmod(Seed,2.23)+121),1234) * (input.pos.y +  (Seed+0.13)));\r",
          "    float cb= noise( fmod(input.pos.x * 12.0312 *( fmod(Seed,3.23)+131),1234) * (input.pos.y +  (Seed+0.15)));\r",
          "    float ca= noise( fmod(input.pos.x * 13.0312 *( fmod(Seed,4.23)+141),1234) * (input.pos.y +  (Seed+0.17)));\r",
          "    \r",
          "    float gray = (cr+cg+cb)/3;\r",
          "    float4 col = lerp(float4(gray,gray,gray,ca), float4(cr,cg,cb,ca), Saturation);\r",
          "    \r",
          "    return col * (MaxColor-MinColor)+MinColor;\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": "MinColor.R",
      "MetaInstanceID": "7da91bf7-03eb-4243-97f8-bd5a41f1dbf5",
      "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": "MinColor.G",
      "MetaInstanceID": "522c7185-c00f-4932-be40-28fe856cfec6",
      "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": "MinColor.B",
      "MetaInstanceID": "ef840e45-8e09-4d07-9b79-e6f2c93ad0c7",
      "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": "MinColor.A",
      "MetaInstanceID": "22761b9d-34ef-4e07-824a-af458f53ce90",
      "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": "MaxColor.R",
      "MetaInstanceID": "ff8fa7b2-0fbd-41f4-9e4d-4e9c66cdc84c",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "MaxColor.G",
      "MetaInstanceID": "b30c3066-f9b1-4bf1-a81d-304ae2e48069",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "MaxColor.B",
      "MetaInstanceID": "6b40e98a-b1e7-462a-b97d-bcfa882c4259",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "MaxColor.A",
      "MetaInstanceID": "3c24c919-5847-4fad-8e61-c32e954eea5c",
      "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": "Seed",
      "MetaInstanceID": "eca1ed7a-8e61-450f-9c50-bfb903e049d0",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "-100000",
      "Max": "100000",
      "Scale": "0.1",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "Saturation",
      "MetaInstanceID": "cbcb92c6-c368-4da5-a70e-083d93944602",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "10",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    }
  ],
  "Outputs": [
    {
      "Name": "Image",
      "MetaInstanceID": "bd379000-8281-498d-bd2d-8af4cb3bd5c9",
      "MetaID": "9848060d-fd84-45b0-b658-d0d531c61dab"
    }
  ],
  "OperatorParts": [
    {
      "MetaInstanceID": "afbe50da-3db7-4f79-8c05-f1feb8088472",
      "MetaID": "e13cdf8d-b13c-4c61-8c11-72779d80b8ae",
      "Name": "RGBANoiseFunc",
      "Version": "a7798253-24ef-4da0-82f0-a50aeab81baa",
      "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.IDe13cdf8d_b13c_4c61_8c11_72779d80b8ae",
        "{",
        "    public class Class_RGBANoise : FXImageFunction",
        "    {",
        "        //>>> _inputids",
        "        private enum InputId",
        "        {",
        "            Code = 0,",
        "            MinColorR = 1,",
        "            MinColorG = 2,",
        "            MinColorB = 3,",
        "            MinColorA = 4,",
        "            MaxColorR = 5,",
        "            MaxColorG = 6,",
        "            MaxColorB = 7,",
        "            MaxColorA = 8,",
        "            Seed = 9,",
        "            Saturation = 10",
        "        }",
        "        //<<< _inputids",
        "",
        "        public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx) {",
        "            //>>> _params",
        "            var Code = inputs[(int)InputId.Code].Eval(context).Text;",
        "            var MinColorR = inputs[(int)InputId.MinColorR].Eval(context).Value;",
        "            var MinColorG = inputs[(int)InputId.MinColorG].Eval(context).Value;",
        "            var MinColorB = inputs[(int)InputId.MinColorB].Eval(context).Value;",
        "            var MinColorA = inputs[(int)InputId.MinColorA].Eval(context).Value;",
        "            var MinColor = new Color4(MinColorR, MinColorG, MinColorB, MinColorA);",
        "            var MaxColorR = inputs[(int)InputId.MaxColorR].Eval(context).Value;",
        "            var MaxColorG = inputs[(int)InputId.MaxColorG].Eval(context).Value;",
        "            var MaxColorB = inputs[(int)InputId.MaxColorB].Eval(context).Value;",
        "            var MaxColorA = inputs[(int)InputId.MaxColorA].Eval(context).Value;",
        "            var MaxColor = new Color4(MaxColorR, MaxColorG, MaxColorB, MaxColorA);",
        "            var Seed = inputs[(int)InputId.Seed].Eval(context).Value;",
        "            var Saturation = inputs[(int)InputId.Saturation].Eval(context).Value;",
        "            //<<< _params",
        "",
        "            return PrepareAndEvalOnChange(context, () => {",
        "                ClearRenderTarget(context, new SharpDX.Color4(0, 0, 0, 0));",
        "",
        "",
        "                Seed %= 321; // Prevent artifacts for big seed values",
        "                //>>> _setup",
        "                {",
        "                    _effect.GetVariableByName(\"RenderTargetSize\").AsVector().Set(new Vector2(_usedViewport.Width, _usedViewport.Height));",
        "                    _effect.GetVariableByName(\"MinColor\").AsVector().Set(new Vector4(MinColorR, MinColorG, MinColorB, MinColorA));",
        "                    _effect.GetVariableByName(\"MaxColor\").AsVector().Set(new Vector4(MaxColorR, MaxColorG, MaxColorB, MaxColorA));",
        "                    _effect.GetVariableByName(\"Seed\").AsScalar().Set(Seed);",
        "                    _effect.GetVariableByName(\"Saturation\").AsScalar().Set(Saturation);",
        "                //<<< _setup",
        "",
        "                Render(context);",
        "",
        "                //>>> _cleanup",
        "                }",
        "                //<<< _cleanup",
        "            });",
        "        }",
        "",
        "    }",
        "}",
        "",
        "",
        "",
        ""
      ],
      "AdditionalAssemblies": []
    }
  ],
  "Operators": [],
  "Connections": [
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "bd379000-8281-498d-bd2d-8af4cb3bd5c9"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "cf8f90e2-0f2e-4a99-b4be-37153fd76471",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "7da91bf7-03eb-4243-97f8-bd5a41f1dbf5",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "522c7185-c00f-4932-be40-28fe856cfec6",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "ef840e45-8e09-4d07-9b79-e6f2c93ad0c7",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "22761b9d-34ef-4e07-824a-af458f53ce90",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "ff8fa7b2-0fbd-41f4-9e4d-4e9c66cdc84c",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "b30c3066-f9b1-4bf1-a81d-304ae2e48069",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "6b40e98a-b1e7-462a-b97d-bcfa882c4259",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "3c24c919-5847-4fad-8e61-c32e954eea5c",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "eca1ed7a-8e61-450f-9c50-bfb903e049d0",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "cbcb92c6-c368-4da5-a70e-083d93944602",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "afbe50da-3db7-4f79-8c05-f1feb8088472"
    }
  ]
}