Sign in to follow this  

Texture tiling without deformation

Recommended Posts

Hi there !

I am trying to achieve a special texture stretching effect in my shader. Here is how I define my uv before sampling my texture, nothing really special.

// uv_ST contains the tiling and offset values
uv.xy = uv.xy * uv_ST.xy +

This gives the standard tiling/stretching and offset behaviour when you tile/stretche a clamped texture as you can see in the image below. First is normal, second is offset and last is stretching.


But I want to avoid the deformation behaviour when stretching, I want to keep margins when stretching my texture or simply cut it in the middle and stretching it. Here is an illustration below.


How could I do that inside my shader when defining my uvs before sampling the texture ?

Thanks a lot !

Edited by fire67

Share this post

Link to post
Share on other sites

If you add a few additional vertices around each dashed line, you can scale them up or down individually by scaling UVs around the centroid of their four surrounding vertices.


Edited by eppo

Share this post

Link to post
Share on other sites

Thanks for your answer, this is very clever but I can't use a solution that involves geometry as I need to be able to change the texture offset along a ribbon mesh while keeping a good stretching.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this