- Home /
How to use a non-screen-sized RenderTexture?
It is obviously quite trivial to create a non-screen-sized RenderTexture in unity pro. However, the problem that I have is that when I render to it using either Graphics.DrawTexture or Graphics.DrawMeshNow, I wind up with scaling based on the (presumably) transforms of the current camera.
For instance, if my RenderTexture is 1024px wide, but my screen is 2048px wide, then any content that I render to the RenderTexture gets smashed in width by half. Something that should have been rendering into a square of 0,0,64,64 would instead render as 0,0,32,64 assuming that the height of the texture and screen were the same.
Added details:
This is for 2D games, so I'm using an orthographic camera and am rendering essentially just textured quads.
I am able to correct for the incorrect scaling by simply scaling the object back up by screenwidth divided by texturewidth. However, that's not really ideal for anything except shadows because it causes blurring and is not remotely pixel-perfect like other draws.
It seems like this should be simple. What am I missing?
I've got the same issue - did you find a better solution than scaling?
Nope, never did find an answer to this one other than scaling -- which definitely leaves lots of artifacting. However, what you can do is render a screen-sized texture and then just have a lot of transparent pixels to work around the problem.
Answer by cmberryau · Sep 03, 2013 at 08:34 AM
I had a similar problem where all created rendertextures would inherit the AR of the main camera - this was fixed by changing the aspect property to 1 (our rendertextures were all square).