Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

White pixels from AA and specular shader

Discussion in 'Editor & General Support' started by Orion, Apr 2, 2012.

  1. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    Hi,

    we're getting these nasty artifacts on our models, whenever a specular shader is used and anti-aliasing is enabled (Unity 3.5). The pixels jump around like crazy on the edges of the model when the camera or light moves.

    - It is definitely not a mipmapping or other texture problem (it happens without textures too).
    - The near or far plane of the camera does not affect the issue.
    - It rarely happens (but it does) on the default unity sphere, if I put a specular material on it.
    - I see it most often where there are lots of polygons (they don't overlap or anything, see sphere). So I assume it has to do with the polygon density.

    Does anyone know how to fix this? We'd really like to have specularity AND anti-aliasing, if that's not asking too much :/

     
  2. ivanzu

    ivanzu

    Joined:
    Nov 25, 2010
    Posts:
    2,065
    Try using different rendering method that fixed it for me.
     
  3. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    You mean deferred lighting? Yeah that's no surprise, since it doesn't support anti aliasing in the first place, which causes the problem.

    But using AA is not negotiable for us.
     
    Last edited: Apr 2, 2012
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Does it occur with light probes instead of 'real' lights?
     
  5. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    Unfortunately, it happens with light probes as well - with the added problem that normal maps don't seem to work anymore, when only lightprobes light the model.
     
    Last edited: Apr 2, 2012
  6. lakru

    lakru

    Joined:
    Feb 19, 2008
    Posts:
    116
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    FYI it happens on ipad too, mostly near the corners of geometry. And we were using a specular shader. I think it's due to unclamped values at angles or something.
     
  8. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    I'd be great if you could post that fixed shader! I'm terrible with writing shaders.

    Fortunately performance isn't really an issue for us, since we only have 2 or 3 models to render, per scene. So having a shader that does the clamping would be great.
     
  9. lakru

    lakru

    Joined:
    Feb 19, 2008
    Posts:
    116
    Try the solution from the link I posted:

    Switch to Bumped Specular. Put a flat normal map (that effectively does nothing, you can generate one if you go to an image, tick Generate Normal map in the settings of the image and turn down Bumpiness to 0). I think then the effect is greatly reduced or gone. I guess it's because then the shader re-writes the normal calculation, which is where the problem is probably.

    If that doesn't help let me know and I'll find the shader.
     
  10. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    I had dismissed this solution, since we also get the artifact on meshes that already use a normal map (so that alone doesn't fix it) - and we wouldn't be able to use the normal map the mesh needs.
     
  11. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    The solution to add
    Code (csharp):
    1. o.Normal = fixed3(0,0,1);
    seems to give the best results so far and is easy to apply to the shaders that don't use a normal map already. Not sure what to do with those -with- a normal map though.
     
  12. theropodx

    theropodx

    Joined:
    May 1, 2011
    Posts:
    40
    Hi all,

    The solution for me was to apply the (Pro-Only) Image Effects Anti-Aliasing Script on my camera. Works great and there are several options there...not sure of performance impact yet...
     
  13. Orion

    Orion

    Joined:
    Mar 31, 2008
    Posts:
    261
    Thanks! That is a good idea! I'll try it later.
     
  14. Jack-Trades

    Jack-Trades

    Joined:
    Apr 5, 2009
    Posts:
    107
    I bumped into this issue for the first time, trying to use a custom normal mapped specular shader.

    None of the workarounds presented earlier work for me because I'm using Unity Pro and all my models use a normal map (so I can't flatten it).

    This is a quite serious issue, it's weird that it haven't been fixed yet.
     
    Last edited: Aug 1, 2012
  15. IridiumStudios

    IridiumStudios

    Joined:
    Apr 15, 2013
    Posts:
    21
    I would like to echo some significant frustration with this.

    I use normal maps, so the workarounds are useless. I can't use AA as a post-effect, as it messes up some of my shader use. I can use Catalyst Control Center to set Supersampling AA on the application to make it look nice, but that's hardly a solution I can present to my customers. = (
     
  16. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    Seeing the problem here too--this is with the standard Unity specular shader and no texture. Certain objects have a very distracting "glittering" as they move. (Even a standard Capsule object will sometimes do it a little.)

    Any new solutions?
     
  17. oscarkool

    oscarkool

    Joined:
    Dec 30, 2013
    Posts:
    4
    Bumping this thread as I too have this problem and it's 2014. You'd think Unity devs would fix it by now lol
     
  18. Khyrid

    Khyrid

    Joined:
    Oct 8, 2010
    Posts:
    1,790
    With Unity 5 on the way, I hope this will be fixed by then. But w/e.
     
  19. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    231
    I, too, am hoping for a fix.