我想交换程序中使用的fragement-shader。片段着色器都具有相同的变量,只是不同的计算。我正在尝试为低级硬件提供替代着色器。webgl替换程序着色器
我最终得到单色输出(而不是纹理),有没有人有一个想法,我可能做错了什么?由于颜色相应改变,我知道着色器正在使用。
//if I don't do this:
//WebGL: INVALID_OPERATION: attachShader: shader attachment already has shader
gl.detachShader(program, _.attachedFS);
//select a random shader, all using the same parameters
attachedFS = fragmentShaders[~~(Math.qrand()*fragmentShaders.length)];
//attach the new shader
gl.attachShader(program, attachedFS);
//if I don't do this nothing happens
gl.linkProgram(program);
//if I don't add this line:
//globject.js:313 WebGL: INVALID_OPERATION: uniform2f:
//location not for current program
updateLocations();
您应该可以创建多个着色器程序,而不是更改现有着色器程序中的着色器。为您使用的每个功能组合创建着色器程序。 – gman