Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

UV flipping and normal mapping

Discussion in '5.5 Beta' started by jack-riddell, Nov 21, 2016.

  1. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Unity 5.5 has added the useful feature of UV flipping to add variety to particle effects but flipping UVs breaks a lot of normal mapping techniques. When UVs get flipped it also flips the direction of the normal mapping creating flaws in the lighting. At the moment I have not found a way to detect UV flipping in a shader and correct for it. could a 0 - 1 value be passed along with the UV to indicate if a UV for a specific Particle Has Been Flipped and what axis the flip has occurred on.
     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    I hadn't thought of that! Log a bug and I will apply the flip to the tangent stream too.

    For anyone doing their own custom normal mapping, perhaps ddx(UV.x) could help.. but particle rotation could mess this up.

    We could add a custom vertex stream for this information. But at that point, it's probably best to just use the random number stream instead, and do all the flipping yourself in the shader ;)
     
    jack-riddell likes this.
  3. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    The issue with ddx(uvx) is that it does not work in the vertex function or on low end mobile and to get the best performance out of a particle shader you want to offload as much work as possible onto the vertex. My current normal mapped particle shader does almost everything in the vertex function and has only 4 lines of code in the fragment function.
    The random number idea is a good one though I will try that out.
     
    richardkettlewell likes this.