Search Unity

How to draw stuff on a texture

Discussion in 'General Graphics' started by NaBUru38, Sep 10, 2015.

  1. NaBUru38

    NaBUru38

    Joined:
    Jan 26, 2014
    Posts:
    12
    Hello, I have experience with FBOs in OpenGL. I clear an FBO (or not), I draw images, texts, lines, circles, etc on it, and then I draw it somethere on the screen.

    I need the same, but instead of drawing the texture on the sceen, I want to apply it on an object. I won't redraw the texture every frame, so I need it to be persistent.

    RenderTexture looks like nothing like I want. Also, I've read that Texture2d.SetPixels() is very slow, and it wouldn't let me draw lines or circles.

    Any suggestions? Thanks!
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    Why don't you want a render texture? You can clear them and render to them just as easily as you can to the screen. You can put that render texture on a camera to draw what that camera sees, or you can call static functions from the Graphics class.

    You can use Graphics.DrawMesh(), Graphics.DrawTexture(), Graphics.Blit(), etc.

    Then you just use that texture in a material to put it on an object.
     
  3. NaBUru38

    NaBUru38

    Joined:
    Jan 26, 2014
    Posts:
    12
    Oh, can I do that with a RenderTexture? The documentation doesn't exactly mention it. Thanks, I'll check it.
     
  4. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    Yeah, unity graphics can be complicated and confusing. Computer graphics in general have a rough learning curve, but can become quick and powerful once you have the knowledge and practice.

    This page might give you some more info on RenderTextures... click around on some of the links to other useful functions (Like Graphics.Blit()) on this page too: http://docs.unity3d.com/ScriptReference/RenderTexture.html