#ifndef UNIVERSAL_PIPELINE_CORE_INCLUDED #define UNIVERSAL_PIPELINE_CORE_INCLUDED // VT is not supported in URP (for now) this ensures any shaders using the VT // node work by falling to regular texture sampling. #define FORCE_VIRTUAL_TEXTURING_OFF 1 #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #if !defined(SHADER_HINT_NICE_QUALITY) #if defined(SHADER_API_MOBILE) || defined(SHADER_API_SWITCH) #define SHADER_HINT_NICE_QUALITY 0 #else #define SHADER_HINT_NICE_QUALITY 1 #endif #endif // Shader Quality Tiers in Universal. // SRP doesn't use Graphics Settings Quality Tiers. // We should expose shader quality tiers in the pipeline asset. // Meanwhile, it's forced to be: // High Quality: Non-mobile platforms or shader explicit defined SHADER_HINT_NICE_QUALITY // Medium: Mobile aside from GLES2 // Low: GLES2 #if SHADER_HINT_NICE_QUALITY #define SHADER_QUALITY_HIGH #elif defined(SHADER_API_GLES) #define SHADER_QUALITY_LOW #else #define SHADER_QUALITY_MEDIUM #endif #ifndef BUMP_SCALE_NOT_SUPPORTED #define BUMP_SCALE_NOT_SUPPORTED !SHADER_HINT_NICE_QUALITY #endif #if UNITY_REVERSED_Z // TODO: workaround. There's a bug where SHADER_API_GL_CORE gets erroneously defined on switch. #if (defined(SHADER_API_GLCORE) && !defined(SHADER_API_SWITCH)) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) //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) #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(-(coord), 0) #else //D3d with reversed Z => z clip range is [near, 0] -> remapping to [0, far] //max is required to protect ourselves from near plane not being correct/meaningfull in case of oblique matrices. #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(((1.0-(coord)/_ProjectionParams.y)*_ProjectionParams.z),0) #endif #elif UNITY_UV_STARTS_AT_TOP //D3d without reversed z => z clip range is [0, far] -> nothing to do #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord) #else //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) #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord) #endif // Stereo-related bits #if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) #define SLICE_ARRAY_INDEX unity_StereoEyeIndex #define TEXTURE2D_X(textureName) TEXTURE2D_ARRAY(textureName) #define TEXTURE2D_X_PARAM(textureName, samplerName) TEXTURE2D_ARRAY_PARAM(textureName, samplerName) #define TEXTURE2D_X_ARGS(textureName, samplerName) TEXTURE2D_ARRAY_ARGS(textureName, samplerName) #define TEXTURE2D_X_HALF(textureName) TEXTURE2D_ARRAY_HALF(textureName) #define TEXTURE2D_X_FLOAT(textureName) TEXTURE2D_ARRAY_FLOAT(textureName) #define LOAD_TEXTURE2D_X(textureName, unCoord2) LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, SLICE_ARRAY_INDEX) #define LOAD_TEXTURE2D_X_LOD(textureName, unCoord2, lod) LOAD_TEXTURE2D_ARRAY_LOD(textureName, unCoord2, SLICE_ARRAY_INDEX, lod) #define SAMPLE_TEXTURE2D_X(textureName, samplerName, coord2) SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, SLICE_ARRAY_INDEX) #define SAMPLE_TEXTURE2D_X_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, SLICE_ARRAY_INDEX, lod) #define GATHER_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, SLICE_ARRAY_INDEX) #define GATHER_RED_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_RED_TEXTURE2D(textureName, samplerName, float3(coord2, SLICE_ARRAY_INDEX)) #define GATHER_GREEN_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_GREEN_TEXTURE2D(textureName, samplerName, float3(coord2, SLICE_ARRAY_INDEX)) #define GATHER_BLUE_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_BLUE_TEXTURE2D(textureName, samplerName, float3(coord2, SLICE_ARRAY_INDEX)) #else #define SLICE_ARRAY_INDEX 0 #define TEXTURE2D_X(textureName) TEXTURE2D(textureName) #define TEXTURE2D_X_PARAM(textureName, samplerName) TEXTURE2D_PARAM(textureName, samplerName) #define TEXTURE2D_X_ARGS(textureName, samplerName) TEXTURE2D_ARGS(textureName, samplerName) #define TEXTURE2D_X_HALF(textureName) TEXTURE2D_HALF(textureName) #define TEXTURE2D_X_FLOAT(textureName) TEXTURE2D_FLOAT(textureName) #define LOAD_TEXTURE2D_X(textureName, unCoord2) LOAD_TEXTURE2D(textureName, unCoord2) #define LOAD_TEXTURE2D_X_LOD(textureName, unCoord2, lod) LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) #define SAMPLE_TEXTURE2D_X(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2) #define SAMPLE_TEXTURE2D_X_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) #define GATHER_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_TEXTURE2D(textureName, samplerName, coord2) #define GATHER_RED_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) #define GATHER_GREEN_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) #define GATHER_BLUE_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) #endif // Structs struct VertexPositionInputs { float3 positionWS; // World space position float3 positionVS; // View space position float4 positionCS; // Homogeneous clip space position float4 positionNDC;// Homogeneous normalized device coordinates }; struct VertexNormalInputs { real3 tangentWS; real3 bitangentWS; float3 normalWS; }; #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderVariablesFunctions.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Deprecated.hlsl" #endif