cyberbotics / webots

Webots Robot Simulator
https://cyberbotics.com
Apache License 2.0
3.29k stars 1.71k forks source link

Viewpoint rotation around picked point doesn't work on VMware #32

Closed omichel closed 5 years ago

omichel commented 5 years ago

Describe the Bug The rotation of the viewpoint around the picked point doesn't work.

Steps to Reproduce

  1. Open any world file, click and drag on a object to rotate the viewpoint.

Expected behavior It should behave like on other platforms.

System

omichel commented 5 years ago

After some investigation, I found that the problem comes from the depth value returned by wr_frame_buffer_copy_depth_pixel here which is slightly too big on VMware. It might by another OpenGL bug on VMware...

omichel commented 5 years ago

As a confirmation of this, all the lidars seem to be broken on VMware, for example the samples / devices / lidar.wbt is broken.

fabienrohrer commented 5 years ago

I can reproduce the GPU picking issue, but not the Lidar issues (the examples are working smoothly in my environment).

fabienrohrer commented 5 years ago

glReadPixels(..., 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, data) works, but returns distorted data.

This distortion is perfectly a square root function, therefore adding the following adjustment function after the glReadPixel solves the issue:

GLfloat *fData = (GLfloat *) data;
fData[0] = fData[0] * fData[0];

Remains to determine why.

Depth buffer content when picking:

capture d ecran 2018-12-11 a 15 18 33
omichel commented 5 years ago

Well spotted!

tpjnorton commented 5 years ago

wow!

fabienrohrer commented 5 years ago

I investigated more the lidar issue. It's not related with depth buffer: Lidar and RangeFinder are using shaders. The content is correct, but is obfuscate by some object:

depth

The problematic object is this black sphere:

sphere

Removing the sphere let the things work smoothly.

result

I will check tomorrow if it's not a near issue. I'm close to provide a clean fix.

fabienrohrer commented 5 years ago

This sphere is almost coplanar with the lidar near plane (at 0.005 millimeters). Probably that the depth precision affects the detection of this object. There is no issues with back faces. So increasing the near plane or changing the position of the sphere are clean fixes.