gpt4 book ai didi

android - 在 arcore 中的 3d 对象上使用模板蒙版时出现问题

转载 作者:行者123 更新时间:2023-11-29 02:21:50 25 4
gpt4 key购买 nike

我正在使用 hello ar java 演示在 3d 对象上使用模板掩码,但是我遇到了一些意外行为。我的模板 mask 正确地遮挡了平面渲染器,但 3d 对象 (andy) 似乎没有预期的 react 。相反,他似乎被翻转了,如图所示。我不确定如何解决这个问题。附件是执行模板掩码的代码 fragment

模板图像在 FlatBuffers 上正确工作但在 3d 模型上失败

  GLES20.glClear ( GLES20.GL_STENCIL_BUFFER_BIT );
GLES20.glEnable(GLES20.GL_STENCIL_TEST);
GLES20.glColorMask(false, false, false, false);
GLES20.glDepthMask(false);
GLES20.glStencilFunc(GLES20.GL_NEVER, 1, 0xFF);
GLES20.glStencilOp(GLES20.GL_REPLACE, GLES20.GL_KEEP, GLES20.GL_KEEP);
GLES20.glStencilMask(0xFF);
GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);

// controls how pixels are rendered in the stencil mask
quadDrawer.draw();

GLES20.glColorMask(true, true, true, true);
GLES20.glDepthMask(true);
GLES20.glStencilMask(0xFF);
GLES20.glStencilFunc(GLES20.GL_EQUAL, 0, 0xFF);

// Visualize planes.
// reacts correctly to the stencil mask
planeRenderer.drawPlanes(
session.getAllTrackables(Plane.class), camera.getDisplayOrientedPose(), projmtx);

// Visualize anchors created by touch.
float scaleFactor = 1.0f;

for (ColoredAnchor coloredAnchor : anchors) {
if (coloredAnchor.anchor.getTrackingState() != TrackingState.TRACKING) {
continue;
}
// Get the current pose of an Anchor in world space. The Anchor pose is updated
// during calls to session.update() as ARCore refines its estimate of the world.
coloredAnchor.anchor.getPose().toMatrix(anchorMatrix, 0);

// Update and draw the model and its shadow.
// does not react correctly to the
virtualObject.updateModelMatrix(anchorMatrix, scaleFactor);
virtualObjectShadow.updateModelMatrix(anchorMatrix, scaleFactor);
virtualObject.draw(viewmtx, projmtx, colorCorrectionRgba, coloredAnchor.color);
virtualObjectShadow.draw(viewmtx, projmtx, colorCorrectionRgba, coloredAnchor.color);
}

GLES20.glDisable(GLES20.GL_STENCIL_TEST);

最佳答案

忘记更新我为此找到的“解决方案”。我没有在 3d 对象上应用模板蒙版,而是再次渲染背景,但将其传递通过模板蒙版。这意味着背景将覆盖 3d 对象,从而实现所需的“掩蔽”效果。

关于android - 在 arcore 中的 3d 对象上使用模板蒙版时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55118280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com