This example shows how to set the render order for coplanar polygons.
The material API allows changing the render order. When polygons are coplanar, you can get problems with
depth fighting (also known as z fighting) where the pixels from the two polys compete for the same screen pixel. As you can see in the following image:
SetRenderOrder in the Material class allows you to avoid this issue. The higher value will be rendered on top of other coplanar polygons. This method will set the depth bias value of objects that the material is assigned to.
simple_demo example you can find two materials with different render orders. The red material (
SetRenderOrder(3)) has a higher value than the white material (
As you can see in the following image the depth fighting issue is resolved.
You can set this in your SDF file including in the material tag a new tag called
render_order with a float value:
Clone the source code, create a build directory and use
make to compile the code:
Execute the example: