Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix perspective matrix #59

Open
9551-Dev opened this issue Jul 18, 2023 · 0 comments
Open

fix perspective matrix #59

9551-Dev opened this issue Jul 18, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@9551-Dev
Copy link
Owner

which out the perspective matrix to use this topology

return function(aspectRatio,fov,nearPlane,farPlane)
    local fov_rad = math.rad(fov)
    local tan_half_fov = math.tan(fov_rad * 0.5)

    local A = 1 / (aspectRatio * tan_half_fov)
    local B = 1 / tan_half_fov
    local C = -(farPlane + nearPlane) / (farPlane - nearPlane)
    local D = -1
    local E = -(2 * farPlane * nearPlane) / (farPlane - nearPlane)

    return {
        A, 0, 0, 0,
        0, B, 0, 0,
        0, 0, C, D,
        0, 0, E, 0
    }
end

this should fix near and far fields

@9551-Dev 9551-Dev added the bug Something isn't working label Jul 18, 2023
@9551-Dev 9551-Dev self-assigned this Jul 18, 2023
@9551-Dev 9551-Dev added this to C3D Jul 18, 2023
@9551-Dev 9551-Dev moved this to Todo pipeline in C3D Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo pipeline
Development

No branches or pull requests

1 participant