## Projection matrix issue

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Papaew
Prole
Posts: 2
Joined: Fri Jan 25, 2019 9:00 pm

### Projection matrix issue

Hello! I'm trying to create simple 3d render engine, but i'm stuck on projection matrix.
I don't know why but it do not give a result (i tried several examples from different sources)
Can someone help me with it?

p.s. I use my own vector and matrix libraries. They are works fine (i guess)
Attachments
uneven 3dlib.zip

Papaew
Prole
Posts: 2
Joined: Fri Jan 25, 2019 9:00 pm

### Re: Projection matrix issue

Okay, some good people helped me on love's discord server (thank you again )

As expected problem was in my perspective matrix. It was column-major, not row-major.
There is a multiple variants to resolve this priblem:
b) Use row-major perspective projection matrix:

Code: Select all

function perspective_projection(fov, aspect, near, far)
return mat4(1/(aspect*t),0,0,0,
0,1/t,0,0,
0,0,-(far+near)/(far-near),-(2*far*near)/(far-near),
0,0,-1,0)
end

c) Convert matrix from column-major to row-major like this:

Code: Select all

projection = columnToRow(projection:unpack())

function columnToRow(matrix)
-- Column -> Row major
if love._version_major > 0 then
matrix, matrix = matrix, matrix
matrix, matrix = matrix, matrix
matrix, matrix = matrix, matrix
matrix, matrix = matrix, matrix
matrix, matrix = matrix, matrix
matrix, matrix = matrix, matrix
end
return matrix
end

And also need to change model position -10 units by z-axis to make sure it's in front of the camera
uneven 3dlib.zip
There is a fixed code here