pbrLightFunctionsCall.fx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifdef LIGHT{X}
  2. #if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
  3. //No light calculation
  4. #else
  5. #ifndef SPECULARTERM
  6. vec3 vLightSpecular{X} = vec3(0.0);
  7. #endif
  8. #ifdef SPOTLIGHT{X}
  9. info = computeSpotLighting(viewDirectionW, normalW, vLightData{X}, vLightDirection{X}, vLightDiffuse{X}.rgb, vLightSpecular{X}, vLightDiffuse{X}.a, roughness, NdotV, specularEnvironmentR90, NdotL);
  10. #endif
  11. #ifdef HEMILIGHT{X}
  12. info = computeHemisphericLighting(viewDirectionW, normalW, vLightData{X}, vLightDiffuse{X}.rgb, vLightSpecular{X}, vLightGround{X}, roughness, NdotV, specularEnvironmentR90, NdotL);
  13. #endif
  14. #if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
  15. info = computeLighting(viewDirectionW, normalW, vLightData{X}, vLightDiffuse{X}.rgb, vLightSpecular{X}, vLightDiffuse{X}.a, roughness, NdotV, specularEnvironmentR90, NdotL);
  16. #endif
  17. #endif
  18. #ifdef SHADOW{X}
  19. #ifdef SHADOWVSM{X}
  20. notShadowLevel = computeShadowWithVSM(vPositionFromLight{X}, shadowSampler{X}, shadowsInfo{X}.z, shadowsInfo{X}.x);
  21. #else
  22. #ifdef SHADOWPCF{X}
  23. #if defined(POINTLIGHT{X})
  24. notShadowLevel = computeShadowWithPCFCube(vLightData{X}.xyz, shadowSampler{X}, shadowsInfo{X}.y, shadowsInfo{X}.z, shadowsInfo{X}.x);
  25. #else
  26. notShadowLevel = computeShadowWithPCF(vPositionFromLight{X}, shadowSampler{X}, shadowsInfo{X}.y, shadowsInfo{X}.z, shadowsInfo{X}.x);
  27. #endif
  28. #else
  29. #if defined(POINTLIGHT{X})
  30. notShadowLevel = computeShadowCube(vLightData{X}.xyz, shadowSampler{X}, shadowsInfo{X}.x, shadowsInfo{X}.z);
  31. #else
  32. notShadowLevel = computeShadow(vPositionFromLight{X}, shadowSampler{X}, shadowsInfo{X}.x, shadowsInfo{X}.z);
  33. #endif
  34. #endif
  35. #endif
  36. #else
  37. notShadowLevel = 1.;
  38. #endif
  39. #if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
  40. lightDiffuseContribution += lightmapColor * notShadowLevel;
  41. #ifdef SPECULARTERM
  42. #ifndef LIGHTMAPNOSPECULAR{X}
  43. lightSpecularContribution += info.specular * notShadowLevel * lightmapColor;
  44. #endif
  45. #endif
  46. #else
  47. lightDiffuseContribution += info.diffuse * notShadowLevel;
  48. #ifdef OVERLOADEDSHADOWVALUES
  49. if (NdotL < 0.000000000011)
  50. {
  51. notShadowLevel = 1.;
  52. }
  53. shadowedOnlyLightDiffuseContribution *= notShadowLevel;
  54. #endif
  55. #ifdef SPECULARTERM
  56. lightSpecularContribution += info.specular * notShadowLevel;
  57. #endif
  58. #endif
  59. #endif