A game about forced loneliness, made by TACStudios
1// This structure abstract uv mapping inside one struct. 2// It represent a mapping of any uv (with its associated tangent space for derivative if SurfaceGradient mode) - UVSet0 to 4, planar, triplanar 3 4#ifndef __SAMPLEUVMAPPING_HLSL__ 5#define __SAMPLEUVMAPPING_HLSL__ 6 7#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl" 8 9#define UV_MAPPING_UVSET 0 10#define UV_MAPPING_PLANAR 1 11#define UV_MAPPING_TRIPLANAR 2 12 13struct UVMapping 14{ 15 int mappingType; 16 float2 uv; // Current uv or planar uv 17 18 // Triplanar specific 19 float2 uvZY; 20 float2 uvXZ; 21 float2 uvXY; 22 23 float3 normalWS; // vertex normal 24 float3 triplanarWeights; 25 26#ifdef SURFACE_GRADIENT 27 // tangent basis to use when mappingType is UV_MAPPING_UVSET 28 // these are vertex level in world space 29 float3 tangentWS; 30 float3 bitangentWS; 31 // TODO: store also object normal map for object triplanar 32#endif 33}; 34 35// Multiple includes of the file to handle all variations of textures sampling for regular, lod and bias 36 37// Regular sampling functions 38#define ADD_FUNC_SUFFIX(Name) Name 39#define SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping, unused) SAMPLE_TEXTURE2D(textureName, samplerName, uvMapping) 40#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl" 41#undef ADD_FUNC_SUFFIX 42#undef SAMPLE_TEXTURE_FUNC 43 44// Lod sampling functions 45#define ADD_FUNC_SUFFIX(Name) MERGE_NAME(Name, Lod) 46#define SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, uvMapping, lod) 47#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl" 48#undef ADD_FUNC_SUFFIX 49#undef SAMPLE_TEXTURE_FUNC 50 51// Bias sampling functions 52#define ADD_FUNC_SUFFIX(Name) MERGE_NAME(Name, Bias) 53#define SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping, bias) SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, uvMapping, bias) 54#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl" 55#undef ADD_FUNC_SUFFIX 56#undef SAMPLE_TEXTURE_FUNC 57 58// Macro to improve readibility of surface data 59#define SAMPLE_UVMAPPING_TEXTURE2D(textureName, samplerName, uvMapping) SampleUVMapping(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, 0.0) // Last 0.0 is unused 60#define SAMPLE_UVMAPPING_TEXTURE2D_LOD(textureName, samplerName, uvMapping, lod) SampleUVMappingLod(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, lod) 61#define SAMPLE_UVMAPPING_TEXTURE2D_BIAS(textureName, samplerName, uvMapping, bias) SampleUVMappingBias(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, bias) 62 63#define SAMPLE_UVMAPPING_NORMALMAP(textureName, samplerName, uvMapping, scale) SampleUVMappingNormal(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, 0.0) 64#define SAMPLE_UVMAPPING_NORMALMAP_LOD(textureName, samplerName, uvMapping, scale, lod) SampleUVMappingNormalLod(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, lod) 65#define SAMPLE_UVMAPPING_NORMALMAP_BIAS(textureName, samplerName, uvMapping, scale, bias) SampleUVMappingNormalBias(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, bias) 66 67#define SAMPLE_UVMAPPING_NORMALMAP_AG(textureName, samplerName, uvMapping, scale) SampleUVMappingNormalAG(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, 0.0) 68#define SAMPLE_UVMAPPING_NORMALMAP_AG_LOD(textureName, samplerName, uvMapping, scale, lod) SampleUVMappingNormalAGLod(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, lod) 69#define SAMPLE_UVMAPPING_NORMALMAP_AG_BIAS(textureName, samplerName, uvMapping, scale, bias) SampleUVMappingNormalAGBias(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, bias) 70 71#define SAMPLE_UVMAPPING_NORMALMAP_RGB(textureName, samplerName, uvMapping, scale) SampleUVMappingNormalRGB(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, 0.0) 72#define SAMPLE_UVMAPPING_NORMALMAP_RGB_LOD(textureName, samplerName, uvMapping, scale, lod) SampleUVMappingNormalRGBLod(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, lod) 73#define SAMPLE_UVMAPPING_NORMALMAP_RGB_BIAS(textureName, samplerName, uvMapping, scale, bias) SampleUVMappingNormalRGBBias(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, bias) 74 75#endif //__SAMPLEUVMAPPING_HLSL__