noggit3
noggit3 copied to clipboard
rendering: wrong render priority for m2 and possibly WMO
@skarnproject reported on 2017-02-03
M2 models (possibly WMO models too) are rendered in a kind of weird order. You don't see the issue normally when the model has no transparent surfaces. Textures containing alpha channel hide models behind themselves (you can see terrain, but not models through them) and sometimes are not rendered from both sides while being two-sided flagged (two-sided generally works for non-transparent surfaces). Might be blending mode related.
@DmitriyTolmachov added on 2017-02-07
Source of this issue is sorting. There is a general rule for drawing meshes. Opaque meshes have to be drawn in this order: nearest - first, farthest - last. While transparent meshes should be drawn in reverse order: farthest - first, nearest - last. So usually meshes are sorted depending on their distance to camera, and drawing is done in two stages: first all opaque meshes on scene are drawn, second all transparent meshes.