- Home /
How can I tile a texture on a Skybox?
My goal is to have a regular grid displayed on the skybox. The box is stationary and the camera can rotate around inside it, but instead of being seamless sky it actually looks like a box due to the grid.
I've created a texture that I want to tile across each face of the box, but the tiling settings for the material do not work when I choose the RenderFX/Skybox shader.
Tiling does work with the default Diffuse shader, however when this material used as a Skybox only the front and back faces of the box are rendered (since its not actually a skybox material).
Any suggestions? I'm using Unity 3.3.
If I'm going to have to write my own shader anyway, would it be better to do without the texture entirely and define the grid programatically?
Answer by noradninja · Mar 22, 2011 at 12:05 PM
A skybox texture more or less is always projected at the same distance from your character. That way when you move, it looks infinitely far away, like a real sky.
Knowing this, you could cheat and fake the effect, since we also know you can't really tile the texture on a skybox (each of the skybox cubemap textures makes a side).
What I would do is make the tiling texture I wanted, then create a plane and a camera in Unity. Rotate the plane so it faces the camera object. Put the plane on it's own layer, and set the camera you made to only render the layer the plane is on. Scale the plane so it fills the viewport, and make the plane child to the camera that renders it.
Now make that whole assembly a child of the Main Camera. Set the Main camera to render everything BUT the plane layer.
Apply texture to plane, tile as needed.
Now, when you move, the plane will appear to remain stationary while the player and environment will move accordingly. Your plane will always appear to be equidistant from the camera, and you will overcome some skybox limitations. Use multiple planes with some scripting and you can do stuff like fake 2D parallax scrolling effects too!
It's also sometimes a good Idea to just make an inverted cube in your 3D program and use that ins$$anonymous$$d. make it move to the position of your player and not rotate to get the whole "skybox" thingy as noradninja describes. A vertex lit shader set to black in diffuse and white in emissive is pretty good.
"we also know you can't really tile the texture on a skybox"... why not? I realize each texture makes a side of the skybox, but there should be no reason I cant tile a texture onto each side, as demonstrated by using a tiled diffuse material for the skybox.
Your answer
Follow this Question
Related Questions
Shader Tiling Texture Overlapping between X and Z Axes 0 Answers
Projector + custom fragment shader = endless texture draw 2 Answers
Custom skybox Shader uv issue, skybox texture stretching along one axis. 0 Answers
Why not tiling on Shader (Sprite/Diffuse)? Unity 5.4.1 f1 1 Answer
What's the syntax for creating a skybox with a script? 2 Answers