I have a question regarding the use of shaders in XNA(C#).
What I am trying to achieve is create a window sized grayscale texture which I will use later as a lightmask.
My shader works fine, It calculated the right gray value for each pixel, but this only works if I draw a black texture which has the size of my window. This is only the case if I render to a texture, rendering directly to the screen works without drawing anything.
So my question is: How do I achieve the effect when drawing directly to the screen, but now rendered to a texture?
Thanks in advance,
Aart Stuurman
Edit:
I think my question is a bit vague. What I actually try to right now is create a render target with a certain width and height and make it completely black. If anyone can tell me how to do this, I would be very grateful.
I also just noticed this is not really the right section for such a question. Sorry about that.
Edit2:
My personal try was this:
public void EmptyTexture(Texture2D tex, Color color)
{
// Create a color array for the pixels
Color[] colors = new Color[tex.Width * tex.Height];
for (int i = 0; i < colors.Length; i++)
{
colors = new Color(color.ToVector3());
}
// Set the color data for the texture
tex.SetData(colors);
}
This incredibly slow though.