Reflection GGX mip selection wrong

Hey @Deltakosh and @sebavan … I have an issue with my reflections being real weak on materials that have a metallic roughness texture exported from Unity. When I export textures that have a metallic roughness textures the metallic and roughness values are use as a scaler 1.0 value. The is scrweing up the roughness → mip level selection for reflections.

How would I deal with something like that ?

Are you sure it is not related to the prefiltering technique you are using ?

The mips would be generated wrong which either over or under blur.

It might be, It might also have to do the left handed gltf and the winding. I am playing with that.
But it may also have to do with lodGenerateScale and offset.

Do you have any details on customizing the prefilter… basically how to pick the perfect scale and offset.

This is how i am using that ROUGHNESS now:

        prefilterMat.SetTexture("_EnvCube", envForPrefilter);
        prefilterMat.SetInt("_SampleCount", samples);
        prefilterMat.SetInt("_Convention", 0); // Always use DX convention in your code

        for (int mip = 0; mip < mipCount; mip++)
        {
            float linearRoughnessAlpha;
            if (mip == 0)
            {
                linearRoughnessAlpha = 0f;
            }
            else
            {
                linearRoughnessAlpha = Mathf.Pow(2.0f, (mip - lodGenerationOffset) / lodGenerationScale) / size;
            }

            float roughness = Mathf.Sqrt(Mathf.Max(0f, linearRoughnessAlpha));
            prefilterMat.SetFloat("_Roughness", roughness);

            for (int faceIndex = 0; faceIndex < 6; faceIndex++)
            {
                prefilterMat.SetInt("_FaceIndex", faceIndex);

                Graphics.SetRenderTarget(cubeRT, mip, Faces[faceIndex]);
                GL.PushMatrix();
                GL.LoadOrtho();
                prefilterMat.SetPass(0);
                DrawFullscreenQuad();
                GL.PopMatrix();
            }
        }

so the default lod scale is 0.8 and offset is 0.

What is the best way to calculate those guys ?

So crap… when i strip everything out and just run Babylon Toolkit right handed gltf with my Babylon Toolkit prefiltered .env

Now I see reflections… I still need to holla at you about the details of using lodgenerationscale and offset… @sebavan

So that means, something in my toolkit material parsing is killing reflections… I gotta go thru that whole pipeline to find WHAT THE HECK is doing that.

But on the bright side… my prefilter system seems like its working:

https://playground.babylonjs.com/#PF48GI#1

Was for sure an issue with my material pipeline (still gotta clean that up)… But the lighting i was working on exporting Unity:

RGBD Skybox
Spherical Harmoics
Reflection Probes (Prefiltered .env files)

Unity Screenshot with Unity Lighting And HDR Skybox And EXR Environment:

Babylon Toolkit Export with Babylon Lighting And RGBD Skybox And Prefiltered ENV

Damm near pixel perfect Babylon Toolkit export:

1 Like

looks perfect to me !!!