Anonymous Anonymous - 3 months ago
202 0

No description

C++

GLM way of doing a perspective projection

T const tanHalfFovy = tan(fovy / static_cast<T>(2));
		
		tmat4x4<T, defaultp> Result(static_cast<T>(0));
		Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
		Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
		Result[2][3] = static_cast<T>(1);

#		if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE
			Result[2][2] = zFar / (zFar - zNear);
			Result[3][2] = -(zFar * zNear) / (zFar - zNear);
#		else
			Result[2][2] = (zFar + zNear) / (zFar - zNear);
			Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
#		endif

//MY VERSION OF THAT ^^
1 / (aspect * tanhalfFovy),       0.0, 0.0, 0.0
0.0,      1 / (tanHalfFovy),           0.0, 0.0, 
0.0, 0.0,  zFar / (zFar - zNear),           1.0,
0.0, 0.0, -(zFar * zNear) / (zFar - zNear), 0.0,