Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Aart   Members   -  Reputation: 213

Like
0Likes
Like

Posted 23 November 2012 - 04:30 AM

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

        // Set the color data for the texture
        tex.SetData(colors);
    }
This incredibly slow though.

Edited by Surgura, 23 November 2012 - 09:16 AM.


Sponsor:

#2 MJP   Moderators   -  Reputation: 10637

Like
1Likes
Like

Posted 24 November 2012 - 12:56 AM

You can just use GraphicsDevice.Clear to efficient clear a render target to a specific color.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS