使用 Alpha 测试的 Opengl 选择 [英] Opengl Selection with Alpha Test

查看:36
本文介绍了使用 Alpha 测试的 Opengl 选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我在互联网上看到的情况来看,我的方法无法真正解决这个问题.

From what I've been seeing around the internet, this problem can't really be solved with my approach.

我目前正在编写一个程序,该程序使用选择缓冲区传递场景中的所有对象.但是,其中一个对象是一个纹理,其中很大一部分的 alpha 为 0.渲染时效果很好,不显示 alpha 值,但在选择模式下,跳过 alpha 测试,并将鼠标悬停在透明区域选择对象而不是它后面的任何东西.

I am currently writing a program that uses a selection buffer pass over all the objects in the scene. However, one of the objects is a texture in which a large part of it has alpha 0. It works fine when rendering, the alpha values are not displayed, but when in selection mode, the alpha test is skipped, and hovering the mouse over the transparent areas selects the object instead of whatever is behind it.

有没有办法在选择模式下启用 alpha 测试?

Is there any way to enable alpha testing in selection mode?

推荐答案

我认为您的意思是跳过了 alpha 混合.我还没有测试过,但从 here 的评论看来,alpha 测试仍然存在在 GL_SELECT 模式下使用.所以你会想要 glEnable(GL_ALPHA_TEST) 然后使用 glAlphaFunc() 来设置你的阈值有多少 alpha 构成一次命中.要在盲目尝试选择这些对象之前进行测试,只需渲染它.你会看到 OpenGL 只渲染多边形的一部分;并且该部分中的任何一个都将构成一次点击,而任何未绘制的部分都不会被您的 GL_SELECT 击中.

I think what you mean is the alpha blending is skipped. I haven't tested it, but it appears from the comment here, that alpha tests are still used in GL_SELECT mode. So you would want to glEnable(GL_ALPHA_TEST) and then use glAlphaFunc() to set your threshold for how much alpha constitutes a hit. To test before you just blindly try selecting these objects, just render it. You'll see that OpenGL only renders part of your polygon; and any of that part would constitute a click, while any of the not-drawn part won't be hit with your GL_SELECT.

请发表评论,让我知道它是如何工作的.如果你仍然不能让它工作,我可以花时间为你写一个测试用例,但如果你能自己让它工作,我宁愿不花时间.:)

Please comment and let me know how it works out. If you still can't get it to work, I can take the time to write a test case for you, but I'd rather not spend the time if you can get it to work on your own. :)

另外,作为参考,OpenGL 文档Alpha 测试手册页glAlphaFunc.

这篇关于使用 Alpha 测试的 Opengl 选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