CSHARP 69
Untitled Guest on 7th June 2021 03:46:38 PM
  1. #ifndef UNIVERSAL_PIPELINE_CORE_INCLUDED
  2. #define UNIVERSAL_PIPELINE_CORE_INCLUDED
  3.  
  4. // VT is not supported in URP (for now) this ensures any shaders using the VT
  5. // node work by falling to regular texture sampling.
  6. #define FORCE_VIRTUAL_TEXTURING_OFF 1
  7.  
  8. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  9. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
  10. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl"
  11. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  12.  
  13. #if !defined(SHADER_HINT_NICE_QUALITY)
  14.     #if defined(SHADER_API_MOBILE) || defined(SHADER_API_SWITCH)
  15.         #define SHADER_HINT_NICE_QUALITY 0
  16.     #else
  17.         #define SHADER_HINT_NICE_QUALITY 1
  18.     #endif
  19. #endif
  20.  
  21. // Shader Quality Tiers in Universal.
  22. // SRP doesn't use Graphics Settings Quality Tiers.
  23. // We should expose shader quality tiers in the pipeline asset.
  24. // Meanwhile, it's forced to be:
  25. // High Quality: Non-mobile platforms or shader explicit defined SHADER_HINT_NICE_QUALITY
  26. // Medium: Mobile aside from GLES2
  27. // Low: GLES2
  28. #if SHADER_HINT_NICE_QUALITY
  29.     #define SHADER_QUALITY_HIGH
  30. #elif defined(SHADER_API_GLES)
  31.     #define SHADER_QUALITY_LOW
  32. #else
  33.     #define SHADER_QUALITY_MEDIUM
  34. #endif
  35.  
  36. #ifndef BUMP_SCALE_NOT_SUPPORTED
  37.     #define BUMP_SCALE_NOT_SUPPORTED !SHADER_HINT_NICE_QUALITY
  38. #endif
  39.  
  40.  
  41. #if UNITY_REVERSED_Z
  42.     #if SHADER_API_OPENGL || SHADER_API_GLES || SHADER_API_GLES3
  43.         //GL with reversed z => z clip range is [near, -far] -> should remap in theory but dont do it in practice to save some perf (range is close enough)
  44.         #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(-(coord), 0)
  45.     #else
  46.         //D3d with reversed Z => z clip range is [near, 0] -> remapping to [0, far]
  47.         //max is required to protect ourselves from near plane not being correct/meaningfull in case of oblique matrices.
  48.         #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(((1.0-(coord)/_ProjectionParams.y)*_ProjectionParams.z),0)
  49.     #endif
  50. #elif UNITY_UV_STARTS_AT_TOP
  51.     //D3d without reversed z => z clip range is [0, far] -> nothing to do
  52.     #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord)
  53. #else
  54.     //Opengl => z clip range is [-near, far] -> should remap in theory but dont do it in practice to save some perf (range is close enough)
  55.     #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord)
  56. #endif
  57.  
  58. // Stereo-related bits
  59. #if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
  60.  
  61.     #define SLICE_ARRAY_INDEX   unity_StereoEyeIndex
  62.  
  63.     #define TEXTURE2D_X(textureName)                                        TEXTURE2D_ARRAY(textureName)
  64.     #define TEXTURE2D_X_PARAM(textureName, samplerName)                     TEXTURE2D_ARRAY_PARAM(textureName, samplerName)
  65.     #define TEXTURE2D_X_ARGS(textureName, samplerName)                      TEXTURE2D_ARRAY_ARGS(textureName, samplerName)
  66.     #define TEXTURE2D_X_HALF(textureName)                                   TEXTURE2D_ARRAY_HALF(textureName)
  67.     #define TEXTURE2D_X_FLOAT(textureName)                                  TEXTURE2D_ARRAY_FLOAT(textureName)
  68.  
  69.     #define LOAD_TEXTURE2D_X(textureName, unCoord2)                         LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, SLICE_ARRAY_INDEX)
  70.     #define LOAD_TEXTURE2D_X_LOD(textureName, unCoord2, lod)                LOAD_TEXTURE2D_ARRAY_LOD(textureName, unCoord2, SLICE_ARRAY_INDEX, lod)
  71.     #define SAMPLE_TEXTURE2D_X(textureName, samplerName, coord2)            SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, SLICE_ARRAY_INDEX)
  72.     #define SAMPLE_TEXTURE2D_X_LOD(textureName, samplerName, coord2, lod)   SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, SLICE_ARRAY_INDEX, lod)
  73.     #define GATHER_TEXTURE2D_X(textureName, samplerName, coord2)            GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, SLICE_ARRAY_INDEX)
  74.     #define GATHER_RED_TEXTURE2D_X(textureName, samplerName, coord2)        GATHER_RED_TEXTURE2D(textureName, samplerName, float3(coord2, SLICE_ARRAY_INDEX))
  75.     #define GATHER_GREEN_TEXTURE2D_X(textureName, samplerName, coord2)      GATHER_GREEN_TEXTURE2D(textureName, samplerName, float3(coord2, SLICE_ARRAY_INDEX))
  76.     #define GATHER_BLUE_TEXTURE2D_X(textureName, samplerName, coord2)       GATHER_BLUE_TEXTURE2D(textureName, samplerName, float3(coord2, SLICE_ARRAY_INDEX))
  77.  
  78. #else
  79.     #define SLICE_ARRAY_INDEX       0
  80.  
  81.     #define TEXTURE2D_X(textureName)                                        TEXTURE2D(textureName)
  82.     #define TEXTURE2D_X_PARAM(textureName, samplerName)                     TEXTURE2D_PARAM(textureName, samplerName)
  83.     #define TEXTURE2D_X_ARGS(textureName, samplerName)                      TEXTURE2D_ARGS(textureName, samplerName)
  84.     #define TEXTURE2D_X_HALF(textureName)                                   TEXTURE2D_HALF(textureName)
  85.     #define TEXTURE2D_X_FLOAT(textureName)                                  TEXTURE2D_FLOAT(textureName)
  86.  
  87.     #define LOAD_TEXTURE2D_X(textureName, unCoord2)                         LOAD_TEXTURE2D(textureName, unCoord2)
  88.     #define LOAD_TEXTURE2D_X_LOD(textureName, unCoord2, lod)                LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod)
  89.     #define SAMPLE_TEXTURE2D_X(textureName, samplerName, coord2)            SAMPLE_TEXTURE2D(textureName, samplerName, coord2)
  90.     #define SAMPLE_TEXTURE2D_X_LOD(textureName, samplerName, coord2, lod)   SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod)
  91.     #define GATHER_TEXTURE2D_X(textureName, samplerName, coord2)            GATHER_TEXTURE2D(textureName, samplerName, coord2)
  92.     #define GATHER_RED_TEXTURE2D_X(textureName, samplerName, coord2)        GATHER_RED_TEXTURE2D(textureName, samplerName, coord2)
  93.     #define GATHER_GREEN_TEXTURE2D_X(textureName, samplerName, coord2)      GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2)
  94.     #define GATHER_BLUE_TEXTURE2D_X(textureName, samplerName, coord2)       GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2)
  95. #endif
  96.  
  97. // Structs
  98. struct VertexPositionInputs
  99. {
  100.     float3 positionWS; // World space position
  101.     float3 positionVS; // View space position
  102.     float4 positionCS; // Homogeneous clip space position
  103.     float4 positionNDC;// Homogeneous normalized device coordinates
  104. };
  105.  
  106. struct VertexNormalInputs
  107. {
  108.     real3 tangentWS;
  109.     real3 bitangentWS;
  110.     float3 normalWS;
  111. };
  112.  
  113. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderVariablesFunctions.hlsl"
  114. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Deprecated.hlsl"
  115.  
  116. #endif

CodePaste est fait pour le code source et le texte général de débogage.

Connectez-vous ou Enregistrez-vous pour éditer, supprimer et suivre vos pastes et bien plus.

Paste brut

Connectez-vous ou Enregistrez-vous pour éditer ou dupliquer ce paste. C'est gratuit !