-1

How do you avoid stretching texture, rendered by the camera, when changing screen size?

For example, if I create a plane with material with a texture, rendered from the camera, the texture will be distorted, depending on smartphone screen proportions and orientation. How can I prevent that from happening, so that texture would always have the same proportions? Alternatively, how do you make it adapt to changing screen sizes?

Here is an example:

In these screenshots, there are 3 objects - cube, plane, and camera. The camera is looking at the cube and rendering a texture. Rendered texture applied as Albedo texture for material of the plane. So the plane works like a TV, showing us an image from the camera.

Then you can see that if I change the size of the window in Unity, the texture will deform. So if I make window wider the texture stretches, and if I make the window narrower, the texture will shrink. enter image description here enter image description here

javathunderman
  • 1,074
  • 2
  • 13
  • 31
Rumata
  • 1,027
  • 3
  • 16
  • 47
  • It's quite difficult to understand whats happening in those screenshots. Could you please explain it in a better way? – Sushant Poojary Jul 29 '17 at 09:44
  • @SushantPoojary Sorry if confused you. On the screenshots, there are 3 objects - cube, plane, and camera. The camera is looking at the cube and rendering a texture. Rendered texture applied as Albedo texture for material of the plane. So the plane works like a TV, showing us an image from the camera. Then you can see that if I change the size of the window in Unity, the texture is deforming. So if I make window wider the texture stretches, If I make the window narrower, the texture shrinks. – Rumata Jul 29 '17 at 12:08

1 Answers1

0

It looks like you have fixed UVs on the plane, or at least a fixed aspect ratio for the UVs, so when the screen aspect ratio changes, the result is that the texture looks stretched in the plane.

You should be able to adjust the UV values used when applying the texture to the plane so they remain in proportion to the screen aspect ratio which is simply Screen.width / Screen.height.

gtp
  • 86
  • 4
  • Thank you, but how can I adjust UV values? – Rumata Aug 09 '17 at 13:21
  • Actually, I'm a little bit confused. Can you send screenshots of the settings for the Camera rendering into your RenderTexture, the RenderTexture itself, and the material you have set on the plane? – gtp Aug 09 '17 at 19:25