Jump to content
  • Advertisement
Sign in to follow this  
Surgura

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

This topic is 2126 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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:

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. Edited by Surgura

Share this post


Link to post
Share on other sites
Advertisement
You can just use GraphicsDevice.Clear to efficient clear a render target to a specific color.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!