pbrDebug.fx 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #if DEBUGMODE > 0
  2. if (vClipSpacePosition.x / vClipSpacePosition.w < vDebugMode.x) {
  3. return;
  4. }
  5. // Geometry
  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) || defined(PARALLAX) || defined(ANISOTROPIC))
  13. // Tangents
  14. gl_FragColor.rgb = TBN[0];
  15. #define DEBUGMODE_NORMALIZE
  16. #elif DEBUGMODE == 4 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))
  17. // BiTangents
  18. gl_FragColor.rgb = TBN[1];
  19. #define DEBUGMODE_NORMALIZE
  20. #elif DEBUGMODE == 5
  21. // Bump Normals
  22. gl_FragColor.rgb = normalW;
  23. #define DEBUGMODE_NORMALIZE
  24. #elif DEBUGMODE == 6 && defined(MAINUV1)
  25. gl_FragColor.rgb = vec3(vMainUV1, 0.0);
  26. #elif DEBUGMODE == 7 && defined(MAINUV2)
  27. gl_FragColor.rgb = vec3(vMainUV2, 0.0);
  28. #elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
  29. // ClearCoat Tangents
  30. gl_FragColor.rgb = TBNClearCoat[0];
  31. #define DEBUGMODE_NORMALIZE
  32. #elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
  33. // ClearCoat BiTangents
  34. gl_FragColor.rgb = TBNClearCoat[1];
  35. #define DEBUGMODE_NORMALIZE
  36. #elif DEBUGMODE == 10 && defined(CLEARCOAT)
  37. // ClearCoat Bump Normals
  38. gl_FragColor.rgb = clearCoatNormalW;
  39. #define DEBUGMODE_NORMALIZE
  40. #elif DEBUGMODE == 11 && defined(ANISOTROPIC)
  41. gl_FragColor.rgb = anisotropicNormal;
  42. #define DEBUGMODE_NORMALIZE
  43. #elif DEBUGMODE == 12 && defined(ANISOTROPIC)
  44. gl_FragColor.rgb = anisotropicTangent;
  45. #define DEBUGMODE_NORMALIZE
  46. #elif DEBUGMODE == 13 && defined(ANISOTROPIC)
  47. gl_FragColor.rgb = anisotropicBitangent;
  48. #define DEBUGMODE_NORMALIZE
  49. // Maps
  50. #elif DEBUGMODE == 20 && defined(ALBEDO)
  51. gl_FragColor.rgb = albedoTexture.rgb;
  52. #elif DEBUGMODE == 21 && defined(AMBIENT)
  53. gl_FragColor.rgb = ambientOcclusionColorMap.rgb;
  54. #elif DEBUGMODE == 22 && defined(OPACITY)
  55. gl_FragColor.rgb = opacityMap.rgb;
  56. #elif DEBUGMODE == 23 && defined(EMISSIVE)
  57. gl_FragColor.rgb = emissiveColorTex.rgb;
  58. #define DEBUGMODE_GAMMA
  59. #elif DEBUGMODE == 24 && defined(LIGHTMAP)
  60. gl_FragColor.rgb = lightmapColor.rgb;
  61. #define DEBUGMODE_GAMMA
  62. #elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
  63. gl_FragColor.rgb = surfaceMetallicColorMap.rgb;
  64. #elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
  65. gl_FragColor.rgb = surfaceReflectivityColorMap.rgb;
  66. #define DEBUGMODE_GAMMA
  67. #elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
  68. gl_FragColor.rgb = vec3(clearCoatMapData.rg, 0.0);
  69. #elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
  70. gl_FragColor.rgb = clearCoatTintMapData.rgb;
  71. #elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
  72. gl_FragColor.rgb = sheenMapData.rgb;
  73. #elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
  74. gl_FragColor.rgb = anisotropyMapData.rgb;
  75. #elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
  76. gl_FragColor.rgb = thicknessMap.rgb;
  77. // Env
  78. #elif DEBUGMODE == 40 && defined(SS_REFRACTION)
  79. // Base color.
  80. gl_FragColor.rgb = environmentRefraction.rgb;
  81. #define DEBUGMODE_GAMMA
  82. #elif DEBUGMODE == 41 && defined(REFLECTION)
  83. gl_FragColor.rgb = environmentRadiance.rgb;
  84. #define DEBUGMODE_GAMMA
  85. #elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)
  86. gl_FragColor.rgb = environmentClearCoatRadiance;
  87. #define DEBUGMODE_GAMMA
  88. // Lighting
  89. #elif DEBUGMODE == 50
  90. gl_FragColor.rgb = diffuseBase.rgb;
  91. #define DEBUGMODE_GAMMA
  92. #elif DEBUGMODE == 51 && defined(SPECULARTERM)
  93. gl_FragColor.rgb = specularBase.rgb;
  94. #define DEBUGMODE_GAMMA
  95. #elif DEBUGMODE == 52 && defined(CLEARCOAT)
  96. gl_FragColor.rgb = clearCoatBase.rgb;
  97. #define DEBUGMODE_GAMMA
  98. #elif DEBUGMODE == 53 && defined(SHEEN)
  99. gl_FragColor.rgb = sheenBase.rgb;
  100. #define DEBUGMODE_GAMMA
  101. #elif DEBUGMODE == 54 && defined(REFLECTION)
  102. gl_FragColor.rgb = environmentIrradiance.rgb;
  103. #define DEBUGMODE_GAMMA
  104. // Lighting Params
  105. #elif DEBUGMODE == 60
  106. gl_FragColor.rgb = surfaceAlbedo.rgb;
  107. #define DEBUGMODE_GAMMA
  108. #elif DEBUGMODE == 61
  109. gl_FragColor.rgb = specularEnvironmentR0;
  110. #define DEBUGMODE_GAMMA
  111. #elif DEBUGMODE == 62 && defined(METALLICWORKFLOW)
  112. gl_FragColor.rgb = vec3(metallicRoughness.r);
  113. #elif DEBUGMODE == 71 && defined(METALLICWORKFLOW)
  114. gl_FragColor.rgb = metallicF0;
  115. #elif DEBUGMODE == 63
  116. gl_FragColor.rgb = vec3(roughness);
  117. #elif DEBUGMODE == 64
  118. gl_FragColor.rgb = vec3(alphaG);
  119. #elif DEBUGMODE == 65
  120. gl_FragColor.rgb = vec3(NdotV);
  121. #elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
  122. gl_FragColor.rgb = clearCoatColor.rgb;
  123. #define DEBUGMODE_GAMMA
  124. #elif DEBUGMODE == 67 && defined(CLEARCOAT)
  125. gl_FragColor.rgb = vec3(clearCoatRoughness);
  126. #elif DEBUGMODE == 68 && defined(CLEARCOAT)
  127. gl_FragColor.rgb = vec3(clearCoatNdotV);
  128. #elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
  129. gl_FragColor.rgb = transmittance;
  130. #elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
  131. gl_FragColor.rgb = refractionTransmittance;
  132. // Misc
  133. #elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION)
  134. gl_FragColor.rgb = vec3(seo);
  135. #elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION)
  136. gl_FragColor.rgb = vec3(eho);
  137. #elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION)
  138. gl_FragColor.rgb = vec3(energyConservationFactor);
  139. #elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  140. gl_FragColor.rgb = specularEnvironmentReflectance;
  141. #define DEBUGMODE_GAMMA
  142. #elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
  143. gl_FragColor.rgb = clearCoatEnvironmentReflectance;
  144. #define DEBUGMODE_GAMMA
  145. #elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION)
  146. gl_FragColor.rgb = sheenEnvironmentReflectance;
  147. #define DEBUGMODE_GAMMA
  148. #elif DEBUGMODE == 86 && defined(ALPHABLEND)
  149. gl_FragColor.rgb = vec3(luminanceOverAlpha);
  150. #elif DEBUGMODE == 87
  151. gl_FragColor.rgb = vec3(alpha);
  152. #endif
  153. gl_FragColor.rgb *= vDebugMode.y;
  154. #ifdef DEBUGMODE_NORMALIZE
  155. gl_FragColor.rgb = normalize(gl_FragColor.rgb) * 0.5 + 0.5;
  156. #endif
  157. #ifdef DEBUGMODE_GAMMA
  158. gl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);
  159. #endif
  160. gl_FragColor.a = 1.0;
  161. #endif