Skip to content

Commit

Permalink
feat: Shader Commands now support -Force ( Fixes #163 )
Browse files Browse the repository at this point in the history
Also fixing Set-OBSShaderFilter -ShaderFile
  • Loading branch information
James Brundage committed Feb 14, 2024
1 parent fc154fc commit 42c7aaf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Build/obs--shaders.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ foreach ($shaderParameterSet in $ShaderParameters) {
Help = "The inline value of the shader. This will normally be provided as a default parameter, based off of the name."
}

$ShaderParameters["Force"] = [Ordered]@{
ParameterName = "Force"
ParameterType = [switch]
Help = "If set, will force the recreation of a shader that already exists"
}

$ShaderParameters["PassThru"] = [Ordered]@{
ParameterName = "PassThru"
ParameterType = [switch]
Expand Down Expand Up @@ -362,7 +368,7 @@ switch -regex ($myVerb) {
ShaderSetting = $ShaderSettings
FilterName = $FilterName
SourceName = $SourceName
}
}

foreach ($CarryOnParameter in "PassThru", "NoResponse","Force") {
if ($PSBoundParameters.ContainsKey($CarryOnParameter)) {
Expand All @@ -384,7 +390,7 @@ switch -regex ($myVerb) {
$ShaderFilterSplat.ShaderFile = $script:CachedShaderFilesFromCommand[$shaderName].FullName
} else {
$ShaderFilterSplat.ShaderText = $shaderText
}
}

if ($myVerb -eq 'Add') {
Add-OBSShaderFilter @ShaderFilterSplat
Expand Down
20 changes: 18 additions & 2 deletions Commands/Filters/Set-OBSShaderFilter.ps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,26 @@ function Set-OBSShaderFilter
This requires that the [OBS Shader Filter](https://github.com/exeldro/obs-shaderfilter) is installed.
.EXAMPLE
Show-OBS -Uri https://pssvg.start-automating.com/Examples/Stars.svg |
Set-OBSShaderFilter -FilterName "Shader" -ShaderFile fisheye-xy -ShaderSetting @{
Set-OBSShaderFilter -FilterName "FisheyeShader" -ShaderFile fisheye-xy -ShaderSetting @{
center_x_percent=30
center_y_percent=70
}
.EXAMPLE
Show-OBS -Uri https://pssvg.start-automating.com/Examples/Stars.svg |
Set-OBSShaderFilter -FilterName "SeasickShader" -ShaderFile seasick -ShaderSetting @{
amplitude = 0.05
speed = 0.5
frequency = 12
opacity = 1
}
.EXAMPLE
Show-OBS -Uri https://pssvg.start-automating.com/Examples/Stars.svg |
Set-OBSShaderFilter -FilterName "TwistShader" -ShaderFile twist -ShaderSetting @{
center_x_percent=50
center_y_percent=50
power = 0.05
rotation = 80
}
#>
[inherit(Command={
Import-Module ..\..\obs-powershell.psd1 -Global
Expand Down Expand Up @@ -56,7 +72,7 @@ function Set-OBSShaderFilter
}
elseif ($ShaderFile) {
if ($ShaderFile -match '[\\/]') {
$shaderSettings.shader_file_name = $shaderSettings.$ExecutionContext.SessionState.Path.GetResolvedProviderPathFromPSPath($ShaderFile) -replace "\\", "/"
$shaderSettings.shader_file_name = "$($ExecutionContext.SessionState.Path.GetResolvedPSPathFromPSPath($ShaderFile))" -replace "\\", "/"
} else {
if (-not $script:CachedOBSShaderFilters) {
$script:CachedOBSShaderFilters =
Expand Down

0 comments on commit 42c7aaf

Please sign in to comment.