2
\$\begingroup\$

I'm making a game, and in part of it, the player uses a computer terminal. I want to draw to a virtual 640x480 screen with pixel precision, and then draw that "virtual screen" to the player's real screen. The end result will not be "pixel perfect" because 99% of people won't play the game at 640x480 -- and, in fact, I want to then go on and add further effects on top of this so it looks more like a CRT display -- but trying to figure out how to do pixel rendering in Unity has proven pretty difficult so far.

Basically I want to render something that looks like this:

example of what I want to render

onto the screen, where I draw all of the text characters myself (using Sprites? subsections of a Texture?), and then I want to render this "virtual screen" out onto the player's screen. I know RenderTextures are a thing, and maybe that's part of it? I've tried a lot of different things so far and got nowhere, hence why I'm posting here.

Sorry if this is too nooby of a question, I'm an experienced programmer who is relatively new to Unity.

\$\endgroup\$
  • \$\begingroup\$ One option to consider is to make one texture for each character. Don't draw individual pixels on the screen, draw pixels on the textures and then apply those textures. If you want those fancy CRT effects with curved, blurred texts in the corner, it's just a matter of bending the mesh a bit. \$\endgroup\$ – MSalters Jul 29 '15 at 10:02
2
\$\begingroup\$

You will want to use Texture2D.SetPixel or Texture2D.GetPixels and Texture2D.SetPixels if you want to blit sprites onto your texture.

You could render your sprites to a RenderTexture. It may be faster but until Unity5 it was a Pro-only feature (which I don't have) so I haven't experimented with it yet. You can't draw individual pixels on the GPU without a lot of complications though anyway, so if that is a requirement then you will need to use Texture2D.

For a 640x480 image, it should be sufficient to just do it on the CPU with Texture2D, even if you update it every frame.

\$\endgroup\$
1
\$\begingroup\$

I think Fuzzy Logic answer is best suited for your question (he got my +1), but i'd like to give a naif alternative. You can setup a bunch of Unity objects like quads, text, sprites (call all that TerminalStuff) and use a separate camera (call it terminalCamera) that capture the terminalStuff (perpendiculary). Then set the render output of terminalCamera to a texture In this way you can change your Terminal elements (like moving unity text objects to simulate scrolling text) to simulate terminal activity.

\$\endgroup\$
  • \$\begingroup\$ Thanks, this is the solution that I discovered on my own after posting this, but I will definitely investigate Fuzzy Logic's, too. \$\endgroup\$ – takua108 Jul 29 '15 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.