Search Unity

Legacy Bumped Specular - smoothed polygons edge shine problem

Discussion in 'General Graphics' started by Eudaimonium, May 23, 2015.

  1. Eudaimonium

    Eudaimonium

    Joined:
    Dec 22, 2013
    Posts:
    131
    Hi there,

    I am experiencing a weird problem regarding the titular shader.

    First off, please don't reply with "Use standard". I am developing sort of a "legacy" game, lots of content but very low hardware requirements, targeted platform is low-end PCs.

    Now, on to the problem. Best illustrated with pictures:

    Here is one of the models for a Longsword hilt, with applied shader and a texture:


    The brown leather grip belongs to a polygon smoothing group, where as the metal parts do not. As you can already see, the specularity on the metal parts manifests as expected, however on the grip itself it's acting very weird - it only manifests very close to the edges of the quads (not individual triangles) making up the sword hilt.

    Here is the same hilt, rotated a bit - notice the lack of any specularity on the hitl, even though it's supposed to be smoothed round:


    I have played around with model import settings and settings the "tangents" to "None" appears to alleviate the edge-only shine issue, but produces a new problem:


    As you can see the specularity is unnaturally strong and does not respond to the diffuse map's alpha channel which should determine the strength of specular effect.

    However I'm coming to the conclusion that my sword hilt model is not to blame, as I have noticed the same anomaly on the material "preview" sphere model as well, take a close look:


    Here is the same image with Levels tweaked in photo editing software to help exaggerate the problem:


    So, how does one go about solving the edge-shine specularity problem on smoothed polygons, such as a round longsword hilt?

    Note: I am no stranger to HLSL shader code, and I believe a transition to Unity's shader system should not be too rough, but I'm yet to try it. I would not shy away from solving the problem in shader code, if the solution to this is not some trivial thing I'm missing.

    Thank you in advance for any help! :)
     
  2. smd863

    smd863

    Joined:
    Jan 26, 2014
    Posts:
    292
    Looks like you are using a shader that calculates at least part of the specular per-vertex instead of per-pixel. Probably the light/view angle part of the calculations are done per-vertex and then finished in the fragment shader with the normal map.

    Your options are to increase the complexity of your geometry, or to use a more complex shader (move the entire calculation into the fragment shader).

    If you don't want to mess around with shaders yourself and you're very concerned with performance, "CORE-framework" is a good asset to look into. Lots of legacy shaders that are highly optimized to run on mobile devices so they should fly even on older machines.

    Although it never hurts to start with your own shader and built-it up optimally to only include the features you need if you don't mind learning Unity's shader system.
     
  3. Eudaimonium

    Eudaimonium

    Joined:
    Dec 22, 2013
    Posts:
    131
    I am well aware of the specular per-vertex calculations, but that should not mean the specularity should fade-out towards the middle of the polygon. Look at the metal part of the longsword hilt - entire hilt is using one shader.

    So basically either the shader code is bugged at smoothed polygons, or there's just something I'm overlooking.

    I will try out various import-export options from 3DS Max as well, in the meantime, I'm really hoping somebody would say "Yeah you're just missing X, it solves the problem".