godotengine / godot

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

Y-Billboarded QuadMesh rotates unexpectedly when 3D camera is rotated on the Z axis #52108

Closed MagdielM closed 3 years ago

MagdielM commented 3 years ago

Godot version

v3.3.3 stable (Mono build)

System information

Windows 10, AMD Radeon RX 480M, GLES3

Issue description

In a 3D scene, a QuadMesh with a SpatialMaterial with its Billboard mode set to Y-Billboard does not retain its expected orientation when the viewed through a camera rotated on its Z axis.

Camera Z Rotation 0°: image

Camera Z Rotation 45°: image

If the camera is rotated beyond 90 degrees, either clockwise or counterclockwise, the QuadMesh is no longer visible.

Camera Z Rotation -110°: image

I suspect this is because the QuadMesh is being rotated around the global Y axis and back faces are culled by default. When the material's culling mode is set to disabled, the QuadMesh becomes visible again.

Camera Z Rotation -110°, face culling disabled: image

In my experience, this occurs in both the GLES3 and GLES2 backends.

Steps to reproduce

In an empty project:

  1. Place a Camera node in a 3D scene.
  2. Place a MeshInstance in view of the camera and assign a QuadMesh resource to its mesh property.
  3. Assign a SpatialMaterial with its BillboardMode parameter set to Y-Billboard.
  4. Set the camera's Z-rotation to anything other than 0. Higher values will produce more prominent results.
  5. Preview the camera view from the editor. Alternatively, play the scene.

From the reproduction project:

  1. Open the "Test Scene" scene.
  2. Preview the "Camera 1" node to observe normal behavior.
  3. Preview the "Camera 2" node to observe the "Test QuadMesh" node being skewed.
  4. Preview the "Camera 3" node to observe the "Test QuadMesh" node becoming invisible.

Minimal reproduction project

YBillboardingZRotationTest.zip

CaptainProton42 commented 3 years ago

I made a PR for this and also opened a proposal for overhauling how billboards work a bit: https://github.com/godotengine/godot-proposals/issues/3211