Home Unreal Engine

material affect object instead of UVs?

polycounter lvl 16
Offline / Send Message
Oniram polycounter lvl 16
so what i have here is a shader ive set up to use a gradient mask, mixed with a heightmap. i want to be able to control the height at with im blending the snow on the mesh, but since i have repeating textures, it repeats every UV section. is there a way to get this so i can effect the entire object (if possible without adding an additional UV channel).

heres what ive got

uvthings.jpg

Replies

  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    World Position is the node you're looking for.

    There is a Function called "World Aligned Texture" which should be what you're looking for.
  • Oniram
    Options
    Offline / Send Message
    Oniram polycounter lvl 16
    that function is amazing. however. the way that my shader is set up, that wont work.

    how would i use world position to do this. here is the bit of my shader that im working with, if it helps.

    sfda.jpg this is being plugged into the alpha of a lerp between the brick and snow textures.

    the offscreen connections are just heightmaps going into the subtract and multiply nodes, and the alpha of the lerp here is just a vertex blend.
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Think of using world position as the basis for a mask.
    Like.. Think of the world grid AS uv's a d your model being placed and moved around in them.
    I'll give a more thorough answer later, but see if that analogy helps.
  • tharle
    Options
    Offline / Send Message
    tharle polycounter lvl 9
    basically instead of using a texture gradient just use one of the channels from world position, pretty sure blue is the vertical one. you just have to play with the numbers to get the gradient to match your asset and then use that as the mask that controls your snow. the only thing that might cause problems is if you use the asset multiple times at different heights as the snow would be based on the world height - you could add in some vertex colour parameters though which would give you more control.
  • Oniram
    Options
    Offline / Send Message
    Oniram polycounter lvl 16
    the result that world position gives is close to what i want but the world height thing does cause some issues.
  • LoTekK
    Options
    Offline / Send Message
    LoTekK polycounter lvl 17
    One possible (albeit not entirely ideal) way could be to plug your V coord [0,1] to [ObjectWorldPosition.y - (ObjectRadius / 2), (ObjectWorldPosition.y + (ObjectRadius / 2))]. This would really only work properly with objects that are taller than they are wide, though.
Sign In or Register to comment.