CTI URP SG Utils.hlsl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. void CTI_ColorVariation_float(
  2. half3 Albedo,
  3. half4 ColorVariation,
  4. half ColorVariationStrength,
  5. out half3 o_Albedo
  6. )
  7. {
  8. o_Albedo = lerp(Albedo, (Albedo + ColorVariation.rgb) * 0.5, (ColorVariationStrength * ColorVariation.a).xxx );
  9. }
  10. void CTI_UnpackFixNormal_float(
  11. half4 normalSample,
  12. half normalScale,
  13. float isFrontFace,
  14. out half3 o_normalTS
  15. )
  16. {
  17. o_normalTS = UnpackNormalAG(normalSample, normalScale);
  18. o_normalTS.z *= isFrontFace ? 1 : -1;
  19. }
  20. void CTI_UnpackNormal_float(
  21. half4 normalSample,
  22. half normalScale,
  23. out half3 o_normalTS
  24. )
  25. {
  26. o_normalTS = UnpackNormalAG(normalSample, normalScale);
  27. }
  28. void CTI_UnpackNormalBillboard_float(
  29. half4 normalSample,
  30. half normalScale,
  31. out half3 o_normalTS
  32. )
  33. {
  34. // Up is flipped!
  35. normalSample.g = 1 - normalSample.g;
  36. o_normalTS = UnpackNormalAG(normalSample, normalScale);
  37. }
  38. void CTI_AlphaLeak_float(
  39. half alphaSample,
  40. half leak,
  41. out half o_Occlusion
  42. )
  43. {
  44. o_Occlusion = (alphaSample <= leak) ? 1 : alphaSample; // Eliminate alpha leaking into ao
  45. }