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

Question How is unity_IndirectSpecColor calculated?

Discussion in 'General Graphics' started by OmgLaserGunPewPew, Aug 27, 2022.

  1. OmgLaserGunPewPew

    OmgLaserGunPewPew

    Joined:
    Sep 15, 2019
    Posts:
    3
    Can't find any information about it. I thought it was some average sky texture color (or average of upper hemisphere) but my calculations doesn't match well with unity_IndirectSpecColor values.
     
  2. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    It appears to be missing from the documentation, I have created a ticket to get this sorted out. Sorry for the inconvenience.

    The shader variable is the constant indirect specular color, only used when sampling of the environment map is disabled and set based on RenderSettings state. It is a black float4 if you don't have a valid skybox material.

    If your skybox material is valid, it is calculated like this:
    Code (CSharp):
    1. // Use constant part of skybox ambient SH as indirect specular color when no environment map is used
    2. // Don't apply ambient intensity
    3. const SphericalHarmonicsL2& sh = GetAmbientProbe();
    4. const ColorRGBAf c(sh.GetCoefficient(SphericalHarmonics::kColorChannelRed, 0),
    5.                    sh.GetCoefficient(SphericalHarmonics::kColorChannelGreen, 0),
    6.                    sh.GetCoefficient(SphericalHarmonics::kColorChannelBlue, 0));
    7. unity_IndirectSpecularColor = LinearToActiveColorSpace(c * m_ReflectionIntensity);
     
    OmgLaserGunPewPew likes this.