pbrBlockSheen.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. // Do not edit.
  2. import { ShaderStore } from "../../Engines/shaderStore.js";
  3. const name = "pbrBlockSheen";
  4. const shader = `#ifdef SHEEN
  5. struct sheenOutParams
  6. {float sheenIntensity;vec3 sheenColor;float sheenRoughness;
  7. #ifdef SHEEN_LINKWITHALBEDO
  8. vec3 surfaceAlbedo;
  9. #endif
  10. #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
  11. float sheenAlbedoScaling;
  12. #endif
  13. #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  14. vec3 finalSheenRadianceScaled;
  15. #endif
  16. #if DEBUGMODE>0
  17. #ifdef SHEEN_TEXTURE
  18. vec4 sheenMapData;
  19. #endif
  20. #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  21. vec3 sheenEnvironmentReflectance;
  22. #endif
  23. #endif
  24. };
  25. #define pbr_inline
  26. #define inline
  27. void sheenBlock(
  28. in vec4 vSheenColor,
  29. #ifdef SHEEN_ROUGHNESS
  30. in float vSheenRoughness,
  31. #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
  32. in vec4 sheenMapRoughnessData,
  33. #endif
  34. #endif
  35. in float roughness,
  36. #ifdef SHEEN_TEXTURE
  37. in vec4 sheenMapData,
  38. in float sheenMapLevel,
  39. #endif
  40. in float reflectance,
  41. #ifdef SHEEN_LINKWITHALBEDO
  42. in vec3 baseColor,
  43. in vec3 surfaceAlbedo,
  44. #endif
  45. #ifdef ENVIRONMENTBRDF
  46. in float NdotV,
  47. in vec3 environmentBrdf,
  48. #endif
  49. #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  50. in vec2 AARoughnessFactors,
  51. in vec3 vReflectionMicrosurfaceInfos,
  52. in vec2 vReflectionInfos,
  53. in vec3 vReflectionColor,
  54. in vec4 vLightingIntensity,
  55. #ifdef REFLECTIONMAP_3D
  56. in samplerCube reflectionSampler,
  57. in vec3 reflectionCoords,
  58. #else
  59. in sampler2D reflectionSampler,
  60. in vec2 reflectionCoords,
  61. #endif
  62. in float NdotVUnclamped,
  63. #ifndef LODBASEDMICROSFURACE
  64. #ifdef REFLECTIONMAP_3D
  65. in samplerCube reflectionSamplerLow,
  66. in samplerCube reflectionSamplerHigh,
  67. #else
  68. in sampler2D reflectionSamplerLow,
  69. in sampler2D reflectionSamplerHigh,
  70. #endif
  71. #endif
  72. #ifdef REALTIME_FILTERING
  73. in vec2 vReflectionFilteringInfo,
  74. #endif
  75. #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
  76. in float seo,
  77. #endif
  78. #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
  79. in float eho,
  80. #endif
  81. #endif
  82. out sheenOutParams outParams
  83. )
  84. {float sheenIntensity=vSheenColor.a;
  85. #ifdef SHEEN_TEXTURE
  86. #if DEBUGMODE>0
  87. outParams.sheenMapData=sheenMapData;
  88. #endif
  89. #endif
  90. #ifdef SHEEN_LINKWITHALBEDO
  91. float sheenFactor=pow5(1.0-sheenIntensity);vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);float sheenRoughness=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
  92. #ifdef SHEEN_TEXTURE
  93. sheenIntensity*=sheenMapData.a;
  94. #endif
  95. #else
  96. vec3 sheenColor=vSheenColor.rgb;
  97. #ifdef SHEEN_TEXTURE
  98. #ifdef SHEEN_GAMMATEXTURE
  99. sheenColor.rgb*=toLinearSpace(sheenMapData.rgb);
  100. #else
  101. sheenColor.rgb*=sheenMapData.rgb;
  102. #endif
  103. sheenColor.rgb*=sheenMapLevel;
  104. #endif
  105. #ifdef SHEEN_ROUGHNESS
  106. float sheenRoughness=vSheenRoughness;
  107. #ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
  108. #if defined(SHEEN_TEXTURE)
  109. sheenRoughness*=sheenMapData.a;
  110. #endif
  111. #elif defined(SHEEN_TEXTURE_ROUGHNESS)
  112. sheenRoughness*=sheenMapRoughnessData.a;
  113. #endif
  114. #else
  115. float sheenRoughness=roughness;
  116. #ifdef SHEEN_TEXTURE
  117. sheenIntensity*=sheenMapData.a;
  118. #endif
  119. #endif
  120. #if !defined(SHEEN_ALBEDOSCALING)
  121. sheenIntensity*=(1.-reflectance);
  122. #endif
  123. sheenColor*=sheenIntensity;
  124. #endif
  125. #ifdef ENVIRONMENTBRDF
  126. /*#ifdef SHEEN_SOFTER
  127. vec3 environmentSheenBrdf=vec3(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));
  128. #else*/
  129. #ifdef SHEEN_ROUGHNESS
  130. vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
  131. #else
  132. vec3 environmentSheenBrdf=environmentBrdf;
  133. #endif
  134. /*#endif*/
  135. #endif
  136. #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
  137. float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
  138. #ifdef SPECULARAA
  139. sheenAlphaG+=AARoughnessFactors.y;
  140. #endif
  141. vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);sampleReflectionTexture(
  142. sheenAlphaG,
  143. vReflectionMicrosurfaceInfos,
  144. vReflectionInfos,
  145. vReflectionColor,
  146. #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
  147. NdotVUnclamped,
  148. #endif
  149. #ifdef LINEARSPECULARREFLECTION
  150. sheenRoughness,
  151. #endif
  152. reflectionSampler,
  153. reflectionCoords,
  154. #ifndef LODBASEDMICROSFURACE
  155. reflectionSamplerLow,
  156. reflectionSamplerHigh,
  157. #endif
  158. #ifdef REALTIME_FILTERING
  159. vReflectionFilteringInfo,
  160. #endif
  161. environmentSheenRadiance
  162. );vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
  163. #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
  164. sheenEnvironmentReflectance*=seo;
  165. #endif
  166. #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
  167. sheenEnvironmentReflectance*=eho;
  168. #endif
  169. #if DEBUGMODE>0
  170. outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
  171. #endif
  172. outParams.finalSheenRadianceScaled=
  173. environmentSheenRadiance.rgb *
  174. sheenEnvironmentReflectance *
  175. vLightingIntensity.z;
  176. #endif
  177. #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
  178. outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
  179. #endif
  180. outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;}
  181. #endif
  182. `;
  183. // Sideeffect
  184. ShaderStore.IncludesShadersStore[name] = shader;
  185. /** @internal */
  186. export const pbrBlockSheen = { name, shader };
  187. //# sourceMappingURL=pbrBlockSheen.js.map