# Getting a sampler of the default rendertarget (null)

I've been working on a mod for "Duck Game" that adds dark levels like in Spelunky.

I read this guide on how to make shaders, but in my case I don't have access to the draw method and since the game isnt drawn in a rendertarget first I can't do the same blending as he did.

I wrote my own shader that sets the alpha based on the average color value, looks like this:

float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
{
float4 color = tex2D(s0,coords);
color.a = 1-((color.r + color.b + color.g)/3);
return color;
}


And it looks like this in game:

I personally isn't satisfied with how this looks but to make it like in the tutorial (which is way better) I would need to get the sampler of the main draw (with current rendercontext set to null).

Is there a way to get the pixels on screen so that I can use it like in the tutorial?
I'll also accept answers with better ways of doing it.

• Could you explain exactly what is wrong with the picture please, not knowing what your game is meant to look like makes it hard for me to see the problem. – Thomas Mathieson Oct 13 '17 at 18:58
• what im trying to achieve: youtu.be/J1xr9kbQXKI I dont even think its possible tho – eim64 Oct 14 '17 at 8:53

Ok, so I'm not an expert in XNA, but provided it uses standard GLSL then you might be able to do:

if (color.a < cutoff)
{

clip(color.a-cutoff);