pbrFragmentSamplersDeclaration.fx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #ifdef ALBEDO
  2. #if ALBEDODIRECTUV == 1
  3. #define vAlbedoUV vMainUV1
  4. #elif ALBEDODIRECTUV == 2
  5. #define vAlbedoUV vMainUV2
  6. #else
  7. varying vec2 vAlbedoUV;
  8. #endif
  9. uniform sampler2D albedoSampler;
  10. #endif
  11. #ifdef AMBIENT
  12. #if AMBIENTDIRECTUV == 1
  13. #define vAmbientUV vMainUV1
  14. #elif AMBIENTDIRECTUV == 2
  15. #define vAmbientUV vMainUV2
  16. #else
  17. varying vec2 vAmbientUV;
  18. #endif
  19. uniform sampler2D ambientSampler;
  20. #endif
  21. #ifdef OPACITY
  22. #if OPACITYDIRECTUV == 1
  23. #define vOpacityUV vMainUV1
  24. #elif OPACITYDIRECTUV == 2
  25. #define vOpacityUV vMainUV2
  26. #else
  27. varying vec2 vOpacityUV;
  28. #endif
  29. uniform sampler2D opacitySampler;
  30. #endif
  31. #ifdef EMISSIVE
  32. #if EMISSIVEDIRECTUV == 1
  33. #define vEmissiveUV vMainUV1
  34. #elif EMISSIVEDIRECTUV == 2
  35. #define vEmissiveUV vMainUV2
  36. #else
  37. varying vec2 vEmissiveUV;
  38. #endif
  39. uniform sampler2D emissiveSampler;
  40. #endif
  41. #ifdef LIGHTMAP
  42. #if LIGHTMAPDIRECTUV == 1
  43. #define vLightmapUV vMainUV1
  44. #elif LIGHTMAPDIRECTUV == 2
  45. #define vLightmapUV vMainUV2
  46. #else
  47. varying vec2 vLightmapUV;
  48. #endif
  49. uniform sampler2D lightmapSampler;
  50. #endif
  51. #ifdef REFLECTIVITY
  52. #if REFLECTIVITYDIRECTUV == 1
  53. #define vReflectivityUV vMainUV1
  54. #elif REFLECTIVITYDIRECTUV == 2
  55. #define vReflectivityUV vMainUV2
  56. #else
  57. varying vec2 vReflectivityUV;
  58. #endif
  59. uniform sampler2D reflectivitySampler;
  60. #endif
  61. #ifdef MICROSURFACEMAP
  62. #if MICROSURFACEMAPDIRECTUV == 1
  63. #define vMicroSurfaceSamplerUV vMainUV1
  64. #elif MICROSURFACEMAPDIRECTUV == 2
  65. #define vMicroSurfaceSamplerUV vMainUV2
  66. #else
  67. varying vec2 vMicroSurfaceSamplerUV;
  68. #endif
  69. uniform sampler2D microSurfaceSampler;
  70. #endif
  71. #ifdef CLEARCOAT
  72. #ifdef CLEARCOAT_TEXTURE
  73. #if CLEARCOAT_TEXTUREDIRECTUV == 1
  74. #define vClearCoatUV vMainUV1
  75. #elif CLEARCOAT_TEXTUREDIRECTUV == 2
  76. #define vClearCoatUV vMainUV2
  77. #else
  78. varying vec2 vClearCoatUV;
  79. #endif
  80. uniform sampler2D clearCoatSampler;
  81. #endif
  82. #ifdef CLEARCOAT_BUMP
  83. #if CLEARCOAT_BUMPDIRECTUV == 1
  84. #define vClearCoatBumpUV vMainUV1
  85. #elif CLEARCOAT_BUMPDIRECTUV == 2
  86. #define vClearCoatBumpUV vMainUV2
  87. #else
  88. varying vec2 vClearCoatBumpUV;
  89. #endif
  90. uniform sampler2D clearCoatBumpSampler;
  91. #endif
  92. #ifdef CLEARCOAT_TINT_TEXTURE
  93. #if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1
  94. #define vClearCoatTintUV vMainUV1
  95. #elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2
  96. #define vClearCoatTintUV vMainUV2
  97. #else
  98. varying vec2 vClearCoatTintUV;
  99. #endif
  100. uniform sampler2D clearCoatTintSampler;
  101. #endif
  102. #endif
  103. #ifdef SHEEN
  104. #ifdef SHEEN_TEXTURE
  105. #if SHEEN_TEXTUREDIRECTUV == 1
  106. #define vSheenUV vMainUV1
  107. #elif SHEEN_TEXTUREDIRECTUV == 2
  108. #define vSheenUV vMainUV2
  109. #else
  110. varying vec2 vSheenUV;
  111. #endif
  112. uniform sampler2D sheenSampler;
  113. #endif
  114. #endif
  115. #ifdef ANISOTROPIC
  116. #ifdef ANISOTROPIC_TEXTURE
  117. #if ANISOTROPIC_TEXTUREDIRECTUV == 1
  118. #define vAnisotropyUV vMainUV1
  119. #elif ANISOTROPIC_TEXTUREDIRECTUV == 2
  120. #define vAnisotropyUV vMainUV2
  121. #else
  122. varying vec2 vAnisotropyUV;
  123. #endif
  124. uniform sampler2D anisotropySampler;
  125. #endif
  126. #endif
  127. // Reflection
  128. #ifdef REFLECTION
  129. #ifdef REFLECTIONMAP_3D
  130. #define sampleReflection(s, c) textureCube(s, c)
  131. uniform samplerCube reflectionSampler;
  132. #ifdef LODBASEDMICROSFURACE
  133. #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)
  134. #else
  135. uniform samplerCube reflectionSamplerLow;
  136. uniform samplerCube reflectionSamplerHigh;
  137. #endif
  138. #ifdef USEIRRADIANCEMAP
  139. uniform samplerCube irradianceSampler;
  140. #endif
  141. #else
  142. #define sampleReflection(s, c) texture2D(s, c)
  143. uniform sampler2D reflectionSampler;
  144. #ifdef LODBASEDMICROSFURACE
  145. #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)
  146. #else
  147. uniform sampler2D reflectionSamplerLow;
  148. uniform sampler2D reflectionSamplerHigh;
  149. #endif
  150. #ifdef USEIRRADIANCEMAP
  151. uniform sampler2D irradianceSampler;
  152. #endif
  153. #endif
  154. #ifdef REFLECTIONMAP_SKYBOX
  155. varying vec3 vPositionUVW;
  156. #else
  157. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  158. varying vec3 vDirectionW;
  159. #endif
  160. #endif
  161. #endif
  162. #ifdef ENVIRONMENTBRDF
  163. uniform sampler2D environmentBrdfSampler;
  164. #endif
  165. // SUBSURFACE
  166. #ifdef SUBSURFACE
  167. #ifdef SS_REFRACTION
  168. #ifdef SS_REFRACTIONMAP_3D
  169. #define sampleRefraction(s, c) textureCube(s, c)
  170. uniform samplerCube refractionSampler;
  171. #ifdef LODBASEDMICROSFURACE
  172. #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)
  173. #else
  174. uniform samplerCube refractionSamplerLow;
  175. uniform samplerCube refractionSamplerHigh;
  176. #endif
  177. #else
  178. #define sampleRefraction(s, c) texture2D(s, c)
  179. uniform sampler2D refractionSampler;
  180. #ifdef LODBASEDMICROSFURACE
  181. #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)
  182. #else
  183. uniform sampler2D refractionSamplerLow;
  184. uniform sampler2D refractionSamplerHigh;
  185. #endif
  186. #endif
  187. #endif
  188. #ifdef SS_THICKNESSANDMASK_TEXTURE
  189. #if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1
  190. #define vThicknessUV vMainUV1
  191. #elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2
  192. #define vThicknessUV vMainUV2
  193. #else
  194. varying vec2 vThicknessUV;
  195. #endif
  196. uniform sampler2D thicknessSampler;
  197. #endif
  198. #endif