Skin_PixelGeometryEval.azsli 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. // This #define magic lets you use the EvaluatePixelGeometry function in this file without making it the final EvaluatePixelGeometry
  10. // used in your shader. Simply #define EvaluatePixelGeometry to your custom definition before including this file
  11. //
  12. #ifndef EvaluatePixelGeometry
  13. #define EvaluatePixelGeometry EvaluatePixelGeometry_Skin
  14. #endif
  15. #include "../BasePBR/BasePBR_PixelGeometryEval.azsli"
  16. PixelGeometryData EvaluatePixelGeometry_Skin(
  17. VsSystemValues SV,
  18. const MaterialParameters params,
  19. float3 positionWS,
  20. real3 normalWS,
  21. real3 tangentWS,
  22. real3 bitangentWS,
  23. float2 uvs[UvSetCount],
  24. float2 detailUvs[UvSetCount],
  25. real4 wrinkleBlendFactors,
  26. bool isFrontFace)
  27. {
  28. // Base PBR Geo Data
  29. PixelGeometryData geoData = EvaluatePixelGeometry_BasePBR(SV, params, positionWS, normalWS, tangentWS, bitangentWS, uvs, isFrontFace);
  30. // Skin specifics
  31. // skin only has one detail UV channel
  32. geoData.detailUv = detailUvs[0];
  33. geoData.wrinkleBlendFactors = wrinkleBlendFactors;
  34. return geoData;
  35. }
  36. PixelGeometryData EvaluatePixelGeometry_Skin(VsOutput IN, VsSystemValues SV, bool isFrontFace, const MaterialParameters params)
  37. {
  38. real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(SV));
  39. real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(SV));
  40. real3 normalWS, tangentWS, bitangentWS;
  41. ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
  42. return EvaluatePixelGeometry_Skin(
  43. SV,
  44. params,
  45. IN.worldPosition,
  46. normalWS,
  47. tangentWS,
  48. bitangentWS,
  49. IN.uvs,
  50. IN.detailUvs,
  51. real4(IN.blendFactors),
  52. isFrontFace);
  53. }