android - ARCore Sceneform ChromaKeyVideo Sampleproject 如何使用视频功能
问题描述
我查看了最近发布的 ARCores Sceneform 示例项目ChromaKeyVideo。
我想使用该功能在我的 ar 场景中显示视频,但没有色度键功能。在示例项目中,他们使用纹理来抠出背景等。
但是我怎样才能将这个示例转换为只显示一个 .mp4 视频文件?目前我必须使用 OpenGL 渲染器的实现。使用 Sceneform 代替它会非常好。显然这是可能的。但我不知道我必须使用哪些材料才能显示一个可靠的视频。
那么如何更改此示例以仅显示没有色度键功能的完整视频?
解决方案
您可以创建仅使用外部纹理的新自定义材质。您可以在 sampledata/models 目录中创建一个新的 .mat 文件,名为externalTexture.mat
:
// Copyright 2018 Google LLC. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
material {
"name" : "Chroma Key Video Material",
"defines" : [
"baseColor"
],
"parameters" : [
{
// The texture displaying the frames of the video.
"type" : "samplerExternal",
"name" : "videoTexture"
}
],
"requires" : [
"position",
"uv0"
],
"shadingModel" : "unlit",
// Blending is "masked" instead of "transparent" so that the shadows account for the
// transparent regions of the video instead of just the shape of the mesh.
"blending" : "masked",
// Material is double sided so that the video is visible when walking behind it.
"doubleSided" : true
}
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
vec2 uv = getUV0();
if (!gl_FrontFacing) {
uv.x = 1.0 - uv.x;
}
material.baseColor = texture(materialParams_videoTexture, uv).rgba;
}
}
然后在您的 .sfa 文件中将材质源更改为 externalTexture.mat:
source: "sampledata/models/externalTexture.mat",
推荐阅读
- python - 连接两个不同维度的数组numpy
- discord - 如何使用 discord.js v12 制作模拟命令?
- python - 字符串变量的 Python3 可变性
- git - 如何在 github 操作中运行 git diff
- java - Java8 Lambda 函数分配异常
- javascript - 具有动态列范围的 Google 脚本中的第一个空行
- wordpress - bitnami/WordPress 图表 - 在自定义图像中嵌入上传
- python - 如果值相同,切片会给出不正确的结果
- installation - 如何在 Cygwin 上安装和使用 Lex?
- android - 自定义 SwipeToRefresh 移动 RecyclerView Android 嵌套滚动