'texture2D':在Forward Compatibile上下文中删除了该功能

时间:2016-10-17 20:34:22

标签: c++ opengl glsl

我正在尝试使用public async Task<IActionResult> LawFirmDetails(Lawyer lawyer) and the href to: <a=href="~/Home/LawFirmDetails?lawyer=@info" class=header>First Name</a></th> 实现5x5卷积过滤器(查找边)这里是我的代码GLSL来源:

.glsl

当我运行我的代码时,它给了我错误:

#version 150
#define SIZE 25

// A texture is expected
uniform sampler2D Texture;

// The vertex shader fill feed this input
in vec2 FragTexCoord;

// The final color
out vec4 FragmentColor;

float matr[25];
float matg[25];
float matb[25];

vec4 get_pixel(in vec2 coords, in float x, in float y) {
   return texture2D(Texture, coords + vec2(x, y));
}

float convolve(in float[SIZE] kernel, in float[SIZE] matrix) {
   float res = 0.0;
   for (int i = 0; i < 25; i++)
      res += kernel[i] * matrix[i];
   return clamp(res, 0.0, 1.0);
}

void fill_matrix() {
   float dxtex = 1.0 / float(textureSize(Texture, 0));
   float dytex = 1.0 / float(textureSize(Texture, 0));
   float[25] mat;
   for (int i = 0; i < 5; i++)
      for(int j = 0; j < 5; j++) {
        vec4 pixel = get_pixel(FragTexCoord,float(i - 2) * dxtex, float(j - 2) * dytex);
         matr[i * 5 + j] = pixel[0];
         matg[i * 5 + j] = pixel[1];
         matb[i * 5 + j] = pixel[2];
      }
}

void main() {

  float[SIZE] ker_edge_detection = float[SIZE] (
    .0,.0, -1., .0, .0,
    .0, .0,-1., .0, .0,
    .0, .0, 4., .0, .0,
    .0, .0, -1., .0,.0,
    .0, .0, -1., .0, .0
  );

  fill_matrix();

  FragmentColor = vec4(convolve(ker_edge_detection,matr), convolve(ker_edge_detection,matg), convolve(ker_edge_detection,matb), 1.0);
}

奇怪的是,当我试图在其他Linux上运行代码然后在Windows机器上运行时,它运行正常。此外,当我在Error Compiling Fragment Shader ... ERROR: 0:17: 'texture2D' : function is removed in Forward Compatibile context ERROR: 0:17: 'texture2D' : no matching overloaded function found (using implicit conversion) Error Linking Shader Program ... Attached fragment shader is not compiled. Function is removed in Forward Compatibile context 函数中更改texture2D以返回get_pixel()时,它只会像魅力一样工作。有人可以解释问题出在哪里吗?

1 个答案:

答案 0 :(得分:6)

错误表示您需要知道的一切。 fit <- survfit(modform, data = ovarian) fit$call$formula # modform fit$call$formula <- modform fit$call$formula # Surv(futime, fustat) ~ rx fit # Call: survfit(formula = Surv(futime, fustat) ~ rx, data = ovarian) # # n events median 0.95LCL 0.95UCL # rx=1 13 7 638 268 NA # rx=2 13 5 NA 475 NA 是GLSL 1.00天的旧功能。它被移除并替换为texture2D,它使用函数重载来处理大多数采样器类型,而不是限制为texture。因此,在核心配置文件或向前兼容性上下文中,您无法调用sampler2D