SurfaceInput.hlsl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef UNIVERSAL_INPUT_SURFACE_INCLUDED
  2. #define UNIVERSAL_INPUT_SURFACE_INCLUDED
  3. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  4. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceData.hlsl"
  5. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
  6. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
  7. TEXTURE2D(_BaseMap);
  8. SAMPLER(sampler_BaseMap);
  9. float4 _BaseMap_TexelSize;
  10. float4 _BaseMap_MipInfo;
  11. TEXTURE2D(_BumpMap);
  12. SAMPLER(sampler_BumpMap);
  13. TEXTURE2D(_EmissionMap);
  14. SAMPLER(sampler_EmissionMap);
  15. ///////////////////////////////////////////////////////////////////////////////
  16. // Material Property Helpers //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. half Alpha(half albedoAlpha, half4 color, half cutoff)
  19. {
  20. #if !defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A) && !defined(_GLOSSINESS_FROM_BASE_ALPHA)
  21. half alpha = albedoAlpha * color.a;
  22. #else
  23. half alpha = color.a;
  24. #endif
  25. #if defined(_ALPHATEST_ON)
  26. clip(alpha - cutoff);
  27. #endif
  28. return alpha;
  29. }
  30. half4 SampleAlbedoAlpha(float2 uv, TEXTURE2D_PARAM(albedoAlphaMap, sampler_albedoAlphaMap))
  31. {
  32. return half4(SAMPLE_TEXTURE2D(albedoAlphaMap, sampler_albedoAlphaMap, uv));
  33. }
  34. half3 SampleNormal(float2 uv, TEXTURE2D_PARAM(bumpMap, sampler_bumpMap), half scale = half(1.0))
  35. {
  36. #ifdef _NORMALMAP
  37. half4 n = SAMPLE_TEXTURE2D(bumpMap, sampler_bumpMap, uv);
  38. #if BUMP_SCALE_NOT_SUPPORTED
  39. return UnpackNormal(n);
  40. #else
  41. return UnpackNormalScale(n, scale);
  42. #endif
  43. #else
  44. return half3(0.0h, 0.0h, 1.0h);
  45. #endif
  46. }
  47. half3 SampleEmission(float2 uv, half3 emissionColor, TEXTURE2D_PARAM(emissionMap, sampler_emissionMap))
  48. {
  49. #ifndef _EMISSION
  50. return 0;
  51. #else
  52. return SAMPLE_TEXTURE2D(emissionMap, sampler_emissionMap, uv).rgb * emissionColor;
  53. #endif
  54. }
  55. #endif