Hello,
I want to take a screenshot of an orthographic camera (which is not curently rendering).
I don’t do anything fancy, just create my render texture the size of my camera, make it the target texture and call camera.render(). Here’s the code:
private static RenderTexture m_RenderTexture;
private static void GenerateDocumentScreenshot(Camera cam)
{
int width = cam.pixelWidth;
int height = cam.pixelHeight;
m_RenderTexture = null;
m_RenderTexture = new RenderTexture (width, height, 24);
m_RenderTexture.isPowerOfTwo = false;
m_RenderTexture.useMipMap = false;
RenderTexture.active = m_RenderTexture;
cam.targetTexture = m_RenderTexture;
cam.Render ();
}
This works perfectly for any viewport with W >= 1 and H >= 1.
However, here’s the configuration I wish to take the screenshot with:
In this case, my screenshot will end up exactly like this:
The left half is exactly what’s in the center of my camera and the right half is complete trash. I checked my camera in game and it is rendering everything perfectly (it is not active) with everything in place.
The thing is that if I change W from 0.5 to 0.8, the screenshot will not have only half correct, but about 80%, which leads me to believe cam.Render() only renders up to W percent of the width and H percent of the height. Which makes no sense at all to me and looks like a bug.
Can somebody help me? Is this something I’m doing wrong or is it a thing of the Render() method or the even the renderTexture?
Thanks!