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

[Experiment] Silhouette effect #87

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions RealityMixer/Capture/Shaders/Shaders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,18 @@ struct Shaders {
vec2 chroma = texture2D(u_diffuseTexture, _surface.diffuseTexcoord).rg;

vec4 textureColor = yCbCrToRGB(luma, chroma);
_surface.diffuse = textureColor;

float blendValue = smoothChromaKey(textureColor.rgb, maskColor, sensitivity, smoothness);

float maskTextureValue = texture2D(u_ambientTexture, _surface.diffuseTexcoord).r;
_surface.ambient = vec4(1.0, 1.0, 1.0, 1.0);

if (maskTextureValue > 0.5) {
_surface.transparent = vec4(blendValue, blendValue, blendValue, 1.0);
_surface.transparent = vec4(1.0 - blendValue, 1.0 - blendValue, 1.0 - blendValue, 1.0);
_surface.diffuse = vec4(1.0, 0.0, 1.0, 1.0);
} else {
_surface.transparent = vec4(1.0, 1.0, 1.0, 1.0);
_surface.transparent = vec4(0.0, 0.0, 0.0, 1.0);
_surface.diffuse = vec4(1.0, 0.0, 1.0, 1.0);
}
"""
}
Expand Down