Fade screen-space reflection towards inner margin
- Fade reflection towards inner margin and clip it at screen edges instead of external margin. - Round edges of the fade margin if both are being cut off to prevent sharp corners.
This commit is contained in:
parent
8c5ed68847
commit
cf7bb2c51f
1 changed files with 6 additions and 5 deletions
|
@ -175,16 +175,17 @@ void main() {
|
||||||
float margin_blend = 1.0;
|
float margin_blend = 1.0;
|
||||||
|
|
||||||
vec2 margin = vec2((viewport_size.x + viewport_size.y) * 0.5 * 0.05); // make a uniform margin
|
vec2 margin = vec2((viewport_size.x + viewport_size.y) * 0.5 * 0.05); // make a uniform margin
|
||||||
if (any(bvec4(lessThan(pos, -margin), greaterThan(pos, viewport_size + margin)))) {
|
if (any(bvec4(lessThan(pos, vec2(0.0, 0.0)), greaterThan(pos, viewport_size * 0.5)))) {
|
||||||
// clip outside screen + margin
|
// clip at the screen edges
|
||||||
frag_color = vec4(0.0);
|
frag_color = vec4(0.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
//blend fading out towards external margin
|
//blend fading out towards inner margin
|
||||||
vec2 margin_grad = mix(pos - viewport_size, -pos, lessThan(pos, vec2(0.0)));
|
// 0.25 = midpoint of half-resolution reflection
|
||||||
margin_blend = 1.0 - smoothstep(0.0, margin.x, max(margin_grad.x, margin_grad.y));
|
vec2 margin_grad = mix(viewport_size * 0.5 - pos, pos, lessThan(pos, viewport_size * 0.25));
|
||||||
|
margin_blend = smoothstep(0.0, margin.x * margin.y, margin_grad.x * margin_grad.y);
|
||||||
//margin_blend = 1.0;
|
//margin_blend = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue