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

Blue light turns violett in Camera View #295

Closed
davidAnPrintell opened this issue Jan 28, 2022 · 30 comments · Fixed by #311
Closed

Blue light turns violett in Camera View #295

davidAnPrintell opened this issue Jan 28, 2022 · 30 comments · Fixed by #311

Comments

@davidAnPrintell
Copy link

Hi!

I faced some unexpected color behavior, if there is a blue light source indoor.
Im worried that there will be other color grading issues.

Expected Behavior

The camera view renders the expected color, like other AR cameras or the native camera.

Current Behavior

The camera view renders a violet color.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Run a sample Project (tested with Augmented Images and environment-lights) on an android device ( tested on an Samsung Galaxy S8 and S20).
  2. Turn a blue light source on

Context

Couldnt reproduce the issue with archived Sceneform 1.15.0.
Expected Behavior Screenshot is the sample AR-Core Augmented Images project (OpenGL Rendering)

Current Behavior testet with

  • SDK version: Android-Version 12
@ThomasGorisse
Copy link
Collaborator

Hi,

Can you try to disable light estimation?

@davidAnPrintell
Copy link
Author

Thanks for your quick reply.
I also had this issue with all the available configs in the sample light estimation app.

My Configs:

config.updateMode = Config.UpdateMode.LATEST_CAMERA_IMAGE
config.focusMode = Config.FocusMode.AUTO
config.planeFindingMode = Config.PlaneFindingMode.DISABLED
config.instantPlacementMode = Config.InstantPlacementMode.DISABLED
config.augmentedFaceMode = Config.AugmentedFaceMode.DISABLED
config.lightEstimationMode = Config.LightEstimationMode.DISABLED
config.augmentedImageDatabase = imageDatabase
session.configure(config)
arSceneView?.setSession(session)

@ThomasGorisse
Copy link
Collaborator

Please also call arSceneView.lightEstimationConfig = LightEstimationConfig.DISABLED

@davidAnPrintell
Copy link
Author

To better reproduce the issue, i just filmed some blue images from google images. Result:

First Img is my app with following configs:

                    config.updateMode = Config.UpdateMode.LATEST_CAMERA_IMAGE
                    config.focusMode = Config.FocusMode.AUTO;
                    config.planeFindingMode = Config.PlaneFindingMode.DISABLED
                    config.augmentedImageDatabase = imageDatabase
                    session.configure(config)
                    arSceneView?.lightEstimationConfig = LightEstimationConfig.DISABLED
                    arSceneView?.setSession(session)

Second Img is https://github.com/SceneView/sceneform-android/tree/master/samples/augmented-images

Thrid Img is https://github.com/google-ar/arcore-android-sdk/tree/master/samples/augmented_image_java

@ThomasGorisse
Copy link
Collaborator

ThomasGorisse commented Jan 28, 2022

@RGregat @grassydragon Do you think it could be a Filmic color mode issue?

@grassydragon
Copy link
Contributor

Since the inverseTonemapSRGB function is used in the camera material the camera image can be also affected by the color issues. According to Romain, the inverse tonemapping operation should be exact for the Filmic tonemapping. However, something could have changed in Filament or Sceneform because the problem with the ViewRenderable color has been reported recently: #252

@ThomasGorisse
Copy link
Collaborator

ThomasGorisse commented Jan 28, 2022

@davidAnPrintell Would you mind creating a discussion (not an issue) on the Filament repo and linking/mentioning this issue?

@ThomasGorisse
Copy link
Collaborator

BTW, thanks for your detailed issue.

@davidAnPrintell
Copy link
Author

Link for Diskussion: google/filament#5136

@romainguy
Copy link

It's a known side effect of inverse tone mapping. You are seeing a hue shift due to out of gamut colors. We already have an open bug for this and it's not entirely trivial to fix. In the meantime make sure you are using the FILMIC tone mapper.

@ThomasGorisse
Copy link
Collaborator

ThomasGorisse commented Jan 29, 2022

@grassydragon
Copy link
Contributor

If I use the deprecated toneMapping(ColorGrading.ToneMapping.FILMIC) here, the colors are rendered as expected:

