Home Unreal Engine

Edit parts of material in negative texture space?

polycounter
Hey, is there a way to edit the parts of the material that are in the negative UV space? I have hair cards with an applied flow/tangent map and I want to flip the red channel of any cards that have been flipped. I've been doing this by giving those flipped cards a red vertex colour and in Unreal, using the red vertex colour channel to flip the red channel of the tangent map. 



But, my life would be easier if I could just offset the cards into negative UV space by 1, then access those cards in Unreal and flip the red channel. As I understand it, the groom asset doesn't use vertex colours, so this would be a good solution? Is this possible?

Replies

  • Alex_J
    Offline / Send Message
    Alex_J grand marshal polycounter
    not sure what you mean by negative UV space (like moving some shells down a quadrant to the -1,0 square?) but, if you just need a way to target specific UV shells separately, can you use a second channel? That's pretty easy to work wiht a second UV channel in the material graph 
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    you can mask by UV position - just mess with the texcoords (eg. clamp them - theres better options but I'd need to have the editor open in front of me to do it) and use the result as a mask for a lerp (don't use switches/branching, its very bad for gpus) 
    edit:
    knocked an example up in designer instead.  this will give you a white mask where either axis is < 0 (range is -3 to 3 in the example image)


  • HarlequinWerewolf
    Thank you for setting this up! But forgive me for being dense, these nodes are waaaay out of my comfort zone and I'm not getting the "mask" as far as I can tell? Chances are, I'm missing something here.

    This is what I have feeding into the alpha of my "flip" node and it just seems to be flipping everything, not just the UVs in negative space.
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    oh - sorry. that wasn't too clear now i look at it..

    replace the texture node with a texcoords node
    replace the swizzle nodes with component masks (one just R, one just G)

    and you'll get a black and white mask
  • HarlequinWerewolf
    Hey @poopipe Thank you! I got it working. For whatever reason though, Unreal took issue with the max function so I plugged it into a min and inverted


    Top row of planes are in negative UV space with UVs flipped causing the mismatch with their flow map.

    With your method of using negative space as a mask! Thank you!


    Sorry @Alex_J I completely forgot to respond. Yes, I could have done this in a 2nd UV channel, my brain just went to trying to get negative space masked out. My current material is using the second UV channel as a "dye mask" and I don't really want to bring in more channels than I need. Thank you again though, it is a totally viable way of doing it.
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    glad it's working.  

    I can imagine there might be some issues with the numbers in the material editor vs designer. the uv coords may even be flipped vertically.

    I have a much more robust version floating around at the office that allows you to specify exactly which UV tiles go into a mask but I'd have to sit down and make it again to have any idea what goes on in there :) 


  • HarlequinWerewolf
    Oooh, being able to specify the UV tile would be interesting. I want to see if I can get this method working with the groom asset as I couldn't use vertex colours on that so that's my next task
Sign In or Register to comment.