Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Correct Specular For Transparent Shader

Discussion in 'Shaders' started by Reanimate_L, Apr 18, 2012.

  1. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Hi Guys,
    Is it possible to achieve correct specular behaviour for transparent shader?
    You can see in attached image that the specular is still visible in the area where the light supposed to be occluded.
    Well i'm not looking a shadow for transparent shader, i know it's the limitation of deffered renderer CMIIW, but how about specular for transparent shader, is it possible? is there any way to solve this.
    $spec.jpg

    Thanks
     
  2. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,880
    Specular highlights is just a matter of lighting function with surface shaders.
    Unity provided blinnphong and general phong shading formulas around the web has some strange artifacts when undesired from some angles.
    Try blinn, or smiliar lighting functions according to your situation.

    [Advertisement]
    Or you can buy my shader pack which i already included the solution :p
     
  3. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Eh, i'm not talking about the spec angle actually (or did i??).
    I mean is something like this picture
    in this one i use standar specular shader while in my previous pic i'm using transparent spec.
    As you can see the specular is not visible in the area where the light is occluded.
    So yeah, same question. is it possible to achieve the same spec behaviour for transparent shader?
     

    Attached Files:

  4. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,880
    Your correct question should be; why shadows dont work with transparent objects.

    If it suits your needs, try to use cut-out specular shader. If not, you must do your own shadow mapping.
     
  5. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Ah i see, so it depend on the shadow isn't?. I thought there is another way to achieve this without shadow on transparent shader
     
  6. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,880
    Well, in the situation you posted its related to shadows.
    Or you can also make a custom transparent shader that also accepts an occlusion texture as well and that way you can block the specular highlights too.

    Edit: Also there might be another way to change shadow casting and recieving or maybe lightmaps can be involved but i never messed with those yet, so i wouldnt know.
    Maybe someone else does?

    Edit2: Also an image effect might also solve this problem but wouldnt give nice results i suppose.
     
    Last edited: Apr 18, 2012
  7. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,880
    IF you are writing your own custom lighting, try the following logic to implement fake light occulusion for the specularity

    if (s.albedo + lightcolor0.rgb <= 0) spec = 0;