|
103 | 103 | #define GATHER_BLUE_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) |
104 | 104 | #endif |
105 | 105 |
|
| 106 | +/// |
| 107 | +/// Texture Sampling Macro Overrides for Scaling |
| 108 | +/// |
| 109 | +/// When mip bias is supported by the underlying platform, the following section redefines all 2d texturing operations to support a global mip bias feature. |
| 110 | +/// This feature is used to improve rendering quality when image scaling is active. It achieves this by adding a bias value to the standard mip lod calculation |
| 111 | +/// which allows us to select the mip level based on the final image resolution rather than the current rendering resolution. |
| 112 | + |
| 113 | +#ifdef PLATFORM_SAMPLE_TEXTURE2D_BIAS |
| 114 | + #ifdef SAMPLE_TEXTURE2D |
| 115 | + #undef SAMPLE_TEXTURE2D |
| 116 | + #define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) \ |
| 117 | + PLATFORM_SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, _GlobalMipBias.x) |
| 118 | + #endif |
| 119 | + #ifdef SAMPLE_TEXTURE2D_BIAS |
| 120 | + #undef SAMPLE_TEXTURE2D_BIAS |
| 121 | + #define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) \ |
| 122 | + PLATFORM_SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, (bias + _GlobalMipBias.x)) |
| 123 | + #endif |
| 124 | +#endif |
| 125 | + |
| 126 | +#ifdef PLATFORM_SAMPLE_TEXTURE2D_GRAD |
| 127 | + #ifdef SAMPLE_TEXTURE2D_GRAD |
| 128 | + #undef SAMPLE_TEXTURE2D_GRAD |
| 129 | + #define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) \ |
| 130 | + PLATFORM_SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, (dpdx * _GlobalMipBias.y), (dpdy * _GlobalMipBias.y)) |
| 131 | + #endif |
| 132 | +#endif |
| 133 | + |
| 134 | +#ifdef PLATFORM_SAMPLE_TEXTURE2D_ARRAY_BIAS |
| 135 | + #ifdef SAMPLE_TEXTURE2D_ARRAY |
| 136 | + #undef SAMPLE_TEXTURE2D_ARRAY |
| 137 | + #define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) \ |
| 138 | + PLATFORM_SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, _GlobalMipBias.x) |
| 139 | + #endif |
| 140 | + #ifdef SAMPLE_TEXTURE2D_ARRAY_BIAS |
| 141 | + #undef SAMPLE_TEXTURE2D_ARRAY_BIAS |
| 142 | + #define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) \ |
| 143 | + PLATFORM_SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, (bias + _GlobalMipBias.x)) |
| 144 | + #endif |
| 145 | +#endif |
| 146 | + |
| 147 | +#ifdef PLATFORM_SAMPLE_TEXTURECUBE_BIAS |
| 148 | + #ifdef SAMPLE_TEXTURECUBE |
| 149 | + #undef SAMPLE_TEXTURECUBE |
| 150 | + #define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) \ |
| 151 | + PLATFORM_SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, _GlobalMipBias.x) |
| 152 | + #endif |
| 153 | + #ifdef SAMPLE_TEXTURECUBE_BIAS |
| 154 | + #undef SAMPLE_TEXTURECUBE_BIAS |
| 155 | + #define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) \ |
| 156 | + PLATFORM_SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, (bias + _GlobalMipBias.x)) |
| 157 | + #endif |
| 158 | +#endif |
| 159 | + |
| 160 | +#ifdef PLATFORM_SAMPLE_TEXTURECUBE_ARRAY_BIAS |
| 161 | + |
| 162 | + #ifdef SAMPLE_TEXTURECUBE_ARRAY |
| 163 | + #undef SAMPLE_TEXTURECUBE_ARRAY |
| 164 | + #define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index)\ |
| 165 | + PLATFORM_SAMPLE_TEXTURECUBE_ARRAY_BIAS(textureName, samplerName, coord3, index, _GlobalMipBias.x) |
| 166 | + #endif |
| 167 | + |
| 168 | + #ifdef SAMPLE_TEXTURECUBE_ARRAY_BIAS |
| 169 | + #undef SAMPLE_TEXTURECUBE_ARRAY_BIAS |
| 170 | + #define SAMPLE_TEXTURECUBE_ARRAY_BIAS(textureName, samplerName, coord3, index, bias)\ |
| 171 | + PLATFORM_SAMPLE_TEXTURECUBE_ARRAY_BIAS(textureName, samplerName, coord3, index, (bias + _GlobalMipBias.x)) |
| 172 | + #endif |
| 173 | +#endif |
| 174 | + |
| 175 | +#define VT_GLOBAL_MIP_BIAS_MULTIPLIER (_GlobalMipBias.y) |
| 176 | + |
106 | 177 | // Structs |
107 | 178 | struct VertexPositionInputs |
108 | 179 | { |
|
0 commit comments