Sign in to follow this  
Surgura

XNA(C#) and Shaders(Effects) - draw an empty screen with shader

Recommended Posts

Hey,

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:
[code]
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[i] = new Color(color.ToVector3());
}

// Set the color data for the texture
tex.SetData(colors);
}
[/code]
This incredibly slow though. Edited by Surgura

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this