LayaPBRStandardLighting.cginc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "LayaBRDF.cginc"
  2. half2 MetallicGloss(float2 uv)
  3. {
  4. half2 mg;
  5. #ifdef MetallicGlossTexture
  6. #ifdef Smoothness_DiffuseTexture_Alpha
  7. mg.r = tex2D(_MetallicGlossMap, uv).r;
  8. mg.g = tex2D(_MainTex, uv).a;
  9. #else
  10. mg = tex2D(_MetallicGlossMap, uv).ra;
  11. #endif
  12. mg.g *= _GlossMapScale;
  13. #else
  14. mg.r = _Metallic;
  15. #ifdef Smoothness_DiffuseTexture_Alpha
  16. mg.g = tex2D(_MainTex, uv).a * _GlossMapScale;
  17. #else
  18. mg.g = _Glossiness;
  19. #endif
  20. #endif
  21. return mg;
  22. }
  23. inline half4 LayaPBRStandardLighting (half4 diffuseColor, half metallic, half smoothness, half3 normal, half3 viewDir, half3 lightDir, LayaGI gi)
  24. {
  25. normal = normalize(normal);
  26. half oneMinusReflectivity;
  27. half3 diffColor;
  28. half3 specColor;
  29. half alpha;
  30. diffColor = DiffuseAndSpecularFromMetallic (diffuseColor.rgb, metallic, /*out*/ specColor, /*out*/ oneMinusReflectivity);
  31. diffColor = LayaPreMultiplyAlpha(diffColor, diffuseColor.a, oneMinusReflectivity, /*out*/alpha);
  32. half4 color = BRDF1_Laya_PBS (diffColor, specColor, oneMinusReflectivity, smoothness, normal, viewDir, lightDir, gi);
  33. color.a = alpha;
  34. return color;
  35. }