Skip to main content
GameDev.net gamedev.net
🔒 Locked

Texture tiling without deformation

Started by fire67 Apr 21, 2017 at 3:08 PM 3 replies 2.3k views
Original Post
fire67
fire67

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 !

eppo
eppo

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]

fire67
fire67

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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.