脚踏实地

心 勿噪

hlsl的 投影和view矩阵

float4x4 LookAtMatrix(float3 eyePosition, float3 lookAt, float3 up)
{
    float3 zaxis = normalize(lookAt - eyePosition);
    float3 yaxis = normalize(up);
    float3 xaxis = normalize(cross(yaxis, zaxis));
    yaxis = normalize(cross(zaxis, xaxis));
    
    float4x4 result = float4x4(xaxis.x, yaxis.x, zaxis.x, 0.0,
                               xaxis.y, yaxis.y, zaxis.y, 0.0,
                               xaxis.z, yaxis.z, zaxis.z, 0.0,
     -dot(xaxis, eyePosition), -dot(yaxis, eyePosition), -dot(zaxis, eyePosition), 1.0);
                   
    return result;
}
#define MATH_PI_DIV_180  0.0174532925
float4x4 DxPorjMatrix(float fov_y, float aspect, float zNear, float zFar)
{
    // Left Hand
    float f_n = 1.0f / (zFar - zNear);
    float yScale = 1.0 / tan(MATH_PI_DIV_180 * (fov_y) * 0.5f);
    float xScale = yScale / aspect;
    float4x4 result = float4x4(xScale, 0.0, 0.0, 0.0,
                               0.0, yScale, 0.0, 0.0,
                               0.0, 0.0, zFar*f_n, 1.0,
                               0.0, 0.0, -zNear * zFar * f_n, 1.0);
    return result;
}

biliner 插值

posted on 2015-10-24 10:38 LSH 阅读(479) 评论(0)  编辑 收藏 引用