data storage
This commit is contained in:
@@ -59,6 +59,26 @@
|
||||
],
|
||||
"description": "Normalized fisheye radius; adjust X/Y when the image is cropped or squeezed."
|
||||
},
|
||||
{
|
||||
"id": "sourceEdgeCut",
|
||||
"label": "Source Edge Cut",
|
||||
"type": "float",
|
||||
"default": 0.01,
|
||||
"min": 0,
|
||||
"max": 0.2,
|
||||
"step": 0.001,
|
||||
"description": "Cuts slightly inward from all four source-frame edges before sampling to hide empty border regions."
|
||||
},
|
||||
{
|
||||
"id": "sourceEdgeFeather",
|
||||
"label": "Source Edge Feather",
|
||||
"type": "float",
|
||||
"default": 0.02,
|
||||
"min": 0,
|
||||
"max": 0.2,
|
||||
"step": 0.001,
|
||||
"description": "Softens the trimmed source edges into the outside color for easier background blending."
|
||||
},
|
||||
{
|
||||
"id": "virtualFovDegrees",
|
||||
"label": "Virtual FOV",
|
||||
|
||||
@@ -61,6 +61,20 @@ float normalizedFisheyeRadius(float theta, float halfFov)
|
||||
return theta / safeHalfFov;
|
||||
}
|
||||
|
||||
float sourceUvRectMask(float2 uv, float2 inputResolution)
|
||||
{
|
||||
float2 pixel = 1.0 / max(inputResolution, float2(1.0, 1.0));
|
||||
float cut = max(sourceEdgeCut, 0.0);
|
||||
float feather = max(sourceEdgeFeather, 0.0);
|
||||
float2 featherSize = max(float2(feather, feather), pixel * 0.5);
|
||||
|
||||
float left = smoothstep(cut, cut + featherSize.x, uv.x);
|
||||
float right = 1.0 - smoothstep(1.0 - cut - featherSize.x, 1.0 - cut, uv.x);
|
||||
float top = smoothstep(cut, cut + featherSize.y, uv.y);
|
||||
float bottom = 1.0 - smoothstep(1.0 - cut - featherSize.y, 1.0 - cut, uv.y);
|
||||
return saturate(left * right * top * bottom);
|
||||
}
|
||||
|
||||
float4 shadeVideo(ShaderContext context)
|
||||
{
|
||||
float2 screen = float2(context.uv.x * 2.0 - 1.0, 1.0 - context.uv.y * 2.0);
|
||||
@@ -99,5 +113,7 @@ float4 shadeVideo(ShaderContext context)
|
||||
if (sourceUv.x < 0.0 || sourceUv.x > 1.0 || sourceUv.y < 0.0 || sourceUv.y > 1.0)
|
||||
return outsideColor;
|
||||
|
||||
return sampleVideo(sourceUv);
|
||||
float sourceMask = sourceUvRectMask(sourceUv, context.inputResolution);
|
||||
float4 sourceColor = sampleVideo(sourceUv);
|
||||
return saturate(lerp(outsideColor, sourceColor, sourceMask));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user