Can you tell if a vertex attribute is enabled from within a vertex shader?

江枫思渺然 提交于 2019-11-29 14:05:56

No there isn't.

Pass a boolean uniform yourself to emulate it.

FYI:

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:

That is not true. If an attribute is disabled, its value comes from regular OpenGL state. Namely, the state set by the glVertexAttrib functions. So it is perfectly legal to have these kinds of "constant attributes" sent to shaders.

That's why the API doesn't have a way for a shader to tell if an attribute is "disabled". A "disabled" attribute may still have meaningful data.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!