google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.8k stars 1.89k forks source link

unlit material color error #3435

Closed JackKaiXing closed 3 years ago

JackKaiXing commented 3 years ago

Hello,

I created a material with shadingModel : unlit and material.baseColor.rgb = vec3(1.0, 0.0,0.0), however the resulting color in my monitor is (0.96, 0.12, 0.07).

Any ideas about how I can fix this?

romainguy commented 3 years ago

There are two reasons for this: tone mapping and color grading. Turn of post processing or use linear tone mapping if you want exact colors. You can also use the inverse tonemap function described in the materials documentation.

JackKaiXing commented 3 years ago

@romainguy turn off the post processing works. However, just set tone mapping to linear does not work. I also tried to set color grading to linear. Any ideas?

romainguy commented 3 years ago

Use the inverse tonemap function in your material. You can also increase the color grading quality to avoid rounding error.

JackKaiXing commented 3 years ago

@romainguy

I tried the following... view->setPostProcessingEnabled(true) view->setToneMapping(filament::View::ToneMapping::Linear)

in my unlit material, material.baseColor.rgb = vec3(211.0f/255.0f, 233.0f/255.0f,232.0f/255.0f) , i tried both with and without inverseTonemap and it stiil does not output the desired color.

any ideas?

romainguy commented 3 years ago

You're not supposed to set tone mapping to linear and use the inverse function. Do one or the other. But again this won't be always exact, only turning off post processing is (or using linear tone mapping + ultra quality post processing).

JackKaiXing commented 3 years ago

@romainguy

how to set ultra quality post processing. I am new to filament.

And does it possible to render some stuff with post processing and some stuff not, during one frame.

romainguy commented 3 years ago

Sorry ultra quality color grading.

JackKaiXing commented 3 years ago

@romainguy

I tried the following... view->setPostProcessingEnabled(true) view->setToneMapping(filament::View::ToneMapping::Linear) without InverseToneMapping in my unlit material.

The above lines does not working correct for desired colors until I do newColor = sRGB_to_linear (myOldColor) as mentioned in material docs and then set newColor to my unlit material. After this, the output color of my monitor is basically equal to myOldColor.

Is there any settings about input color space?