In my last game, we used an alternative to occlusion queries for this problem, but it requires that you're able to bind your depth-buffer as a readable texture -- I don't know if XNA allows that, but it's possible in D3D9, so maybe.
It doesn't. You'd have to manually render depth to a render target.
I have deferred shading so i got depth buffer ;)
First we calculate on the CPU the expected depth value of the light source, and it's screen space position:
I done that part already to show flare w/o occlusion test:)
Now the 16x16 render-target contains 256 boolean values, indicating whether the light is in front or behind that pixel nearby it.
If we now generate mip-maps for this render-target, then mip-level #4 will be a 1x1 texture, containing the percentage of visible pixels.
: O That's a very clever approach. I am going to work with this tomorrow.
It's kinda working. Just needs some tweaks. Thank You for help