Search Unity

unity5.4 pbr shadow wrong

Discussion in 'Shaders' started by dreamerflyer, Feb 27, 2017.

  1. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    Code (CSharp):
    1. inline half4 LightingStandardSpecular (SurfaceOutputStandardSpecular s, half3 viewDir, UnityGI gi)
    2. {
    3.     s.Normal = normalize(s.Normal);
    4.  
    5.     // energy conservation
    6.     half oneMinusReflectivity=0;
    7.     //s.Albedo = EnergyConservationBetweenDiffuseAndSpecular (s.Albedo, s.Specular, /*out*/ oneMinusReflectivity);
    8.  
    9.     // shader relies on pre-multiply alpha-blend (_SrcBlend = One, _DstBlend = OneMinusSrcAlpha)
    10.     // this is necessary to handle transparency in physically correct way - only diffuse component gets affected by alpha
    11.     half outputAlpha;
    12.     //s.Albedo = PreMultiplyAlpha (s.Albedo, s.Alpha, 1, /*out*/ outputAlpha);
    13.  
    14.     half4 c = UNITY_BRDF_PBS (s.Albedo, s.Specular, oneMinusReflectivity, s.Smoothness, s.Normal, viewDir, gi.light, gi.indirect);
    15.     //c.rgb += UNITY_BRDF_GI (s.Albedo, s.Specular, oneMinusReflectivity, s.Smoothness, s.Normal, viewDir, s.Occlusion, gi);
    16. //    c.a = outputAlpha;
    17. //c .rgb=s.Specular;
    18.     return c;
    19. }
    20.  
    21.  
    22. inline void LightingStandardSpecular_GI (
    23.     SurfaceOutputStandardSpecular s,
    24.     UnityGIInput data,
    25.     inout UnityGI gi)
    26. {
    27.  
    28.     UNITY_GI(gi, s, data);
    29.  
    30. }
    i not change the unity_gi,but the shadow go through two sides,how to fixed this?
     

    Attached Files:

    • s1.png
      s1.png
      File size:
      277.6 KB
      Views:
      1,025
    • s2.png
      s2.png
      File size:
      231.4 KB
      Views:
      783