Fix EEVEE: Screen Space Refraction Artefacts caused by viewport aspect ratio

This was caused by the vertical/horizontal clasification being done in
NDC space which wasn't respecting the Aspect ratio.

Multiplying the test vector by the target size fixes the issue.
This commit is contained in:
Clément Foucault 2022-09-21 21:48:23 +02:00
parent 91dd29fd45
commit f42569bb71
Notes: blender-bot 2023-02-14 04:24:05 +01:00
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3
Referenced by issue #101034, EEVEE: Screen Space Refraction Artefacts when the viewport is narrow and non square
1 changed files with 2 additions and 1 deletions

View File

@ -51,7 +51,8 @@ void raytrace_screenspace_ray_finalize(inout ScreenSpaceRay ray)
}
float ray_len_sqr = len_squared(ray.direction.xyz);
/* Make ray.direction cover one pixel. */
bool is_more_vertical = abs(ray.direction.x) < abs(ray.direction.y);
bool is_more_vertical = abs(ray.direction.x / ssrPixelSize.x) <
abs(ray.direction.y / ssrPixelSize.y);
ray.direction /= (is_more_vertical) ? abs(ray.direction.y) : abs(ray.direction.x);
ray.direction *= (is_more_vertical) ? ssrPixelSize.y : ssrPixelSize.x;
/* Clip to segment's end. */