您能否确定是否从顶点着色器中启用了顶点属性? [英] Can you tell if a vertex attribute is enabled from within a vertex shader?

查看:81
本文介绍了您能否确定是否从顶点着色器中启用了顶点属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以确定是否从顶点着色器中启用了顶点属性?我知道,如果禁用了vertex属性,则所有值都将被视为0.0,因此我可以进行如下测试:

I was wondering if there was a way to tell if a vertex attribute is enabled from within a vertex shader? I know that if the vertex attribute is disabled all the values will be treated as 0.0, so I could do a test like the following:

if (attribute == 0)
{
    // Do something different to normal.
}
else
{
    // Use the attribute.
}

但是对于启用该属性且该值仅设置为0(将其视为已禁用)的情况,这显然存在问题!

But this has the obvious problem for the case that the attribute is enabled and the value is just set to 0 (it will be treated as if it's disabled)!

另一种解决方案是只使用一个统一变量来声明是否使用该属性,但是我想知道GLSL中是否内置了可以做到这一点的东西?

The other solution would be to just use a uniform variable that states whether or not to use the attribute, but I wondered if there was anything built into GLSL that would do that?

推荐答案

没有.

自己传递布尔制服来模拟它.

Pass a boolean uniform yourself to emulate it.

这篇关于您能否确定是否从顶点着色器中启用了顶点属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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