How to repeat the texture instead of stretching?

Node-based Shader Editor

How to repeat the texture instead of stretching?

Postby RuhanBello » Sun Jan 14, 2018 6:28 pm

Hi guys,

I am new to shader things and I have a noob question:

How can I make a shader that repeats the texture when the object gets bigger?

I mean, when you put some texture on a cube, for example, and you stretch it only on the X axis, the texture gets stretched. But currently I need the texture to repeat instead of stretching. Can someone please help me with this?
RuhanBello
 
Posts: 1
Joined: Sun Jan 14, 2018 6:24 pm

Re: How to repeat the texture instead of stretching?

Postby Amplify_Borba » Mon Jan 15, 2018 10:09 am

Hello RuhanBello, thank you for getting in touch and for your support!

First you need to set the texture's Wrap Mode to Repeat, by selecting it in Unity and using the Inspector, hitting Apply after doing so.
Then, within the shader, you may use an Object Scale node passing the scale for the current game object from its X and Y coordinates to the tiling value of a Texture Coordinates node to the UV of the Texture Sample node.

Here's an image of the suggested node setup for your convenience:

Repeat.jpg
Repeat.jpg (177.85 KiB) Viewed 5377 times


Please let us know if this helps, or if you have any further questions, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: How to repeat the texture instead of stretching?

Postby JayExbl » Mon Feb 18, 2019 3:27 am

Hi,
I've been experimenting with Object Scale but I'm having an issue - I'm guessing this only works if the object is uniformly scaled on all axes, right? If I have an object with scale 1, 1, 0.1 the tiling will be incorrect on the Z axis.

Not sure if it's possible to work around this without using a triplanar mapped shader, is that right?
JayExbl
 
Posts: 4
Joined: Fri Jan 18, 2019 5:25 am

Re: How to repeat the texture instead of stretching?

Postby Amplify_Borba » Tue Feb 19, 2019 3:37 pm

Hello, can you share a sample of what you've created so that I might best help you out?
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 15 guests