pbrLightFunctionsCall.fx 2.2 KB

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