Fix SSR orientation issues when using orthogonal camera

- Use negative clip space values to fix reversed rotations in reflections
- Use constant -z view vector when raymarching to fix perspective in reflections
This commit is contained in:
Mert Kasar 2024-07-10 21:28:42 +03:00
parent 26d1577f39
commit 56ed2cb6d1
2 changed files with 2 additions and 2 deletions

View File

@ -90,7 +90,7 @@ void main() {
if (sc_multiview) {
view_dir = normalize(vertex + scene_data.eye_offset[params.view_index].xyz);
} else {
view_dir = normalize(vertex);
view_dir = params.orthogonal ? vec3(0.0, 0.0, -1.0) : normalize(vertex);
}
vec3 ray_dir = normalize(reflect(view_dir, normal));

View File

@ -20,7 +20,7 @@ vec3 reconstructCSPosition(vec2 screen_pos, float z) {
return pos.xyz;
} else {
if (params.orthogonal) {
return vec3((screen_pos.xy * params.proj_info.xy + params.proj_info.zw), z);
return vec3(-(screen_pos.xy * params.proj_info.xy + params.proj_info.zw), z);
} else {
return vec3((screen_pos.xy * params.proj_info.xy + params.proj_info.zw) * z, z);
}