cyberbotics / webots

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

Wrong sphere texture mapping in WREN #281

Closed stefaniapedrazzi closed 5 years ago

stefaniapedrazzi commented 5 years ago

Describe the Bug The texture mapping for a sphere displayed in Webots doesn't match the X3D texture mapping.

Steps to Reproduce

  1. Go to 'textured_shapes.wbt'
  2. Export HTML5 model
  3. Open the exported model in a browser
  4. The texture mapping in the browser and in Webots for the sphere are different in the top and bottom area

Expected behavior The sphere texture mapping in WREN should match the X3D one.

Screenshots Webots: textured_shapes_webots x3dom: Screenshot from 2019-03-14 10-28-41 view3dscene: textured_shapes_view3dscene

fabienrohrer commented 5 years ago

The fix should probably target R2019b instead, because it may have consequences for the users to fix the Webots mapping. Is this true?

stefaniapedrazzi commented 5 years ago

Yes, i will target 2019b. I don't think that users will have to change anything in the texture mapping, but sensors can behave slightly differently.

stefaniapedrazzi commented 5 years ago

The mismatch comes from the different triangulation of the sphere:

sphere_triangulation

The WREN implementation (icosphere) is probably better as all the triangles are about the same size. But it doesn't match the sphere (uv sphere) used by X3D (x3dom) and THREE.js.

I checked in Blender and both primitives UV Sphere and Icosphere are available. If we want to keep the icosphere, then we have to export it as IndexedFaceSet and not as a Sphere geometry.

omichel commented 5 years ago

Yes, let's do this: export our Sphere primitive as mesh for THREE.js.

DavidMansolino commented 5 years ago

Linked to #254

stefaniapedrazzi commented 5 years ago

During the meeting we discussed to add a flag to the Sphere node specifying if the mapping/triangulation type: icosphere or uv-sphere.

The flag could be called "uv" or "ico"

omichel commented 5 years ago

I have a small preference for "ico".

stefaniapedrazzi commented 5 years ago

THREEjs has the IcosahedronGeometry that corresponds to the icosphere. So we could maybe use the Sphere node when exporting to x3d (not VRML) instead of the IndexedFaceSet.

stefaniapedrazzi commented 5 years ago

Fixed in #407