Hello Guest

Author Topic: Depth sorting, pespective camera, and Shader Cutout vs Shader Blend  (Read 4232 times)

cjke.7777

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
I know there are a few posts already on the forums, but I can't seem to straighten it out, and I'm pulling my hair out!

As you can see from the images below, the Cutout shader works perfectly, but the blend does not. With the blend shader I get the depth weirdness, as others have noticed in their own projects. I understand that the blend shader takes the center of the sprite and sorts depth based on that (or there abouts).

"Why not use cutout?" I hear you shout? Well I need alpha/opacity control (such as the glass, but also the ability to turn down the opacity via the Color property of the sprite).

Sooooo is there a Shader Cutout that supports tint/alpha, while keeping the beauty of it's handling of depth?
Also is the explanation anywhere around the tk2d shaders and what is for what?
Also is there a reason that the cutout way of handling depth can't be applied to the blend shader? (I'm sure there is a logical reason, just curious)

Shader - Cutout ==  :)



Shader - Blend ==  :(



unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Depth sorting, pespective camera, and Shader Cutout vs Shader Blend
« Reply #1 on: December 14, 2013, 03:22:49 pm »
The cutout shader uses the gpu depth buffer, which means that sorting is automatic. Its can't be semi transparent, so it can treat the solid bits as, well, solid.
Transparent shaders on the other hand need to be sorted properly, as they can't use the depth buffer.

If you're on unity 4.3, you can use order in layer to sort your sprites consistently regardless of the shader its using.

cjke.7777

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Depth sorting, pespective camera, and Shader Cutout vs Shader Blend
« Reply #2 on: April 01, 2014, 02:26:54 pm »
Sorry about the looooong delay. Yep that worked for me, thanks again