I have one terrain object in my game and I have "stages" which zooms the camera out. Now, what i want is to adjust the tiling of textures on my terrain, when the camera zooms out to a new "stage".
Is it possible to adjust the tiling at runtime?
Cheers.
It should be possible by setting the texture scale for the terrain shaders. I will try it later and answer your question.
Ok, this is a try. I'm not writing this fully for you, but you could try something like this:
Add an extra `MonoBehaviour` class to your terrain gameobject
in the `Update()` method, get the renderer from the terrain component (see example)
foreach `Material`: `mat.SetTextureScale("name: like _Scale probably?", new Vector2(someFormula));`
You can get the main camera with: `Camera.main;`
Example, not tested and more like pseudo-code:
public class NewBehaviourScript : MonoBehaviour
{
// Use this for initialization
void Start () {}
// Update is called once per frame
void Update () {
// get the materials from the terrain
Material [] ms = this.gameObject.GetComponent<Terrain>().renderer.materials;
Camera main = Camera.main; // get the main camera
// set texture scale each frame,
//because the camera will probably change each frame
foreach (Material m in ms)
{
m.SetTextureScale("...", new Vector2(someFormula));
}
}
}
I am not certain about the name of SetTextureScale, because it depends fully on the shader it uses. I am also uncertain about just saying: `GetComponent().renderer`. Don't know if that works. But it's worth a try.
It should be possible by setting the texture scale for the terrain shaders. I will try it later and answer your question.
– efge@Bablo: Biggest issue is: Is your Terrain a custom terrain or is it the unity
– MarnixTerrainclass?It is a normal unity terrain. What do you mean by custom terrain? Like a custom 3d-model?
– anon25233549