Newer
Older
HoloAnatomy / Assets / HoloToolkit / Common / Shaders / Obsolete / FastConfigurable / macro.cginc
SURFACEBOOK2\jackwynne on 25 May 2018 1 KB v1
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License. See LICENSE in the project root for license information.
  3.  
  4. #ifndef MACRO
  5. #define MACRO
  6.  
  7. //bootleg ternary operator - no __VA_ARGS__
  8. #define IIF(cond) IIF_ ## cond
  9. #define IIF_0(t, f) f
  10. #define IIF_1(t, f) t
  11.  
  12. #define CONCAT(arg1, arg2) arg1 ## arg2
  13.  
  14. #define TRANSFORM_TEX_00(uv, st) uv
  15. #define TRANSFORM_TEX_10(uv, st) uv * st.xy
  16. #define TRANSFORM_TEX_01(uv, st) uv + st.zw
  17. #define TRANSFORM_TEX_11(uv, st) uv * st.xy + st.zw
  18.  
  19. // main tex
  20. #ifdef _MainTex_SCALE_ON
  21. #define _MainTex_SCALE_TOGGLE 1
  22. #else
  23. #define _MainTex_SCALE_TOGGLE 0
  24. #endif
  25.  
  26. #ifdef _MainTex_OFFSET_ON
  27. #define _MainTex_OFFSET_TOGGLE 1
  28. #else
  29. #define _MainTex_OFFSET_TOGGLE 0
  30. #endif
  31.  
  32. #define MAINTEX_TYPE_S CONCAT(TRANSFORM_TEX_, _MainTex_SCALE_TOGGLE)
  33. #define MAINTEX_TYPE_SO CONCAT(MAINTEX_TYPE_S, _MainTex_OFFSET_TOGGLE)
  34. #define TRANSFORM_TEX_MAINTEX(uv, st) MAINTEX_TYPE_SO ## (uv, st)
  35.  
  36. //bump map
  37. #ifdef _BumpMap_SCALE_ON
  38. #define _BumpMap_SCALE_TOGGLE 1
  39. #else
  40. #define _BumpMap_SCALE_TOGGLE 0
  41. #endif
  42.  
  43. #ifdef _BumpMap_OFFSET_ON
  44. #define _BumpMap_OFFSET_TOGGLE 1
  45. #else
  46. #define _BumpMap_OFFSET_TOGGLE 0
  47. #endif
  48.  
  49. #define BUMPMAP_TYPE_S CONCAT(TRANSFORM_TEX_, _BumpMap_SCALE_TOGGLE)
  50. #define BUMPMAP_TYPE_SO CONCAT(BUMPMAP_TYPE_S, _BumpMap_OFFSET_TOGGLE)
  51. #define TRANSFORM_TEX_BUMPMAP(uv, st) BUMPMAP_TYPE_SO ## (uv, st)
  52.  
  53. //occlusion map
  54. #ifdef _OcclusionMap_SCALE_ON
  55. #define _OcclusionMap_SCALE_TOGGLE 1
  56. #else
  57. #define _OcclusionMap_SCALE_TOGGLE 0
  58. #endif
  59.  
  60. #ifdef _OcclusionMap_OFFSET_ON
  61. #define _OcclusionMap_OFFSET_TOGGLE 1
  62. #else
  63. #define _OcclusionMap_OFFSET_TOGGLE 0
  64. #endif
  65.  
  66. #define OCCLUSIONMAP_TYPE_S CONCAT(TRANSFORM_TEX_, _OcclusionMap_SCALE_TOGGLE)
  67. #define OCCLUSIONMAP_TYPE_SO CONCAT(OCCLUSIONMAP_TYPE_S, _OcclusionMap_OFFSET_TOGGLE)
  68. #define TRANSFORM_TEX_OCCLUSIONMAP(uv, st) OCCLUSIONMAP_TYPE_SO ## (uv, st)
  69.  
  70. #endif //MACRO