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)
Projection matrix issue
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Projection matrix issue
 Attachments

 uneven 3dlib.zip
 (38.69 KiB) Downloaded 43 times
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 columnmajor, not rowmajor.
There is a multiple variants to resolve this priblem:
a) In shader:send use "column" parameter instead "row"
b) Use rowmajor perspective projection matrix:
c) Convert matrix from columnmajor to rowmajor like this:
And also need to change model position 10 units by zaxis to make sure it's in front of the camera
As expected problem was in my perspective matrix. It was columnmajor, not rowmajor.
There is a multiple variants to resolve this priblem:
a) In shader:send use "column" parameter instead "row"
b) Use rowmajor perspective projection matrix:
Code: Select all
function perspective_projection(fov, aspect, near, far)
local t = tan(rad(fov)/2)
return mat4(1/(aspect*t),0,0,0,
0,1/t,0,0,
0,0,(far+near)/(farnear),(2*far*near)/(farnear),
0,0,1,0)
end
Code: Select all
projection = columnToRow(projection:unpack())
shader:send("proj", projection)
function columnToRow(matrix)
 Column > Row major
if love._version_major > 0 then
matrix[2], matrix[5] = matrix[5], matrix[2]
matrix[3], matrix[9] = matrix[9], matrix[3]
matrix[4], matrix[13] = matrix[13], matrix[4]
matrix[7], matrix[10] = matrix[10], matrix[7]
matrix[8], matrix[14] = matrix[14], matrix[8]
matrix[12], matrix[15] = matrix[15], matrix[12]
end
return matrix
end
Who is online
Users browsing this forum: No registered users and 25 guests