godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.83k stars 21.14k forks source link

The panoramic sky field of view is not set correctly in orthogonal mode #23077

Open capnm opened 6 years ago

capnm commented 6 years ago

Godot version:

0dbe01483a902c49ecedf4fd36b74353424145a5

OS/device including version:

Linux

Issue description:

Auto/default FOV

image

image

The same with a similar custom FOV

image

image

Steps to reproduce: Attach a panorama texture to the environment node and press numpad-5.

NewNodeGames commented 6 years ago

If I increase sky_custom_fov and then set back to zero the skybox or panorama looks correct. Weird.

capnm commented 6 years ago

In Blender, the background is at least not disturbing and physically theoretically looks more correct. I think it should be set to the maximum FOV value similar to Blender. The background flickers when you turn the view, but that doesn't seem to be a problem.

b1

b2

b6

b7

Calinou commented 5 years ago

The background flickers when you turn the view, but that doesn't seem to be a problem.

I tried that out as I was looking into fixing this, but I think the rapid color flashes when rotating can be problematic for people who are prone to light-induced seizures.

Calinou commented 4 years ago

Here's a patch that sets the sky FOV to 0.1 in orthogonal mode when no custom sky FOV is set:

diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
index a33c94fbcd..34a8ad2b57 100644
--- a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
+++ b/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
@@ -1306,13 +1306,15 @@ void RasterizerSceneHighEndRD::_draw_sky(RD::DrawListID p_draw_list, RD::Framebu
    // Camera
    CameraMatrix camera;

-   if (custom_fov) {
+   if (custom_fov || p_projection.is_orthogonal()) {
+       // Use a very low FOV when using orthogonal projection.
+       // This is more technically correct compared to drawing a stretched out sky.

        float near_plane = p_projection.get_z_near();
        float far_plane = p_projection.get_z_far();
        float aspect = p_projection.get_aspect();

-       camera.set_perspective(custom_fov, aspect, near_plane, far_plane);
+       camera.set_perspective(MAX(0.1, custom_fov), aspect, near_plane, far_plane);

    } else {
        camera = p_projection;

But as I said, it kind of hurts to look at when panning the camera around, especially in panoramas with strong light variations.

@clayjohn @reduz Any opinions on this?

capnm commented 4 years ago

Now when I think about it again, in orthogonal mode it would be better to turn the panorama off for the background and/or make a viewport option for a replacement color.

The background is turned off in the Blender material preview viewport, and you can also turn it off in the render viewport.

DDL-Blue commented 4 years ago

The sky in the very default "just opened Godot and created new project" 3D scene seems to have the same problem. When set to orthogonal view, the sun seems to be broken in the same way.

Calinou commented 4 years ago

@DDL-Blue Indeed, this issue isn't limited to PanoramaSky. It'll occur with any sky that's not a plain color.