Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Add chroma key support; make passthrough settings real time #2662

Merged
merged 5 commits into from
Feb 1, 2025

Conversation

zmerp
Copy link
Member

@zmerp zmerp commented Jan 25, 2025

No description provided.

@zmerp zmerp requested a review from shinyquagsire23 January 25, 2025 17:40
@zmerp zmerp marked this pull request as draft January 25, 2025 17:44
@shinyquagsire23
Copy link
Contributor

shinyquagsire23 commented Jan 25, 2025

So, looking at the settings I've already got a few critiques:

  • Default HSV should be #107C10 imo (120deg, 0.871 saturation, 0.486 value), having the green be more dull gives the thresholds more head/foot room to measure distances from, whereas neon green is at the top of the HSV cylinder and can only go downward (and that's also what I use with this SteamVR environment, which I'd highly recommend testing against bc it also gives you a nice way to test semiopacity on the dash).
    • Yes I know most flight simulators and VRChat environments use neon keyed stuff, and they're wrong and they should feel bad about it
  • For visionOS what I found works well is having a plain distance min/max threshold instead of per-component distances, especially for semitransparency, with defaults set at [0.35, 0.7] min/max for good-ish semitransparency on that environment. That way the desaturated grays on semitransparency get as much treatment as AA edges and other greens. Though I think technically my hue distances might be borked since 0.0 hue should be 0.0 distance from 1.0 hue, but idk.
    • Ex: If the distance between a pixel and the chroma color is 0.35 or lower, the alpha should be 0.0, if the distance is 0.525 the alpha should be 0.5, if the distance is 0.7 or greater the alpha should be 1.0
  • For some reason I was only able to key out the green on that environment by setting the hue to like 200-something degrees and messing with the feathering? It's totally nonsensical for some reason.
  • IMO the chroma key color should just be inputted as an sRGB hex code or at least dual-inputtable with one (ideally with something in the UI that shows the color selected).

Edit: Just realized the feathering is basically just my distance thing, but the distances being centered around 1.0 doesn't make a ton of sense, esp considering the visionOS defaults are [0.35, 0.7], so both very low

#[schema(strings(display_name = "Hue range"), suffix = "°")]
#[schema(flag = "real-time")]
#[schema(gui(slider(min = 0.0, max = 360.0, step = 1.0)))]
pub hue_range_deg: f32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh this being in degrees doesn't make a ton of sense? I can see the logic of weighting each of the components in a distance function mayyybe, but the default should be 1.0 weight and should be conveyed as a 0~2 weighting, everything made way more sense when I set this value to 180deg

@zmerp zmerp requested a review from shinyquagsire23 January 31, 2025 13:17
@zmerp zmerp marked this pull request as ready for review January 31, 2025 13:58
Copy link
Contributor

@daniel5gh daniel5gh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quickly glanced over your implementation out of interest, since I was looking to do something similar.

Found a typo.

alvr/client_core/src/connection.rs Outdated Show resolved Hide resolved
Co-authored-by: Daniël van Adrichem <daniel5gh@spiet.nl>
@shinyquagsire23
Copy link
Contributor

I think the current iteration is extremely servicsble for sims/VRChat where the expectation is like, 'key out my neon #FF0000 and semitransparency isn't a concern'. Good defaults as well. But I will say that the green semitransparency and outlines when I change the saturation ranges makes me a bit sad lol, I think maybe the distance-based keying with the subtract will have to be its own configuration (which is probably fine, it doesn't have to be one size fits all). The distance based keying always struggled with being overly broad to its own detriment, so to reiterate I think this current iteration has an actual strength in that regard.

Other downside is I feel like the min/max stuff is still a bit hostile to the possibility of color pickers (I don't know anyone that can do RGB->HSV conversions off the top of their head), but again maybe a super basic keying option separate from this one would be the better way to handle that.

@zmerp
Copy link
Member Author

zmerp commented Feb 1, 2025

I agree that a simpler chroma keying option would work for many people that closely control the key color in their video content, so we offer a single RGB color as parameter. But then we would need to fix the color bleeding. I've come to terms that the color fix on the edges of the mask cannot be purely based on color but also on location of the mask pixels, the neared full 1.0 mask pixel color should bleed into the transition area. I can see that this might be not feasible unless we impose strong restrictions on the size of the transition area.
I'd say to defer this problem to a different PR.

@shinyquagsire23
Copy link
Contributor

tbh distance with min/max feathering and the key subtract does a good job on just edges, but it's just fundamentally reliant on ~some linear relationship between the mask and the key color. But yeah, different PR. This method is good for nuking entire color ranges, which min/max feathering can't really do.

@zmerp zmerp merged commit 69e5e56 into master Feb 1, 2025
8 checks passed
@zmerp zmerp deleted the chroma-key branch February 1, 2025 11:48
@alexferreira1
Copy link

Can you please explain to me the start-end-min-max for the HSV variables? I'd like to passthrough a magenta colour but am struggling to fine tune it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants