diff options
| author | yum <yum.food.vr@gmail.com> | 2026-03-06 15:10:27 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-03-06 15:10:27 -0800 |
| commit | 20234b7fdc550fd3d2542391ac5bb735a7edb820 (patch) | |
| tree | f9ef3c10151a1186743dac32b1c25b891a171006 /globals.cginc | |
| parent | 86680bb2efb0854d95de8ca1dabbd7399d806dd9 (diff) | |
Switch from #ifdef to uniform branches for decals
Makes code much smaller & simpler, and shader locker constant folding
should make it just as efficient.
Diffstat (limited to 'globals.cginc')
| -rwxr-xr-x | globals.cginc | 111 |
1 files changed, 28 insertions, 83 deletions
diff --git a/globals.cginc b/globals.cginc index 44417ac..c7529b1 100755 --- a/globals.cginc +++ b/globals.cginc @@ -249,93 +249,38 @@ float _Parallax_Heightmap_Ray_Marching_Steps; #define DECAL_MIX_MODE_MULTIPLY 1 #define DECAL_MIX_MODE_ADD_PRODUCT 2 -#if defined(_DECAL0) -float4 _Decal0_Color; -texture2D _Decal0_MainTex; -float4 _Decal0_MainTex_ST; -float _Decal0_Opacity; -int _Decal0_UV_Mode; -int _Decal0_UV_Channel; -int _Decal0_Mix_Mode; -#if defined(_DECAL0_ROTATION) -float _Decal0_Rotation; -#endif // _DECAL0_ROTATION -#if defined(_DECAL0_MASK) -texture2D _Decal0_Mask; -float4 _Decal0_Mask_ST; -int _Decal0_Mask_UV_Channel; -#endif // _DECAL0_MASK -#if defined(_DECAL0_METALLIC_GLOSS) -texture2D _Decal0_Metallic_Gloss; -float4 _Decal0_Metallic_Gloss_ST; -#endif // _DECAL0_METALLIC_GLOSS -#endif // _DECAL0 +#define DECAL_GLOBALS(N) \ + float4 _Decal##N##_Color; \ + texture2D _Decal##N##_MainTex; \ + float4 _Decal##N##_MainTex_ST; \ + float _Decal##N##_Opacity; \ + int _Decal##N##_UV_Mode; \ + int _Decal##N##_UV_Channel; \ + int _Decal##N##_Mix_Mode; \ + float _Decal##N##_Rotation_Enabled; \ + float _Decal##N##_Rotation; \ + float _Decal##N##_Mask_Enabled; \ + texture2D _Decal##N##_Mask; \ + float4 _Decal##N##_Mask_ST; \ + int _Decal##N##_Mask_UV_Channel; \ + float _Decal##N##_Mask_Invert; \ + float _Decal##N##_Albedo_Clamp; \ + float _Decal##N##_Metallic_Gloss_Enabled; \ + texture2D _Decal##N##_Metallic_Gloss; \ + float4 _Decal##N##_Metallic_Gloss_ST; +#if defined(_DECAL0) +DECAL_GLOBALS(0) +#endif #if defined(_DECAL1) -float4 _Decal1_Color; -texture2D _Decal1_MainTex; -float4 _Decal1_MainTex_ST; -float _Decal1_Opacity; -int _Decal1_UV_Mode; -int _Decal1_UV_Channel; -int _Decal1_Mix_Mode; -#if defined(_DECAL1_ROTATION) -float _Decal1_Rotation; -#endif // _DECAL1_ROTATION -#if defined(_DECAL1_MASK) -texture2D _Decal1_Mask; -float4 _Decal1_Mask_ST; -int _Decal1_Mask_UV_Channel; -#endif // _DECAL1_MASK -#if defined(_DECAL1_METALLIC_GLOSS) -texture2D _Decal1_Metallic_Gloss; -float4 _Decal1_Metallic_Gloss_ST; -#endif // _DECAL1_METALLIC_GLOSS -#endif // _DECAL1 - +DECAL_GLOBALS(1) +#endif #if defined(_DECAL2) -float4 _Decal2_Color; -texture2D _Decal2_MainTex; -float4 _Decal2_MainTex_ST; -float _Decal2_Opacity; -int _Decal2_UV_Mode; -int _Decal2_UV_Channel; -int _Decal2_Mix_Mode; -#if defined(_DECAL2_ROTATION) -float _Decal2_Rotation; -#endif // _DECAL2_ROTATION -#if defined(_DECAL2_MASK) -texture2D _Decal2_Mask; -float4 _Decal2_Mask_ST; -int _Decal2_Mask_UV_Channel; -#endif // _DECAL2_MASK -#if defined(_DECAL2_METALLIC_GLOSS) -texture2D _Decal2_Metallic_Gloss; -float4 _Decal2_Metallic_Gloss_ST; -#endif // _DECAL2_METALLIC_GLOSS -#endif // _DECAL2 - +DECAL_GLOBALS(2) +#endif #if defined(_DECAL3) -float4 _Decal3_Color; -texture2D _Decal3_MainTex; -float4 _Decal3_MainTex_ST; -float _Decal3_Opacity; -int _Decal3_UV_Mode; -int _Decal3_UV_Channel; -int _Decal3_Mix_Mode; -#if defined(_DECAL3_ROTATION) -float _Decal3_Rotation; -#endif // _DECAL3_ROTATION -#if defined(_DECAL3_MASK) -texture2D _Decal3_Mask; -float4 _Decal3_Mask_ST; -int _Decal3_Mask_UV_Channel; -#endif // _DECAL3_MASK -#if defined(_DECAL3_METALLIC_GLOSS) -texture2D _Decal3_Metallic_Gloss; -float4 _Decal3_Metallic_Gloss_ST; -#endif // _DECAL3_METALLIC_GLOSS -#endif // _DECAL3 +DECAL_GLOBALS(3) +#endif #define MATCAP_MODE_REPLACE 0 #define MATCAP_MODE_ADD 1 |
