Home Unreal Engine

Tile a specific portion of a texture in Unreal material editor

polycounter lvl 6
Offline / Send Message
Limewax polycounter lvl 6
I'm testing out a theory where I can try to be a bit more optimized... to do this, I am trying to tile a specific portion of a texture along a certain coordinate (Vtiling, but not Utiling at all)

This is the preview of the current material. The area circled in blue shows the area of the material that I am trying to tile.
DrnFdfl.jpg

Here is the texture itself along side of the mask of the texture portion I am trying to tile.
8ni9U6Y.jpg

Here is what I am trying to avoid:
bwcx4k7.jpg

I know I can do this through making them separate textures, but again I am trying to practice optimization. How would you go about doing this?

Replies

  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Tile it with the UVs? That would be the cheapest solution. Maybe you just need some extra edges. Showing your mesh would help.
  • Clark Coots
    Options
    Offline / Send Message
    Clark Coots polycounter lvl 12
    you have the right idea using a mask, so is the problem your shader set up isn't masking out the top part of the texture?
  • Limewax
    Options
    Offline / Send Message
    Limewax polycounter lvl 6
    coots7 wrote: »
    you have the right idea using a mask, so is the problem your shader set up isn't masking out the top part of the texture?

    Yeah, the problem is that I cant really comprehend how to set this up in the shader. A friend told me that I could potentially do it with subUV, but I've still yet to figure it out.

    So I'm trying to take a texture like this:
    iYbxUFo.jpg

    and create something like this:
    LtOIX3t.jpg

    except doing it entirely through the shader (with that mask that I've got in the alpha)
  • ImSlightlyBored
    Options
    Offline / Send Message
    ImSlightlyBored polycounter lvl 13
    You don't necessarily need a mask, just use "fmod" on your texture coordinates, with the correct value for the y tile.
    for example-
    fmod(UV, float2(1.0,0.5));

    This will repeat your texture on Y depending on the limit you feed it - with the above pseudo code it'll repeat from 0 to 0.5, and then repeat that section infinitely.

    You'll want to only do this operation on Y though, so it'd be

    wrapLimit = (the value you want to go from);
    float2 WrappedUV = (inCoords.x, (fmod(inCoords.y, wrapLimit)));

    Those would tile. To tile from a point that's not 0, just add to your fmod UVs, so it'd be something like (WrappedUV + uvOffset.xy)

    In your example you'd want tile to about 0.3 (as this is about the percentage of texture space you're looking at) and then add 0.7 to make it look from 0.7 to 1.0

    BUT - and here's a lovely caveat - there's limits with this. Because it's all maths based, and some other stuff I don't understand - you will get an infinitely small seam every time it tiles.
    I have never been able to fix this - I almost used this technique on AA but then just could not solve that. It's a shame, as it would be useful otherwise.
    Maybe someone else knows the solution to that. I feel like you should be able to do it with multi samples but no idea off the top of my head.


    That's the complicated way that I think you are looking for, but realistically... forgive me, but could you just make a tiling texture for that? You've already had to bring in a mask for it -that would be my recommendation. Or go in hard with the UV layout!
  • Angry Beaver
    Options
    Offline / Send Message
    Angry Beaver polycounter lvl 7
    The problem is because while you're sampling the texture over the correct portion the actual texture information isn't being wrapped. try overpainting with what the repeat looks like jsut after you add the line so IE if your texture is like below


    aaaqqbbbbbbbbrrccc

    and you want to tile just the underlined part, make this modification to your texture

    aarqqbbbbbbbbrrqcc

    so now when it samples from the last r the q will of bled over.
Sign In or Register to comment.