You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让Sceneform中的emissive(自发光)属性生效?

问题:Sceneform中emissive属性无法生效,无法实现光晕效果

我已尝试所有方法,甚至查看了Filament源码,但仍不清楚为何Sceneform中的emissive属性无法生效。根据官方文档描述:"emissive的主要用途是在HDR管线配置了bloom通道时,让无光照表面产生光晕效果",我清楚Sceneform原生不支持自发光光照,因此尝试使用Filament的matc.exe编译自定义材质文件并加载到Thomas修改版Sceneform中,具体操作如下:

自定义材质代码

material {
    name : "Emissive Material",
    parameters : [
        {
           type : float4,
           name : emissive
        }
    ],  
    shadingModel : lit,
}

fragment {
    void material(inout MaterialInputs material) {
        prepareMaterial(material);        
        material.baseColor = materialParams.emissive; // *生效,但无周围光晕*
        material.emissive = materialParams.emissive; // *单独设置不生效*
        material.emissive = vec4(0,1,0,1000000); // *单独设置不生效*        
    }
}

编译命令

// 进入Filament的bin目录
matc -p all  -o  ../bloomMat/sceneform_bloom_t23.matc  ../bloomMat/sceneform_bloom.mat

加载材质的代码实现

ModelRenderable.builder()
.setSource(this,Uri.parse("https://.../my_glb_path.glb"))
.setIsFilamentGltf(true)
.build()
.thenAccept(
modelRenderable -> {
    renderable = modelRenderable;
    com.google.ar.sceneform.rendering.Material.builder()
    .setSource(getApplicationContext(),R.raw.sceneform_bloom_t23)
    .build()
    .thenAccept(new Consumer() {
        @Override
        public void accept(Material material) {
            material.setFloat4("emissive",1,0,0,1000000); // *不生效*
            renderable.setMaterial(material);
        }
    });
});

尝试sfa配置方案

我还按照sfa文档配置了gltf_material.sfm,编写的sfa文件如下:

{
  materials: [
    {
      name: 'unlit_material',
      parameters: [
             { baseColorFactor: [10,10,10,10], }, // *生效*
             { emissiveFactor: 2147483647, }, // *不生效*
             { emissive: 'andy', }, // *生效,但无自发光光晕*
             { opacity: null, },
             //{ reflectance: 0, },
           ],
      source: 'build/sceneform_sdk/default_materials/gltf_material.sfm',
    }
  ],
 model: {
    attributes: [ 'Position', 'TexCoord', 'Orientation', ],
    collision: {},
    file: 'sampledata/andy02/andy.obj',
    name: 'andy',
    recenter: 'root',
  },
  samplers: [
    {
     file: 'sampledata/andy02/andy.png',
     name: 'andy',
     pipeline_name: 'andy.png'
    }
  ],
  version: '0.54:2'
}

以上所有操作均未达到预期效果,模型始终没有bloom光晕。我知道SceneView支持自发光效果,但公司目前仍在使用Sceneform,期望实现类似示例图中中心绿色箭头的发光效果,请问如何让Sceneform中的emissive属性生效?


内容的提问来源于stack exchange,提问作者小蝦米

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 16:45:41