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?
How to repeat the texture instead of stretching?
-
RuhanBello
- Posts: 1
- Joined: Sun Jan 14, 2018 6:24 pm
- Amplify_Borba
- Posts: 1239
- Joined: Mon Jul 24, 2017 9:50 am
Re: How to repeat the texture instead of stretching?
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:
Please let us know if this helps, or if you have any further questions, thanks!
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:
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!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Re: How to repeat the texture instead of stretching?
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?
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?
- Amplify_Borba
- Posts: 1239
- Joined: Mon Jul 24, 2017 9:50 am
Re: How to repeat the texture instead of stretching?
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!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!