• Advertisement
Sign in to follow this  

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

This topic is 1943 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


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

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.

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

This incredibly slow though. Edited by Surgura

Share this post

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

  • Advertisement