osc multi arguments
Some checks failed
CI / Native Windows Build And Tests (push) Failing after 7s
CI / React UI Build (push) Has been cancelled
CI / Windows Release Package (push) Has been cancelled

This commit is contained in:
2026-05-03 14:51:57 +10:00
parent 7dc4b552a5
commit 0560ea3c49
8 changed files with 436 additions and 48 deletions

View File

@@ -0,0 +1,54 @@
{
"id": "video-transform",
"name": "Video Transform",
"description": "Zooms, pans, and rotates the video by remapping output pixels back into source UV space.",
"category": "Utility",
"entryPoint": "shadeVideo",
"parameters": [
{
"id": "zoom",
"label": "Zoom",
"type": "float",
"default": 1.0,
"min": 0.1,
"max": 8.0,
"step": 0.01
},
{
"id": "pan",
"label": "Pan",
"type": "vec2",
"default": [0.0, 0.0],
"min": [-1.0, -1.0],
"max": [1.0, 1.0],
"step": [0.001, 0.001]
},
{
"id": "rotationDegrees",
"label": "Rotation",
"type": "float",
"default": 0.0,
"min": -180.0,
"max": 180.0,
"step": 0.1
},
{
"id": "edgeMode",
"label": "Edge Mode",
"type": "enum",
"default": "black",
"options": [
{ "value": "black", "label": "Black" },
{ "value": "clamp", "label": "Clamp" },
{ "value": "wrap", "label": "Wrap" },
{ "value": "mirror", "label": "Mirror" }
]
},
{
"id": "outsideColor",
"label": "Outside Color",
"type": "color",
"default": [0.0, 0.0, 0.0, 1.0]
}
]
}

View File

@@ -0,0 +1,44 @@
static const float PI = 3.14159265358979323846;
float2 rotateAroundCenter(float2 uv, float radians)
{
float2 centered = uv - 0.5;
float s = sin(radians);
float c = cos(radians);
return float2(c * centered.x - s * centered.y, s * centered.x + c * centered.y) + 0.5;
}
float mirroredCoordinate(float coordinate)
{
float wrapped = frac(coordinate * 0.5) * 2.0;
return wrapped <= 1.0 ? wrapped : 2.0 - wrapped;
}
float2 applyEdgeMode(float2 uv, out bool inside)
{
inside = uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0;
if (edgeMode == 1)
return clamp(uv, 0.0, 1.0);
if (edgeMode == 2)
return frac(uv);
if (edgeMode == 3)
return float2(mirroredCoordinate(uv.x), mirroredCoordinate(uv.y));
return uv;
}
float4 shadeVideo(ShaderContext context)
{
float safeZoom = max(zoom, 0.001);
float2 sourceUv = (context.uv - 0.5) / safeZoom + 0.5;
sourceUv -= pan;
sourceUv = rotateAroundCenter(sourceUv, -rotationDegrees * (PI / 180.0));
bool inside = false;
float2 sampledUv = applyEdgeMode(sourceUv, inside);
if (!inside && edgeMode == 0)
return outsideColor;
return sampleVideo(sampledUv);
}