0

あなたの助けが必要です!頂点変換部分を cpu コードから頂点シェーダーに移動しようとしています。頂点変換の cpp コードは次のとおりです。

//calculate the transform matrix of a refelcting surface
//@point: a point on the surface
//@normal: the normalized normal of the surface
//@return: the transform matrix
glm::mat4 flatReflect(glm::vec3& point, glm::vec3& normal)
{
    glm::vec4 R = glm::vec4(point,1);
    glm::vec4 N = glm::vec4(normal,0);
    GLfloat d = glm::dot(R,N);
    glm::mat4 result;
    result[0][0] = 1 - 2* N.x*N.x;
    result[0][1] = -2*N.x*N.y;
    result[0][2] = -2*N.x*N.z;
    result[0][3] = -2*N.x*d;
    result[1][0] = result[0][1];
    result[1][1] = 1 - 2*N.y*N.y;
    result[1][2] = -2*N.y*N.z;
    result[1][3] = -2*N.y*d;
    result[2][0] = result[0][2];
    result[2][1] = result[1][2];
    result[2][2] = 1-2*N.z*N.z;
    result[2][3] = -2*N.z*d;
    result[3][0] = 0;
    result[3][1] = 0;
    result[3][2] = 0;
    result[3][3] = 1;
    return result;
}

何か案が?前もって感謝します!

4

1 に答える 1