here is my question in two words :
how to apply a depth of field filter effect that work fine with transparent materials ?
here is the director cut version of this question :
I use 2d filters based on the depth information, retrieved from
On a lot of objects in the game, I applied custom gl shaders that give the ability to define material properties in game. Among theses properties one can define the transparency.
my issue is that I’m unable to keep the right zdepth information when using these shaders : bgl_DepthTexture gives no information at all, whatever the .a value of the mat was, about the ‘pixel zdepth’ and returns the next zdepth of the opaque object in the background.
two exceptions I know, where the material zdepth is still available :
mat defined as alphaclip + transparency enabled
mat defined as opaque + transparency disabled (obviously)
but I can’t use alphaclip in my case (several layers of objects) I need something like
opaque + transp enabled or
alphablend + transp disabled
add mode also work… (as alphablend to my point of view, is there a description somewhere, I didn’t found the particularity of it)
again, these modes work as I use GL shaders, not blender materials.
zdepth inverse or zdepth offset options don’t seem to do anything (and what about the ‘scanline only’ notice ? I don’t understand)
I was thinking to different tricks to make it works, but well…
. tweak the bgl_DepthTexture value by near pixel color comparison (same or near color = same depth and other depth tests before)
. find the right blender mat configuration (something like ‘ok do the job about transparency in bgl_RenderedTexture, but don’t change anything about the zdepth values in bgl’)
thanks for any feedback / pointers / tricks, jerome