Skip to content

BF: Fix an issue with overlay depth-sorting in the 3D view

Paul McCarthy requested to merge paulmc/fsleyes:bf/depth-3d into main

The 3D view uses a shader program which takes as its input a set of 2D RGBA textures and depth textures, one for each displayed overlay. This shader program sorts the inputs according to their depth, ensuring that each fragment is correctly ordered by its depth in the final rendered scene. However, the shader was not considering the possibility that some fragments could be transparent when sorting the depth values, which was resulting in artifacts in certain situations.

This shader was also using an unstable sorting algorithm, which meant that the sorted order of fragments with the same depth value was not consistent. This algorithm has been replaced with a stable algorithm (insertion sort), meaning that the order of fragments with the same depth will be preserved after sorting (and their display order can be changed by re-ordering the overlay list).

Edited by Paul McCarthy

Merge request reports