gazebosim / gazebosim/gz-rendering

OGRE2: Meshes with odd number of negative scale elements are rendered with inverted normals

Open
#267 2 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
C++
Stars
81
Forks
90
Avg merge
1d 13h
Merged PRs (30d)
10

Description

## Environment
* OS Version: Ubuntu 18.04
* Source or binary build: Binary, 4.6.0

## Description
* Expected behavior: If a visual mesh has `-1 1 1` it should be rendered just as a mirrored version of the scale-less version.
* Actual behavior: Backface culling culls the wrong faces from the scaled mesh, making it partly transparent. This hints at inverted normals. With OGRE1, this is okay and the scaled meshes are solid. With OGRE2, the scaled meshes behave as explained.

## Steps to reproduce

1. Run the attached SDF world in Ignition Gazebo 4 with OGRE 2 renderer.
2. Open an Image display to verify this issue affects both GUI camera and sensors.
3. Examine the scene. Visuals 1 and 4 are rendered correctly (you can't see the miniature cube inside them), while visuals 2, 3 and 5 render half-transparent showing the little cubes that should be hidden inside them.

Here's the test SDF:

test.sdf:

```



ogre2



true


0 0 1 0 0 0


https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Number1/tip/files/meshes/number.dae
1 1 1




0 0 1 0 0 0


0.05 0.05 0.05


1 0 0 1
0.8 0.8 0.8 1
0.8 0.8 0.8 1




0 3 1 0 0 0


https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Number1/tip/files/meshes/number.dae
-1 1 1




0 3 1 0 0 0


0.05 0.05 0.05


1 0 0 1
0.8 0.8 0.8 1
0.8 0.8 0.8 1




3 0 1 0 0 0


https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Number1/tip/files/meshes/number.dae
1 -1 1




3 0 1 0 0 0


0.05 0.05 0.05


1 0 0 1
0.8 0.8 0.8 1
0.8 0.8 0.8 1




3 3 1 0 0 0


https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Number1/tip/files/meshes/number.dae
-1 -1 1




3 3 1 0 0 0


0.05 0.05 0.05


1 0 0 1
0.8 0.8 0.8 1
0.8 0.8 0.8 1




3 6 1 0 0 0


https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Number1/tip/files/meshes/number.dae
-1 -1 -1




3 6 1 0 0 0


0.05 0.05 0.05


1 0 0 1
0.8 0.8 0.8 1
0.8 0.8 0.8 1



6.0
-5 3 5 0 0.5 0

1

640
480
R8G8B8


0.02
300





```

## Output

This happens with all kinds of meshes, simple or complex, Collada or STL. Whenever there is an odd number of negative scale elements (so 1 or 3), the wrong faces are culled. A colleague hinted that this might have something to do with (non-)right-handedness of the scaled coordinate system.

The SDF spec doesn't mention anything about this being a desired behavior in the `` docs.

![Snímek z 2021-03-08 22-13-15](https://user-images.githubusercontent.com/182533/110382708-92e82a00-805b-11eb-8e3c-45c899bc142e.png)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided test.sdf in Ignition Gazebo 4 with the OGRE2 renderer, using both the GUI camera and a sensor. Compare meshes with one, two, and three negative scale elements and inspect backface culling. Done means oddly mirrored meshes render solidly with the correct faces visible, matching the expected behavior described for OGRE1.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.