2

我在 GLSL 片段着色器中有一个子例程方法,它应该输出基于 sampler2D 的像素作为输入参数。程序无法使用此设置进行编译。但是,只要我只输出一种没有 texure2D() 计算的颜色,该方法就可以正常工作。是否有可能无法将 sampler2D 作为参数传递。我正在使用 OpenGL 4.2,GLSL 420

这是代码:

#version 420
subroutine vec4 RenderPass(sampler2D tex,vec2 uvsIn);
subroutine uniform RenderPass renderTechnique;
layout(binding=0)  uniform sampler2D colorMap;
smooth in vec2 uvsOut;

 ........ there rest of stuff

subroutine( RenderPass )
vec4 copyPass(sampler2D tex,vec2 uvsIn){


  return texture2D(tex,uvsIn);
  ////this however works ok : return vec4(1,0,0,1);

}

void main()
{

    outputColor = renderTechnique(colorMap,uvsOut);


}

更新:好的,感谢您的提示。我修复了着色器编译日志。现在我收到了这个程序错误:

: error C5208: Sampler needs to be a uniform (global or parameter to main), need to inline function or resolve conditional expression
4

0 回答 0