Sorting in a 2D Topdown Game

How would i do the sorting so that my player can go behind trees and so on. And i would still want to be able to use shaders like a wind shader on the trees e.g… I’ve seen i would need multiple spritebatches for shaders. But i don’t know how to YSort the trees and the player then. I use BackToFront Sorting right now and if i set the depthstencil to default it works, but then i need to alpha clip the textures which looks ugly with my textures because they are hand drawn. Any ideas on what i could do? I already tried immediate rendering too but then sorting every object is very expensive the way i came up with. and then nothing would be batched, so the performance then is quiet bad. Does somebody have any idea on what i could do?

something you could do is create a dictionary of lists where the keys in the dictionary are something like “buildings” and “trees” and “characters”, then iterate over the dictionary and render the foremost objects last, and objects in the background first. something like a priority queue

Using a ‘BackToFront’ or ‘FrontToBack’ SpriteSortMode is the correct approach (respects layerDepth values passed when calling SpriteBatch.Draw).

I don’t understand what issue you’re having with “alpha clip”. Do you mean you need to change BlendState?

Thanks for the response guys! With alpha clip the edges of my textures are not smoothed anymore, which makes them look bad and i wanna avoid that if i can. Changing the blendstate didnt change this for me unfortunately. Thought i could maybe somehow sort them in different batches without having the transparency clip the objects below away. Idk why it works within batches but not when they are in seperate batches.
@sentryarchlabs Thank you, but i think the transparency problem persists then.

I think for now i do everything in one batch and try to do without shaders completely.