This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
generated from obsproject/obs-plugintemplate
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new ONNX models and update brew bundle command
- Loading branch information
Showing
16 changed files
with
1,007 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
uniform float4x4 ViewProj; | ||
uniform texture2d image; | ||
uniform texture2d focalmask; | ||
|
||
uniform float xOffset; | ||
uniform float yOffset; | ||
|
||
sampler_state textureSampler { | ||
Filter = Linear; | ||
AddressU = Clamp; | ||
AddressV = Clamp; | ||
}; | ||
|
||
struct VertDataIn { | ||
float4 pos : POSITION; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
struct VertDataOut { | ||
float4 pos : POSITION; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
VertDataOut VSDefault(VertDataOut v_in) | ||
{ | ||
VertDataOut vert_out; | ||
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj); | ||
vert_out.uv = v_in.uv; | ||
return vert_out; | ||
} | ||
|
||
/** | ||
* Standard Kawase blur | ||
*/ | ||
float4 PSKawaseBlur(VertDataOut v_in) : TARGET | ||
{ | ||
// Calculate the blur value from neighboring pixels | ||
float4 sum = float4(0.0, 0.0, 0.0, 0.0); | ||
sum += image.Sample(textureSampler, v_in.uv + float2( xOffset, yOffset)); | ||
sum += image.Sample(textureSampler, v_in.uv + float2(-xOffset, yOffset)); | ||
sum += image.Sample(textureSampler, v_in.uv + float2( xOffset, -yOffset)); | ||
sum += image.Sample(textureSampler, v_in.uv + float2(-xOffset, -yOffset)); | ||
sum *= 0.25; | ||
return sum; | ||
} | ||
|
||
/** | ||
* Mask aware Kawase blur | ||
* Only uses pixels which are in the masked area for blur. This prevents the "Halo Effect" on | ||
* the border pixels of the mask. | ||
*/ | ||
float4 PSKawaseBlurMaskAware(VertDataOut v_in) : TARGET | ||
{ | ||
if (focalmask.Sample(textureSampler, v_in.uv).r == 0) { | ||
// No mask - return the original image value without any blur | ||
return image.Sample(textureSampler, v_in.uv); | ||
} | ||
|
||
// Calculate the blur value from neighboring pixels | ||
|
||
float alphaValue1 = focalmask.Sample(textureSampler, v_in.uv + float2( xOffset, yOffset)).r; | ||
float4 sum = image.Sample(textureSampler, v_in.uv + float2( xOffset, yOffset)) * alphaValue1; | ||
|
||
float alphaValue2 = focalmask.Sample(textureSampler, v_in.uv + float2(-xOffset, yOffset)).r; | ||
sum += image.Sample(textureSampler, v_in.uv + float2(-xOffset, yOffset)) * alphaValue2; | ||
|
||
float alphaValue3 = focalmask.Sample(textureSampler, v_in.uv + float2( xOffset, -yOffset)).r; | ||
sum += image.Sample(textureSampler, v_in.uv + float2( xOffset, -yOffset)) * alphaValue3; | ||
|
||
float alphaValue4 = focalmask.Sample(textureSampler, v_in.uv + float2(-xOffset, -yOffset)).r; | ||
sum += image.Sample(textureSampler, v_in.uv + float2(-xOffset, -yOffset)) * alphaValue4; | ||
|
||
float pixelCounter = alphaValue1 + alphaValue2 + alphaValue3 + alphaValue4; | ||
|
||
// Complement the blur pixels with a relative fraction of the center pixel | ||
return (sum + image.Sample(textureSampler, v_in.uv) * (4.0 - pixelCounter)) * 0.25; | ||
} | ||
|
||
technique Draw | ||
{ | ||
pass | ||
{ | ||
vertex_shader = VSDefault(v_in); | ||
pixel_shader = PSKawaseBlur(v_in); | ||
} | ||
} | ||
|
||
technique DrawMaskAware | ||
{ | ||
pass | ||
{ | ||
vertex_shader = VSDefault(v_in); | ||
pixel_shader = PSKawaseBlurMaskAware(v_in); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
uniform float4x4 ViewProj; | ||
uniform texture2d image; | ||
uniform texture2d focalmask; | ||
uniform float4 color = {1.0, 1.0, 1.0, 1.0}; | ||
|
||
sampler_state textureSampler { | ||
Filter = Linear; | ||
AddressU = Clamp; | ||
AddressV = Clamp; | ||
}; | ||
|
||
struct VertDataIn { | ||
float4 pos : POSITION; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
struct VertDataOut { | ||
float4 pos : POSITION; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
VertDataOut VSDefault(VertDataOut v_in) | ||
{ | ||
VertDataOut vert_out; | ||
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj); | ||
vert_out.uv = v_in.uv; | ||
return vert_out; | ||
} | ||
|
||
/* where the mask is 1 draw a solid color */ | ||
float4 PSSolid(VertDataOut v_in) : TARGET | ||
{ | ||
if (focalmask.Sample(textureSampler, v_in.uv).r != 0) { | ||
return color.bgra; | ||
} | ||
return image.Sample(textureSampler, v_in.uv); | ||
} | ||
|
||
/* draw just the mask */ | ||
float4 PSMask(VertDataOut v_in) : TARGET | ||
{ | ||
if (focalmask.Sample(textureSampler, v_in.uv).r != 0) { | ||
return float4(1,1,1,1); | ||
} | ||
return float4(0,0,0,1); | ||
} | ||
|
||
float4 PSDefault(VertDataOut v_in) : TARGET | ||
{ | ||
return image.Sample(textureSampler, v_in.uv); | ||
} | ||
|
||
technique DrawSolidColor | ||
{ | ||
pass | ||
{ | ||
vertex_shader = VSDefault(v_in); | ||
pixel_shader = PSSolid(v_in); | ||
} | ||
} | ||
|
||
technique DrawMask | ||
{ | ||
pass | ||
{ | ||
vertex_shader = VSDefault(v_in); | ||
pixel_shader = PSMask(v_in); | ||
} | ||
} | ||
|
||
technique Draw | ||
{ | ||
pass | ||
{ | ||
vertex_shader = VSDefault(v_in); | ||
pixel_shader = PSDefault(v_in); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.