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 ABNielsen · Dec 08, 2014 at 08:25 PM · texturerenderclamprepeat

What's the difference between clamp and repeat textures?

By logic, setting a texture to "repeat" should repeat the texture. So why do I get no difference between clamp and repeat settings when I apply a texture to a cube and scale the cube? This feels like a very big oversight for a game engine if it can only "tile" textures on terrain, which is the only place I've actually seen textures tile correctly.

alt text

To illustrate my point, here is what the texture looks like when I scale a cube.

alt text

Here is what I want it to look like when I scale the cube.

Regardless of whether I have my texture set to repeat or clamp, I get the exact same result. So what is the difference, and how can I get my texture to work like example 2, and not like example 1?

right.png (104.1 kB)
wrong.png (85.1 kB)
Comment
Add comment · Show 1
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 ABNielsen · Jan 28, 2015 at 06:30 AM 0
Share

Hey, Guys! A new answer to this question: http://answers.unity3d.com/questions/361573/how-to-make-a-texture-tile-and-not-stretch.html from DevLurkin has a working answer and script. Give him all the kudos!

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by MrSoad · Dec 08, 2014 at 01:30 PM

Scaling an object does not change how the Texture is applied to that object.

To increase or decrease the tiling you have to change the texture tiling property in the Material. Clamp will stop tiling and just stretch the last pixel row if the texture tiling property is set to more than 1 in the x or y dimensions. Repeat makes it tile but only in accordance with the tiling property setting, not scale.

Comment
Add comment · Show 5 · 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
avatar image Owen-Reynolds · Dec 09, 2014 at 04:37 AM 0
Share

...and this is the way standard 3D modelling works. Unity just copied the way everyone else does it (which is good.) "Everyone knows" that stretching a wall stretches the texture.

Then, to emphasize, Repeat and Clamp say that if you have tiling, how should the extra textures look. So if you don't tile, they do nothing.

avatar image Bunny83 · Dec 09, 2014 at 05:02 AM 1
Share

Here is a good example of repeat and clamp wrapmodes. Note that those wrapmodes are actually how the hardware handles texture lookup in shaders. So it's nothing Unity has specifically copied but it's simply how our graphics hardware works.

The wrapmode applies for texture coordinates which are outside of the texture area (smaller than 0 or greater than 1).

Actually the hardware would support setting the wrapmode for the u and v axis seperately but most (high level) engines only set them as pair since in most cases you either need clamp or repeat on both axes.

avatar image ABNielsen · Dec 09, 2014 at 05:31 AM 0
Share

So in order to get the results I want, I would have to add a script to every object that manually changes the wrapmode on the individual uv's?

avatar image Owen-Reynolds · Dec 10, 2014 at 12:52 AM 0
Share

Just look up $$anonymous$$aterials and tiling. That will do what you want, not Clamp and Repeat modes.

avatar image ABNielsen · Dec 10, 2014 at 01:19 AM 0
Share

$$anonymous$$aterial tiling does not give me the result I want, not by a long shot.

avatar image
2

Answer by Owen-Reynolds · Dec 11, 2014 at 07:22 PM

Ah...looked at that second "what I want" picture again. It can't be done, not by using the Unity cube and changing settings. Asking about Repeat/Clamp was just confusing the issue.

The rule for 3D models is, when an object stretches, the texture stretches. You're wanting the system to change that to "when an object stretches, the texture tiles more." That makes sense. It's called planar-mapping. But it takes a special set-up this cube doesn't have. And it won't track the model (if you did get a different cube to look this way, then changed size, the texture would still just stretch/shrink.)

In 3D modelling, objects are unwrapped a certain way, using a certain number of materials. The Unity cube has one material, and is unwrapped so the entire texture is pasted 1x1 on each face. Since it uses one material, you can only set the tiling on them all the same way. In other words, you can make the right side tile 1x2, the way you have it, but then every face will tile 1x2.

One way would be to make/find a new cube, using three materials (for each pair of aligned faces.) Three materials means you can supply three tilings. Or, could just use 3 small cubes (if the match is correct, they will be seamless.)

Comment
Add comment · Show 3 · 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
avatar image ABNielsen · Dec 11, 2014 at 08:46 PM 0
Share

So how does tiling work on a Terrain object? Feels like a major oversight to not have such functionality, especially with the recent push towards 2D games and sprites. Or is there a script/plugin out there for it that I just haven't found yet? I keep looking, only to come up with answers that are incomplete at best.

avatar image Owen-Reynolds · Dec 12, 2014 at 04:16 AM 0
Share

That's like saying not curing the common cold is an oversite. We tried, and it's way, way harder than we thought.

3D modellers have been trying for over a decade to make things easier, and this is the best we can do. Terrains are easy -- they're just bumpy planes, using blend shaders. Look at the sides of a game mountain to see how the "magic" really works.

avatar image ABNielsen · Dec 12, 2014 at 05:05 AM 0
Share

Um... you might want to re-read that. I know it's very possible in a basic 3D modeling program so long as you know how to control uv's. Tiling is also cheaper on memory in many 2D games and dev platforms that I've seen. If it works on a flat terrain, why not a flat box, or even just the plane object? $$anonymous$$aybe if I add the terrain shader to it...

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Vertical or Horizontal texture wrapmode 1 Answer

How do I clamp a texture only on the y axis, but repeat on the x axis? 0 Answers

2D - How to make sprites repeat tiles? 4 Answers

How to render html text in new UI system (unity 4.6) 0 Answers

How to clean on RenderTexture to transparent with brush 0 Answers


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