3
\$\begingroup\$

What I want is basically: A way to blur every object/sprite on the scene, but have a "blur-free" circular zone, that can move. And everything that's behind that circular zone won't have the blur effect applied to it.

In a 2D mobile game, how would I do that, especially in a way that's not too heavy, performance-wise(if possible).

And if it's not possible to do that in a way that won't completely destroy my performance, I also have those sprites already "pre-blurred" so maybe there's a way to have both blurred and "unblurred" objects at the same position, and only draw the right parts of them as they go through the scene and reach the blur-free zone. If there's a way to do that, that'd also help immensely.

Thanks for your time.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Do you want a hard cut-off or a gradual transition from crisp to blurred? \$\endgroup\$
    – DMGregory
    Commented Jan 21, 2016 at 4:55
  • 1
    \$\begingroup\$ Blending between the normal and pre-blurred sprites dynamically will almost certainly be faster than doing the blur at run-time, even if it means drawing the entire scene twice. \$\endgroup\$
    – MooseBoys
    Commented Jan 21, 2016 at 8:32
  • \$\begingroup\$ A hard cut-off is fine. Whichever is simpler to implement. @MooseBoys yeah, that's what I thought. But how would I go into doing that? With the little I know about it, I think this would be like a mask or "inverse mask". But how to do it on all my scene's sprites without it tanking the fps is the problem. \$\endgroup\$ Commented Jan 21, 2016 at 11:47

1 Answer 1

1
\$\begingroup\$

I managed to solve my problem. I used the shaders from this post: http://forum.unity3d.com/threads/sprite-renderer-mask-on-specific-sorting-layer.356824/#post-2310992

And a simple grey circle for the "blur-free" circular zone. The pre-blurred sprites used the "Stencil Draw In Mask" one, the regular sprites used a shader that was the same as the above, but with Ref set to 1, and the grey circle used the Stencil Mask. While my draw calls doubled, as there was 2 times the amount of objects on scene, the performance impact wasn't as great as if I used a shader to blur the entire scene.

Thanks for your attention.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .