godotengine / godotengine/godot
Camera3D.unproject_offset does not work with FRUSTRUM_PROJECTION projection type.
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in 4.x
### System information
Windows 11 - Godot 4.1-stable
### Issue description
Cameras with frustrum projection don't work properly with unproject_offset. I've tried looking around to see if anyone else is having this issue. Unfortunately for me frustrum projection is a kind of obscure feature and I'm using it in doubly obscure ways. The most helpful document I ran into was [Deprecate Camera3D's PROJECTION_FRUSTUM projection mode](https://github.com/godotengine/godot-proposals/issues/8536), which explained some of the known jank. Ideally, I would be using custom projection matrices. For now, I'd be satisfied with just a tip to get the screen position under frustrum projection, but it would be nice if the function worked with frustrum projection out of the box.
### Steps to reproduce
Download the MRP. Launch the test scene and rotate the camera with the arrow keys. If the camera's project is changed to perspective or orthographic, the sprite will be placed over the cube (as long as the cube is on screen, I didn't bother adding checks otherwise for the mrp). In frustrum project though, the sprite gets offset. It appears that unproject_offset is basing it's calculations off of the fov variable, which would line up with the claim from the deprecation request: "None of the code paths in Camera3D actually explicitly handles PROJECTION_FRUSTUM."
### Minimal reproduction project (MRP)
[CameraProjectionTest.zip](https://github.com/godotengine/godot/files/14816963/CameraProjectionTest.zip)
Contributor guide
Research direction
Start at the Camera3D.unproject_offset entry point and reproduce the issue with the linked CameraProjectionTest.zip project on Godot 4.x. Compare the sprite placement under perspective, orthographic, and frustum projection; done means unproject_offset places the sprite over the cube for frustum projection as it does for the other projection types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100