Home Technical Talk

Shader - Stretch Textures from UV's (Post Process)

polycounter lvl 12
Offline / Send Message
Ace-Angel polycounter lvl 12
Hey, does anyone know of a quick way to stretch the texture, via the UV Coordinates? Maybe even for Post-Process Scene related modulation?

I currently Mul my Tex Coords by 0.5, 1.0

The results are there, but still somewhat subpar, while static object stretch fine, when it comes to scene stuff, the Stretch somewhat shoots my screen view all over the place without respecting the 'angle' or view I'm looking for.

Replies

  • Kurt Russell Fan Club
    Options
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    Could you show a picture to describe what your problem is?

    Multiplying texture coordinates (sampling per pixel from a different part of a texture) will effectively take your image and stretch/scale it. You get out a scaled version of what you put in, like Photoshop scale. It'll scale not using the midpoint of the image but the corner. Do you mean you want to scale from the midpoint? For that you'd need to subtract .5,.5, scale and then add .5,.5 again.
  • Butthair
    Options
    Offline / Send Message
    Butthair polycounter lvl 11
    Do you want to affect the U and V separately?

    I'm not sure if this is most efficient, but you could append to Const1Vectors together, then multiply by TexCoords. For the purpose setting params.
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Well, here is a quick example of what I mean:
    75216422.png

    The problem is in this case, I want the 'stretch to respect the center of the View/Camera. So my highlights correspond to their stretch correctly.

    I don't care about the edges, they can shoot to the moon for all I care.

    But yeah, basically you can see what happens in the image instead.
  • Kurt Russell Fan Club
    Options
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    Ahh that's what I thought. In that case, do a subtract then multiply then add.

    Whenever you scale (multiply) UVs, you're scaling around the pivot point of the UVs, which is the origin (which is 0,0). If you want the UVs to pivot at the (0.5,0.5) point then you need maths such that when you multiply, the 0.5,0.5 point hasn't moved... and that everything else has moved away from it.

    The only value that retains its value after you multiply is zero, and every value greater than it goes up and every value that's less than it goes down. So you subtract 0.5,0.5 (or your ideal pivot) to make that part of the image the zero point, multiply by your scale factor and then add your 0.5,0.5 back again.
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Thanks for the write-up. Cheers, will try that!
Sign In or Register to comment.