Infinite plane background

Lautaro Source

How would i go about creating as a background for a 3d scene a plane with a texture that stretches into the horzon? I have tried a skybox but i think a skybox will also be needed "behind" the infinite plane.



answered 1 week ago Ugur Tufekci #1


 using UnityEngine;

    using System.Linq;

    using System.Collections.Generic;

    public class InfiniteScrolling : MonoBehaviour


        public float speed;

        private List backgroundPart;

        void Start()


            backgroundPart = new List();

            for (int i = 0; i < transform.childCount; i++)


                Transform child = transform.GetChild(i);

                if (child.GetComponent() != null)





            backgroundPart = backgroundPart.OrderBy(t => t.position.x).ToList();


        void Update()


            transform.Translate(Vector2.right * Time.deltaTime * speed);

            Transform firstChild = backgroundPart.FirstOrDefault();

            if (firstChild != null)


                if (firstChild.position.x < Camera.main.transform.position.x)


                    if (firstChild.GetComponent().IsVisibleFrom(Camera.main) == false)


                        Transform lastChild = backgroundPart.LastOrDefault();

                        Vector3 lastPosition = lastChild.transform.position;

                        Vector3 lastSize = (lastChild.GetComponent().bounds.max – lastChild.GetComponent().bounds.min );

                        firstChild.position = new Vector3(lastPosition.x + lastSize.x, firstChild.position.y, firstChild.position.z);









public static bool IsVisibleFrom(this Renderer renderer, Camera camera)


        Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);

        return GeometryUtility.TestPlanesAABB(planes, renderer.bounds);


Also link from article :

answered 6 days ago zambari #2

It depends whether you need to have an actual geometry that will be seen from close up - if not, you can bake it into the skybox.

In some cases (i.e. when the user has stereoscopic display on their head) you will need to have actual geometry.

Its not exactly clear from your question if you want to create a 'floor' or a 'wall', but in both cases I would link it with player position somehow. A floor could follow players X an Z, while a 'wall' could be made a child to the camera, this way it would never leave the viewport.

Skybox would still be the cheapest by a significant margin, we can give more advice if you provide some additional information. i.e. what are you trying to achieve

comments powered by Disqus