Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan: Screen space reflections weirdly rotated with orthogonal cameras #79002

Closed
ghost opened this issue Jul 3, 2023 · 4 comments · Fixed by #94184
Closed

Vulkan: Screen space reflections weirdly rotated with orthogonal cameras #79002

ghost opened this issue Jul 3, 2023 · 4 comments · Fixed by #94184

Comments

@ghost
Copy link

ghost commented Jul 3, 2023

Godot version

v4.0.3.stable.official [5222a99]

System information

Mac Ventura - Vulkan API 1.2.231 - Forward+ - Apple M1

Issue description

SSR doesn't appear correctly with orthographic cameras, the reflections are rotated around seemingly inverse to the camera.

There's a similar issue #49204, however the previous one is for Godot 3.5 and the workarounds no longer work. The editor camera no longer works properly, and neither does moving the camera far away. I believe this may be a different (though likely related) problem. Hopefully this is okay.

Screenshot:
Screenshot 2023-07-03 at 4 50 23 PM

Best regards.

Steps to reproduce

  1. Switch editor to orthographic mode and rotate the camera around, reflections are weird (in previous issue the editor camera was unaffected)
  2. Preview OrthoCamera -- this is set to use the previous workaround of moving the camera far away, however this doesn't seem to work anymore

Minimal reproduction project

SSRTest.zip

@Calinou Calinou changed the title Screen space reflections weirdly rotated with orthogonal cameras Vulkan: Screen space reflections weirdly rotated with orthogonal cameras Jul 3, 2023
@Calinou
Copy link
Member

Calinou commented Aug 31, 2023

@farfalk
Copy link

farfalk commented Jul 8, 2024

This still happens in 4.3beta2, with some additional weird visual glitches happening only with SSR enabled
immagine

@github-project-automation github-project-automation bot moved this to For team assessment in Rendering Issue Triage Jul 10, 2024
@clayjohn clayjohn moved this from For team assessment to Up for grabs in Rendering Issue Triage Jul 10, 2024
@mertkasar
Copy link
Contributor

mertkasar commented Jul 10, 2024

Also suffering this issue in my project. Reproducible in every v4.x.x release.

Using negative camera space positions solves the wrong reflection rotations in orthogonal cameras. Turns out the rotations were actually reversed in here:

if (params.orthogonal) {
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);
}

So, line 23 becomes:

return vec3(-(screen_pos.xy * params.proj_info.xy + params.proj_info.zw), z);

However, issue #49204 from branch 3.x appeared here, too. Reflections gain perspective in orthographic cameras as the z-position of the camera lowers. Here is a minimal reproduction of this in a custom build with the fix above:
ssao_on
(in-game camera sits at z:25)

Whereas the expected behavior is much more like this:
ssao_on
(orthogonal editor camera, which probably sits at much greater z)

MRP:
ssr_orthographic_mrp.zip

@Geometror's workaround mentioned in the other issue can also be applied here once this issue is fixed. But still, reflections in an orthogonal camera should be… orthographic, I guess 😅 Perspective can be omitted entirely for SSR with orthogonal cameras.

@Calinou
Copy link
Member

Calinou commented Jul 10, 2024

Good catch 🙂

Using negative camera space positions solves the wrong reflection rotations in orthogonal cameras. Turns out the rotations were actually reversed:

Can you open a pull request for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants