- Home /
Avoiding Distortion with Parallax Texture Offset
Hi everyone, we're working on a parallax background system at the moment. Using a perspective camera to have multiple layers of background images on planes, where I have the textures of all of them being offset in the X direction as the player moves. This works exactly as planned.
The issue is that we have textures larger than the planes- for longer levels- and when we apply the texture to the planes the texture distorts to fit the plane width. Is there a way to not stretch the texture to fit, so it acts as more of a mask for the texture? We want to try and avoid making the planes the same size as the texture/aspect ratio of the images and messing around with the distance from the camera to keep the images looking good.
I attached a couple of reference images. Ideally, when shrunk the plane shows the same amount of the texture as it did when it was larger instead of squeezing down to fit the smaller space. 

Any thoughts or direction would be helpful!
As I said in the post; "Is there a way to not stretch the texture to fit, so it acts as more of a mask for the texture? We want to try and avoid making the planes the same size as the texture/aspect ratio of the images and messing around with the distance from the camera to keep the images looking good." I'm not sure if I mislead you somehow with that, we want to know if there's a way to apply a texture without it stretching to fit the object for this parallax effect
What have you tried already that didn't work out? Did you check out the solutions other users have, such as: http://answers.unity3d.com/questions/233902/textures-stretch-on-wide-objects.html , http://forum.unity3d.com/threads/texture-stretch.119278/ , http://answers.unity3d.com/questions/775619/texture-stretches-when-tiled-in-editor.html , http://answers.unity3d.com/questions/361573/how-to-make-a-texture-tile-and-not-stretch.html ,
Answer by kru · Feb 28, 2015 at 06:33 AM
In order to make the smaller plane show the same texel density as the stretched plane, you're going to have to change the UV offsets and tiling properties of your background material. Select the material which is on the small plane, locate the X/Y offset and tiling properties. As you change them, you'll notice the image move and warp.
You'll want to write a script which can change these numbers for you as the camera moves around your level. The math isn't challenging, but it does take some thought. Get your script writer with the most confidence in his or her mathematics to Google around for parallax algorithm for a day.
Your answer