This will be a quick one. Light Path Expressions offer a lot of flexibility over the AOV’s you would like to pass off to Compositing. Most modern path tracing render engines like Arnold, RenderMan, Blender’s Cycles, VRay, etc. have support for it by now. With LPE’s you can split pretty much any light path you desire, which brings me to the solution to this first problem.
Usually when you have a refractive object in your scene everything that is being refracted lands in 1 single AOV (usually called refraction, transmission, or something along those lines).
So if I have a scene like this…
…and my diffuse like this:
As you can imagine tweaking the diffuse in comp will be a bit of a cumbersome task as the color of the teapot for example is in 2 different AOVs. Luckily what you can do is to modify the default LPE’s a bit to include transmissive paths in other AOVs like diffuse, specular, subsurface scattering, etc.
I won’t go into too much details of how it works. If you want a proper overview on LPE’s you can read up on them HERE.
The default diffuse_direct looks like this usually:
Which simply means the lightpath Camera (C) -> Diffuse Reflection event (<RD>) -> Light Source / Emissive Object ([<L.>O])
To make all the light paths include refraction events as well you can tell the light paths to look for zero or more transmissive specular events before evaluating the rest of the light path.
So if you modify the diffuse_direct like this:
As a TL;DR here is the stuff I personally like using: