more shaders and updates/changes
This commit is contained in:
@@ -47,6 +47,35 @@
|
||||
"step": 0.1,
|
||||
"description": "Rotates the source image around the frame center."
|
||||
},
|
||||
{
|
||||
"id": "cropAspect",
|
||||
"label": "Crop Aspect",
|
||||
"type": "enum",
|
||||
"default": "none",
|
||||
"options": [
|
||||
{
|
||||
"value": "none",
|
||||
"label": "None"
|
||||
},
|
||||
{
|
||||
"value": "4x3",
|
||||
"label": "4:3"
|
||||
},
|
||||
{
|
||||
"value": "3x2",
|
||||
"label": "3:2"
|
||||
},
|
||||
{
|
||||
"value": "1x1",
|
||||
"label": "1:1"
|
||||
},
|
||||
{
|
||||
"value": "9x16",
|
||||
"label": "9:16"
|
||||
}
|
||||
],
|
||||
"description": "Crops the visible image to a centered preset aspect ratio without squeezing the source."
|
||||
},
|
||||
{
|
||||
"id": "edgeMode",
|
||||
"label": "Edge Mode",
|
||||
|
||||
@@ -28,8 +28,42 @@ float2 applyEdgeMode(float2 uv, out bool inside)
|
||||
return uv;
|
||||
}
|
||||
|
||||
float selectedCropAspect()
|
||||
{
|
||||
if (cropAspect == 1)
|
||||
return 4.0 / 3.0;
|
||||
if (cropAspect == 2)
|
||||
return 3.0 / 2.0;
|
||||
if (cropAspect == 3)
|
||||
return 1.0;
|
||||
if (cropAspect == 4)
|
||||
return 9.0 / 16.0;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool insideCropWindow(float2 uv, float2 resolution)
|
||||
{
|
||||
float targetAspect = selectedCropAspect();
|
||||
if (targetAspect <= 0.0)
|
||||
return true;
|
||||
|
||||
float outputAspect = resolution.x / max(resolution.y, 1.0);
|
||||
float2 cropSize = float2(1.0, 1.0);
|
||||
if (outputAspect > targetAspect)
|
||||
cropSize.x = targetAspect / outputAspect;
|
||||
else
|
||||
cropSize.y = outputAspect / targetAspect;
|
||||
|
||||
float2 cropMin = (1.0 - cropSize) * 0.5;
|
||||
float2 cropMax = cropMin + cropSize;
|
||||
return uv.x >= cropMin.x && uv.x <= cropMax.x && uv.y >= cropMin.y && uv.y <= cropMax.y;
|
||||
}
|
||||
|
||||
float4 shadeVideo(ShaderContext context)
|
||||
{
|
||||
if (!insideCropWindow(context.uv, max(context.outputResolution, float2(1.0, 1.0))))
|
||||
return outsideColor;
|
||||
|
||||
float safeZoom = max(zoom, 0.001);
|
||||
float2 sourceUv = (context.uv - 0.5) / safeZoom + 0.5;
|
||||
sourceUv -= pan;
|
||||
|
||||
Reference in New Issue
Block a user