- Home /
How do I correctly use a RenderTexture on a GUITexture?
I rendered a chat log in a GUITexture with a regular camera, cleared to black background color, and the text was crisp and clear. I moved on and set up a RenderTexture and textured a cube with the chat log, for some neat 3d effects, and the text showed up, allthough somewhat blurry but that's expected since I moved to a perspective view and the cube moves around. My solution to that problem was to find the "resting state" of the cube and when it was aligned i simply removed the cube and rendered a regular GUITexture with the same RenderTexture. As expected the chat log shows up but it is not as crisp and clear anymore.
I've tried to set up the connections both via the editor and in code. I've tried to set the size of the TargetTexture to match the dimensions of the screen, the nearest (rounded up) power of two and some test value to see the difference but I can't seem to find a solution.
Obviously one would think I should just render the original GUITexture directly and skip the TargetTexture alltogether but I really need this functionality, especially for cases where there's other things than a chat log that needs rendering.
Any guidance in this matter would be highly appreciated. I've search around the Answers section and other places on the interweb but can't seem to find a close enough match on my problem. Surely I'm just missing something simple but I just can't figure out what.
Thanks for your time folks!
(Here's a screenshot of the clear crisp text to the left and the TargetTexture connected one to the right.)
Answer by kx00 · Mar 27, 2013 at 04:01 PM
So, I found a way around the problem and thought I might share it in case someone should find it useful or would like to discuss it further (not that my problem has started a discussion but who knows, mayby it will ;)).
The way it works now is that when the cube stops spinning the cube is immediatly removed and its scale and translation is converted into normalized screen coordinates and applied to the rendering camera's 'rect' instead. If the chat needs to spin away again I simply reenable the cube, set the cameras render texture and start to rotate. This gives a somewhat blurry chat during transitions but a crisp and clear one when it's used.
Happy coding!