-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from taj-ny/develop
v1.3.0
- Loading branch information
Showing
14 changed files
with
675 additions
and
139 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Modified version of https://www.shadertoy.com/view/ldfSDj | ||
|
||
uniform bool roundTopLeftCorner; | ||
uniform bool roundTopRightCorner; | ||
uniform bool roundBottomLeftCorner; | ||
uniform bool roundBottomRightCorner; | ||
|
||
uniform int topCornerRadius; | ||
uniform int bottomCornerRadius; | ||
|
||
uniform float antialiasing; | ||
|
||
uniform vec2 regionSize; | ||
|
||
uniform sampler2D beforeBlurTexture; | ||
uniform sampler2D afterBlurTexture; | ||
|
||
varying vec2 uv; | ||
|
||
float udRoundBox(vec2 p, vec2 b, vec2 fragCoord) | ||
{ | ||
float radius = 0.0; | ||
if ((fragCoord.y <= topCornerRadius) | ||
&& ((roundTopLeftCorner && fragCoord.x <= topCornerRadius) | ||
|| (roundTopRightCorner && fragCoord.x >= regionSize.x - topCornerRadius))) { | ||
radius = topCornerRadius; | ||
p.y -= radius; | ||
} else if ((fragCoord.y >= regionSize.y - bottomCornerRadius) | ||
&& ((roundBottomLeftCorner && fragCoord.x <= bottomCornerRadius) | ||
|| (roundBottomRightCorner && fragCoord.x >= regionSize.x - bottomCornerRadius))) { | ||
radius = bottomCornerRadius; | ||
p.y += radius; | ||
} | ||
|
||
return length(max(abs(p) - (b + vec2(0.0, radius)) + radius, 0.0)) - radius; | ||
} | ||
|
||
void main(void) | ||
{ | ||
vec2 halfRegionSize = regionSize * 0.5; | ||
vec2 fragCoord = uv * regionSize; | ||
float box = udRoundBox(fragCoord - halfRegionSize, halfRegionSize, fragCoord); | ||
|
||
// If antialiasing is 0, the shader will be used to generate corner masks. | ||
vec3 foreground = vec3(1.0, 1.0, 1.0); | ||
vec3 background = vec3(0.0, 0.0, 0.0); | ||
if (antialiasing > 0.0) { | ||
foreground = texture2D(afterBlurTexture, uv).rgb; | ||
background = texture2D(beforeBlurTexture, uv).rgb; | ||
} | ||
|
||
gl_FragColor = vec4(mix(foreground, background, smoothstep(0.0, antialiasing, box)), 1.0); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#version 140 | ||
|
||
// Modified version of https://www.shadertoy.com/view/ldfSDj | ||
|
||
uniform bool roundTopLeftCorner; | ||
uniform bool roundTopRightCorner; | ||
uniform bool roundBottomLeftCorner; | ||
uniform bool roundBottomRightCorner; | ||
|
||
uniform int topCornerRadius; | ||
uniform int bottomCornerRadius; | ||
|
||
uniform float antialiasing; | ||
|
||
uniform vec2 regionSize; | ||
|
||
uniform sampler2D beforeBlurTexture; | ||
uniform sampler2D afterBlurTexture; | ||
|
||
in vec2 uv; | ||
|
||
out vec4 fragColor; | ||
|
||
float udRoundBox(vec2 p, vec2 b, vec2 fragCoord) | ||
{ | ||
float radius = 0.0; | ||
if ((fragCoord.y <= topCornerRadius) | ||
&& ((roundTopLeftCorner && fragCoord.x <= topCornerRadius) | ||
|| (roundTopRightCorner && fragCoord.x >= regionSize.x - topCornerRadius))) { | ||
radius = topCornerRadius; | ||
p.y -= radius; | ||
} else if ((fragCoord.y >= regionSize.y - bottomCornerRadius) | ||
&& ((roundBottomLeftCorner && fragCoord.x <= bottomCornerRadius) | ||
|| (roundBottomRightCorner && fragCoord.x >= regionSize.x - bottomCornerRadius))) { | ||
radius = bottomCornerRadius; | ||
p.y += radius; | ||
} | ||
|
||
return length(max(abs(p) - (b + vec2(0.0, radius)) + radius, 0.0)) - radius; | ||
} | ||
|
||
void main(void) | ||
{ | ||
vec2 halfRegionSize = regionSize * 0.5; | ||
vec2 fragCoord = uv * regionSize; | ||
float box = udRoundBox(fragCoord - halfRegionSize, halfRegionSize, fragCoord); | ||
|
||
// If antialiasing is 0, the shader will be used to generate corner masks. | ||
vec3 foreground = vec3(1.0, 1.0, 1.0); | ||
vec3 background = vec3(0.0, 0.0, 0.0); | ||
if (antialiasing > 0.0) { | ||
foreground = texture(afterBlurTexture, uv).rgb; | ||
background = texture(beforeBlurTexture, uv).rgb; | ||
} | ||
|
||
fragColor = vec4(mix(foreground, background, smoothstep(0.0, antialiasing, box)), 1.0); | ||
} |
Oops, something went wrong.