pbrLightFunctionsCall.fx 3.0 KB

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