Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Bablo · Apr 11, 2011 at 01:25 PM · terrainruntimetiling

Adjusting terrain texture tiling.

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.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image efge · Apr 11, 2011 at 01:58 PM 1
Share

It should be possible by setting the texture scale for the terrain shaders. I will try it later and answer your question.

avatar image Marnix · Apr 11, 2011 at 03:00 PM 0
Share

@Bablo: Biggest issue is: Is your Terrain a custom terrain or is it the unity `Terrain` class?

avatar image Bablo · Apr 12, 2011 at 09:57 AM 0
Share

It is a normal unity terrain. What do you mean by custom terrain? Like a custom 3d-model?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Marnix · Apr 11, 2011 at 03:11 PM

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<Terrain>().renderer. Don't know if that works. But it's worth a try.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to make trees in a terrain transparent in runtime? 0 Answers

lowering Terrain at run-time, C# 0 Answers

Paint Terrain Texture From Vector3 List 0 Answers

Modify a mesh at runtime 0 Answers

Make a simple tree 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges