Created
March 14, 2019 17:51
-
-
Save pfulop/cb19a4ace6565455313e7890a1f80214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform vec3 c_colorToReplace; | |
uniform float c_thresholdSensitivity; | |
uniform float c_smoothing; | |
#pragma transparent | |
#pragma body | |
vec3 textureColor = _surface.diffuse.rgb; | |
float maskY = 0.2989 * c_colorToReplace.r + 0.5866 * c_colorToReplace.g + 0.1145 * c_colorToReplace.b; | |
float maskCr = 0.7132 * (c_colorToReplace.r - maskY); | |
float maskCb = 0.5647 * (c_colorToReplace.b - maskY); | |
float Y = 0.2989 * textureColor.r + 0.5866 * textureColor.g + 0.1145 * textureColor.b; | |
float Cr = 0.7132 * (textureColor.r - Y); | |
float Cb = 0.5647 * (textureColor.b - Y); | |
float blendValue = smoothstep(c_thresholdSensitivity, c_thresholdSensitivity + c_smoothing, distance(vec2(Cr, Cb), vec2(maskCr, maskCb))); | |
float a = blendValue; | |
_surface.transparent.a = a; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment