zoukankan      html  css  js  c++  java
  • 不知道哪里有关于OGL Automatic TextureCoordinate Generation过程的详细说明

    仔细查阅了一下RedBook上关于自动纹理坐标生成的说明


    The GL_OBJECT_LINEAR function calculates the texture coordinates in the model's coordinate system. In Example 9-3 , where the contour lines are perpendicular to the base of the teapot, they would remain so, no matter how the teapot was rotated or viewed. Sometimes you'd like the contour lines to be calculated relative to the eye's coordinate system. In other words, you want to multiply the vector (p1p2p3p4) by the inverse of the modelview matrix before calculating the distance to the plane. If you specify GL_TEXTURE_GEN_MODE with GL_EYE_LINEAR, this is exactly what happens. The texture coordinate is generated with the following function:


    generated coordinate = p1'xe + p2'ye + p3'ze + p4'we

    where (p1' p2' p3' p4') = (p1p2p3p4)M-1


    In this case, (xe, ye, ze, we) are the eye coordinates of the vertex, and p1, ..., p4 are supplied as the param argument to glTexGen*() with pname set to GL_EYE_PLANE. The primed values are calculated only once, at the time they're specified, so this operation isn't as computationally expensive as it looks. To see the effect of this function, in the example above, change sgenparams back to {1, 0, 0, 0}, and change GL_OBJECT_LINEAR to GL_EYE_LINEAR. The result is red stripes parallel to the y-z plane from the eye's point of view, as shown in Figure J-25



    我使用的时候是:

    #ifdef AUTO_TEXTURE_COORD_GEN
        GLfloat eyePlaneS[] 
    = 1.00.00.00.0 };
        GLfloat eyePlaneT[] 
    = 0.01.00.00.0 };
        GLfloat eyePlaneR[] 
    = 0.00.01.00.0 };
        GLfloat eyePlaneQ[] 
    = 0.00.00.01.0 };
        glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
        glTexGenfv(GL_S, GL_EYE_PLANE, eyePlaneS);
        glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
        glTexGenfv(GL_T, GL_EYE_PLANE, eyePlaneT);
        glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
        glTexGenfv(GL_R, GL_EYE_PLANE, eyePlaneR);
        glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
        glTexGenfv(GL_Q, GL_EYE_PLANE, eyePlaneQ);
    #endif

    看起来固定渲染管线的做法同我的模拟做法是一样的。那么究竟是什么原因导致的扭曲呢?

  • 相关阅读:
    冲刺第二阶段第十天
    冲刺第二阶段第九天
    冲刺第二阶段第八天
    冲刺第二阶段第七天
    第十三周学习进度条
    冲刺第二阶段第六天
    第二冲刺阶段绩效评估
    Beta版总结会议
    Alpha版总结会议
    第二次冲刺阶段站立会议(十)
  • 原文地址:https://www.cnblogs.com/Pointer/p/79580.html
Copyright © 2011-2022 走看看