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

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

  • 相关阅读:
    spring 注解学习 一 Bean的注入
    jdk动态代理详解 二 代理失效
    jdk动态代理详解 一 入门
    tomcat中web应用的目录结构
    mongoose与mongodb 的版本兼容性表格
    树莓派3B安装ffmpeg过程记录
    ESP8266驱动SSD1306 ESP8266 for Arduino(NodeMCU U8G2库)
    ESP8266 for Arduino开发环境安装
    Mongodb3.4升张到4.0过程
    使用webgl(three.js)创建自动化抽象化3D机房,3D机房模块详细介绍(抽象版一)
  • 原文地址:https://www.cnblogs.com/Pointer/p/79580.html
Copyright © 2011-2022 走看看