GLSL学习笔记 - 9.1 Transformation
转换顶点到裁减坐标系中的两种方式
转换顶点到眼坐标系中
转换法线到眼坐标系中
规格化法线
缩放法线
纹理坐标变换
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_Position = ftransform();
gl_Position = ftransform();
转换顶点到眼坐标系中
vec4 ecPosition;
vec3 ecPosition3; // in 3 space
// Transform vertex to eye coordinates
if (NeedEyePosition){
ecPosition = gl_ModelViewMatrix * gl_Vertex;
ecPosition3 = (vec3 (ecPosition)) / ecPosition.w;
}
vec3 ecPosition3; // in 3 space
// Transform vertex to eye coordinates
if (NeedEyePosition){
ecPosition = gl_ModelViewMatrix * gl_Vertex;
ecPosition3 = (vec3 (ecPosition)) / ecPosition.w;
}
转换法线到眼坐标系中
normal = gl_NormalMatrix * gl_Normal;
规格化法线
normal = normalize(normal);
缩放法线
normal = normal * gl_NormalScale;
纹理坐标变换
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;