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

get_intersection is inaccurate with a near horizontal camera #498

Open
MilesRomanum opened this issue Sep 25, 2024 · 3 comments
Open

get_intersection is inaccurate with a near horizontal camera #498

MilesRomanum opened this issue Sep 25, 2024 · 3 comments

Comments

@MilesRomanum
Copy link

MilesRomanum commented Sep 25, 2024

Terrain3D version

v.0.9.3-beta

System information

Godot 4.3 - Windows 10 - RTX 3080 TI - Vulkan Forward+

Is the issue reproducable in the demo?

Yes

Issue description

get_intersection is inaccurate when trying to use click detection on a flat/horizontal camera. Here is a trail of logs that show the potential deviation

Hearts.of.Steel.DEBUG.2024-09-25.01-26-48.mp4

Below is my project (if you run with console and right click on the map, you will get reports of error, distance etc)

Hearts.of.Steel.zip

Logs

Error: 4.172072    Dist: 47.907257
Error: 31.103138    Dist: 78.95521
Error: 26.155058    Dist: 105.19489
Error: 59.366867    Dist: 164.7356
Error: 41.345886    Dist: 206.0743
Error: 37.026024    Dist: 169.3499
Error: 94.67689    Dist: 74.74287```
@TokisanGames
Copy link
Owner

The calculation for our GPU mouse was changed in #500 fdbdd36, which increased the bit depth. You could rerun your accuracy tests with get_intersection() to see if it helps if you like.

@MilesRomanum
Copy link
Author

MilesRomanum commented Oct 5, 2024

Hi, I updated to the latest build, but I think it isnt better.

Error: 195.10928	Dist: 96.99999	Estimate: (-50.490257, 2.1923776, -59.30308)	get_intersection: (-152.04807, -27.234423, -223.2778)
Error: 70.21573	Dist: 167.00017	Estimate: (141.91121, 6.1355257, -65.47567)	get_intersection: (80.26688, 10.628754, -32.158478)
Error: 59.644417	Dist: 107.00001	Estimate: (109.21683, 3.863419, -121.39816)	get_intersection: (125.72325, -3.360117, -178.25601)
Error: 14.938561	Dist: 92.00023	Estimate: (180.57889, 9.896137, -91.63437)	get_intersection: (195.31886, 8.771511, -89.482864)
Error: 54.439037	Dist: 145.99986	Estimate: (30.42535, 4.030425, -121.96139)	get_intersection: (84.48676, 8.800047, -117.692535)

Ill share a video in a second. I added a debug marker to show the two collision position to demonstrate better. red is estimate, green is get_intersection

@MilesRomanum
Copy link
Author

MilesRomanum commented Oct 5, 2024

Sharing the debug log, this is mapped to every click recorded in the video. red marker is where the estimate returned, versus green for get_intersection
Part1:

Hearts.Of.Steel.Debug.2024-10-05.01-40-35.-.Copy.-.Trim1.mp4

part2:
https://github.com/user-attachments/assets/8d3f9e6c-5bf8-4f0e-b641-d3b9cf21e574

Error: 125.99021	Dist: 167.99976	Estimate: (139.78886, 5.582857, -65.41576)	get_intersection: (23.650845, 14.011656, -17.307026)
Error: 71.474724	Dist: 95.99963	Estimate: (186.11154, 8.179788, -16.108404)	get_intersection: (254.5876, 1.7453604, 3.3406029)
Error: 54.875015	Dist: 149.99963	Estimate: (294.80597, 4.0693984, -124.0558)	get_intersection: (268.88422, 8.73481, -75.91472)
Error: 44.654305	Dist: 105.00113	Estimate: (360.26288, 4.7399936, -93.67245)	get_intersection: (404.6128, -0.39843178, -94.50224)
Error: 10.400347	Dist: 93.99986	Estimate: (357.36133, -0.010972619, 8.01142)	get_intersection: (356.1135, -1.8733864, 18.167282)
Error: 70.68224	Dist: 164.00052	Estimate: (240.01453, 5.2122087, 90.925644)	get_intersection: (301.24237, 10.215933, 55.9672)
Error: 76.33255	Dist: 239.99902	Estimate: (107.84906, 4.3857574, 221.78114)	get_intersection: (167.60542, 8.341199, 174.4505)
Error: 220.4336	Dist: 18.99996	Estimate: (114.441505, 12.430712, 42.566242)	get_intersection: (20.843628, -38.51715, -150.39677)
Error: 34.081936	Dist: 53.000088	Estimate: (128.70679, 1.3547925, -10.902894)	get_intersection: (105.18446, 11.3011, 11.665879)
Error: 9.250448	Dist: 62.000168	Estimate: (74.84858, 2.1242995, -28.525751)	get_intersection: (81.24271, 4.31719, -22.210915)
Error: 10.195393	Dist: 51	Estimate: (35.5852, 7.427745, -0.9930133)	get_intersection: (26.717762, 5.54974, 3.6747112)
Error: 27.455229	Dist: 22.999996	Estimate: (4.323099, 6.734419, 11.310597)	get_intersection: (-12.11165, -5.3073006, -7.0928154)
Error: 93.42034	Dist: 115.99991	Estimate: (-96.08584, 3.8323512, -30.210556)	get_intersection: (-5.355257, 14.293623, -10.566666)

Had to compress/downsample/lower the framerate, but as you can see, green (get_intersection) can be very far off where the mouse meets the terrain. red (iterative approximation) is not perfect, but it is much closer to the reference point so the error estimate is legitimate.

I think the reason why this may not have been massive in the editor is because the camera angle is almost vertical, whereas here it is horizontal.

let me know if you'd like to look at my source code, ill edit out the unnecessary stuff and upload the project files upon request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants