Make SSR water verticals behave better

This commit is contained in:
Joshua Barretto 2022-10-10 22:07:07 +01:00
parent d40be0ea5f
commit be8ef302bc

View File

@ -122,6 +122,8 @@ void main() {
vec2 suv = (clippos.xy / clippos.w) * 0.5 * vec2(1, -1) + 0.5;
float d = -depth_at(suv);
if (d < svpos.z * 0.8 && d > svpos.z * 0.999) {
// Don't cast into water!
if (texture(sampler2D(t_src_color, s_src_color), suv).a >= 1.0) {
t -= 1.0 / float(MAIN_ITERS);
// Do a bit of extra iteration to try to refine the estimate
const int ITERS = 8;
@ -139,6 +141,7 @@ void main() {
}
break;
}
}
t += 1.0 / float(MAIN_ITERS);
}
#endif
@ -155,7 +158,7 @@ void main() {
clamp((new_dist - dist * 0.5) / (dist * 0.5), 0.0, 1.0),
max(dot(normalize(new_wpos - wpos), refl_dir) - 0.95, 0.0) / 0.05
)
);
) * 0.85;
if (merge > 0.0) {
vec3 new_col = texture(sampler2D(t_src_color, s_src_color), new_uv).rgb;