mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make SSR water verticals behave better
This commit is contained in:
parent
d40be0ea5f
commit
be8ef302bc
@ -122,22 +122,25 @@ 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) {
|
||||
t -= 1.0 / float(MAIN_ITERS);
|
||||
// Do a bit of extra iteration to try to refine the estimate
|
||||
const int ITERS = 8;
|
||||
float diff = 1.0 / float(MAIN_ITERS);
|
||||
for (int i = 0; i < ITERS; i ++) {
|
||||
vec3 swpos = mix(wpos, ray_end, t);
|
||||
svpos = (view_mat * vec4(swpos, 1)).xyz;
|
||||
vec4 clippos = proj_mat * vec4(svpos, 1);
|
||||
vec2 suv = (clippos.xy / clippos.w) * 0.5 * vec2(1, -1) + 0.5;
|
||||
float d = -depth_at(suv);
|
||||
t += ((d > svpos.z * 0.999) ? -1.0 : 1.0) * diff;
|
||||
diff *= 0.5;
|
||||
// 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;
|
||||
float diff = 1.0 / float(MAIN_ITERS);
|
||||
for (int i = 0; i < ITERS; i ++) {
|
||||
vec3 swpos = mix(wpos, ray_end, t);
|
||||
svpos = (view_mat * vec4(swpos, 1)).xyz;
|
||||
vec4 clippos = proj_mat * vec4(svpos, 1);
|
||||
vec2 suv = (clippos.xy / clippos.w) * 0.5 * vec2(1, -1) + 0.5;
|
||||
float d = -depth_at(suv);
|
||||
t += ((d > svpos.z * 0.999) ? -1.0 : 1.0) * diff;
|
||||
diff *= 0.5;
|
||||
|
||||
new_uv = suv;
|
||||
new_uv = suv;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
t += 1.0 / float(MAIN_ITERS);
|
||||
}
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user