{
  "id": "greenscreen-key",
  "name": "Greenscreen Key",
  "description": "Production-style green/blue screen keyer with matte refinement, despill, edge treatment, and debug views.",
  "category": "Keying",
  "entryPoint": "shadeVideo",
  "passes": [
    {
      "id": "rawMatte",
      "source": "shader.slang",
      "entryPoint": "buildRawMatte",
      "inputs": [
        "layerInput"
      ],
      "output": "rawMatte"
    },
    {
      "id": "refinedMatte",
      "source": "shader.slang",
      "entryPoint": "refineMatte",
      "inputs": [
        "rawMatte"
      ],
      "output": "refinedMatte"
    },
    {
      "id": "final",
      "source": "shader.slang",
      "entryPoint": "applyKey",
      "inputs": [
        "refinedMatte"
      ],
      "output": "layerOutput"
    }
  ],
  "parameters": [
    {
      "id": "screenColor",
      "label": "Screen Color",
      "type": "color",
      "default": [
        0.15,
        0.85,
        0.2,
        1
      ],
      "min": [
        0,
        0,
        0,
        0
      ],
      "max": [
        1,
        1,
        1,
        1
      ],
      "step": [
        0.01,
        0.01,
        0.01,
        0.01
      ],
      "description": "Target screen color to remove; use green or blue depending on the backdrop."
    },
    {
      "id": "threshold",
      "label": "Screen Gain",
      "type": "float",
      "default": 0.24,
      "min": 0.01,
      "max": 0.8,
      "step": 0.005,
      "description": "Higher values keep more foreground; lower values remove more screen."
    },
    {
      "id": "softness",
      "label": "Softness",
      "type": "float",
      "default": 0.16,
      "min": 0.001,
      "max": 0.5,
      "step": 0.005,
      "description": "Feathers the transition between foreground and keyed screen."
    },
    {
      "id": "screenBalance",
      "label": "Screen Balance",
      "type": "float",
      "default": 0.5,
      "min": 0,
      "max": 1,
      "step": 0.005,
      "description": "Balances chroma-distance keying against color-direction keying."
    },
    {
      "id": "screenPreBlur",
      "label": "Screen PreBlur",
      "type": "float",
      "default": 1,
      "min": 0,
      "max": 8,
      "step": 0.1,
      "description": "Blurs source color before matte generation to reduce noisy edges."
    },
    {
      "id": "erodeDilate",
      "label": "Erode/Dilate",
      "type": "float",
      "default": 0,
      "min": -0.3,
      "max": 0.3,
      "step": 0.005,
      "description": "Negative erodes the matte; positive expands it."
    },
    {
      "id": "matteBlur",
      "label": "Matte Blur",
      "type": "float",
      "default": 1.25,
      "min": 0,
      "max": 6,
      "step": 0.1,
      "description": "Softens the generated matte after keying."
    },
    {
      "id": "matteGamma",
      "label": "Matte Gamma",
      "type": "float",
      "default": 1,
      "min": 0.25,
      "max": 4,
      "step": 0.01,
      "description": "Shapes midtone opacity in the matte."
    },
    {
      "id": "matteContrast",
      "label": "Matte Contrast",
      "type": "float",
      "default": 1,
      "min": 0.25,
      "max": 4,
      "step": 0.01,
      "description": "Increases or reduces matte separation around 50 percent alpha."
    },
    {
      "id": "blackCleanup",
      "label": "Black Cleanup",
      "type": "float",
      "default": 0,
      "min": 0,
      "max": 1,
      "step": 0.005,
      "description": "Pushes semi-transparent dark matte areas toward transparent."
    },
    {
      "id": "whiteCleanup",
      "label": "White Cleanup",
      "type": "float",
      "default": 0,
      "min": 0,
      "max": 1,
      "step": 0.005,
      "description": "Pushes semi-transparent light matte areas toward opaque."
    },
    {
      "id": "despill",
      "label": "Despill",
      "type": "float",
      "default": 0.45,
      "min": 0,
      "max": 1.5,
      "step": 0.01,
      "description": "Removes screen-colored contamination from foreground edges."
    },
    {
      "id": "despillBias",
      "label": "Despill Bias",
      "type": "float",
      "default": 0,
      "min": -0.5,
      "max": 0.5,
      "step": 0.005,
      "description": "Offsets spill detection when foreground colors are close to the screen color."
    },
    {
      "id": "spillTint",
      "label": "Spill Tint",
      "type": "color",
      "default": [
        1,
        1,
        1,
        1
      ],
      "min": [
        0,
        0,
        0,
        0
      ],
      "max": [
        1,
        1,
        1,
        1
      ],
      "step": [
        0.01,
        0.01,
        0.01,
        0.01
      ],
      "description": "Tint used when neutralizing spill."
    },
    {
      "id": "edgeRecover",
      "label": "Edge Recover",
      "type": "float",
      "default": 0.18,
      "min": 0,
      "max": 1,
      "step": 0.005,
      "description": "Adds color recovery along semi-transparent matte edges."
    },
    {
      "id": "edgeColor",
      "label": "Edge Color",
      "type": "color",
      "default": [
        1,
        1,
        1,
        1
      ],
      "min": [
        0,
        0,
        0,
        0
      ],
      "max": [
        1,
        1,
        1,
        1
      ],
      "step": [
        0.01,
        0.01,
        0.01,
        0.01
      ],
      "description": "Tint applied to recovered edge detail."
    },
    {
      "id": "clipBlack",
      "label": "Clip Black",
      "type": "float",
      "default": 0,
      "min": 0,
      "max": 0.5,
      "step": 0.005,
      "description": "Matte values below this become transparent."
    },
    {
      "id": "clipWhite",
      "label": "Clip White",
      "type": "float",
      "default": 1,
      "min": 0.5,
      "max": 1,
      "step": 0.005,
      "description": "Matte values above this become opaque."
    },
    {
      "id": "cropLeft",
      "label": "Crop Left",
      "description": "Trims the final matte from the left edge as a fraction of frame width.",
      "type": "float",
      "default": 0,
      "min": 0,
      "max": 0.5,
      "step": 0.001
    },
    {
      "id": "cropRight",
      "label": "Crop Right",
      "description": "Trims the final matte from the right edge as a fraction of frame width.",
      "type": "float",
      "default": 0,
      "min": 0,
      "max": 0.5,
      "step": 0.001
    },
    {
      "id": "cropTop",
      "label": "Crop Top",
      "description": "Trims the final matte from the top edge as a fraction of frame height.",
      "type": "float",
      "default": 0,
      "min": 0,
      "max": 0.5,
      "step": 0.001
    },
    {
      "id": "cropBottom",
      "label": "Crop Bottom",
      "description": "Trims the final matte from the bottom edge as a fraction of frame height.",
      "type": "float",
      "default": 0,
      "min": 0,
      "max": 0.5,
      "step": 0.001
    },
    {
      "id": "viewMode",
      "label": "View",
      "type": "enum",
      "default": "composite",
      "options": [
        {
          "value": "composite",
          "label": "Composite"
        },
        {
          "value": "matte",
          "label": "Matte"
        },
        {
          "value": "spill",
          "label": "Spill"
        },
        {
          "value": "despill",
          "label": "Despill"
        },
        {
          "value": "status",
          "label": "Status"
        }
      ],
      "description": "Debug output mode for inspecting matte, spill, and despill stages."
    }
  ]
}
