暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PseudoSubsurface.hlsl 1.0KB

12345678910111213141516171819202122232425262728293031323334
  1. void PseudoSubsurface_half (half3 WorldPosition, half3 WorldNormal, half SSRadius, half ShadowResponse, out half3 ssAmount)
  2. {
  3. #ifdef SHADERGRAPH_PREVIEW
  4. half3 color = half3(0,0,0);
  5. half atten = 1;
  6. half3 dir = half3 (0.707, 0, 0.707);
  7. #else
  8. #if defined(UNIVERSAL_PIPELINE_CORE_INCLUDED)
  9. half4 shadowCoord = TransformWorldToShadowCoord(WorldPosition);
  10. Light mainLight = GetMainLight(shadowCoord);
  11. half3 color = mainLight.color;
  12. half atten = mainLight.shadowAttenuation;
  13. half3 dir = mainLight.direction;
  14. #else
  15. half3 color = half3(0, 0, 0);
  16. half atten = 1;
  17. half3 dir = half3 (0.707, 0, 0.707);
  18. #endif
  19. #endif
  20. half NdotL = dot(WorldNormal, -1 * dir);
  21. half alpha = SSRadius;
  22. half theta_m = acos(-alpha); // boundary of the lighting function
  23. half theta = max(0, NdotL + alpha) - alpha;
  24. half normalizer = (2 + alpha) / (2 * (1 + alpha));
  25. half wrapped = (pow(abs((theta + alpha) / (1 + alpha)), 1 + alpha)) * normalizer;
  26. half shadow = lerp (1, atten, ShadowResponse);
  27. ssAmount = abs(color * shadow * wrapped);
  28. }