I am having some problems with alpha sorting when depthwrite is false. I am using the technique below with two ribbon trails. They are sorted correctly on their own but not together. Is there anyway to fix this or manually sort them? The only way I found to move each point slightly in Z enable the depthwrite, but that at some point would make it too close to the camera.
Thank you. I am trying to switch to using depth-test and add offset in the GLSL shader, but it doesn’t seem to work with gl_Position.
I added the offset below to the Unlit shader: gl_Position.z *= 0.99;
And I changed the technique to use depth test.
Sorry what I meant is that I have set one batch to: gl_Position.z *= 0.99 and kept the other as it is. But I got similar problems to the video above. Any other ways of sorting manually or disabling anything else that might affect the sorting of the batches other than the depth. It looks like something else might be overwriting the sorting.
The default sorting of the Ribbon Trail is correct when the depth test is disabled but only for the same batch. I would like to sort multiple batches of Ribbon Trail as if they were one the same batch in order of placement. Any new polygon should be on top of the previous polygons no matter which batch they are from.
Then you still have mostly the same problem with your shader.
If you multiply Z by 0.99 for the whole batch it’s going to move the whole batch, not parts of it, so it will be impossible for them to tangle/intermix as the whole thing is moving instead of specific segments (unless there’s some selection code you didn’t show).
Try multiplying Z by the output of any 2d noise function (keyed on X and Y) and see if that gets you at least somewhere.
I was just testing one batch with 0.99 the other with 1.0. I also tried some negative on one batch and positive on another. This is just to test if this approach would work at all. If I can get this to work I will add an attribute to each polygon and multiply it as an offset in the shader. What works for sure if just moving the actual point position before creating the polygon in the update loop, but at some point it would get too close to the camera.