How to implement Environmental HDR Lighting Estimation in Sceneform?
Asked Answered
L

0

12

I´m trying to implement lighting estimation with new Google's API Environmental HDR. I'm following the instructions in developer guide, but I don't know how to implement the app-specific code.

I have configure the session like this:

config.setLightEstimationMode(Config.LightEstimationMode.ENVIRONMENTAL_HDR);
session.configure(config);

And put this code in my update call

private void onSceneUpdate(FrameTime frameTime) {

    if (fragment instanceof ArFragment && loadedRenderable) {

        if ( frame == null )
            return;
            LightEstimate lightEstimate = frame.getLightEstimate();
            // note - currently only out param.
            float[] intensity = lightEstimate.getEnvironmentalHdrMainLightIntensity(); 
            float[] direction = lightEstimate.getEnvironmentalHdrMainLightDirection();
            //app.setDirectionalLightValues(intensity, direction);

            float[] harmonics = lightEstimate.getEnvironmentalHdrAmbientSphericalHarmonics();
            //app.setAmbientSphericalHarmonicsLightValues(harmonics); // app-specific code.

            // Get HDR environmental lighting as a cubemap in linear color space.
            Image[] lightmaps = lightEstimate.acquireEnvironmentalHdrCubeMap();

            for (int i = 0; i < lightmaps.length /*should be 6*/; ++i) {
                //app.UploadToTexture(i, lightmaps[i]);

            }
        }
    }
}

I can't figure out what to do with the parameters provided by those methods

I just want to light the 3D model with the same light conditions as the scene. Can anyone help me to achieve this? Or provide any example?

Lagoon answered 24/7, 2019 at 14:26 Comment(3)
did you get any solution?Auraaural
i have black models when apply ENVIRONMENTAL_HDR even if i do setLookDirection for sun from lightEstimate.getEnvironmentalHdrMainLightDirection()..Donofrio
I didn't find any workaround for this yet. I'm stuck with the same problem as @VadimShved saidLagoon

© 2022 - 2024 — McMap. All rights reserved.