@romainguy
Copy link

Yeah I need to find a good way to offer inverse tone mapping based on the selected tone mapper in ColorGrading.

@ThomasGorisse
Copy link
Collaborator

@davidAnPrintell Can you try calling this?

arSceneView.renderer!!.filamentView.colorGrading =
            ColorGrading.Builder().toneMapping(ColorGrading.ToneMapping.FILMIC)
                .build(EngineInstance.getEngine().filamentEngine)

@davidAnPrintell
Copy link
Author

Thanks a lot. Its solves the issue

@davidAnPrintell
Copy link
Author

I'll close this issue, since its a known filament bug.
Thanks for the help

@ThomasGorisse
Copy link
Collaborator

@grassydragon @RGregat Did we merged it?

@ThomasGorisse ThomasGorisse reopened this Feb 9, 2022
@grassydragon
Copy link
Contributor

@grassydragon @RGregat Did we merged it?

No, should we merge it and wait for the related Filament issue to be resolved?

@romainguy
Copy link

Note that toneMapping(ColorGrading.ToneMapping.FILMIC) will not go anywhere. It's marked deprecated because I'd like to move our users to " better" tone mappers, but we won't remove it from our APIs. You can safely use it.

Ideally I'd like everyone to use the generic tone mapper (terrible name, great tone mapper) with luminance scaling turned on.

@romainguy
Copy link

Except you have luminance scaling off :p But luminance scaling would need to be invertible, that's another story.

@ThomasGorisse
Copy link
Collaborator

Except you have luminance scaling off :p But luminance scaling would need to be invertible, that's another story.

Sorry I'm tired. Answer edited

@ThomasGorisse
Copy link
Collaborator

ThomasGorisse commented Feb 9, 2022

So we can't use the generic tone mapping even with luminanceScaling(true) to solve the blue issue?

@romainguy
Copy link

The problem is how inverseTonemap() works. It was designed for FILMIC, and will only be somewhat of an approximation with other tone mappers.

@ThomasGorisse
Copy link
Collaborator

@grassydragon I'm not good enough in fragment shader. Do you think there could be any other way than using the inverse tonemap for the camera stream here:

material.baseColor.rgb = inverseTonemapSRGB(color.rgb);

@grassydragon
Copy link
Contributor

I think only if we use the linear tone mapper or there is a way to disable the tone mapping for particular renderables (the camera stream and view renderables).

@romainguy
Copy link

Just use FILMIC and inverseTonemapSRGB() :)

@ThomasGorisse
Copy link
Collaborator

@grassydragon Can you PR it?
// Change the ToneMapper to FILMIC to avoid some over saturated
// colors, for example material orange 500.

renderer.getFilamentView().setColorGrading(
        new ColorGrading
                .Builder()
                .toneMapping(ColorGrading.ToneMapping.FILMIC)
                .build(EngineInstance.getEngine().getFilamentEngine())
);

@ThomasGorisse
Copy link
Collaborator

Surely not related but this blue issue made me thought about some color issues I had during lights estimation work.
I always though that it was due to ARCore more recognizing blue than other colors but could it be related to some Filmic color accentuation differences?

Screenshot_20210830-222747 Screenshot_20210830-223026 Screenshot_20210830-222818
Screenshot_20210830-222016 Screenshot_20210830-223223 Screenshot_20210830-221800

As you can see, red and green are less present in the reflections than other colors (Maybe it's only main light estimation issue but I try my luck)

@romainguy
Copy link

Seems like a light estimation issue. Tone mapping would not be responsible for removing green from the lighting.

@ThomasGorisse
Copy link
Collaborator

ThomasGorisse commented Feb 9, 2022

I just made the test again and confirm it's an ARCore "issue".
@devbridie, any idea why would red and green be less recognized?
On the right column, the ARCore estimated environment reflections applied to the Skybox. Main light color also applied.

Screenshot_20220209-205940 Screenshot_20220209-205945
Screenshot_20220209-210029 Screenshot_20220209-210018
Screenshot_20220209-210230 Screenshot_20220209-210145

@grassydragon grassydragon linked a pull request Feb 10, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants