1
$\begingroup$

I am using this Kawase Blur, to apply blur onto my buffer. But I would like to apply this blur in an uniform way, no matter the distance of the objects from the camera.

I guess that I need to use the depth buffer but how should I change the offset according to depth ?

// offset : From 0 to number of pass    
float o = 0;
o += tex2D(tex, coord + (float2( offset + 0.5,  offset + 0.5) * texelSize)) * 0.25;
o += tex2D(tex, coord + (float2(-offset - 0.5,  offset + 0.5) * texelSize)) * 0.25;
o += tex2D(tex, coord + (float2(-offset - 0.5, -offset - 0.5) * texelSize)) * 0.25;
o += tex2D(tex, coord + (float2( offset + 0.5, -offset - 0.5) * texelSize)) * 0.25;
$\endgroup$
  • $\begingroup$ basically, you should divide the offset by the depth of the current fragment. this is akin to the transform that geometry goes through during perspective projection $\endgroup$ – Sebastián Mestre Dec 27 '17 at 3:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.