Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Normal Maps on Shuriken Particle System Not Working

Discussion in 'Editor & General Support' started by gravitoid, Sep 9, 2014.

  1. gravitoid

    gravitoid

    Joined:
    Apr 15, 2013
    Posts:
    4
    Hello, I am having an issue in the Unity Shuriken particle system where I apply a normal map to my particles, yet the normal map doesn't seem to work properly.
    I have a hunch this may have something to do with how the particle renderer orders rotating the object and calculating lighting, but I am not sure.
    I have just a spherical normal map in the material that is on the emitter and it works perfect when I create my own billboard script and put the material on a quad, but it seems to totally fall apart when I use it with shuriken.

    In the gif I included, the orbs spinning around the yellow sphere in the center are all image planes with a billboard script on them with material that uses an alpha and normal map.
    http://i.imgur.com/n5NQ8Fy.gif

    Here is another gif. This gif is what happens when I put the same material on the particle emitter. The emitter is just set to billboard mode and the camera is rotating around it. Nothing special.
    http://i.imgur.com/hKLYmDW.gif

    This is the normal map I am using.
    http://i.imgur.com/LGSuh3T.png
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Shuriken uses some form of bent normals, and if you want it lit correctly, you must generate normals within the shader, there's no other way around it. Consider these are billboards always pointing at the camera? obviously it's going to have problems.

    There's a parameter in the Shuriken Render tab that could help called 'Normal Direction' which if you fiddle with might be what you want.
     
  3. gravitoid

    gravitoid

    Joined:
    Apr 15, 2013
    Posts:
    4
    I fiddled with the Normal Direction which gives me a float from 0-to-1 to play with and it doesn't fix it.
    So your suggestion is to not use the statement "o.Normal = UnpackNormal(tex2D(_NormalMap, uv_NormalMap)).rgb" but instead calculate the normal myself in my lighting model calculation?
    If so, might you know what I might specifically research to get a good idea about how I might do that?
    I will go ahead and try and dink around and come back if I find a solution.
    Thanks for your feedback. :)
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    In shader where you calculate the dot product, ie

    fixed nd = dot( normal, i.normalDir);

    Where normal is the unpacked normal map, and the normalDir is from vertex shader, you will probably want to pass in a constant instead to describe the surface of the normal. In your case this would be something like normalized(vertpos-lightpos) - so that it's always facing the light. Or just fixed3(0, 0, -1) for facing camera. I don't recall offhand if that's correct because I went for 3D particles in the end, but will no doubt get back to it at some point :)

    Actually! if I remember rightly (ignore the above unless it matters to you) shuriken transforms its verts in camera space not world space... so that's the real issue at hand afaik... see http://forum.unity3d.com/threads/shader-issue-with-shuriken.173792/
     
  5. gravitoid

    gravitoid

    Joined:
    Apr 15, 2013
    Posts:
    4
    Okay, thanks. I think I might be able to figure it out. I'll report back if I figure it out. But if anyone else has already solved it, feel free to educate me what the solution is. I'm sure others will appreciate the solution as well.