Sign in to follow this  

Texture tiling without deformation

Recommended Posts

Posted (edited)

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 + uv_ST.zw

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.

Zwj4l.jpg

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.

HdUgs.jpg

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
Posted (edited)

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.

[attachment=35685:s.png]

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