No Description
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.

SurfaceInput.hlsl 2.0KB

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