This thread and the attached example code may be helpful - you can switch off certain elements, render the depth texture, then switch the elements back before color is rendered.
This thread and the attached example code may be helpful - you can switch off certain elements, render the depth texture, then switch the elements back before color is rendered.