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?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
dupi
  • 121
  • 2

0 Answers0