forked from patriciogonzalezvivo/lygia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sampler.hlsl
50 lines (41 loc) · 1.3 KB
/
sampler.hlsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
contributors: Patricio Gonzalez Vivo
description: It defines the default sampler type and function for the shader.
license:
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
*/
#if defined(__SHADER_TARGET_MAJOR) && __SHADER_TARGET_MAJOR < 4
#ifndef SAMPLER_FNC
#define SAMPLER_FNC(TEX, UV) tex2D(TEX, UV)
#endif
#ifndef SAMPLER_TYPE
#define SAMPLER_TYPE sampler2D
#endif
#else
// https://docs.unity3d.com/Manual/SL-SamplerStates.html
#ifndef SAMPLER_BILINEAR_CLAMP
#define SAMPLER_BILINEAR_CLAMP defaultLinearClampSampler
SamplerState SAMPLER_BILINEAR_CLAMP
{
Filter = MIN_MAG_LINEAR_MIP_POINT;
AddressU = Clamp;
AddressV = Clamp;
};
#endif
#ifndef SAMPLER_TRILINEAR_CLAMP
#define SAMPLER_TRILINEAR_CLAMP defaultTrilinearClampSampler
SamplerState SAMPLER_TRILINEAR_CLAMP
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};
#endif
#ifndef SAMPLER_FNC
#define SAMPLER_FNC(TEX, UV) TEX.Sample(SAMPLER_BILINEAR_CLAMP, UV)
#endif
#ifndef SAMPLER_TYPE
#define SAMPLER_TYPE Texture2D
#endif
#endif