CustomLighting.hlsl 963 B

1234567891011121314151617181920212223242526272829303132
  1. void MainLight_half(float3 WorldPos, out half3 Dir, out half3 Color, out half DistanceAtten, out half ShadowAtten)
  2. {
  3. #if 1
  4. Dir = half3(0.5, 0.5, 0);
  5. Color = 1;
  6. DistanceAtten = 1;
  7. ShadowAtten = 1;
  8. #else
  9. half4 shadowCoord = TransformWorldToShadowCoord(WorldPos);
  10. Light mainLight = GetMainLight(shadowCoord);
  11. Dir = mainLight.direction;
  12. Color = mainLight.color;
  13. DistanceAtten = mainLight.distanceAttenuation;
  14. ShadowAtten = mainLight.shadowAttenuation;
  15. #endif
  16. Dir = 0;
  17. }
  18. void SampleSH_half(half3 normalWS, out half3 Ambient)
  19. {
  20. // LPPV is not supported in Ligthweight Pipeline
  21. real4 SHCoefficients[7];
  22. SHCoefficients[0] = unity_SHAr;
  23. SHCoefficients[1] = unity_SHAg;
  24. SHCoefficients[2] = unity_SHAb;
  25. SHCoefficients[3] = unity_SHBr;
  26. SHCoefficients[4] = unity_SHBg;
  27. SHCoefficients[5] = unity_SHBb;
  28. SHCoefficients[6] = unity_SHC;
  29. Ambient = max(half3(0, 0, 0), SampleSH9(SHCoefficients, normalWS));
  30. }