Godot Version
4.4
Question
I was initially writing a post asking a question, but was able to figure things out while doing so. I am looking for conformation that I came to correct conclusion since I coudn’t find anything in documentation or on the forums. I also wanted to create the post in case someone will face a similiar problem.
normal_roughness_texture stores NORMAL vectors in view space using the following encoding
stored = 0.5 * (normal_view + 1.0)
This is done to not miss negative parts of the normals.
To get them in view space we should use the inverse operation:
normal_view = 2.0 * texture(normals, SCREEN_UV).xyz - 1.0
And to transform them to world space the following code:
normal_world = (INV_VIEW_MATRIX * vec4(normal_view, 0.0))
This seems to work perfectly for me but took some time to figure out.