我写纹理映射GLSL程序。 我有一个奇怪的问题。 从我的顶点着色器,我想通过纹理坐标VEC 2的变化对断枝着色器。 在同一个PROG差异着色和我一样的,它的工作。 但对于这个纹理它不工作。 如果我评论说行,然后一切正常。 我不知道为什么会这样。
这是顶点着色器:
attribute vec4 position;
attribute vec4 color1;
attribute vec4 normal;
attribute vec2 texCoord;
uniform mat4 model; //passed to shader
uniform mat4 projection; //passed to shader
uniform mat4 view; // passed to shader
uniform mat4 normalMatrix; //passed to shader
uniform mat4 worldNormalMatrix;
uniform vec3 eyePos;
varying vec4 pcolor;
varying vec3 fNormal;
varying vec3 v;
varying mat4 modelMat;
varying mat4 viewMat;
varying mat4 projectionMat;
varying vec2 texCoordinate;
varying vec3 reflector;
void main()
{
//texCoordinate = texCoord; // If I uncomment this, then I get wrong output. but the same thing works in a diff shader!!
mat4 projectionModelView;
vec4 N;
vec3 WorldCameraPosition = vec3(model*vec4(eyePos,1.0));
vec3 worldPos = vec3(model*position);
vec3 worldNorm = normalize(vec3(worldNormalMatrix*normal));
vec3 worldView = normalize(vec3(WorldCameraPosition-worldPos));
reflector = reflect(-worldView, worldNorm);
projectionMat = projection;
modelMat=model;
viewMat=view;
N=normalMatrix*normal;
fNormal = vec3(N); //need to multiply this with normal matrix
projectionModelView=projection*view*model;
v=vec3(view*model*position); // v is the position at eye space for each vertex passed to frag shader
gl_Position = projectionModelView * position; // calculate clip space position
}