summaryrefslogtreecommitdiffstats
path: root/texture_macros.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-01-19 13:25:52 -0800
committeryum <yum.food.vr@gmail.com>2025-01-19 13:25:52 -0800
commitffc4bb2c80582cd81aa801bff9c274d833076ae6 (patch)
treef733af8b33b4c980386d2a3f2d533b8ce8611403 /texture_macros.cginc
parentbee103e89fc83030bfc0251db5a78bb153042e1f (diff)
Add terrain gimmick (ds2_11) and analytic fog (fog01)
Diffstat (limited to 'texture_macros.cginc')
-rw-r--r--texture_macros.cginc189
1 files changed, 189 insertions, 0 deletions
diff --git a/texture_macros.cginc b/texture_macros.cginc
new file mode 100644
index 0000000..c82e432
--- /dev/null
+++ b/texture_macros.cginc
@@ -0,0 +1,189 @@
+#ifndef __TEXTURE_MACROS_INC
+#define __TEXTURE_MACROS_INC
+
+#include "interpolators.cginc"
+
+float2 get_uv_by_channel(v2f i, uint which_channel) {
+ switch (which_channel) {
+ case 0:
+ return i.uv0;
+ break;
+#if !defined(_OPTIMIZE_INTERPOLATORS)
+ case 1:
+ return i.uv1;
+ break;
+#if !defined(LIGHTMAP_ON)
+ case 2:
+ return i.uv2;
+ break;
+ case 3:
+ return i.uv3;
+ break;
+ case 4:
+ return i.uv4;
+ break;
+ case 5:
+ return i.uv5;
+ break;
+ case 6:
+ return i.uv6;
+ break;
+ case 7:
+ return i.uv7;
+ break;
+#endif
+#endif // _OPTIMIZE_INTERPOLATORS
+ default:
+ return 0;
+ break;
+ }
+}
+
+#define UV_SCOFF(i, tex_st, which_channel) get_uv_by_channel(i, round(which_channel)) * (tex_st).xy + (tex_st).zw
+
+#if defined(_PBR_SAMPLER_LINEAR_REPEAT)
+#define GET_SAMPLER_PBR linear_repeat_s
+#elif defined(_PBR_SAMPLER_LINEAR_CLAMP)
+#define GET_SAMPLER_PBR linear_clamp_s
+#elif defined(_PBR_SAMPLER_POINT_REPEAT)
+#define GET_SAMPLER_PBR point_repeat_s
+#elif defined(_PBR_SAMPLER_POINT_CLAMP)
+#define GET_SAMPLER_PBR point_clamp_s
+#elif defined(_PBR_SAMPLER_BILINEAR_REPEAT)
+#define GET_SAMPLER_PBR bilinear_repeat_s
+#elif defined(_PBR_SAMPLER_BILINEAR_CLAMP)
+#define GET_SAMPLER_PBR bilinear_clamp_s
+#else
+#define GET_SAMPLER_PBR bilinear_clamp_s
+#endif
+
+#if defined(_PBR_OVERLAY0_SAMPLER_LINEAR_REPEAT)
+#define GET_SAMPLER_OV0 linear_repeat_s
+#elif defined(_PBR_OVERLAY0_SAMPLER_LINEAR_CLAMP)
+#define GET_SAMPLER_OV0 linear_clamp_s
+#elif defined(_PBR_OVERLAY0_SAMPLER_POINT_REPEAT)
+#define GET_SAMPLER_OV0 point_repeat_s
+#elif defined(_PBR_OVERLAY0_SAMPLER_POINT_CLAMP)
+#define GET_SAMPLER_OV0 point_clamp_s
+#elif defined(_PBR_OVERLAY0_SAMPLER_BILINEAR_REPEAT)
+#define GET_SAMPLER_OV0 bilinear_repeat_s
+#elif defined(_PBR_OVERLAY0_SAMPLER_BILINEAR_CLAMP)
+#define GET_SAMPLER_OV0 bilinear_clamp_s
+#else
+#define GET_SAMPLER_OV0 linear_clamp_s
+#endif
+
+#if defined(_PBR_OVERLAY1_SAMPLER_LINEAR_REPEAT)
+#define GET_SAMPLER_OV1 linear_repeat_s
+#elif defined(_PBR_OVERLAY1_SAMPLER_LINEAR_CLAMP)
+#define GET_SAMPLER_OV1 linear_clamp_s
+#elif defined(_PBR_OVERLAY1_SAMPLER_POINT_REPEAT)
+#define GET_SAMPLER_OV1 point_repeat_s
+#elif defined(_PBR_OVERLAY1_SAMPLER_POINT_CLAMP)
+#define GET_SAMPLER_OV1 point_clamp_s
+#elif defined(_PBR_OVERLAY1_SAMPLER_BILINEAR_REPEAT)
+#define GET_SAMPLER_OV1 bilinear_repeat_s
+#elif defined(_PBR_OVERLAY1_SAMPLER_BILINEAR_CLAMP)
+#define GET_SAMPLER_OV1 bilinear_clamp_s
+#else
+#define GET_SAMPLER_OV1 linear_clamp_s
+#endif
+
+#if defined(_PBR_OVERLAY2_SAMPLER_LINEAR_REPEAT)
+#define GET_SAMPLER_OV2 linear_repeat_s
+#elif defined(_PBR_OVERLAY2_SAMPLER_LINEAR_CLAMP)
+#define GET_SAMPLER_OV2 linear_clamp_s
+#elif defined(_PBR_OVERLAY2_SAMPLER_POINT_REPEAT)
+#define GET_SAMPLER_OV2 point_repeat_s
+#elif defined(_PBR_OVERLAY2_SAMPLER_POINT_CLAMP)
+#define GET_SAMPLER_OV2 point_clamp_s
+#elif defined(_PBR_OVERLAY2_SAMPLER_BILINEAR_REPEAT)
+#define GET_SAMPLER_OV2 bilinear_repeat_s
+#elif defined(_PBR_OVERLAY2_SAMPLER_BILINEAR_CLAMP)
+#define GET_SAMPLER_OV2 bilinear_clamp_s
+#else
+#define GET_SAMPLER_OV2 linear_clamp_s
+#endif
+
+#if defined(_PBR_OVERLAY3_SAMPLER_LINEAR_REPEAT)
+#define GET_SAMPLER_OV3 linear_repeat_s
+#elif defined(_PBR_OVERLAY3_SAMPLER_LINEAR_CLAMP)
+#define GET_SAMPLER_OV3 linear_clamp_s
+#elif defined(_PBR_OVERLAY3_SAMPLER_POINT_REPEAT)
+#define GET_SAMPLER_OV3 point_repeat_s
+#elif defined(_PBR_OVERLAY3_SAMPLER_POINT_CLAMP)
+#define GET_SAMPLER_OV3 point_clamp_s
+#elif defined(_PBR_OVERLAY3_SAMPLER_BILINEAR_REPEAT)
+#define GET_SAMPLER_OV3 bilinear_repeat_s
+#elif defined(_PBR_OVERLAY3_SAMPLER_BILINEAR_CLAMP)
+#define GET_SAMPLER_OV3 bilinear_clamp_s
+#else
+#define GET_SAMPLER_OV3 linear_clamp_s
+#endif
+
+#if defined(_RIM_LIGHTING0_SAMPLER_LINEAR_REPEAT)
+#define GET_SAMPLER_RL0 linear_repeat_s
+#elif defined(_RIM_LIGHTING0_SAMPLER_LINEAR_CLAMP)
+#define GET_SAMPLER_RL0 linear_clamp_s
+#elif defined(_RIM_LIGHTING0_SAMPLER_POINT_REPEAT)
+#define GET_SAMPLER_RL0 point_repeat_s
+#elif defined(_RIM_LIGHTING0_SAMPLER_POINT_CLAMP)
+#define GET_SAMPLER_RL0 point_clamp_s
+#elif defined(_RIM_LIGHTING0_SAMPLER_BILINEAR_REPEAT)
+#define GET_SAMPLER_RL0 bilinear_repeat_s
+#elif defined(_RIM_LIGHTING0_SAMPLER_BILINEAR_CLAMP)
+#define GET_SAMPLER_RL0 bilinear_clamp_s
+#else
+#define GET_SAMPLER_RL0 linear_clamp_s
+#endif
+
+#if defined(_RIM_LIGHTING1_SAMPLER_LINEAR_REPEAT)
+#define GET_SAMPLER_RL1 linear_repeat_s
+#elif defined(_RIM_LIGHTING1_SAMPLER_LINEAR_CLAMP)
+#define GET_SAMPLER_RL1 linear_clamp_s
+#elif defined(_RIM_LIGHTING1_SAMPLER_POINT_REPEAT)
+#define GET_SAMPLER_RL1 point_repeat_s
+#elif defined(_RIM_LIGHTING1_SAMPLER_POINT_CLAMP)
+#define GET_SAMPLER_RL1 point_clamp_s
+#elif defined(_RIM_LIGHTING1_SAMPLER_BILINEAR_REPEAT)
+#define GET_SAMPLER_RL1 bilinear_repeat_s
+#elif defined(_RIM_LIGHTING1_SAMPLER_BILINEAR_CLAMP)
+#define GET_SAMPLER_RL1 bilinear_clamp_s
+#else
+#define GET_SAMPLER_RL1 linear_clamp_s
+#endif
+
+#if defined(_RIM_LIGHTING2_SAMPLER_LINEAR_REPEAT)
+#define GET_SAMPLER_RL2 linear_repeat_s
+#elif defined(_RIM_LIGHTING2_SAMPLER_LINEAR_CLAMP)
+#define GET_SAMPLER_RL2 linear_clamp_s
+#elif defined(_RIM_LIGHTING2_SAMPLER_POINT_REPEAT)
+#define GET_SAMPLER_RL2 point_repeat_s
+#elif defined(_RIM_LIGHTING2_SAMPLER_POINT_CLAMP)
+#define GET_SAMPLER_RL2 point_clamp_s
+#elif defined(_RIM_LIGHTING2_SAMPLER_BILINEAR_REPEAT)
+#define GET_SAMPLER_RL2 bilinear_repeat_s
+#elif defined(_RIM_LIGHTING2_SAMPLER_BILINEAR_CLAMP)
+#define GET_SAMPLER_RL2 bilinear_clamp_s
+#else
+#define GET_SAMPLER_RL2 linear_clamp_s
+#endif
+
+#if defined(_RIM_LIGHTING3_SAMPLER_LINEAR_REPEAT)
+#define GET_SAMPLER_RL3 linear_repeat_s
+#elif defined(_RIM_LIGHTING3_SAMPLER_LINEAR_CLAMP)
+#define GET_SAMPLER_RL3 linear_clamp_s
+#elif defined(_RIM_LIGHTING3_SAMPLER_POINT_REPEAT)
+#define GET_SAMPLER_RL3 point_repeat_s
+#elif defined(_RIM_LIGHTING3_SAMPLER_POINT_CLAMP)
+#define GET_SAMPLER_RL3 point_clamp_s
+#elif defined(_RIM_LIGHTING3_SAMPLER_BILINEAR_REPEAT)
+#define GET_SAMPLER_RL3 bilinear_repeat_s
+#elif defined(_RIM_LIGHTING3_SAMPLER_BILINEAR_CLAMP)
+#define GET_SAMPLER_RL3 bilinear_clamp_s
+#else
+#define GET_SAMPLER_RL3 linear_clamp_s
+#endif
+
+#endif // __TEXTURE_MACROS_INC
+