FiniteSingularity / obs-advanced-masks

Advanced Masking Plugin for OBS
GNU General Public License v2.0
146 stars 10 forks source link

Fixes shape-scaling issue. #44

Closed FiniteSingularity closed 9 months ago

FiniteSingularity commented 9 months ago

This PR fixes the incorrect scaling issue, #43 .

Since it changes the scale of a shape mask at a given input size, the fix was put in a new version of the source. So existing filters will not be broken by this change (however their size will not be correct, and will not be consistent with new instances of the filter that are created after updating to this code).

ZombieHDGaming commented 9 months ago

I just wanted to give some input on this before it eventually gets merged in:

Based on this PR, the original issue of the mask width and height now appear to properly align with the source's actual width and height when setting them accordingly. However, I'm not sure if this is intentional behavior and wanted to mention it, it appears that when you match the width and height with the source itself, a small one pixel border is still observable at the edge of the mask. In my testing, this was done with an Elgato Facecam Pro set to 4k resolution and framed to the canvas and the mask set for 3840 width and 2160 height, and the source was not fully covering the canvas and had a single pixel border at the edge being able to show any sources behind it. If the width was increased to 3841 and height increased to 2161, the edge was no longer visible (can provide a picture of needed).

Again, not sure if this was intentional design and wanted to bring it up just in case. And thank you for the fix Finite!

FiniteSingularity commented 9 months ago

@ZombieHDGaming - Thank you for testing out the PR. Definitely not the intended behavior. I'll dive into this tomorrow, and figure out what is going on.

FiniteSingularity commented 9 months ago

Hi @ZombieHDGaming-

Unfortunately, I am not able to replicate this issue. I don't have a FaceCam Pro, though I do have the Camlink Pro (which will output 4k). With both a 3840x2160 color source, and a 4k camlink pro source, setting the rectangular mask to exactly 3840x2160 doesn't show any background pixels at the edges.

Can you please launch OBS, and then go Help --> Log Files --> Upload current log file and paste the link here? Also if you could let me know the scene where you are applying the mask, and the source name that you are applying the mask to?

ZombieHDGaming commented 9 months ago

Hi Finite, Here is a link to the log with a very basic setup as I was able to reproduce the issue with just 2 color sources: https://obsproject.com/logs/bSyGI5suHHBGDXTo

Screenshot 2024-01-22 16-06-29

Hopefully Github shows this correctly, but the picture shows 2 separate color sources (Color Source and Color Source 2), both defaulted to 1920x1080 (as that is my canvas size). In my setup, color source 2 was a darker color source with the advanced mask applied using solely defaults besides adjusting the Mask Geometry width and height to also be 1920x1080 and a small border being visible on the outside (if it's not quite showing right via the browser, save to PC and view via Photos in dark mode and you'll see it). It appears that it's not resolution dependent and more like a potential off by one issue somewhere in the plugin. If needed, I can potentially dive further and see if I can find where it's occurring.

FiniteSingularity commented 9 months ago

I was able to replicate it. Thanks @ZombieHDGaming.

FiniteSingularity commented 9 months ago

Hi @ZombieHDGaming-

Give this build a try: https://github.com/FiniteSingularity/obs-advanced-masks/actions/runs/7628106582 . It should fix that single pixel issue. To detect the shapes and where the mask should be, we use Signed Distance Field functions. The problem was that pixels on the border (distance of zero to the border) were flagged as outside the mask. That should be fixed in this new build. Let me know if it fixes your issue.