Add a glow around the edges of a source without padding?

Sudonim

New Member
Currently my setup involves a canvas of a standard 16:9 resolution, which has a background image to fill the scene and a single source which is some game that is almost never the same 16:9 ratio as my canvas. This is why I use a background image, to fill out the scene. I also have two image sources, which consist of a black to transparent gradient which I manually place on the edge of my game source (black side touching the game), to give a gentle edge to the actual game window in the scene. I transform the game source with "Fit to screen" so it's always scaled and positioned appropriately, then I have to manually place the gradients to each side myself.
However, a game I want to record occasionally changes its aspect ratio, which throws my manual system off. So I'd like to automate this process with some sort of filter to add the black glow to the source. This wouldn't be a problem, since people have already made filters which can put a glow around a source (Though the one I found seems to work poorly with dark colors). However, anything that would do this needs to add padding to the source so it has something to draw to. Because I'm scaling my source with "Fit to screen", this shrinks the game so it no longer is neatly filling the canvas.
I can see a couple potential solutions, but have not been able to figure out any. Parenting the gradients to the edges of the game source would let me continue to use my image sources, which would be ideal. A filter to dynamically change crop/pad values to meet a certain aspect ratio, or a way to resize just the bounding box to allow the padding to not affect it's sizing at all would also work, provided I can find a good glow filter which works well with dark colors.
Any help would be appreciated.
 

Sudonim

New Member
Group Selected Items together and try to apply "Fit to screen" (Ctrl+F) to the whole group.
Or maybe this: https://obsproject.com/forum/thread...le-windowed-game-captures-to-the-left.170772/ ?
Neither of these are what I'm looking for.
Here's a couple of examples of what I'm doing using a notepad window. Both of the dark gradients on the left and right are separate image sources.
Screenshot 2025-03-17 16-25-13.png

Every time I switch to a different game which has a different aspect ratio (likely different resolution entirely), I need to manually reposition the gradients to the edges of the new source.
Screenshot 2025-03-17 16-33-48.png

This effect is what I'd like to do automatically, while still having the game source properly fitted to the canvas.
 

JonathanC09

Member

¿Ya has probado este plugin? Have you tried this plugin yet?
 

Sudonim

New Member

¿Ya has probado este plugin? Have you tried this plugin yet?
Yes, I have. It's the one I mentioned which has trouble with dark colors. In order to draw anything along the edge of the source it needs to add padding, which shrinks my source on the scene.
Here's an example, the padding makes the source smaller because it's including the padding generated by the filter in the "Fit to Screen"
Screenshot 2025-03-18 16-25-47.png

This is what it looks like with the same glow set to black, it's definitely there, but it's way too subtle.
Screenshot 2025-03-18 16-26-00.png
 

Suslik V

Active Member
It is complex task because you want to keep the side sources not transformed but snapped to the texture (not to the bounding box), with proper alignment, likely shifted few pixels into the source's center while remain behind the main source. I know script based solution (.lua) and it is very specific, so it is not published in resources. Maybe I will share the code here in few days (after some modifications and tests). No guaranty that the solution will work for you.
 

Suslik V

Active Member
This .lua script makes new Filter available for selection. The filter will be named "Snap to Item Texture". You can apply the filter to the source/item in the sources list and select from the properties of the filter where to anchor. Then assign hotkey named "Snap to Item Texture corners (Filter)" in OBS Settings. Hit hotkey in the current scene and any item with the filter should snap to selected point of the texture (not to bounding box) of the target source. To anchor to left corners you likely need to Transform the source to set Positional Alignment to "Top Right". Offset may not work correctly, so ignore it and instead use Group and apply the filter to the Group. Then set "Top Center" alignment and "Scale to inner bounds" for whole group (thus group width can be resized in OBS UI while keeping inner image centered at anchor point). Requires OBS v27.0.1 or newer. Has NOT undergone intensive testing. NOT tested with latest OBS! Thus,

As is. It is free.

filter-snap-to-item_1_0b.zip, ~4KiB to download.
CRC of the zip archive MD5:90E562CC4211C0142EA48355318D3B51

inside:
"filter-snap-to-item.lua" (~15 KiB)
 

Attachments

  • filter-snap-to-item_1_0b.zip
    4 KB · Views: 9

Sudonim

New Member
This .lua script makes new Filter available for selection. The filter will be named "Snap to Item Texture". You can apply the filter to the source/item in the sources list and select from the properties of the filter where to anchor. Then assign hotkey named "Snap to Item Texture corners (Filter)" in OBS Settings. Hit hotkey in the current scene and any item with the filter should snap to selected point of the texture (not to bounding box) of the target source. To anchor to left corners you likely need to Transform the source to set Positional Alignment to "Top Right". Offset may not work correctly, so ignore it and instead use Group and apply the filter to the Group. Then set "Top Center" alignment and "Scale to inner bounds" for whole group (thus group width can be resized in OBS UI while keeping inner image centered at anchor point). Requires OBS v27.0.1 or newer. Has NOT undergone intensive testing. NOT tested with latest OBS! Thus,

As is. It is free.

filter-snap-to-item_1_0b.zip, ~4KiB to download.
CRC of the zip archive MD5:90E562CC4211C0142EA48355318D3B51

inside:
"filter-snap-to-item.lua" (~15 KiB)
Script works pretty well. I've edited it to run whenever the snap source changes size (OBS seems to grind to a halt if I just do it every draw cycle), and that seems to be doing exactly what I was looking for, except now it only seems to work on one of the two sources. It will fix itself if I reopen the filter window, or change its order in the sources list. Not sure what I could do to fix that.
I really appreciate writing a script for me, thanks a ton!
 

Suslik V

Active Member
I've edited... now it only seems to work on one of the two sources. It will fix itself if I reopen the filter window, or change its order in the sources list.
I think, you just need to mimic hotkey or button press by calling the "request_snap_to_for_all()" function of the script - it schedules anchoring for all filters in the next rendering.
 

Sudonim

New Member
I think, you just need to mimic hotkey or button press by calling the "request_snap_to_for_all()" function of the script - it schedules anchoring for all filters in the next rendering.
Worked like a charm. I'll upload my edited script too, in case anyone else in the future wants to use it.
 

Attachments

  • filter-snap-to-item - Copy.zip
    4.2 KB · Views: 9

Suslik V

Active Member
If you need automatic follow the "Snap to" item (to follow all transform changes) then you need more complex algorithm. Yeah, it will be slower.

Auto-follow functionality (~1 sec interval). Now, in Studio mode anchoring should also work. Everything else - as written few post above ( here: https://obsproject.com/forum/thread...f-a-source-without-padding.184798/post-676784 ).

Edit:
Fixed few mistakes in algorithm that caused side effect of permanent anchoring. Because of these mistakes - I decided to make from it a new feature. So, now script has property to select anchoring mode ("semi-automatic" - analyzes geometry of the target, "automatic" - permanent anchoring, "manual" - only by hotkey). Some fixes for Studio mode.

filter-snap-to-item_1_3b.zip, ~5KiB to download.
CRC of the zip archive MD5:82FD885D1E32FE4F3C648445B4F6E151

inside:
"filter-snap-to-item.lua" (~20 KiB)
 

Attachments

  • filter-snap-to-item_1_3b.zip
    5.3 KB · Views: 13
Last edited:
Top