Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

android - Rendering facemask from ARcore augmented faces meshes

I need to render a facemask using Filament. From ARcore Augmented Faces I have buffer for indices, vertices. Unfortunately rendered facemask is somehow corrupted. Take a look at that screenshot

I take meshes from the AugmentedFace object:

val meshVertices = face.meshVertices
val uvs = face.meshTextureCoordinates
val meshNormals = face.meshNormals
val meshIndices = face.meshTriangleIndices

Then I create vertices and index buffers:

faceVertexBuffer = VertexBuffer.Builder()
    .bufferCount(3)
    .vertexCount(468)
    .attribute(VertexBuffer.VertexAttribute.POSITION, 0, VertexBuffer.AttributeType.FLOAT3, 0, 3 * Float.SIZE_BYTES)
    .attribute(VertexBuffer.VertexAttribute.TANGENTS, 1, VertexBuffer.AttributeType.FLOAT3, 0,             3 * Float.SIZE_BYTES)
    .attribute(VertexBuffer.VertexAttribute.UV0, 2, VertexBuffer.AttributeType.FLOAT2, 0,             2 * Float.SIZE_BYTES)
    .build(filament.engine)
    
meshVertices.rewind()
meshNormals.rewind()
uvs.rewind()

faceVertexBuffer.setBufferAt(filament.engine, 0, meshVertices)
faceVertexBuffer.setBufferAt(filament.engine, 1, meshNormals)
faceVertexBuffer.setBufferAt(filament.engine, 2, uvs)

faceIndexBuffer = IndexBuffer.Builder()
    .indexCount(2694)
    .bufferType(IndexBuffer.Builder.IndexType.USHORT)
    .build(filament.engine)

meshIndices.rewind()
faceIndexBuffer.setBuffer(filament.engine, meshIndices)

and I render the object and add it to the scene:

RenderableManager.Builder(1)
.boundingBox(Box(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f))
.geometry(0, RenderableManager.PrimitiveType.TRIANGLES, faceVertexBuffer, faceIndexBuffer, 0, 468)
.material(0, materialInstance)
.build(filament.engine, faceRenderable)
filament.scene.addEntity(faceRenderable)

The facemask is well postioned, eyes, mouth on the place, but the texture is broken.

Any hints what am I missing?

question from:https://stackoverflow.com/questions/65884396/rendering-facemask-from-arcore-augmented-faces-meshes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...