Naming of `reverseStablePainterSort` but it seems to actually be painter sort, not reverse?

From the docs, setTransparentSort is by default set to reversePainterSortStable.

.setTransparentSort ( method : Function ) : undefined

Sets the custom transparent sort function for the WebGLRenderLists. Pass null to use the default reversePainterSortStable function.

But isn’t this incorrect? Normally you would want Painter Sort for proper blending, which is sorting them polygons from far to near (like how a painter paints). Far to near is how Wikipedia also defines Painter Sort.

I went and tested with THREEjs and it _does_ look like polygons are sorted from far to near, not near to far.

In this example, the RED plane is sorted in front of the GREEN plane. Mesh 0 in the sorted array is the GREEN plane and, Mesh 1 in the sorted array is the RED plane. So… back to front, with a higher z depth value coming first. Log lines shown occur right after the WebGLRenderList .sort() function

So it seems to function like what we’d call “Painter Sort”. So why then is is called reversePainterSortStable?

I feel like there’s some confusion here on my part and that I’m missing something…

1 Like

I agree. I think the docs sound wrong/misleading.

@Mugen87 any opinion on this?

TBH, I’m not sure how the existing naming convention was defined but according to the Wikipedia article the names for the opaque and transparent sort functions should indeed be reversed.

Opaque pass renders near to far, transparent far to near since that is required for blending.