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.82k stars 1.89k forks source link

Custom material color is darker in android device #8142

Closed zhangbo-0213 closed 1 week ago

zhangbo-0213 commented 1 month ago

Describe the bug we use custom material and set the same color, but in some android device , the color is darker, while iOS is lighter, the iOS color is what we wanted; and if we restart the app, the color is the same with iOS in some android device, sometime we start app , the material color in android device is normal, but sometime it is darker(30%-40% appear), while the color in iOS device is always right.

To Reproduce Steps to reproduce the behavior: use the custom material in android device

Expected behavior the color in android device should always be the same with iOS device

Logs here is the custom material mat:

material {
name : CarPainter,
shadingModel : lit,
blending : opaque,
flipUV:false,
requires : [
uv0
],
parameters : [
{
type : float3,
name : baseColorFactor
},
{
type : sampler2d,
name : gradientMapFactor
},
{
type : float3,
name : gradientColorFactor
},
{
type : sampler2d,
name : baseMapFactor
},
{
type : float3,
name : baseMapColorFactor
},
{
type : float3,
name : subsurfaceColorFactor
},
{
type : float,
name : roughnessFactor
},
{
type : float,
name : metallicFactor
},
{
type : float,
name : reflectance
},
{
type : float3,
name : sheenColorFactor
},
{
type : float,
name : sheenRoughnessFactor
},
{
type : float,
name : clearCoatFactor
},
{
type : float,
name : clearCoatRoughnessFactor
},
{
type : sampler2d,
name : ambientOcclusionMapFactor
}
]
}

fragment {
void material(inout MaterialInputs material) {
    prepareMaterial(material);
    float gradientValue = texture(materialParams_gradientMapFactor, getUV0()).r;
    float baseMapValue = texture(materialParams_baseMapFactor, getUV0()).r;
    material.baseColor.rgb = saturate((materialParams.baseColorFactor * (1.0 - gradientValue) +     materialParams.gradientColorFactor * gradientValue) * (1.0 - baseMapValue) + materialParams.baseMapColorFactor * baseMapValue);

    material.roughness = materialParams.roughnessFactor;
    material.metallic = materialParams.metallicFactor;

    material.sheenColor = materialParams.sheenColorFactor;
    material.sheenRoughness = materialParams.sheenRoughnessFactor;
    material.clearCoat = materialParams.clearCoatFactor;
    material.clearCoatRoughness = materialParams.clearCoatRoughnessFactor;
    material.ambientOcclusion = texture(materialParams_ambientOcclusionMapFactor, getUV0()).r ;
}
}

Smartphone (please complete the following information): Device: iPhone 13 / Redmi Note 11T Pro OS: iOS 17.4.1 / Android 14

Additional context Filament 1.28.0

pixelflinger commented 1 month ago

Can you attach some screenshot and repro steps? Which app did you use? Do you see the problem on the Android emulator, or on other devices?

This bug report is not actionable, there is nothing we can do or investigate.