google/filament

POINT light does NOT work in android

Jrrrrrrrrrr opened this issue · 1 comments

Describe the bug
I used Filament version 1.52.0 in Android to render a glb file. After the rendering was successful and the background was set to transparent, I hoped to add lights to optimize the display effect of the 3D model. When I added DirectionalLight, I could see the effect. However, when I continued to add PointLight, there was no effect at all, and adding ambient light also had no effect.

To Reproduce
My code like:

 private fun createSimpleIndirectLight() {
    val engine = modelViewer.engine
    val scene = modelViewer.scene
    
    val indirectLight = IndirectLight.Builder()
        .intensity(130000f)  
        .build(engine)
    scene.indirectLight = indirectLight

    createDirectionalLight(scene, engine, floatArrayOf(-1f, -1f, -1f), 150000f, floatArrayOf(1.0f, 0.98f, 0.95f)) 

    createPointLight(
        scene, engine,
        position = floatArrayOf(0f, 1f, 10f),
        intensity = 130000f,
        color = floatArrayOf(0.9f, 0.95f, 1f) 
    )

    // 后光源(负Z方向)
    createPointLight(
        scene, engine,
        position = floatArrayOf(0f, 1f, -1f),
        intensity = 128000f,
        color = floatArrayOf(1f, 0.95f, 0.9f) 
    )

    // 左光源(负X方向)
    createPointLight(
        scene, engine,
        position = floatArrayOf(-1f, 1f, 0f),
        intensity = 135000f,
        color = floatArrayOf(0.8f, 0.9f, 1f) 
    )

    // 右光源(正X方向)
    createPointLight(
        scene, engine,
        position = floatArrayOf(1f, 1f, 0f),
        intensity = 135000f,
        color = floatArrayOf(1f, 0.9f, 0.8f) 
    )

    // 底部光源(负Y方向)
    createPointLight(
        scene, engine,
        position = floatArrayOf(0f, -3f, 0f),
        intensity = 120000f,
        color = floatArrayOf(0.85f, 0.85f, 0.9f) 
    )

    scene.skybox = null

    enableDetailEnhancement()
}

private fun createDirectionalLight(
    scene: Scene,
    engine: Engine,
    direction: FloatArray,
    intensity: Float,
    color: FloatArray,
) {
    val entity = EntityManager.get().create()
    LightManager.Builder(LightManager.Type.DIRECTIONAL)
        .direction(direction[0], direction[1], direction[2])
        .color(color[0], color[1], color[2])
        .intensity(intensity)
        .build(engine, entity)
    scene.addEntity(entity)
}

private fun createPointLight(
    scene: Scene,
    engine: Engine,
    position: FloatArray,
    intensity: Float,
    color: FloatArray,
) {
    val entity = EntityManager.get().create()
    LightManager.Builder(LightManager.Type.POINT)
        .position(position[0], position[1], position[2])
        .color(color[0], color[1], color[2])
        .intensity(intensity)
        .falloff(5f)
        .build(engine, entity)
    scene.addEntity(entity)
}

Expected behavior
Observe the effects of point light sources and ambient light.

Screenshots
If applicable, add screenshots to help explain your problem.

Logs
If applicable, copy full logs from your console here. Please do not
use screenshots of logs, copy them as text, use gist or attach an uncompressed file.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • GPU: [e.g. NVIDIA GTX 1080]
  • Backend: [OpenGL/Vulkan]

Smartphone (please complete the following information):

  • Device: In-car Android device
  • OS: Android (UpsideDownCake) 14.0

Additional context
Add any other context about the problem here.

You can check using filament sample code that all types of lights are working. Please check your code.