Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in specular calculation for image-based lighting #12008

Closed
jjhembd opened this issue May 30, 2024 · 0 comments · Fixed by #12006
Closed

Error in specular calculation for image-based lighting #12008

jjhembd opened this issue May 30, 2024 · 0 comments · Fixed by #12006

Comments

@jjhembd
Copy link
Contributor

jjhembd commented May 30, 2024

What happened?

For image-based lighting from supplied environment maps, the specular reflection for dark, smooth, dielectric surfaces is too dark.
image

A smooth surface should reflect some of the light from the environment. At wide reflection angles, where the light from the source just glances against the surface before continuing to the eye position, a smooth surface is almost 100% reflective. The above image should look more like this:
image
Notice the faint reflection of the environment map in each sphere.

The current calculation of the specular reflection is as follows:

    vec3 F = fresnelSchlick2(f0, f90, VdotH);
    vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;
    vec3 specularIBL = sampleSpecularEnvironment(cubeDir, roughness);
    specularIBL *= F * brdfLut.x + brdfLut.y;
    //...
    return f0 * specularIBL;

The additional f0 factor at the end looks like a mistake. The f0 color is already incorporated in the Fresnel term F, which is equal to f0 at normal incidence, but transitions toward a white reflectivity at glancing incidence. Removing the extra f0 factor would make the environment map lighting more consistent with our direct lighting, and also more consistent with other PBR implementations and PBR theory.

Reproduction steps

  1. Load the testing Sandcastle
  2. Note the flat black appearance of the spheres.
  3. Compare to the reference implementation and note the more reflective appearance of the spheres.

Sandcastle example

http://localhost:8080/Apps/Sandcastle/index.html#c=rVp7c9s2Ev8qqO5mqtzIFJ8iqUS5S+ykdetMMrbTm2nVcSASkliDhAYA7agdf/dbPPjQI3avzT+OCAK7i9++l8lYJSS6K8g94WiGKnKPToko6tL5Sa8N54NMP5+ySuKiInw+GKE/5hVCuCpKLAtWTdESU0FGalEWJaGwrb9WC/Kas3tB+CXJWFmSKif5JRGM1rvHH549n1fzKtMy/YFERioyQhkuCcf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rUxRFrK4gyADNmmGec0O/eBwgvOtbnIOux1IhbOX6HfGymumpbcEtINAVJHZGg0J54wf+0756Y16o7/OqKSij07RP//QBx4+tV72pN+80TNF9OP3lzclBHZegHfcNCq3HqMKkyccpq+Gj7Kg0Ck67VepN59186hmSsf5KD8xBJ/39OPoCuGM4/tTVpZwETFsG6C9AHgI404HxMAAGaX6i7b9NpxxQqqrDc7Iqe79Tts9vd5H7QfDWDsl/jzsS7ZgtY7NV7qUczhooRboX2rmElkbsi3lkkMhA8hUBODsz6gsN0el0LIuf4YbnIFtqOAHXLkm5npNd2Sn6kbbs94Qbe1IdgnLuBJDP7ZT8+bARs2sYbsZwrcyUcZuX8nHLgQYgY4Ou7edgT2uVmRoZRoZXiMtuOeEXvis9yF8MBq8EHJLycsmzvynKPWXdHDOoeOMJYHiCsxCjBc1mIF0MiGayvDFuH/0RV7coSKfHflvCNBDYiHgzbKm9Kr4ncwHL1+MYf/BUes276GgoHirtq29lxdm0XGcF2N4PH6yzdrtTV5I5UDto1pYsHzbW1BLfOdZreQvL5pkh6CMMOnuxRjWD3fursCa/sSO9Efk+YArRcD1gRo8ga7Vb/wZfnvmASLOxrzx4CmHEvZkAcEElu5Uap4eFmcjpN+YydEUfav5fdu79XFJVDug+AH28BT+SWYHZA9QgIU+gPC4AzE893TQV9z/AA

Environment

Browser: Chrome
CesiumJS Version: 1.117
Operating System: Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant