2

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?

2 Answers2

1

There is an example available in the ArCore SDK hello_ar_java sample. The code can be found here: https://github.com/google-ar/arcore-android-sdk/blob/master/samples/hello_ar_java/.

Light estimate is read in HelloArActivity.java. The coefficients are pre-multiplied in the method updateSphericalHarmonicsCoefficients(), then written to an opengl uniform buffer. The opengl shader code that uses the values can be found in environmental_hdr.vert and environmental_hdr.frag.

shield
  • 139
  • 1
  • 7
0

Same situation here.

Any luck on finding any example?

MAML
  • 83
  • 7