如何让自发光属性在Sceneform中发挥作用?

问题描述 投票:0回答:1

所有的方法都试过了,连灯丝的代码都看过了,就是不知道为什么emissive属性在Sceneform里就不行了

文件

“自发光的主要用途是在 HDR 管道配置有光晕通道时强制未照亮的表面光晕。”

据我理解这句话,谷歌已经知道Sceneform不能有自发光

我尝试使用Filament matc.exe在Thomass修改的Sceneform上构建一个matc文件加载,原始mat文件是这样的:

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

fragment {
    void material(inout MaterialInputs material) {
        prepareMaterial(material);        
        material.baseColor = materialParams.emissive; // work,but no bloom light around.
        material.emissive = materialParams.emissive; // not work when only set it
        material.emissive = vec4(0,1,0,1000000); // not work when only set it        
    }
}

并使用 Filament matc.exe 构建:

//cd to my filament /bin

matc -p all  -o  ../bloomMat/sceneform_bloom_t23.matc  ../bloomMat/sceneform_bloom.mat

建一个sceneform_bloom_t23.matc文件,然后粘贴到raw目录下

并像这样使用它:

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); // not work 
            renderable.setMaterial(material);
        }
    });
});

模型没有绽放光

我也尝试使用sfa文档said,使用gltf_material.sfm并像这样编写sfa文件:

{
  materials: [
    {
      name: 'unlit_material',
      parameters: [
             { baseColorFactor: [10,10,10,10], }, // work
             { emissiveFactor: 2147483647, }, // not work
             { emissive: 'andy', }, // work ,but not have emissive Light.
             { 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'
}

还是不行。

我知道SceneView可以有发射光,但问题是我公司还在用Sceneform。

我期待的效果: image(发光的绿色箭头,在图片中心)

最后,我的问题是,如何让自发光属性在Sceneform上起作用?

这是我第二次发这个问题。在之前的版本里,我说了一些被禁止的话。

希望这个问题能得到解答,非常感谢

android augmented-reality sceneform google-filament
1个回答
0
投票

要使发光属性起作用,必须在灯丝视图上启用光晕。使用来自 google 的原始 sceneform 库,我认为这是不可能的,因为无法访问灯丝视图(不过也许可以通过反射来完成)。但是这个 repo 中的 sceneform 版本是可能的: https://github.com/SceneView/sceneform-android

Bloom 可以像这样启用(kotlin 代码):

val bloomOptions = com.google.android.filament.View.BloomOptions()
bloomOptions.enabled = true
scene!!.view.renderer!!.filamentView.bloomOptions = bloomOptions
© www.soinside.com 2019 - 2024. All rights reserved.