Author Topic: DOF or blur by specific sorting layer order for Orthographic 2D game?  (Read 139 times)

Joey Lu

  • Guest
Hi, just purchased the Beautify 2, a great asset
One question, I'm building a 2D game in Orthographic mode, my understanding is that current DOF effect only works by z distance that orthographic doesn't actually have
Is it possible to achieve this effect by sorting layer order? or can I manually specify which layer to be blurred in different intensities? tks

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
Unfortunately that's not possible. The sorting layer is used internally during the transparent render pass in which all transparent objects are rendered. There's no injection points between one sorting layer and another, it's just a value that Unity uses internally to decide the order of the batches of sprites. So DOF can occur either before or after all transparent objects have rendered.
One could write a system that renders tranparent objects by groups, based on the sorting layer, to an off-screen buffer, performs certain kind of blur, and then compose those layers in the camera buffer. But that's not really a depth of field which computes the blur per pixel based on depth, but just a layered blur effect.






Joey Lu

  • Guest
tks for the reply, so if I need to blur different objects in different intensity, the best way is to add new camera for that dedicated layer and attach the beautify script to each of it and adjust blur effects? is this the correct way to achieve? tks

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5832
    • View Profile
You could try that, but instead of using DOF, just use the Blur effect under Artistic Choices section.