pbrDebug.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // Do not edit.
  2. import { ShaderStore } from "../../Engines/shaderStore.js";
  3. const name = "pbrDebug";
  4. const shader = `#if DEBUGMODE>0
  5. if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {
  6. #if DEBUGMODE==1
  7. gl_FragColor.rgb=vPositionW.rgb;
  8. #define DEBUGMODE_NORMALIZE
  9. #elif DEBUGMODE==2 && defined(NORMAL)
  10. gl_FragColor.rgb=vNormalW.rgb;
  11. #define DEBUGMODE_NORMALIZE
  12. #elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)
  13. gl_FragColor.rgb=TBN[0];
  14. #define DEBUGMODE_NORMALIZE
  15. #elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)
  16. gl_FragColor.rgb=TBN[1];
  17. #define DEBUGMODE_NORMALIZE
  18. #elif DEBUGMODE==5
  19. gl_FragColor.rgb=normalW;
  20. #define DEBUGMODE_NORMALIZE
  21. #elif DEBUGMODE==6 && defined(MAINUV1)
  22. gl_FragColor.rgb=vec3(vMainUV1,0.0);
  23. #elif DEBUGMODE==7 && defined(MAINUV2)
  24. gl_FragColor.rgb=vec3(vMainUV2,0.0);
  25. #elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
  26. gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];
  27. #define DEBUGMODE_NORMALIZE
  28. #elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
  29. gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];
  30. #define DEBUGMODE_NORMALIZE
  31. #elif DEBUGMODE==10 && defined(CLEARCOAT)
  32. gl_FragColor.rgb=clearcoatOut.clearCoatNormalW;
  33. #define DEBUGMODE_NORMALIZE
  34. #elif DEBUGMODE==11 && defined(ANISOTROPIC)
  35. gl_FragColor.rgb=anisotropicOut.anisotropicNormal;
  36. #define DEBUGMODE_NORMALIZE
  37. #elif DEBUGMODE==12 && defined(ANISOTROPIC)
  38. gl_FragColor.rgb=anisotropicOut.anisotropicTangent;
  39. #define DEBUGMODE_NORMALIZE
  40. #elif DEBUGMODE==13 && defined(ANISOTROPIC)
  41. gl_FragColor.rgb=anisotropicOut.anisotropicBitangent;
  42. #define DEBUGMODE_NORMALIZE
  43. #elif DEBUGMODE==20 && defined(ALBEDO)
  44. gl_FragColor.rgb=albedoTexture.rgb;
  45. #ifndef GAMMAALBEDO
  46. #define DEBUGMODE_GAMMA
  47. #endif
  48. #elif DEBUGMODE==21 && defined(AMBIENT)
  49. gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;
  50. #elif DEBUGMODE==22 && defined(OPACITY)
  51. gl_FragColor.rgb=opacityMap.rgb;
  52. #elif DEBUGMODE==23 && defined(EMISSIVE)
  53. gl_FragColor.rgb=emissiveColorTex.rgb;
  54. #ifndef GAMMAEMISSIVE
  55. #define DEBUGMODE_GAMMA
  56. #endif
  57. #elif DEBUGMODE==24 && defined(LIGHTMAP)
  58. gl_FragColor.rgb=lightmapColor.rgb;
  59. #ifndef GAMMALIGHTMAP
  60. #define DEBUGMODE_GAMMA
  61. #endif
  62. #elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
  63. gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;
  64. #elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
  65. gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;
  66. #define DEBUGMODE_GAMMA
  67. #elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
  68. gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);
  69. #elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
  70. gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;
  71. #elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
  72. gl_FragColor.rgb=sheenOut.sheenMapData.rgb;
  73. #elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
  74. gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;
  75. #elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
  76. gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;
  77. #elif DEBUGMODE==32 && defined(BUMP)
  78. gl_FragColor.rgb=texture2D(bumpSampler,vBumpUV).rgb;
  79. #elif DEBUGMODE==40 && defined(SS_REFRACTION)
  80. gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;
  81. #define DEBUGMODE_GAMMA
  82. #elif DEBUGMODE==41 && defined(REFLECTION)
  83. gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;
  84. #ifndef GAMMAREFLECTION
  85. #define DEBUGMODE_GAMMA
  86. #endif
  87. #elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)
  88. gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;
  89. #define DEBUGMODE_GAMMA
  90. #elif DEBUGMODE==50
  91. gl_FragColor.rgb=diffuseBase.rgb;
  92. #define DEBUGMODE_GAMMA
  93. #elif DEBUGMODE==51 && defined(SPECULARTERM)
  94. gl_FragColor.rgb=specularBase.rgb;
  95. #define DEBUGMODE_GAMMA
  96. #elif DEBUGMODE==52 && defined(CLEARCOAT)
  97. gl_FragColor.rgb=clearCoatBase.rgb;
  98. #define DEBUGMODE_GAMMA
  99. #elif DEBUGMODE==53 && defined(SHEEN)
  100. gl_FragColor.rgb=sheenBase.rgb;
  101. #define DEBUGMODE_GAMMA
  102. #elif DEBUGMODE==54 && defined(REFLECTION)
  103. gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;
  104. #ifndef GAMMAREFLECTION
  105. #define DEBUGMODE_GAMMA
  106. #endif
  107. #elif DEBUGMODE==60
  108. gl_FragColor.rgb=surfaceAlbedo.rgb;
  109. #define DEBUGMODE_GAMMA
  110. #elif DEBUGMODE==61
  111. gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;
  112. #define DEBUGMODE_GAMMA
  113. #elif DEBUGMODE==62 && defined(METALLICWORKFLOW)
  114. gl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);
  115. #elif DEBUGMODE==71 && defined(METALLICWORKFLOW)
  116. gl_FragColor.rgb=reflectivityOut.metallicF0;
  117. #elif DEBUGMODE==63
  118. gl_FragColor.rgb=vec3(roughness);
  119. #elif DEBUGMODE==64
  120. gl_FragColor.rgb=vec3(alphaG);
  121. #elif DEBUGMODE==65
  122. gl_FragColor.rgb=vec3(NdotV);
  123. #elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
  124. gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;
  125. #define DEBUGMODE_GAMMA
  126. #elif DEBUGMODE==67 && defined(CLEARCOAT)
  127. gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);
  128. #elif DEBUGMODE==68 && defined(CLEARCOAT)
  129. gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);
  130. #elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
  131. gl_FragColor.rgb=subSurfaceOut.transmittance;
  132. #elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
  133. gl_FragColor.rgb=subSurfaceOut.refractionTransmittance;
  134. #elif DEBUGMODE==72
  135. gl_FragColor.rgb=vec3(microSurface);
  136. #elif DEBUGMODE==73
  137. gl_FragColor.rgb=vAlbedoColor.rgb;
  138. #define DEBUGMODE_GAMMA
  139. #elif DEBUGMODE==74 && !defined(METALLICWORKFLOW)
  140. gl_FragColor.rgb=vReflectivityColor.rgb;
  141. #define DEBUGMODE_GAMMA
  142. #elif DEBUGMODE==75
  143. gl_FragColor.rgb=vEmissiveColor.rgb;
  144. #define DEBUGMODE_GAMMA
  145. #elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)
  146. gl_FragColor.rgb=vec3(seo);
  147. #elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
  148. gl_FragColor.rgb=vec3(eho);
  149. #elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)
  150. gl_FragColor.rgb=vec3(energyConservationFactor);
  151. #elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  152. gl_FragColor.rgb=specularEnvironmentReflectance;
  153. #define DEBUGMODE_GAMMA
  154. #elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  155. gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;
  156. #define DEBUGMODE_GAMMA
  157. #elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)
  158. gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;
  159. #define DEBUGMODE_GAMMA
  160. #elif DEBUGMODE==86 && defined(ALPHABLEND)
  161. gl_FragColor.rgb=vec3(luminanceOverAlpha);
  162. #elif DEBUGMODE==87
  163. gl_FragColor.rgb=vec3(alpha);
  164. #elif DEBUGMODE==88 && defined(ALBEDO)
  165. gl_FragColor.rgb=vec3(albedoTexture.a);
  166. #elif DEBUGMODE==89
  167. gl_FragColor.rgb=aoOut.ambientOcclusionColor.rgb;
  168. #else
  169. float stripeWidth=30.;float stripePos=floor((gl_FragCoord.x+gl_FragCoord.y)/stripeWidth);float whichColor=mod(stripePos,2.);vec3 color1=vec3(.6,.2,.2);vec3 color2=vec3(.3,.1,.1);gl_FragColor.rgb=mix(color1,color2,whichColor);
  170. #endif
  171. gl_FragColor.rgb*=vDebugMode.y;
  172. #ifdef DEBUGMODE_NORMALIZE
  173. gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;
  174. #endif
  175. #ifdef DEBUGMODE_GAMMA
  176. gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);
  177. #endif
  178. gl_FragColor.a=1.0;
  179. #ifdef PREPASS
  180. gl_FragData[0]=toLinearSpace(gl_FragColor);
  181. gl_FragData[1]=vec4(0.,0.,0.,0.);
  182. #endif
  183. #ifdef DEBUGMODE_FORCERETURN
  184. return;
  185. #endif
  186. }
  187. #endif
  188. `;
  189. // Sideeffect
  190. ShaderStore.IncludesShadersStore[name] = shader;
  191. /** @internal */
  192. export const pbrDebug = { name, shader };
  193. //# sourceMappingURL=pbrDebug.js.map