TransmissionInput.azsli 950 B

12345678910111213141516171819202122232425262728293031
  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. option bool o_transmission_useTexture;
  10. real4 GeTransmissionInput(Texture2D map, sampler mapSampler, float2 uv, real4 transmissionTintThickness, float4 uvDxDy = float4(0.0, 0.0, 0.0, 0.0), bool customDerivatives = false)
  11. {
  12. if(o_transmission_useTexture)
  13. {
  14. if (customDerivatives)
  15. {
  16. transmissionTintThickness.w *= real(map.SampleGrad(mapSampler, uv, uvDxDy.xy, uvDxDy.zw).r);
  17. }
  18. else
  19. {
  20. #ifdef CS_SAMPLERS
  21. transmissionTintThickness.w *= real(map.SampleLevel(mapSampler, uv, 0).r);
  22. #else
  23. transmissionTintThickness.w *= real(map.Sample(mapSampler, uv).r);
  24. #endif /* CS_SAMPLERS */
  25. }
  26. }
  27. return transmissionTintThickness;
  28. }