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

Added render order to material #188

Merged
merged 8 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tutorials.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Ignition @IGN_DESIGNATION_CAP@ library and how to use the library effectively.
8. \subpage simple_demo "Simple demo"
9. \subpage text_geom "Text geom"
10. \subpage particles "Particles"
10. \subpage render_order "Render Order"
ahcorde marked this conversation as resolved.
Show resolved Hide resolved

## License

Expand Down
14 changes: 7 additions & 7 deletions tutorials/21_render_order.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
\page render_order Render order

This example shows how to set the render order for coplanar poligons.
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` where the pixels from the two polys compete for the same screen pixel. As you
can see in the following image:
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:

@image html img/render_order_bad.png

The method `SetRenderOrder` in the Material class allows avoiding this issue. The higher value will
be rendered on top of other coplanar polygons.
The method `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.

In the `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 (`SetRenderOrder(3)`).

\snippet examples/render_pass/Main.cc red material
\snippet examples/simple_demo/Main.cc red material

\snippet examples/simple_demo/Main.cc white material

As you can see in the following image the z-fighting issue is resolved.
As you can see in the following image the depth fighting issue is resolved.

@image html img/render_order_good.png

Expand Down