Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Resolved Ability to disable specular highlights for translucent shaders (HDRP)

Discussion in 'Graphics Dev Blitz Day 2023 - Q&A' started by BOXOPHOBIC, May 25, 2023.

  1. BOXOPHOBIC

    BOXOPHOBIC

    Joined:
    Jul 17, 2015
    Posts:
    531
    Hey! As I mentioned in a lot of places already, HDRP added the option to disable the specular highlights in 2022.x but it only works for the Specular shader, making the feature useless for the others. Most developers I talked to, would like to disable the specular on vegetation, which uses the translucent/sss shaders, which doesn't have a specular color field :|
     
    teutonicus likes this.
  2. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    936
    Hi,
    we are aware of this limitation. But we have technical constrain forbidden us to extent it to other Material Type. There is no room in the GBuffer. The "trick" for specular color was doable as we were reuse an existin attribute and modifying its interpretation.
     
    BOXOPHOBIC likes this.
  3. BOXOPHOBIC

    BOXOPHOBIC

    Joined:
    Jul 17, 2015
    Posts:
    531
    Hi. I was wondering if this couldn't be achieved by using the smoothness instead. Disable spec when the smoothness is below 0.02 (2% if I remember correctly) and this would work for all shaders.
     
  4. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    936
    The 2% currently have a meaning.

    specular color is the F0 term of the Fresnel equation, which is the intensity at grazing angle hitting a material. This is calculated from the index of Refraction. and index of refractoin of 1.5 map to 4% . In real world there is no Material that have a negative index of refraction < 1.2 (outside of complex index of refraction for metal but they have a kappa component) this is where those 2% come from. As we aren't suppose to have value below 2% we consider that if there is, it is an intention from the artists to attenuate the specular (and if the artists want it, it mean we don't really care about the Fresnel term and having it wrong is ok). This also have a smooth transition as you can gradually attenuate the specular.

    Folding it into the smoothness don't make sense in this regards. Smoothness is not link to the Fresnel equation (in analytical brdf) and we have no way to exclude a range of smoothness to understand what was the artists intent. Also it will not allow any smooth transition as the value aren't correlated.

    Hope it help.
     
    Last edited: May 27, 2023
    teutonicus likes this.
  5. BOXOPHOBIC

    BOXOPHOBIC

    Joined:
    Jul 17, 2015
    Posts:
    531
    Thanks for the detailed explanation! It makes much more sense now.
     
    teutonicus likes this.
  6. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    I'm obviously a dummy regarding light transport and shading, so please correct me if I'm wrong or missing something, but: this assumes that the geometry is accurately portrayed by the surface normal, right? Which is not really the case for vegetation but also terrain shading (where this causes a lot of headaches, artistically, as well.) I believe there are two major reasons for this:
    1. In the above cases, relatively intense normal maps are quite common that tend to break up strong fresnel from up close. However, those normal maps often have more high-and mid frequency detail, which means that at lower mip map levels they tend to be blurred into flatness. The specular issue is especially pronounced at glancing angles and at a distance, both factor which make sampling at lower-res mip levels more common.
    2. Both vegetation and terrain materials have their normal maps authored for mostly frontal viewing. However, those types of materials often have considerable depth and complexity 'hidden' within the direction of the surface normal. As a result, the surface normals when viewed from low angles would be considerably different.
    I think due to both of these factors, the input to the shading model is using incorrectly & involunatrily flattened surface normal vectors. From my limited understanding, it could be helpful to consider a 'stochastic normal variation' in the fresnel term, particularly at lower mip levels. This could allow artists to correct for the above-mentioned issues and I would argue would also be physically correct.
     
  7. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    936
    Hi,

    1. This is refer as normal map filtering, and it is about transfering the geomtry information from one geometry description level to another: Vertex / displacement map -> shading normal - > Roughness.
    When you fitler geometric information contain in the footprint of a pixel and that there is too much high frequency inside it, you need to transfer the raimaining in the next level. This is the same than for mips but apply to geometry. In practive it mean that we should consider the variance of the normal in the normal map processing and transfer it to modify the roughness. This apply to all geometry, not only vegetation. We are doing that currently in Unity due to workflow issue (need to store variance in normal map, or to have normal and roughness coupled which isn't the case in Unity). However we do it for geometric curvature (option in shader graph on lit.shader).

    2. I guess you refer to the process of spherifying the normal in order that tree get an overall better lighting. And yes, it is to hide the geometry complexity. And is indeed recommended workflow for tree.

    Side note: Our Book of the dead demo don't kill any specular and we get decent result:


     
    Last edited: May 30, 2023
    one_one likes this.
  8. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    621
    Thanks for the quick response!

    Yes, absolutely, this is a good way of adjusting roughness over mip levels. But as you mentioned in this thread, the fresnel response is not tied to the roughness, so a decreased smoothness (or even a smoothness of 0) does not address the issue mentioned in this thread. So I guess what I'm asking about is normal map filtering that attenuates the fresnel response.

    Yes, BotD looks excellent and does not have this issue - though it does not feature the situation where, from my experience, this becomes most obvious:
    1. LODs of deciduous trees that have large flat triangles that are not spherified, same with 'card' based grass meshes.
    2. Open and relatively flat terrains at low sun altitudes.
    Corniferous trees, detailed/strand-based ground plant meshes and avoiding large flat areas are great ways of avoiding this issue, though they are not always feasible strategies. With all that said, I'm still aware that the issue of adding a 'fresnel attentuation' is also a technical issue - I just wanted to stress that there are cases where it's not feasible to accurately represent the surface geometry, making the resulting surface look unnatural despite the fresnel response being technically correct for the provided values.
     
  9. scyxiaoh

    scyxiaoh

    Joined:
    Dec 20, 2016
    Posts:
    8
    Hi, is the trick you mentioned currently usable? Our project has a urgent need to fix the Fresnel issue on puffy tree canopies.