且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

GLSL中的二阶函数?

更新时间:2021-07-25 16:12:12

我正在寻找一种将函数用作GLSL中另一个函数的参数的方法.

I'm looking for a way to use a function as an argument to another function in GLSL.

简短的回答:您不能.

您在GLSL中获得的与这种功能最接近的是 shader子例程.而且,这仅允许外部OpenGL API选择要使用的子例程,而不是着色器本身.

The closest thing to this kind of functionality you'll get in GLSL is shader subroutines. And that only allows the external OpenGL API to select which subroutine to use, not the shader itself.

所以只需执行switch/case语句并获得它即可.

So just do the switch/case statement and get it over with.