obs-filters: Add crop filter
Allows any source to be cropped, though note that this renders to texture first, so for more optimal results, cropping values should probably be put in to capture sources that can be cropped as they're actually rendered by the source.
This commit is contained in:
38
plugins/obs-filters/data/crop_filter.effect
Normal file
38
plugins/obs-filters/data/crop_filter.effect
Normal file
@@ -0,0 +1,38 @@
|
||||
uniform float4x4 ViewProj;
|
||||
uniform texture2d image;
|
||||
|
||||
uniform float2 mul_val;
|
||||
uniform float2 add_val;
|
||||
|
||||
sampler_state textureSampler {
|
||||
Filter = Linear;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
};
|
||||
|
||||
struct VertData {
|
||||
float4 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertData VSCrop(VertData v_in)
|
||||
{
|
||||
VertData vert_out;
|
||||
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
|
||||
vert_out.uv = v_in.uv * mul_val + add_val;
|
||||
return vert_out;
|
||||
}
|
||||
|
||||
float4 PSCrop(VertData v_in) : TARGET
|
||||
{
|
||||
return image.Sample(textureSampler, v_in.uv);
|
||||
}
|
||||
|
||||
technique Draw
|
||||
{
|
||||
pass
|
||||
{
|
||||
vertex_shader = VSCrop(v_in);
|
||||
pixel_shader = PSCrop(v_in);
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
MaskFilter="Image Mask/Blend"
|
||||
AsyncDelayFilter="Video Delay (Async)"
|
||||
CropFilter="Crop"
|
||||
DelayMs="Delay (milliseconds)"
|
||||
Type="Type"
|
||||
MaskBlendType.MaskColor="Alpha Mask (Color Channel)"
|
||||
@@ -15,3 +16,10 @@ Brightness="Brightness"
|
||||
Gamma="Gamma"
|
||||
BrowsePath.Images="All Image Files"
|
||||
BrowsePath.AllFiles="All Files"
|
||||
Crop.Left="Left"
|
||||
Crop.Right="Right"
|
||||
Crop.Top="Top"
|
||||
Crop.Bottom="Bottom"
|
||||
Crop.Width="Width"
|
||||
Crop.Height="Height"
|
||||
Crop.Relative="Relative"
|
||||
|
Reference in New Issue
Block a user