Mercurial > games > semicongine
comparison semiconginev2/core/matrix.nim @ 1257:e9b8d87b9883
fix: super stupid bug in perspective matrix X(
author | sam <sam@basx.dev> |
---|---|
date | Sun, 28 Jul 2024 18:55:46 +0700 |
parents | b0f4c8ccd49a |
children |
comparison
equal
deleted
inserted
replaced
1256:bfb75c934f4e | 1257:e9b8d87b9883 |
---|---|
442 makeRandomMatrixInit(TMat34) | 442 makeRandomMatrixInit(TMat34) |
443 makeRandomMatrixInit(TMat43) | 443 makeRandomMatrixInit(TMat43) |
444 makeRandomMatrixInit(TMat4) | 444 makeRandomMatrixInit(TMat4) |
445 | 445 |
446 func Perspective*(fovy, aspect, zNear, zFar: float32): Mat4 = | 446 func Perspective*(fovy, aspect, zNear, zFar: float32): Mat4 = |
447 let tanHalfFovy = tan(fovy / 2) | 447 let tanHalfFovy = 1 / tan(fovy / 2) |
448 return Mat4(data: [ | 448 return Mat4(data: [ |
449 1 / (aspect * tanHalfFovy), 0, 0, 0, | 449 tanHalfFovy / aspect, 0, 0, 0, |
450 0, 1 / tanHalfFovy, 0, 0, | 450 0, tanHalfFovy, 0, 0, |
451 0, 0, zFar / (zFar - zNear), -(zFar * zNear) / (zFar - zNear), | 451 0, 0, zFar / (zFar - zNear), -(zFar * zNear) / (zFar - zNear), |
452 0, 0, 1, 1, | 452 0, 0, 1, 0, |
453 ]) | 453 ]) |
454 | 454 |
455 func Ortho*(left, right, top, bottom, zNear, zFar: float32): Mat4 = | 455 func Ortho*(left, right, top, bottom, zNear, zFar: float32): Mat4 = |
456 Mat4(data: [ | 456 Mat4(data: [ |
457 2 / (right - left), 0, 0, -(right + left) / (right - left), | 457 2 / (right - left), 0, 0, -(right + left) / (right - left), |